List of usage examples for org.eclipse.jface.viewers StructuredSelection StructuredSelection
public StructuredSelection(List elements)
List
. From source file:ac.soton.eventb.classdiagrams.diagram.navigator.ClassdiagramsNavigatorLinkHelper.java
License:Open Source License
/** * @generated/* w w w.j a v a 2 s . co m*/ */ public IStructuredSelection findSelection(IEditorInput anInput) { IDiagramDocument document = ClassdiagramsDiagramEditorPlugin.getInstance().getDocumentProvider() .getDiagramDocument(anInput); if (document == null) { return StructuredSelection.EMPTY; } Diagram diagram = document.getDiagram(); if (diagram == null || diagram.eResource() == null) { return StructuredSelection.EMPTY; } IFile file = WorkspaceSynchronizer.getFile(diagram.eResource()); if (file != null) { ClassdiagramsNavigatorItem item = new ClassdiagramsNavigatorItem(diagram, file, false); return new StructuredSelection(item); } return StructuredSelection.EMPTY; }
From source file:ac.soton.eventb.classdiagrams.diagram.part.ClassdiagramsDiagramEditor.java
License:Open Source License
/** * @generated//from w ww . j a v a 2s . co m */ private ISelection getNavigatorSelection() { IDiagramDocument document = getDiagramDocument(); if (document == null) { return StructuredSelection.EMPTY; } Diagram diagram = document.getDiagram(); if (diagram == null || diagram.eResource() == null) { return StructuredSelection.EMPTY; } IFile file = WorkspaceSynchronizer.getFile(diagram.eResource()); if (file != null) { ClassdiagramsNavigatorItem item = new ClassdiagramsNavigatorItem(diagram, file, false); return new StructuredSelection(item); } return StructuredSelection.EMPTY; }
From source file:ac.soton.eventb.classdiagrams.diagram.part.ModelElementSelectionPage.java
License:Open Source License
/** * @generated/*from www . j av a 2 s . com*/ */ public void setModelElement(EObject modelElement) { selectedModelElement = modelElement; if (modelViewer != null) { if (selectedModelElement != null) { modelViewer.setInput(selectedModelElement.eResource()); modelViewer.setSelection(new StructuredSelection(selectedModelElement)); } else { modelViewer.setInput(null); } setPageComplete(validatePage()); } }
From source file:ac.soton.eventb.classdiagrams.diagram.part.ModelElementSelectionPage.java
License:Open Source License
/** * @generated//w ww. j a va 2 s . co m */ public void createControl(Composite parent) { initializeDialogUnits(parent); Composite plate = new Composite(parent, SWT.NONE); plate.setLayoutData(new GridData(GridData.FILL_BOTH)); GridLayout layout = new GridLayout(); layout.marginWidth = 0; plate.setLayout(layout); setControl(plate); Label label = new Label(plate, SWT.NONE); label.setText(getSelectionTitle()); label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); modelViewer = new TreeViewer(plate, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); GridData layoutData = new GridData(GridData.FILL_BOTH); layoutData.heightHint = 300; layoutData.widthHint = 300; modelViewer.getTree().setLayoutData(layoutData); modelViewer.setContentProvider(new AdapterFactoryContentProvider( ClassdiagramsDiagramEditorPlugin.getInstance().getItemProvidersAdapterFactory())); modelViewer.setLabelProvider(new AdapterFactoryLabelProvider( ClassdiagramsDiagramEditorPlugin.getInstance().getItemProvidersAdapterFactory())); if (selectedModelElement != null) { modelViewer.setInput(selectedModelElement.eResource()); modelViewer.setSelection(new StructuredSelection(selectedModelElement)); } modelViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { ModelElementSelectionPage.this.updateSelection((IStructuredSelection) event.getSelection()); } }); setPageComplete(validatePage()); }
From source file:ac.soton.eventb.classdiagrams.diagram.sheet.ClassdiagramsPropertySection.java
License:Open Source License
/** * @generated/* w w w . j a va2 s. c o m*/ */ public void setInput(IWorkbenchPart part, ISelection selection) { if (selection.isEmpty() || false == selection instanceof StructuredSelection) { super.setInput(part, selection); return; } final StructuredSelection structuredSelection = ((StructuredSelection) selection); ArrayList transformedSelection = new ArrayList(structuredSelection.size()); for (Iterator it = structuredSelection.iterator(); it.hasNext();) { Object r = transformSelection(it.next()); if (r != null) { transformedSelection.add(r); } } super.setInput(part, new StructuredSelection(transformedSelection)); }
From source file:ac.soton.eventb.classdiagrams.diagram.sheet.custom.ConstraintsPropertySection.java
License:Open Source License
@Override protected ISelection getEditorSelection(Object object) { DiagramEditor editor = (DiagramEditor) getPart(); IStructuredSelection selection = (IStructuredSelection) editor.getDiagramGraphicalViewer().getSelection(); if (selection != null && selection.size() == 1) { GraphicalEditPart selectedPart = (GraphicalEditPart) selection.getFirstElement(); EditPart part = selectedPart.findEditPart(null, (EObject) object); if (part != null) return new StructuredSelection(part); if (selectedPart.getParent() != null) { part = ((GraphicalEditPart) selectedPart.getParent()).findEditPart(null, (EObject) object); if (part != null) return new StructuredSelection(part); }/*from w w w . jav a2s . co m*/ } return null; }
From source file:ac.soton.eventb.roseEditor.propertySections.abstracts.AbstractEventBPropertySection.java
License:Open Source License
@Override public void setInput(final IWorkbenchPart part, final ISelection selection) { owner = null;/*from w w w. j a va 2 s. c o m*/ if (selection.isEmpty() || false == selection instanceof StructuredSelection) { super.setInput(part, selection); return; } final StructuredSelection structuredSelection = (StructuredSelection) selection; ArrayList<Object> transformedSelection = new ArrayList<Object>(structuredSelection.size()); for (Object object : structuredSelection.toList()) { if (owner == null && object instanceof EventBElement) { owner = (EventBElement) object; } if (object != null) { transformedSelection.add(object); } } super.setInput(part, new StructuredSelection(transformedSelection)); }
From source file:ac.soton.eventb.statemachines.diagram.navigator.StatemachinesNavigatorLinkHelper.java
License:Open Source License
/** * @generated//from w ww .jav a2s. c om */ public IStructuredSelection findSelection(IEditorInput anInput) { IDiagramDocument document = StatemachinesDiagramEditorPlugin.getInstance().getDocumentProvider() .getDiagramDocument(anInput); if (document == null) { return StructuredSelection.EMPTY; } Diagram diagram = document.getDiagram(); if (diagram == null || diagram.eResource() == null) { return StructuredSelection.EMPTY; } IFile file = WorkspaceSynchronizer.getFile(diagram.eResource()); if (file != null) { StatemachinesNavigatorItem item = new StatemachinesNavigatorItem(diagram, file, false); return new StructuredSelection(item); } return StructuredSelection.EMPTY; }
From source file:ac.soton.eventb.statemachines.diagram.part.StatemachinesDiagramEditor.java
License:Open Source License
/** * @generated/*ww w. j av a2 s . c o m*/ */ private ISelection getNavigatorSelection() { IDiagramDocument document = getDiagramDocument(); if (document == null) { return StructuredSelection.EMPTY; } Diagram diagram = document.getDiagram(); IFile file = WorkspaceSynchronizer.getFile(diagram.eResource()); if (file != null) { StatemachinesNavigatorItem item = new StatemachinesNavigatorItem(diagram, file, false); return new StructuredSelection(item); } return StructuredSelection.EMPTY; }
From source file:ac.soton.eventb.statemachines.diagram.sheet.custom.InvariantsPropertySection.java
License:Open Source License
@Override protected ISelection getEditorSelection(Object object) { StatemachinesDiagramEditor editor = (StatemachinesDiagramEditor) getPart(); IStructuredSelection selection = (IStructuredSelection) editor.getDiagramGraphicalViewer().getSelection(); if (selection != null && selection.size() == 1) { GraphicalEditPart selectedPart = (GraphicalEditPart) selection.getFirstElement(); EditPart part = selectedPart.findEditPart(null, (EObject) object); if (part != null) return new StructuredSelection(part); if (selectedPart.getParent() != null) { part = ((GraphicalEditPart) selectedPart.getParent()).findEditPart(null, (EObject) object); if (part != null) return new StructuredSelection(part); }/* w w w . j a v a 2 s. c o m*/ } return null; }