use of com.archimatetool.model.IFolder in project archi by archimatetool.
the class MyImporter method createAndAddArchimateComponent.
protected IArchimateConcept createAndAddArchimateComponent(IArchimateModel model, EClass type, String name, String id) {
IArchimateConcept concept = (IArchimateConcept) IArchimateFactory.eINSTANCE.create(type);
concept.setName(name);
concept.setId(id);
IFolder folder = model.getDefaultFolderForObject(concept);
folder.getElements().add(concept);
idLookup.put(concept.getId(), concept);
return concept;
}
use of com.archimatetool.model.IFolder in project archi by archimatetool.
the class TreeModelViewerDragDropHandler method isValidTreeSelection.
/**
* Determine whether we have a valid selection of objects dragged from the Tree
* Do it at the start of the drag operation for optimal speed.
*/
boolean isValidTreeSelection(IStructuredSelection selection) {
if (selection == null || selection.isEmpty()) {
return false;
}
IArchimateModel model = null;
for (Object object : selection.toArray()) {
// Can't drag Models
if (object instanceof IArchimateModel) {
return false;
}
// Can only drag user folders
if (object instanceof IFolder && ((IFolder) object).getType() != FolderType.USER) {
return false;
}
// Don't allow mixed parent models
if (object instanceof IArchimateModelObject) {
IArchimateModel m = ((IArchimateModelObject) object).getArchimateModel();
if (model != null && m != model) {
return false;
}
model = m;
}
}
return true;
}
use of com.archimatetool.model.IFolder in project archi by archimatetool.
the class TreeModelViewerDragDropHandler method isValidDropTarget.
/**
* @return True if target is valid
*/
boolean isValidDropTarget(DropTargetEvent event) {
// File from desktop onto blank area
if (isFileDragOperation(event.currentDataType)) {
return event.item == null;
}
// Local Tree Selection...
// Dragging onto a Folder
Object parent = getTargetParent(event);
if (parent instanceof IFolder) {
IFolder targetfolder = (IFolder) parent;
IStructuredSelection selection = (IStructuredSelection) LocalSelectionTransfer.getTransfer().getSelection();
for (Object object : selection.toList()) {
// must have the same top folder type - a restriction which one day we should not enforce!
if (!hasCommonAncestorFolder(targetfolder, (EObject) object)) {
return false;
}
if (!canDropObject(object, (TreeItem) event.item)) {
return false;
}
}
return true;
}
return false;
}
use of com.archimatetool.model.IFolder in project archi by archimatetool.
the class TreeModelViewerDragDropHandler method doDropOperation.
void doDropOperation(DropTargetEvent event) {
// Local
if (isLocalTreeDragOperation(event.currentDataType)) {
Object parent = getTargetParent(event);
if (parent instanceof IFolder) {
IStructuredSelection selection = (IStructuredSelection) LocalSelectionTransfer.getTransfer().getSelection();
moveTreeObjects((IFolder) parent, selection.toArray());
}
} else // File
if (isFileDragOperation(event.currentDataType)) {
addFileObjects((String[]) event.data);
}
}
use of com.archimatetool.model.IFolder in project archi by archimatetool.
the class Archimate2To3Handler method convertConnectorsFolder.
private void convertConnectorsFolder(IArchimateModel model, IFolder connectorsFolder) {
IFolder otherFolder = model.getFolder(FolderType.OTHER);
if (otherFolder != null) {
for (EObject eObject : new ArrayList<EObject>(connectorsFolder.eContents())) {
otherFolder.getElements().add(eObject);
}
}
model.getFolders().remove(connectorsFolder);
}
Aggregations