Example usage for org.eclipse.jface.layout RowDataFactory swtDefaults

List of usage examples for org.eclipse.jface.layout RowDataFactory swtDefaults

Introduction

In this page you can find the example usage for org.eclipse.jface.layout RowDataFactory swtDefaults.

Prototype

public static RowDataFactory swtDefaults() 

Source Link

Document

Creates a new RowDataFactory initialized with the SWT defaults.

Usage

From source file:com.aptana.projects.wizards.ProjectTemplateSelectionPage.java

License:Open Source License

private void setSelectedTag(String tag) {
    tagsListViewer.removeSelectionChangedListener(tagSelectionChangedListener);
    tagsListViewer.setSelection(new StructuredSelection(tag));
    tagsListViewer.addSelectionChangedListener(tagSelectionChangedListener);
    // re-construct the list of templates shown on the right
    Control[] children = templatesListComposite.getChildren();
    for (Control templateControl : children) {
        templateControl.dispose();/*from w w  w .j a va  2  s  .  c o m*/
    }
    templateControlMap.clear();

    List<IProjectTemplate> templates = templateTagsMap.get(tag);
    Color background = templatesListComposite.getBackground();
    for (IProjectTemplate template : templates) {
        final Composite templateControl = new Composite(templatesListComposite, SWT.NONE);
        templateControl.setLayout(GridLayoutFactory.fillDefaults().extendedMargins(0, 0, 5, 5).create());
        templateControl.setLayoutData(RowDataFactory.swtDefaults().hint(95, SWT.DEFAULT).create());
        templateControl.setBackground(background);

        Label image = new Label(templateControl, SWT.CENTER);
        image.setImage(getImage(template));
        image.setBackground(background);
        image.setLayoutData(
                GridDataFactory.fillDefaults().grab(true, false).align(SWT.CENTER, SWT.CENTER).create());
        Label text = new Label(templateControl, SWT.CENTER | SWT.WRAP);
        text.setText(template.getDisplayName());
        text.setBackground(background);
        text.setLayoutData(
                GridDataFactory.fillDefaults().grab(true, true).align(SWT.CENTER, SWT.BEGINNING).create());

        MouseAdapter mouseAdapter = new MouseAdapter() {

            @Override
            public void mouseDown(MouseEvent e) {
                setSelectedTemplate(templateControlMap.get(templateControl));
            }

            @Override
            public void mouseDoubleClick(MouseEvent e) {
                // Treat double-click like selecting the template and clicking "Next"
                if (canFlipToNextPage()) {
                    getContainer().showPage(getNextPage());
                }
            }
        };
        templateControl.addMouseListener(mouseAdapter);
        image.addMouseListener(mouseAdapter);
        text.addMouseListener(mouseAdapter);

        templateControlMap.put(templateControl, template);
    }
    templatesListComposite.layout(true, true);
}

From source file:com.nokia.carbide.internal.discovery.ui.editor.TaskBar.java

License:Open Source License

private void createTitle(IActionBar actionBar) {
    Label l = new Label(this, SWT.LEFT);
    l.setFont(JFaceResources.getBannerFont());
    l.setBackground(l.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    l.setText(actionBar.getTitle());//from  w ww. j  ava2 s .com
    RowDataFactory.swtDefaults().applyTo(l);
    l = new Label(this, SWT.HORIZONTAL | SWT.SEPARATOR);
    RowDataFactory.swtDefaults().applyTo(l);
}

From source file:org.eclipse.koneki.ldt.ui.internal.preferences.LuaExecutionEnvironmentPreferencePage.java

License:Open Source License

@Override
protected Control createContents(Composite parent) {
    // ----------------
    // CREATE CONTROL
    // create container composite
    Composite containerComposite = new Composite(parent, SWT.NONE);
    GridLayoutFactory.swtDefaults().margins(0, 0).numColumns(2).applyTo(containerComposite);

    eeTreeViewer = new CheckboxTreeViewer(containerComposite,
            SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    eeTreeViewer.setContentProvider(new LuaExecutionEnvironmentContentProvider());
    eeTreeViewer.setLabelProvider(//from  ww  w .j a v a  2 s. com
            new DelegatingStyledCellLabelProvider(new LuaExecutionEnvironmentLabelProvider()));
    eeTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            refreshRemoveButton();
        }
    });
    GridDataFactory.fillDefaults().grab(true, true).applyTo(eeTreeViewer.getControl());

    // add a listener to allow only one default EE
    eeTreeViewer.addCheckStateListener(new ICheckStateListener() {
        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            LuaExecutionEnvironment defaultEE = (LuaExecutionEnvironment) event.getElement();
            if (event.getChecked()) {

                // allow to check only one element of the table
                eeTreeViewer.setCheckedElements(new Object[] { defaultEE });
                getPreferenceStore().setValue(PreferenceInitializer.EE_DEFAULT_ID, defaultEE.getEEIdentifier());

                // remove warning no default EE message if any
                setMessage(null);
            } else {

                // removing the default ee from pref
                getPreferenceStore().setValue(PreferenceInitializer.EE_DEFAULT_ID, "none"); //$NON-NLS-1$
                setMessage(Messages.LuaExecutionEnvironmentPreferencePage_warning_nodefault, WARNING);
            }
        }
    });

    // create buttons
    Composite buttonsComposite = new Composite(containerComposite, SWT.NONE);
    GridDataFactory.fillDefaults().applyTo(buttonsComposite);
    RowLayoutFactory.fillDefaults().type(SWT.VERTICAL).fill(true).applyTo(buttonsComposite);

    // Add
    Button addButton = new Button(buttonsComposite, SWT.None);
    RowDataFactory.swtDefaults().hint(SWTUtil.getButtonWidthHint(addButton), -1).applyTo(addButton);
    addButton.setText(Messages.LuaExecutionEnvironmentPreferencePage_addbutton);

    // Remove
    removeButton = new Button(buttonsComposite, SWT.None);
    RowDataFactory.swtDefaults().hint(SWTUtil.getButtonWidthHint(removeButton), -1).applyTo(removeButton);
    removeButton.setText(Messages.LuaExecutionEnvironmentPreferencePage_removeButton);

    // Link to available EEs
    Link availableEELink = new Link(containerComposite, SWT.NONE);
    availableEELink.setText(Messages.LuaExecutionEnvironmentPreferencePage_availableEELink);
    GridDataFactory.fillDefaults().span(2, 1).applyTo(availableEELink);

    // ----------------
    // ADD LISTENERS
    addButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            doAddButtonSelection(e);
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    removeButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        @Override
        public void widgetDefaultSelected(final SelectionEvent e) {
            doRemoveSelection(e);
        }
    });
    availableEELink.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            try {
                PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser()
                        .openURL(new URL(AVAILABLE_EXECUTION_ENVIRONEMENT_URL));
            } catch (PartInitException e1) {
                Activator.logError("Unable to open: " + AVAILABLE_EXECUTION_ENVIRONEMENT_URL, e1); //$NON-NLS-1$
            } catch (MalformedURLException e1) {
                Activator.logError("Unable to open: " + AVAILABLE_EXECUTION_ENVIRONEMENT_URL, e1); //$NON-NLS-1$
            }
        }
    });

    // add a listener to activities which can hide EE to refresh the UI
    activitiesWatched = LuaExecutionEnvironmentUIManager.addListenerToEERelatedActivity(activityListener);

    // ----------------
    // Initialize UI
    initializePage();
    return containerComposite;
}

From source file:org.eclipse.nebula.widgets.suggestbox.SuggestBox.java

License:Open Source License

private void createWidgets() {
    //      GridLayoutFactory.fillDefaults().numColumns(2).applyTo(this);
    boxComposite = new Composite(this, SWT.NONE);
    RowLayout rowLayout = new RowLayout();
    rowLayout.marginTop = 2;// w w  w .j a  v a 2  s  . c o m
    rowLayout.marginBottom = 2;
    rowLayout.marginLeft = 2;
    rowLayout.marginRight = 2;
    rowLayout.spacing = LayoutConstants.getSpacing().x;
    boxComposite.setLayout(rowLayout);
    boxComposite.setVisible(false);
    //      GridDataFactory.fillDefaults().exclude(true).applyTo(boxComposite);
    RowDataFactory.swtDefaults().exclude(true).applyTo(boxComposite);
    text = new Text(this, SWT.SINGLE);
    text.setFont(resourceManager.createFont(getFontDescriptor()));
    text.setBackground(getDisplay().getSystemColor(SWT.COLOR_WHITE));
    RowDataFactory.swtDefaults().hint(150, SWT.DEFAULT).applyTo(text);
    //      GridDataFactory.fillDefaults().grab(true, false).applyTo(text);
    RowLayoutFactory.fillDefaults().spacing(LayoutConstants.getSpacing().x).applyTo(this);
}

From source file:org.eclipse.reddeer.swt.test.impl.menu.AbstractMenuTest.java

License:Open Source License

@Before
public void createMenus() {
    Display.syncExec(new Runnable() {

        @Override//from   w ww.ja v  a 2s.co m
        public void run() {
            swtShell = new Shell();
            swtShell.setMenuBar(getShellMenuBar(swtShell));
            swtShell.setMenu(getShellContextMenu(swtShell));
            swtShell.setText(SHELL_TEXT);

            tree = new Tree(swtShell, SWT.SINGLE);

            ToolBar toolbar = new ToolBar(swtShell, SWT.FLAT);
            ToolItem toolItem = new ToolItem(toolbar, SWT.DROP_DOWN);
            toolItem.setToolTipText("toolItemMenu");

            ToolItem toolItem1 = new ToolItem(toolbar, SWT.PUSH);
            toolItem1.setToolTipText("genericToolItem");

            DropdownSelectionListener dropdownListener = new DropdownSelectionListener(toolItem);
            dropdownListener.add("ToolItemMenuItem1");
            dropdownListener.add("ToolItemMenuItem2");
            dropdownListener.add("ToolItemMenuItem3");
            toolItem.addSelectionListener(dropdownListener);

            RowDataFactory.swtDefaults().applyTo(toolbar);

            TreeItem item = new TreeItem(tree, SWT.NONE);
            item.setText("TreeItem1");

            TreeItem item2 = new TreeItem(tree, SWT.NONE);
            item2.setText("TreeItem2");

            tree.setMenu(getTreeMenu(tree));

            text = new Text(swtShell, 0);
            text.setText("Test");
            text.setSize(100, 100);

            RowLayoutFactory.fillDefaults().applyTo(swtShell);
            RowDataFactory.swtDefaults().applyTo(tree);
            RowDataFactory.swtDefaults().applyTo(text);

            swtShell.layout();
            swtShell.open();

        }
    });

    shell = new DefaultShell(SHELL_TEXT);
}

From source file:org.polymap.p4.process.ModuleProcessPanel.java

License:Open Source License

protected Composite createButtonsSection() {
    Composite section = tk().createComposite(parent);
    section.setLayout(//from  www.  j av  a 2  s . c o m
            RowLayoutFactory.fillDefaults().spacing(8).margins(2, 2).fill(true).justify(true).create());

    startBtn = tk().createButton(section, "", SWT.PUSH);
    startBtn.setLayoutData(RowDataFactory.swtDefaults().hint(150, SWT.DEFAULT).create());
    startBtn.addSelectionListener(UIUtils.selectionListener(ev -> {
        if (job == null) {
            startProcess();
        } else {
            stopProcess();
            //startBtn.setEnabled( false );
        }
    }));
    updateStartBtn();
    return section;
}

From source file:org.polymap.p4.process.ProcessModulePanel.java

License:Open Source License

protected Composite createButtonsSection() {
    Composite section = tk().createComposite(parent);
    section.setLayout(/*  ww w .j a  v  a2s . c  o m*/
            RowLayoutFactory.fillDefaults().spacing(8).margins(2, 3).fill(true).justify(true).create());

    startBtn = tk().createButton(section, "", SWT.PUSH);
    startBtn.setLayoutData(RowDataFactory.swtDefaults().hint(150, SWT.DEFAULT).create());
    startBtn.addSelectionListener(UIUtils.selectionListener(ev -> {
        if (bgjob.get().state() != State.RUNNING) {
            startProcess();
        } else {
            stopProcess();
        }
    }));
    updateStartBtn();
    return section;
}

From source file:org.robotframework.ide.eclipse.main.plugin.launch.tabs.TagsComposite.java

License:Apache License

private void createDefinitionText() {
    tagNameText = new Text(this, SWT.BORDER);
    RowDataFactory.swtDefaults().hint(60, 17).applyTo(tagNameText);
    tagNameText.addKeyListener(new KeyAdapter() {
        @Override/*from ww  w  .  j  ava  2s  .co m*/
        public void keyReleased(final KeyEvent e) {
            if (e.character == SWT.CR) {
                addTag();
            }
        }
    });
    tagNameText.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(final ModifyEvent e) {
            listener.newTagIsEdited();
        }
    });
    tagsSupport.install(tagNameText);
}

From source file:org.robotframework.ide.eclipse.main.plugin.launch.tabs.TagsComposite.java

License:Apache License

private Composite createTagControlFor(final String tag) {
    final Composite newTag = new Composite(this, SWT.BORDER);
    newTag.setBackground(getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
    newTag.setBackgroundMode(SWT.INHERIT_FORCE);
    RowDataFactory.swtDefaults().applyTo(newTag);
    GridLayoutFactory.fillDefaults().numColumns(2).spacing(1, 0).applyTo(newTag);

    final CLabel newTagLabel = new CLabel(newTag, SWT.NONE);
    newTagLabel.setImage(ImagesManager.getImage(RedImages.getTagImage()));
    newTagLabel.setText(tag);/*from   w  w w  .j av  a 2s .  co  m*/
    GridDataFactory.fillDefaults().hint(SWT.DEFAULT, 20).applyTo(newTagLabel);

    final Button newTagRemoveBtn = new Button(newTag, SWT.PUSH);
    newTagRemoveBtn.setImage(ImagesManager.getImage(RedImages.getRemoveTagImage()));
    newTagRemoveBtn.setToolTipText("Remove tag");
    GridDataFactory.fillDefaults().hint(18, 16).applyTo(newTagRemoveBtn);
    newTagRemoveBtn.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {
            removeTag(tag);
        }
    });
    return newTag;
}

From source file:org.robotframework.ide.eclipse.main.plugin.launch.tabs.TagsComposite.java

License:Apache License

private void createAddingButton() {
    addTagButton = new Button(this, SWT.PUSH);
    addTagButton.setImage(ImagesManager.getImage(RedImages.getAddImage()));
    addTagButton.setToolTipText("Add new tag");
    RowDataFactory.swtDefaults().hint(22, 22).applyTo(addTagButton);
    addTagButton.addSelectionListener(new SelectionAdapter() {
        @Override// w ww  . j a  va 2 s.c  o m
        public void widgetSelected(final SelectionEvent e) {
            addTag();
        }
    });
}