List of usage examples for org.eclipse.jface.viewers IStructuredSelection toArray
public Object[] toArray();
From source file:com.archimatetool.editor.views.tree.actions.DeleteAction.java
License:Open Source License
@Override public void run() { IStructuredSelection selection = getSelection(); if (selection == null || selection.isEmpty()) { return;/*from ww w.j a va 2s.c o m*/ } DeleteCommandHandler cmdHandler = new DeleteCommandHandler((TreeModelViewer) getSelectionProvider(), selection.toArray()); /* * If the objects are referenced in a diagram warn user */ if (cmdHandler.hasDiagramReferences()) { if (!MessageDialog.openQuestion(Display.getDefault().getActiveShell(), Messages.DeleteAction_1, Messages.DeleteAction_2 + "\n\n" + //$NON-NLS-1$ Messages.DeleteAction_3)) { return; } } cmdHandler.delete(); }
From source file:com.archimatetool.editor.views.tree.actions.DuplicateAction.java
License:Open Source License
@Override public void run() { IStructuredSelection selection = getSelection(); if (selection == null || selection.isEmpty()) { return;//from w ww.jav a 2 s . c om } DuplicateCommandHandler cmdHandler = new DuplicateCommandHandler(selection.toArray()); cmdHandler.duplicate(); }
From source file:com.archimatetool.editor.views.tree.actions.GenerateViewAction.java
License:Open Source License
private List<IArchimateElement> getValidSelectedObjects(IStructuredSelection selection) { List<IArchimateElement> list = new ArrayList<IArchimateElement>(); if (isSameModel(selection)) { for (Object o : selection.toArray()) { // Only Elements if (o instanceof IArchimateElement) { if (!list.contains(o)) { list.add((IArchimateElement) o); }/*from ww w . jav a 2s. c o m*/ } } } return list; }
From source file:com.archimatetool.editor.views.tree.actions.GenerateViewAction.java
License:Open Source License
/** * As this action is for the models tree, it's possible a user could select objects * from different models. We don't want this. *//*from w ww.ja v a 2 s . c om*/ private boolean isSameModel(IStructuredSelection selection) { IArchimateModel model = null; for (Object o : selection.toArray()) { if (o instanceof IArchimateModelObject) { IArchimateModel nextModel = ((IArchimateModelObject) o).getArchimateModel(); if (model != null && model != nextModel) { return false; } model = nextModel; } } return true; }
From source file:com.archimatetool.editor.views.tree.TreeModelViewerDragDropHandler.java
License:Open Source License
/** * Determine whether we have a valid selection of objects dragged from the Tree * Do it at the start of the drag operation for optimal speed. *///from ww w. j a v a 2 s . c o m boolean isValidTreeSelection(IStructuredSelection selection) { if (selection == null || selection.isEmpty()) { return false; } IArchimateModel model = null; for (Object object : selection.toArray()) { // Can't drag Models if (object instanceof IArchimateModel) { return false; } // Can only drag user folders if (object instanceof IFolder && ((IFolder) object).getType() != FolderType.USER) { return false; } // Don't allow mixed parent models if (object instanceof IArchimateModelElement) { IArchimateModel m = ((IArchimateModelElement) object).getArchimateModel(); if (model != null && m != model) { return false; } model = m; } } return true; }
From source file:com.archimatetool.editor.views.tree.TreeModelViewerDragDropHandler.java
License:Open Source License
void doDropOperation(DropTargetEvent event) { //boolean move = event.detail == DND.DROP_MOVE; // Local/* www .ja v a2 s. co m*/ if (isLocalTreeDragOperation(event.currentDataType)) { Object parent = getTargetParent(event); if (parent instanceof IFolder) { IStructuredSelection selection = (IStructuredSelection) LocalSelectionTransfer.getTransfer() .getSelection(); moveTreeObjects((IFolder) parent, selection.toArray()); } } // File else if (isFileDragOperation(event.currentDataType)) { addFileObjects((String[]) event.data); } }
From source file:com.archimatetool.hammer.view.ValidatorView.java
License:Open Source License
void selectObjects(IStructuredSelection selection) { if (selection != null) { List<IArchimateConcept> treeList = new ArrayList<IArchimateConcept>(); List<IDiagramModel> viewList = new ArrayList<IDiagramModel>(); List<IDiagramModelComponent> viewComponentList = new ArrayList<IDiagramModelComponent>(); for (Object o : selection.toArray()) { if (o instanceof IIssue) { IIssue issue = (IIssue) o; if (issue.getObject() instanceof IArchimateConcept) { treeList.add((IArchimateConcept) issue.getObject()); } else if (issue.getObject() instanceof IDiagramModel) { viewList.add((IDiagramModel) issue.getObject()); } else if (issue.getObject() instanceof IDiagramModelComponent) { viewList.add(((IDiagramModelComponent) issue.getObject()).getDiagramModel()); viewComponentList.add(((IDiagramModelComponent) issue.getObject())); }/*from w w w .ja v a 2s . co m*/ } } if (!treeList.isEmpty()) { ITreeModelView view = (ITreeModelView) ViewManager.showViewPart(ITreeModelView.ID, false); if (view != null) { view.getViewer().setSelection(new StructuredSelection(treeList), true); } } if (!viewList.isEmpty()) { for (IDiagramModel dm : viewList) { IDiagramModelEditor editor = EditorManager.openDiagramEditor(dm); if (editor instanceof IArchimateDiagramEditor) { ((IArchimateDiagramEditor) editor).selectObjects(viewComponentList.toArray()); } } } } }
From source file:com.archimatetool.hammer.view.ValidatorView.java
License:Open Source License
private boolean isIssueSelected(IStructuredSelection selection) { for (Object o : selection.toArray()) { if (o instanceof IIssue) { return true; }//w w w . j a v a 2 s .c o m } return false; }
From source file:com.archimatetool.hammer.view.ValidatorView.java
License:Open Source License
private boolean isIssueObjectSelected(IStructuredSelection selection) { for (Object o : selection.toArray()) { if (o instanceof IIssue && ((IIssue) o).getObject() != null) { if (((IIssue) o).getObject() != null) { return true; }/*from ww w. j ava2 s . c o m*/ } } return false; }
From source file:com.archimatetool.templates.dialog.TemplateManagerDialogDragDropHandler.java
License:Open Source License
private void copy(ITemplateGroup parent) { IStructuredSelection selection = (IStructuredSelection) LocalSelectionTransfer.getTransfer().getSelection(); // From Table to Tree for (Object o : selection.toArray()) { if (o instanceof ITemplate) { if (!parent.getTemplates().contains(o)) { parent.addTemplate((ITemplate) o); }/*www. j a va2 s.c o m*/ } } fTreeViewer.refresh(); }