Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding spring model bits

  • Loading branch information...
commit e981ebeb490d162d29b01a5047be6af2377ab2d9 1 parent 6cf02f4
@bfitzpat authored
View
51 ...g.jboss.tools.sca/src/org/jboss/tools/sca/diagram/implementation/SCADiagramAddImplementationFeature.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ *
+ * @author bfitzpat
+ ******************************************************************************/
+package org.jboss.tools.sca.diagram.implementation;
+
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.context.IAddContext;
+import org.eclipse.graphiti.features.impl.AbstractAddShapeFeature;
+import org.eclipse.graphiti.mm.pictograms.ContainerShape;
+import org.eclipse.graphiti.mm.pictograms.PictogramElement;
+import org.eclipse.soa.sca.sca1_1.model.sca.Component;
+import org.eclipse.soa.sca.sca1_1.model.sca.Implementation;
+
+public class SCADiagramAddImplementationFeature extends AbstractAddShapeFeature {
+
+ public SCADiagramAddImplementationFeature( IFeatureProvider fp ) {
+ super(fp);
+ }
+
+ @Override
+ public boolean canAdd(IAddContext context) {
+ // check if user wants to add a component service
+ if (context.getNewObject() instanceof Implementation) {
+ ContainerShape targetContainer = context.getTargetContainer();
+ // check if user wants to add to a component
+ if (getBusinessObjectForPictogramElement(targetContainer) instanceof Component) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public PictogramElement add(IAddContext context) {
+ ContainerShape targetContainer = context.getTargetContainer();
+
+ getDiagramEditor().refresh();
+
+ return targetContainer;
+ }
+
+}
View
83 ...boss.tools.sca/src/org/jboss/tools/sca/diagram/implementation/SCADiagramCreateImplementationFeature.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ *
+ * @author bfitzpat
+ ******************************************************************************/
+package org.jboss.tools.sca.diagram.implementation;
+
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.context.ICreateContext;
+import org.eclipse.graphiti.features.impl.AbstractCreateFeature;
+import org.eclipse.graphiti.mm.pictograms.ContainerShape;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.soa.sca.sca1_1.model.sca.Component;
+import org.eclipse.soa.sca.sca1_1.model.sca.Implementation;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.jboss.tools.sca.ImageProvider;
+import org.jboss.tools.sca.diagram.component.wizards.SCADiagramAddImplementationWizard;
+import org.jboss.tools.switchyard.model.camel.CamelImplementationType;
+import org.jboss.tools.switchyard.model.camel.CamelPackage;
+
+public class SCADiagramCreateImplementationFeature extends AbstractCreateFeature {
+
+ public SCADiagramCreateImplementationFeature(IFeatureProvider fp) {
+ super (fp, "Implementation", "Create implementation");
+ }
+
+ @Override
+ public boolean canCreate(ICreateContext context) {
+ ContainerShape targetContainer = context.getTargetContainer();
+ // check if user wants to add to a component
+ if (targetContainer instanceof Component ||
+ getBusinessObjectForPictogramElement(targetContainer) instanceof Component) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public Object[] create(ICreateContext context) {
+
+ Object o = getBusinessObjectForPictogramElement(context.getTargetContainer());
+ Component component = (Component) o;
+
+ Implementation newImplementation = null;
+ SCADiagramAddImplementationWizard wizard = new SCADiagramAddImplementationWizard();
+ wizard.setDiagram(getDiagram());
+ wizard.setComponent(component);
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ WizardDialog wizDialog = new WizardDialog(shell, wizard);
+ int rtn_code = wizDialog.open();
+ if (rtn_code == Window.OK) {
+ newImplementation = wizard.getImplementation();
+ } else {
+ return EMPTY;
+ }
+
+ if (newImplementation != null) {
+ // do something with it
+ if (newImplementation instanceof CamelImplementationType)
+ component.getImplementationGroup().add(CamelPackage.eINSTANCE.getDocumentRoot_ImplementationCamel(), newImplementation);
+ }
+
+ getDiagramEditor().refresh(context.getTargetContainer());
+
+ // return newly created business object(s)
+ return new Object[] { newImplementation };
+ }
+
+ @Override
+ public String getCreateImageId() {
+ return ImageProvider.IMG_16_IMPLEMENTATION_TYPE;
+ }
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.