use of com.archimatetool.model.INameable in project archi by archimatetool.
the class ExportAsImageAction method run.
@Override
public void run() {
String name = null;
Object model = fGraphViewer.getInput();
if (model instanceof INameable) {
name = ((INameable) model).getName();
}
WizardDialog dialog = new ExtendedWizardDialog(fGraphViewer.getControl().getShell(), new ExportAsImageWizard(fGraphViewer.getGraphControl().getContents(), name), // $NON-NLS-1$
"ExportZestViewAsImage") {
@Override
protected void createButtonsForButtonBar(Composite parent) {
// Change "Finish" to "Save"
super.createButtonsForButtonBar(parent);
Button b = getButton(IDialogConstants.FINISH_ID);
b.setText(Messages.ExportAsImageAction_3);
}
};
dialog.open();
}
use of com.archimatetool.model.INameable in project archi by archimatetool.
the class DiagramEditorFindReplaceProvider method replace.
@Override
public boolean replace(String toFind, String toReplaceWith) {
// Replace All
if (isAll()) {
List<EditPart> editParts = getAllMatchingEditParts(toFind);
if (!editParts.isEmpty()) {
List<String> newNames = new ArrayList<String>();
for (EditPart editPart : editParts) {
String newName = getNewName(((INameable) editPart.getModel()).getName(), toFind, toReplaceWith);
newNames.add(newName);
}
doRenameCommands(editParts, newNames);
fGraphicalViewer.setSelection(new StructuredSelection(editParts));
fGraphicalViewer.reveal(editParts.get(0));
}
return !editParts.isEmpty();
} else // Replace Next/Previous
{
// Replace on selected EditParts
if (replaceSelection) {
List<EditPart> selected = getSelectedEditParts();
if (!selected.isEmpty()) {
List<EditPart> editParts = new ArrayList<EditPart>();
List<String> newNames = new ArrayList<String>();
for (EditPart editPart : selected) {
if (matches(editPart, toFind)) {
editParts.add(editPart);
String newName = getNewName(((INameable) editPart.getModel()).getName(), toFind, toReplaceWith);
newNames.add(newName);
}
}
if (!editParts.isEmpty()) {
doRenameCommands(editParts, newNames);
return true;
}
}
} else // Replace on next single selection
{
EditPart editPart = getFirstSelectedEditPart();
if (matches(editPart, toFind)) {
doRenameCommand(editPart, getNewName(((INameable) editPart.getModel()).getName(), toFind, toReplaceWith));
return true;
}
}
// Else move forward
return find(toFind);
}
}
use of com.archimatetool.model.INameable in project archi by archimatetool.
the class DiagramEditorFindReplaceProvider method doRenameCommand.
void doRenameCommand(EditPart editPart, String newName) {
INameable object = (INameable) editPart.getModel();
CommandStack stack = (CommandStack) ((IAdapter) object).getAdapter(CommandStack.class);
if (stack != null) {
stack.execute(new EObjectFeatureCommand(NLS.bind(Messages.DiagramEditorFindReplaceProvider_0, object.getName()), object, IArchimatePackage.Literals.NAMEABLE__NAME, newName));
}
}
use of com.archimatetool.model.INameable in project archi by archimatetool.
the class FieldDataFactory method getFieldValue.
public static Object getFieldValue(Object dataElement, String fieldName) {
if ("this".equals(fieldName)) {
// $NON-NLS-1$
return dataElement;
}
if ("id".equals(fieldName) && dataElement instanceof IIdentifier) {
// $NON-NLS-1$
return ((IIdentifier) dataElement).getId();
}
if ("name".equals(fieldName) && dataElement instanceof INameable) {
// $NON-NLS-1$
String name = ((INameable) dataElement).getName();
if (name == null || "".equals(name)) {
// $NON-NLS-1$
name = ArchiLabelProvider.INSTANCE.getDefaultName(((EObject) dataElement).eClass());
}
return name;
}
if ("type".equals(fieldName) && dataElement instanceof EObject) {
// $NON-NLS-1$
return ArchiLabelProvider.INSTANCE.getDefaultName(((EObject) dataElement).eClass());
}
if ("documentation".equals(fieldName) && dataElement instanceof IDocumentable) {
// $NON-NLS-1$
String s = ((IDocumentable) dataElement).getDocumentation();
return StringUtils.isSet(s) ? s : null;
}
if ("purpose".equals(fieldName) && dataElement instanceof IArchimateModel) {
// $NON-NLS-1$
String s = ((IArchimateModel) dataElement).getPurpose();
return StringUtils.isSet(s) ? s : null;
}
if ("relation_source".equals(fieldName) && dataElement instanceof IArchimateRelationship) {
// $NON-NLS-1$
IArchimateRelationship relation = (IArchimateRelationship) dataElement;
IArchimateConcept source = relation.getSource();
String s = source.getName();
return StringUtils.isSet(s) ? s : null;
}
if ("relation_target".equals(fieldName) && dataElement instanceof IArchimateRelationship) {
// $NON-NLS-1$
IArchimateRelationship relation = (IArchimateRelationship) dataElement;
IArchimateConcept target = relation.getTarget();
String s = target.getName();
return StringUtils.isSet(s) ? s : null;
}
return null;
}
use of com.archimatetool.model.INameable in project archi by archimatetool.
the class TreeModelViewerFindReplaceProviderTests method testFindNextElement_Forward_NotCaseSensitive_2.
@Test
public void testFindNextElement_Forward_NotCaseSensitive_2() {
provider.setParameter(IFindReplaceProvider.PARAM_FORWARD, true);
provider.setParameter(IFindReplaceProvider.PARAM_CASE_SENSITIVE, false);
provider.setParameter(IFindReplaceProvider.PARAM_ALL_MODELS, true);
String searchString = "director";
INameable element = provider.findNextElement(null, searchString);
assertEquals("Director of Finance", element.getName());
element = provider.findNextElement(element, searchString);
assertEquals("Director of Operations", element.getName());
element = provider.findNextElement(element, searchString);
assertEquals("Director of Sales", element.getName());
// No more
assertNull(provider.findNextElement(element, searchString));
}
Aggregations