use of com.archimatetool.model.IArchimateModelObject in project archi by archimatetool.
the class TreeStateHelper method saveStateOnApplicationClose.
/**
* Save expanded state of tree elements on Application close
* @param memento
*/
void saveStateOnApplicationClose(IMemento memento) {
Hashtable<File, String> map = new Hashtable<File, String>();
IMemento expandedMem = memento.createChild(MEMENTO_EXPANDED);
for (Object element : fTreeViewer.getVisibleExpandedElements()) {
if (element instanceof IIdentifier && element instanceof IArchimateModelObject) {
// Only store if saved in a file
File file = ((IArchimateModelObject) element).getArchimateModel().getFile();
if (file != null) {
String id = ((IIdentifier) element).getId();
String string = map.get(file);
if (string == null) {
string = id;
} else {
string += ELEMENT_SEP_CHAR + id;
}
map.put(file, string);
}
}
}
for (File file : map.keySet()) {
IMemento elementMem = expandedMem.createChild(MEMENTO_MODEL);
elementMem.putString(MEMENTO_FILE, file.getAbsolutePath());
elementMem.putString(MEMENTO_ELEMENTS, map.get(file));
}
}
use of com.archimatetool.model.IArchimateModelObject in project archi by archimatetool.
the class NavigatorView 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().getActualInput();
if (input instanceof IArchimateModelObject && ((IArchimateModelObject) input).getArchimateModel() == newValue) {
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 moveTreeObjects.
/**
* Move Tree Objects
*/
void moveTreeObjects(IFolder newParent, Object[] objects) {
final CompoundCommand compoundCommand = new NonNotifyingCompoundCommand() {
@Override
public String getLabel() {
return getCommands().size() > 1 ? Messages.TreeModelViewerDragDropHandler_0 : super.getLabel();
}
};
for (Object object : objects) {
if (object instanceof IFolder) {
// This first - folders go in folders
if (!newParent.getFolders().contains(object)) {
compoundCommand.add(new MoveFolderCommand(newParent, (IFolder) object));
}
} else if (object instanceof IArchimateModelObject) {
if (!newParent.getElements().contains(object)) {
compoundCommand.add(new MoveObjectCommand(newParent, (IArchimateModelObject) object));
}
}
}
CommandStack stack = (CommandStack) newParent.getAdapter(CommandStack.class);
stack.execute(compoundCommand);
}
use of com.archimatetool.model.IArchimateModelObject in project archi by archimatetool.
the class GenerateViewAction method isSameModel.
/**
* As this action is for the models tree, it's possible a user could select objects
* from different models. We don't want this.
*/
private boolean isSameModel(IStructuredSelection selection) {
IArchimateModel model = null;
for (Object o : selection.toArray()) {
if (o instanceof IArchimateModelObject) {
IArchimateModel nextModel = ((IArchimateModelObject) o).getArchimateModel();
if (model != null && model != nextModel) {
return false;
}
model = nextModel;
}
}
return true;
}
Aggregations