public void setActions(IAction[] actions) { toolBarManager.removeAll(); if (actions == null) return; for (int i = 0; i < actions.length; i++) { toolBarManager.add(createActionContributionItem(actions[i])); } toolBarManager.update(true); }
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); } }
protected void createDefaultActions() { toolBarManager.removeAll(); if ((gridStyle & IGridViewer.NoToolBar) == 0) { if ((gridStyle & IGridViewer.fullEditable) != 0) { Element element = null; try { // element = // LoadSchemaManager.getSchemaManager().getElement( // data); element = CompositeMapUtil.getElement(data); } catch (Exception e) { // do nothing } if (element != null && element.isArray()) { final QualifiedName qName = element.getElementType().getQName(); Action addAction = new AddElementAction(this, data, qName, ActionListener.NONE); addAction.setText(""); addAction.setHoverImageDescriptor( AuroraPlugin.getImageDescriptor(LocaleMessage.getString("add.icon"))); Action removeAction = new RemoveElementAction(this, ActionListener.DefaultImage); Action refreshAction = new RefreshAction(this, ActionListener.DefaultImage); toolBarManager.add(createActionContributionItem(addAction)); toolBarManager.add(createActionContributionItem(refreshAction)); toolBarManager.add(createActionContributionItem(removeAction)); toolBarManager.update(true); tableViewer .getTable() .addKeyListener( new KeyListener() { public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.DEL) { removeElement(); } } public void keyReleased(KeyEvent e) {} }); } } } if ((gridStyle & IGridViewer.isMulti) != 0) { Action allCheckAction = new Action( LocaleMessage.getString("all.checed"), AuroraPlugin.getImageDescriptor(LocaleMessage.getString("checked.icon"))) { public void run() { setAllChecked(tableViewer.getTable(), true); } }; Action unAllCheckAction = new Action( LocaleMessage.getString("non.checed"), AuroraPlugin.getImageDescriptor(LocaleMessage.getString("unchecked.icon"))) { public void run() { setAllChecked(tableViewer.getTable(), false); } }; toolBarManager.add(createActionContributionItem(allCheckAction)); toolBarManager.add(createActionContributionItem(unAllCheckAction)); toolBarManager.update(true); } }
private void updateLeftHeaderToolBar() { leftToolBarManager.removeAll(); leftToolBarManager.add(new Separator("activation")); // $NON-NLS-1$ leftToolBarManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); // initialLeftToolbarSize = leftToolBarManager.getSize(); leftToolBarManager.add(activateAction); // for (IFormPage page : getPages()) { // if (page instanceof AbstractTaskEditorPage) { // AbstractTaskEditorPage taskEditorPage = (AbstractTaskEditorPage) page; // taskEditorPage.fillLeftHeaderToolBar(leftToolBarManager); // } else if (page instanceof TaskPlanningEditor) { // TaskPlanningEditor taskEditorPage = (TaskPlanningEditor) page; // taskEditorPage.fillLeftHeaderToolBar(leftToolBarManager); // } // } // add external contributions menuService = (IMenuService) getSite().getService(IMenuService.class); if (menuService != null && leftToolBarManager instanceof ContributionManager) { TaskRepository outgoingNewRepository = TasksUiUtil.getOutgoingNewTaskRepository(task); TaskRepository taskRepository = (outgoingNewRepository != null) ? outgoingNewRepository : taskEditorInput.getTaskRepository(); menuService.populateContributionManager( leftToolBarManager, "toolbar:" + ID_LEFT_TOOLBAR_HEADER + "." //$NON-NLS-1$ //$NON-NLS-2$ + taskRepository.getConnectorKind()); } leftToolBarManager.update(true); if (hasLeftToolBar()) { // XXX work around a bug in Gtk that causes the toolbar size to be incorrect if no // tool bar buttons are contributed // if (leftToolBar != null) { // Point size = leftToolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT, false); // boolean changed = false; // for (Control control : leftToolBar.getChildren()) { // final Point childSize = control.computeSize(SWT.DEFAULT, SWT.DEFAULT, false); // if (childSize.y > size.y) { // size.y = childSize.y; // changed = true; // } // } // if (changed) { // leftToolBar.setSize(size); // } // } // // if (PlatformUtil.isToolBarHeightBroken(leftToolBar)) { // ToolItem item = new ToolItem(leftToolBar, SWT.NONE); // item.setEnabled(false); // item.setImage(CommonImages.getImage(CommonImages.BLANK)); // item.setWidth(1); // noExtraPadding = true; // } else if (PlatformUtil.needsToolItemToForceToolBarHeight()) { // ToolItem item = new ToolItem(leftToolBar, SWT.NONE); // item.setEnabled(false); // int scaleHeight = 22; // if (PlatformUtil.needsCarbonToolBarFix()) { // scaleHeight = 32; // } // final Image image = new Image(item.getDisplay(), // CommonImages.getImage(CommonImages.BLANK) // .getImageData() // .scaledTo(1, scaleHeight)); // item.setImage(image); // item.addDisposeListener(new DisposeListener() { // public void widgetDisposed(DisposeEvent e) { // image.dispose(); // } // }); // item.setWidth(1); // noExtraPadding = true; // } // fix size of toolbar on Gtk with Eclipse 3.3 Point size = leftToolBar.getSize(); if (size.x == 0 && size.y == 0) { size = leftToolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); leftToolBar.setSize(size); } } }