package de.uks.beast.editor.provider;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.graphiti.dt.IDiagramTypeProvider;
import org.eclipse.graphiti.features.ICreateConnectionFeature;
import org.eclipse.graphiti.features.ICreateFeature;
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.palette.IPaletteCompartmentEntry;
import org.eclipse.graphiti.palette.impl.ConnectionCreationToolEntry;
import org.eclipse.graphiti.palette.impl.ObjectCreationToolEntry;
import org.eclipse.graphiti.palette.impl.PaletteCompartmentEntry;
import org.eclipse.graphiti.palette.impl.StackEntry;
import org.eclipse.graphiti.tb.DefaultToolBehaviorProvider;

import de.uks.beast.editor.util.Constants.*;
import static de.uks.beast.editor.util.Constants.*;

public class EditorToolBehaviorProvider extends DefaultToolBehaviorProvider {

	public EditorToolBehaviorProvider(IDiagramTypeProvider diagramTypeProvider) {
		super(diagramTypeProvider);
	}

	@Override
	public IPaletteCompartmentEntry[] getPalette() {
		List<IPaletteCompartmentEntry> ret = new ArrayList<IPaletteCompartmentEntry>();

		// add compartments from super class
		IPaletteCompartmentEntry[] superCompartments = super.getPalette();
		for (int i = 0; i < superCompartments.length; i++) {
			ret.add(superCompartments[i]);
		}

		// add new compartment at the end of the existing compartments
		PaletteCompartmentEntry compartmentEntry = new PaletteCompartmentEntry(
				SERVICES.text(), null);
		ret.add(compartmentEntry);

		/* // Example code
		// add new stack entry to new compartment
		StackEntry stackEntry = new StackEntry("EObject", "EObject", null);
		compartmentEntry.addToolEntry(stackEntry);

		// add all create-features to the new stack-entry
		IFeatureProvider featureProvider = getFeatureProvider();
		ICreateFeature[] createFeatures = featureProvider.getCreateFeatures();
		for (ICreateFeature cf : createFeatures) {
			ObjectCreationToolEntry objectCreationToolEntry = new ObjectCreationToolEntry(
					cf.getCreateName(), cf.getCreateDescription(),
					cf.getCreateImageId(), cf.getCreateLargeImageId(), cf);
			stackEntry.addCreationToolEntry(objectCreationToolEntry);
		}

		// add all create-connection-features to the new stack-entry
		ICreateConnectionFeature[] createConnectionFeatures = featureProvider
				.getCreateConnectionFeatures();
		for (ICreateConnectionFeature cf : createConnectionFeatures) {
			ConnectionCreationToolEntry connectionCreationToolEntry = new ConnectionCreationToolEntry(
					cf.getCreateName(), cf.getCreateDescription(),
					cf.getCreateImageId(), cf.getCreateLargeImageId());
			connectionCreationToolEntry.addCreateConnectionFeature(cf);
			stackEntry.addCreationToolEntry(connectionCreationToolEntry);
		}
		*/

		return ret.toArray(new IPaletteCompartmentEntry[ret.size()]);

	}

}

@@ -43,222 +43,113 @@
 ort 
-java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport org.eclipse.graphiti.dt.IDiagramTypeProvider;%0Aimport org.eclipse.graphiti.features.ICreateConnectionFeature;%0Aimport org.eclipse.graphiti.features.ICreateFeature
+static de.uks.beast.editor.util.Constants.SERVICES;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List
 ;%0A
+%0A
 impo
@@ -176,24 +176,22 @@
 iti.
-features.IFeatur
+dt.IDiagramTyp
 ePro
@@ -263,144 +263,8 @@
 ry;%0A
-import org.eclipse.graphiti.palette.impl.ConnectionCreationToolEntry;%0Aimport org.eclipse.graphiti.palette.impl.ObjectCreationToolEntry;%0A
 impo
@@ -329,61 +329,8 @@
 ry;%0A
-import org.eclipse.graphiti.palette.impl.StackEntry;%0A
 impo
@@ -390,106 +390,8 @@
 r;%0A%0A
-import de.uks.beast.editor.util.Constants.*;%0Aimport static de.uks.beast.editor.util.Constants.*;%0A%0A
 publ
@@ -641,16 +641,22 @@
 e() %7B%0A%09%09
+final 
 List%3CIPa
@@ -769,16 +769,22 @@
 class%0A%09%09
+final 
 IPalette
@@ -930,24 +930,27 @@
 nts%5Bi%5D);%0A%09%09%7D
+%0A%09%09
 %0A%0A%09%09// add n

remove unused entries