use of com.archimatetool.model.IArchimateModelObject in project archi by archimatetool.
the class AbstractECorePropertySection method getFilteredObjects.
/**
* Filter selected objects.
* Also ensure that selected objects are from only one model.
* We don't support selections from more than one model due to each model having its own command stack.
*
* @return A list of filtered adaptable objects according to type
*/
private List<EObject> getFilteredObjects(List<?> objects) {
ArrayList<EObject> list = new ArrayList<EObject>();
IObjectFilter filter = getFilter();
// Get underlying object if a Filter is applied
for (Object object : objects) {
if (filter != null) {
object = filter.adaptObject(object);
}
if (object instanceof EObject) {
list.add((EObject) object);
}
}
// Only use the objects that are in *one* model - the model in the first selected object
if (!list.isEmpty()) {
IArchimateModel firstModel = ((IArchimateModelObject) list.get(0)).getArchimateModel();
// Remove objects with different parent models
for (int i = list.size() - 1; i >= 1; i--) {
IArchimateModelObject eObject = (IArchimateModelObject) list.get(i);
if (eObject.getArchimateModel() != firstModel) {
list.remove(eObject);
}
}
}
return list;
}
use of com.archimatetool.model.IArchimateModelObject in project archi by archimatetool.
the class ZestView method propertyChange.
// =================================================================================
// Listen to Editor Model Changes
// =================================================================================
@Override
public void propertyChange(PropertyChangeEvent evt) {
String propertyName = evt.getPropertyName();
Object newValue = evt.getNewValue();
// Model Closed
if (propertyName == IEditorModelManager.PROPERTY_MODEL_REMOVED) {
Object input = getViewer().getInput();
if (input instanceof IArchimateModelObject && ((IArchimateModelObject) input).getArchimateModel() == newValue) {
fDrillDownManager.reset();
}
} else // Command Stack - update Actions
if (propertyName == IEditorModelManager.COMMAND_STACK_CHANGED) {
updateActions();
} else {
super.propertyChange(evt);
}
}
use of com.archimatetool.model.IArchimateModelObject 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.IArchimateModelObject in project archi by archimatetool.
the class TreeModelViewerFindReplaceProvider method getModelInScope.
/**
* @return The model in scope of the selected element
*/
private IArchimateModel getModelInScope() {
IStructuredSelection selection = (IStructuredSelection) fTreeModelViewer.getSelection();
Object o = selection.getFirstElement();
if (o instanceof IArchimateModelObject) {
return ((IArchimateModelObject) o).getArchimateModel();
}
return null;
}
use of com.archimatetool.model.IArchimateModelObject in project archi by archimatetool.
the class TreeStateHelper method restoreExpandedTreeElements.
/**
* Restore expanded elements on TreeView creation
*/
void restoreExpandedTreeElements(TreeViewer viewer) {
fTreeViewer = viewer;
addDisposeListener();
if (fExpandedElements.isEmpty()) {
return;
}
for (Object o : fExpandedElements) {
// Actual object
if (o instanceof IArchimateModelObject) {
fTreeViewer.expandToLevel(o, 1);
}
// String ids
if (o instanceof FileMap) {
try {
File file = ((FileMap) o).file;
String[] elements = ((FileMap) o).elements;
for (IArchimateModel model : IEditorModelManager.INSTANCE.getModels()) {
if (file.equals(model.getFile())) {
for (String id : elements) {
EObject element = ArchimateModelUtils.getObjectByID(model, id);
if (element != null) {
fTreeViewer.expandToLevel(element, 1);
}
}
// found model
break;
}
}
} catch (Exception ex) {
// We don't want to fail just for some stupid string operation
ex.printStackTrace();
}
}
}
}
Aggregations