List of usage examples for org.eclipse.jface.viewers IStructuredSelection toList
public List toList();
List
. From source file:com.crispico.flower.mp.contributions.FlowerPasteAction.java
License:Open Source License
/** * Update editing domain from selection/* ww w . j av a 2 s . co m*/ */ public void update(IStructuredSelection selection) { // get editing domain EditingDomain editingDomain = FlowerMPUtils.getEditingDomainFromSelection(selection.toList()); // if editingDomain not null, update action if (editingDomain != null) { setEditingDomain(editingDomain); setEnabled(pasteAction.updateSelection(selection)); } else { // editingDomain is null, reset action setEnabled(false); } }
From source file:com.crispico.flower.mp.contributions.FlowerRedoAction.java
License:Open Source License
/** * Update editing domain from selection/* w ww . j a v a 2 s. c o m*/ */ public void update(IStructuredSelection selection) { // get editing domain EditingDomain editingDomain = FlowerMPUtils.getEditingDomainFromSelection(selection.toList()); // if editingDomain not null, update action if (editingDomain != null) { setEditingDomain(editingDomain); update(); } else { // editingDomain is null, reset action setEnabled(false); // check to see if we have Relations elements inside the selection boolean containsVirtualElements = false; for (Object obj : selection.toList()) { if (obj instanceof RelationVirtualElement) { containsVirtualElements = true; break; } } if (containsVirtualElements) { IStructuredSelection newSelection = replaceVirtualElements(selection); // get the editingDomain from new selection EditingDomain domain = FlowerMPUtils.getEditingDomainFromSelection(selection.toList()); // update only if the found domain is not null if (domain != null) { setEditingDomain(domain); update(); } } } }
From source file:com.diffplug.common.swt.jface.ViewerMisc.java
License:Apache License
@SuppressWarnings("unchecked") public static <T> void multiSelectionList(StructuredViewer viewer, RxBox<ImmutableList<T>> box) { Preconditions.checkArgument(SwtMisc.flagIsSet(SWT.MULTI, viewer.getControl()), "Control style does not have SWT.MULTI set."); // set the box when the selection changes viewer.addSelectionChangedListener(event -> { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); box.set(ImmutableList.copyOf(selection.toList())); });//from w ww . j a va 2s . c o m // set the selection when the box changes SwtExec.immediate().guardOn(viewer.getControl()).subscribe(box, list -> { viewer.setSelection(new StructuredSelection(list)); }); }
From source file:com.ecfeed.ui.modelif.NodeSelectionUtils.java
License:Open Source License
public List<AbstractNode> getSelectedNodes() { List<AbstractNode> result = new ArrayList<>(); IStructuredSelection selection = (IStructuredSelection) fSelectionProvider.getSelection(); for (Object o : selection.toList()) { if (o instanceof AbstractNode) { result.add((AbstractNode) o); }//from www .ja va2 s .c om } return result; }
From source file:com.fiorano.services.feeder.cps.MessagePropertiesPage.java
License:Open Source License
private Control createAttachmentControls(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); GridLayout layout = new GridLayout(2, false); layout.marginHeight = 20;// www.j av a2s . c om layout.marginWidth = 20; composite.setLayout(layout); Table table = new Table(composite, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER); GridData tableData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 4); tableData.heightHint = 150; table.setLayoutData(tableData); TableColumn Column1 = new TableColumn(table, SWT.NONE); Column1.setText(Messages_Feeder.MessagePropertiesPage_13); TableColumn Column2 = new TableColumn(table, SWT.NONE); Column2.setText(Messages_Feeder.MessagePropertiesPage_14); TableLayout tableLayout = new TableLayout(); tableLayout.addColumnData(new ColumnWeightData(1, 40)); tableLayout.addColumnData(new ColumnWeightData(1, 60)); table.setLayout(tableLayout); table.setHeaderVisible(true); table.setLinesVisible(true); aaddButton = new Button(composite, SWT.PUSH); aaddButton.setText(Messages_Feeder.MessagePropertiesPage_15); aaddButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); aaddButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { add_attachment(e); if (amodel.size() > 0) { adelAllButton.setEnabled(true); } attTableViewer.refresh(); } }); adelButton = new Button(composite, SWT.PUSH); adelButton.setText(Messages_Feeder.MessagePropertiesPage_16); adelButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); adelButton.setEnabled(false); adelButton.addSelectionListener(new SelectionAdapter() { @SuppressWarnings("unchecked") public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = ((IStructuredSelection) attTableViewer.getSelection()); List<Attachment> attachments = (List<Attachment>) selection.toList(); for (Attachment attachment : attachments) { amodel.remove(attachment.getName()); } if (amodel.size() == 0) { adelAllButton.setEnabled(false); } attTableViewer.refresh(); } }); adelAllButton = new Button(composite, SWT.NONE); adelAllButton.setText(Messages_Feeder.MessagePropertiesPage_17); adelAllButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); adelAllButton.setEnabled(amodel.size() > 0); adelAllButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { amodel.clear(); adelAllButton.setEnabled(false); attTableViewer.refresh(); } }); createAttachmentViewer(table); return composite; }
From source file:com.fiorano.services.feeder.cps.MessagePropertiesPage.java
License:Open Source License
private Control createHeaderControls(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); GridLayout layout = new GridLayout(2, false); layout.marginHeight = 20;/*w w w. j av a2s.c o m*/ layout.marginWidth = 20; composite.setLayout(layout); headerTable = new Table(composite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER); GridData tableData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 4); tableData.heightHint = 150; headerTable.setLayoutData(tableData); TableColumn Column1 = new TableColumn(headerTable, SWT.NONE); Column1.setText(Messages_Feeder.MessagePropertiesPage_0); TableColumn Column2 = new TableColumn(headerTable, SWT.NONE); Column2.setText(Messages_Feeder.MessagePropertiesPage_27); TableColumn Column3 = new TableColumn(headerTable, SWT.NONE); Column3.setText(Messages_Feeder.MessagePropertiesPage_28); TableLayout tableLayout = new TableLayout(); tableLayout.addColumnData(new ColumnWeightData(1, 30)); tableLayout.addColumnData(new ColumnWeightData(1, 30)); tableLayout.addColumnData(new ColumnWeightData(1, 40)); headerTable.setLayout(tableLayout); headerTable.setHeaderVisible(true); headerTable.setLinesVisible(true); haddButton = new Button(composite, SWT.PUSH); haddButton.setText(Messages_Feeder.MessagePropertiesPage_29); haddButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); haddButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Header header = new Header(); header.setName(generateName()); header.setType(FeederConstants.STRING_PROPERTY_TYPE); header.setValue(""); //$NON-NLS-1$ hmodel.put(header.getName(), header); if (hmodel.size() > 0) { hdelAllButton.setEnabled(true); } headerTableViewer.refresh(); } private String generateName() { int i = 0; while (hmodel.containsKey("Name" + (i++))) { //$NON-NLS-0$ } return "Name" + (i - 1); //$NON-NLS-1$ } }); hdelButton = new Button(composite, SWT.PUSH); hdelButton.setText(Messages_Feeder.MessagePropertiesPage_33); hdelButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); hdelButton.setEnabled(false); hdelButton.addSelectionListener(new SelectionAdapter() { @SuppressWarnings("unchecked") public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = (IStructuredSelection) headerTableViewer.getSelection(); List<Header> headers = (List<Header>) selection.toList(); for (Header header : headers) { hmodel.remove(header.getName()); } if (hmodel.size() == 0) { hdelAllButton.setEnabled(false); } headerTableViewer.refresh(); } }); hdelAllButton = new Button(composite, SWT.NONE); hdelAllButton.setText(Messages_Feeder.MessagePropertiesPage_34); hdelAllButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); hdelAllButton.setEnabled(hmodel.size() > 0); hdelAllButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { hmodel.clear(); hdelAllButton.setEnabled(false); headerTableViewer.refresh(); } }); createHeaderViewer(headerTable); return composite; }
From source file:com.google.dart.tools.internal.corext.refactoring.reorg.RenameSelectionState.java
License:Open Source License
private void consider(IWorkbenchPart part) { if (part == null) { return;/*from ww w. j a va 2 s .c o m*/ } ISetSelectionTarget target = null; if (!(part instanceof ISetSelectionTarget)) { target = (ISetSelectionTarget) part.getAdapter(ISetSelectionTarget.class); if (target == null) { return; } } else { target = (ISetSelectionTarget) part; } ISelectionProvider selectionProvider = part.getSite().getSelectionProvider(); if (selectionProvider == null) { return; } ISelection s = selectionProvider.getSelection(); if (!(s instanceof IStructuredSelection)) { return; } IStructuredSelection selection = (IStructuredSelection) s; if (!selection.toList().contains(fElement)) { return; } fParts.add(part); fSelections.add(selection); }
From source file:com.google.dart.tools.search2.internal.ui.SearchHistorySelectionDialog.java
License:Open Source License
protected final void validateDialogState() { IStructuredSelection sel = (IStructuredSelection) fViewer.getSelection(); int elementsSelected = sel.toList().size(); fRemoveButton.setEnabled(elementsSelected > 0); Button okButton = getOkButton(); if (okButton != null) { okButton.setEnabled(elementsSelected == 1); }//from w w w. j ava 2 s. c o m Button openInNewButton = getButton(IDialogConstants.OPEN_ID); if (openInNewButton != null) { openInNewButton.setEnabled(elementsSelected == 1); } }
From source file:com.google.dart.tools.ui.actions.CloseLibraryAction.java
License:Open Source License
private void handleSelectionChanged(IStructuredSelection selection) { this.selection = selection; if (selection == null || selection.isEmpty()) { setEnabled(false);//w w w . ja v a 2 s . co m } else { for (Object object : selection.toList()) { if (!(object instanceof DartLibrary)) { setEnabled(false); return; } } setEnabled(true); } }
From source file:com.google.dart.tools.ui.callhierarchy.OpenCallHierarchyAction.java
License:Open Source License
@Override public void run(IStructuredSelection selection) { List<?> elements = selection.toList(); if (!CallHierarchy.arePossibleInputElements(elements)) { elements = Collections.EMPTY_LIST; }//from w w w . j a v a 2s. c o m TypeMember[] members = elements.toArray(new TypeMember[elements.size()]); if (!ActionUtil.areProcessable(getShell(), members)) { return; } CallHierarchyUI.openView(members, getSite().getWorkbenchWindow()); }