List of usage examples for org.eclipse.jface.viewers IStructuredSelection toList
public List toList();
List
. From source file:it.eng.spagobi.studio.documentcomposition.actions.NewDocumentCompositionAction.java
License:Mozilla Public License
public void run(IAction action) { SpagoBIDocumentCompositionWizard sbindw = new SpagoBIDocumentCompositionWizard(); // CommonViewer commViewer=((CommonNavigator) view).getCommonViewer(); // IStructuredSelection sel=(IStructuredSelection)commViewer.getSelection(); IStructuredSelection sel = (IStructuredSelection) selection; Object objSel = sel.toList().get(0); Folder folderSel = null;//from w w w . ja v a2s.c o 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"); } }
From source file:it.eng.spagobi.studio.documentcomposition.wizards.pages.ModifyNavigationWizardPage.java
License:Mozilla Public License
private Parameter getNavigationItem(final Composite composite) { Parameter param = null;/*from www .j a v a 2 s. c o m*/ IStructuredSelection selection = ((SpagoBIModifyNavigationWizard) getWizard()).getSelection(); Object objSel = selection.toList().get(0); Table listOfNavigations = (Table) objSel; TableItem[] itemsSel = listOfNavigations.getSelection(); final GridLayout gl2 = new GridLayout(); gl2.numColumns = 3; gl2.marginHeight = 3; GridData gridData = new GridData(GridData.FILL_HORIZONTAL); gridData.widthHint = 200; gridData.minimumWidth = 200; gridData.grabExcessHorizontalSpace = true; gridData.horizontalSpan = 2; if (itemsSel != null && itemsSel.length != 0) { final DocumentComposition docComp = Activator.getDefault().getDocumentComposition(); if (docComp != null && docComp.getDocumentsConfiguration() != null) { Vector docs = docComp.getDocumentsConfiguration().getDocuments(); if (docs != null) { for (int i = 0; i < docs.size(); i++) { Parameters params = ((Document) docs.elementAt(i)).getParameters(); if (params != null) { for (int j = 0; j < params.getParameter().size(); j++) { param = params.getParameter().elementAt(j); String navigName = itemsSel[0].getText(); if (param.getType() != null && param.getType().equalsIgnoreCase("OUT") && param.getNavigationName() != null && param.getNavigationName().equals(navigName)) { navigationNameText.setText(navigName); navigationNameText.setEditable(false); String masterDoc = ((Document) docs.elementAt(i)).getSbiObjLabel(); String masterParam = param.getSbiParLabel(); String masterParamDefault = param.getDefaultVal(); masterDocName.setText(docInfoUtil.get(masterDoc)); masterDocName.setEditable(false); fillMasterParamsData(masterDoc); //masterParamName.setText(masterParam); String labelMaster = (String) masterParamName.getData(masterParam); if (labelMaster == null) { //edited by user labelMaster = masterParam; } masterParamName.setText(labelMaster); masterParamName.setEditable(false); masterDefaultValueOutputParam.setText(masterParamDefault); masterDefaultValueOutputParam.setEditable(false); //cicla su destinazioni Refresh refresh = param.getRefresh(); Vector<RefreshDocLinked> destinations = refresh.getRefreshDocLinked(); for (int k = 0; k < destinations.size(); k++) { //secondo composite final Composite composite2 = new Composite(composite, SWT.NONE); composite2.setLayout(gl2); destinCounter++; final RefreshDocLinked destin = destinations.get(k); String docDest = destin.getLabelDoc(); final String docDestParam = destin.getLabelParam(); //inserisce blocco x destinazione Composite destBlock = new Composite(composite2, SWT.BORDER | SWT.FILL); GridLayout glBlock = new GridLayout(); glBlock.numColumns = 3; destBlock.setLayout(glBlock); new Label(destBlock, SWT.NONE).setText("Destination document:"); destinationDocNameCombo .addElement(new Combo(destBlock, SWT.BORDER | SWT.READ_ONLY)); destinationDocNameCombo.elementAt(destinCounter).setLayoutData(gridData); destinationDocNameCombo.elementAt(destinCounter).setVisible(true); fillDestinationCombo(docDest, destinCounter); //crea una nuovo output text new Label(destBlock, SWT.NONE).setText("Input parameter:"); Combo newText = new Combo(destBlock, SWT.BORDER | SWT.READ_ONLY); destinationInputParam.addElement(newText); newText.setLayoutData(gridData); fillDestinationParamCombo(docDest, destinCounter, docDestParam); new Label(destBlock, SWT.NONE).setText("Default value:"); destinationInputParamDefaultValue .addElement(new Text(destBlock, SWT.BORDER)); destinationInputParamDefaultValue.elementAt(destinCounter) .setLayoutData(gridData); setDefaultValue(docs, destinCounter, docDest, docDestParam); final int element = k; destinationDocNameCombo.elementAt(element) .addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent event) { Combo selectedCombo = (Combo) event.widget; //ricavo dal vettore di combo la sua posizione int destinComboToRedraw = destinationDocNameCombo .indexOf(selectedCombo); //controlla se destinazione precedentem selezionata boolean canSelect = canSelectDestination( selectedCombo.getText(), destinComboToRedraw); if (!canSelect) { //messaggio di errore in dialog selectedCombo .deselect((selectedCombo).getSelectionIndex()); final boolean[] result = new boolean[1]; Shell confirm = createErrorDialog( composite2.getParent(), result, 1); confirm.setText("Error"); confirm.setSize(300, 100); confirm.open(); } else { name = destinationDocNameCombo.elementAt(element) .getText(); destinationInfo = destinationInfos.get(element); destinationInfo.setDocDestName(name); destinationInputParam.elementAt(destinComboToRedraw) .removeAll(); String label = docInfoUtil.get(name); fillDestinationParamCombo(label, destinComboToRedraw, docDestParam); destinationInputParam.elementAt(destinComboToRedraw) .redraw(); } } }); destinationInputParam.elementAt(element) .addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent event) { //verifica se gi presente... ParameterBO bo = new ParameterBO(); String docLab = docInfoUtil.get(destinationDocNameCombo .elementAt(element).getText()); // boolean exists = bo.inputParameterExists(docComp, docLab, destinationInputParam.elementAt(element).getText()); // if(exists){ // // final boolean[] result = new boolean[1]; // Shell confirm = createConfirmDialog(composite2.getParent(), result, element, destin); // confirm.open(); // // }else // { destinationInfo = destinationInfos.get(element); //destinationInfo.setParamDestName(destinationInputParam.elementAt(element).getText()); String label = destinationInputParam.elementAt(element) .getText(); String urlName = (String) destinationInputParam .elementAt(element).getData(label); destinationInfo.setParamDestName(urlName); destinationInfo.setParamDestId(destin.getIdParam()); // } } }); destinationInputParamDefaultValue.elementAt(element) .addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent event) { destinationInfo = destinationInfos.get(element); destinationInfo.setParamDefaultValue( destinationInputParamDefaultValue .elementAt(element)); destinationInfo.setParamDestId(destin.getIdParam()); } }); //pulsante delete GridData gd = new GridData(GridData.FILL); gd.horizontalSpan = 1; Button deleteDestButton = new Button(composite2, SWT.PUSH); deleteDestButtonVector.add(deleteDestButton); deleteDestButton.setText("Delete"); deleteDestButton.setLayoutData(gd); // set the counter id!! deleteDestButton.setData((Integer) destinCounter); Listener deleteListener = new Listener() { public void handleEvent(Event event) { switch (event.type) { case SWT.Selection: if (destinationDocNameCombo.size() == 1) { //non possibile cancellare destination final boolean[] result = new boolean[1]; Shell confirm = createErrorDialog(composite2.getParent(), result, 3); confirm.setText("Error"); confirm.setSize(300, 100); confirm.open(); } else { // I must get the selected combo! Button b = (Button) event.widget; Integer numero = (Integer) b.getData(); int selectionIndex = destinationDocNameCombo .elementAt(numero).getSelectionIndex(); name = destinationDocNameCombo.elementAt(numero) .getItem(selectionIndex); String nomen = destinationDocNameCombo.elementAt(numero) .getItem(selectionIndex); deletedParams.put(destin.getIdParam(), name); deleteDestination(numero, composite2); for (int i = 0; i <= destinCounter; i++) { refillDestinationCombo(null, i); } // after delete if remains only one make not visible all delete buttons! if (destinationDocNameCombo.size() == 1) { for (Iterator iterator = deleteDestButtonVector .iterator(); iterator.hasNext();) { Button button = (Button) iterator.next(); if (!button.isDisposed()) button.setVisible(false); } } // move index of other button: for (Iterator iterator = deleteDestButtonVector .iterator(); iterator.hasNext();) { Button button = (Button) iterator.next(); if (!button.isDisposed()) { Integer data = (Integer) button.getData(); if (data.intValue() > numero.intValue()) { button.setData( new Integer(data.intValue() - 1)); } } } } composite.pack(); composite.redraw(); } } }; deleteDestButton.addListener(SWT.Selection, deleteListener); destinationInfo = new DestinationInfo(); destinationInfo.setDocDestName( destinationDocNameCombo.elementAt(destinCounter).getText()); //destinationInfo.setParamDestName(destinationInputParam.elementAt(destinCounter).getText()); String label = destinationInputParam.elementAt(destinCounter).getText(); String urlName = (String) destinationInputParam.elementAt(destinCounter) .getData(label); destinationInfo.setParamDestName(urlName); destinationInfo.setParamDefaultValue( destinationInputParamDefaultValue.elementAt(destinCounter)); destinationInfos.add(destinationInfo); composite2.pack(); composite2.redraw(); } //fine } } setPageComplete(true); } } } } } composite.pack(); composite.layout(); return param; }
From source file:it.eng.spagobi.studio.geo.actions.NewGEOAction.java
License:Mozilla Public License
public void run(IAction action) { SpagoBIGEOWizard sbindw = new SpagoBIGEOWizard(); // CommonViewer commViewer=((CommonNavigator) view).getCommonViewer(); // IStructuredSelection sel=(IStructuredSelection)commViewer.getSelection(); IStructuredSelection sel = (IStructuredSelection) selection; Object objSel = sel.toList().get(0); Folder folderSel = null;/*from w w w. ja v 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 GEO document"); } }
From source file:it.eng.spagobi.studio.jasper.actions.NewJasperAction.java
License:Mozilla Public License
public void run(IAction action) { SpagoBINewJasperReportWizard sbindw = new SpagoBINewJasperReportWizard(); // CommonViewer commViewer=((CommonNavigator) view).getCommonViewer(); // IStructuredSelection sel=(IStructuredSelection)commViewer.getSelection(); IStructuredSelection sel = (IStructuredSelection) selection; Object objSel = sel.toList().get(0); Folder folderSel = null;//w w w . j a va 2 s.com 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"); } }
From source file:javaee.core.Handler.java
License:Open Source License
private List<IProject> collectSelectedProjects(ExecutionEvent event) { ISelection currentSelection = HandlerUtil.getCurrentSelection(event); Builder<IProject> result = ImmutableList.builder(); if (currentSelection instanceof IStructuredSelection) { IStructuredSelection selection = (IStructuredSelection) currentSelection; IAdapterManager adapterManager = Platform.getAdapterManager(); for (Object selectionItem : selection.toList()) { IResource resource = (IResource) adapterManager.getAdapter(selectionItem, IResource.class); if (resource != null) { IProject project = resource.getProject(); result.add(project);/*from www . j ava 2 s .com*/ } } } return result.build(); }
From source file:joachimeichborn.geotag.model.selections.PictureSelection.java
License:Open Source License
@SuppressWarnings("unchecked") public PictureSelection(final IStructuredSelection aSelection) { selection = Collections.unmodifiableList((List<Picture>) aSelection.toList()); }
From source file:joachimeichborn.geotag.model.selections.PositionSelection.java
License:Open Source License
@SuppressWarnings("unchecked") public PositionSelection(final IStructuredSelection aSelection) { selection = Collections.unmodifiableList((List<PositionData>) aSelection.toList()); }
From source file:joachimeichborn.geotag.model.selections.TrackSelection.java
License:Open Source License
@SuppressWarnings("unchecked") public TrackSelection(final IStructuredSelection aSelection) { this((List<Track>) aSelection.toList()); }
From source file:mbtarranger.explorer.XplrView.java
License:Open Source License
protected void fillContextMenu(IMenuManager manager) { IStructuredSelection sele = (IStructuredSelection) viewer.getSelection(); if (!sele.isEmpty()) { ViewContent_TreeNodeV2 selNode = (ViewContent_TreeNodeV2) sele.toList().get(0); switch (selNode.contentType) { case Alternative: manager.add(actions.action_resetProblemReporting); manager.add(new Separator()); manager.add(actions.action_renderAutomataAsTextualARR); manager.add(actions.action_renderAutomata); manager.add(actions.action_renderAutomataNormalized); manager.add(new Separator()); // Other plug-ins can contribute their actions here manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); break; case AlternativesListing: manager.add(actions.action_resetProblemReporting); manager.add(new Separator()); manager.add(actions.action_renderAutomataAsTextualARR); manager.add(actions.action_renderAutomata); manager.add(actions.action_renderAutomataNormalized); manager.add(new Separator()); // Other plug-ins can contribute their actions here manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); break; case Scenario: manager.add(actions.action_resetProblemReporting); manager.add(new Separator()); manager.add(actions.action_renderAutomataAsTextualARR); manager.add(actions.action_renderAutomata); manager.add(actions.action_renderAutomataNormalized); manager.add(new Separator()); // Other plug-ins can contribute their actions here manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); break; case ComposeTermNonterminal: case ComposeTermTerminal: manager.add(actions.action_resetProblemReporting); manager.add(new Separator()); manager.add(actions.action_renderAutomataAsTextualARR); manager.add(actions.action_renderAutomata); manager.add(actions.action_renderAutomataNormalized); manager.add(new Separator()); // Other plug-ins can contribute their actions here manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); break; case SmvFile: manager.add(actions.action_resetProblemReporting); manager.add(new Separator()); manager.add(actions.action_syntaxCheck_a_v); manager.add(actions.action_syntaxCheck_a); manager.add(actions.action_syntaxCheck_A_v); manager.add(actions.action_syntaxCheck_A); manager.add(new Separator()); // Other plug-ins can contribute their actions here manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); break; case PromelaProcessBehaviour: manager.add(actions.action_resetProblemReporting); manager.add(new Separator()); manager.add(actions.action_renderAutomataAsTextualARR); manager.add(actions.action_renderAutomata); manager.add(actions.action_renderAutomataNormalized); manager.add(new Separator()); // Other plug-ins can contribute their actions here manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); break; case NeverSpec: manager.add(actions.action_resetProblemReporting); manager.add(new Separator()); manager.add(actions.action_renderAutomataAsTextualARR); manager.add(actions.action_renderAutomata); manager.add(actions.action_renderAutomataNormalized); manager.add(new Separator()); // Other plug-ins can contribute their actions here manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); break; case LtlSpec: manager.add(actions.action_resetProblemReporting); manager.add(new Separator()); manager.add(actions.action_renderAutomataAsTextualARR); manager.add(actions.action_renderAutomata); manager.add(actions.action_renderAutomataNormalized); manager.add(new Separator()); // Other plug-ins can contribute their actions here manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); break; case NotraceSpec: manager.add(actions.action_resetProblemReporting); manager.add(new Separator()); manager.add(actions.action_renderAutomataAsTextualARR); manager.add(actions.action_renderAutomata); manager.add(actions.action_renderAutomataNormalized); manager.add(new Separator()); // Other plug-ins can contribute their actions here manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); break; case TraceSpec: manager.add(actions.action_resetProblemReporting); manager.add(new Separator()); manager.add(actions.action_renderAutomataAsTextualARR); manager.add(actions.action_renderAutomata); manager.add(actions.action_renderAutomataNormalized); manager.add(new Separator()); // Other plug-ins can contribute their actions here manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); break; case Config: manager.add(actions.action_resetProblemReporting); manager.add(new Separator()); manager.add(actions.action_generateTestCommons); manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); break; case Test: case AutoconstructedTest: manager.add(actions.action_resetProblemReporting); manager.add(new Separator()); manager.add(actions.action_findPath); manager.add(actions.action_verify); manager.add(actions.action_renderTrail_alsoUncomplete); manager.add(actions.action_renderTrail_onlyIfComplete); manager.add(actions.action_generateTestCommons); manager.add(actions.action_generateTests); manager.add(actions.action_generateTests_summarized); manager.add(actions.action_generateTests_detailed); manager.add(new Separator()); // Other plug-ins can contribute their actions here manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); break; case Testset: manager.add(actions.action_resetProblemReporting); manager.add(new Separator()); manager.add(actions.action_generateTestsuite_definitionOnly); manager.add(actions.action_generateTestCommons); manager.add(new Separator()); // Other plug-ins can contribute their actions here manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); break; case Variant: manager.add(actions.action_resetProblemReporting); manager.add(new Separator()); manager.add(actions.action_renderAutomataAsTextualARR); manager.add(actions.action_renderAutomata); manager.add(actions.action_renderAutomataNormalized); manager.add(new Separator()); // Other plug-ins can contribute their actions here manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); break; case VariantsListing: manager.add(actions.action_resetProblemReporting); manager.add(new Separator()); manager.add(actions.action_renderAutomataAsTextualARR); manager.add(actions.action_renderAutomata); manager.add(actions.action_renderAutomataNormalized); manager.add(new Separator()); // Other plug-ins can contribute their actions here manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); break; default:/*from w ww . ja v a2 s .co m*/ manager.add(actions.action_resetProblemReporting); manager.add(new Separator()); manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); } } }
From source file:mlm.eclipse.ide.jsworkingset.internal.ImportWorkingSetsHandler.java
License:Open Source License
private void execute0(final ExecutionEvent pEvent) { final ISelection selection = HandlerUtil.getCurrentSelection(pEvent); if (selection == null || selection.isEmpty()) { return;/* ww w . ja va2s . c o m*/ } if (!(selection instanceof IStructuredSelection)) { return; } final IAdapterManager adapterManager = Platform.getAdapterManager(); final IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager(); final ScriptEngineManager manager = new ScriptEngineManager(); final ScriptEngine engine = Activator.newScriptEngine(manager); final IStructuredSelection sselection = (IStructuredSelection) selection; final List<?> selElems = sselection.toList(); for (final Object selElem : selElems) { final IFile file = (IFile) adapterManager.getAdapter(selElem, IFile.class); if (file != null) { final IPath dir = file.getFullPath().removeLastSegments(1); engine.put(ScriptEngine.FILENAME, file.getFullPath()); try (Reader reader = new InputStreamReader(file.getContents())) { engine.eval(reader); final Bindings workingSetsBindings = (Bindings) engine.get("workingSets"); for (final Object wsObj : workingSetsBindings.values()) { final Bindings workingSetBindings = (Bindings) wsObj; final String label = (String) workingSetBindings.get("name"); final String script = (String) workingSetBindings.get("script"); IPath scriptPath = new Path(script); if (!scriptPath.isAbsolute()) { scriptPath = dir.append(scriptPath); } final String name = String.valueOf(System.currentTimeMillis()); final IWorkingSet workingSet = workingSetManager.createWorkingSet(name, new IAdaptable[0]); workingSet.setId(Activator.ID_WORKING_SET); JSWorkingSetPrefs.setName(workingSet, label); JSWorkingSetPrefs.setScript(workingSet, scriptPath.toString()); workingSetManager.addWorkingSet(workingSet); } } catch (CoreException | IOException | ScriptException ex) { Activator.log(IStatus.ERROR, "Failed to access/load/compile script!", ex); //$NON-NLS-1$ } } } }