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());
}
}
}
}
}
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;
}
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();
}
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());
}
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;
}
Aggregations