You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ch...@apache.org on 2006/02/22 00:40:29 UTC
svn commit: r379627 [32/34] - in /incubator/servicemix/trunk: ./ etc/
sandbox/servicemix-wsn-1.2/src/sa/META-INF/
sandbox/servicemix-wsn-1.2/src/su/META-INF/ servicemix-assembly/
servicemix-assembly/src/main/assembly/ servicemix-assembly/src/main/relea...
Modified: incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/AbstractComponentEditPart.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/AbstractComponentEditPart.java?rev=379627&r1=379626&r2=379627&view=diff
==============================================================================
--- incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/AbstractComponentEditPart.java (original)
+++ incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/AbstractComponentEditPart.java Tue Feb 21 15:40:05 2006
@@ -1,281 +1,281 @@
-/*
- * Copyright 2005-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.servicemix.packaging.parts;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.namespace.QName;
-
-import org.apache.servicemix.descriptors.packaging.assets.Artifact;
-import org.apache.servicemix.descriptors.packaging.assets.Assets;
-import org.apache.servicemix.descriptors.packaging.assets.Connection;
-import org.apache.servicemix.descriptors.packaging.assets.Parameter;
-import org.apache.servicemix.packaging.ComponentArtifact;
-import org.apache.servicemix.packaging.model.AbstractComponent;
-import org.apache.servicemix.packaging.model.AbstractConnectableService;
-import org.apache.servicemix.packaging.model.ComponentBased;
-import org.apache.servicemix.packaging.model.ComponentConnection;
-import org.apache.servicemix.packaging.model.Connectable;
-import org.apache.servicemix.packaging.model.ModelElement;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.draw2d.ChopboxAnchor;
-import org.eclipse.draw2d.ConnectionAnchor;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gef.ConnectionEditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.NodeEditPart;
-import org.eclipse.gef.Request;
-
-/**
- * The abstract implementation for a JBI component edit part (GEF)
- *
- * @author <a href="mailto:philip.dodds@gmail.com">Philip Dodds </a>
- *
- */
-public abstract class AbstractComponentEditPart extends
- AbstractGraphicalEditPart2 implements PropertyChangeListener,
- NodeEditPart {
-
- protected ConnectionAnchor anchor;
-
- public void activate() {
- if (!isActive()) {
- super.activate();
- ((ModelElement) getModel()).addPropertyChangeListener(this);
- }
- }
-
- protected void setPropertyFromAssets(Object arg0, Object arg1, Assets assets) {
-
- if (arg0 instanceof Parameter) {
- Parameter parameter = (Parameter) arg0;
- String value = (String) arg1;
-
- for (Parameter parameterValue : assets.getParameter()) {
- if (parameter.getName().equals(parameterValue.getName())) {
- parameterValue.setValue(value);
- return;
- }
- }
-
- Parameter newParameterValue = new Parameter();
- newParameterValue.setName(parameter.getName());
- newParameterValue.setValue(value);
- assets.getParameter().add(newParameterValue);
- } else if (arg0 instanceof Connection) {
- Connection connection = (Connection) arg0;
- QName value = (QName) arg1;
-
- for (Connection resourceReference : assets.getConnection()) {
- if (connection.getName().equals(resourceReference.getName())) {
- resourceReference.setQname(value);
- return;
- }
- }
-
- Connection newReference = new Connection();
- newReference.setName(connection.getName());
- newReference.setQname(value);
- newReference.setType(connection.getType());
- assets.getConnection().add(newReference);
- } else if (arg0 instanceof Artifact) {
- Artifact artifact = (Artifact) arg0;
- IResource resource = (IResource) arg1;
- for (Artifact artifactReference : assets.getArtifact()) {
- if (artifact.getName().equals(artifactReference.getName())) {
- artifactReference.setPath(resource.getProjectRelativePath()
- .toOSString());
- return;
- }
- }
- Artifact newArtifactReference = new Artifact();
- newArtifactReference.setName(artifact.getName());
- newArtifactReference.setPath(resource.getProjectRelativePath()
- .toOSString());
- assets.getArtifact().add(newArtifactReference);
- }
- }
-
- protected Object getPropertyFromAssets(Object arg0, Assets assets) {
- Object result = null;
- if (arg0 instanceof Parameter) {
- Parameter parameter = (Parameter) arg0;
- for (Parameter parameterValue : assets.getParameter()) {
- if (parameter.getName().equals(parameterValue.getName())) {
- result = parameterValue.getValue();
- }
- }
- result = parameter.getValue();
- } else if (arg0 instanceof Connection) {
- Connection connection = (Connection) arg0;
- for (Connection resourceReference : assets.getConnection()) {
- if (connection.getName().equals(resourceReference.getName())) {
- result = resourceReference.getQname();
- }
- }
- } else if (arg0 instanceof Artifact) {
- Artifact artifact = (Artifact) arg0;
- for (Artifact artifactReference : assets.getArtifact()) {
- if (artifact.getName().equals(artifactReference.getName())) {
- return artifactReference.getPath();
- }
- }
- }
- return result;
- }
-
- protected DeploymentDiagramEditPart getDeploymentDiagram() {
- return (DeploymentDiagramEditPart) getRoot().getChildren().get(0);
- }
-
- protected void createEditPolicies() {
- // allow removal of the associated model element
- installEditPolicy(EditPolicy.COMPONENT_ROLE,
- new AbstractComponentEditPolicy());
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, null);
- }
-
- protected IFigure createFigure() {
- IFigure f = createFigureForModel();
- return f;
- }
-
- protected abstract IFigure createFigureForModel();
-
- public void deactivate() {
- if (isActive()) {
- super.deactivate();
- ((ModelElement) getModel()).removePropertyChangeListener(this);
- }
- }
-
- protected ConnectionAnchor getConnectionAnchor() {
- if (anchor == null) {
- anchor = new ChopboxAnchor(getFigure());
- }
- return anchor;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#getModelSourceConnections()
- */
- protected List getModelSourceConnections() {
- if (getModel() instanceof Connectable)
- return ((Connectable) getModel()).getSourceConnections();
- else
- return new ArrayList();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#getModelTargetConnections()
- */
- protected List getModelTargetConnections() {
- if (getModel() instanceof Connectable)
- return ((Connectable) getModel()).getTargetConnections();
- else
- return new ArrayList();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.gef.NodeEditPart#getSourceConnectionAnchor(org.eclipse.gef.ConnectionEditPart)
- */
- public ConnectionAnchor getSourceConnectionAnchor(
- ConnectionEditPart connection) {
- return getConnectionAnchor();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.gef.NodeEditPart#getSourceConnectionAnchor(org.eclipse.gef.Request)
- */
- public ConnectionAnchor getSourceConnectionAnchor(Request request) {
- return getConnectionAnchor();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.gef.NodeEditPart#getTargetConnectionAnchor(org.eclipse.gef.ConnectionEditPart)
- */
- public ConnectionAnchor getTargetConnectionAnchor(
- ConnectionEditPart connection) {
- return getConnectionAnchor();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.gef.NodeEditPart#getTargetConnectionAnchor(org.eclipse.gef.Request)
- */
- public ConnectionAnchor getTargetConnectionAnchor(Request request) {
- return getConnectionAnchor();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent evt) {
- String prop = evt.getPropertyName();
- try {
- if (AbstractConnectableService.LOCATION_PROP.equals(prop)
- || AbstractConnectableService.SERVICENAME_PROP.equals(prop)) {
- refreshVisuals();
- } else if (AbstractConnectableService.SOURCE_CONNECTIONS_PROP
- .equals(prop)) {
- refreshSourceConnections();
- } else if (AbstractConnectableService.TARGET_CONNECTIONS_PROP
- .equals(prop)) {
- refreshTargetConnections();
- }
- } catch (Throwable t) {
- System.out
- .println("Exception while trying to handle property change : "
- + t.getLocalizedMessage());
- t.printStackTrace();
- }
- }
-
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- Rectangle bounds = new Rectangle(((AbstractComponent) getModel())
- .getLocation(), getFigure().getPreferredSize());
- ((GraphicalEditPart) getParent()).setLayoutConstraint(this,
- getFigure(), bounds);
- refreshSourceConnections();
- }
-
- public ComponentArtifact getComponentArtifact() {
- if (getModel() instanceof ComponentBased) {
- return ((ComponentBased) getModel()).getComponentArtifact();
- } else
- return null;
- }
-}
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.packaging.parts;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.servicemix.descriptors.packaging.assets.Artifact;
+import org.apache.servicemix.descriptors.packaging.assets.Assets;
+import org.apache.servicemix.descriptors.packaging.assets.Connection;
+import org.apache.servicemix.descriptors.packaging.assets.Parameter;
+import org.apache.servicemix.packaging.ComponentArtifact;
+import org.apache.servicemix.packaging.model.AbstractComponent;
+import org.apache.servicemix.packaging.model.AbstractConnectableService;
+import org.apache.servicemix.packaging.model.ComponentBased;
+import org.apache.servicemix.packaging.model.ComponentConnection;
+import org.apache.servicemix.packaging.model.Connectable;
+import org.apache.servicemix.packaging.model.ModelElement;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.draw2d.ChopboxAnchor;
+import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.ConnectionEditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.NodeEditPart;
+import org.eclipse.gef.Request;
+
+/**
+ * The abstract implementation for a JBI component edit part (GEF)
+ *
+ * @author <a href="mailto:philip.dodds@gmail.com">Philip Dodds </a>
+ *
+ */
+public abstract class AbstractComponentEditPart extends
+ AbstractGraphicalEditPart2 implements PropertyChangeListener,
+ NodeEditPart {
+
+ protected ConnectionAnchor anchor;
+
+ public void activate() {
+ if (!isActive()) {
+ super.activate();
+ ((ModelElement) getModel()).addPropertyChangeListener(this);
+ }
+ }
+
+ protected void setPropertyFromAssets(Object arg0, Object arg1, Assets assets) {
+
+ if (arg0 instanceof Parameter) {
+ Parameter parameter = (Parameter) arg0;
+ String value = (String) arg1;
+
+ for (Parameter parameterValue : assets.getParameter()) {
+ if (parameter.getName().equals(parameterValue.getName())) {
+ parameterValue.setValue(value);
+ return;
+ }
+ }
+
+ Parameter newParameterValue = new Parameter();
+ newParameterValue.setName(parameter.getName());
+ newParameterValue.setValue(value);
+ assets.getParameter().add(newParameterValue);
+ } else if (arg0 instanceof Connection) {
+ Connection connection = (Connection) arg0;
+ QName value = (QName) arg1;
+
+ for (Connection resourceReference : assets.getConnection()) {
+ if (connection.getName().equals(resourceReference.getName())) {
+ resourceReference.setQname(value);
+ return;
+ }
+ }
+
+ Connection newReference = new Connection();
+ newReference.setName(connection.getName());
+ newReference.setQname(value);
+ newReference.setType(connection.getType());
+ assets.getConnection().add(newReference);
+ } else if (arg0 instanceof Artifact) {
+ Artifact artifact = (Artifact) arg0;
+ IResource resource = (IResource) arg1;
+ for (Artifact artifactReference : assets.getArtifact()) {
+ if (artifact.getName().equals(artifactReference.getName())) {
+ artifactReference.setPath(resource.getProjectRelativePath()
+ .toOSString());
+ return;
+ }
+ }
+ Artifact newArtifactReference = new Artifact();
+ newArtifactReference.setName(artifact.getName());
+ newArtifactReference.setPath(resource.getProjectRelativePath()
+ .toOSString());
+ assets.getArtifact().add(newArtifactReference);
+ }
+ }
+
+ protected Object getPropertyFromAssets(Object arg0, Assets assets) {
+ Object result = null;
+ if (arg0 instanceof Parameter) {
+ Parameter parameter = (Parameter) arg0;
+ for (Parameter parameterValue : assets.getParameter()) {
+ if (parameter.getName().equals(parameterValue.getName())) {
+ result = parameterValue.getValue();
+ }
+ }
+ result = parameter.getValue();
+ } else if (arg0 instanceof Connection) {
+ Connection connection = (Connection) arg0;
+ for (Connection resourceReference : assets.getConnection()) {
+ if (connection.getName().equals(resourceReference.getName())) {
+ result = resourceReference.getQname();
+ }
+ }
+ } else if (arg0 instanceof Artifact) {
+ Artifact artifact = (Artifact) arg0;
+ for (Artifact artifactReference : assets.getArtifact()) {
+ if (artifact.getName().equals(artifactReference.getName())) {
+ return artifactReference.getPath();
+ }
+ }
+ }
+ return result;
+ }
+
+ protected DeploymentDiagramEditPart getDeploymentDiagram() {
+ return (DeploymentDiagramEditPart) getRoot().getChildren().get(0);
+ }
+
+ protected void createEditPolicies() {
+ // allow removal of the associated model element
+ installEditPolicy(EditPolicy.COMPONENT_ROLE,
+ new AbstractComponentEditPolicy());
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, null);
+ }
+
+ protected IFigure createFigure() {
+ IFigure f = createFigureForModel();
+ return f;
+ }
+
+ protected abstract IFigure createFigureForModel();
+
+ public void deactivate() {
+ if (isActive()) {
+ super.deactivate();
+ ((ModelElement) getModel()).removePropertyChangeListener(this);
+ }
+ }
+
+ protected ConnectionAnchor getConnectionAnchor() {
+ if (anchor == null) {
+ anchor = new ChopboxAnchor(getFigure());
+ }
+ return anchor;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#getModelSourceConnections()
+ */
+ protected List getModelSourceConnections() {
+ if (getModel() instanceof Connectable)
+ return ((Connectable) getModel()).getSourceConnections();
+ else
+ return new ArrayList();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#getModelTargetConnections()
+ */
+ protected List getModelTargetConnections() {
+ if (getModel() instanceof Connectable)
+ return ((Connectable) getModel()).getTargetConnections();
+ else
+ return new ArrayList();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gef.NodeEditPart#getSourceConnectionAnchor(org.eclipse.gef.ConnectionEditPart)
+ */
+ public ConnectionAnchor getSourceConnectionAnchor(
+ ConnectionEditPart connection) {
+ return getConnectionAnchor();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gef.NodeEditPart#getSourceConnectionAnchor(org.eclipse.gef.Request)
+ */
+ public ConnectionAnchor getSourceConnectionAnchor(Request request) {
+ return getConnectionAnchor();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gef.NodeEditPart#getTargetConnectionAnchor(org.eclipse.gef.ConnectionEditPart)
+ */
+ public ConnectionAnchor getTargetConnectionAnchor(
+ ConnectionEditPart connection) {
+ return getConnectionAnchor();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gef.NodeEditPart#getTargetConnectionAnchor(org.eclipse.gef.Request)
+ */
+ public ConnectionAnchor getTargetConnectionAnchor(Request request) {
+ return getConnectionAnchor();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent evt) {
+ String prop = evt.getPropertyName();
+ try {
+ if (AbstractConnectableService.LOCATION_PROP.equals(prop)
+ || AbstractConnectableService.SERVICENAME_PROP.equals(prop)) {
+ refreshVisuals();
+ } else if (AbstractConnectableService.SOURCE_CONNECTIONS_PROP
+ .equals(prop)) {
+ refreshSourceConnections();
+ } else if (AbstractConnectableService.TARGET_CONNECTIONS_PROP
+ .equals(prop)) {
+ refreshTargetConnections();
+ }
+ } catch (Throwable t) {
+ System.out
+ .println("Exception while trying to handle property change : "
+ + t.getLocalizedMessage());
+ t.printStackTrace();
+ }
+ }
+
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ Rectangle bounds = new Rectangle(((AbstractComponent) getModel())
+ .getLocation(), getFigure().getPreferredSize());
+ ((GraphicalEditPart) getParent()).setLayoutConstraint(this,
+ getFigure(), bounds);
+ refreshSourceConnections();
+ }
+
+ public ComponentArtifact getComponentArtifact() {
+ if (getModel() instanceof ComponentBased) {
+ return ((ComponentBased) getModel()).getComponentArtifact();
+ } else
+ return null;
+ }
+}
Propchange: incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/AbstractComponentEditPart.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/AbstractComponentEditPolicy.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/AbstractComponentEditPolicy.java?rev=379627&r1=379626&r2=379627&view=diff
==============================================================================
--- incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/AbstractComponentEditPolicy.java (original)
+++ incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/AbstractComponentEditPolicy.java Tue Feb 21 15:40:05 2006
@@ -1,46 +1,46 @@
-/*
- * Copyright 2005-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.servicemix.packaging.parts;
-
-import org.apache.servicemix.packaging.model.AbstractComponent;
-import org.apache.servicemix.packaging.model.DeploymentDiagram;
-import org.apache.servicemix.packaging.model.ServiceAssembly;
-import org.apache.servicemix.packaging.model.ServiceUnit;
-import org.apache.servicemix.packaging.model.commands.ComponentDeleteCommand;
-import org.apache.servicemix.packaging.model.commands.ServiceUnitDeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.editpolicies.ComponentEditPolicy;
-import org.eclipse.gef.requests.GroupRequest;
-
-/**
- * The abstract edit policy for a JBI component (GEF)
- *
- * @author <a href="mailto:philip.dodds@gmail.com">Philip Dodds </a>
- *
- */
-public class AbstractComponentEditPolicy extends ComponentEditPolicy {
-
- protected Command createDeleteCommand(GroupRequest deleteRequest) {
- Object parent = getHost().getParent().getModel();
- Object child = getHost().getModel();
- if (parent instanceof DeploymentDiagram
- && child instanceof AbstractComponent) {
- return new ComponentDeleteCommand((DeploymentDiagram) parent,
- (AbstractComponent) child);
- }
- return super.createDeleteCommand(deleteRequest);
- }
-}
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.packaging.parts;
+
+import org.apache.servicemix.packaging.model.AbstractComponent;
+import org.apache.servicemix.packaging.model.DeploymentDiagram;
+import org.apache.servicemix.packaging.model.ServiceAssembly;
+import org.apache.servicemix.packaging.model.ServiceUnit;
+import org.apache.servicemix.packaging.model.commands.ComponentDeleteCommand;
+import org.apache.servicemix.packaging.model.commands.ServiceUnitDeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.ComponentEditPolicy;
+import org.eclipse.gef.requests.GroupRequest;
+
+/**
+ * The abstract edit policy for a JBI component (GEF)
+ *
+ * @author <a href="mailto:philip.dodds@gmail.com">Philip Dodds </a>
+ *
+ */
+public class AbstractComponentEditPolicy extends ComponentEditPolicy {
+
+ protected Command createDeleteCommand(GroupRequest deleteRequest) {
+ Object parent = getHost().getParent().getModel();
+ Object child = getHost().getModel();
+ if (parent instanceof DeploymentDiagram
+ && child instanceof AbstractComponent) {
+ return new ComponentDeleteCommand((DeploymentDiagram) parent,
+ (AbstractComponent) child);
+ }
+ return super.createDeleteCommand(deleteRequest);
+ }
+}
Propchange: incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/AbstractComponentEditPolicy.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/AbstractGraphicalEditPart2.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/AbstractGraphicalEditPart2.java?rev=379627&r1=379626&r2=379627&view=diff
==============================================================================
--- incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/AbstractGraphicalEditPart2.java (original)
+++ incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/AbstractGraphicalEditPart2.java Tue Feb 21 15:40:05 2006
@@ -1,22 +1,22 @@
-package org.apache.servicemix.packaging.parts;
-
-import java.util.List;
-
-import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-
-public abstract class AbstractGraphicalEditPart2 extends
- AbstractGraphicalEditPart {
-
- public IPropertyDescriptor[] getArray(List<IPropertyDescriptor> descriptors) {
- IPropertyDescriptor[] array = new IPropertyDescriptor[descriptors
- .size()];
- int pos = 0;
- for (IPropertyDescriptor descriptor : descriptors) {
- array[pos] = descriptor;
- pos++;
- }
- return array;
- }
-
-}
+package org.apache.servicemix.packaging.parts;
+
+import java.util.List;
+
+import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+
+public abstract class AbstractGraphicalEditPart2 extends
+ AbstractGraphicalEditPart {
+
+ public IPropertyDescriptor[] getArray(List<IPropertyDescriptor> descriptors) {
+ IPropertyDescriptor[] array = new IPropertyDescriptor[descriptors
+ .size()];
+ int pos = 0;
+ for (IPropertyDescriptor descriptor : descriptors) {
+ array[pos] = descriptor;
+ pos++;
+ }
+ return array;
+ }
+
+}
Propchange: incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/AbstractGraphicalEditPart2.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/BindingComponentEditPart.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/BindingComponentEditPart.java?rev=379627&r1=379626&r2=379627&view=diff
==============================================================================
--- incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/BindingComponentEditPart.java (original)
+++ incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/BindingComponentEditPart.java Tue Feb 21 15:40:05 2006
@@ -1,105 +1,105 @@
-/*
- * Copyright 2005-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.servicemix.packaging.parts;
-
-import java.util.LinkedList;
-
-import org.apache.servicemix.descriptors.packaging.assets.Components.Component;
-import org.apache.servicemix.packaging.figure.BindingComponentFigure;
-import org.apache.servicemix.packaging.model.AbstractComponent;
-import org.apache.servicemix.packaging.model.BindingComponent;
-import org.apache.servicemix.packaging.model.ComponentBased;
-import org.apache.servicemix.packaging.parts.descriptors.AssetDescriptorFactory;
-import org.apache.servicemix.packaging.parts.descriptors.QNamePropertyDescriptor;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-
-/**
- * The GEF Edit Part for a Binding Component
- *
- * @author <a href="mailto:philip.dodds@gmail.com">Philip Dodds </a>
- *
- */
-public class BindingComponentEditPart extends AbstractComponentEditPart
- implements IPropertySource {
-
- private LinkedList<IPropertyDescriptor> descriptors;
-
- @Override
- protected IFigure createFigureForModel() {
- BindingComponentFigure newFigure = new BindingComponentFigure(
- (BindingComponent) getModel());
- return newFigure;
- }
-
- private Component getComponentDescriptor() {
- Component component = null;
- if (getModel() instanceof ComponentBased) {
- for (Component componentIter : ((ComponentBased) getModel())
- .getComponentArtifact().getComponents().getComponent()) {
- if (componentIter.getName().equals(
- ((ComponentBased) getModel()).getComponentName())) {
- component = componentIter;
- }
- }
- }
- return component;
-
- }
-
- public Object getEditableValue() {
- return this;
- }
-
- public IPropertyDescriptor[] getPropertyDescriptors() {
- if (descriptors == null) {
- descriptors = new LinkedList<IPropertyDescriptor>();
- if (getComponentDescriptor().getAssets() != null) {
- descriptors.addAll(AssetDescriptorFactory.getDescriptors(
- getComponentDescriptor().getAssets(),
- getDeploymentDiagram()));
- }
- }
- return getArray(descriptors);
- }
-
- public Object getPropertyValue(Object arg0) {
- return getPropertyFromAssets(arg0, ((BindingComponent) getModel())
- .getStoredAssets());
- }
-
- public boolean isPropertySet(Object arg0) {
- return true;
- }
-
- @Override
- protected void refreshVisuals() {
- ((BindingComponentFigure) getFigure()).refresh();
- super.refreshVisuals();
- }
-
- public void resetPropertyValue(Object arg0) {
-
- }
-
- public void setPropertyValue(Object arg0, Object arg1) {
- setPropertyFromAssets(arg0, arg1, ((BindingComponent) getModel())
- .getStoredAssets());
- ((AbstractComponent) getModel()).updated();
- }
-
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.packaging.parts;
+
+import java.util.LinkedList;
+
+import org.apache.servicemix.descriptors.packaging.assets.Components.Component;
+import org.apache.servicemix.packaging.figure.BindingComponentFigure;
+import org.apache.servicemix.packaging.model.AbstractComponent;
+import org.apache.servicemix.packaging.model.BindingComponent;
+import org.apache.servicemix.packaging.model.ComponentBased;
+import org.apache.servicemix.packaging.parts.descriptors.AssetDescriptorFactory;
+import org.apache.servicemix.packaging.parts.descriptors.QNamePropertyDescriptor;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource;
+
+/**
+ * The GEF Edit Part for a Binding Component
+ *
+ * @author <a href="mailto:philip.dodds@gmail.com">Philip Dodds </a>
+ *
+ */
+public class BindingComponentEditPart extends AbstractComponentEditPart
+ implements IPropertySource {
+
+ private LinkedList<IPropertyDescriptor> descriptors;
+
+ @Override
+ protected IFigure createFigureForModel() {
+ BindingComponentFigure newFigure = new BindingComponentFigure(
+ (BindingComponent) getModel());
+ return newFigure;
+ }
+
+ private Component getComponentDescriptor() {
+ Component component = null;
+ if (getModel() instanceof ComponentBased) {
+ for (Component componentIter : ((ComponentBased) getModel())
+ .getComponentArtifact().getComponents().getComponent()) {
+ if (componentIter.getName().equals(
+ ((ComponentBased) getModel()).getComponentName())) {
+ component = componentIter;
+ }
+ }
+ }
+ return component;
+
+ }
+
+ public Object getEditableValue() {
+ return this;
+ }
+
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ if (descriptors == null) {
+ descriptors = new LinkedList<IPropertyDescriptor>();
+ if (getComponentDescriptor().getAssets() != null) {
+ descriptors.addAll(AssetDescriptorFactory.getDescriptors(
+ getComponentDescriptor().getAssets(),
+ getDeploymentDiagram()));
+ }
+ }
+ return getArray(descriptors);
+ }
+
+ public Object getPropertyValue(Object arg0) {
+ return getPropertyFromAssets(arg0, ((BindingComponent) getModel())
+ .getStoredAssets());
+ }
+
+ public boolean isPropertySet(Object arg0) {
+ return true;
+ }
+
+ @Override
+ protected void refreshVisuals() {
+ ((BindingComponentFigure) getFigure()).refresh();
+ super.refreshVisuals();
+ }
+
+ public void resetPropertyValue(Object arg0) {
+
+ }
+
+ public void setPropertyValue(Object arg0, Object arg1) {
+ setPropertyFromAssets(arg0, arg1, ((BindingComponent) getModel())
+ .getStoredAssets());
+ ((AbstractComponent) getModel()).updated();
+ }
+
}
Propchange: incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/BindingComponentEditPart.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/ConnectionEditPart.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/ConnectionEditPart.java?rev=379627&r1=379626&r2=379627&view=diff
==============================================================================
--- incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/ConnectionEditPart.java (original)
+++ incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/ConnectionEditPart.java Tue Feb 21 15:40:05 2006
@@ -1,82 +1,82 @@
-/*
- * Copyright 2005-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.servicemix.packaging.parts;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-
-import org.apache.servicemix.packaging.model.ComponentConnection;
-import org.apache.servicemix.packaging.model.ModelElement;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.PolygonDecoration;
-import org.eclipse.draw2d.PolylineConnection;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.editparts.AbstractConnectionEditPart;
-import org.eclipse.gef.editpolicies.NonResizableEditPolicy;
-
-/**
- * The GEF edit part for a connection
- *
- * @author <a href="mailto:philip.dodds@gmail.com">Philip Dodds </a>
- *
- */
-public class ConnectionEditPart extends AbstractConnectionEditPart implements
- PropertyChangeListener {
-
- /**
- * Upon activation, attach to the model element as a property change
- * listener.
- */
- public void activate() {
- if (!isActive()) {
- super.activate();
- ((ModelElement) getModel()).addPropertyChangeListener(this);
- }
- }
-
- protected void createEditPolicies() {
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE,
- new NonResizableEditPolicy());
- }
-
- protected IFigure createFigure() {
- PolylineConnection connection = (PolylineConnection) super
- .createFigure();
- connection.setTargetDecoration(new PolygonDecoration());
- connection.setLineStyle(getCastedModel().getLineStyle());
- return connection;
- }
-
- public void deactivate() {
- if (isActive()) {
- super.deactivate();
- ((ModelElement) getModel()).removePropertyChangeListener(this);
- }
- }
-
- private ComponentConnection getCastedModel() {
- return (ComponentConnection) getModel();
- }
-
- public void propertyChange(PropertyChangeEvent event) {
- String property = event.getPropertyName();
- if (ComponentConnection.LINESTYLE_PROP.equals(property)) {
- ((PolylineConnection) getFigure()).setLineStyle(getCastedModel()
- .getLineStyle());
- }
- }
-
-}
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.packaging.parts;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import org.apache.servicemix.packaging.model.ComponentConnection;
+import org.apache.servicemix.packaging.model.ModelElement;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.PolygonDecoration;
+import org.eclipse.draw2d.PolylineConnection;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.editparts.AbstractConnectionEditPart;
+import org.eclipse.gef.editpolicies.NonResizableEditPolicy;
+
+/**
+ * The GEF edit part for a connection
+ *
+ * @author <a href="mailto:philip.dodds@gmail.com">Philip Dodds </a>
+ *
+ */
+public class ConnectionEditPart extends AbstractConnectionEditPart implements
+ PropertyChangeListener {
+
+ /**
+ * Upon activation, attach to the model element as a property change
+ * listener.
+ */
+ public void activate() {
+ if (!isActive()) {
+ super.activate();
+ ((ModelElement) getModel()).addPropertyChangeListener(this);
+ }
+ }
+
+ protected void createEditPolicies() {
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE,
+ new NonResizableEditPolicy());
+ }
+
+ protected IFigure createFigure() {
+ PolylineConnection connection = (PolylineConnection) super
+ .createFigure();
+ connection.setTargetDecoration(new PolygonDecoration());
+ connection.setLineStyle(getCastedModel().getLineStyle());
+ return connection;
+ }
+
+ public void deactivate() {
+ if (isActive()) {
+ super.deactivate();
+ ((ModelElement) getModel()).removePropertyChangeListener(this);
+ }
+ }
+
+ private ComponentConnection getCastedModel() {
+ return (ComponentConnection) getModel();
+ }
+
+ public void propertyChange(PropertyChangeEvent event) {
+ String property = event.getPropertyName();
+ if (ComponentConnection.LINESTYLE_PROP.equals(property)) {
+ ((PolylineConnection) getFigure()).setLineStyle(getCastedModel()
+ .getLineStyle());
+ }
+ }
+
+}
Propchange: incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/ConnectionEditPart.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/DeploymentDiagramEditPart.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/DeploymentDiagramEditPart.java?rev=379627&r1=379626&r2=379627&view=diff
==============================================================================
--- incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/DeploymentDiagramEditPart.java (original)
+++ incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/DeploymentDiagramEditPart.java Tue Feb 21 15:40:05 2006
@@ -1,206 +1,206 @@
-/*
- * Copyright 2005-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.servicemix.packaging.parts;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.servicemix.packaging.model.AbstractComponent;
-import org.apache.servicemix.packaging.model.AbstractConnectableService;
-import org.apache.servicemix.packaging.model.DeploymentDiagram;
-import org.apache.servicemix.packaging.model.ModelElement;
-import org.apache.servicemix.packaging.model.commands.ComponentCreateCommand;
-import org.apache.servicemix.packaging.model.commands.ComponentSetConstraintCommand;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.draw2d.ConnectionLayer;
-import org.eclipse.draw2d.Figure;
-import org.eclipse.draw2d.FreeformLayer;
-import org.eclipse.draw2d.FreeformLayout;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.MarginBorder;
-import org.eclipse.draw2d.ShortestPathConnectionRouter;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.LayerConstants;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.editpolicies.RootComponentEditPolicy;
-import org.eclipse.gef.editpolicies.XYLayoutEditPolicy;
-import org.eclipse.gef.requests.ChangeBoundsRequest;
-import org.eclipse.gef.requests.CreateRequest;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-
-/**
- * The GEF edit part for a deployment diagram
- *
- * @author <a href="mailto:philip.dodds@gmail.com">Philip Dodds </a>
- *
- */
-public class DeploymentDiagramEditPart extends AbstractGraphicalEditPart2
- implements PropertyChangeListener, IPropertySource {
-
- private static final String DEPLOY_PATH = "deployPath";
-
- private static final String INSTALL_PATH = "installPath";
-
- private static class ShapesXYLayoutEditPolicy extends XYLayoutEditPolicy {
-
- protected Command createAddCommand(EditPart child, Object constraint) {
- // not used
- return null;
- }
-
- protected Command createChangeConstraintCommand(
- ChangeBoundsRequest request, EditPart child, Object constraint) {
- if (child instanceof AbstractComponentEditPart
- && constraint instanceof Rectangle) {
- return new ComponentSetConstraintCommand(
- (AbstractComponent) ((AbstractComponentEditPart) child)
- .getModel(), request, (Rectangle) constraint);
- }
- return super.createChangeConstraintCommand(request, child,
- constraint);
- }
-
- protected Command createChangeConstraintCommand(EditPart child,
- Object constraint) {
- // not used
- return null;
- }
-
- protected Command getCreateCommand(CreateRequest request) {
- Object childClass = request.getNewObjectType();
- if (childClass instanceof AbstractConnectableService) {
- return new ComponentCreateCommand((AbstractComponent) request
- .getNewObject(), (DeploymentDiagram) getHost()
- .getModel(), (Rectangle) getConstraintFor(request));
- }
- return null;
- }
-
- protected Command getDeleteDependantCommand(Request request) {
- // not used
- return null;
- }
-
- }
-
- private IProject project;
-
- public DeploymentDiagramEditPart(IProject owningProject) {
- this.project = owningProject;
- }
-
- public void activate() {
- if (!isActive()) {
- super.activate();
- ((ModelElement) getModel()).addPropertyChangeListener(this);
- }
- }
-
- protected void createEditPolicies() {
- installEditPolicy(EditPolicy.COMPONENT_ROLE,
- new RootComponentEditPolicy());
- installEditPolicy(EditPolicy.LAYOUT_ROLE,
- new ShapesXYLayoutEditPolicy());
- }
-
- protected IFigure createFigure() {
- Figure f = new FreeformLayer();
- f.setBorder(new MarginBorder(3));
- f.setLayoutManager(new FreeformLayout());
-
- ConnectionLayer connLayer = (ConnectionLayer) getLayer(LayerConstants.CONNECTION_LAYER);
- connLayer.setConnectionRouter(new ShortestPathConnectionRouter(f));
-
- return f;
- }
-
- public void deactivate() {
- if (isActive()) {
- super.deactivate();
- ((ModelElement) getModel()).removePropertyChangeListener(this);
- }
- }
-
- private DeploymentDiagram getCastedModel() {
- return (DeploymentDiagram) getModel();
- }
-
- public Object getEditableValue() {
- // TODO Auto-generated method stub
- return null;
- }
-
- protected List getModelChildren() {
- return getCastedModel().getChildren();
- }
-
- public IProject getProject() {
- return project;
- }
-
- public IPropertyDescriptor[] getPropertyDescriptors() {
- List<IPropertyDescriptor> descriptors = new ArrayList<IPropertyDescriptor>();
- descriptors
- .add(new TextPropertyDescriptor(INSTALL_PATH, "Install path"));
- descriptors.add(new TextPropertyDescriptor(DEPLOY_PATH, "Deploy path"));
- return getArray(descriptors);
- }
-
- public Object getPropertyValue(Object arg0) {
- if (DEPLOY_PATH.equals(arg0))
- return ((DeploymentDiagram) getModel()).getDeployPath();
- else if (INSTALL_PATH.equals(arg0))
- return ((DeploymentDiagram) getModel()).getInstallPath();
- return null;
- }
-
- public boolean isPropertySet(Object arg0) {
- // TODO Auto-generated method stub
- return false;
- }
-
- public void propertyChange(PropertyChangeEvent evt) {
- String prop = evt.getPropertyName();
- if (DeploymentDiagram.CHILD_ADDED_PROP.equals(prop)
- || DeploymentDiagram.CHILD_REMOVED_PROP.equals(prop)) {
- refreshChildren();
- }
- }
-
- public void resetPropertyValue(Object arg0) {
- // TODO Auto-generated method stub
-
- }
-
- public void setProject(IProject project) {
- this.project = project;
- }
-
- public void setPropertyValue(Object arg0, Object arg1) {
- if (DEPLOY_PATH.equals(arg0))
- ((DeploymentDiagram) getModel()).setDeployPath((String) arg1);
- else if (INSTALL_PATH.equals(arg0))
- ((DeploymentDiagram) getModel()).setInstallPath((String) arg1);
- }
-
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.packaging.parts;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.servicemix.packaging.model.AbstractComponent;
+import org.apache.servicemix.packaging.model.AbstractConnectableService;
+import org.apache.servicemix.packaging.model.DeploymentDiagram;
+import org.apache.servicemix.packaging.model.ModelElement;
+import org.apache.servicemix.packaging.model.commands.ComponentCreateCommand;
+import org.apache.servicemix.packaging.model.commands.ComponentSetConstraintCommand;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.draw2d.ConnectionLayer;
+import org.eclipse.draw2d.Figure;
+import org.eclipse.draw2d.FreeformLayer;
+import org.eclipse.draw2d.FreeformLayout;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.MarginBorder;
+import org.eclipse.draw2d.ShortestPathConnectionRouter;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.LayerConstants;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.RootComponentEditPolicy;
+import org.eclipse.gef.editpolicies.XYLayoutEditPolicy;
+import org.eclipse.gef.requests.ChangeBoundsRequest;
+import org.eclipse.gef.requests.CreateRequest;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;
+
+/**
+ * The GEF edit part for a deployment diagram
+ *
+ * @author <a href="mailto:philip.dodds@gmail.com">Philip Dodds </a>
+ *
+ */
+public class DeploymentDiagramEditPart extends AbstractGraphicalEditPart2
+ implements PropertyChangeListener, IPropertySource {
+
+ private static final String DEPLOY_PATH = "deployPath";
+
+ private static final String INSTALL_PATH = "installPath";
+
+ private static class ShapesXYLayoutEditPolicy extends XYLayoutEditPolicy {
+
+ protected Command createAddCommand(EditPart child, Object constraint) {
+ // not used
+ return null;
+ }
+
+ protected Command createChangeConstraintCommand(
+ ChangeBoundsRequest request, EditPart child, Object constraint) {
+ if (child instanceof AbstractComponentEditPart
+ && constraint instanceof Rectangle) {
+ return new ComponentSetConstraintCommand(
+ (AbstractComponent) ((AbstractComponentEditPart) child)
+ .getModel(), request, (Rectangle) constraint);
+ }
+ return super.createChangeConstraintCommand(request, child,
+ constraint);
+ }
+
+ protected Command createChangeConstraintCommand(EditPart child,
+ Object constraint) {
+ // not used
+ return null;
+ }
+
+ protected Command getCreateCommand(CreateRequest request) {
+ Object childClass = request.getNewObjectType();
+ if (childClass instanceof AbstractConnectableService) {
+ return new ComponentCreateCommand((AbstractComponent) request
+ .getNewObject(), (DeploymentDiagram) getHost()
+ .getModel(), (Rectangle) getConstraintFor(request));
+ }
+ return null;
+ }
+
+ protected Command getDeleteDependantCommand(Request request) {
+ // not used
+ return null;
+ }
+
+ }
+
+ private IProject project;
+
+ public DeploymentDiagramEditPart(IProject owningProject) {
+ this.project = owningProject;
+ }
+
+ public void activate() {
+ if (!isActive()) {
+ super.activate();
+ ((ModelElement) getModel()).addPropertyChangeListener(this);
+ }
+ }
+
+ protected void createEditPolicies() {
+ installEditPolicy(EditPolicy.COMPONENT_ROLE,
+ new RootComponentEditPolicy());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE,
+ new ShapesXYLayoutEditPolicy());
+ }
+
+ protected IFigure createFigure() {
+ Figure f = new FreeformLayer();
+ f.setBorder(new MarginBorder(3));
+ f.setLayoutManager(new FreeformLayout());
+
+ ConnectionLayer connLayer = (ConnectionLayer) getLayer(LayerConstants.CONNECTION_LAYER);
+ connLayer.setConnectionRouter(new ShortestPathConnectionRouter(f));
+
+ return f;
+ }
+
+ public void deactivate() {
+ if (isActive()) {
+ super.deactivate();
+ ((ModelElement) getModel()).removePropertyChangeListener(this);
+ }
+ }
+
+ private DeploymentDiagram getCastedModel() {
+ return (DeploymentDiagram) getModel();
+ }
+
+ public Object getEditableValue() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ protected List getModelChildren() {
+ return getCastedModel().getChildren();
+ }
+
+ public IProject getProject() {
+ return project;
+ }
+
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ List<IPropertyDescriptor> descriptors = new ArrayList<IPropertyDescriptor>();
+ descriptors
+ .add(new TextPropertyDescriptor(INSTALL_PATH, "Install path"));
+ descriptors.add(new TextPropertyDescriptor(DEPLOY_PATH, "Deploy path"));
+ return getArray(descriptors);
+ }
+
+ public Object getPropertyValue(Object arg0) {
+ if (DEPLOY_PATH.equals(arg0))
+ return ((DeploymentDiagram) getModel()).getDeployPath();
+ else if (INSTALL_PATH.equals(arg0))
+ return ((DeploymentDiagram) getModel()).getInstallPath();
+ return null;
+ }
+
+ public boolean isPropertySet(Object arg0) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void propertyChange(PropertyChangeEvent evt) {
+ String prop = evt.getPropertyName();
+ if (DeploymentDiagram.CHILD_ADDED_PROP.equals(prop)
+ || DeploymentDiagram.CHILD_REMOVED_PROP.equals(prop)) {
+ refreshChildren();
+ }
+ }
+
+ public void resetPropertyValue(Object arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setProject(IProject project) {
+ this.project = project;
+ }
+
+ public void setPropertyValue(Object arg0, Object arg1) {
+ if (DEPLOY_PATH.equals(arg0))
+ ((DeploymentDiagram) getModel()).setDeployPath((String) arg1);
+ else if (INSTALL_PATH.equals(arg0))
+ ((DeploymentDiagram) getModel()).setInstallPath((String) arg1);
+ }
+
}
Propchange: incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/DeploymentDiagramEditPart.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/DeploymentEditPartFactory.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/DeploymentEditPartFactory.java?rev=379627&r1=379626&r2=379627&view=diff
==============================================================================
--- incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/DeploymentEditPartFactory.java (original)
+++ incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/DeploymentEditPartFactory.java Tue Feb 21 15:40:05 2006
@@ -1,71 +1,71 @@
-/*
- * Copyright 2005-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.servicemix.packaging.parts;
-
-import org.apache.servicemix.packaging.model.BindingComponent;
-import org.apache.servicemix.packaging.model.ComponentConnection;
-import org.apache.servicemix.packaging.model.DeploymentDiagram;
-import org.apache.servicemix.packaging.model.ServiceAssembly;
-import org.apache.servicemix.packaging.model.ServiceUnit;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPartFactory;
-
-/**
- * The Edit Part Factory for GEF to create the Edit Parts based on the model
- *
- * @author <a href="mailto:philip.dodds@gmail.com">Philip Dodds </a>
- *
- */
-public class DeploymentEditPartFactory implements EditPartFactory {
-
- private IProject project;
-
- public EditPart createEditPart(EditPart context, Object modelElement) {
- EditPart newEditPart = getInstance(modelElement);
- if (newEditPart != null)
- newEditPart.setModel(modelElement);
- return newEditPart;
- }
-
- private EditPart getInstance(Object modelElement) {
- if (modelElement instanceof DeploymentDiagram) {
- return new DeploymentDiagramEditPart(project);
- }
- if (modelElement instanceof BindingComponent) {
- return new BindingComponentEditPart();
- }
- if (modelElement instanceof ServiceAssembly) {
- return new ServiceAssemblyEditPart();
- }
- if (modelElement instanceof ServiceUnit) {
- return new ServiceUnitEditPart();
- }
- if (modelElement instanceof ComponentConnection) {
- return new ConnectionEditPart();
- }
- return null;
- }
-
- public IProject getProject() {
- return project;
- }
-
- public void setProject(IProject project) {
- this.project = project;
- }
-
-}
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.packaging.parts;
+
+import org.apache.servicemix.packaging.model.BindingComponent;
+import org.apache.servicemix.packaging.model.ComponentConnection;
+import org.apache.servicemix.packaging.model.DeploymentDiagram;
+import org.apache.servicemix.packaging.model.ServiceAssembly;
+import org.apache.servicemix.packaging.model.ServiceUnit;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPartFactory;
+
+/**
+ * The Edit Part Factory for GEF to create the Edit Parts based on the model
+ *
+ * @author <a href="mailto:philip.dodds@gmail.com">Philip Dodds </a>
+ *
+ */
+public class DeploymentEditPartFactory implements EditPartFactory {
+
+ private IProject project;
+
+ public EditPart createEditPart(EditPart context, Object modelElement) {
+ EditPart newEditPart = getInstance(modelElement);
+ if (newEditPart != null)
+ newEditPart.setModel(modelElement);
+ return newEditPart;
+ }
+
+ private EditPart getInstance(Object modelElement) {
+ if (modelElement instanceof DeploymentDiagram) {
+ return new DeploymentDiagramEditPart(project);
+ }
+ if (modelElement instanceof BindingComponent) {
+ return new BindingComponentEditPart();
+ }
+ if (modelElement instanceof ServiceAssembly) {
+ return new ServiceAssemblyEditPart();
+ }
+ if (modelElement instanceof ServiceUnit) {
+ return new ServiceUnitEditPart();
+ }
+ if (modelElement instanceof ComponentConnection) {
+ return new ConnectionEditPart();
+ }
+ return null;
+ }
+
+ public IProject getProject() {
+ return project;
+ }
+
+ public void setProject(IProject project) {
+ this.project = project;
+ }
+
+}
Propchange: incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/DeploymentEditPartFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/DeploymentTreeEditPartFactory.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/DeploymentTreeEditPartFactory.java?rev=379627&r1=379626&r2=379627&view=diff
==============================================================================
--- incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/DeploymentTreeEditPartFactory.java (original)
+++ incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/DeploymentTreeEditPartFactory.java Tue Feb 21 15:40:05 2006
@@ -1,36 +1,36 @@
-/*
- * Copyright 2005-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.servicemix.packaging.parts;
-
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPartFactory;
-
-/**
- * The edit part factory for the tree
- *
- * TODO Needs implementing
- *
- * @author <a href="mailto:philip.dodds@gmail.com">Philip Dodds </a>
- *
- */
-public class DeploymentTreeEditPartFactory implements EditPartFactory {
-
- public EditPart createEditPart(EditPart arg0, Object arg1) {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.packaging.parts;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPartFactory;
+
+/**
+ * The edit part factory for the tree
+ *
+ * TODO Needs implementing
+ *
+ * @author <a href="mailto:philip.dodds@gmail.com">Philip Dodds </a>
+ *
+ */
+public class DeploymentTreeEditPartFactory implements EditPartFactory {
+
+ public EditPart createEditPart(EditPart arg0, Object arg1) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Propchange: incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/DeploymentTreeEditPartFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/ServiceAssemblyEditPart.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/ServiceAssemblyEditPart.java?rev=379627&r1=379626&r2=379627&view=diff
==============================================================================
--- incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/ServiceAssemblyEditPart.java (original)
+++ incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/ServiceAssemblyEditPart.java Tue Feb 21 15:40:05 2006
@@ -1,153 +1,153 @@
-/*
- * Copyright 2005-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.servicemix.packaging.parts;
-
-import java.beans.PropertyChangeEvent;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.servicemix.descriptors.packaging.assets.Components.Component;
-import org.apache.servicemix.packaging.figure.ServiceAssemblyFigure;
-import org.apache.servicemix.packaging.model.AbstractComponent;
-import org.apache.servicemix.packaging.model.ComponentBased;
-import org.apache.servicemix.packaging.model.DeploymentDiagram;
-import org.apache.servicemix.packaging.model.ServiceAssembly;
-import org.apache.servicemix.packaging.parts.descriptors.ServiceNameHelper;
-import org.eclipse.draw2d.ActionEvent;
-import org.eclipse.draw2d.ActionListener;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-
-/**
- * The GEF edit part of a service
- *
- * @author <a href="mailto:philip.dodds@gmail.com">Philip Dodds </a>
- *
- */
-public class ServiceAssemblyEditPart extends AbstractComponentEditPart
- implements IPropertySource, ActionListener {
-
- private LinkedList<IPropertyDescriptor> descriptors;
-
- @Override
- protected IFigure createFigureForModel() {
- ServiceAssemblyFigure newFigure = new ServiceAssemblyFigure(
- (ServiceAssembly) getModel(), this);
- return newFigure;
- }
-
- @Override
- public IFigure getContentPane() {
- return ((ServiceAssemblyFigure) getFigure()).getContentPaneFigure();
- }
-
- @Override
- protected List getModelChildren() {
- return ((ServiceAssembly) getModel()).getServiceUnit();
- }
-
- @Override
- public void refresh() {
- super.refresh();
- refreshVisuals();
- refreshChildren();
- }
-
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- super.propertyChange(evt);
- if (evt.getPropertyName().equals(ServiceAssembly.NAME_PROP)) {
- refreshVisuals();
- } else if (evt.getPropertyName().equals(ServiceAssembly.ADDCHILD_PROP)) {
- this.refresh();
- }
- }
-
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- ((ServiceAssemblyFigure) getFigure()).refresh();
- }
-
- private Component getComponentDescriptor() {
- Component component = null;
- if (getModel() instanceof ComponentBased) {
- for (Component componentIter : ((ComponentBased) getModel())
- .getComponentArtifact().getComponents().getComponent()) {
- if (componentIter.getName().equals(
- ((ComponentBased) getModel()).getComponentName())) {
- component = componentIter;
- }
- }
- }
- return component;
-
- }
-
- public Object getEditableValue() {
- return this;
- }
-
- public IPropertyDescriptor[] getPropertyDescriptors() {
- if (descriptors == null) {
- descriptors = new LinkedList<IPropertyDescriptor>();
- descriptors.add(new TextPropertyDescriptor(getModel(),
- "Service assembly name"));
- /*
- * Ignore assets for assembly if
- * (getComponentDescriptor().getAssets() != null) {
- * descriptors.addAll(AssetDescriptorFactory.getDescriptors(
- * getComponentDescriptor().getAssets(), getDeploymentDiagram())); }
- */
- }
-
- return getArray(descriptors);
- }
-
- public Object getPropertyValue(Object arg0) {
- if (arg0 instanceof ServiceAssembly) {
- return ((ServiceAssembly) arg0).getName();
- } else
- return getPropertyFromAssets(arg0, ((ServiceAssembly) getModel())
- .getStoredAssets());
- }
-
- public boolean isPropertySet(Object arg0) {
- return true;
- }
-
- public void resetPropertyValue(Object arg0) {
-
- }
-
- public void setPropertyValue(Object arg0, Object arg1) {
- if (arg0 instanceof ServiceAssembly) {
- ((ServiceAssembly) arg0).setName((String) arg1);
- } else
- setPropertyFromAssets(arg0, arg1, ((ServiceAssembly) getModel())
- .getStoredAssets());
- ((AbstractComponent) getModel()).updated();
- }
-
- public void actionPerformed(ActionEvent arg0) {
- ((ServiceAssembly) getModel())
- .createServiceUnit(ServiceNameHelper
- .getUniqueServiceName((DeploymentDiagram) getDeploymentDiagram()
- .getModel()));
- }
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.packaging.parts;
+
+import java.beans.PropertyChangeEvent;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.servicemix.descriptors.packaging.assets.Components.Component;
+import org.apache.servicemix.packaging.figure.ServiceAssemblyFigure;
+import org.apache.servicemix.packaging.model.AbstractComponent;
+import org.apache.servicemix.packaging.model.ComponentBased;
+import org.apache.servicemix.packaging.model.DeploymentDiagram;
+import org.apache.servicemix.packaging.model.ServiceAssembly;
+import org.apache.servicemix.packaging.parts.descriptors.ServiceNameHelper;
+import org.eclipse.draw2d.ActionEvent;
+import org.eclipse.draw2d.ActionListener;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;
+
+/**
+ * The GEF edit part of a service
+ *
+ * @author <a href="mailto:philip.dodds@gmail.com">Philip Dodds </a>
+ *
+ */
+public class ServiceAssemblyEditPart extends AbstractComponentEditPart
+ implements IPropertySource, ActionListener {
+
+ private LinkedList<IPropertyDescriptor> descriptors;
+
+ @Override
+ protected IFigure createFigureForModel() {
+ ServiceAssemblyFigure newFigure = new ServiceAssemblyFigure(
+ (ServiceAssembly) getModel(), this);
+ return newFigure;
+ }
+
+ @Override
+ public IFigure getContentPane() {
+ return ((ServiceAssemblyFigure) getFigure()).getContentPaneFigure();
+ }
+
+ @Override
+ protected List getModelChildren() {
+ return ((ServiceAssembly) getModel()).getServiceUnit();
+ }
+
+ @Override
+ public void refresh() {
+ super.refresh();
+ refreshVisuals();
+ refreshChildren();
+ }
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ super.propertyChange(evt);
+ if (evt.getPropertyName().equals(ServiceAssembly.NAME_PROP)) {
+ refreshVisuals();
+ } else if (evt.getPropertyName().equals(ServiceAssembly.ADDCHILD_PROP)) {
+ this.refresh();
+ }
+ }
+
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ ((ServiceAssemblyFigure) getFigure()).refresh();
+ }
+
+ private Component getComponentDescriptor() {
+ Component component = null;
+ if (getModel() instanceof ComponentBased) {
+ for (Component componentIter : ((ComponentBased) getModel())
+ .getComponentArtifact().getComponents().getComponent()) {
+ if (componentIter.getName().equals(
+ ((ComponentBased) getModel()).getComponentName())) {
+ component = componentIter;
+ }
+ }
+ }
+ return component;
+
+ }
+
+ public Object getEditableValue() {
+ return this;
+ }
+
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ if (descriptors == null) {
+ descriptors = new LinkedList<IPropertyDescriptor>();
+ descriptors.add(new TextPropertyDescriptor(getModel(),
+ "Service assembly name"));
+ /*
+ * Ignore assets for assembly if
+ * (getComponentDescriptor().getAssets() != null) {
+ * descriptors.addAll(AssetDescriptorFactory.getDescriptors(
+ * getComponentDescriptor().getAssets(), getDeploymentDiagram())); }
+ */
+ }
+
+ return getArray(descriptors);
+ }
+
+ public Object getPropertyValue(Object arg0) {
+ if (arg0 instanceof ServiceAssembly) {
+ return ((ServiceAssembly) arg0).getName();
+ } else
+ return getPropertyFromAssets(arg0, ((ServiceAssembly) getModel())
+ .getStoredAssets());
+ }
+
+ public boolean isPropertySet(Object arg0) {
+ return true;
+ }
+
+ public void resetPropertyValue(Object arg0) {
+
+ }
+
+ public void setPropertyValue(Object arg0, Object arg1) {
+ if (arg0 instanceof ServiceAssembly) {
+ ((ServiceAssembly) arg0).setName((String) arg1);
+ } else
+ setPropertyFromAssets(arg0, arg1, ((ServiceAssembly) getModel())
+ .getStoredAssets());
+ ((AbstractComponent) getModel()).updated();
+ }
+
+ public void actionPerformed(ActionEvent arg0) {
+ ((ServiceAssembly) getModel())
+ .createServiceUnit(ServiceNameHelper
+ .getUniqueServiceName((DeploymentDiagram) getDeploymentDiagram()
+ .getModel()));
+ }
}
Propchange: incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/ServiceAssemblyEditPart.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/ServiceUnitEditPart.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/ServiceUnitEditPart.java?rev=379627&r1=379626&r2=379627&view=diff
==============================================================================
--- incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/ServiceUnitEditPart.java (original)
+++ incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/ServiceUnitEditPart.java Tue Feb 21 15:40:05 2006
@@ -1,135 +1,135 @@
-/*
- * Copyright 2005-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.servicemix.packaging.parts;
-
-import java.util.LinkedList;
-
-import org.apache.servicemix.descriptors.packaging.assets.Components.Component;
-import org.apache.servicemix.packaging.figure.ServiceUnitFigure;
-import org.apache.servicemix.packaging.model.AbstractComponent;
-import org.apache.servicemix.packaging.model.ComponentBased;
-import org.apache.servicemix.packaging.model.ServiceUnit;
-import org.apache.servicemix.packaging.parts.descriptors.AssetDescriptorFactory;
-import org.eclipse.draw2d.ChopboxAnchor;
-import org.eclipse.draw2d.ConnectionAnchor;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.editpolicies.NonResizableEditPolicy;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-
-/**
- * The GEF edit part for a service unit
- *
- * @author <a href="mailto:philip.dodds@gmail.com">Philip Dodds </a>
- *
- */
-public class ServiceUnitEditPart extends AbstractComponentEditPart implements
- IPropertySource {
-
- private LinkedList<IPropertyDescriptor> descriptors;
-
- @Override
- protected void createEditPolicies() {
- NonResizableEditPolicy selectionPolicy = new NonResizableEditPolicy();
- selectionPolicy.setDragAllowed(false);
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, selectionPolicy);
-
- installEditPolicy(EditPolicy.COMPONENT_ROLE,
- new ServiceUnitEditPolicy());
- }
-
- @Override
- protected IFigure createFigureForModel() {
- ServiceUnitFigure newFigure = new ServiceUnitFigure(
- (ServiceUnit) getModel());
- return newFigure;
- }
-
- @Override
- protected void refreshVisuals() {
- ((ServiceUnitFigure) getFigure()).refresh();
- super.refreshVisuals();
- }
-
- private Component getComponentDescriptor() {
- Component component = null;
- if (getModel() instanceof ComponentBased) {
- for (Component componentIter : ((ComponentBased) getModel())
- .getComponentArtifact().getComponents().getComponent()) {
- if (componentIter.getName().equals(
- ((ComponentBased) getModel()).getComponentName())) {
- component = componentIter;
- }
- }
- }
- return component;
-
- }
-
- public Object getEditableValue() {
- return this;
- }
-
- public IPropertyDescriptor[] getPropertyDescriptors() {
- if (descriptors == null) {
- descriptors = new LinkedList<IPropertyDescriptor>();
- descriptors.add(new TextPropertyDescriptor(getModel(),
- "Service unit name"));
- if (getComponentDescriptor().getAssets() != null)
- descriptors.addAll(AssetDescriptorFactory.getDescriptors(
- getComponentDescriptor().getAssets(),
- getDeploymentDiagram()));
-
- }
- return getArray(descriptors);
- }
-
- public Object getPropertyValue(Object arg0) {
- if (arg0 instanceof ServiceUnit) {
- return ((ServiceUnit) arg0).getServiceUnitName();
- } else
- return getPropertyFromAssets(arg0, ((ServiceUnit) getModel())
- .getStoredAssets());
- }
-
- public boolean isPropertySet(Object arg0) {
- return true;
- }
-
- public void resetPropertyValue(Object arg0) {
-
- }
-
- @Override
- protected ConnectionAnchor getConnectionAnchor() {
- if (anchor == null) {
- anchor = new ChopboxAnchor(((ServiceUnitFigure) getFigure())
- .getComponentImage());
- }
- return anchor;
- }
-
- public void setPropertyValue(Object arg0, Object arg1) {
- if (arg0 instanceof ServiceUnit) {
- ((ServiceUnit) arg0).setServiceUnitName((String) arg1);
- } else
- setPropertyFromAssets(arg0, arg1, ((ServiceUnit) getModel())
- .getStoredAssets());
- ((AbstractComponent) getModel()).updated();
- }
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.packaging.parts;
+
+import java.util.LinkedList;
+
+import org.apache.servicemix.descriptors.packaging.assets.Components.Component;
+import org.apache.servicemix.packaging.figure.ServiceUnitFigure;
+import org.apache.servicemix.packaging.model.AbstractComponent;
+import org.apache.servicemix.packaging.model.ComponentBased;
+import org.apache.servicemix.packaging.model.ServiceUnit;
+import org.apache.servicemix.packaging.parts.descriptors.AssetDescriptorFactory;
+import org.eclipse.draw2d.ChopboxAnchor;
+import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.editpolicies.NonResizableEditPolicy;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;
+
+/**
+ * The GEF edit part for a service unit
+ *
+ * @author <a href="mailto:philip.dodds@gmail.com">Philip Dodds </a>
+ *
+ */
+public class ServiceUnitEditPart extends AbstractComponentEditPart implements
+ IPropertySource {
+
+ private LinkedList<IPropertyDescriptor> descriptors;
+
+ @Override
+ protected void createEditPolicies() {
+ NonResizableEditPolicy selectionPolicy = new NonResizableEditPolicy();
+ selectionPolicy.setDragAllowed(false);
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, selectionPolicy);
+
+ installEditPolicy(EditPolicy.COMPONENT_ROLE,
+ new ServiceUnitEditPolicy());
+ }
+
+ @Override
+ protected IFigure createFigureForModel() {
+ ServiceUnitFigure newFigure = new ServiceUnitFigure(
+ (ServiceUnit) getModel());
+ return newFigure;
+ }
+
+ @Override
+ protected void refreshVisuals() {
+ ((ServiceUnitFigure) getFigure()).refresh();
+ super.refreshVisuals();
+ }
+
+ private Component getComponentDescriptor() {
+ Component component = null;
+ if (getModel() instanceof ComponentBased) {
+ for (Component componentIter : ((ComponentBased) getModel())
+ .getComponentArtifact().getComponents().getComponent()) {
+ if (componentIter.getName().equals(
+ ((ComponentBased) getModel()).getComponentName())) {
+ component = componentIter;
+ }
+ }
+ }
+ return component;
+
+ }
+
+ public Object getEditableValue() {
+ return this;
+ }
+
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ if (descriptors == null) {
+ descriptors = new LinkedList<IPropertyDescriptor>();
+ descriptors.add(new TextPropertyDescriptor(getModel(),
+ "Service unit name"));
+ if (getComponentDescriptor().getAssets() != null)
+ descriptors.addAll(AssetDescriptorFactory.getDescriptors(
+ getComponentDescriptor().getAssets(),
+ getDeploymentDiagram()));
+
+ }
+ return getArray(descriptors);
+ }
+
+ public Object getPropertyValue(Object arg0) {
+ if (arg0 instanceof ServiceUnit) {
+ return ((ServiceUnit) arg0).getServiceUnitName();
+ } else
+ return getPropertyFromAssets(arg0, ((ServiceUnit) getModel())
+ .getStoredAssets());
+ }
+
+ public boolean isPropertySet(Object arg0) {
+ return true;
+ }
+
+ public void resetPropertyValue(Object arg0) {
+
+ }
+
+ @Override
+ protected ConnectionAnchor getConnectionAnchor() {
+ if (anchor == null) {
+ anchor = new ChopboxAnchor(((ServiceUnitFigure) getFigure())
+ .getComponentImage());
+ }
+ return anchor;
+ }
+
+ public void setPropertyValue(Object arg0, Object arg1) {
+ if (arg0 instanceof ServiceUnit) {
+ ((ServiceUnit) arg0).setServiceUnitName((String) arg1);
+ } else
+ setPropertyFromAssets(arg0, arg1, ((ServiceUnit) getModel())
+ .getStoredAssets());
+ ((AbstractComponent) getModel()).updated();
+ }
}
Propchange: incubator/servicemix/trunk/tooling/servicemix-packaging-eclipse-plugin/src/main/java/org/apache/servicemix/packaging/parts/ServiceUnitEditPart.java
------------------------------------------------------------------------------
svn:eol-style = native