List of usage examples for org.eclipse.jface.viewers IStructuredSelection toList
public List toList();
List
. From source file:net.sf.eclipsensis.template.AbstractTemplateSettings.java
License:Open Source License
private void export() { IStructuredSelection selection = (IStructuredSelection) mTableViewer.getSelection(); Collection<T> templates = Common.makeGenericList(mTemplateManager.getTemplateClass(), selection.toList()); FileDialog dialog = new FileDialog(getShell(), SWT.SAVE); dialog.setText(EclipseNSISPlugin.getResourceString("template.settings.export.title")); //$NON-NLS-1$ dialog.setFilterExtensions(/*ww w . j av a2 s .co m*/ new String[] { EclipseNSISPlugin.getResourceString("template.settings.import.extension") }); //$NON-NLS-1$ dialog.setFileName(EclipseNSISPlugin.getResourceString("template.settings.export.filename")); //$NON-NLS-1$ String path = dialog.open(); if (path == null) { return; } File file = new File(path); if (!file.exists() || Common.openConfirm(getShell(), EclipseNSISPlugin.getFormattedString("save.confirm", new Object[] { file.getAbsolutePath() }), //$NON-NLS-1$ getShellImage())) { try { mTemplateManager.getReaderWriter().export(templates, file); } catch (Exception e) { Common.openError(getShell(), e.getLocalizedMessage(), getShellImage()); } } }
From source file:net.sf.eclipsensis.wizard.NSISWizardAttributesPage.java
License:Open Source License
private void createLanguagesGroup(Composite parent) { final Group langGroup = NSISWizardDialogUtil.createGroup(parent, 1, "language.support.group.label", null, //$NON-NLS-1$ false);//from ww w . j a va2s . com GridData data = (GridData) langGroup.getLayoutData(); data.verticalAlignment = SWT.FILL; data.grabExcessVerticalSpace = true; data.horizontalAlignment = SWT.FILL; data.grabExcessHorizontalSpace = true; NSISWizardSettings settings = mWizard.getSettings(); final Button enableLangSupport = NSISWizardDialogUtil.createCheckBox(langGroup, "enable.language.support.label", settings.isEnableLanguageSupport(), true, null, false); //$NON-NLS-1$ enableLangSupport.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { boolean selection = enableLangSupport.getSelection(); mWizard.getSettings().setEnableLanguageSupport(selection); validateField(LANG_CHECK); } }); final MasterSlaveController m = new MasterSlaveController(enableLangSupport); final Composite listsComposite = new Composite(langGroup, SWT.NONE); data = new GridData(SWT.FILL, SWT.FILL, true, true); listsComposite.setLayoutData(data); GridLayout layout = new GridLayout(2, true); layout.marginHeight = 0; layout.marginWidth = 0; listsComposite.setLayout(layout); java.util.List<NSISLanguage> selectedLanguages = settings.getLanguages(); if (selectedLanguages.isEmpty()) { NSISLanguage defaultLanguage = NSISLanguageManager.getInstance().getDefaultLanguage(); if (defaultLanguage != null) { selectedLanguages.add(defaultLanguage); } } java.util.List<NSISLanguage> availableLanguages = NSISLanguageManager.getInstance().getLanguages(); availableLanguages.removeAll(selectedLanguages); Composite leftComposite = new Composite(listsComposite, SWT.NONE); leftComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); layout = new GridLayout(2, false); layout.marginHeight = 0; layout.marginWidth = 0; leftComposite.setLayout(layout); ((GridData) NSISWizardDialogUtil.createLabel(leftComposite, "available.languages.label", //$NON-NLS-1$ true, m, false).getLayoutData()).horizontalSpan = 2; final List availableLangList = new List(leftComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI); data = new GridData(SWT.FILL, SWT.FILL, true, true); Dialog.applyDialogFont(availableLangList); data.heightHint = Common.calculateControlSize(availableLangList, 0, 12).y; availableLangList.setLayoutData(data); m.addSlave(availableLangList); final ListViewer availableLangViewer = new ListViewer(availableLangList); CollectionContentProvider collectionContentProvider = new CollectionContentProvider(); availableLangViewer.setContentProvider(collectionContentProvider); availableLangViewer.setInput(availableLanguages); availableLangViewer.setSorter(new ViewerSorter(cLanguageCollator)); final Composite buttonsComposite1 = new Composite(leftComposite, SWT.NONE); layout = new GridLayout(1, false); layout.marginHeight = 0; layout.marginWidth = 0; buttonsComposite1.setLayout(layout); data = new GridData(SWT.FILL, SWT.CENTER, false, false); buttonsComposite1.setLayoutData(data); final Button allRightButton = new Button(buttonsComposite1, SWT.PUSH); data = new GridData(SWT.FILL, SWT.CENTER, true, false); allRightButton.setLayoutData(data); allRightButton.setImage(EclipseNSISPlugin.getImageManager() .getImage(EclipseNSISPlugin.getResourceString("all.right.icon"))); //$NON-NLS-1$ allRightButton.setToolTipText(EclipseNSISPlugin.getResourceString("all.right.tooltip")); //$NON-NLS-1$ final Button rightButton = new Button(buttonsComposite1, SWT.PUSH); data = new GridData(SWT.FILL, SWT.CENTER, true, false); rightButton.setLayoutData(data); rightButton.setImage( EclipseNSISPlugin.getImageManager().getImage(EclipseNSISPlugin.getResourceString("right.icon"))); //$NON-NLS-1$ rightButton.setToolTipText(EclipseNSISPlugin.getResourceString("right.tooltip")); //$NON-NLS-1$ final Button leftButton = new Button(buttonsComposite1, SWT.PUSH); data = new GridData(SWT.FILL, SWT.CENTER, true, false); leftButton.setLayoutData(data); leftButton.setImage( EclipseNSISPlugin.getImageManager().getImage(EclipseNSISPlugin.getResourceString("left.icon"))); //$NON-NLS-1$ leftButton.setToolTipText(EclipseNSISPlugin.getResourceString("left.tooltip")); //$NON-NLS-1$ final Button allLeftButton = new Button(buttonsComposite1, SWT.PUSH); data = new GridData(SWT.FILL, SWT.CENTER, true, false); allLeftButton.setLayoutData(data); allLeftButton.setImage( EclipseNSISPlugin.getImageManager().getImage(EclipseNSISPlugin.getResourceString("all.left.icon"))); //$NON-NLS-1$ allLeftButton.setToolTipText(EclipseNSISPlugin.getResourceString("all.left.tooltip")); //$NON-NLS-1$ Composite rightComposite = new Composite(listsComposite, SWT.NONE); rightComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); layout = new GridLayout(2, false); layout.marginHeight = 0; layout.marginWidth = 0; rightComposite.setLayout(layout); ((GridData) NSISWizardDialogUtil.createLabel(rightComposite, "selected.languages.label", //$NON-NLS-1$ true, m, isScriptWizard()).getLayoutData()).horizontalSpan = 2; final List selectedLangList = new List(rightComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI); data = new GridData(SWT.FILL, SWT.FILL, true, true); Dialog.applyDialogFont(selectedLangList); data.heightHint = Common.calculateControlSize(selectedLangList, 0, 12).y; selectedLangList.setLayoutData(data); m.addSlave(selectedLangList); final ListViewer selectedLangViewer = new ListViewer(selectedLangList); selectedLangViewer.setContentProvider(collectionContentProvider); selectedLangViewer.setInput(selectedLanguages); final ListViewerUpDownMover<java.util.List<NSISLanguage>, NSISLanguage> mover = new ListViewerUpDownMover<java.util.List<NSISLanguage>, NSISLanguage>() { @Override @SuppressWarnings("unchecked") protected java.util.List<NSISLanguage> getAllElements() { return (java.util.List<NSISLanguage>) ((ListViewer) getViewer()).getInput(); } @Override protected void updateStructuredViewerInput(java.util.List<NSISLanguage> input, java.util.List<NSISLanguage> elements, java.util.List<NSISLanguage> move, boolean isDown) { (input).clear(); (input).addAll(elements); } }; mover.setViewer(selectedLangViewer); final Composite buttonsComposite2 = new Composite(rightComposite, SWT.NONE); layout = new GridLayout(1, false); layout.marginHeight = 0; layout.marginWidth = 0; buttonsComposite2.setLayout(layout); data = new GridData(SWT.FILL, SWT.CENTER, false, false); buttonsComposite2.setLayoutData(data); final Button upButton = new Button(buttonsComposite2, SWT.PUSH); data = new GridData(SWT.FILL, SWT.CENTER, true, false); upButton.setLayoutData(data); upButton.setImage( EclipseNSISPlugin.getImageManager().getImage(EclipseNSISPlugin.getResourceString("up.icon"))); //$NON-NLS-1$ upButton.setToolTipText(EclipseNSISPlugin.getResourceString("up.tooltip")); //$NON-NLS-1$ m.addSlave(upButton); final Button downButton = new Button(buttonsComposite2, SWT.PUSH); data = new GridData(SWT.FILL, SWT.CENTER, true, false); downButton.setLayoutData(data); downButton.setImage( EclipseNSISPlugin.getImageManager().getImage(EclipseNSISPlugin.getResourceString("down.icon"))); //$NON-NLS-1$ downButton.setToolTipText(EclipseNSISPlugin.getResourceString("down.tooltip")); //$NON-NLS-1$ m.addSlave(downButton); Composite langOptions = langGroup; boolean showSupportedLangOption = NSISPreferences.getInstance().getNSISVersion() .compareTo(INSISVersions.VERSION_2_26) >= 0; if (showSupportedLangOption) { langOptions = new Composite(langGroup, SWT.None); layout = new GridLayout(2, false); layout.marginHeight = 0; layout.marginWidth = 0; langOptions.setLayout(layout); data = new GridData(SWT.FILL, SWT.FILL, true, false); langOptions.setLayoutData(data); } final Button selectLang = NSISWizardDialogUtil.createCheckBox(langOptions, "select.language.label", //$NON-NLS-1$ settings.isSelectLanguage(), true, m, false); final Button displaySupported; if (showSupportedLangOption) { ((GridData) selectLang.getLayoutData()).horizontalSpan = 1; displaySupported = NSISWizardDialogUtil.createCheckBox(langOptions, "display.supported.languages.label", //$NON-NLS-1$ settings.isDisplaySupportedLanguages(), true, m, false); ((GridData) displaySupported.getLayoutData()).horizontalSpan = 1; displaySupported.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { mWizard.getSettings().setDisplaySupportedLanguages(displaySupported.getSelection()); } }); } else { displaySupported = null; } final MasterSlaveEnabler mse = new MasterSlaveEnabler() { public void enabled(Control control, boolean flag) { } @SuppressWarnings("unchecked") public boolean canEnable(Control control) { NSISWizardSettings settings = mWizard.getSettings(); if (control == allRightButton) { return settings.isEnableLanguageSupport() && availableLangViewer.getList().getItemCount() > 0; } else if (control == rightButton) { return settings.isEnableLanguageSupport() && !availableLangViewer.getSelection().isEmpty(); } else if (control == allLeftButton) { return settings.isEnableLanguageSupport() && selectedLangViewer.getList().getItemCount() > 0; } else if (control == leftButton) { return settings.isEnableLanguageSupport() && !selectedLangViewer.getSelection().isEmpty(); } else if (control == upButton) { return settings.isEnableLanguageSupport() && mover.canMoveUp(); } else if (control == downButton) { return settings.isEnableLanguageSupport() && mover.canMoveDown(); } else if (control == selectLang) { java.util.List<NSISLanguage> selectedLanguages = (java.util.List<NSISLanguage>) selectedLangViewer .getInput(); return settings.getInstallerType() != INSTALLER_TYPE_SILENT && settings.isEnableLanguageSupport() && selectedLanguages.size() > 1; } else if (control == displaySupported && displaySupported != null) { java.util.List<NSISLanguage> selectedLanguages = (java.util.List<NSISLanguage>) selectedLangViewer .getInput(); return settings.getInstallerType() != INSTALLER_TYPE_SILENT && settings.isEnableLanguageSupport() && selectedLanguages.size() > 1 && selectLang.getSelection(); } else { return true; } } }; m.addSlave(rightButton, mse); m.addSlave(allRightButton, mse); m.addSlave(leftButton, mse); m.addSlave(allLeftButton, mse); m.setEnabler(upButton, mse); m.setEnabler(downButton, mse); m.setEnabler(selectLang, mse); if (displaySupported != null) { m.setEnabler(displaySupported, mse); } selectLang.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { mWizard.getSettings().setSelectLanguage(selectLang.getSelection()); if (displaySupported != null) { displaySupported.setEnabled(mse.canEnable(displaySupported)); } } }); final Runnable langRunnable = new Runnable() { public void run() { availableLangViewer.refresh(false); selectedLangViewer.refresh(false); allRightButton.setEnabled(mse.canEnable(allRightButton)); allLeftButton.setEnabled(mse.canEnable(allLeftButton)); rightButton.setEnabled(mse.canEnable(rightButton)); leftButton.setEnabled(mse.canEnable(leftButton)); upButton.setEnabled(mse.canEnable(upButton)); downButton.setEnabled(mse.canEnable(downButton)); selectLang.setEnabled(mse.canEnable(selectLang)); if (displaySupported != null) { displaySupported.setEnabled(mse.canEnable(displaySupported)); } setPageComplete(validateField(LANG_CHECK)); } }; rightButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent se) { moveAcross(availableLangViewer, selectedLangViewer, Common.makeGenericList(NSISLanguage.class, ((IStructuredSelection) availableLangViewer.getSelection()).toList())); langRunnable.run(); } }); allRightButton.addSelectionListener(new SelectionAdapter() { @Override @SuppressWarnings("unchecked") public void widgetSelected(SelectionEvent se) { moveAcross(availableLangViewer, selectedLangViewer, (java.util.List<NSISLanguage>) availableLangViewer.getInput()); langRunnable.run(); } }); leftButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent se) { moveAcross(selectedLangViewer, availableLangViewer, Common.makeGenericList(NSISLanguage.class, ((IStructuredSelection) selectedLangViewer.getSelection()).toList())); langRunnable.run(); } }); allLeftButton.addSelectionListener(new SelectionAdapter() { @Override @SuppressWarnings("unchecked") public void widgetSelected(SelectionEvent se) { moveAcross(selectedLangViewer, availableLangViewer, (java.util.List<NSISLanguage>) selectedLangViewer.getInput()); langRunnable.run(); } }); upButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent se) { mover.moveUp(); langRunnable.run(); } }); downButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent se) { mover.moveDown(); langRunnable.run(); } }); availableLangViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { rightButton.setEnabled(mse.canEnable(rightButton)); allRightButton.setEnabled(mse.canEnable(allRightButton)); } }); availableLangViewer.getList().addSelectionListener(new SelectionAdapter() { @Override public void widgetDefaultSelected(SelectionEvent event) { IStructuredSelection sel = (IStructuredSelection) availableLangViewer.getSelection(); if (!sel.isEmpty()) { moveAcross(availableLangViewer, selectedLangViewer, Common.makeGenericList(NSISLanguage.class, sel.toList())); selectedLangViewer.reveal(sel.getFirstElement()); langRunnable.run(); } } }); selectedLangViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { leftButton.setEnabled(mse.canEnable(leftButton)); allLeftButton.setEnabled(mse.canEnable(allLeftButton)); upButton.setEnabled(mse.canEnable(upButton)); downButton.setEnabled(mse.canEnable(downButton)); selectLang.setEnabled(mse.canEnable(selectLang)); if (displaySupported != null) { displaySupported.setEnabled(mse.canEnable(displaySupported)); } } }); selectedLangViewer.getList().addSelectionListener(new SelectionAdapter() { @Override public void widgetDefaultSelected(SelectionEvent event) { IStructuredSelection sel = (IStructuredSelection) selectedLangViewer.getSelection(); if (!sel.isEmpty()) { moveAcross(selectedLangViewer, availableLangViewer, Common.makeGenericList(NSISLanguage.class, sel.toList())); availableLangViewer.reveal(sel.getFirstElement()); langRunnable.run(); } } }); m.updateSlaves(); listsComposite.addListener(SWT.Resize, new Listener() { boolean init = false; public void handleEvent(Event e) { if (!init) { // Stupid hack so that the height hint doesn't get changed // on the first resize, // i.e., when the page is drawn for the first time. init = true; } else { Point size = listsComposite.getSize(); GridLayout layout = (GridLayout) listsComposite.getLayout(); int heightHint = size.y - 2 * layout.marginHeight; ((GridData) availableLangList.getLayoutData()).heightHint = heightHint; ((GridData) selectedLangList.getLayoutData()).heightHint = heightHint; int totalWidth = size.x - 2 * layout.marginWidth - 3 * layout.horizontalSpacing; int listWidth = (int) (totalWidth * 0.4); int buttonWidth = (int) (0.5 * (totalWidth - 2 * listWidth)); size = availableLangList.computeSize(listWidth, SWT.DEFAULT); int delta = 0; if (size.x > listWidth) { delta = size.x - listWidth; listWidth = listWidth - delta; } ((GridData) availableLangList.getLayoutData()).widthHint = listWidth; ((GridData) buttonsComposite1.getLayoutData()).widthHint = totalWidth - 2 * (listWidth + delta) - buttonWidth; ((GridData) selectedLangList.getLayoutData()).widthHint = listWidth; ((GridData) buttonsComposite2.getLayoutData()).widthHint = buttonWidth; listsComposite.layout(); } } }); addPageChangedRunnable(new Runnable() { public void run() { if (isCurrentPage()) { selectLang.setEnabled(mse.canEnable(selectLang)); if (displaySupported != null) { displaySupported.setEnabled(mse.canEnable(displaySupported)); } } } }); mWizard.addSettingsListener(new INSISWizardSettingsListener() { public void settingsChanged(NSISWizardSettings oldSettings, NSISWizardSettings newSettings) { enableLangSupport.setSelection(newSettings.isEnableLanguageSupport()); m.updateSlaves(); selectLang.setSelection(newSettings.isSelectLanguage()); if (displaySupported != null) { displaySupported.setSelection(newSettings.isDisplaySupportedLanguages()); } java.util.List<NSISLanguage> selectedLanguages = newSettings.getLanguages(); java.util.List<NSISLanguage> availableLanguages = NSISLanguageManager.getInstance().getLanguages(); if (selectedLanguages.isEmpty()) { NSISWizardWelcomePage welcomePage = (NSISWizardWelcomePage) mWizard .getPage(NSISWizardWelcomePage.NAME); if (welcomePage != null) { if (!welcomePage.isCreateFromTemplate()) { NSISLanguage defaultLanguage = NSISLanguageManager.getInstance().getDefaultLanguage(); if (defaultLanguage != null && availableLanguages.contains(defaultLanguage)) { selectedLanguages.add(defaultLanguage); } } } } selectedLangViewer.setInput(selectedLanguages); availableLanguages.removeAll(selectedLanguages); availableLangViewer.setInput(availableLanguages); } }); }
From source file:net.sf.groovyMonkey.actions.PublishScript.java
License:Open Source License
protected List<IFile> getScripts() { final List<IFile> scripts = array(); if (!(selection instanceof IStructuredSelection)) return scripts; final IStructuredSelection sel = (IStructuredSelection) selection; final List<?> selectedObjects = sel.toList(); for (final Object object : selectedObjects) if (object instanceof IFile) scripts.add((IFile) object); return scripts; }
From source file:net.sf.jmoney.stocks.MergeDuplicatedSecurityHandler.java
License:Open Source License
public Object execute(ExecutionEvent event) throws ExecutionException { Shell shell = HandlerUtil.getActiveShellChecked(event); IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(event); IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); Security security1 = (Security) selection.toList().get(0); Security security2 = (Security) selection.toList().get(1); ExtendablePropertySet<? extends Security> propertySet1 = SecurityInfo.getPropertySet() .getActualPropertySet(security1.getClass()); ExtendablePropertySet<? extends Security> propertySet2 = SecurityInfo.getPropertySet() .getActualPropertySet(security2.getClass()); if (propertySet1 != propertySet2) { throw new ExecutionException(MessageFormat.format( "The two securities cannot be merged because they are not of types {0} and {1}. Only securities of the same type can be merged.", propertySet1.getObjectDescription(), propertySet1.getObjectDescription())); }//w w w . j a v a 2 s .c o m DatastoreManager sessionManager = (DatastoreManager) window.getActivePage().getInput(); TransactionManager transaction = new TransactionManager(sessionManager); mergeSecondIntoFirst(transaction, propertySet1, security1, security2); replaceSecondWithFirst(transaction, SessionInfo.getPropertySet(), transaction.getSession(), propertySet1, security1, security2); transaction.commit("Merge Securities"); return null; }
From source file:net.sf.jmoney.taxes.us.wizards.TxfExportWizard.java
License:Open Source License
/** * We will cache window object in order to be able to provide parent shell * for the message dialog.// w w w .j a v a 2s.c om */ public void init(IWorkbench workbench, IStructuredSelection selection) { this.window = workbench.getActiveWorkbenchWindow(); this.selection = selection; // Original JMoney disabled the export menu items when no // session was open. I don't know how to do that in Eclipse, // so we display a message instead. DatastoreManager sessionManager = (DatastoreManager) window.getActivePage().getInput(); if (sessionManager == null) { MessageDialog.openError(window.getShell(), "Disabled Action Selected", "You cannot export data unless you have a session open. You must first open a session."); return; } /* * This wizard exports all the selected accounts. We check that the selected * accounts are all stock accounts, and that at least one was selected. */ if (selection.isEmpty()) { MessageDialog.openError(window.getShell(), "Unable to Export Capital Gains Data", "You must select one or more stock accounts before running this wizard."); return; } for (Object selectedObject : selection.toList()) { if (!(selectedObject instanceof StockAccount)) { MessageDialog.openError(window.getShell(), "Unable to Export Capital Gains Data", "You have selected something that is not a stock account. Only stock accounts can be selected when exporting capital gains data."); return; } } mainPage = new TxfExportWizardPage(window); addPage(mainPage); }
From source file:net.sf.jmoney.views.feedback.FeedbackHistorySelectionDialog.java
License:Open Source License
@Override protected void buttonPressed(int buttonId) { if (buttonId == REMOVE_ID) { IStructuredSelection selection = (IStructuredSelection) fViewer.getSelection(); for (Object curr : selection.toList()) { fRemovedEntries.add((Feedback) curr); fInput.remove(curr);/*from w w w.jav a 2 s . c o m*/ fViewer.remove(curr); } if (fViewer.getSelection().isEmpty() && !fInput.isEmpty()) { fViewer.setSelection(new StructuredSelection(fInput.get(0))); } return; } if (buttonId == IDialogConstants.OPEN_ID) { fIsOpenInNewView = true; super.buttonPressed(IDialogConstants.OK_ID); } else { super.buttonPressed(buttonId); } }
From source file:net.sf.smbt.ui.ableton.dialogs.AbletonLiveOscPortConfigDialog.java
License:LGPL
protected void okPressed() { IStructuredSelection selection = (IStructuredSelection) listViewer.getSelection(); setResult(selection.toList()); super.okPressed(); }
From source file:net.sf.sveditor.ui.argfile.editor.outline.SVArgFileOutlinePage.java
License:Open Source License
@SuppressWarnings("unchecked") private void setSavedSelection(ISelection sel) { if (fDebugEn) { fLog.debug("--> setSavedSelection: set fIgnoreSelectionChange=true"); }/*from w w w.j a va 2 s . c o m*/ fIgnoreSelectionChange = true; try { if (!sel.isEmpty() && sel instanceof IStructuredSelection) { List<Object> path = new ArrayList<Object>(); IStructuredSelection ss = (IStructuredSelection) sel; List<Object> new_sel_l = new ArrayList<Object>(); List<Object> target_path = new ArrayList<Object>(); for (Object sel_it : ss.toList()) { if (sel_it instanceof ISVDBItemBase) { path.clear(); target_path.clear(); buildFullPath(path, (ISVDBItemBase) sel_it); if (lookupPath(fContent.getFile(), path.iterator(), target_path)) { ISVDBItemBase sel_t = (ISVDBItemBase) target_path.get(target_path.size() - 1); new_sel_l.add(sel_t); } } else if (sel_it instanceof SVDBFilePath) { new_sel_l.add(fContent.getFilePath()); } else if (sel_it instanceof Tuple) { Tuple<SVDBFileTree, ISVDBItemBase> t = (Tuple<SVDBFileTree, ISVDBItemBase>) sel_it; for (Tuple<SVDBFileTree, ISVDBItemBase> i : fContent.getFilePath().getPath()) { if (i.first().getFilePath().equals(t.first().getFilePath())) { new_sel_l.add(i); break; } } } } StructuredSelection new_sel = new StructuredSelection(new_sel_l); getTreeViewer().setSelection(new_sel); } } finally { fIgnoreSelectionChange = false; } if (fDebugEn) { fLog.debug("<-- setSavedSelection: set fIgnoreSelectionChange=true"); } }
From source file:net.sf.sveditor.ui.argfile.editor.SVArgFileOutlinePage.java
License:Open Source License
private void setSavedSelection(ISelection sel) { if (fDebugEn) { fLog.debug("--> setSavedSelection: set fIgnoreSelectionChange=true"); }/* ww w . j ava2 s .co m*/ fIgnoreSelectionChange = true; try { if (!sel.isEmpty() && sel instanceof IStructuredSelection) { List<ISVDBItemBase> path = new ArrayList<ISVDBItemBase>(); IStructuredSelection ss = (IStructuredSelection) sel; List<ISVDBItemBase> new_sel_l = new ArrayList<ISVDBItemBase>(); List<ISVDBItemBase> target_path = new ArrayList<ISVDBItemBase>(); for (Object sel_it : ss.toList()) { if (sel_it instanceof ISVDBItemBase) { path.clear(); target_path.clear(); buildFullPath(path, (ISVDBItemBase) sel_it); if (lookupPath(fSVDBFile, path.iterator(), target_path)) { ISVDBItemBase sel_t = target_path.get(target_path.size() - 1); new_sel_l.add(sel_t); } } } StructuredSelection new_sel = new StructuredSelection(new_sel_l); getTreeViewer().setSelection(new_sel); } } finally { fIgnoreSelectionChange = false; } if (fDebugEn) { fLog.debug("<-- setSavedSelection: set fIgnoreSelectionChange=true"); } }
From source file:net.sf.sveditor.ui.editor.outline.SVOutlinePage.java
License:Open Source License
@SuppressWarnings("unchecked") private void setSavedSelection(ISelection sel) { if (fDebugEn) { fLog.debug("--> setSavedSelection: set fIgnoreSelectionChange=true"); }//w w w . ja v a 2 s . com fIgnoreSelectionChange = true; try { if (!sel.isEmpty() && sel instanceof IStructuredSelection) { List<Object> path = new ArrayList<Object>(); IStructuredSelection ss = (IStructuredSelection) sel; List<Object> new_sel_l = new ArrayList<Object>(); List<Object> target_path = new ArrayList<Object>(); for (Object sel_it : ss.toList()) { if (sel_it instanceof ISVDBItemBase) { path.clear(); target_path.clear(); buildFullPath(path, (ISVDBItemBase) sel_it); if (lookupPath(fContent.getFile(), path.iterator(), target_path)) { Object sel_t = target_path.get(target_path.size() - 1); new_sel_l.add(sel_t); } } else if (sel_it instanceof SVDBFilePath) { new_sel_l.add(fContent.getFilePath()); } else if (sel_it instanceof Tuple) { Tuple<SVDBFileTree, ISVDBItemBase> t = (Tuple<SVDBFileTree, ISVDBItemBase>) sel_it; // See if we can find the old selection for (Tuple<SVDBFileTree, ISVDBItemBase> i : fContent.getFilePath().getPath()) { if (i.first().getFilePath().equals(t.first().getFilePath())) { new_sel_l.add(i); break; } } } } StructuredSelection new_sel = new StructuredSelection(new_sel_l); getTreeViewer().setSelection(new_sel); } } finally { fIgnoreSelectionChange = false; } if (fDebugEn) { fLog.debug("<-- setSavedSelection: set fIgnoreSelectionChange=true"); } }