Example usage for org.eclipse.jface.layout RowLayoutFactory fillDefaults

List of usage examples for org.eclipse.jface.layout RowLayoutFactory fillDefaults

Introduction

In this page you can find the example usage for org.eclipse.jface.layout RowLayoutFactory fillDefaults.

Prototype

public static RowLayoutFactory fillDefaults() 

Source Link

Document

Creates a RowLayoutFactory that creates RowLayouts with no margins, fill behavior, and default dialog spacing.

Usage

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//from w ww .  j  a  va 2  s.c om
            .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:com.eclipsesource.tabris.demos.entrypoints.VideoDemo.java

License:Open Source License

private void hookControlsAndVideo(final Video video, Composite controls) {
    controls.setLayout(RowLayoutFactory.fillDefaults().create());
    final Button playButton = createPlayButton(video, controls);
    final Button pauseButton = createPauseButton(video, controls);
    final Button stopButton = createStopButton(video, controls);
    final Button backwardButton = createBackwardButton(video, controls);
    final Button forwardButton = createForwardButton(video, controls);
    final Button fullscreenButton = createFullscreenButton(video, controls);
    createShowControlsButton(video, controls);
    createRepeatButton(video, controls);
    pauseButton.setEnabled(false);//from w  w  w  . ja  va2  s .co  m
    stopButton.setEnabled(false);
    video.addPresentationListener(new PresentationListener() {

        public void presentationChanged(Presentation newMode) {
            if (newMode == Presentation.EMBEDDED) {
                fullscreenButton.setEnabled(true);
            } else {
                fullscreenButton.setEnabled(false);
            }
        }
    });
    video.addPlaybackListener(new PlaybackListener() {

        public void playbackChanged(Playback newMode) {
            if (newMode == Playback.PLAY) {
                playButton.setEnabled(false);
                pauseButton.setEnabled(true);
                stopButton.setEnabled(true);
                forwardButton.setEnabled(true);
                backwardButton.setEnabled(true);
            } else if (newMode == Playback.PAUSE || newMode == Playback.STOP) {
                playButton.setEnabled(true);
                pauseButton.setEnabled(false);
                stopButton.setEnabled(false);
                forwardButton.setEnabled(true);
                backwardButton.setEnabled(true);
            } else if (newMode == Playback.FAST_FORWARD) {
                playButton.setEnabled(true);
                pauseButton.setEnabled(true);
                stopButton.setEnabled(true);
                forwardButton.setEnabled(false);
                backwardButton.setEnabled(true);
            } else if (newMode == Playback.FAST_BACKWARD) {
                playButton.setEnabled(true);
                pauseButton.setEnabled(true);
                stopButton.setEnabled(true);
                forwardButton.setEnabled(true);
                backwardButton.setEnabled(false);
            }
        }
    });
}

From source file:de.akra.idocit.ui.composites.DocumentItemComposite.java

License:Apache License

@Override
protected void initGUI(Composite pvParent) throws CompositeInitializationException {
    GridLayoutFactory.fillDefaults().numColumns(2).applyTo(this);
    GridDataFactory.fillDefaults().grab(true, true).minSize(MIN_WIDTH, MIN_HEIGHT).applyTo(this);

    // create container for the two comboboxes
    Composite container = new Composite(pvParent, SWT.NONE);
    RowLayoutFactory.fillDefaults().type(SWT.HORIZONTAL).wrap(false).applyTo(container);

    // create container for thematic role information
    Composite themRoleContainer = new Composite(container, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(3).applyTo(themRoleContainer);

    Label labelThematicRole = new Label(themRoleContainer, SWT.NONE);
    labelThematicRole.setText("Thematic Role:");
    btnThematicRole = new Button(themRoleContainer, SWT.PUSH);

    checkBoxErrorCase = new Button(themRoleContainer, SWT.CHECK);
    checkBoxErrorCase.setText("Documents an Error Case");

    // create tab folder
    addresseeTabFolder = new TabFolder(pvParent, SWT.NONE | SWT.RESIZE);
    GridDataFactory.fillDefaults().grab(true, true).span(2, 1).applyTo(addresseeTabFolder);
    addresseeDocTextField = new LinkedHashMap<Addressee, Text>();

    addresseesMenu = new Menu(this.getShell(), SWT.POP_UP);

    rolePopUpMenu = new Menu(this.getShell(), SWT.POP_UP);
}

From source file:net.yatomiya.e4.ui.workbench.renderers.swt.TrimUtil.java

License:Open Source License

public static Composite wrapTrim(Control trim) {
    int orientation = SWT.HORIZONTAL;
    if (trim instanceof ToolBar)
        orientation = (((ToolBar) trim).getStyle() & SWT.VERTICAL) == 0 ? SWT.HORIZONTAL : SWT.VERTICAL;

    Composite parentComp = trim.getParent();
    Composite wrapper = new Composite(parentComp, SWT.NONE);
    RowLayout layout = RowLayoutFactory.fillDefaults().wrap(false).spacing(0).type(orientation).create();
    layout.marginLeft = 3;//ww  w . j a va  2  s. com
    layout.center = true;
    wrapper.setLayout(layout);

    // Separator (aka 'drag handle')
    ToolBar separatorToolBar = new ToolBar(wrapper, orientation | SWT.WRAP | SWT.FLAT | SWT.RIGHT);
    new ToolItem(separatorToolBar, SWT.SEPARATOR);

    // Put the trim under the wrapper and ensure it's last
    trim.setParent(wrapper);
    trim.moveBelow(null);

    return wrapper;
}

From source file:org.bonitasoft.studio.properties.sections.general.TransitionCondition.java

License:Open Source License

private void createLine(Composite parent, List<Expression> conditions,
        DecisionTableAction decisionTableAction) {
    final Composite row = widgetFactory.createComposite(parent);
    row.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    row.setLayout(RowLayoutFactory.fillDefaults().spacing(0).type(SWT.HORIZONTAL).create());

    for (Expression condition : conditions) {
        widgetFactory.createLabel(row, condition.getContent(), SWT.NONE);
        if (conditions.indexOf(condition) != conditions.size() - 1) {
            widgetFactory.createLabel(row, " ", SWT.NONE);
            widgetFactory.createLabel(row, Messages.and, SWT.NONE);
            widgetFactory.createLabel(row, " ", SWT.NONE);
        }//www.j  a  v  a2 s  .  c o  m
    }

    widgetFactory.createLabel(row, "  ", SWT.NONE);
    final Label image = widgetFactory.createLabel(row, "", SWT.NONE);
    image.setImage(Pics.getImage(PicsConstants.arrowRight));
    if (decisionTableAction instanceof TakeTransitionAction) {
        if (((TakeTransitionAction) decisionTableAction).isTakeTransition()) {
            widgetFactory.createLabel(row, "  ", SWT.NONE);
            widgetFactory.createLabel(row, Messages.takeTransition, SWT.NONE);
        } else {
            widgetFactory.createLabel(row, "  ", SWT.NONE);
            widgetFactory.createLabel(row, Messages.dontTakeTransition, SWT.NONE);
        }
    }

}

From source file:org.bonitasoft.studio.properties.sections.general.TransitionConditionContribution.java

License:Open Source License

private void createLine(final Composite parent, final List<Expression> conditions,
        final DecisionTableAction decisionTableAction) {
    final Composite row = widgetFactory.createComposite(parent);
    row.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    row.setLayout(RowLayoutFactory.fillDefaults().spacing(0).type(SWT.HORIZONTAL).create());

    for (final Expression condition : conditions) {
        widgetFactory.createLabel(row, condition.getContent(), SWT.NONE);
        if (conditions.indexOf(condition) != conditions.size() - 1) {
            widgetFactory.createLabel(row, " ", SWT.NONE);
            widgetFactory.createLabel(row, Messages.and, SWT.NONE);
            widgetFactory.createLabel(row, " ", SWT.NONE);
        }/*from  w  ww  . ja v  a  2  s.  com*/
    }

    widgetFactory.createLabel(row, "  ", SWT.NONE);
    final Label image = widgetFactory.createLabel(row, "", SWT.NONE);
    image.setImage(Pics.getImage(PicsConstants.arrowRight));
    if (decisionTableAction instanceof TakeTransitionAction) {
        if (((TakeTransitionAction) decisionTableAction).isTakeTransition()) {
            widgetFactory.createLabel(row, "  ", SWT.NONE);
            widgetFactory.createLabel(row, Messages.takeTransition, SWT.NONE);
        } else {
            widgetFactory.createLabel(row, "  ", SWT.NONE);
            widgetFactory.createLabel(row, Messages.dontTakeTransition, SWT.NONE);
        }
    }

}

From source file:org.chrysalix.eclipse.focustree.FocusTree.java

License:Open Source License

/**
 * @param parent//from  w w  w  .  ja  v a  2 s. c  om
 *        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.cloudfoundry.ide.eclipse.internal.server.ui.editor.ApplicationDetailsPart.java

License:Open Source License

private void createGeneralSection(Composite parent) {
    generalSection = toolkit.createSection(parent, Section.TITLE_BAR);
    generalSection.setLayout(new GridLayout());
    GridDataFactory.fillDefaults().grab(true, false).applyTo(generalSection);
    generalSection.setText("General");

    // reset spacing due to toolbar
    generalSection.clientVerticalSpacing = 0;

    Composite client = toolkit.createComposite(generalSection);
    client.setLayout(new GridLayout(2, false));
    GridDataFactory.fillDefaults().grab(true, false).applyTo(client);
    generalSection.setClient(client);/*from  w  w w .  ja  va 2  s .c om*/

    createLabel(client, "Name:", SWT.CENTER);
    serverNameText = createText(client, SWT.NONE);

    createLabel(client, "Mapped URLs:", SWT.TOP);

    Composite uriComposite = toolkit.createComposite(client);
    GridLayoutFactory.fillDefaults().numColumns(2).margins(0, 0).applyTo(uriComposite);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(uriComposite);

    mappedURIsLink = new Link(uriComposite, SWT.MULTI);
    GridDataFactory.fillDefaults().grab(true, false).hint(250, SWT.DEFAULT).applyTo(mappedURIsLink);
    adaptControl(mappedURIsLink);

    mappedURIsLink.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            CloudUiUtil.openUrl("http://" + e.text);
        }
    });

    ImageHyperlink editURI = toolkit.createImageHyperlink(uriComposite, SWT.PUSH);
    GridDataFactory.fillDefaults().grab(true, false).align(SWT.RIGHT, SWT.TOP).applyTo(editURI);
    editURI.setImage(CloudFoundryImages.getImage(CloudFoundryImages.EDIT));
    editURI.addHyperlinkListener(new HyperlinkAdapter() {
        @Override
        public void linkActivated(HyperlinkEvent e) {
            CloudFoundryURLsWizard wizard = new CloudFoundryURLsWizard(cloudServer,
                    getApplication().getApplicationId(), URIs);
            WizardDialog dialog = new WizardDialog(editorPage.getEditorSite().getShell(), wizard);
            if (dialog.open() == Window.OK) {
                URIs = wizard.getURLs();
                mappedURIsLink.setText(getURIsAsLinkText(wizard.getURLs()));
                generalSection.getParent().layout(true, true);
                editorPage.reflow();
                getApplication().getApplication().setUris(URIs);
            }
        }
    });

    createLabel(client, "Memory limit:", SWT.CENTER);

    Composite memoryComposite = toolkit.createComposite(client);
    GridLayoutFactory.fillDefaults().margins(0, 0).numColumns(2).equalWidth(false).applyTo(memoryComposite);

    memoryCombo = new Combo(memoryComposite, SWT.BORDER);
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.FILL).applyTo(memoryCombo);
    memoryCombo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (canUpdate) {
                int selectionIndex = memoryCombo.getSelectionIndex();
                if (selectionIndex != -1) {
                    memory = editorPage.getApplicationMemoryChoices()[selectionIndex];
                    new UpdateApplicationMemoryAction(editorPage, memory, getApplication()).run();
                }
            }
        }

    });

    memoryNoteLabel = toolkit.createLabel(memoryComposite, " Change is not updated until application restarts");
    GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(memoryNoteLabel);

    createLabel(client, "Instances:", SWT.CENTER);

    instanceSpinner = new Spinner(client, SWT.BORDER);
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(instanceSpinner);
    instanceSpinner.setMinimum(0);
    instanceSpinner.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            if (canUpdate) {
                new UpdateInstanceCountAction(editorPage, instanceSpinner, getApplication()).run();
            }
        }
    });
    toolkit.adapt(instanceSpinner);

    buttonComposite = toolkit.createComposite(client);
    GridDataFactory.fillDefaults().span(2, 1).applyTo(buttonComposite);

    RowLayout layout = RowLayoutFactory.fillDefaults().margins(0, 5).wrap(false).create();
    layout.center = true;
    buttonComposite.setLayout(layout);

    startAppButton = toolkit.createButton(buttonComposite, "Start", SWT.PUSH);
    startAppButton.setImage(ImageResource.getImage(ImageResource.IMG_CLCL_START));
    startAppButton.setEnabled(true);
    startAppButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            startStopApplication(ApplicationAction.START);
        }
    });

    debugControl = toolkit.createButton(buttonComposite, "Debug", SWT.PUSH);
    debugControl.setImage(CloudFoundryImages.getImage(CloudFoundryImages.DEBUG));
    debugControl.setEnabled(true);
    debugControl.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            debugApplication(ApplicationAction.DEBUG);
        }
    });

    // Do not show Debug control if server does not support debug
    debugControl.setVisible(isDebugAllowed());

    stopAppButton = toolkit.createButton(buttonComposite, "Stop", SWT.PUSH);
    stopAppButton.setImage(ImageResource.getImage(ImageResource.IMG_CLCL_STOP));
    stopAppButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            startStopApplication(ApplicationAction.STOP);
        }
    });

    connectToDebugger = toolkit.createButton(buttonComposite, "Connect to Debugger", SWT.PUSH);
    connectToDebugger.setImage(CloudFoundryImages.getImage(CloudFoundryImages.DEBUG));
    connectToDebugger.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            connectToDebugger();
        }
    });

    // Do not show drop down options for restart if debug support is not
    // allowed
    ApplicationAction[] restartActions = isDebugAllowed()
            ? new ApplicationAction[] { ApplicationAction.START, ApplicationAction.DEBUG }
            : null;

    restartAppButton = new ApplicationActionMenuControl(buttonComposite, restartActions,
            ApplicationAction.START, "Restart", CloudFoundryImages.getImage(CloudFoundryImages.RESTART),
            toolkit) {

        public void setDefaultTooltipMessage() {
            // Don't do anything as tooltip is controlled by the editor part
        }

    };
    restartAppButton.createControl();

    restartAppButton.addMenuListener(new IButtonMenuListener() {

        public void widgetSelected(ApplicationAction actionType) {
            restartApplication(ApplicationAction.RESTART, actionType);
        }
    });

    updateRestartAppButton = new ApplicationActionMenuControl(buttonComposite, restartActions,
            ApplicationAction.START, "Update and Restart",
            CloudFoundryImages.getImage(CloudFoundryImages.RESTART), toolkit) {

        public void setDefaultTooltipMessage() {
            // Don't do anything as tooltip is controlled by the editor part
        }

    };
    updateRestartAppButton.createControl();

    updateRestartAppButton.addMenuListener(new IButtonMenuListener() {

        public void widgetSelected(ApplicationAction actionType) {
            restartApplication(ApplicationAction.UPDATE_RESTART, actionType);
        }
    });

    // If debugging is not supported, permanently hide the debug buttons
    if (!isDebugAllowed()) {
        RowData data = new RowData();
        data.exclude = true;
        debugControl.setLayoutData(data);
        debugControl.setVisible(false);

        data = new RowData();
        data.exclude = true;
        connectToDebugger.setLayoutData(data);
        connectToDebugger.setVisible(false);

        buttonComposite.layout(true, true);
    }
}

From source file:org.cloudfoundry.ide.eclipse.server.ui.internal.editor.ApplicationDetailsPart.java

License:Open Source License

private void createApplicationOperationsSection(Composite parent) {

    operationsSection = toolkit.createSection(parent, Section.TITLE_BAR | Section.TWISTIE);
    operationsSection.setExpanded(true);
    operationsSection.setLayout(new GridLayout());
    GridDataFactory.fillDefaults().grab(true, false).applyTo(operationsSection);
    operationsSection.setText(Messages.ApplicationDetailsPart_TEXT_APP_OP);

    // reset spacing due to toolbar
    operationsSection.clientVerticalSpacing = 0;

    Composite client = toolkit.createComposite(operationsSection);
    client.setLayout(new GridLayout(2, false));
    GridDataFactory.fillDefaults().grab(true, false).applyTo(client);
    operationsSection.setClient(client);

    topButtonRow = toolkit.createComposite(client);
    GridDataFactory.fillDefaults().span(2, 1).applyTo(topButtonRow);

    RowLayout layout = RowLayoutFactory.fillDefaults().margins(0, 2).wrap(false).create();
    layout.center = true;//from  w  ww .j  av  a 2 s  .c  o  m
    topButtonRow.setLayout(layout);

    startAppButton = toolkit.createButton(topButtonRow, Messages.ApplicationDetailsPart_TEXT_START, SWT.PUSH);
    startAppButton.setImage(ImageResource.getImage(ImageResource.IMG_CLCL_START));
    startAppButton.setToolTipText(Messages.ApplicationDetailsPart_TEXT_START_TOOLTIP);

    startAppButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            restartApplication(ApplicationAction.RESTART);
        }
    });
    // Always enable. App can be restarted both when it is stopped and
    // started.
    startAppButton.setEnabled(true);

    stopAppButton = toolkit.createButton(topButtonRow, Messages.ApplicationDetailsPart_TEXT_STOP, SWT.PUSH);
    stopAppButton.setImage(ImageResource.getImage(ImageResource.IMG_CLCL_STOP));
    stopAppButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            startStopApplication(ApplicationAction.STOP);
        }
    });

    updateRestartAppButton = toolkit.createButton(topButtonRow,
            Messages.ApplicationDetailsPart_TEXT_UPDATE_RESTART, SWT.PUSH);
    updateRestartAppButton.setImage(CloudFoundryImages.getImage(CloudFoundryImages.RESTART));
    updateRestartAppButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            restartApplication(ApplicationAction.UPDATE_RESTART);
        }
    });

    updateRestartAppButton.setToolTipText(Messages.ApplicationDetailsPart_TEXT_UPDATE_RESTART_TOOLTIP);

    lowerButtonRow = toolkit.createComposite(client);
    GridDataFactory.fillDefaults().span(2, 1).applyTo(lowerButtonRow);

    layout = RowLayoutFactory.fillDefaults().margins(0, 2).wrap(false).create();
    layout.center = true;
    lowerButtonRow.setLayout(layout);

    pushAppButton = toolkit.createButton(lowerButtonRow, Messages.ApplicationDetailsPart_TEXT_PUSH, SWT.PUSH);
    pushAppButton.setImage(CloudFoundryImages.getImage(CloudFoundryImages.PUSH));
    pushAppButton.setEnabled(false);
    pushAppButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            startStopApplication(ApplicationAction.START);
        }
    });

    pushAppButton.setToolTipText(Messages.ApplicationDetailsPart_TEXT_PUSH_TOOLTIP);

    createDebugArea(lowerButtonRow);

}

From source file:org.eclipse.e4.ui.workbench.renderers.swt.ToolBarRenderer.java

License:Open Source License

ToolBar createToolbar(final MUIElement element, Composite intermediate) {
    int orientation = getOrientation(element);
    RowLayout layout = RowLayoutFactory.fillDefaults().wrap(false).spacing(0).type(orientation).create();
    layout.marginLeft = 3;/*from  w ww  .ja  v  a2s .  co m*/
    layout.center = true;
    intermediate.setLayout(layout);
    // new Label(intermediate, (orientation == SWT.HORIZONTAL ? SWT.VERTICAL
    // : SWT.HORIZONTAL) | SWT.SEPARATOR);
    ToolBar separatorToolBar = new ToolBar(intermediate, orientation | SWT.WRAP | SWT.FLAT | SWT.RIGHT);
    new ToolItem(separatorToolBar, SWT.SEPARATOR);
    return new ToolBar(intermediate, orientation | SWT.WRAP | SWT.FLAT | SWT.RIGHT);
}