Search in sources :

Example 1 with ITreeModelView

use of com.archimatetool.editor.views.tree.ITreeModelView in project archi by archimatetool.

the class ValidatorView method selectObjects.

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()));
                }
            }
        }
        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());
                }
            }
        }
    }
}
Also used : ITreeModelView(com.archimatetool.editor.views.tree.ITreeModelView) IDiagramModelComponent(com.archimatetool.model.IDiagramModelComponent) ArrayList(java.util.ArrayList) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IDiagramModelEditor(com.archimatetool.editor.diagram.IDiagramModelEditor) IArchimateDiagramEditor(com.archimatetool.editor.diagram.IArchimateDiagramEditor) IDiagramModel(com.archimatetool.model.IDiagramModel) IArchimateConcept(com.archimatetool.model.IArchimateConcept) IIssue(com.archimatetool.hammer.validation.issues.IIssue)

Example 2 with ITreeModelView

use of com.archimatetool.editor.views.tree.ITreeModelView in project archi by archimatetool.

the class SelectElementInTreeAction method run.

@Override
public void run() {
    List<?> selection = getSelectedObjects();
    List<Object> elements = new ArrayList<Object>();
    for (Object object : selection) {
        if (object instanceof EditPart) {
            Object model = ((EditPart) object).getModel();
            if (model instanceof IDiagramModel) {
                elements.add(model);
            } else if (model instanceof IDiagramModelArchimateComponent) {
                elements.add(((IDiagramModelArchimateComponent) model).getArchimateConcept());
            }
        }
    }
    ITreeModelView view = (ITreeModelView) ViewManager.showViewPart(ITreeModelView.ID, true);
    if (view != null) {
        view.getViewer().setSelection(new StructuredSelection(elements), true);
    }
}
Also used : ITreeModelView(com.archimatetool.editor.views.tree.ITreeModelView) IDiagramModel(com.archimatetool.model.IDiagramModel) ArrayList(java.util.ArrayList) EditPart(org.eclipse.gef.EditPart) IDiagramModelArchimateComponent(com.archimatetool.model.IDiagramModelArchimateComponent) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject)

Example 3 with ITreeModelView

use of com.archimatetool.editor.views.tree.ITreeModelView in project archi by archimatetool.

the class ZestView method makeActions.

/**
 * Make local actions
 */
private void makeActions() {
    fActionProperties = new PropertiesAction(getViewer());
    fActionLayout = new Action(Messages.ZestView_0) {

        @Override
        public void run() {
            fGraphViewer.doApplyLayout();
        }

        @Override
        public String getToolTipText() {
            return getText();
        }

        @Override
        public ImageDescriptor getImageDescriptor() {
            return AbstractUIPlugin.imageDescriptorFromPlugin(ArchiZestPlugin.PLUGIN_ID, // $NON-NLS-1$
            "img/layout.gif");
        }
    };
    fActionPinContent = new Action(Messages.ZestView_4, IAction.AS_CHECK_BOX) {

        {
            setToolTipText(Messages.ZestView_1);
            setImageDescriptor(IArchiImages.ImageFactory.getImageDescriptor(IArchiImages.ICON_PIN));
        }
    };
    fActionCopyImageToClipboard = new CopyZestViewAsImageToClipboardAction(fGraphViewer);
    fActionExportImageToFile = new ExportAsImageAction(fGraphViewer);
    fActionSelectInModelTree = new Action(Messages.ZestView_8) {

        @Override
        public void run() {
            IStructuredSelection selection = (IStructuredSelection) getViewer().getSelection();
            ITreeModelView view = (ITreeModelView) ViewManager.showViewPart(ITreeModelView.ID, true);
            if (view != null && !selection.isEmpty()) {
                view.getViewer().setSelection(new StructuredSelection(selection.toArray()), true);
            }
        }

        @Override
        public String getToolTipText() {
            return getText();
        }
    };
}
Also used : ITreeModelView(com.archimatetool.editor.views.tree.ITreeModelView) IAction(org.eclipse.jface.action.IAction) IViewerAction(com.archimatetool.editor.views.tree.actions.IViewerAction) PropertiesAction(com.archimatetool.editor.views.tree.actions.PropertiesAction) Action(org.eclipse.jface.action.Action) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) PropertiesAction(com.archimatetool.editor.views.tree.actions.PropertiesAction)

Example 4 with ITreeModelView

use of com.archimatetool.editor.views.tree.ITreeModelView in project archi by archimatetool.

the class UsedInRelationshipsSection method createTableControl.

private void createTableControl(Composite parent) {
    createLabel(parent, Messages.UsedInRelationshipsSection_0, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.NONE);
    // Table
    Composite tableComp = createTableComposite(parent, SWT.NONE);
    TableColumnLayout tableLayout = (TableColumnLayout) tableComp.getLayout();
    fTableViewer = new TableViewer(tableComp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
    // Column
    TableViewerColumn column = new TableViewerColumn(fTableViewer, SWT.NONE, 0);
    tableLayout.setColumnData(column.getColumn(), new ColumnWeightData(100, false));
    // On Mac shows alternate table row colours
    fTableViewer.getTable().setLinesVisible(true);
    // Help ID
    PlatformUI.getWorkbench().getHelpSystem().setHelp(fTableViewer.getTable(), HELP_ID);
    fTableViewer.setContentProvider(new IStructuredContentProvider() {

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }

        public void dispose() {
        }

        public Object[] getElements(Object inputElement) {
            return ArchimateModelUtils.getAllRelationshipsForConcept((IArchimateElement) inputElement).toArray();
        }
    });
    fTableViewer.setLabelProvider(new UsedInRelationshipsTableLabelProvider(fTableViewer.getTable()));
    fTableViewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            if (isAlive(fArchimateElement)) {
                Object o = ((IStructuredSelection) event.getSelection()).getFirstElement();
                if (o instanceof IArchimateRelationship) {
                    IArchimateRelationship relation = (IArchimateRelationship) o;
                    ITreeModelView view = (ITreeModelView) ViewManager.findViewPart(ITreeModelView.ID);
                    if (view != null) {
                        view.getViewer().setSelection(new StructuredSelection(relation), true);
                    }
                }
            }
        }
    });
    fTableViewer.setComparator(new ViewerComparator());
    // DND
    fTableViewer.addDragSupport(DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK, new Transfer[] { LocalSelectionTransfer.getTransfer() }, new DragSourceListener() {

        public void dragStart(DragSourceEvent event) {
            // Drag started from the Table
            LocalSelectionTransfer.getTransfer().setSelection(fTableViewer.getSelection());
            event.doit = true;
        }

        public void dragSetData(DragSourceEvent event) {
            // For consistency set the data to the selection even though
            // the selection is provided by the LocalSelectionTransfer
            // to the drop target adapter.
            event.data = LocalSelectionTransfer.getTransfer().getSelection();
        }

        public void dragFinished(DragSourceEvent event) {
            LocalSelectionTransfer.getTransfer().setSelection(null);
        }
    });
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) ITreeModelView(com.archimatetool.editor.views.tree.ITreeModelView) Composite(org.eclipse.swt.widgets.Composite) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) DragSourceListener(org.eclipse.swt.dnd.DragSourceListener) DragSourceEvent(org.eclipse.swt.dnd.DragSourceEvent) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Aggregations

ITreeModelView (com.archimatetool.editor.views.tree.ITreeModelView)4 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 IDiagramModel (com.archimatetool.model.IDiagramModel)2 ArrayList (java.util.ArrayList)2 IArchimateDiagramEditor (com.archimatetool.editor.diagram.IArchimateDiagramEditor)1 IDiagramModelEditor (com.archimatetool.editor.diagram.IDiagramModelEditor)1 IViewerAction (com.archimatetool.editor.views.tree.actions.IViewerAction)1 PropertiesAction (com.archimatetool.editor.views.tree.actions.PropertiesAction)1 IIssue (com.archimatetool.hammer.validation.issues.IIssue)1 IArchimateConcept (com.archimatetool.model.IArchimateConcept)1 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)1 IDiagramModelArchimateComponent (com.archimatetool.model.IDiagramModelArchimateComponent)1 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)1 IDiagramModelComponent (com.archimatetool.model.IDiagramModelComponent)1 EditPart (org.eclipse.gef.EditPart)1 Action (org.eclipse.jface.action.Action)1 IAction (org.eclipse.jface.action.IAction)1 TableColumnLayout (org.eclipse.jface.layout.TableColumnLayout)1 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)1