/* * (non-Javadoc) * * @see * org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer#processContents * (org.eclipse.e4.ui.model.application.ui.MElementContainer) */ @Override public void processContents(MElementContainer<MUIElement> container) { // I can either simply stop processing, or we can walk the model // ourselves like the "old" days // EMF gives us null lists if empty if (container == null) return; Object obj = container; ToolBarManager parentManager = getManager((MToolBar) obj); if (parentManager == null) { return; } // Process any contents of the newly created ME List<MUIElement> parts = container.getChildren(); if (parts != null) { MUIElement[] plist = parts.toArray(new MUIElement[parts.size()]); for (int i = 0; i < plist.length; i++) { MUIElement childME = plist[i]; modelProcessSwitch(parentManager, (MToolBarElement) childME); } } parentManager.update(true); ToolBar tb = getToolbarFrom(container.getWidget()); if (tb != null) { tb.pack(true); tb.getShell().layout(new Control[] {tb}, SWT.DEFER); } }
@Override public IInformationControl createInformationControl(Shell parent) { if (BrowserInformationControl.isAvailable(parent)) { if (!enriched) { return new SpringPropertiesInformationControl( parent, PreferenceConstants.APPEARANCE_JAVADOC_FONT, statusText) { @Override public IInformationControlCreator getInformationPresenterControlCreator() { return new SpringPropertiesInformationControlCreator(true, null); } }; } else { ToolBarManager toolbar = new ToolBarManager(SWT.FLAT); BrowserInformationControl control = new SpringPropertiesInformationControl( parent, PreferenceConstants.APPEARANCE_JAVADOC_FONT, toolbar) { @Override public IInformationControlCreator getInformationPresenterControlCreator() { return new SpringPropertiesInformationControlCreator(true, null); } }; fillToolbar(toolbar, control); toolbar.update(true); return control; } } return new DefaultInformationControl(parent, true); }
public void addActions(IAction[] actions) { if (actions == null) return; for (int i = 0; i < actions.length; i++) { toolBarManager.add(createActionContributionItem(actions[i])); } toolBarManager.update(true); }
private void createFeaturesToolbar(FormToolkit toolkit, Section section) { Composite headerComposite = toolkit.createComposite(section, SWT.NONE); RowLayout rowLayout = new RowLayout(); rowLayout.marginTop = 0; rowLayout.marginBottom = 0; headerComposite.setLayout(rowLayout); headerComposite.setBackground(null); toolBarManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL); toolBarManager.createControl(headerComposite); installAction = new InstallAction(); installAction.setEnabled(false); toolBarManager.add(installAction); toolBarManager.add(new CheckForUpdatesAction()); CommandContributionItem item = JBossCentralActivator.createContributionItem( getSite(), "org.jboss.tools.central.refreshDiscovery"); toolBarManager.add(item); toolBarManager.update(true); section.setTextClient(headerComposite); }
@Override public void createPartControl(final Composite parent) { resizeAction = new Action("Resize", SWT.TOGGLE) { @Override public void run() { updatePreview(true); } }; resizeAction.setImageDescriptor( Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "/icons/resize.png")); GridLayoutFactory.fillDefaults().numColumns(2).spacing(0, 0).applyTo(parent); ToolBar toolbar = new ToolBar(parent, SWT.VERTICAL | SWT.FLAT); toolbar.setBackground(toolbar.getDisplay().getSystemColor(SWT.COLOR_GRAY)); ToolBarManager toolbarManager = new ToolBarManager(toolbar); toolbarManager.add(resizeAction); GridDataFactory.fillDefaults() .grab(false, true) .align(SWT.BEGINNING, SWT.FILL) .applyTo(toolbar); toolbarManager.update(true); container = new Composite(parent, SWT.NONE); container.setLayout(new FillLayout()); GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(container); getSite().getPage().addPartListener(trackRelevantEditorsPartListener); tryConnectTo(getSite().getPage().getActiveEditor()); }
/** * To Manage the creation of an ancestor action to manage the visibilty of the ancestor Pane. * * @param ok boolean parameters if true the action is created if false the action is not created. * @param toolBarManager the ToolBarManager on which the action should be added */ private void createAncestorPaneManagerAction(ToolBarManager toolBarManager, boolean ok) { if (ok) { toolBarManager.add(showHideAncestor); Separator separator = new Separator(); toolBarManager.add(separator); } }
/* * (non-Javadoc) * * @see * org.xmind.ui.properties.PropertyEditor#setBackground(org.eclipse.swt. * graphics.Color) */ @Override public void setBackground(Color color) { super.setBackground(color); if (getControl() != null && !getControl().isDisposed()) getControl().setBackground(color); if (toolBar != null && toolBar.getControl() != null && !toolBar.getControl().isDisposed()) toolBar.getControl().setBackground(color); }
private ToolBar createToolbar(final MUIElement element, Composite parent) { int orientation = getOrientation(element); ToolBarManager manager = getManager((MToolBar) element); if (manager == null) { manager = new ToolBarManager(orientation | SWT.WRAP | SWT.FLAT | SWT.RIGHT); IContributionManagerOverrides overrides = null; MApplicationElement parentElement = element.getParent(); if (parentElement == null) { parentElement = (MApplicationElement) ((EObject) element).eContainer(); } if (parentElement != null) { overrides = (IContributionManagerOverrides) parentElement.getTransientData().get(IContributionManagerOverrides.class.getName()); } manager.setOverrides(overrides); linkModelToManager((MToolBar) element, manager); } ToolBar bar = manager.createControl(parent); bar.setData(manager); bar.setData(AbstractPartRenderer.OWNING_ME, element); bar.getShell().layout(new Control[] {bar}, SWT.DEFER); bar.addDisposeListener( new DisposeListener() { public void widgetDisposed(DisposeEvent e) { cleanUp((MToolBar) element); } }); return bar; }
/** Updates the history controls. */ private void updateHistoryControls() { historyToolbar.update(false); IContributionItem[] items = historyToolbar.getItems(); for (int i = 0; i < items.length; i++) { items[i].update(IAction.ENABLED); items[i].update(IAction.TOOL_TIP_TEXT); } }
/** * Create the filter controls. By default, a text and corresponding tool bar button that clears * the contents of the text is created. Subclasses may override. * * @param parent parent <code>Composite</code> of the filter controls * @return the <code>Composite</code> that contains the filter controls */ protected Composite createFilterControls(Composite parent) { createFilterText(parent); createClearText(parent); filterToolBar.update(false); // initially there is no text to clear filterToolBar.getControl().setVisible(false); return parent; }
@Override protected void fillCoolBar(ICoolBarManager coolBar) { ToolBarManager toolBarManager = new ToolBarManager(SWT.ARROW_DOWN); coolBar.add(toolBarManager); toolBarManager.add(introAction); toolBarManager.add(saveAction); }
/** * Set the background for the widgets that support the filter text area. * * @param background background <code>Color</code> to set */ public void setBackground(Color background) { super.setBackground(background); if (filterComposite != null) { filterComposite.setBackground(background); } if (filterToolBar != null && filterToolBar.getControl() != null) { filterToolBar.getControl().setBackground(background); } }
private Control createToolBar(Composite parent) { toolBar = new ToolBarManager(); picker = new ColorPicker(configurer.getPopupStyle(), configurer.getPalette()); configureColorPicker(picker); toolBar.add(picker); toolBar.createControl(parent); return toolBar.getControl(); }
@Override protected void createToolbarItems(ToolBarManager manager) { IAction action = getActionRegistry().getAction(IActionIDConstant.CV_ADD); manager.add(action); action = getActionRegistry().getAction(IActionIDConstant.CV_DELETE); manager.add(action); action = getActionRegistry().getAction(IActionIDConstant.CV_MOVE_UP); manager.add(action); action = getActionRegistry().getAction(IActionIDConstant.CV_MOVE_DOWN); manager.add(action); }
private void initializeToolbars(Composite parent) { ToolBarManager tbm = CompareViewerPane.getToolBarManager(parent); if (tbm != null) { tbm.removeAll(); // define groups tbm.add(new Separator("modes")); // $NON-NLS-1$ tbm.add(new Separator("merge")); // $NON-NLS-1$ tbm.add(new Separator("navigation")); // $NON-NLS-1$ CompareConfiguration cc = getCompareConfiguration(); if (cc.isRightEditable()) { fCopyLeftToRightAction = new Action() { public void run() { copy(true); } }; Utilities.initAction( fCopyLeftToRightAction, getResourceBundle(), "action.CopyLeftToRight."); // $NON-NLS-1$ tbm.appendToGroup("merge", fCopyLeftToRightAction); // $NON-NLS-1$ fHandlerService.registerAction( fCopyLeftToRightAction, "org.eclipse.compare.copyAllLeftToRight"); // $NON-NLS-1$ } if (cc.isLeftEditable()) { fCopyRightToLeftAction = new Action() { public void run() { copy(false); } }; Utilities.initAction( fCopyRightToLeftAction, getResourceBundle(), "action.CopyRightToLeft."); // $NON-NLS-1$ tbm.appendToGroup("merge", fCopyRightToLeftAction); // $NON-NLS-1$ fHandlerService.registerAction( fCopyRightToLeftAction, "org.eclipse.compare.copyAllRightToLeft"); // $NON-NLS-1$ } final ChangePropertyAction a = new ChangePropertyAction( fBundle, getCompareConfiguration(), "action.EnableAncestor.", ICompareUIConstants.PROP_ANCESTOR_VISIBLE); // $NON-NLS-1$ a.setChecked(fAncestorVisible); fAncestorItem = new ActionContributionItem(a); fAncestorItem.setVisible(false); tbm.appendToGroup("modes", fAncestorItem); // $NON-NLS-1$ tbm.getControl().addDisposeListener(a); createToolItems(tbm); updateToolItems(); tbm.update(true); } }
@Override protected void fillToolBar(ToolBarManager toolBar) { if (needsRefresh()) { IAction repositoryConfigRefresh = doCreateRefreshAction(); toolBar.add(repositoryConfigRefresh); } }
/** * @param parentManager * @param itemModel * @param ci */ private void addToManager( ToolBarManager parentManager, MToolBarElement model, IContributionItem ci) { MElementContainer<MUIElement> parent = model.getParent(); // technically this shouldn't happen if (parent == null) { parentManager.add(ci); } else { int index = parent.getChildren().indexOf(model); // shouldn't be -1, but better safe than sorry if (index > parentManager.getSize() || index == -1) { parentManager.add(ci); } else { parentManager.insert(index, ci); } } }
private void createMemoryBlocksTreeViewPane(Composite parent) { fMemBlkViewer = new MemoryBlocksTreeViewPane(this); fViewPanes.put(MemoryBlocksTreeViewPane.PANE_ID, fMemBlkViewer); ViewForm viewerViewForm = new ViewForm(parent, SWT.NONE); PlatformUI.getWorkbench() .getHelpSystem() .setHelp( viewerViewForm, IDebugUIConstants.PLUGIN_ID + ".MemoryView_context"); // $NON-NLS-1$ fViewPaneControls.put(MemoryBlocksTreeViewPane.PANE_ID, viewerViewForm); fWeights.add(Integer.valueOf(15)); fMemBlkViewer.addSelectionListener(fSelectionProvider); Control viewerControl = fMemBlkViewer.createViewPane( viewerViewForm, MemoryBlocksTreeViewPane.PANE_ID, DebugUIMessages.MemoryView_Memory_monitors); viewerViewForm.setContent(viewerControl); ISelection selection = fMemBlkViewer.getSelectionProvider().getSelection(); if (selection != null) fSelectionProvider.setSelection(selection); ToolBarManager viewerToolBarMgr = new ToolBarManager(SWT.FLAT); IAction[] actions = fMemBlkViewer.getActions(); for (int i = 0; i < actions.length; i++) { viewerToolBarMgr.add(actions[i]); } ToolBar viewerToolbar = viewerToolBarMgr.createControl(viewerViewForm); viewerViewForm.setTopRight(viewerToolbar); Label viewerLabel = new Label(viewerViewForm, SWT.WRAP); viewerLabel.setText(DebugUIMessages.MemoryView_Memory_monitors); viewerViewForm.setTopLeft(viewerLabel); fMemBlkViewer .getControl() .addFocusListener( new FocusAdapter() { @Override public void focusGained(FocusEvent e) { fActivePaneId = fMemBlkViewer.getId(); } }); }
public void handleEvent(Event event) { // Ensure that this event is for a MMenuItem if (!(event.getProperty(UIEvents.EventTags.ELEMENT) instanceof MToolBarElement)) return; MToolBarElement itemModel = (MToolBarElement) event.getProperty(UIEvents.EventTags.ELEMENT); String attName = (String) event.getProperty(UIEvents.EventTags.ATTNAME); if (UIEvents.UIElement.TOBERENDERED.equals(attName)) { Object obj = itemModel.getParent(); if (!(obj instanceof MToolBar)) { return; } ToolBarManager parent = getManager((MToolBar) obj); if (itemModel.isToBeRendered()) { if (parent != null) { modelProcessSwitch(parent, itemModel); parent.update(true); ToolBar tb = parent.getControl(); if (tb != null && !tb.isDisposed()) { tb.pack(true); tb.getShell().layout(new Control[] {tb}, SWT.DEFER); } } } else { IContributionItem ici = modelToContribution.remove(itemModel); if (ici != null && parent != null) { parent.remove(ici); } if (ici != null) { ici.dispose(); } } } else if (UIEvents.UIElement.VISIBLE.equals(attName)) { IContributionItem ici = getContribution(itemModel); if (ici == null) { return; } ici.setVisible(itemModel.isVisible()); ToolBarManager parent = (ToolBarManager) ((ContributionItem) ici).getParent(); if (parent != null) { parent.markDirty(); parent.update(true); // MUIElement tbModel = itemModel.getParent(); // disposeToolbarIfNecessary((MToolBar) tbModel); ToolBar tb = parent.getControl(); if (tb != null && !tb.isDisposed()) { tb.pack(true); tb.getShell().layout(new Control[] {tb}, SWT.DEFER); } } } }
@Override protected void contributeEditorCommands(ToolBarManager toolBarManager) { super.contributeEditorCommands(toolBarManager); toolBarManager.add(new Separator()); toolBarManager.add( new ControlContribution("DDLFormat") { @Override protected Control createControl(Composite parent) { final Combo ddlFormatCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY | SWT.DROP_DOWN); ddlFormatCombo.setToolTipText("DDL Format"); for (OracleDDLFormat format : OracleDDLFormat.values()) { ddlFormatCombo.add(format.getTitle()); if (format == ddlFormat) { ddlFormatCombo.select(ddlFormatCombo.getItemCount() - 1); } } ddlFormatCombo.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { for (OracleDDLFormat format : OracleDDLFormat.values()) { if (format.ordinal() == ddlFormatCombo.getSelectionIndex()) { ddlFormat = format; getEditorInput() .getDatabaseObject() .getDataSource() .getContainer() .getPreferenceStore() .setValue(OracleConstants.PREF_KEY_DDL_FORMAT, ddlFormat.name()); refreshPart(this, true); break; } } } }); return ddlFormatCombo; } }); }
@Override public void dispose() { if (refreshJobChangeListener != null) { RefreshDiscoveryJob.INSTANCE.removeJobChangeListener(refreshJobChangeListener); refreshJobChangeListener = null; } if (toolBarManager != null) { toolBarManager.dispose(); toolBarManager = null; } super.dispose(); }
/** * Sets the child viewer. This method should only be called once, after the viewer has been * created. * * @param aViewer the new child viewer */ public void setChildTree(TreeViewer aViewer) { // Save viewer. fChildTree = aViewer; // Create adapter. adapter = new DrillDownAdapter(fChildTree); adapter.addNavigationActions(toolBarMgr); toolBarMgr.update(true); // Set tree layout. fChildTree.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); layout(); }
private void createSectionToolbar(Section section, FormToolkit toolkit) { ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT); 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() { public void widgetDisposed(DisposeEvent e) { if (handCursor.isDisposed() == false) { handCursor.dispose(); } } }); fNewPluginAction = new NewPluginAction(); fNewFragmentAction = new NewFragmentAction(); toolBarManager.add(fNewPluginAction); toolBarManager.add(fNewFragmentAction); toolBarManager.update(true); section.setTextClient(toolbar); }
private void internalRefresh(Object input) { IMergeViewerContentProvider content = getMergeContentProvider(); if (content == null) { return; } Object ancestor = content.getAncestorContent(input); boolean oldFlag = fIsThreeWay; if (Utilities.isHunk(input)) { fIsThreeWay = true; } else if (input instanceof ICompareInput) fIsThreeWay = (((ICompareInput) input).getKind() & Differencer.DIRECTION_MASK) != 0; else fIsThreeWay = ancestor != null; if (fAncestorItem != null) fAncestorItem.setVisible(fIsThreeWay); if (fAncestorVisible && oldFlag != fIsThreeWay) fComposite.layout(true); Object left = content.getLeftContent(input); Object right = content.getRightContent(input); updateContent(ancestor, left, right); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=453799 // Content provider may be disposed after call to updateContent() content = getMergeContentProvider(); if (content == null) { return; } updateHeader(); ToolBarManager tbm = CompareViewerPane.getToolBarManager(fComposite.getParent()); if (tbm != null) { updateToolItems(); tbm.update(true); tbm.getControl().getParent().layout(true); } }
/** * Adds the header to a parent composite. * * @param parent the parent */ protected void createHeader(Composite parent) { final Composite headerComposite = new Composite(parent, SWT.NONE); final GridLayout headerLayout = GridLayoutFactory.fillDefaults().create(); headerComposite.setLayout(headerLayout); GridDataFactory.fillDefaults() .align(SWT.FILL, SWT.FILL) .grab(true, false) .applyTo(headerComposite); headerBgColor = new Color(parent.getDisplay(), new RGB(220, 240, 247)); headerComposite.setBackground(headerBgColor); final EObject modelElement = getViewModelContext().getDomainModel(); final EditingDomain editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(modelElement); /* The header of the composite */ if (modelElement.eContainer() == null && !DynamicEObjectImpl.class.isInstance(modelElement)) { final Composite header = getPageHeader(headerComposite); final List<Action> actions = readToolbarActions(modelElement, editingDomain); final ToolBar toolBar = new ToolBar(header, SWT.FLAT | SWT.RIGHT); final FormData formData = new FormData(); formData.right = new FormAttachment(100, 0); toolBar.setLayoutData(formData); toolBar.layout(); final ToolBarManager toolBarManager = new ToolBarManager(toolBar); /* Add actions to header */ for (final Action action : actions) { toolBarManager.add(action); } toolBarManager.update(true); header.layout(); } }
protected void createSectionToolbar(Section section, FormToolkit toolkit) { ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT); 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(); } } }); // save ActionContributionItem saveMenuAction = new ActionContributionItem(ActionFactory.SAVE.create(getEditorSite().getWorkbenchWindow())); toolBarManager.add(saveMenuAction); toolBarManager.update(true); section.setTextClient(toolbar); }
/* * @see edu.berkeley.eduride.isa.ui.text.java.hover.AbstractAnnotationHover.AnnotationInfo#fillToolBar(org.eclipse.jface.action.ToolBarManager) */ public void fillToolBar(ToolBarManager manager, IInformationControl infoControl) { super.fillToolBar(manager, infoControl); if (!(annotation instanceof IJavaAnnotation)) return; IJavaAnnotation javaAnnotation = (IJavaAnnotation) annotation; String optionId = JavaCore.getOptionForConfigurableSeverity(javaAnnotation.getId()); if (optionId != null) { IJavaProject javaProject = javaAnnotation.getCompilationUnit().getJavaProject(); boolean isJavadocProblem = (javaAnnotation.getId() & IProblem.Javadoc) != 0; ConfigureProblemSeverityAction problemSeverityAction = new ConfigureProblemSeverityAction( javaProject, optionId, isJavadocProblem, infoControl); manager.add(problemSeverityAction); } }
/** Creates the navigation buttons for this viewer. */ protected void createNavigationButtons() { GridData gid; GridLayout layout; // Define layout. layout = new GridLayout(); layout.marginHeight = layout.marginWidth = layout.horizontalSpacing = layout.verticalSpacing = 0; setLayout(layout); // Create a toolbar. toolBarMgr = new ToolBarManager(SWT.FLAT); ToolBar toolBar = toolBarMgr.createControl(this); gid = new GridData(); gid.horizontalAlignment = GridData.FILL; gid.verticalAlignment = GridData.BEGINNING; toolBar.setLayoutData(gid); }
/** * Create the composite. * * @param parent a widget which will be the parent of the new instance (cannot be null) * @param style the style of widget to construct */ public VisualisationDiffToolBar(Composite parent, int style) { super(parent, style); createActions(); setLayout(new FormLayout()); /** Left Tool Bar */ Composite leftToolBarComposite = new Composite(this, SWT.NONE); leftToolBarComposite.setLayout(new FormLayout()); FormData fdleftToolBarComposite = new FormData(); fdleftToolBarComposite.top = new FormAttachment(0); fdleftToolBarComposite.left = new FormAttachment(0); leftToolBarComposite.setLayoutData(fdleftToolBarComposite); ToolBar leftToolBar = new ToolBar(leftToolBarComposite, SWT.FLAT | SWT.RIGHT); FormData fdleftToolBar = new FormData(); fdleftToolBar.top = new FormAttachment(0); leftToolBar.setLayoutData(fdleftToolBar); visualizationType = new ToolItem(leftToolBar, SWT.NONE); visualizationType.setImage( ResourceManager.getPluginImage( "org.eclipse.emf.compare.ui.2", "iconsMainTBar/differencesIcon.gif")); visualizationType.setText("Visualizatin of Structural Differences"); // lblNewLabel.setImage(ResourceManager.getPluginImage("org.eclipse.emf.compare.ui.2", // "icons/next_nav_into.gif")); leftToolBar.update(); /** RighToolBar */ ToolBar righToolBar = new ToolBar(this, SWT.FLAT | SWT.RIGHT); FormData fdRighToolBar = new FormData(); fdRighToolBar.top = new FormAttachment(0); fdRighToolBar.right = new FormAttachment(100); righToolBar.setLayoutData(fdRighToolBar); ToolBarManager righToolBarManager = new ToolBarManager(righToolBar); createAncestorPaneManagerAction(righToolBarManager, EMFCompareConfiguration.fThreeWay); righToolBarManager.add(copyAlltoRight); righToolBarManager.add(copyAlltoLeft); righToolBarManager.add(copyLeftTorRight); righToolBarManager.add(copyRightToLeft); righToolBarManager.add(new Separator()); righToolBarManager.add(nextChange); righToolBarManager.add(previousChange); righToolBar.update(); righToolBarManager.update(true); }
protected void fillCoolBar(ICoolBarManager coolBar) { final ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT); coolBar.add(toolBarManager); toolBarManager.add(saveAction); toolBarManager.add(new Separator()); toolBarManager.add(undoAction); toolBarManager.add(redoAction); toolBarManager.add(openglAction); }