List of usage examples for org.eclipse.jface.viewers ISelectionProvider ISelectionProvider
ISelectionProvider
From source file:com.aptana.ide.debug.internal.ui.actions.BreakpointPropertiesAction.java
License:Open Source License
/** * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) *///from ww w.j a v a2s . c o m public void run(IAction action) { PropertyDialogAction propertyAction = new PropertyDialogAction( new SameShellProvider(DebugUiPlugin.getActiveWorkbenchShell()), new ISelectionProvider() { public void addSelectionChangedListener(ISelectionChangedListener listener) { } public ISelection getSelection() { return new StructuredSelection(breakpoint); } public void removeSelectionChangedListener(ISelectionChangedListener listener) { } public void setSelection(ISelection selection) { } }); propertyAction.run(); }
From source file:com.aptana.ide.debug.internal.ui.actions.BreakpointPropertiesRulerAction.java
License:Open Source License
/** * @see org.eclipse.jface.action.IAction#run() *//*from www . ja v a2 s . c om*/ public void run() { if (getBreakpoint() != null) { PropertyDialogAction action = new PropertyDialogAction( new SameShellProvider(getTextEditor().getEditorSite().getShell()), new ISelectionProvider() { public void addSelectionChangedListener(ISelectionChangedListener listener) { } public ISelection getSelection() { return new StructuredSelection(getBreakpoint()); } public void removeSelectionChangedListener(ISelectionChangedListener listener) { } public void setSelection(ISelection selection) { } }); action.run(); } }
From source file:com.aptana.ide.logging.view.LogView.java
License:Open Source License
/** * Hooks context menu.//from w w w . ja v a2s . c om */ private void hookContextMenu() { menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$ menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager manager) { fillContextMenu(manager); } }); Menu menu = menuMgr.createContextMenu(tabFolder); tabFolder.setMenu(menu); getSite().registerContextMenu(menuMgr, new ISelectionProvider() { public void addSelectionChangedListener(ISelectionChangedListener listener) { } public ISelection getSelection() { return null; } public void removeSelectionChangedListener(ISelectionChangedListener listener) { } public void setSelection(ISelection selection) { } }); }
From source file:com.aptana.ide.update.internal.manager.P2Eclipse35PluginManager.java
License:Open Source License
/** * @see com.aptana.ide.update.manager.IPluginManager#uninstall(IPlugin, IProgressMonitor) *//*from ww w .j ava 2 s . c o m*/ public IStatus uninstall(IPlugin plugin, IProgressMonitor monitor) throws PluginManagerException { if (monitor.isCanceled()) { return Status.CANCEL_STATUS; } String profileId = IProfileRegistry.SELF; Collector roots = new Collector(); try { InstallableUnitQuery query = new InstallableUnitQuery(getFeatureGroupName(plugin), Version.parseVersion(plugin.getVersion())); ProfileElement element = new ProfileElement(null, profileId); roots = element.getQueryable().query(query, roots, monitor); } catch (CoreException e) { IdeLog.logError(P2Eclipse35Activator.getDefault(), e.getMessage(), e); } if (roots == null || roots.size() <= 0) { throw new PluginManagerException( P2Eclipse35Messages.P2PluginManager_ERR_MSG_No_installable_units_found); } final IInstallableUnit[] ius = (IInstallableUnit[]) roots.toArray(IInstallableUnit.class); if (monitor.isCanceled()) { return Status.CANCEL_STATUS; } UninstallAction action = new UninstallAction(Policy.getDefault(), new ISelectionProvider() { public void addSelectionChangedListener(ISelectionChangedListener listener) { } public ISelection getSelection() { return new StructuredSelection(ius); } public void removeSelectionChangedListener(ISelectionChangedListener listener) { } public void setSelection(ISelection selection) { } }, profileId); action.run(); return Status.OK_STATUS; }
From source file:com.aptana.js.debug.ui.internal.actions.BreakpointPropertiesAction.java
License:Open Source License
/** * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */// w w w .j av a 2 s . c o m public void run(IAction action) { PropertyDialogAction propertyAction = new PropertyDialogAction( new SameShellProvider(UIUtils.getActiveShell()), new ISelectionProvider() { public void addSelectionChangedListener(ISelectionChangedListener listener) { } public ISelection getSelection() { return new StructuredSelection(breakpoint); } public void removeSelectionChangedListener(ISelectionChangedListener listener) { } public void setSelection(ISelection selection) { } }); propertyAction.run(); }
From source file:com.aptana.php.debug.ui.actions.breakpoints.PHPBreakpointPropertiesRulerAction.java
License:Open Source License
/** * @see Action#run()/* w w w .ja v a 2 s . co m*/ */ @Override public void run() { if (getBreakpoint() != null) { final PropertyDialogAction action = new PropertyDialogAction(getEditor().getEditorSite(), new ISelectionProvider() { public void addSelectionChangedListener(final ISelectionChangedListener listener) { } @SuppressWarnings("synthetic-access") public ISelection getSelection() { return new StructuredSelection(getBreakpoint()); } public void removeSelectionChangedListener(final ISelectionChangedListener listener) { } public void setSelection(final ISelection selection) { } }); action.run(); } }
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();/* ww w.j ava 2 s . 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.javadude.antxr.eclipse.ui.actions.JavaBreakpointPropertiesAction.java
License:Open Source License
/** {@inheritDoc} */ public void run(IAction action) { IShellProvider shellProvider = new IShellProvider() { public Shell getShell() { return AntxrUIPlugin.getActiveWorkbenchShell(); }//from w w w. j a v a 2 s. c o m }; PropertyDialogAction propertyAction = new PropertyDialogAction(shellProvider, new ISelectionProvider() { public void addSelectionChangedListener(ISelectionChangedListener listener) { // nothing to do here } public ISelection getSelection() { return new StructuredSelection(getBreakpoint()); } public void removeSelectionChangedListener(ISelectionChangedListener listener) { // nothing to do here } public void setSelection(ISelection selection) { // nothing to do here } }); propertyAction.run(); }
From source file:com.javadude.antxr.eclipse.ui.actions.JavaBreakpointPropertiesRulerAction.java
License:Open Source License
/** {@inheritDoc} */ public void run() { if (getBreakpoint() != null) { IShellProvider shellProvider = new IShellProvider() { public Shell getShell() { return getTextEditor().getEditorSite().getShell(); }//from w w w .j a va 2 s .c om }; PropertyDialogAction action = new PropertyDialogAction(shellProvider, new ISelectionProvider() { public void addSelectionChangedListener(ISelectionChangedListener listener) { // nothing to do here } public ISelection getSelection() { return new StructuredSelection(getBreakpoint()); } public void removeSelectionChangedListener(ISelectionChangedListener listener) { // nothing to do here } public void setSelection(ISelection selection) { // nothing to do here } }); action.run(); } }
From source file:com.mentor.nucleus.bp.debug.ui.actions.BPBreakpointPropertiesAction.java
License:Open Source License
public void run(IAction action) { PropertyDialogAction propertyAction = new PropertyDialogAction(fPart.getSite(), new ISelectionProvider() { public void addSelectionChangedListener(ISelectionChangedListener listener) { }// w w w . ja v a 2s. c o m public ISelection getSelection() { return new StructuredSelection(getBreakpoint()); } public void removeSelectionChangedListener(ISelectionChangedListener listener) { } public void setSelection(ISelection selection) { } }); propertyAction.run(); }