List of usage examples for org.eclipse.jface.viewers IStructuredSelection toList
public List toList();
List
. From source file:com.subgraph.vega.ui.http.intercept.config.ConfigureInterceptionContent.java
License:Open Source License
private SelectionListener createSelectionListenerButtonRemove() { return new SelectionAdapter() { @Override// ww w . j ava 2 s . c o m public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = (IStructuredSelection) tableViewerBreakpoints.getSelection(); for (Object ob : selection.toList()) { if ((ob instanceof IHttpCondition) && (conditionSet != null)) conditionSet.removeCondition((IHttpCondition) ob); } tableViewerBreakpoints.refresh(true); } }; }
From source file:com.subgraph.vega.ui.http.requestfilters.RequestFilterConfigContent.java
License:Open Source License
private SelectionListener createSelectionListenerButtonRemove() { return new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection(); for (Object element : selection.toList()) { if (element instanceof IHttpCondition) { conditionSet.removeCondition((IHttpCondition) element); conditionSetDirty = true; } else if (element instanceof IHttpConditionType) { IHttpConditionType type = (IHttpConditionType) element; for (IHttpCondition c : conditionSet.getAllConditions()) { if (c.getType() == type) { conditionSet.removeCondition(c); conditionSetDirty = true; }//from w w w. jav a2 s. c om } } } treeViewer.refresh(); } }; }
From source file:com.svcdelivery.liquibase.eclipse.internal.ui.version.LibrarySelectorPage.java
License:Apache License
@Override public void createControl(Composite parent) { final Composite root = new Composite(parent, SWT.NONE); root.setLayout(new GridLayout(4, false)); Label urlLabel = new Label(root, SWT.NONE); urlLabel.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, false)); urlLabel.setText("URL"); url = new Text(root, SWT.NONE); url.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); Button browse = new Button(root, SWT.PUSH); browse.setText("File"); browse.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); Button add = new Button(root, SWT.PUSH); add.setText("Add"); add.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); Label urlListLabel = new Label(root, SWT.NONE); urlListLabel.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, false)); urlListLabel.setText("URLs"); urlList = new ListViewer(root, SWT.MULTI); urlList.getList().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1)); urlList.setContentProvider(new CollectionContentProvider<URL>()); urlList.setInput(urls);// w w w . ja va 2 s . co m Button remove = new Button(root, SWT.PUSH); remove.setText("Remove"); remove.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false)); Label versionLabel = new Label(root, SWT.NONE); versionLabel.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, false)); versionLabel.setText("Version"); versionText = new Text(root, SWT.NONE); versionText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1)); if (version != null) { versionText.setText(version.toString()); } browse.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { Display.getDefault().asyncExec(new Runnable() { public void run() { FileDialog fd = new FileDialog(getShell()); fd.setFilterExtensions(new String[] { "*.jar" }); String filename = fd.open(); if (filename != null) { File file = new File(filename); if (file != null) { try { url.setText(file.toURI().toURL().toString()); } catch (MalformedURLException e) { e.printStackTrace(); } } } } }); } }); add.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { setErrorMessage(null); String text = url.getText(); try { URL lib = new URL(text); urls.add(lib); updateUrlList(); } catch (MalformedURLException e1) { setErrorMessage("Invalid URL."); } } }); remove.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { ISelection selection = urlList.getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection ss = (IStructuredSelection) selection; if (ss.size() > 0) { urls.removeAll(ss.toList()); updateUrlList(); } } } }); versionText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent event) { String txt = versionText.getText(); if (txt != null) { try { version = new Version(txt); } catch (IllegalArgumentException e) { version = null; } } } }); setControl(root); }
From source file:com.technophobia.substeps.junit.ui.component.FeatureViewer.java
License:Open Source License
public synchronized void setShowFailuresOnly(final boolean failuresOnly, final int layoutMode) { /*/* w w w. j a v a 2 s.c o m*/ * Management of fTreeViewer and fTableViewer * ****************************************** - invisible viewer is * updated on registerViewerUpdate unless its f*NeedsRefresh is true - * invisible viewer is not refreshed upfront - on layout change, new * viewer is refreshed if necessary - filter only applies to "current" * layout mode / viewer */ try { viewerbook.setRedraw(false); IStructuredSelection selection = null; final boolean switchLayout = layoutMode != this.layoutMode.value(); if (switchLayout) { selection = (IStructuredSelection) selectionProvider.getSelection(); if (layoutMode == ViewLayout.HIERARCHICAL.value()) { if (treeNeedsRefresh) { clearUpdateAndExpansion(); } } else { if (tableNeedsRefresh) { clearUpdateAndExpansion(); } } this.layoutMode = ViewLayout.forValue(layoutMode); viewerbook.showPage(getActiveViewer().getControl()); } // avoid realizing all TableItems, especially in flat mode! final StructuredViewer viewer = getActiveViewer(); if (failuresOnly) { if (!getActiveViewerHasFilter()) { setActiveViewerNeedsRefresh(true); setActiveViewerHasFilter(true); viewer.setInput(null); viewer.addFilter(failuresOnlyFilter); } } else { if (getActiveViewerHasFilter()) { setActiveViewerNeedsRefresh(true); setActiveViewerHasFilter(false); viewer.setInput(null); viewer.removeFilter(failuresOnlyFilter); } } processChangesInUI(); if (selection != null) { // workaround for // https://bugs.eclipse.org/bugs/show_bug.cgi?id=125708 // (ITreeSelection not adapted if TreePaths changed): final StructuredSelection flatSelection = new StructuredSelection(selection.toList()); selectionProvider.setSelection(flatSelection, true); } } finally { viewerbook.setRedraw(true); } }
From source file:com.vectrace.MercurialEclipse.synchronize.actions.PushPullSynchronizeAction.java
License:Open Source License
@Override protected SynchronizeModelOperation getSubscriberOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements) {//w ww .ja v a 2 s.c o m IStructuredSelection sel = getStructuredSelection(); Set<Object> target = new HashSet<Object>(); ISynchronizeParticipant part = getConfiguration().getParticipant(); if (sel instanceof TreeSelection) { target.addAll(((TreeSelection) sel).toList()); } else if (allowAll && part instanceof MercurialSynchronizeParticipant) { target.addAll( Arrays.asList(((MercurialSynchronizeParticipant) part).getRepositoryLocations().getProjects())); } else { target.addAll(sel.toList()); } return new PushPullSynchronizeOperation(configuration, elements, target, isPull, update); }
From source file:com.vectrace.MercurialEclipse.utils.ResourceUtils.java
License:Open Source License
/** * @param selection may be null/* w w w. j av a 2 s . com*/ * @return never null , may be empty list containing all resources from given selection */ public static List<IResource> getResources(IStructuredSelection selection) { List<IResource> resources = new ArrayList<IResource>(); List<?> list = selection.toList(); for (Object object : list) { if (object instanceof ChangeSet) { Set<IFile> files = ((ChangeSet) object).getFiles(); for (IFile file : files) { if (!resources.contains(file)) { resources.add(file); } } } else if (object instanceof PathFromChangeSet) { PathFromChangeSet pathFromChangeSet = (PathFromChangeSet) object; Set<FileFromChangeSet> files = pathFromChangeSet.getFiles(); for (FileFromChangeSet ffc : files) { IFile file = ffc.getFile(); if (file != null && !resources.contains(file)) { resources.add(file); } } } else { IResource resource = getResource(object); if (resource != null && !resources.contains(resource)) { resources.add(resource); } } } return resources; }
From source file:com.windowtester.test.locator.swt.AbstractLocatorTest.java
License:Open Source License
public void assertContainsExactly(IStructuredSelection selection, Object[] elems) { assertContainsExactly(selection.toList(), Arrays.asList(elems)); }
From source file:de.anbos.eclipse.logviewer.plugin.preferences.rule.RulePreferencePage.java
License:Apache License
@SuppressWarnings("unchecked") private void exportSelected() { IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection(); if (selection.isEmpty()) { if (askSelectAll()) { tableViewer.getTable().selectAll(); selection = (IStructuredSelection) tableViewer.getSelection(); } else {/* w ww. j a v a 2 s. c o m*/ MessageDialog.openError(getShell(), LogViewerPlugin.getResourceString("preferences.ruleseditor.export.error.title"), //$NON-NLS-1$ LogViewerPlugin .getResourceString("preferences.ruleseditor.export.error.select.items.text")); //$NON-NLS-1$ return; } } Collection<RulePreferenceData> itemArray = new ArrayList<RulePreferenceData>(); itemArray.addAll(selection.toList()); export(itemArray.toArray(new RulePreferenceData[itemArray.size()])); }
From source file:de.anbos.eclipse.logviewer.plugin.preferences.rule.RulePreferencePage.java
License:Apache License
@SuppressWarnings("unchecked") private void exportAll() { // save selection IStructuredSelection selectionSave = (IStructuredSelection) tableViewer.getSelection(); // select all tableViewer.getTable().selectAll();/*from w ww . jav a2s . co m*/ IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection(); if (selection.isEmpty()) { MessageDialog.openError(getShell(), LogViewerPlugin.getResourceString("preferences.ruleseditor.export.error.title"), //$NON-NLS-1$ LogViewerPlugin.getResourceString("preferences.ruleseditor.export.error.select.items.text")); //$NON-NLS-1$ return; } else { //export Collection<RulePreferenceData> itemArray = new ArrayList<RulePreferenceData>(); itemArray.addAll(selection.toList()); export(itemArray.toArray(new RulePreferenceData[itemArray.size()])); } // restore selection tableViewer.setSelection(selectionSave, true); }
From source file:de.bmw.yamaica.common.ui.utils.WizardSelector.java
License:Mozilla Public License
public static boolean isEnabledForSelection(String[] supportedFileExtensions, ISelection selection) { if (supportedFileExtensions.length > 0) { if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; for (Object sel : structuredSelection.toList()) { if (sel instanceof IResource) { IResource res = (IResource) sel; String fileExtension = res.getFileExtension(); if (fileExtension != null) { for (String supportedFileExtension : supportedFileExtensions) { if (supportedFileExtension.trim().equals(fileExtension)) return true; }//from w w w. j av a2 s . c om } } } } return false; } return true; }