List of usage examples for org.eclipse.jface.viewers IStructuredSelection toList
public List toList();
List
. From source file:gov.redhawk.ui.views.internal.monitor.handler.StopMonitorHandler.java
License:Open Source License
@Override public Object execute(final ExecutionEvent event) throws ExecutionException { final ISelection selection = HandlerUtil.getCurrentSelection(event); if (selection instanceof IStructuredSelection) { final IStructuredSelection ss = (IStructuredSelection) selection; final IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event); final IViewReference[] viewReferences = window.getActivePage().getViewReferences(); for (final IViewReference viewReference : viewReferences) { if (viewReference.getId().equals(PortMonitorView.ID)) { final PortMonitorView view = (PortMonitorView) viewReference.getView(true); if (view != null) { for (final Object obj : ss.toList()) { if (obj instanceof EObject) { view.removeMonitor((EObject) obj); }//from w ww . ja v a2 s . c o m } } } } } return null; }
From source file:gov.redhawk.ui.views.namebrowser.internal.command.ConnectToDomainHandler.java
License:Open Source License
/** * {@inheritDoc}/*from ww w . ja v a 2 s. co m*/ */ @Override public Object execute(final ExecutionEvent event) throws ExecutionException { final ISelection selection = HandlerUtil.getCurrentSelection(event); if (selection instanceof IStructuredSelection) { final IStructuredSelection sel = (IStructuredSelection) selection; for (final Object selected : sel.toList()) { if (selected instanceof BindingNode) { final BindingNode b = (BindingNode) selected; Shell shell = HandlerUtil.getActiveShell(event); DomainConnectionUtil.showDialog(shell.getDisplay(), b.getHost(), b.getPath().split("/")[1]); } } } return null; }
From source file:gov.redhawk.ui.views.namebrowser.internal.command.Disconnect.java
License:Open Source License
@Override public Object execute(final ExecutionEvent event) throws ExecutionException { final ISelection selection = HandlerUtil.getCurrentSelection(event); if (selection instanceof IStructuredSelection) { final IStructuredSelection sel = (IStructuredSelection) selection; for (final Object selected : sel.toList()) { if (selected instanceof BindingNode && ((BindingNode) selected).getParent() == null) { final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getActivePage(); if (page != null) { final NameBrowserView view = (NameBrowserView) page.findView(NameBrowserView.ID); if (view != null) { final Job job = new Job("Disconnecting from Host") { @Override public IStatus run(final IProgressMonitor monitor) { monitor.beginTask("Disconnecting from Host", IProgressMonitor.UNKNOWN); view.disconnect((BindingNode) selected); return Status.OK_STATUS; }// ww w.j a v a 2 s . co m }; job.schedule(); } } } } } return null; }
From source file:gov.redhawk.ui.views.namebrowser.internal.command.RemoveContext.java
License:Open Source License
@Override public Object execute(final ExecutionEvent event) throws ExecutionException { final ISelection selection = HandlerUtil.getCurrentSelection(event); final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); if (page != null) { final NameBrowserView view; view = (NameBrowserView) page.findView(NameBrowserView.ID); if (view != null) { if (selection instanceof IStructuredSelection) { final IStructuredSelection sel = (IStructuredSelection) selection; final List<BindingNode> unbindList = new ArrayList<BindingNode>(); for (final Object selected : sel.toList()) { if (selected instanceof BindingNode) { unbindList.add((BindingNode) selected); }// w w w . ja v a 2 s. c om } final Job job = new Job("Remove context") { @Override protected IStatus run(final IProgressMonitor monitor) { view.removeContext(unbindList); return Status.OK_STATUS; } }; job.schedule(); } } } return null; }
From source file:gov.redhawk.ui.views.namebrowser.internal.command.UnbindObject.java
License:Open Source License
@Override public Object execute(final ExecutionEvent event) throws ExecutionException { final ISelection selection = HandlerUtil.getCurrentSelection(event); if (selection instanceof IStructuredSelection) { final IStructuredSelection sel = (IStructuredSelection) selection; final List<BindingNode> unbindList = new ArrayList<BindingNode>(); for (final Object selected : sel.toList()) { if (selected instanceof BindingNode) { unbindList.add((BindingNode) selected); }//from w w w. j a v a2 s . co m } final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); if (page != null) { final NameBrowserView view = (NameBrowserView) page.findView(NameBrowserView.ID); if (view != null) { final Job job = new Job("Unbind object") { @Override protected IStatus run(final IProgressMonitor monitor) { monitor.beginTask("Unbinding " + unbindList.size() + " objects", IProgressMonitor.UNKNOWN); view.unbind(unbindList); return Status.OK_STATUS; } }; job.setPriority(UIJob.LONG); job.schedule(); } } } return null; }
From source file:gov.redhawk.waveformviewer.ui.handler.WaveformActivity.java
License:Open Source License
@Override public Object execute(final ExecutionEvent event) throws ExecutionException { final ISelection selection = HandlerUtil.getCurrentSelection(event); final ArrayList<Object> ret = new ArrayList<Object>(); // Try to find the view that triggered this event if ((event.getTrigger() != null) && (event.getTrigger().getClass() == Event.class)) { final IWorkbenchPart part = HandlerUtil.getActivePart(event); if (part instanceof ApplicationActionListener) { this.appListener = (ApplicationActionListener) part; }/*from ww w.j av a 2 s . c o m*/ this.pages = HandlerUtil.getActiveWorkbenchWindow(event).getPages(); } // process each selection if (selection instanceof IStructuredSelection) { final IStructuredSelection ss = (IStructuredSelection) selection; for (final Object obj : ss.toList()) { processSelection(obj, ret); } } // If the triggering view was actually a listener, tell it we did // something wave related if (this.appListener != null) { this.appListener.actionPerformed(this.action, ret); } return ret; }
From source file:it.eng.spagobi.meta.editor.business.menu.BusinessModelMenuActionFactory.java
License:Mozilla Public License
public static Map<String, Collection<IAction>> getActions(IEditorPart activeEditorPart, Collection<?> descriptors, ISelection selection) { Map actions = new HashMap(); if (selection.isEmpty()) return actions; IStructuredSelection sselection = (IStructuredSelection) selection; List<?> list = sselection.toList(); Object target = list.get(0);/*from ww w . j a va 2 s . co m*/ if (target instanceof BusinessTable) { List editActions = new ArrayList(); List olapActions = new ArrayList(); if (((BusinessTable) target).getPhysicalTable() != null) { editActions.add(new AddIdentifierAction(activeEditorPart, selection)); editActions.add(new EditBusinessColumnsAction(activeEditorPart, selection)); editActions.add(new AddOutcomeBusinessRelationshipAction(activeEditorPart, selection)); editActions.add(new AddIncomeBusinessRelationshipAction(activeEditorPart, selection)); // editActions.add(new AddPhysicalTableToBusinessTableAction(activeEditorPart, selection)); editActions.add(new AddCalculatedFieldAction(activeEditorPart, selection)); // Add Olap Actions String tableType = getTableType((BusinessTable) target); if (tableType.equals(("generic"))) { olapActions.add(new SetCubeAction(activeEditorPart, selection)); olapActions.add(new SetDimensionAction(activeEditorPart, selection)); olapActions.add(new SetTemporalDimensionAction(activeEditorPart, selection)); olapActions.add(new SetTimeDimensionAction(activeEditorPart, selection)); } else if (tableType.equals(("cube"))) { olapActions.add(new SetDimensionAction(activeEditorPart, selection)); olapActions.add(new SetGenericAction(activeEditorPart, selection)); olapActions.add(new SetTemporalDimensionAction(activeEditorPart, selection)); olapActions.add(new SetTimeDimensionAction(activeEditorPart, selection)); } else if (tableType.contains(("dimension"))) { olapActions.add(new SetCubeAction(activeEditorPart, selection)); olapActions.add(new SetGenericAction(activeEditorPart, selection)); olapActions.add(new EditHierarchiesAction(activeEditorPart, selection)); } } else { editActions.add(new EditBusinessColumnsAction(activeEditorPart, selection)); } actions.put("Edit", editActions); actions.put("Olap", olapActions); } else if (target instanceof BusinessView) { List editActions = new ArrayList(); editActions.add(new AddIdentifierAction(activeEditorPart, selection)); editActions.add(new EditBusinessColumnsAction(activeEditorPart, selection)); editActions.add(new AddOutcomeBusinessRelationshipAction(activeEditorPart, selection)); editActions.add(new AddIncomeBusinessRelationshipAction(activeEditorPart, selection)); // editActions.add(new AddPhysicalTableToBusinessTableAction(activeEditorPart, selection)); // editActions.add(new RemovePhysicalTableToBusinessViewAction(activeEditorPart, selection)); editActions.add(new EditBusinessViewInnerJoinRelationshipsAction(activeEditorPart, selection)); editActions.add(new AddCalculatedFieldAction(activeEditorPart, selection)); actions.put("Edit", editActions); // List removeActions = new ArrayList(); // removeActions.add(new RemovePhysicalTableToBusinessViewAction(activeEditorPart, selection)); // actions.put("Remove", removeActions); } else if (target instanceof SimpleBusinessColumn) { List editActions = new ArrayList(); List removeActions = new ArrayList(); List olapActions = new ArrayList(); BusinessColumn businessColumn = (BusinessColumn) target; if ((businessColumn.isIdentifier()) || (businessColumn.isPartOfCompositeIdentifier())) { RemoveFromIdentifierAction removeFromIdentifierAction = new RemoveFromIdentifierAction( activeEditorPart, selection); Command command = removeFromIdentifierAction.getPerformFinishCommand(); // Check if Command is executable if (command instanceof ISpagoBIModelCommand) { removeActions.add(removeFromIdentifierAction); } actions.put("Edit", removeActions); } else { AddToIdentifierAction addToIdentifierAction = new AddToIdentifierAction(activeEditorPart, selection); Command command = addToIdentifierAction.getPerformFinishCommand(); // Check if Command is executable if (command instanceof ISpagoBIModelCommand) { editActions.add(addToIdentifierAction); } actions.put("Edit", editActions); } // Link to ProfileAttribute LinkToProfileAttributeAction linkToProfileAttributeAction = new LinkToProfileAttributeAction( activeEditorPart, selection); Command command = linkToProfileAttributeAction.getPerformFinishCommand(); // Check if Command is executable if (command instanceof ISpagoBIModelCommand) { editActions.add(linkToProfileAttributeAction); } if (!removeActions.isEmpty()) { editActions.addAll(removeActions); } actions.put("Edit", editActions); // Cube commands Cube cube = checkIfInsideCube((BusinessColumn) target); if (cube != null) { String columnType = getColumnType((BusinessColumn) target); if (columnType.equals(("attribute"))) { olapActions.add(new SetMeasureAction(activeEditorPart, selection)); } else if (columnType.equals(("measure"))) { olapActions.add(new SetAttributeAction(activeEditorPart, selection)); } actions.put("Olap", olapActions); } } else if (target instanceof CalculatedBusinessColumn) { List editActions = new ArrayList(); List removeActions = new ArrayList(); CalculatedBusinessColumn businessColumn = (CalculatedBusinessColumn) target; editActions.add(new AddCalculatedFieldAction(activeEditorPart, selection)); editActions.add(new LinkToProfileAttributeAction(activeEditorPart, selection)); actions.put("Edit", editActions); } else if (target instanceof BusinessRootItemProvider) { List editActions = new ArrayList(); editActions.add(new AddBusinessTableAction(activeEditorPart, selection, null)); editActions.add(new AddEmptyBusinessTableAction(activeEditorPart, selection)); editActions.add(new AddBusinessRelationshipAction(activeEditorPart, selection)); actions.put("Edit", editActions); List generateActions = new ArrayList(); generateActions.add(new CreateQueryAction(activeEditorPart, selection)); generateActions.add(new GenerateJPAMappingAction(activeEditorPart, selection)); generateActions.add(new CreateMondrianAction(activeEditorPart, selection)); actions.put("Create", generateActions); // List queryActions = new ArrayList(); // queryActions.add(new CreateQueryAction(activeEditorPart, selection)); // actions.put("Query", queryActions); } return actions; }
From source file:it.eng.spagobi.meta.editor.multi.wizards.NewQueryFileProjectExplorerWizard.java
License:Mozilla Public License
@Override public void init(IWorkbench workbench, IStructuredSelection selection) { this.workbench = workbench; this.selection = selection; if (selection != null && !selection.toList().isEmpty()) { Object objSel = selection.toList().get(0); if (objSel instanceof IFile) { logger.debug("set default dataset path"); IProject project = ((IFile) objSel).getProject(); IPath pathProj = project.getFullPath(); containerFullPath = pathProj.append(SpagoBIMetaConstants.FOLDER_DATASET); }/*from w w w .j av a2s.c o m*/ } }
From source file:it.eng.spagobi.meta.editor.physical.menu.PhysicalModelMenuActionFactory.java
License:Mozilla Public License
public static Map<String, Collection<IAction>> getActions(IEditorPart activeEditorPart, Collection<?> descriptors, ISelection selection) { Map actions = new HashMap(); if (selection.isEmpty()) return actions; IStructuredSelection sselection = (IStructuredSelection) selection; List<?> list = sselection.toList(); Object target = list.get(0);//from w w w .j av a 2 s .c om if (target instanceof PhysicalRootItemProvider) { List updateActions = new ArrayList(); updateActions.add(new UpdatePhysicalModelAction(activeEditorPart, selection)); actions.put("Update", updateActions); } else if (target instanceof PhysicalTableItemProvider) { // do something... } return actions; }
From source file:it.eng.spagobi.studio.birt.actions.NewBirtAction.java
License:Mozilla Public License
public void run(IAction action) { SpagoBINewBirtReportWizard sbindw = new SpagoBINewBirtReportWizard(); // CommonViewer commViewer=((CommonNavigator) view).getCommonViewer(); // IStructuredSelection sel=(IStructuredSelection)commViewer.getSelection(); IStructuredSelection sel = (IStructuredSelection) selection; Object objSel = sel.toList().get(0); Folder folderSel = null;//from ww w . jav a 2 s . co m try { // FolderSel is the folder in wich to insert the new template folderSel = (Folder) objSel; sbindw.init(PlatformUI.getWorkbench(), sel); // Create the wizard dialog WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), sbindw); // Open the wizard dialog dialog.open(); } catch (Exception e) { // SpagoBILogger.errorLog("no selected folder", e); MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error", "You must select a folder in wich to insert the report"); } }