List of usage examples for org.eclipse.jface.action ControlContribution ControlContribution
protected ControlContribution(String id)
From source file:com.collabnet.subversion.merge.wizards.MergeWizardRevisionsPage.java
License:Open Source License
public void createControl(Composite parent) { final MergeWizard wizard = (MergeWizard) getWizard(); resources = wizard.getResources();/*from www . j av a2s.c o m*/ if (resources != null && resources.length > 0) { svnResource = SVNWorkspaceRoot.getSVNResourceFor(resources[0]); try { repositoryLocation = svnResource.getRepository(); } catch (Exception e1) { } } Composite composite = new Composite(parent, SWT.NULL); GridLayout layout = new GridLayout(); layout.verticalSpacing = 0; layout.marginHeight = 0; composite.setLayout(layout); GridData data = new GridData(GridData.FILL_BOTH); composite.setLayoutData(data); horizontalSash = new SashForm(composite, SWT.HORIZONTAL); horizontalSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); verticalSash = new SashForm(horizontalSash, SWT.VERTICAL); GridLayout sashLayout = new GridLayout(); sashLayout.verticalSpacing = 0; sashLayout.marginHeight = 0; verticalSash.setLayout(sashLayout); verticalSash.setLayoutData(new GridData(GridData.FILL_BOTH)); Composite historyGroup = new Composite(verticalSash, SWT.NULL); GridLayout historyLayout = new GridLayout(); historyLayout.verticalSpacing = 5; historyLayout.marginHeight = 0; historyGroup.setLayout(historyLayout); historyGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); Composite filterGroup = new Composite(historyGroup, SWT.NULL); GridLayout filterLayout = new GridLayout(); filterLayout.verticalSpacing = 0; filterLayout.marginHeight = 0; filterLayout.numColumns = 3; filterGroup.setLayout(filterLayout); filterGroup.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL)); Label filterLabel = new Label(filterGroup, SWT.NULL); filterLabel.setText(Messages.MergeWizardRevisionsPage_filter); filterText = new Text(filterGroup, SWT.BORDER); filterText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL)); filterText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { tableHistoryViewer.addFilter(new TextViewFilter()); tableHistoryViewer.refresh(); TableItem[] items = tableHistoryViewer.getTable().getItems(); for (TableItem item : items) { ILogEntry entry = adaptToLogEntry(item.getData()); if (entry != null) { SVNRevision.Number revision = entry.getRevision(); item.setChecked(selectedRevisions.contains(revision)); } } showMessage(); } }); this.moreOptionsButton = new Button(filterGroup, 8); this.moreOptionsButton.setText(Messages.MergeWizardRevisionsPage_moreOptions); SelectionListener selectionListener = getSelectionListener(); this.moreOptionsButton.addSelectionListener(selectionListener); historyTableProvider = new HistoryTableProvider( SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION | SWT.CHECK, pageName); historyTableProvider.setIncludeMergeRevisions(false); historyTableProvider.setIncludeTags(false); tableHistoryViewer = historyTableProvider.createTable(historyGroup); data = new GridData(GridData.FILL_BOTH); data.widthHint = 500; data.heightHint = 100; tableHistoryViewer.getTable().setLayoutData(data); tableHistoryViewer.setContentProvider(new IStructuredContentProvider() { public void dispose() { } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } public Object[] getElements(Object inputElement) { if (entries == null) return new ILogEntry[0]; return entries; } }); tableHistoryViewer.setInput(getUrl()); tableHistoryViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { generateChangeLogButton.setEnabled(!tableHistoryViewer.getSelection().isEmpty()); TableItem[] items = tableHistoryViewer.getTable().getItems(); for (TableItem item : items) { ILogEntry entry = adaptToLogEntry(item.getData()); SVNRevision.Number revision = entry.getRevision(); if (item.getChecked()) { selectedRevisions.add(revision); } else { selectedRevisions.remove(revision); } } if (selectedRevisions.size() == 0) { if (message == null) showMessage(); else setMessage(message); } else { // check size of entries and table data setMessage(selectedRevisions.size() + Messages.MergeWizardRevisionsPage_revisionsSelected); } setPageComplete(canFinish()); } }); tableHistoryViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { setPageComplete(canFinish()); ISelection selection = event.getSelection(); if (selection == null || !(selection instanceof IStructuredSelection)) { textViewer.setDocument(new Document("")); //$NON-NLS-1$ changePathsViewer.setInput(null); return; } IStructuredSelection ss = (IStructuredSelection) selection; if (ss.size() != 1) { textViewer.setDocument(new Document("")); //$NON-NLS-1$ changePathsViewer.setInput(null); return; } LogEntry entry = (LogEntry) ss.getFirstElement(); textViewer.setDocument(new Document(entry.getComment())); changePathsViewer.setCurrentLogEntry(entry); changePathsViewer.setInput(entry); } }); generateChangeLogAction = new GenerateChangeLogAction(new ISelectionProvider() { public void addSelectionChangedListener(ISelectionChangedListener listener) { } public ISelection getSelection() { return tableHistoryViewer.getSelection(); } public void setSelection(ISelection selection) { } public void removeSelectionChangedListener(ISelectionChangedListener listener) { } }); MenuManager menuMgr = new MenuManager(); Menu menu = menuMgr.createContextMenu(tableHistoryViewer.getTable()); menuMgr.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager menuMgr) { if (!tableHistoryViewer.getSelection().isEmpty()) { menuMgr.add(new ToggleSelectionAction()); menuMgr.add(generateChangeLogAction); } } }); menuMgr.setRemoveAllWhenShown(true); tableHistoryViewer.getTable().setMenu(menu); Composite commentGroup = new Composite(verticalSash, SWT.NULL); GridLayout commentLayout = new GridLayout(); commentLayout.verticalSpacing = 0; commentLayout.marginHeight = 0; commentGroup.setLayout(commentLayout); commentGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); textViewer = new TextViewer(commentGroup, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.READ_ONLY); data = new GridData(GridData.FILL_BOTH); data.heightHint = 100; data.widthHint = 500; textViewer.getControl().setLayoutData(data); Composite pathGroup = new Composite(verticalSash, SWT.NULL); GridLayout pathLayout = new GridLayout(); pathLayout.verticalSpacing = 0; pathLayout.marginHeight = 0; pathGroup.setLayout(pathLayout); pathGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); ViewForm viewerPane = new ViewForm(pathGroup, SWT.BORDER | SWT.FLAT); viewerPane.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); CLabel toolbarLabel = new CLabel(viewerPane, SWT.NONE) { public Point computeSize(int wHint, int hHint, boolean changed) { return super.computeSize(wHint, Math.max(24, hHint), changed); } }; toolbarLabel.setText(Messages.MergeWizardRevisionsPage_2); viewerPane.setTopLeft(toolbarLabel); ToolBar toolbar = new ToolBar(viewerPane, SWT.FLAT); viewerPane.setTopCenter(toolbar); ToolBarManager toolbarManager = new ToolBarManager(toolbar); toolbarManager.add(new Separator()); toolbarManager.add(new ControlContribution("showCompare") { //$NON-NLS-1$ @Override protected Control createControl(Composite parent) { showCompareButton = new Button(parent, SWT.TOGGLE | SWT.FLAT); showCompareButton.setImage(SVNUIPlugin.getImage(ISVNUIConstants.IMG_SYNCPANE)); showCompareButton.setToolTipText(Messages.MergeWizardRevisionsPage_4); showCompareButton.setSelection(showCompare); showCompareButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { showComparePane(!showCompare); if (showCompare) { compareRevisions(); } } }); return showCompareButton; } }); toolbarManager.update(true); ChangePathsTreeContentProvider contentProvider = new ChangePathsTreeContentProvider(); changePathsViewer = new ChangePathsTreeViewer(viewerPane, contentProvider); viewerPane.setContent(changePathsViewer.getTree()); changePathsViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { compareRevisions(); } }); changePathsViewer.getTree().addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (showCompare) { compareRevisions(); } } }); setPageComplete(canFinish()); if (message == null) setMessage(Messages.MergeWizardRevisionsPage_specifyRevisions); else setMessage(message); try { int[] weights = new int[3]; weights[0] = settings.getInt("MergeWizardRevisionsPageWeights0"); //$NON-NLS-1$ weights[1] = settings.getInt("MergeWizardRevisionsPageWeights1"); //$NON-NLS-1$ weights[2] = settings.getInt("MergeWizardRevisionsPageWeights2"); //$NON-NLS-1$ verticalSash.setWeights(weights); } catch (Exception e) { } compareViewerPane = new CompareViewerSwitchingPane(horizontalSash, SWT.BORDER | SWT.FLAT) { protected Viewer getViewer(Viewer oldViewer, Object input) { CompareConfiguration cc = compareInput.getCompareConfiguration(); cc.setLeftEditable(false); cc.setRightEditable(false); cc.setLeftLabel(compareInput.getLeftLabel()); cc.setRightLabel(compareInput.getRightLabel()); return CompareUI.findContentViewer(oldViewer, input, this, cc); } }; compareViewerPane.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); try { int[] weights = new int[2]; weights[0] = settings.getInt("MergeWizardRevisionsPageWeightsHorizontal0"); //$NON-NLS-1$ weights[1] = settings.getInt("MergeWizardRevisionsPageWeightsHorizontal1"); //$NON-NLS-1$ horizontalSash.setWeights(weights); } catch (Exception e) { } Composite buttonGroup = new Composite(composite, SWT.NULL); GridLayout buttonLayout = new GridLayout(); buttonLayout.numColumns = 3; buttonGroup.setLayout(buttonLayout); data = new GridData(GridData.HORIZONTAL_ALIGN_CENTER); buttonGroup.setLayoutData(data); generateChangeLogButton = new Button(buttonGroup, SWT.PUSH); generateChangeLogButton.setText(Messages.MergeWizardRevisionsPage_generateChangeLog); generateChangeLogButton.setEnabled(false); generateChangeLogButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { generateChangeLogAction.run(); } }); if (!showCompare) { horizontalSash.setMaximizedControl(verticalSash); } else { showCompareButton.setSelection(true); } setControl(composite); }
From source file:com.collabnet.subversion.merge.wizards.MergeWizardUnblockRevisionsPage.java
License:Open Source License
public void createControl(Composite parent) { final MergeWizard wizard = (MergeWizard) getWizard(); resource = wizard.getResource();//from w w w . j a va 2s.co m if (resource != null) { svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource); try { repositoryLocation = svnResource.getRepository(); } catch (Exception e1) { } } Composite composite = new Composite(parent, SWT.NULL); GridLayout layout = new GridLayout(); layout.verticalSpacing = 0; layout.marginHeight = 0; composite.setLayout(layout); GridData data = new GridData(GridData.FILL_BOTH); composite.setLayoutData(data); horizontalSash = new SashForm(composite, SWT.HORIZONTAL); horizontalSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); verticalSash = new SashForm(horizontalSash, SWT.VERTICAL); GridLayout sashLayout = new GridLayout(); sashLayout.verticalSpacing = 0; sashLayout.marginHeight = 0; verticalSash.setLayout(sashLayout); verticalSash.setLayoutData(new GridData(GridData.FILL_BOTH)); Composite historyGroup = new Composite(verticalSash, SWT.NULL); GridLayout historyLayout = new GridLayout(); historyLayout.verticalSpacing = 0; historyLayout.marginHeight = 0; historyGroup.setLayout(historyLayout); historyGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); historyTableProvider = new HistoryTableProvider( SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION | SWT.CHECK, "MergeWizardUnblockRevisionsPage"); //$NON-NLS-1$ historyTableProvider.setIncludeMergeRevisions(false); historyTableProvider.setIncludeTags(false); tableHistoryViewer = historyTableProvider.createTable(historyGroup); data = new GridData(GridData.FILL_BOTH); data.widthHint = 500; data.heightHint = 100; tableHistoryViewer.getTable().setLayoutData(data); tableHistoryViewer.setContentProvider(new IStructuredContentProvider() { public void dispose() { } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } public Object[] getElements(Object inputElement) { if (entries == null) return new ILogEntry[0]; return entries; } }); tableHistoryViewer.setInput(fromUrl); tableHistoryViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { setPageComplete(canFinish()); ISelection selection = event.getSelection(); if (selection == null || !(selection instanceof IStructuredSelection)) { textViewer.setDocument(new Document("")); //$NON-NLS-1$ changePathsViewer.setInput(null); return; } IStructuredSelection ss = (IStructuredSelection) selection; if (ss.size() != 1) { textViewer.setDocument(new Document("")); //$NON-NLS-1$ changePathsViewer.setInput(null); return; } LogEntry entry = (LogEntry) ss.getFirstElement(); textViewer.setDocument(new Document(entry.getComment())); changePathsViewer.setCurrentLogEntry(entry); changePathsViewer.setInput(entry); } }); MenuManager menuMgr = new MenuManager(); Menu menu = menuMgr.createContextMenu(tableHistoryViewer.getTable()); menuMgr.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager menuMgr) { if (!tableHistoryViewer.getSelection().isEmpty()) { menuMgr.add(new ToggleSelectionAction()); } } }); menuMgr.setRemoveAllWhenShown(true); tableHistoryViewer.getTable().setMenu(menu); Composite commentGroup = new Composite(verticalSash, SWT.NULL); GridLayout commentLayout = new GridLayout(); commentLayout.verticalSpacing = 0; commentLayout.marginHeight = 0; commentGroup.setLayout(commentLayout); commentGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); textViewer = new TextViewer(commentGroup, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.READ_ONLY); data = new GridData(GridData.FILL_BOTH); data.heightHint = 100; data.widthHint = 500; textViewer.getControl().setLayoutData(data); Composite pathGroup = new Composite(verticalSash, SWT.NULL); GridLayout pathLayout = new GridLayout(); pathLayout.verticalSpacing = 0; pathLayout.marginHeight = 0; pathGroup.setLayout(pathLayout); pathGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); ViewForm viewerPane = new ViewForm(pathGroup, SWT.BORDER | SWT.FLAT); viewerPane.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); CLabel toolbarLabel = new CLabel(viewerPane, SWT.NONE) { public Point computeSize(int wHint, int hHint, boolean changed) { return super.computeSize(wHint, Math.max(24, hHint), changed); } }; toolbarLabel.setText(Messages.MergeWizardRevisionsPage_2); viewerPane.setTopLeft(toolbarLabel); ToolBar toolbar = new ToolBar(viewerPane, SWT.FLAT); viewerPane.setTopCenter(toolbar); ToolBarManager toolbarManager = new ToolBarManager(toolbar); toolbarManager.add(new Separator()); toolbarManager.add(new ControlContribution("showCompare") { //$NON-NLS-1$ @Override protected Control createControl(Composite parent) { showCompareButton = new Button(parent, SWT.TOGGLE | SWT.FLAT); showCompareButton.setImage(SVNUIPlugin.getImage(ISVNUIConstants.IMG_SYNCPANE)); showCompareButton.setToolTipText(Messages.MergeWizardRevisionsPage_4); showCompareButton.setSelection(showCompare); showCompareButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { showComparePane(!showCompare); if (showCompare) { compareRevisions(); } } }); return showCompareButton; } }); toolbarManager.update(true); ChangePathsTreeContentProvider contentProvider = new ChangePathsTreeContentProvider(); changePathsViewer = new ChangePathsTreeViewer(viewerPane, contentProvider); viewerPane.setContent(changePathsViewer.getTree()); changePathsViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { compareRevisions(); } }); changePathsViewer.getTree().addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (showCompare) { compareRevisions(); } } }); setPageComplete(false); setMessage(Messages.MergeWizardUnblockRevisionsPage_specifyRevisions); try { int[] weights = new int[3]; weights[0] = settings.getInt("MergeWizardRevisionsPageWeights0"); //$NON-NLS-1$ weights[1] = settings.getInt("MergeWizardRevisionsPageWeights1"); //$NON-NLS-1$ weights[2] = settings.getInt("MergeWizardRevisionsPageWeights2"); //$NON-NLS-1$ verticalSash.setWeights(weights); } catch (Exception e) { } compareViewerPane = new CompareViewerSwitchingPane(horizontalSash, SWT.BORDER | SWT.FLAT) { protected Viewer getViewer(Viewer oldViewer, Object input) { CompareConfiguration cc = compareInput.getCompareConfiguration(); cc.setLeftEditable(false); cc.setRightEditable(false); cc.setLeftLabel(compareInput.getLeftLabel()); cc.setRightLabel(compareInput.getRightLabel()); return CompareUI.findContentViewer(oldViewer, input, this, cc); } }; compareViewerPane.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); try { int[] weights = new int[2]; weights[0] = settings.getInt("MergeWizardRevisionsPageWeightsHorizontal0"); //$NON-NLS-1$ weights[1] = settings.getInt("MergeWizardRevisionsPageWeightsHorizontal1"); //$NON-NLS-1$ horizontalSash.setWeights(weights); } catch (Exception e) { } if (!showCompare) { horizontalSash.setMaximizedControl(verticalSash); } else { showCompareButton.setSelection(true); } setControl(composite); }
From source file:com.matlab.eclipse.mconsole.views.MatlabConsoleView.java
License:Open Source License
private void fillLocalToolBar(IToolBarManager manager) { manager.add(new GroupMarker("matlabpause")); manager.add(new Separator("matlabpause")); manager.add(pauseMatlabAction);/*from w w w. j a va 2 s. co m*/ manager.add(new GroupMarker("chooser")); manager.add(new Separator("chooser")); manager.appendToGroup("chooser", new ControlContribution("none") { //$NON-NLS-1$ @Override protected int computeWidth(Control control) { return 300; } @Override protected Control createControl(Composite parent) { dirChooser = new Combo(parent, SWT.NONE); dirChooser.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { String dirtochange = dirChooser.getText(); final String workspaceRoot = ResourcesPlugin.getWorkspace().getRoot().getLocation() .toString(); if (dirtochange.indexOf("%WS") > -1) { dirtochange = dirtochange.replaceFirst("%WS", workspaceRoot); } else if (dirtochange.indexOf("~") > -1) { dirtochange = dirtochange.replaceFirst("~", System.getenv("HOME")); } MConsolePlugin.getDefault().getMatlab().changeMatlabDirectoryToPath(dirtochange); } }); dirChooser.addKeyListener(new KeyAdapter() { @Override public void keyPressed(final KeyEvent e) { if (e.character == SWT.CR) { run("cd " + dirChooser.getText(), null); } } }); if (MConsolePlugin.getDefault().isMatlabInitialized()) try { dirChooser.setText(MConsolePlugin.getDefault().getMatlab().getMatlabPwd()); } catch (Exception e) { } dirChooser.setEnabled(false); return dirChooser; } }); manager.appendToGroup("chooser", dirChooseAction); manager.appendToGroup("chooser", dirUpAction); manager.add(new GroupMarker("com.matlab.eclipse")); manager.add(new Separator("com.matlab.eclipse")); manager.add(raiseFiguresAction); manager.add(closeAllFiguresAction); manager.add(new GroupMarker("others")); manager.add(new Separator("others")); manager.add(clearCommandHistoryAction); manager.add(helpBrowserAction); manager.add(new GroupMarker("debug")); manager.add(new Separator("debug")); manager.add(debugConsoleViewAction); manager.add(new GroupMarker("matlab")); manager.add(new Separator("matlab")); manager.add(stopMatlabAction); manager.add(startMatlabAction); }
From source file:com.onpositive.richtexteditor.actions.ActionFactory.java
License:Open Source License
/** * @return font style change action/* w ww .j a va 2s . co m*/ */ public IContributionItem getStyleContributionItem() { if (controlContribution == null) { controlContribution = new ControlContribution("style") { protected Control createControl(Composite parent) { combo = new StyleCombo(parent, SWT.READ_ONLY | SWT.BORDER); combo.setItems(manager.getFontStyleManager().getFontStyleDisplayNames()); combo.setText(manager.getFontStyleManager().getDefaultStyle().getDisplayName()); combo.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { if (combo.getSelectionIndex() > -1) { if (viewer.getSelectedRange().y > 0) { manager.changeFontCommand(combo.getItem(combo.getSelectionIndex()), viewer.getSelectedRange().x, viewer.getSelectedRange().y); viewer.getTextWidget().setFocus(); } else { setCurrentBasePartitionState(); viewer.getTextWidget().setFocus(); } } } }); return combo; } }; } return controlContribution; }
From source file:com.onpositive.richtexteditor.actions.ActionFactory.java
License:Open Source License
public ArrayList<IContributionItem> createActionsList() { initContainers();/*w w w . jav a 2s. c o m*/ // addActionToList(new ControlContribution("Zoom") { // // // protected Control createControl(Composite parent) { // final CCombo cmd = new CCombo(parent, SWT.NONE); // final float[] zooms = new float[] { 0.5f, 0.75f, 1f, 2f, 3f }; // cmd.setItems(new String[] { "50%", "75%", "100%", "200%", // "300%" }); // cmd.select(2); // cmd.addSelectionListener(new SelectionListener() { // // public void widgetDefaultSelected(SelectionEvent e) { // // } // // public void widgetSelected(SelectionEvent e) { // int selectionIndex = cmd.getSelectionIndex(); // manager.setScale(zooms[selectionIndex]); // } // // }); // return cmd; // } // // }); addActionToList(new ActionContributionItem(this.getBoldAction())); addActionToList(new ActionContributionItem(this.getItalicAction())); addActionToList(new ActionContributionItem(this.getUnderlineAction())); addActionToList(new ActionContributionItem(this.getSupAction())); addActionToList(new ActionContributionItem(this.getSubAction())); // TODO IMPLEMENT IT addActionToList(new ActionContributionItem(this.getStrikeThroughAction())); addActionToList(new Separator()); addActionToList(this.getStyleContributionItem()); addActionToList(new Separator()); addActionToList(new ActionContributionItem(this.getAlignLeftAction())); addActionToList(new ActionContributionItem(this.getAlignRightAction())); addActionToList(new ActionContributionItem(this.getAlignCenterAction())); addActionToList(new ActionContributionItem(this.getAlignJustifyAction())); addActionToList(new ActionContributionItem(this.getIncreaseFirstLineIndentAction())); addActionToList(new ActionContributionItem(this.getDecreaseFirstLineIndentAction())); addActionToList(new ActionContributionItem(this.getSingleSpacingAction())); addActionToList(new ActionContributionItem(this.getOneAndHalfSpacingAction())); addActionToList(new ActionContributionItem(this.getDoubleSpacingAction())); addActionToList(new Separator()); addActionToList(new ActionContributionItem(this.getIncreaseRightIndentAction())); addActionToList(new ActionContributionItem(this.getDecreaseRightIndentAction())); addActionToList(new Separator()); addActionToList(new ActionContributionItem(this.getNewLinkAction())); addActionToList(new Separator()); addActionToList(new ActionContributionItem(this.getBulletedListAction())); addActionToList(new ActionContributionItem(this.getNumberedListAction())); addActionToList(new Separator()); // fix for Windows toolbar redrawing issue addActionToList(new ControlContribution("") { protected Control createControl(Composite parent) { // parent.setLayout(new FillLayout()); ToolBar toolbar = new ToolBar(parent, SWT.NONE); ToolBarManager ma = new ToolBarManager(toolbar); ma.add(getForegroundColorAction()); ma.add(new Separator()); ma.add(getBackgroundColorAction()); ma.update(true); return ma.getControl(); } }); addActionToList(new Separator()); addActionToList(new ActionContributionItem(this.getAddImageAction())); addActionToList(new ActionContributionItem(this.getAddRegionAction())); // TODO OPTIMIZE IT // addActionToList(new // ActionContributionItem(this.getAddJavaRegionAction())); addActionToList(new Separator()); addActionToList(new ActionContributionItem(this.getOpenFileAction())); addActionToList(new Separator()); addActionToList(new ActionContributionItem(this.getAddHRAction())); addActionToList(new ActionContributionItem(this.getCustomizeFontStyleAction())); return resList; }
From source file:com.programmablefun.ide.App.java
License:Open Source License
private void createToolbar() { coolBarManager = new CoolBarManager(SWT.FLAT); final ToolBarManager vmToolBarManager = new ToolBarManager(SWT.FLAT | SWT.NO_FOCUS); coolBarManager.add(vmToolBarManager); vmToolBarManager.add(vmStartAction); vmToolBarManager.add(vmPauseAction); vmToolBarManager.add(vmResumeAction); vmToolBarManager.add(vmStopAction);/* ww w .ja v a 2 s. c om*/ vmToolBarManager.add(vmStepIntoAction); vmToolBarManager.add(vmStepOverAction); final ToolBarManager helpToolBarManager = new ToolBarManager(SWT.FLAT | SWT.NO_FOCUS); coolBarManager.add(helpToolBarManager); helpToolBarManager.add(new ControlContribution("trace-code") { @Override protected Control createControl(Composite parent) { Button checkbox = new Button(parent, SWT.CHECK); checkbox.setText(Messages.get(Toolbar_FollowCodeExecution)); checkbox.setSelection(highlightLines); checkbox.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { highlightLines = checkbox.getSelection(); } }); return checkbox; } }); helpToolBarManager.add(helpAction); coolBarManager.createControl(shell); }
From source file:com.siteview.mde.internal.ui.editor.schema.SchemaFormPage.java
License:Open Source License
private ControlContribution createUIControlConPreviewRefDoc() { return new ControlContribution("Preview") { //$NON-NLS-1$ protected Control createControl(Composite parent) { // Create UI createUIImageHyperlinkPreviewRefDoc(parent); // Create Listener createUIListenerImageHyperlinkPreviewRefDoc(); return fImageHyperlinkPreviewRefDoc; }/*w w w. j a va2s. com*/ }; }
From source file:com.siteview.mde.internal.ui.editor.targetdefinition.TargetEditor.java
License:Open Source License
public void contributeToToolbar(final ScrolledForm form, String contextID) { ControlContribution setAsTarget = new ControlContribution("Set") { //$NON-NLS-1$ protected Control createControl(Composite parent) { final ImageHyperlink hyperlink = new ImageHyperlink(parent, SWT.NONE); hyperlink.setText(MDEUIMessages.AbstractTargetPage_setTarget); hyperlink.setUnderlined(true); hyperlink.setForeground(getToolkit().getHyperlinkGroup().getForeground()); hyperlink.addHyperlinkListener(new IHyperlinkListener() { public void linkActivated(HyperlinkEvent e) { LoadTargetDefinitionJob.load(getTarget()); }// w w w . j av a2s. com public void linkEntered(HyperlinkEvent e) { hyperlink.setForeground(getToolkit().getHyperlinkGroup().getActiveForeground()); } public void linkExited(HyperlinkEvent e) { hyperlink.setForeground(getToolkit().getHyperlinkGroup().getForeground()); } }); return hyperlink; } }; final String helpContextID = contextID; Action help = new Action("help") { //$NON-NLS-1$ public void run() { BusyIndicator.showWhile(form.getForm().getDisplay(), new Runnable() { public void run() { PlatformUI.getWorkbench().getHelpSystem().displayHelp(helpContextID); } }); } }; help.setToolTipText(MDEUIMessages.PDEFormPage_help); help.setImageDescriptor(MDEPluginImages.DESC_HELP); Action export = new Action("export") { //$NON-NLS-1$ public void run() { TargetDefinitionExportWizard wizard = new TargetDefinitionExportWizard(getTarget()); wizard.setWindowTitle(MDEUIMessages.ExportActiveTargetDefinition); WizardDialog dialog = new WizardDialog(getSite().getShell(), wizard); dialog.open(); } }; export.setToolTipText("Export"); //$NON-NLS-1$ export.setImageDescriptor(MDEPluginImages.DESC_EXPORT_TARGET_TOOL); form.getToolBarManager().add(setAsTarget); form.getToolBarManager().add(export); form.getToolBarManager().add(help); form.updateToolBar(); }
From source file:net.openchrom.xxd.processor.supplier.rscripting.ui.code.PlaceholderLabel.java
License:Open Source License
public IContributionItem getPlaceholderLabel() { IContributionItem item = new ControlContribution("PlaceholderLabel") { protected Control createControl(Composite parent) { Composite com = new Composite(parent, SWT.NONE); // com.setLayout(layout); com.setSize(4000, 64);/*from ww w .j a va 2 s . c o m*/ Label label = new Label(com, SWT.NONE); label.setSize(4000, 64); return com; } }; return item; }
From source file:org.eclipse.egit.ui.internal.commit.CommitEditor.java
License:Open Source License
/** * @see org.eclipse.ui.forms.editor.SharedHeaderFormEditor#createHeaderContents(org.eclipse.ui.forms.IManagedForm) *//*from w w w . java 2 s. com*/ protected void createHeaderContents(IManagedForm headerForm) { RepositoryCommit commit = getCommit(); ScrolledForm form = headerForm.getForm(); new HeaderText(form.getForm(), commit.getRevCommit().name()); form.setToolTipText(commit.getRevCommit().name()); getToolkit().decorateFormHeading(form.getForm()); IToolBarManager toolbar = form.getToolBarManager(); ControlContribution repositoryLabelControl = new ControlContribution("repositoryLabel") { //$NON-NLS-1$ @Override protected Control createControl(Composite parent) { FormToolkit toolkit = getHeaderForm().getToolkit(); Composite composite = toolkit.createComposite(parent); RowLayout layout = new RowLayout(); composite.setLayout(layout); composite.setBackground(null); String label = getCommit().getRepositoryName(); ImageHyperlink link = new ImageHyperlink(composite, SWT.NONE); 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 composite; } }; toolbar.add(repositoryLabelControl); toolbar.add(createCommandContributionItem(CreateTagHandler.ID)); toolbar.add(createCommandContributionItem(CreateBranchHandler.ID)); toolbar.add(createCommandContributionItem(CheckoutHandler.ID)); toolbar.add(createCommandContributionItem(CherryPickHandler.ID)); toolbar.add(createCommandContributionItem(RevertHandler.ID)); addContributions(toolbar); toolbar.update(true); getSite().setSelectionProvider(new ISelectionProvider() { public void setSelection(ISelection selection) { // Ignored } public void removeSelectionChangedListener(ISelectionChangedListener listener) { // Ignored } public ISelection getSelection() { return new StructuredSelection(getCommit()); } public void addSelectionChangedListener(ISelectionChangedListener listener) { // Ignored } }); }