List of usage examples for org.eclipse.jface.layout RowLayoutFactory fill
public RowLayoutFactory fill(boolean fill)
From source file:com.eclipsesource.tabris.demos.entrypoints.ScrollDemo.java
License:Open Source License
private ScrollingComposite createScrollingComposite(Display display, Composite parent, int scrollStyle) { final ScrollingComposite scrollableParent = new ScrollingComposite(parent, scrollStyle); int layoutStyle = scrollStyle == SWT.V_SCROLL ? SWT.VERTICAL : SWT.HORIZONTAL; scrollableParent/*w ww .j a va 2s . c o m*/ .setLayout(RowLayoutFactory.fillDefaults().type(layoutStyle).wrap(false).fill(true).create()); scrollableParent.setLayoutData( GridDataFactory.fillDefaults().grab(true, true).align(SWT.CENTER, SWT.FILL).create()); scrollableParent.setBackground(new Color(display, 255, 255, 255)); return scrollableParent; }
From source file:org.chrysalix.eclipse.focustree.FocusTree.java
License:Open Source License
/** * @param parent//from w w w. ja v a 2s . c o m * parent composite * @param closable * <code>true</code> if this tree can be closed by the user * @param root * the root of this tree * @param model * the model for this tree */ @SuppressWarnings("unused") public FocusTree(final Composite parent, final boolean closable, final Object root, final Model model) { super(parent, SWT.NONE); this.root = root; this.model = model; ((FillLayout) parent.getLayout()).type = SWT.VERTICAL; GridLayoutFactory.fillDefaults().spacing(0, 0).applyTo(this); // Construct pop-up menu final Menu popup = new Menu(getShell(), SWT.POP_UP); setMenu(popup); final MenuItem collapseAllMenuItem = new MenuItem(popup, SWT.PUSH); collapseAllMenuItem.setText(EclipseI18n.focusTreeCollapseAllMenuItem.text()); collapseAllMenuItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { focusTreeCanvas.collapseAllSelected(); } }); final MenuItem duplicateMenuItem = new MenuItem(popup, SWT.PUSH); duplicateMenuItem.setText(EclipseI18n.focusTreeDuplicateMenuItem.text()); duplicateMenuItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { duplicate(root); } }); iconViewMenuItem = new MenuItem(popup, SWT.PUSH); iconViewMenuItem.setText(EclipseI18n.focusTreeShowIconViewMenuItem.text()); addMenuDetectListener(new MenuDetectListener() { @Override public void menuDetected(final MenuDetectEvent event) { if (focusTreeCanvas.iconViewShown()) { iconViewMenuItem.setText(EclipseI18n.focusTreeHideIconViewMenuItem.text()); return; } iconViewMenuItem.setText(EclipseI18n.focusTreeShowIconViewMenuItem.text()); final Control control = getDisplay().getCursorControl(); Column column = null; if (control instanceof FocusTreeCanvas) for (final Column col : columns) { if (col.bounds.contains(event.x, event.y)) { column = col; break; } } else column = (Column) control.getData(COLUMN_PROPERTY); iconViewMenuItem.setEnabled(column != null); iconViewMenuItem.setData(COLUMN_PROPERTY, column); } }); iconViewMenuItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { toggleIconView((Column) iconViewMenuItem.getData(COLUMN_PROPERTY)); } }); new MenuItem(popup, SWT.SEPARATOR); final MenuItem copyPathMenuItem = new MenuItem(popup, SWT.PUSH); copyPathMenuItem.setText(EclipseI18n.focusTreeCopyPathMenuItem.text()); // // Construct zoom slider // final Composite sliderPanel = new Composite( toolBar, SWT.BORDER ); // GridDataFactory.swtDefaults().applyTo( sliderPanel ); // GridLayoutFactory.fillDefaults().applyTo( sliderPanel ); // final Slider zoomSlider = new Slider( sliderPanel, SWT.NONE ); // zoomSlider.setSelection( 50 ); // zoomSlider.setThumb( 1 ); // zoomSlider.setToolTipText( EclipseI18n.focusTreeZoomToolTip.text() ); // // Construct search field // final Text searchText = new Text( toolBar, SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL ); // GridDataFactory.swtDefaults().align( SWT.FILL, SWT.CENTER ).grab( true, false ).applyTo( searchText ); // searchText.setToolTipText( EclipseI18n.focusTreeSearchToolTip.text() ); // Construct path bar final Composite pathBar = new Composite(this, SWT.NONE); GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(pathBar); GridLayoutFactory.fillDefaults().numColumns(5).applyTo(pathBar); ToolBar subToolBar = new ToolBar(pathBar, SWT.NONE); final SelectionAdapter copyPathSelectionListener = new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { final TextTransfer textTransfer = TextTransfer.getInstance(); final StringBuilder path = new StringBuilder(); for (final Control control : pathButtonBar.getChildren()) path.append('/').append(((Label) control).getText()); CLIPBOARD.setContents(new Object[] { path.toString() }, new Transfer[] { textTransfer }); } }; newToolBarButton(subToolBar, SWT.PUSH, "copy.gif", EclipseI18n.focusTreeCopyPathToolTip, copyPathSelectionListener); copyPathMenuItem.addSelectionListener(copyPathSelectionListener); leftPathBarButton = new Label(pathBar, SWT.NONE); final int arrowSize = leftPathBarButton.computeSize(SWT.DEFAULT, SWT.DEFAULT).y * 2 / 3; leftPathBarButton.setImage(newArrowImage(arrowSize, true)); leftPathBarButton.setToolTipText(EclipseI18n.focusTreePreviousPathButtonToolTip.text()); leftPathBarButton.setVisible(false); pathButtonBar = new Composite(pathBar, SWT.NONE); GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(pathButtonBar); RowLayoutFactory.fillDefaults().fill(true).wrap(false).applyTo(pathButtonBar); rightPathBarButton = new Label(pathBar, SWT.NONE); rightPathBarButton.setImage(newArrowImage(arrowSize, false)); rightPathBarButton.setVisible(false); rightPathBarButton.setToolTipText(EclipseI18n.focusTreeNextPathButtonToolTip.text()); leftPathBarButton.addMouseListener(new MouseAdapter() { @Override public void mouseUp(final MouseEvent event) { if (leftMouseButtonClicked(event)) scrollPathBarLeft(); } }); rightPathBarButton.addMouseListener(new MouseAdapter() { @Override public void mouseUp(final MouseEvent event) { if (leftMouseButtonClicked(event)) scrollPathBarRight(); } }); pathButtonBar.addListener(SWT.Resize, new Listener() { @Override public void handleEvent(final Event event) { // Show all path buttons final Control[] pathButtons = pathButtonBar.getChildren(); for (final Control pathButton : pathButtons) { pathButton.setVisible(true); ((RowData) pathButton.getLayoutData()).exclude = false; } // Hide first shown path button on left until all buttons fit in button bar hideExcessiveLeftMostPathButtons(); } }); subToolBar = new ToolBar(pathBar, SWT.NONE); if (closable) { final SelectionAdapter closeSelectionListener = new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { final Composite parent = getParent(); dispose(); parent.layout(); } }; newToolBarButton(subToolBar, SWT.PUSH, "close.gif", EclipseI18n.focusTreeCloseTreeToolTip, closeSelectionListener); new MenuItem(popup, SWT.SEPARATOR); final MenuItem closeMenuItem = new MenuItem(popup, SWT.PUSH); closeMenuItem.setText(EclipseI18n.focusTreeCloseTreeMenuItem.text()); closeMenuItem.addSelectionListener(closeSelectionListener); } // Construct horizontally-scrolling diagram area scroller = new ScrolledComposite(this, SWT.H_SCROLL | SWT.V_SCROLL); GridDataFactory.fillDefaults().grab(true, true).applyTo(scroller); scroller.setExpandVertical(true); scroller.setExpandHorizontal(true); scroller.setBackgroundMode(SWT.INHERIT_FORCE); // Construct canvas with header headeredCanvas = new Composite(scroller, SWT.NONE); GridLayoutFactory.fillDefaults().spacing(0, 0).applyTo(headeredCanvas); scroller.setContent(headeredCanvas); scroller.setBackground(getDisplay().getSystemColor(SWT.COLOR_WHITE)); // Construct header bar headerBar = new Composite(headeredCanvas, SWT.NONE); GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(headerBar); GridLayoutFactory.fillDefaults().spacing(0, 0).numColumns(0).applyTo(headerBar); // Construct inner canvas focusTreeCanvas = new FocusTreeCanvas(this, headeredCanvas, SWT.BORDER | SWT.DOUBLE_BUFFERED); GridDataFactory.fillDefaults().grab(true, true).applyTo(focusTreeCanvas); focusTreeCanvas.addMouseTrackListener(new MouseTrackAdapter() { @Override public void mouseExit(final MouseEvent event) { focusTreeCanvas.toolBar.setVisible(false); } @Override public void mouseHover(final MouseEvent event) { final Point origin = scroller.getOrigin(); if (!focusTreeCanvas.iconViewShown() && event.x - origin.x < focusTreeCanvas.toolBar.getSize().width) { focusTreeCanvas.moveToolBar(origin.x); focusTreeCanvas.toolBar.setVisible(true); } else focusTreeCanvas.toolBar.setVisible(false); } }); addListener(SWT.Resize, new Listener() { @Override public void handleEvent(final Event event) { if (focusTreeCanvas.iconViewShown()) focusTreeCanvas.updateIconViewBounds(); else focusTreeCanvas.updateBounds(); } }); initialize(); }
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(/* w ww.j a v a 2s .c om*/ 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.modeshape.modeler.eclipse.FocusTree.java
License:Open Source License
/** * {@inheritDoc}/*from w w w . j av a2s .c om*/ * * @see org.modeshape.modeler.ui.FocusTreeView#constructPathButtonBar() */ @Override public void constructPathButtonBar() { pathButtonBar = new Composite(pathBar, SWT.NONE); GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(pathButtonBar); RowLayoutFactory.fillDefaults().fill(true).wrap(false).applyTo(pathButtonBar); pathButtonBar.addListener(SWT.Resize, new Listener() { @Override public void handleEvent(final Event event) { controller.pathBarResized(); } }); }
From source file:org.polyglotter.eclipse.TreeSpinner.java
License:Open Source License
/** * @param parent// w w w . j ava2s. co m * parent composite */ public TreeSpinner(final Composite parent) { super(parent, SWT.NONE); GridLayoutFactory.fillDefaults().numColumns(4).applyTo(this); ((GridLayout) getLayout()).verticalSpacing = 0; // Construct left tool bar // TODO i18n ToolBar toolBar = new ToolBar(this, SWT.NONE); newToolBarButton(toolBar, SWT.PUSH, "home.gif", "Scroll to root column"); newToolBarButton(toolBar, SWT.PUSH, "add.gif", "Add item below focus line of selected column"); newToolBarButton(toolBar, SWT.PUSH, "delete.gif", "Delete item from focus line of selected column"); newToolBarButton(toolBar, SWT.PUSH, "collapseall.gif", "Collapse all columns below root column"); newToolBarButton(toolBar, SWT.PUSH, "icons.gif", "View only the selected column as thumbnails"); newToolBarButton(toolBar, SWT.PUSH, "duplicate.gif", "Create a clone below this tree"); newToolBarButton(toolBar, SWT.CHECK, "sync.gif", "Link with other views"); newToolBarButton(toolBar, SWT.PUSH, "rotate.gif", "Rotate tree 90"); // Construct zoom slider final Composite sliderPanel = new Composite(this, SWT.BORDER); GridDataFactory.swtDefaults().applyTo(sliderPanel); GridLayoutFactory.fillDefaults().applyTo(sliderPanel); final Slider slider = new Slider(sliderPanel, SWT.NONE); slider.setSelection(50); slider.setThumb(1); slider.setToolTipText("Zoom view in or out"); // Construct search field final Text text = new Text(this, SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL); GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(text); text.setToolTipText("Search for items in or below this tree's root"); // Construct right tool bar toolBar = new ToolBar(this, SWT.NONE); GridDataFactory.swtDefaults().applyTo(toolBar); newToolBarButton(toolBar, SWT.PUSH, "close.gif", "Close this tool bar (Reopen using context menu)"); // Construct path bar final Composite pathBar = new Composite(this, SWT.BORDER); GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(4, 1).applyTo(pathBar); GridLayoutFactory.fillDefaults().margins(LayoutConstants.getSpacing().x, 0).numColumns(3).applyTo(pathBar); this.pathButtonBar = new Composite(pathBar, SWT.NONE); RowLayoutFactory.fillDefaults().fill(true).wrap(false).applyTo(this.pathButtonBar); toolBar = new ToolBar(pathBar, SWT.NONE); newToolBarButton(toolBar, SWT.PUSH, "copy.gif", "Copy the path of the selected column to the clipboard"); toolBar = new ToolBar(pathBar, SWT.NONE); GridDataFactory.swtDefaults().align(SWT.END, SWT.CENTER).grab(true, false).applyTo(toolBar); newToolBarButton(toolBar, SWT.PUSH, "close.gif", "Close this path bar (Reopen using context menu)"); // Construct scrolling diagram area this.scroller = new ScrolledComposite(this, SWT.H_SCROLL | SWT.V_SCROLL); GridDataFactory.fillDefaults().grab(true, true).span(4, 1).applyTo(this.scroller); this.scroller.setExpandVertical(true); // Construct outer canvas this.outerCanvas = new Composite(this.scroller, SWT.NONE); // GridDataFactory.fillDefaults().grab( true, true ).applyTo( outerCanvas ); GridLayoutFactory.fillDefaults().spacing(0, 0).applyTo(this.outerCanvas); this.scroller.setContent(this.outerCanvas); // Construct header bar this.headerBar = new Composite(this.outerCanvas, SWT.NONE); GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(this.headerBar); GridLayoutFactory.fillDefaults().spacing(0, 0).numColumns(0).applyTo(this.headerBar); // Construct inner canvas this.innerCanvas = new TreeCanvas(this, this.outerCanvas, SWT.NONE); GridDataFactory.fillDefaults().grab(true, true).applyTo(this.innerCanvas); }
From source file:org.polymap.p4.process.ModuleProcessPanel.java
License:Open Source License
protected Composite createButtonsSection() { Composite section = tk().createComposite(parent); section.setLayout(//from w w w. j a v 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 . ja v a 2s . 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
TagsComposite(final Composite parent, final TagsProposalsSupport tagsSupport, final TagsListener listener) { super(parent, SWT.NONE); this.listener = listener; this.tagComposites = new LinkedHashMap<>(); this.tagsSupport = tagsSupport; RowLayoutFactory.fillDefaults().fill(true).type(SWT.HORIZONTAL).spacing(2).wrap(true).applyTo(this); createTagsControls(new ArrayList<String>()); createDefinitionText();//from w w w . ja v a2s. c o m createAddingButton(); }
From source file:org.robotframework.ide.eclipse.main.plugin.search.RedSearchPage.java
License:Apache License
private void createSearchInGroup(final Composite parent) { final Group searchInGroup = new Group(parent, SWT.NONE); searchInGroup.setText("Search in"); GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(searchInGroup); RowLayoutFactory.fillDefaults().type(SWT.HORIZONTAL).fill(true).margins(5, 3).applyTo(searchInGroup); for (final SearchTarget target : newArrayList(SearchTarget.SUITE, SearchTarget.RESOURCE, SearchTarget.STANDARD_LIBRARY, SearchTarget.REFERENCED_LIBRARY, SearchTarget.VARIABLE_FILE)) { targetsButtons.put(target, new Button(searchInGroup, SWT.CHECK)); targetsButtons.get(target).setText(target.getLabel()); targetsButtons.get(target).addSelectionListener(new SelectionAdapter() { @Override//from w w w .j a v a 2 s . c o m public void widgetSelected(final SelectionEvent e) { searchContainer.setPerformActionEnabled(searchCanBePerformed()); } }); } }