Java Code Examples for org.eclipse.emf.edit.provider.ItemProviderAdapter

The following examples show how to use org.eclipse.emf.edit.provider.ItemProviderAdapter. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: bonita-studio   Source File: NamingUtils.java    License: GNU General Public License v2.0 6 votes vote down vote up
public String generateName(final Element newItem, final Element existingItem) {
    final DefaultElementNameProvider elementNameProvider = new DefaultElementNameProvider();
    final Adapter adapter = new ProcessItemProviderAdapterFactory().createAdapter(newItem);
    final ItemProviderAdapter itemProvider = (ItemProviderAdapter) adapter;
    String defaultName = elementNameProvider.getNameFor(newItem);
    // the container of the newItem (where we search for the number max)
    EObject mainContainer;
    if (defaultName == null) {
        defaultName = itemProvider.getText(newItem);
    }

    mainContainer = process;

    if (mainContainer != null) {
        int number = getMaxElements((Element) mainContainer, defaultName);
        number++;
        defaultName += number;
    }
    newItem.setName(defaultName);

    return defaultName;
}