Search in sources :

Example 26 with ToolBarManager

use of org.eclipse.jface.action.ToolBarManager in project rap by entirej.

the class EJRWTPieChartRecordBlockRenderer method buildGuiComponent.

@Override
public void buildGuiComponent(EJRWTEntireJGridPane blockCanvas) {
    EJFrameworkExtensionProperties appProp = EJCoreProperties.getInstance().getApplicationDefinedProperties();
    if (appProp != null) {
        EJFrameworkExtensionProperties propertyGroup = appProp.getPropertyGroup(EJRWTSingleRecordBlockDefinitionProperties.ACTION_GROUP);
        if (propertyGroup != null) {
            addActionKeyinfo(propertyGroup.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ACTION_QUERY_KEY), EJRWTSingleRecordBlockDefinitionProperties.ACTION_QUERY_KEY);
            addActionKeyinfo(propertyGroup.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ACTION_INSERT_KEY), EJRWTSingleRecordBlockDefinitionProperties.ACTION_INSERT_KEY);
            addActionKeyinfo(propertyGroup.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ACTION_UPDATE_KEY), EJRWTSingleRecordBlockDefinitionProperties.ACTION_UPDATE_KEY);
            addActionKeyinfo(propertyGroup.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ACTION_DELETE_KEY), EJRWTSingleRecordBlockDefinitionProperties.ACTION_DELETE_KEY);
            addActionKeyinfo(propertyGroup.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ACTION_REFRESH_KEY), EJRWTSingleRecordBlockDefinitionProperties.ACTION_REFRESH_KEY);
        }
    }
    EJBlockProperties blockProperties = _block.getProperties();
    EJMainScreenProperties mainScreenProperties = blockProperties.getMainScreenProperties();
    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.widthHint = mainScreenProperties.getWidth();
    gridData.heightHint = mainScreenProperties.getHeight();
    gridData.horizontalSpan = mainScreenProperties.getHorizontalSpan();
    gridData.verticalSpan = mainScreenProperties.getVerticalSpan();
    gridData.grabExcessHorizontalSpace = mainScreenProperties.canExpandHorizontally();
    gridData.grabExcessVerticalSpace = mainScreenProperties.canExpandVertically();
    if (gridData.grabExcessHorizontalSpace) {
        gridData.minimumWidth = mainScreenProperties.getWidth();
    }
    if (gridData.grabExcessVerticalSpace) {
        gridData.minimumHeight = mainScreenProperties.getHeight();
    }
    _rendererProp = blockProperties.getBlockRendererProperties();
    blockCanvas.setLayoutData(gridData);
    EJFrameworkExtensionProperties sectionProperties = null;
    if (_rendererProp != null) {
        sectionProperties = _rendererProp.getPropertyGroup(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR);
    }
    if (sectionProperties != null && sectionProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE) != null && !EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE_GROUP.equals(sectionProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE))) {
        int style = ExpandableComposite.TITLE_BAR;
        String mode = sectionProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE);
        if (EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE_TWISTIE.equals(mode)) {
            style = style | ExpandableComposite.TWISTIE;
        } else if (EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE_TREE_NODE.equals(mode)) {
            style = style | ExpandableComposite.TREE_NODE;
        }
        if (sectionProperties.getBooleanProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_EXPANDED, true)) {
            style = style | ExpandableComposite.EXPANDED;
        }
        Section section = toolkit.createSection(blockCanvas, style);
        section.setLayoutData(gridData);
        String title = sectionProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_TITLE);
        if (title != null) {
            section.setText(title);
        }
        EJRWTImageRetriever.getGraphicsProvider().rendererSection(section);
        String frameTitle = mainScreenProperties.getFrameTitle();
        if (mainScreenProperties.getDisplayFrame() && frameTitle != null && frameTitle.length() > 0) {
            Group group = new Group(section, SWT.NONE);
            group.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_GROUP);
            group.setLayout(new FillLayout());
            group.setLayoutData(gridData);
            hookKeyListener(group);
            group.setText(frameTitle);
            _mainPane = new EJRWTEntireJGridPane(group, 1, mainScreenProperties.getDisplayFrame() ? SWT.BORDER : SWT.NONE);
            _mainPane.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_GROUP);
            section.setClient(group);
        } else {
            _mainPane = new EJRWTEntireJGridPane(section, 1);
            _mainPane.setLayoutData(gridData);
            _mainPane.cleanLayoutHorizontal();
            _mainPane.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_GROUP);
            section.setClient(_mainPane);
        }
        final EJFrameworkExtensionPropertyList propertyList = sectionProperties.getPropertyList(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_ACTIONS);
        if (propertyList != null && propertyList.getAllListEntries().size() > 0) {
            ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
            final ToolBar toolbar = toolBarManager.createControl(section);
            final Cursor handCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND);
            toolbar.setCursor(handCursor);
            // Cursor needs to be explicitly disposed
            toolbar.addDisposeListener(new DisposeListener() {

                @Override
                public void widgetDisposed(DisposeEvent e) {
                    if (handCursor != null && handCursor.isDisposed() == false) {
                        handCursor.dispose();
                    }
                }
            });
            List<EJFrameworkExtensionPropertyListEntry> allListEntries = propertyList.getAllListEntries();
            for (EJFrameworkExtensionPropertyListEntry entry : allListEntries) {
                final String actionID = entry.getProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_ACTION_ID);
                String actionImage = entry.getProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_ACTION_IMAGE);
                String actionName = entry.getProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_ACTION_NAME);
                String actionTooltip = entry.getProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_ACTION_TOOLTIP);
                if (actionID != null) {
                    Action action = new Action(actionID, IAction.AS_PUSH_BUTTON) {

                        @Override
                        public void runWithEvent(Event event) {
                            _block.executeActionCommand(actionID, EJScreenType.MAIN);
                        }
                    };
                    if (actionName != null) {
                        action.setText(actionName);
                    }
                    if (actionTooltip != null) {
                        action.setDescription(actionTooltip);
                    }
                    if (actionImage != null && actionImage.length() > 0) {
                        action.setImageDescriptor((EJRWTImageRetriever.createDescriptor(actionImage)));
                    }
                    toolBarManager.add(action);
                }
            }
            toolBarManager.update(true);
            section.setTextClient(toolbar);
        }
    } else {
        String frameTitle = mainScreenProperties.getFrameTitle();
        if (mainScreenProperties.getDisplayFrame() && frameTitle != null && frameTitle.length() > 0) {
            Group group = new Group(blockCanvas, SWT.NONE);
            group.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_GROUP);
            group.setLayout(new FillLayout());
            group.setLayoutData(gridData);
            hookKeyListener(group);
            group.setText(frameTitle);
            _mainPane = new EJRWTEntireJGridPane(group, 1, mainScreenProperties.getDisplayFrame() ? SWT.BORDER : SWT.NONE);
            _mainPane.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_GROUP);
        } else {
            _mainPane = new EJRWTEntireJGridPane(blockCanvas, 1);
            _mainPane.setLayoutData(gridData);
            _mainPane.cleanLayout();
            _mainPane.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_GROUP);
        }
    }
    hookKeyListener(_mainPane);
    int style = SWT.NONE;
    Collection<EJItemGroupProperties> allItemGroupProperties = _block.getProperties().getScreenItemGroupContainer(EJScreenType.MAIN).getAllItemGroupProperties();
    {
        _chartView = null;
        if (allItemGroupProperties.size() > 0) {
            EJItemGroupProperties displayProperties = allItemGroupProperties.iterator().next();
            if (displayProperties.dispayGroupFrame() && displayProperties.getFrameTitle() != null && displayProperties.getFrameTitle().length() > 0) {
                Group group = new Group(_mainPane, SWT.NONE);
                group.setLayout(new FillLayout());
                group.setText(displayProperties.getFrameTitle());
                group.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
                _chartView = new PieChart(group, style) {

                    protected void action(String method, org.eclipse.rap.json.JsonObject parameters) {
                        processAction(method, parameters);
                    }
                };
            } else {
                _chartView = new PieChart(_mainPane, displayProperties.dispayGroupFrame() ? style | SWT.BORDER : style) {

                    protected void action(String method, org.eclipse.rap.json.JsonObject parameters) {
                        processAction(method, parameters);
                    }
                };
                _chartView.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
            }
        } else {
            _chartView = new PieChart(_mainPane, style) {

                protected void action(String method, org.eclipse.rap.json.JsonObject parameters) {
                    processAction(method, parameters);
                }
            };
            _chartView.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
        }
    }
    _chartView.addFocusListener(new FocusListener() {

        @Override
        public void focusLost(FocusEvent arg0) {
            setHasFocus(false);
        }

        @Override
        public void focusGained(FocusEvent arg0) {
            setHasFocus(true);
        }
    });
    _mainPane.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(MouseEvent arg0) {
            if (!_chartView.isFocusControl()) {
                setHasFocus(true);
            }
        }
    });
    _chartView.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(MouseEvent arg0) {
            if (!_chartView.isFocusControl()) {
                setHasFocus(true);
            }
        }
    });
    for (EJItemGroupProperties groupProperties : allItemGroupProperties) {
        Collection<EJScreenItemProperties> itemProperties = groupProperties.getAllItemProperties();
        for (EJScreenItemProperties screenItemProperties : itemProperties) {
            EJCoreMainScreenItemProperties mainScreenItemProperties = (EJCoreMainScreenItemProperties) screenItemProperties;
            String visualAttribute = mainScreenItemProperties.getBlockRendererRequiredProperties().getStringProperty(VISUAL_ATTRIBUTE_PROPERTY);
            EJScreenItemController item = _block.getScreenItem(EJScreenType.MAIN, mainScreenItemProperties.getReferencedItemName());
            EJRWTAppItemRenderer itemRenderer = (EJRWTAppItemRenderer) item.getManagedItemRenderer().getUnmanagedRenderer();
            if (visualAttribute != null) {
                EJCoreVisualAttributeProperties va = EJCoreProperties.getInstance().getVisualAttributesContainer().getVisualAttributeProperties(visualAttribute);
                if (va != null) {
                    itemRenderer.setInitialVisualAttribute(va);
                }
            }
            if (item.getProperties().getVisualAttributeProperties() != null) {
                itemRenderer.setVisualAttribute(item.getProperties().getVisualAttributeProperties());
            }
        }
    }
    refresh();
}
Also used : Group(org.eclipse.swt.widgets.Group) DisposeListener(org.eclipse.swt.events.DisposeListener) IAction(org.eclipse.jface.action.IAction) EJRWTDeleteAction(org.entirej.applicationframework.rwt.application.components.actions.EJRWTDeleteAction) EJRWTQueryAction(org.entirej.applicationframework.rwt.application.components.actions.EJRWTQueryAction) EJRWTUpdateAction(org.entirej.applicationframework.rwt.application.components.actions.EJRWTUpdateAction) EJRWTInsertAction(org.entirej.applicationframework.rwt.application.components.actions.EJRWTInsertAction) Action(org.eclipse.jface.action.Action) EJItemGroupProperties(org.entirej.framework.core.properties.interfaces.EJItemGroupProperties) EJCoreMainScreenItemProperties(org.entirej.framework.core.properties.EJCoreMainScreenItemProperties) JsonObject(org.eclipse.rap.json.JsonObject) Cursor(org.eclipse.swt.graphics.Cursor) DisposeEvent(org.eclipse.swt.events.DisposeEvent) FocusEvent(org.eclipse.swt.events.FocusEvent) ToolBarManager(org.eclipse.jface.action.ToolBarManager) PieChart(org.eclipse.rap.chartjs.pie.PieChart) EJScreenItemProperties(org.entirej.framework.core.properties.interfaces.EJScreenItemProperties) EJFrameworkExtensionProperties(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties) EJFrameworkExtensionPropertyList(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionPropertyList) MouseEvent(org.eclipse.swt.events.MouseEvent) MouseAdapter(org.eclipse.swt.events.MouseAdapter) FillLayout(org.eclipse.swt.layout.FillLayout) Section(org.eclipse.ui.forms.widgets.Section) EJRWTAppItemRenderer(org.entirej.applicationframework.rwt.renderer.interfaces.EJRWTAppItemRenderer) EJFrameworkExtensionPropertyListEntry(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionPropertyListEntry) EJScreenItemController(org.entirej.framework.core.interfaces.EJScreenItemController) EJBlockProperties(org.entirej.framework.core.properties.interfaces.EJBlockProperties) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) DisposeEvent(org.eclipse.swt.events.DisposeEvent) FocusEvent(org.eclipse.swt.events.FocusEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) Event(org.eclipse.swt.widgets.Event) EJMainScreenProperties(org.entirej.framework.core.properties.interfaces.EJMainScreenProperties) FocusListener(org.eclipse.swt.events.FocusListener) EJRWTEntireJGridPane(org.entirej.applicationframework.rwt.layout.EJRWTEntireJGridPane) EJCoreVisualAttributeProperties(org.entirej.framework.core.properties.EJCoreVisualAttributeProperties)

Example 27 with ToolBarManager

use of org.eclipse.jface.action.ToolBarManager in project egit by eclipse.

the class StagingView method createStagedToolBarComposite.

private void createStagedToolBarComposite() {
    Composite stagedToolbarComposite = toolkit.createComposite(stagedSection);
    stagedToolbarComposite.setBackground(null);
    stagedToolbarComposite.setLayout(createRowLayoutWithoutMargin());
    stagedSection.setTextClient(stagedToolbarComposite);
    stagedExpandAllAction = new Action(UIText.UIUtils_ExpandAll, IAction.AS_PUSH_BUTTON) {

        @Override
        public void run() {
            stagedViewer.expandAll();
            enableAutoExpand(stagedViewer);
        }
    };
    stagedExpandAllAction.setImageDescriptor(UIIcons.EXPAND_ALL);
    stagedExpandAllAction.setId(EXPAND_ALL_ITEM_TOOLBAR_ID);
    stagedCollapseAllAction = new Action(UIText.UIUtils_CollapseAll, IAction.AS_PUSH_BUTTON) {

        @Override
        public void run() {
            stagedViewer.collapseAll();
            disableAutoExpand(stagedViewer);
        }
    };
    stagedCollapseAllAction.setImageDescriptor(UIIcons.COLLAPSEALL);
    stagedCollapseAllAction.setId(COLLAPSE_ALL_ITEM_TOOLBAR_ID);
    stagedToolBarManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL);
    stagedToolBarManager.add(unstageAction);
    stagedToolBarManager.add(unstageAllAction);
    stagedToolBarManager.add(stagedExpandAllAction);
    stagedToolBarManager.add(stagedCollapseAllAction);
    stagedToolBarManager.update(true);
    stagedToolBarManager.createControl(stagedToolbarComposite);
}
Also used : IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) BooleanPrefAction(org.eclipse.egit.ui.internal.actions.BooleanPrefAction) RepositoryToolbarAction(org.eclipse.egit.ui.internal.components.RepositoryMenuUtil.RepositoryToolbarAction) IWorkbenchAction(org.eclipse.ui.actions.ActionFactory.IWorkbenchAction) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ToolBarManager(org.eclipse.jface.action.ToolBarManager)

Example 28 with ToolBarManager

use of org.eclipse.jface.action.ToolBarManager in project egit by eclipse.

the class StagingView method setExpandCollapseActionsVisible.

private void setExpandCollapseActionsVisible(boolean staged, boolean visibleExpandAll, boolean visibleCollapseAll) {
    ToolBarManager toolBarManager = staged ? stagedToolBarManager : unstagedToolBarManager;
    for (IContributionItem item : toolBarManager.getItems()) {
        String id = item.getId();
        if (EXPAND_ALL_ITEM_TOOLBAR_ID.equals(id)) {
            item.setVisible(visibleExpandAll);
        } else if (COLLAPSE_ALL_ITEM_TOOLBAR_ID.equals(id)) {
            item.setVisible(visibleCollapseAll);
        }
    }
    (staged ? stagedExpandAllAction : unstagedExpandAllAction).setEnabled(visibleExpandAll);
    (staged ? stagedCollapseAllAction : unstagedCollapseAllAction).setEnabled(visibleCollapseAll);
    toolBarManager.update(true);
}
Also used : IContributionItem(org.eclipse.jface.action.IContributionItem) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ToolBarManager(org.eclipse.jface.action.ToolBarManager)

Example 29 with ToolBarManager

use of org.eclipse.jface.action.ToolBarManager in project egit by eclipse.

the class CommitEditor method createHeaderContents.

/**
 * @see org.eclipse.ui.forms.editor.SharedHeaderFormEditor#createHeaderContents(org.eclipse.ui.forms.IManagedForm)
 */
@Override
protected void createHeaderContents(IManagedForm headerForm) {
    headerForm.addPart(new FocusManagerFormPart(headerFocusTracker) {

        @Override
        public void setDefaultFocus() {
            headerForm.getForm().getForm().setFocus();
        }
    });
    RepositoryCommit commit = getCommit();
    ScrolledForm form = headerForm.getForm();
    String commitName = commit.getRevCommit().name();
    String title = getFormattedHeaderTitle(commitName);
    HeaderText text = new HeaderText(form.getForm(), title, commitName);
    Control textControl = text.getControl();
    if (textControl != null) {
        headerFocusTracker.addToFocusTracking(textControl);
    }
    form.setToolTipText(commitName);
    getToolkit().decorateFormHeading(form.getForm());
    toolbar = form.getToolBarManager();
    ControlContribution repositoryLabelControl = new ControlContribution(// $NON-NLS-1$
    "repositoryLabel") {

        @Override
        protected Control createControl(Composite parent) {
            FormToolkit toolkit = getHeaderForm().getToolkit();
            String label = getCommit().getRepositoryName();
            ImageHyperlink link = new ImageHyperlink(parent, SWT.NONE);
            // Focus tracking on this link doesn't really work. It's a
            // focusable control inside another focusable control (the
            // toolbar). When focus leaves this control through tabbing
            // or deactivating the editor, the toolbar gets the focus (and
            // possibly loses it right away again). Thus the focus tracker
            // will always see the toolbar as the last focused control.
            // Unfortunately there is no other way to get some text onto
            // the first line of a FormHeading.
            headerFocusTracker.addToFocusTracking(link);
            link.setText(label);
            link.setFont(JFaceResources.getBannerFont());
            link.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
            link.setToolTipText(UIText.CommitEditor_showGitRepo);
            link.addHyperlinkListener(new HyperlinkAdapter() {

                @Override
                public void linkActivated(HyperlinkEvent event) {
                    RepositoriesView view;
                    try {
                        view = (RepositoriesView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(RepositoriesView.VIEW_ID);
                        view.showRepository(getCommit().getRepository());
                    } catch (PartInitException e) {
                        Activator.handleError(UIText.CommitEditor_couldNotShowRepository, e, false);
                    }
                }
            });
            return link;
        }
    };
    toolbar.add(repositoryLabelControl);
    CommonUtils.getService(getSite(), IPartService.class).addPartListener(activationListener);
    if (commit.isStash()) {
        toolbar.add(createActionContributionItem(StashApplyHandler.ID, UIText.CommitEditor_toolbarApplyStash, UIIcons.STASH_APPLY));
        toolbar.add(createActionContributionItem(StashDropHandler.ID, UIText.CommitEditor_toolbarDeleteStash, PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_DELETE)));
    } else {
        toolbar.add(createActionContributionItem(CreateTagHandler.ID, UIText.CommitEditor_toolbarCreateTag, UIIcons.TAG));
        toolbar.add(createActionContributionItem(CreateBranchHandler.ID, UIText.CommitEditor_toolbarCreateBranch, UIIcons.BRANCH));
        toolbar.add(createActionContributionItem(CheckoutHandler.ID, UIText.CommitEditor_toolbarCheckOut, UIIcons.CHECKOUT));
        toolbar.add(createActionContributionItem(CherryPickHandler.ID, UIText.CommitEditor_toolbarCherryPick, UIIcons.CHERRY_PICK));
        toolbar.add(createActionContributionItem(RevertHandler.ID, UIText.CommitEditor_toolbarRevert, UIIcons.REVERT));
        toolbar.add(createActionContributionItem(ShowInHistoryHandler.ID, UIText.CommitEditor_toolbarShowInHistory, UIIcons.HISTORY));
    }
    addContributions(toolbar);
    toolbar.update(true);
    getSite().setSelectionProvider(new ISelectionProvider() {

        @Override
        public void setSelection(ISelection selection) {
        // Ignored
        }

        @Override
        public void removeSelectionChangedListener(ISelectionChangedListener listener) {
        // Ignored
        }

        @Override
        public ISelection getSelection() {
            return new StructuredSelection(getCommit());
        }

        @Override
        public void addSelectionChangedListener(ISelectionChangedListener listener) {
        // Ignored
        }
    });
    if (toolbar instanceof ToolBarManager) {
        Control control = ((ToolBarManager) toolbar).getControl();
        if (control != null) {
            headerFocusTracker.addToFocusTracking(control);
        }
    }
}
Also used : HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Composite(org.eclipse.swt.widgets.Composite) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ControlContribution(org.eclipse.jface.action.ControlContribution) IPartService(org.eclipse.ui.IPartService) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ToolBarManager(org.eclipse.jface.action.ToolBarManager) Control(org.eclipse.swt.widgets.Control) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ScrolledForm(org.eclipse.ui.forms.widgets.ScrolledForm) RepositoriesView(org.eclipse.egit.ui.internal.repository.RepositoriesView) ISelection(org.eclipse.jface.viewers.ISelection) PartInitException(org.eclipse.ui.PartInitException) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Example 30 with ToolBarManager

use of org.eclipse.jface.action.ToolBarManager in project webtools.servertools by eclipse.

the class NewManualServerComposite method createControl.

/**
 * Returns this page's initial visual components.
 */
protected void createControl() {
    // top level group
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    layout.horizontalSpacing = SWTUtil.convertHorizontalDLUsToPixels(this, 4);
    layout.verticalSpacing = SWTUtil.convertVerticalDLUsToPixels(this, 4);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    setLayout(layout);
    this.setFont(getParent().getFont());
    IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem();
    whs.setHelp(this, ContextIds.NEW_SERVER_WIZARD);
    List<ServerCreationWizardPageExtension> pageExtensionLst = ServerUIPlugin.getServerCreationWizardPageExtensions();
    // Add the page modifier top section UI.
    for (ServerCreationWizardPageExtension curPageExtension : pageExtensionLst) {
        curPageExtension.createControl(ServerCreationWizardPageExtension.UI_POSITION.TOP, this);
        curPageExtension.setUIControlListener(this);
    }
    serverTypeComposite = new ServerTypeComposite(this, moduleType, serverTypeId, new ServerTypeComposite.ServerTypeSelectionListener() {

        public void serverTypeSelected(IServerType type2) {
            handleTypeSelection(type2);
        // WizardUtil.defaultSelect(parent, CreateServerWizardPage.this);
        }
    });
    serverTypeComposite.setIncludeIncompatibleVersions(includeIncompatible);
    GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
    data.horizontalSpan = 3;
    data.minimumHeight = 150;
    serverTypeComposite.setLayoutData(data);
    whs.setHelp(serverTypeComposite, ContextIds.NEW_SERVER_TYPE);
    // Add the page modifier middle section UI.
    for (ServerCreationWizardPageExtension curPageExtension : pageExtensionLst) {
        curPageExtension.createControl(ServerCreationWizardPageExtension.UI_POSITION.MIDDLE, this);
    }
    hostnameListener = new IHostnameSelectionListener() {

        public void hostnameSelected(String selectedHostname) {
            setHost(selectedHostname);
        }
    };
    hostnameLabel = new Label(this, SWT.NONE);
    hostnameLabel.setText(Messages.hostname);
    hostname = new Text(this, SWT.SINGLE | SWT.BORDER | SWT.CANCEL);
    hostname.setText(HostnameComposite.LOCALHOST);
    hostnameDecoration = new ControlDecoration(hostname, SWT.TOP | SWT.LEAD);
    GridData data2 = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    hostname.setLayoutData(data2);
    new Label(this, SWT.NONE);
    hostname.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            setHostnameChangeTimer(hostname.getText());
        }
    });
    FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault();
    fd = registry.getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
    hostnameDecoration.setImage(fd.getImage());
    hostnameDecoration.setDescriptionText(fd.getDescription());
    hostname.addFocusListener(new FocusListener() {

        public void focusGained(FocusEvent e) {
            hostnameDecoration.show();
        }

        public void focusLost(FocusEvent e) {
            hostnameDecoration.hide();
        }
    });
    List<String> hosts = ServerUIPlugin.getPreferences().getHostnames();
    String[] hosts2 = hosts.toArray(new String[hosts.size()]);
    new AutoCompleteField(hostname, new TextContentAdapter(), hosts2);
    serverNameLabel = new Label(this, SWT.NONE);
    serverNameLabel.setText(Messages.serverName);
    serverName = new Text(this, SWT.SINGLE | SWT.BORDER | SWT.CANCEL);
    data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    if ((serverName.getStyle() & SWT.CANCEL) != 0)
        data.horizontalSpan = 2;
    serverName.setLayoutData(data);
    if (server != null)
        serverName.setText(server.getName());
    serverName.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            if (updatingServerName)
                return;
            String name = serverName.getText();
            IServerType selectedServerType = serverTypeComposite.getSelectedServerType();
            if (!validate(selectedServerType)) {
                // Do not set the server name if it is invalid
                return;
            }
            if (server != null) {
                server.setName(name);
                String base = serverName.getText().trim();
                if (ServerPlugin.isIdInUse(server, base)) {
                    server.setAttribute("id", generateUniqueId(base));
                }
                IRuntime runtime2 = server.getRuntime();
                if (runtime2 != null && runtime2 instanceof IRuntimeWorkingCopy) {
                    IRuntimeWorkingCopy rwc = (IRuntimeWorkingCopy) runtime2;
                    rwc.setName(name);
                }
            }
            if (serverNameModified)
                return;
            serverNameModified = true;
            if (serverNameToolBar != null)
                serverNameToolBar.getControl().setVisible(true);
        }
    });
    if ((serverName.getStyle() & SWT.CANCEL) == 0) {
        serverNameToolBar = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL);
        serverNameToolBar.createControl(this);
        IAction resetDefaultAction = new // $NON-NLS-1$
        Action(// $NON-NLS-1$
        "", // $NON-NLS-1$
        IAction.AS_PUSH_BUTTON) {

            public void run() {
                ((ServerWorkingCopy) server).setDefaults(null);
                serverName.setText(server.getName());
                serverNameModified = false;
                if (serverNameToolBar != null)
                    serverNameToolBar.getControl().setVisible(false);
            }
        };
        resetDefaultAction.setToolTipText(Messages.serverNameDefault);
        resetDefaultAction.setImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_ETOOL_RESET_DEFAULT));
        resetDefaultAction.setDisabledImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_DTOOL_RESET_DEFAULT));
        serverNameToolBar.add(resetDefaultAction);
        serverNameToolBar.update(false);
        serverNameToolBar.getControl().setVisible(false);
    }
    runtimeLabel = new Label(this, SWT.NONE);
    runtimeLabel.setText(Messages.wizNewServerRuntime);
    runtimeCombo = new Combo(this, SWT.READ_ONLY);
    runtimeCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    runtimeCombo.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            try {
                setRuntime(runtimes[runtimeCombo.getSelectionIndex()]);
            } catch (Exception ex) {
            // ignore
            }
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    addRuntime = new Link(this, SWT.NONE);
    addRuntime.setText("<a>" + Messages.addRuntime + "</a>");
    addRuntime.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
    addRuntime.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            IServerType serverType = serverTypeComposite.getSelectedServerType();
            showRuntimeWizard(serverType);
        }
    });
    configureRuntimes = new Link(this, SWT.NONE);
    configureRuntimes.setText("<a>" + Messages.configureRuntimes + "</a>");
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    data.horizontalSpan = 3;
    configureRuntimes.setLayoutData(data);
    configureRuntimes.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            if (showPreferencePage()) {
                runtime = null;
                IServerType serverType = serverTypeComposite.getSelectedServerType();
                updateRuntimeCombo(serverType);
            }
        }
    });
    // Add the page modifier bottom section UI.
    for (ServerCreationWizardPageExtension curPageExtension : pageExtensionLst) {
        curPageExtension.createControl(ServerCreationWizardPageExtension.UI_POSITION.BOTTOM, this);
    }
    Dialog.applyDialogFont(this);
}
Also used : IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) ServerTypeComposite(org.eclipse.wst.server.ui.internal.viewers.ServerTypeComposite) ToolBarManager(org.eclipse.jface.action.ToolBarManager) GridLayout(org.eclipse.swt.layout.GridLayout) IWorkbenchHelpSystem(org.eclipse.ui.help.IWorkbenchHelpSystem) IHostnameSelectionListener(org.eclipse.wst.server.ui.internal.wizard.page.HostnameComposite.IHostnameSelectionListener) IAction(org.eclipse.jface.action.IAction) ServerCreationWizardPageExtension(org.eclipse.wst.server.ui.wizard.ServerCreationWizardPageExtension) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) GridData(org.eclipse.swt.layout.GridData) IHostnameSelectionListener(org.eclipse.wst.server.ui.internal.wizard.page.HostnameComposite.IHostnameSelectionListener)

Aggregations

ToolBarManager (org.eclipse.jface.action.ToolBarManager)110 Composite (org.eclipse.swt.widgets.Composite)61 Action (org.eclipse.jface.action.Action)45 GridData (org.eclipse.swt.layout.GridData)42 Control (org.eclipse.swt.widgets.Control)38 ToolBar (org.eclipse.swt.widgets.ToolBar)32 Separator (org.eclipse.jface.action.Separator)30 GridLayout (org.eclipse.swt.layout.GridLayout)29 List (java.util.List)27 SWT (org.eclipse.swt.SWT)26 Images (name.abuchen.portfolio.ui.Images)24 Messages (name.abuchen.portfolio.ui.Messages)24 IMenuManager (org.eclipse.jface.action.IMenuManager)24 DropDown (name.abuchen.portfolio.ui.util.DropDown)22 SimpleAction (name.abuchen.portfolio.ui.util.SimpleAction)22 IToolBarManager (org.eclipse.jface.action.IToolBarManager)22 IAction (org.eclipse.jface.action.IAction)20 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)20 ArrayList (java.util.ArrayList)19 DisposeEvent (org.eclipse.swt.events.DisposeEvent)19