Search in sources :

Example 1 with IDiagramModelEditor

use of com.archimatetool.editor.diagram.IDiagramModelEditor 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 IDiagramModelEditor

use of com.archimatetool.editor.diagram.IDiagramModelEditor in project archi by archimatetool.

the class EditorManager method openDiagramEditor.

/**
 * Open the Diagram Editor for a given DiagramModel Model
 * @param name
 */
public static IDiagramModelEditor openDiagramEditor(IDiagramModel model) {
    if (model == null || model.eContainer() == null || !PlatformUI.isWorkbenchRunning()) {
        return null;
    }
    String id = null;
    IEditorInput editorInput = null;
    if (model instanceof IArchimateDiagramModel) {
        id = IArchimateDiagramEditor.ID;
        editorInput = new DiagramEditorInput(model);
    } else if (model instanceof ISketchModel) {
        id = ISketchEditor.ID;
        editorInput = new DiagramEditorInput(model);
    } else {
        IDiagramEditorFactory factory = DiagramEditorFactoryExtensionHandler.INSTANCE.getFactory(model);
        if (factory != null) {
            id = factory.getEditorID();
            editorInput = factory.createEditorInput(model);
        }
    }
    if (id == null || editorInput == null) {
        // $NON-NLS-1$
        throw new RuntimeException("Unsupported model type");
    }
    IEditorPart part = openEditor(editorInput, id);
    // Check it actually is IDiagramModelEditor, it could be an org.eclipse.ui.internal.ErrorEditorPart if an error occurs
    return part instanceof IDiagramModelEditor ? (IDiagramModelEditor) part : null;
}
Also used : IDiagramEditorFactory(com.archimatetool.editor.diagram.IDiagramEditorFactory) DiagramEditorInput(com.archimatetool.editor.diagram.DiagramEditorInput) IEditorPart(org.eclipse.ui.IEditorPart) IDiagramModelEditor(com.archimatetool.editor.diagram.IDiagramModelEditor) IEditorInput(org.eclipse.ui.IEditorInput) ISketchModel(com.archimatetool.model.ISketchModel) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel)

Example 3 with IDiagramModelEditor

use of com.archimatetool.editor.diagram.IDiagramModelEditor in project archi by archimatetool.

the class FullScreenAction method run.

@Override
public void run() {
    fGraphicalViewer = getWorkbenchPart().getAdapter(GraphicalViewer.class);
    fOldParent = fGraphicalViewer.getControl().getParent();
    fOldPaletteViewer = fGraphicalViewer.getEditDomain().getPaletteViewer();
    // Set Property so clients know this is in full screen mode
    // $NON-NLS-1$
    fGraphicalViewer.setProperty("full_screen", true);
    addKeyBindings();
    // Add key and menu listeners
    fGraphicalViewer.getContextMenu().addMenuListener(contextMenuListener);
    fGraphicalViewer.getControl().addKeyListener(keyListener);
    // Create new Shell
    fNewShell = new Shell(Display.getCurrent(), SWT.NONE);
    // To put the full screen on the current monitor
    fNewShell.setLocation(fOldParent.getShell().getLocation());
    fNewShell.setFullScreen(true);
    fNewShell.setMaximized(true);
    fNewShell.setText(Display.getAppName());
    fNewShell.setLayout(new FillLayout());
    fNewShell.setImage(IArchiImages.ImageFactory.getImage(IArchiImages.ICON_APP_128));
    // On Ubuntu the min/max/close buttons are shown, so trap the close button
    fNewShell.addShellListener(new ShellAdapter() {

        @Override
        public void shellClosed(ShellEvent e) {
            close();
        }
    });
    // Set the Viewer's control's parent to be the new Shell
    fGraphicalViewer.getControl().setParent(fNewShell);
    fNewShell.layout();
    fNewShell.open();
    fFloatingPalette = new FloatingPalette((IDiagramModelEditor) ((DefaultEditDomain) fGraphicalViewer.getEditDomain()).getEditorPart(), fNewShell);
    if (fFloatingPalette.getPaletteState().isOpen) {
        fFloatingPalette.open();
    }
    // Disable the old parent shell
    fOldParent.getShell().setEnabled(false);
    // Listen to Parts being closed
    getWorkbenchPart().getSite().getWorkbenchWindow().getPartService().addPartListener(partListener);
    // Set Focus on new Shell
    fNewShell.setFocus();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ShellAdapter(org.eclipse.swt.events.ShellAdapter) GraphicalViewer(org.eclipse.gef.GraphicalViewer) ShellEvent(org.eclipse.swt.events.ShellEvent) FillLayout(org.eclipse.swt.layout.FillLayout) IDiagramModelEditor(com.archimatetool.editor.diagram.IDiagramModelEditor) FloatingPalette(com.archimatetool.editor.diagram.FloatingPalette)

Example 4 with IDiagramModelEditor

use of com.archimatetool.editor.diagram.IDiagramModelEditor in project archi by archimatetool.

the class UsedInViewsSection method createTableControl.

private void createTableControl(Composite parent) {
    createLabel(parent, Messages.UsedInViewsSection_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);
    // 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 DiagramModelUtils.findReferencedDiagramsForArchimateConcept((IArchimateConcept) inputElement).toArray();
        }
    });
    fTableViewer.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            return ((IDiagramModel) element).getName();
        }

        @Override
        public Image getImage(Object element) {
            return IArchiImages.ImageFactory.getImage(IArchiImages.ICON_DIAGRAM);
        }
    });
    fTableViewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            if (!isAlive(fArchimateConcept)) {
                return;
            }
            Object o = ((IStructuredSelection) event.getSelection()).getFirstElement();
            if (o instanceof IDiagramModel) {
                IDiagramModel diagramModel = (IDiagramModel) o;
                IDiagramModelEditor editor = EditorManager.openDiagramEditor(diagramModel);
                if (editor instanceof IArchimateDiagramEditor) {
                    ((IArchimateDiagramEditor) editor).selectArchimateConcepts(new IArchimateConcept[] { fArchimateConcept });
                }
            }
        }
    });
    fTableViewer.setComparator(new ViewerComparator());
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) Composite(org.eclipse.swt.widgets.Composite) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) Image(org.eclipse.swt.graphics.Image) IDiagramModelEditor(com.archimatetool.editor.diagram.IDiagramModelEditor) IArchimateDiagramEditor(com.archimatetool.editor.diagram.IArchimateDiagramEditor) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) IDiagramModel(com.archimatetool.model.IDiagramModel) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) IArchimateConcept(com.archimatetool.model.IArchimateConcept) TableViewer(org.eclipse.jface.viewers.TableViewer) LabelProvider(org.eclipse.jface.viewers.LabelProvider) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 5 with IDiagramModelEditor

use of com.archimatetool.editor.diagram.IDiagramModelEditor in project archi by archimatetool.

the class TreeSelectionSynchroniser method selectionChanged.

@Override
public void selectionChanged(SelectionChangedEvent event) {
    if (isDispatching) {
        return;
    }
    fLastEvent = event;
    if (!Preferences.doLinkView() || !fDoSync) {
        return;
    }
    isDispatching = true;
    ISelection selection = event.getSelection();
    Object source = event.getSource();
    // Selection from Diagram Editor, so update the Tree if it is showing
    if (source instanceof GraphicalViewer && fTreeView != null) {
        List<Object> list = new ArrayList<Object>();
        for (Object o : ((IStructuredSelection) selection).toArray()) {
            if (o instanceof EditPart) {
                Object model = ((EditPart) o).getModel();
                // Archimate concept
                if (model instanceof IDiagramModelArchimateComponent) {
                    model = ((IDiagramModelArchimateComponent) model).getArchimateConcept();
                    list.add(model);
                } else // Diagram model
                if (model instanceof IDiagramModel) {
                    list.add(model);
                }
            }
        }
        // Select in tree
        fTreeView.getViewer().setSelection(new StructuredSelection(list), true);
    } else // Archimate objects selection from Tree View, so update any Archimate Diagram Editors
    if (source instanceof TreeViewer) {
        List<IArchimateConcept> list = new ArrayList<IArchimateConcept>();
        // Archimate elements
        for (Object o : ((IStructuredSelection) selection).toArray()) {
            if (o instanceof IArchimateConcept) {
                list.add((IArchimateConcept) o);
            }
        }
        // Select these in the Diagram Editors
        for (IDiagramModelEditor diagramEditor : fDiagramEditors) {
            if (diagramEditor instanceof IArchimateDiagramEditor) {
                ((IArchimateDiagramEditor) diagramEditor).selectArchimateConcepts(list.toArray(new IArchimateConcept[list.size()]));
            }
        }
    }
    isDispatching = false;
}
Also used : GraphicalViewer(org.eclipse.gef.GraphicalViewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ArrayList(java.util.ArrayList) EditPart(org.eclipse.gef.EditPart) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IDiagramModelEditor(com.archimatetool.editor.diagram.IDiagramModelEditor) IArchimateDiagramEditor(com.archimatetool.editor.diagram.IArchimateDiagramEditor) IDiagramModel(com.archimatetool.model.IDiagramModel) ISelection(org.eclipse.jface.viewers.ISelection) IDiagramModelArchimateComponent(com.archimatetool.model.IDiagramModelArchimateComponent) IArchimateConcept(com.archimatetool.model.IArchimateConcept) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

IDiagramModelEditor (com.archimatetool.editor.diagram.IDiagramModelEditor)5 IArchimateDiagramEditor (com.archimatetool.editor.diagram.IArchimateDiagramEditor)3 IArchimateConcept (com.archimatetool.model.IArchimateConcept)3 IDiagramModel (com.archimatetool.model.IDiagramModel)3 ArrayList (java.util.ArrayList)2 GraphicalViewer (org.eclipse.gef.GraphicalViewer)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2 DiagramEditorInput (com.archimatetool.editor.diagram.DiagramEditorInput)1 FloatingPalette (com.archimatetool.editor.diagram.FloatingPalette)1 IDiagramEditorFactory (com.archimatetool.editor.diagram.IDiagramEditorFactory)1 ITreeModelView (com.archimatetool.editor.views.tree.ITreeModelView)1 IIssue (com.archimatetool.hammer.validation.issues.IIssue)1 IArchimateDiagramModel (com.archimatetool.model.IArchimateDiagramModel)1 IDiagramModelArchimateComponent (com.archimatetool.model.IDiagramModelArchimateComponent)1 IDiagramModelComponent (com.archimatetool.model.IDiagramModelComponent)1 ISketchModel (com.archimatetool.model.ISketchModel)1 List (java.util.List)1 EditPart (org.eclipse.gef.EditPart)1 TableColumnLayout (org.eclipse.jface.layout.TableColumnLayout)1