List of usage examples for org.eclipse.jface.viewers IStructuredSelection size
public int size();
From source file:com.ebmwebsourcing.petals.common.internal.commands.ConfigureBuildPathCommandHandler.java
License:Open Source License
@Override public void setEnabled(Object evaluationContext) { boolean enabled = false; try {//from w w w . ja v a 2 s.c o m if (PlatformUI.getWorkbench() != null && PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null && PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService() != null && PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService() .getSelection() instanceof IStructuredSelection) { IStructuredSelection selection = (IStructuredSelection) PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getSelectionService().getSelection(); enabled = selection.size() == 1 && selection.getFirstElement() instanceof IProject && ((IProject) selection.getFirstElement()).isAccessible() && ((IProject) selection.getFirstElement()).hasNature(JavaCore.NATURE_ID); } } catch (Exception ex) { PetalsCommonPlugin.log(ex, IStatus.ERROR); } super.setBaseEnabled(enabled); }
From source file:com.ebmwebsourcing.petals.common.internal.formeditor.JbiFormEditor.java
License:Open Source License
@Override public void setSelection(ISelection selection) { // Update the selection this.selection = selection; for (ISelectionChangedListener listener : this.selectionListeners) { listener.selectionChanged(new SelectionChangedEvent(this, selection)); }/*from w w w . j av a 2s. c o m*/ // Update the status line try { IStatusLineManager manager = getEditorSite().getActionBars().getStatusLineManager(); if (selection instanceof IStructuredSelection) { IStructuredSelection sse = (IStructuredSelection) selection; switch (sse.size()) { case 0: manager.setMessage(""); break; case 1: ILabelProvider lp = getStatusLineLabelProvider(); if (lp != null) { String msg = lp.getText(sse.getFirstElement()); Image img = lp.getImage(sse.getFirstElement()); manager.setMessage(img, msg); } break; default: manager.setMessage(sse.size() + " selected elements"); break; } } } catch (Exception e) { PetalsCommonPlugin.log(e, IStatus.WARNING); } }
From source file:com.eco.bio7.scenebuilder.wizard.JavaFXWizardPage.java
License:Open Source License
private void initialize() { if (selection != null && selection.isEmpty() == false && selection instanceof IStructuredSelection) { IStructuredSelection ssel = (IStructuredSelection) selection; if (ssel.size() > 1) return; Object obj = ssel.getFirstElement(); if (obj instanceof IResource) { IContainer container;//from w ww . j av a 2 s . c o m if (obj instanceof IContainer) container = (IContainer) obj; else container = ((IResource) obj).getParent(); containerText.setText(container.getFullPath().toString()); } } fileText.setText("Main.java"); }
From source file:com.elphel.vdt.ui.wizards.module.NewModuleMainPage.java
License:Open Source License
/** * Tests if the current workbench selection is a suitable container to use. *//*w w w . j a v a 2 s .c o m*/ private void initialize() { if ((selection != null) && !selection.isEmpty() && (selection instanceof IStructuredSelection)) { IStructuredSelection ssel = (IStructuredSelection) selection; if (ssel.size() == 1) { Object obj = ssel.getFirstElement(); if (obj instanceof IResource) { IContainer container; if (obj instanceof IContainer) container = (IContainer) obj; else { container = ((IResource) obj).getParent(); textName.setText(((IResource) obj).getName()); } textPath.setText(container.getFullPath().toString()); textName.setText(((IResource) obj).getName()); return; } else if (obj instanceof Module) { IFile file = ((Module) obj).getSourceFile().getFile(); textPath.setText(file.getParent().getFullPath().toString()); textName.setText(file.getName()); } } } IProject project = SelectedResourceManager.getDefault().getSelectedResource().getProject(); textPath.setText(project.getFullPath().toString()); }
From source file:com.embedthis.ejs.ide.wizards.EJScriptNewBCWizardPage.java
License:Open Source License
/** * Tests if the current workbench selection is a suitable container to use. */// w w w .j ava2 s .c om private void initialize() { if (selection != null && selection.isEmpty() == false && selection instanceof IStructuredSelection) { IStructuredSelection ssel = (IStructuredSelection) selection; if (ssel.size() > 1) return; Object obj = ssel.getFirstElement(); if (obj instanceof IResource) { IContainer container; if (obj instanceof IContainer) container = (IContainer) obj; else container = ((IResource) obj).getParent(); containerText.setText(container.getFullPath().toString()); } } fileText.setText("myConfig.bc"); }
From source file:com.embedthis.ejs.ide.wizards.EJScriptNewESFileWizardPage.java
License:Open Source License
/** * Tests if the current workbench selection is a suitable container to use. *//*from w ww . j ava 2 s . c o m*/ private void initialize() { if (selection != null && selection.isEmpty() == false && selection instanceof IStructuredSelection) { IStructuredSelection ssel = (IStructuredSelection) selection; if (ssel.size() > 1) return; Object obj = ssel.getFirstElement(); if (obj instanceof IResource) { IContainer container; if (obj instanceof IContainer) container = (IContainer) obj; else container = ((IResource) obj).getParent(); containerText.setText(container.getFullPath().toString()); } } fileText.setText("new_file.es"); }
From source file:com.essiembre.eclipse.rbe.ui.wizards.ResourceBundleNewWizardPage.java
License:Apache License
/** * Tests if the current workbench selection is a suitable * container to use.// www . j ava2 s .c o m */ private void initialize() { if (selection != null && selection.isEmpty() == false && selection instanceof IStructuredSelection) { IStructuredSelection ssel = (IStructuredSelection) selection; if (ssel.size() > 1) return; Object obj = ssel.getFirstElement(); if (obj instanceof IResource) { IContainer container; if (obj instanceof IContainer) container = (IContainer) obj; else container = ((IResource) obj).getParent(); containerText.setText(container.getFullPath().toString()); } } fileText.setText("ApplicationResources"); }
From source file:com.foglyn.ui.FoglynFilterQueryPage.java
License:Open Source License
private FogBugzFilter getSelectedFilter() { IStructuredSelection selection = (IStructuredSelection) filtersList.getSelection(); if (selection.isEmpty()) { return null; }//from ww w . ja v a 2 s . co m if (selection.size() != 1) { return null; } return (FogBugzFilter) selection.getFirstElement(); }
From source file:com.foosbar.mailsnag.commands.DeleteMessage.java
License:Open Source License
/** * Main execution/*from ww w .ja v a2 s . c o m*/ */ public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchPart part = HandlerUtil.getActivePart(event); if (part instanceof MessagesView) { final MessagesView viewer = (MessagesView) part; viewer.showLogo(); IStructuredSelection iss = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); if (!iss.isEmpty()) { String message = getConfirmationMessage(iss.size()); ResourceBundle BUNDLE = Activator.getResourceBundle(); boolean confirm = MessageDialog.openConfirm(viewer.getViewer().getControl().getShell(), BUNDLE.getString("action.delete.confirm"), message); if (confirm) { deleteMessages(iss, viewer); } } } return null; }
From source file:com.gg.eclipse.closure.ui.properties.FolderSelectionDialog.java
License:Open Source License
private void updateNewFolderButtonState() { IStructuredSelection selection = (IStructuredSelection) getTreeViewer().getSelection(); fSelectedContainer = null;/*from www .ja v a 2 s. c o m*/ if (selection.size() == 1) { Object first = selection.getFirstElement(); if (first instanceof IContainer) { fSelectedContainer = (IContainer) first; } } fNewFolderButton.setEnabled(fSelectedContainer != null); }