use of com.archimatetool.model.IProfile in project archi by archimatetool.
the class CSVImporter method setProfileForNewConcept.
// -------------------------------- Profile Helpers --------------------------------
/**
* Set a profile for a newly created concept
*/
private void setProfileForNewConcept(IArchimateConcept newConcept, String specializationName) {
// Do we have a matching Profile in the model?
IProfile profile = findModelProfile(specializationName, newConcept.eClass().getName());
// No, so create a new Profile and add it to the lookup list
if (profile == null) {
profile = createNewProfile(specializationName, newConcept.eClass().getName());
}
// Assign it
newConcept.getProfiles().add(profile);
}
use of com.archimatetool.model.IProfile in project archi by archimatetool.
the class CSVExporter method createElementRow.
/**
* Create a String Row for an Element
*/
String createElementRow(IArchimateElement element) {
StringBuffer sb = new StringBuffer();
// ID
String id = element.getId();
sb.append(surroundWithQuotes(id));
sb.append(fDelimiter);
// Class
sb.append(surroundWithQuotes(element.eClass().getName()));
sb.append(fDelimiter);
// Name
String name = normalise(element.getName());
sb.append(surroundWithQuotes(name));
sb.append(fDelimiter);
// Documentation
String documentation = normalise(element.getDocumentation());
sb.append(surroundWithQuotes(documentation));
sb.append(fDelimiter);
// Specialization
IProfile profile = element.getPrimaryProfile();
// $NON-NLS-1$
String specialization = normalise(profile != null ? profile.getName() : "");
sb.append(surroundWithQuotes(specialization));
return sb.toString();
}
use of com.archimatetool.model.IProfile in project archi by archimatetool.
the class CSVExporterTests method testCreateElementRow.
@Test
public void testCreateElementRow() {
IArchimateElement element = IArchimateFactory.eINSTANCE.createBusinessActor();
element.setId("a1234567");
element.setName("The Main Man");
element.setDocumentation("This is the Documentation");
IProfile profile = IArchimateFactory.eINSTANCE.createProfile();
profile.setName("Profile");
element.getProfiles().add(profile);
assertEquals("\"a1234567\",\"BusinessActor\",\"The Main Man\",\"This is the Documentation\",\"Profile\"", exporter.createElementRow(element));
}
use of com.archimatetool.model.IProfile in project archi by archimatetool.
the class ProfilesManagerDialog method createNewProfile.
/**
* Create a new Profile and add it to the temp profiles list
*/
private void createNewProfile() {
IProfile profile = IArchimateFactory.eINSTANCE.createProfile();
profile.setConceptType(fDefaultClass.getName());
profile.setName(generateNewProfileName(profile.getConceptType()));
fProfilesTemp.put(profile.getId(), profile);
// fTableViewer.applyEditorValue(); // complete any current editing
fTableViewer.refresh();
fTableViewer.editElement(profile, 1);
}
use of com.archimatetool.model.IProfile in project archi by archimatetool.
the class ProfilesManagerDialog method chooseImage.
/**
* Choose an image from the dialog and apply to selected profiles
*/
private void chooseImage() {
IStructuredSelection selection = fTableViewer.getStructuredSelection();
if (!selection.isEmpty()) {
IProfile firstSelected = (IProfile) selection.getFirstElement();
ImageManagerDialog dialog = new ImageManagerDialog(getParentShell());
dialog.setSelected(fArchimateModel, firstSelected.getImagePath());
if (dialog.open() == Window.OK) {
try {
IArchiveManager archiveManager = (IArchiveManager) fArchimateModel.getAdapter(IArchiveManager.class);
String path = null;
// Image from file
if (dialog.getUserSelectedFile() != null && dialog.getUserSelectedFile().exists()) {
path = archiveManager.addImageFromFile(dialog.getUserSelectedFile());
} else // Existing image which could be in this model or a different model
if (dialog.getUserSelectedImagePath() != null) {
if (dialog.getUserSelectedModel() != fArchimateModel) {
// Different model
IArchiveManager selectedArchiveManager = (IArchiveManager) dialog.getUserSelectedModel().getAdapter(IArchiveManager.class);
path = archiveManager.copyImageBytes(selectedArchiveManager, dialog.getUserSelectedImagePath());
} else {
// Same model
path = dialog.getUserSelectedImagePath();
}
}
if (path != null) {
// Apply the image path to Profiles that can have an image
for (Object o : selection.toList()) {
IProfile profile = (IProfile) o;
if (canHaveImage(profile)) {
profile.setImagePath(path);
}
}
}
} catch (Exception ex) {
ex.printStackTrace();
// $NON-NLS-1$
Logger.logError("Could not create image!", ex);
}
// Select to update image preview
fTableViewer.setSelection(selection);
}
}
}
Aggregations