use of com.archimatetool.model.IArchimateConcept 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.model.IArchimateConcept in project archi by archimatetool.
the class CSVImporter method importRelations.
// -------------------------------- Import Relations --------------------------------
/**
* Import Relations from CSV file
* @param file The file to import
* @throws IOException
* @throws CSVParseException
*/
void importRelations(File file) throws IOException, CSVParseException {
for (CSVRecord csvRecord : getRecords(file)) {
if (!isRelationsRecordCorrectSize(csvRecord)) {
throw new CSVParseException(Messages.CSVImporter_2);
}
// Header
if (isHeaderRecord(csvRecord, RELATIONSHIPS_HEADER)) {
continue;
} else // Relation
{
createRelationFromRecord(csvRecord);
}
}
// Now connect the relations
for (Entry<String, IArchimateConcept> entry : newConcepts.entrySet()) {
if (entry.getValue() instanceof IArchimateRelationship) {
IArchimateRelationship relation = (IArchimateRelationship) entry.getValue();
// Get the ids from the temporary stores
// $NON-NLS-1$
IArchimateConcept source = findReferencedConcept((String) relation.getAdapter("sourceID"));
// $NON-NLS-1$
IArchimateConcept target = findReferencedConcept((String) relation.getAdapter("targetID"));
// Is it a valid relationship?
if (!ArchimateModelUtils.isValidRelationship(source.eClass(), target.eClass(), relation.eClass())) {
throw new CSVParseException(Messages.CSVImporter_5 + relation.getId());
}
// Connect
relation.connect(source, target);
}
}
}
use of com.archimatetool.model.IArchimateConcept 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