use of com.archimatetool.model.IProfile in project archi by archimatetool.
the class ProfilesManagerDialog method updateImagePreview.
/**
* Update the image preview
*/
private void updateImagePreview() {
disposePreviewImage();
IProfile profile = (IProfile) fTableViewer.getStructuredSelection().getFirstElement();
if (profile != null && profile.getImagePath() != null) {
IArchiveManager archiveManager = (IArchiveManager) fArchimateModel.getAdapter(IArchiveManager.class);
try {
fPreviewImage = archiveManager.createImage(profile.getImagePath());
} catch (Exception ex) {
ex.printStackTrace();
// $NON-NLS-1$
Logger.logError("Could not create image!", ex);
}
}
fImagePreview.redraw();
}
use of com.archimatetool.model.IProfile in project archi by archimatetool.
the class ProfilesManagerDialog method okPressed.
/**
* OK was pressed, so see what was added, changed or deleted and execute the Commands
*/
@Override
protected void okPressed() {
super.okPressed();
CompoundCommand compoundCmd = new CompoundCommand(Messages.ProfilesManagerDialog_16);
// Iterate thru our temp list of Profiles
for (IProfile profile : fProfilesTemp.values()) {
// Is this a copy of the original?
if (fProfilesModel.containsKey(profile.getId())) {
IProfile profileOriginal = fProfilesModel.get(profile.getId());
// The Profile has been edited
if (!EcoreUtil.equals(profileOriginal, profile)) {
List<IProfiles> usages = fProfilesUsage.get(profileOriginal.getId());
compoundCmd.add(new ChangeProfileCommand(profileOriginal, profile, usages));
}
} else // A new Profile was added
{
compoundCmd.add(new AddListMemberCommand<IProfile>(fArchimateModel.getProfiles(), profile));
}
}
// Iterate thru model's Profiles and compare with our temp list to see if any Profiles were deleted
for (IProfile profile : fArchimateModel.getProfiles()) {
if (!fProfilesTemp.containsKey(profile.getId())) {
List<IProfiles> usages = fProfilesUsage.get(profile.getId());
compoundCmd.add(new DeleteProfileCommand(profile, usages));
}
}
// Execute the Commands
CommandStack stack = (CommandStack) fArchimateModel.getAdapter(CommandStack.class);
stack.execute(compoundCmd);
}
use of com.archimatetool.model.IProfile in project archi by archimatetool.
the class ProfilesManagerDialog method clearImages.
/**
* Clear all images and set selected Profiles' image paths to null
*/
private void clearImages() {
IStructuredSelection selection = fTableViewer.getStructuredSelection();
for (Object o : selection.toList()) {
((IProfile) o).setImagePath(null);
}
// Reselect to update image preview
fTableViewer.setSelection(selection);
}
use of com.archimatetool.model.IProfile in project archi by archimatetool.
the class ModelImporter method doImport.
public void doImport(File importedFile, IArchimateModel targetModel) throws IOException, ImportException {
if (!importedFile.exists()) {
throw new IOException(NLS.bind(Messages.ModelImporter_2, importedFile));
}
importedModel = IEditorModelManager.INSTANCE.load(importedFile);
this.targetModel = targetModel;
objectCache = createObjectIDCache();
statusMessages = new ArrayList<>();
compoundCommand = new NonNotifyingCompoundCommand(Messages.ModelImporter_1);
// Upate root model object if the option is set
if (updateAll) {
updateObject(importedModel, targetModel);
logMessage(StatusMessageLevel.INFO, Messages.ModelImporter_3, targetModel);
}
// Iterate through all model contents
for (Iterator<EObject> iter = importedModel.eAllContents(); iter.hasNext(); ) {
EObject eObject = iter.next();
// Update folders
if (eObject instanceof IFolder) {
new FolderImporter(this).importFolder((IFolder) eObject);
} else // Update concepts
if (eObject instanceof IArchimateConcept) {
new ConceptImporter(this).importConcept((IArchimateConcept) eObject);
} else // Update Views
if (eObject instanceof IDiagramModel) {
new ViewImporter(this).importView((IDiagramModel) eObject);
} else // Update Profiles
if (eObject instanceof IProfile) {
new ProfileImporter(this).importProfile((IProfile) eObject);
}
}
if (compoundCommand.canExecute()) {
// Check view connection ends are valid if we have done some commands and even if update is off
addCommand(new SetArchimateReconnectionCommand(targetModel));
// Check duplicate names in Profiles
// TODO: No more needed because we match profiles by name and can't generate duplicates
// addCommand(new UnduplicateProfileNamesCommand(targetModel));
}
// Run Commands
CommandStack stack = (CommandStack) targetModel.getAdapter(CommandStack.class);
stack.execute(compoundCommand);
objectCache.clear();
objectCache = null;
importedModel = null;
this.targetModel = null;
}
use of com.archimatetool.model.IProfile in project archi by archimatetool.
the class ProfileImporter method addNewProfile.
private void addNewProfile(IProfile importedProfile) throws IOException {
// Clone the imported Profile
IProfile newProfile = cloneObject(importedProfile);
// Add the clone
addCommand(new AddListMemberCommand<IProfile>(getTargetModel().getProfiles(), newProfile));
// Import any image bytes
importImageBytes(importedProfile, newProfile);
// Log
logMessage(StatusMessageLevel.INFO, Messages.ProfileImporter_1, newProfile);
}
Aggregations