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