use of com.archimatetool.model.INameable in project archi by archimatetool.
the class TreeModelViewerFindReplaceProviderTests method testFindNextElement_Backward_NotCaseSensitive_2.
@Test
public void testFindNextElement_Backward_NotCaseSensitive_2() {
provider.setParameter(IFindReplaceProvider.PARAM_FORWARD, false);
provider.setParameter(IFindReplaceProvider.PARAM_CASE_SENSITIVE, false);
provider.setParameter(IFindReplaceProvider.PARAM_ALL_MODELS, true);
String searchString = "director";
Object startElement = ArchimateModelUtils.getObjectByID(model2, "16fe3cf9");
assertNotNull(startElement);
INameable element = provider.findNextElement(startElement, searchString);
assertEquals("Director of Sales", element.getName());
element = provider.findNextElement(element, searchString);
assertEquals("Director of Operations", element.getName());
element = provider.findNextElement(element, searchString);
assertEquals("Director of Finance", element.getName());
// No more
assertNull(provider.findNextElement(element, searchString));
}
use of com.archimatetool.model.INameable in project archi by archimatetool.
the class TreeModelViewerFindReplaceProviderTests method testFindNextElement_Forward_NotCaseSensitive_1.
@Test
public void testFindNextElement_Forward_NotCaseSensitive_1() {
provider.setParameter(IFindReplaceProvider.PARAM_FORWARD, true);
provider.setParameter(IFindReplaceProvider.PARAM_CASE_SENSITIVE, false);
provider.setParameter(IFindReplaceProvider.PARAM_ALL_MODELS, true);
// Relations as well
provider.setParameter(IFindReplaceProvider.PARAM_INCLUDE_RELATIONS, true);
String searchString = "findme";
INameable element = provider.findNextElement(null, searchString);
assertEquals("FindMe 0", element.getName());
for (int i = 1; i < 11; i++) {
element = provider.findNextElement(element, searchString);
assertEquals("FindMe " + i, element.getName());
}
// No more
assertNull(provider.findNextElement(element, searchString));
}
use of com.archimatetool.model.INameable in project archi by archimatetool.
the class TreeModelViewerFindReplaceProvider method replace.
public boolean replace(String toFind, String toReplaceWith) {
// Replace All
if (isAll()) {
List<INameable> elements = getAllMatchingElements(toFind);
if (!elements.isEmpty()) {
List<String> newNames = new ArrayList<String>();
for (INameable nameable : elements) {
String newName = getNewName(nameable.getName(), toFind, toReplaceWith);
newNames.add(newName);
}
RenameCommandHandler.doRenameCommands(elements, newNames);
fTreeModelViewer.setSelection(new StructuredSelection(elements), true);
}
return !elements.isEmpty();
} else // Replace Next/Previous
{
// Replace on selected elements
if (replaceSelection) {
List<Object> selected = getSelectedObjects();
if (!selected.isEmpty()) {
List<INameable> elements = new ArrayList<INameable>();
List<String> newNames = new ArrayList<String>();
for (Object object : selected) {
if (matches(object, toFind)) {
INameable nameable = (INameable) object;
elements.add(nameable);
String newName = getNewName(nameable.getName(), toFind, toReplaceWith);
newNames.add(newName);
}
}
if (!elements.isEmpty()) {
RenameCommandHandler.doRenameCommands(elements, newNames);
return true;
}
}
} else // Replace on next single selection
{
Object object = getFirstSelectedObject();
if (matches(object, toFind)) {
RenameCommandHandler.doRenameCommand((INameable) object, getNewName(((INameable) object).getName(), toFind, toReplaceWith));
return true;
}
}
// Else move forward
return find(toFind);
}
}
use of com.archimatetool.model.INameable in project archi by archimatetool.
the class TreeModelViewerFindReplaceProvider method find.
public boolean find(String toFind) {
// Find All
if (isAll()) {
List<INameable> elements = getAllMatchingElements(toFind);
fTreeModelViewer.setSelection(new StructuredSelection(elements), true);
return !elements.isEmpty();
} else // Find Next/Previous
{
INameable element = findNextElement(getFirstSelectedObject(), toFind);
if (element != null) {
fTreeModelViewer.setSelection(new StructuredSelection(element), true);
}
return (element != null);
}
}
use of com.archimatetool.model.INameable in project archi-modelrepository-plugin by archi-contribs.
the class GraficoModelLoader method getRestoredObjectsAsString.
/**
* @return The list of resolved objects as a message string or null
*/
public String getRestoredObjectsAsString() {
if (fRestoredObjects == null) {
return null;
}
String s = Messages.GraficoModelLoader_0;
for (IIdentifier id : fRestoredObjects) {
if (id instanceof INameable) {
String name = ((INameable) id).getName();
String className = id.eClass().getName();
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
s += "\n" + (StringUtils.isSet(name) ? name + " (" + className + ")" : className);
}
}
return s;
}
Aggregations