use of com.archimatetool.model.IArchimateModel in project archi by archimatetool.
the class FieldDataFactoryTests method testGetFieldValue_This.
@Test
public void testGetFieldValue_This() {
IArchimateModel model = IArchimateFactory.eINSTANCE.createArchimateModel();
Object o = FieldDataFactory.getFieldValue(model, "this");
assertEquals(model, o);
}
use of com.archimatetool.model.IArchimateModel in project archi by archimatetool.
the class ImageManagerDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
// Help
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
setTitle(Messages.ImageManagerDialog_1);
setMessage(Messages.ImageManagerDialog_2);
Composite composite = (Composite) super.createDialogArea(parent);
Composite client = new Composite(composite, SWT.NULL);
GridLayout layout = new GridLayout(2, false);
client.setLayout(layout);
client.setLayoutData(new GridData(GridData.FILL_BOTH));
SashForm sash = new SashForm(client, SWT.HORIZONTAL);
sash.setLayoutData(new GridData(GridData.FILL_BOTH));
GridData gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = 580;
gd.heightHint = 300;
sash.setLayoutData(gd);
// Table
Composite tableComp = new Composite(sash, SWT.BORDER);
layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
tableComp.setLayout(layout);
CLabel label = new CLabel(tableComp, SWT.NULL);
label.setText(Messages.ImageManagerDialog_3);
Composite tableComp2 = new Composite(tableComp, SWT.NULL);
tableComp2.setLayout(new TableColumnLayout());
tableComp2.setLayoutData(new GridData(GridData.FILL_BOTH));
fModelsViewer = new ModelsViewer(tableComp2);
fModelsViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
// $NON-NLS-1$
fModelsViewer.setInput("");
fModelsViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
Object o = ((IStructuredSelection) event.getSelection()).getFirstElement();
if (o instanceof IArchimateModel) {
fScale.setEnabled(true);
clearGallery();
updateGallery((IArchimateModel) o);
}
}
});
// Mouse Up action...
fModelsViewer.getControl().addMouseListener(new MouseAdapter() {
@Override
public void mouseUp(MouseEvent e) {
Object o = ((IStructuredSelection) fModelsViewer.getSelection()).getFirstElement();
// Open...
if (o == OPEN) {
handleOpenAction();
}
}
});
Composite galleryComposite = new Composite(sash, SWT.NULL);
layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
galleryComposite.setLayout(layout);
fGallery = new Gallery(galleryComposite, SWT.V_SCROLL | SWT.BORDER);
fGallery.setLayoutData(new GridData(GridData.FILL_BOTH));
// Renderers
final NoGroupRenderer groupRenderer = new NoGroupRenderer();
groupRenderer.setItemSize(DEFAULT_GALLERY_ITEM_SIZE, DEFAULT_GALLERY_ITEM_SIZE);
groupRenderer.setAutoMargin(true);
groupRenderer.setMinMargin(10);
fGallery.setGroupRenderer(groupRenderer);
final DefaultGalleryItemRenderer itemRenderer = new DefaultGalleryItemRenderer();
itemRenderer.setDropShadows(true);
itemRenderer.setDropShadowsSize(7);
itemRenderer.setShowRoundedSelectionCorners(false);
fGallery.setItemRenderer(itemRenderer);
// Root Group
fGalleryRoot = new GalleryItem(fGallery, SWT.NONE);
// Slider
fScale = new Scale(galleryComposite, SWT.HORIZONTAL);
gd = new GridData(SWT.END, SWT.NONE, false, false);
gd.widthHint = 120;
if (PlatformUtils.isMac()) {
// Mac clips height of slider
gd.heightHint = 18;
}
fScale.setLayoutData(gd);
fScale.setMinimum(MIN_GALLERY_ITEM_SIZE);
fScale.setMaximum(MAX_GALLERY_ITEM_SIZE);
fScale.setIncrement(8);
fScale.setPageIncrement(32);
fScale.setSelection(DEFAULT_GALLERY_ITEM_SIZE);
fScale.setEnabled(false);
fScale.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
int inc = fScale.getSelection();
itemRenderer.setDropShadows(inc >= 96);
groupRenderer.setItemSize(inc, inc);
}
});
// Gallery selections
fGallery.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (e.item instanceof GalleryItem) {
fSelectedObject = ((GalleryItem) e.item).getData();
} else {
fSelectedObject = null;
}
}
});
// Double-clicks
fGallery.addListener(SWT.MouseDoubleClick, new Listener() {
public void handleEvent(Event event) {
GalleryItem item = fGallery.getItem(new Point(event.x, event.y));
if (item != null) {
okPressed();
}
}
});
// Dispose of the images here not in the main dispose() method because if the help system is showing then
// the TrayDialog is resized and this control is asked to relayout.
fGallery.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
disposeImages();
}
});
sash.setWeights(new int[] { 30, 70 });
/*
* Select the given model and image
* Better to put this on a thread as selection sometimes doesn't happen
*/
Display.getCurrent().asyncExec(new Runnable() {
@Override
public void run() {
// Make selection of model in table if it has images
if (fSelectedModel != null) {
IArchiveManager archiveManager = (IArchiveManager) fSelectedModel.getAdapter(IArchiveManager.class);
if (archiveManager.hasImages()) {
// Select model
fModelsViewer.setSelection(new StructuredSelection(fSelectedModel));
// Make selection of image if set
if (fSelectedImagePath != null) {
for (GalleryItem item : fGalleryRoot.getItems()) {
String imagePath = (String) item.getData();
if (imagePath != null && fSelectedImagePath.equals(imagePath)) {
fGallery.setSelection(new GalleryItem[] { item });
// we need to do this here because this is on a thread
fSelectedObject = imagePath;
break;
}
}
}
} else // Else select the first valid model that's open
{
for (IArchimateModel model : IEditorModelManager.INSTANCE.getModels()) {
archiveManager = (IArchiveManager) model.getAdapter(IArchiveManager.class);
if (archiveManager.hasImages()) {
fModelsViewer.setSelection(new StructuredSelection(model));
break;
}
}
}
}
}
});
return composite;
}
use of com.archimatetool.model.IArchimateModel in project archi by archimatetool.
the class DiagramModelArchimateConnectionTests method testAdd_Remove_ArchimateRelationshipToModel.
@Test
public void testAdd_Remove_ArchimateRelationshipToModel() {
IArchimateModel model = IArchimateFactory.eINSTANCE.createArchimateModel();
IArchimateDiagramModel dm = IArchimateFactory.eINSTANCE.createArchimateDiagramModel();
model.getDefaultFolderForObject(dm).getElements().add(dm);
dm.getChildren().add(source);
dm.getChildren().add(target);
connection.connect(source, target);
// Passing null uses a default folder in the model
IFolder expectedFolder = model.getDefaultFolderForObject(connection.getArchimateRelationship());
connection.addArchimateConceptToModel(null);
assertSame(expectedFolder, connection.getArchimateRelationship().eContainer());
connection.removeArchimateConceptFromModel();
assertNull(connection.getArchimateRelationship().eContainer());
expectedFolder = IArchimateFactory.eINSTANCE.createFolder();
connection.addArchimateConceptToModel(expectedFolder);
assertSame(expectedFolder, connection.getArchimateRelationship().eContainer());
}
use of com.archimatetool.model.IArchimateModel in project archi by archimatetool.
the class DiagramModelArchimateObjectTests method testAdd_Remove_ArchimateElementToModel.
@Test
public void testAdd_Remove_ArchimateElementToModel() {
IArchimateModel model = IArchimateFactory.eINSTANCE.createArchimateModel();
IArchimateDiagramModel dm = IArchimateFactory.eINSTANCE.createArchimateDiagramModel();
model.getDefaultFolderForObject(dm).getElements().add(dm);
dm.getChildren().add(object);
// Passing null uses a default folder in the model
IFolder expectedFolder = model.getDefaultFolderForObject(object.getArchimateElement());
object.addArchimateConceptToModel(null);
assertSame(expectedFolder, object.getArchimateElement().eContainer());
object.removeArchimateConceptFromModel();
assertNull(object.getArchimateElement().eContainer());
expectedFolder = IArchimateFactory.eINSTANCE.createFolder();
object.addArchimateConceptToModel(expectedFolder);
assertSame(expectedFolder, object.getArchimateElement().eContainer());
}
use of com.archimatetool.model.IArchimateModel in project archi by archimatetool.
the class DiagramModelConnectionTests method testGetArchimateModel.
@Test
public void testGetArchimateModel() {
assertNull(connection.getArchimateModel());
IArchimateModel model = IArchimateFactory.eINSTANCE.createArchimateModel();
model.getDefaultFolderForObject(dm).getElements().add(dm);
IDiagramModelGroup dmo = IArchimateFactory.eINSTANCE.createDiagramModelGroup();
dm.getChildren().add(dmo);
connection.connect(dmo, dmo);
assertSame(model, connection.getArchimateModel());
}
Aggregations