List of usage examples for org.eclipse.jface.viewers IStructuredSelection size
public int size();
From source file:com.cloudbees.eclipse.dtp.internal.actions.DeleteDatabaseAction.java
License:Open Source License
@Override public void run(IAction action) { if (action instanceof ObjectPluginAction) { ObjectPluginAction pluginAction = (ObjectPluginAction) action; ISelection selection = pluginAction.getSelection(); if (selection instanceof IStructuredSelection) { final IStructuredSelection structSelection = (IStructuredSelection) selection; @SuppressWarnings("unchecked") final Iterator<DatabaseInfo> iterator = structSelection.iterator(); String name = "-"; if (structSelection.size() == 1) { DatabaseInfo d = (DatabaseInfo) structSelection.getFirstElement(); name = d.getName();//from w ww .ja va 2 s. c o m } try { final String target = structSelection.size() > 1 ? "the selected databases" : "'" + name + "'"; String question = MessageFormat.format("Are you sure you want to delete {0}?", target); boolean confirmed = MessageDialog.openQuestion(Display.getCurrent().getActiveShell(), "Delete", question); if (confirmed) { org.eclipse.core.runtime.jobs.Job job = new org.eclipse.core.runtime.jobs.Job( "Deleting " + target) { @Override protected IStatus run(final IProgressMonitor monitor) { monitor.beginTask("Deleting " + target + "...", structSelection.size() * 10); try { while (iterator.hasNext()) { DatabaseInfo databaseInfo = iterator.next(); monitor.subTask("Deleting '" + databaseInfo.getName() + "'..."); BeesSDK.deleteDatabase(databaseInfo.getName()); monitor.worked(5); deleteDatabaseConnectionProfile(databaseInfo); monitor.worked(5); } CloudBeesDataToolsPlugin.getPoller().fetchAndUpdateDatabases(monitor); CloudBeesUIPlugin.getDefault().fireDatabaseInfoChanged(); } catch (Exception e) { CloudBeesDataToolsPlugin.logErrorAndShowDialog(e); } finally { monitor.done(); } return Status.OK_STATUS; } }; job.setUser(true); job.schedule(); } } catch (Exception e) { CloudBeesDataToolsPlugin.logError(e); } } } }
From source file:com.cloudbees.eclipse.run.ui.popup.actions.DeleteAction.java
License:Open Source License
@Override public void run(IAction action) { if (action instanceof ObjectPluginAction) { ObjectPluginAction pluginAction = (ObjectPluginAction) action; ISelection selection = pluginAction.getSelection(); if (selection instanceof IStructuredSelection) { final IStructuredSelection structSelection = (IStructuredSelection) selection; @SuppressWarnings("unchecked") final Iterator<ApplicationInfo> iterator = structSelection.iterator(); String name = "-"; if (structSelection.size() == 1) { ApplicationInfo d = (ApplicationInfo) structSelection.getFirstElement(); name = d.getId();/*w w w.j a va 2 s. c o m*/ } try { final String target = structSelection.size() > 1 ? "the selected apps" : "'" + name + "'"; String question = MessageFormat.format("Are you sure you want to delete {0}?", target); boolean confirmed = MessageDialog.openQuestion(Display.getCurrent().getActiveShell(), "Delete", question); if (confirmed) { org.eclipse.core.runtime.jobs.Job job = new org.eclipse.core.runtime.jobs.Job( "Deleting " + target) { @Override protected IStatus run(final IProgressMonitor monitor) { monitor.beginTask("Deleting " + target + "...", structSelection.size() * 10); try { while (iterator.hasNext()) { ApplicationInfo applicationInfo = iterator.next(); monitor.subTask("Deleting '" + applicationInfo.getId() + "'..."); BeesSDK.delete(applicationInfo.getId()); monitor.worked(10); } CBRunCoreActivator.getPoller().fetchAndUpdateApps(); CloudBeesUIPlugin.getDefault().fireApplicationInfoChanged(); } catch (Exception e) { CBRunUiActivator.logErrorAndShowDialog(e); } finally { monitor.done(); } return Status.OK_STATUS; } }; job.setUser(true); job.schedule(); } } catch (Exception e) { CBRunUiActivator.logError(e); } } } }
From source file:com.collabnet.subversion.merge.views.MergeResultsView.java
License:Open Source License
private void fillContextMenu(IMenuManager manager) { boolean enableOpen = false; IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection(); Iterator iter = selection.iterator(); while (iter.hasNext()) { Object element = iter.next(); if (element instanceof AdaptableMergeResult) { MergeResult mergeResult = (MergeResult) element; if (mergeResult.getResource() instanceof IFile && !mergeResult.isDelete()) { enableOpen = true;/*from w ww .j ava 2 s. c o m*/ } } if (enableOpen) break; } if (enableOpen) { manager.add(openAction); } if (enableOpen && selection.size() == 1) { MenuManager submenu = new MenuManager(Messages.MergeResultsView_openWith); MergeResult mergeResult = (MergeResult) selection.getFirstElement(); submenu.add(new OpenWithMenu(getSite().getPage(), mergeResult.getResource())); manager.add(submenu); } manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); }
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 w w w . j a v a 2 s . com 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 ww . j a v a 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.delegreg.rpgm.games.basic.statblocks.ui.D20StatBlockDetailsPage.java
License:Open Source License
public void selectionChanged(IFormPart part, ISelection selection) { IStructuredSelection ssel = (IStructuredSelection) selection; if (ssel.size() == 1) { input = (D20StatBlock) ssel.getFirstElement(); } else/*from w w w .jav a2s . c o m*/ input = null; update(); }
From source file:com.delegreg.rpgm.statblocks.ui.DefaultStatBlockDetailsPage.java
License:Open Source License
public void selectionChanged(IFormPart part, ISelection selection) { IStructuredSelection ssel = (IStructuredSelection) selection; if (ssel.size() == 1) { input = (DefaultStatBlock) ssel.getFirstElement(); } else/*from w w w . ja v a 2 s . com*/ input = null; update(); }
From source file:com.dnw.depmap.AnalyzeDependencyJob.java
License:Open Source License
/** * Traverses the selection to find out files of known types. * /*from ww w . jav a 2 s. c o m*/ * @author manbaum * @since Oct 17, 2014 * @param selection the selection of Java elements to be analyzed. * @param monitor the progress monitor. * @return an <code>IResourceFinder</code> object holds the result. */ private final IResourceFinder filterSupportedResource(IStructuredSelection selection, IProgressMonitor monitor) { FactoryBasedResourceFinder finder = new FactoryBasedResourceFinder(Activator.factory, monitor); try { monitor.beginTask("Finding files...", selection.size()); for (@SuppressWarnings("rawtypes") Iterator it = selection.iterator(); it.hasNext();) { Object element = it.next(); try { if (element instanceof IResource) { ((IResource) element).accept(finder); } else if (element instanceof IAdaptable) { IResource resource = (IResource) ((IAdaptable) element).getAdapter(IResource.class); if (resource != null) resource.accept(finder); } } catch (CoreException e) { Activator.console.println(e); } } } finally { monitor.done(); } return finder; }
From source file:com.drgarbage.controlflowgraphfactory.actions.OrderAbstractAction.java
License:Apache License
/** * Sets active Editor.//from w w w . ja va 2s . c o m * @param editor the editor to set */ public void setActiveEditor(ControlFlowGraphEditor editor) { this.editor = editor; editor.getGraphicalViewer().addSelectionChangedListener(new ISelectionChangedListener() { /* (non-Javadoc) * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) */ public void selectionChanged(SelectionChangedEvent event) { Object o = event.getSelection(); if (o instanceof IStructuredSelection) { IStructuredSelection sel = (IStructuredSelection) o; if (sel.size() > 1) { setEnabled(true); } else { setEnabled(false); } } } }); }
From source file:com.dubture.twig.ui.wizards.TwigNewFileWizardPage.java
License:Open Source License
/** * Tests if the current workbench selection is a suitable container to use. *///from w w w .j a va2 s . co m private void initialize() { Logger.debugMSG("Initializing twig file wizard"); if (selection != null && selection.isEmpty() == false && selection instanceof IStructuredSelection) { IStructuredSelection ssel = (IStructuredSelection) selection; if (ssel.size() > 1) { Logger.debugMSG("Selection container more than one elements."); return; } Object obj = ssel.getFirstElement(); if (obj instanceof IScriptFolder) { Logger.debugMSG("Selection is scriptfolder"); IScriptFolder folder = (IScriptFolder) obj; try { String fullPath = folder.getUnderlyingResource().getFullPath().toString(); Logger.debugMSG("Setting container text to " + fullPath); containerText.setText(fullPath); } catch (ModelException e) { Logger.logException(e); } } else if (obj instanceof ProjectFragment) { IProjectFragment fragment = (IProjectFragment) obj; Logger.debugMSG("Selection is projectfragment"); try { String fullPath = fragment.getUnderlyingResource().getFullPath().toString(); Logger.debugMSG("Setting container text to " + fullPath); containerText.setText(fullPath); } catch (ModelException e) { Logger.logException(e); } } else if (obj instanceof IScriptProject) { IScriptProject proj = (IScriptProject) obj; Logger.debugMSG("Selection is scriptproject"); containerText.setText(proj.getPath().toString()); } else if (obj instanceof IFolder) { IFolder folder = (IFolder) obj; Logger.debugMSG("Selection is folder"); containerText.setText(folder.getFullPath().toString()); } else { Logger.debugMSG("Could not determine selection type"); if (obj != null) { Logger.debugMSG("type was " + obj.getClass()); } else { Logger.debugMSG("type was null"); } } } else { Logger.debugMSG("File wizard couldn't retrieve selection"); } Logger.debugMSG("Final container text: " + containerText.getText()); fileText.setText("template.twig"); fileText.forceFocus(); fileText.setSelection(0, 8); }