Skip to content
Snippets Groups Projects
Commit 2622c499 authored by Daniel Ratiu's avatar Daniel Ratiu
Browse files

added also function definitions to the library

refs 1369
parent abba5f84
No related branches found
No related tags found
No related merge requests found
......@@ -47,8 +47,7 @@ import org.fortiss.tooling.kernel.ui.service.IContextMenuService;
* @version $Rev: 18709 $
* @ConQAT.Rating RED Hash:
*/
public abstract class AddElementToLibraryBase<T extends INamedElement> implements
IContextMenuContributor {
public abstract class AddElementToLibraryBase<T extends EObject> implements IContextMenuContributor {
/** {@inheritDoc} */
@Override
......@@ -56,8 +55,7 @@ public abstract class AddElementToLibraryBase<T extends INamedElement> implement
ContextMenuContextProvider contextProvider) {
if(getElementClass().isAssignableFrom(selection.getClass()) &&
!(selection instanceof ILibraryElementReference)) {
INamedElement selectedNamedElement = (INamedElement)selection;
AddToLibraryAction action = new AddToLibraryAction(selectedNamedElement);
AddToLibraryAction action = new AddToLibraryAction(selection);
List<IContributionItem> contributionItems = new ArrayList<IContributionItem>();
contributionItems.add(new ActionContributionItem(action));
return contributionItems;
......@@ -91,10 +89,10 @@ public abstract class AddElementToLibraryBase<T extends INamedElement> implement
private class AddToLibraryAction extends Action {
/** The selected element. */
private INamedElement selectedElement;
private EObject selectedElement;
/** Constructor. */
AddToLibraryAction(INamedElement selectedElement) {
AddToLibraryAction(EObject selectedElement) {
super("Add to Library", ToolingBaseUIActivator.getImageDescriptor("icons/library.png"));
this.selectedElement = selectedElement;
}
......@@ -120,7 +118,7 @@ public abstract class AddElementToLibraryBase<T extends INamedElement> implement
* Checks if this element can be added to the library. Returns null if the element can
* be added to the library and an explanation string otherwise.
*/
protected String checkLibrarySupported(@SuppressWarnings("unused") INamedElement element) {
protected String checkLibrarySupported(@SuppressWarnings("unused") EObject element) {
return null;
}
}
......
......@@ -107,7 +107,7 @@ public class ModelElementLibraryService implements ILibraryService {
/** {@inheritDoc} */
@Override
public void addElementToLibrary(ILibraryPackage pack, INamedElement obj) {
public void addElementToLibrary(ILibraryPackage pack, EObject obj) {
ILibraryService.INSTANCE.addElementToLibrary(pack, obj);
}
......
......@@ -39,7 +39,6 @@ import org.fortiss.tooling.kernel.model.ILibrary;
import org.fortiss.tooling.kernel.model.ILibraryElement;
import org.fortiss.tooling.kernel.model.ILibraryElementReference;
import org.fortiss.tooling.kernel.model.ILibraryPackage;
import org.fortiss.tooling.kernel.model.INamedElement;
import org.fortiss.tooling.kernel.service.ILibraryService;
import org.fortiss.tooling.kernel.service.IPersistencyService;
import org.fortiss.tooling.kernel.service.IPrototypeService;
......@@ -219,14 +218,14 @@ public class LibraryService extends EObjectAwareServiceBase<ILibraryElementHandl
/** {@inheritDoc} */
@Override
public void addElementToLibrary(final ILibraryPackage pack, final INamedElement namedElement) {
public void addElementToLibrary(final ILibraryPackage pack, final EObject namedElement) {
final ITopLevelElement topLevel = IPersistencyService.INSTANCE.getTopLevelElementFor(pack);
topLevel.runAsCommand(new Runnable() {
@Override
public void run() {
INamedElement copy = EcoreUtil.copy(namedElement);
EObject copy = EcoreUtil.copy(namedElement);
Class<? extends INamedElement> clazz = namedElement.getClass();
Class<? extends EObject> clazz = namedElement.getClass();
List<ILibraryElementHandler<EObject>> handlers = getRegisteredHandlers(clazz);
assert handlers.size() == 1;
......
......@@ -25,7 +25,6 @@ import org.fortiss.tooling.kernel.model.ILibrary;
import org.fortiss.tooling.kernel.model.ILibraryElement;
import org.fortiss.tooling.kernel.model.ILibraryElementReference;
import org.fortiss.tooling.kernel.model.ILibraryPackage;
import org.fortiss.tooling.kernel.model.INamedElement;
/**
* The library service provides high level access to the library.
......@@ -72,5 +71,5 @@ public interface ILibraryService {
public void ensureWrappedElementIsUpToDate(final ILibraryElementReference ref);
/** Adds an element to the library in a given library package. */
public void addElementToLibrary(final ILibraryPackage pack, final INamedElement obj);
public void addElementToLibrary(final ILibraryPackage pack, final EObject obj);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment