diff options
author | Henrik Rentz-Reichert | 2011-05-19 14:40:16 +0000 |
---|---|---|
committer | Henrik Rentz-Reichert | 2011-05-19 14:40:16 +0000 |
commit | dbeba570c4936467bea37bdfa9213283e5a353d9 (patch) | |
tree | b343781ebc97e2681a219aa83c81c093d95a89ce /plugins/org.eclipse.etrice.ui.common | |
parent | c253b9e044ccfa42cb3b72aa320e0594c62145a9 (diff) | |
download | org.eclipse.etrice-dbeba570c4936467bea37bdfa9213283e5a353d9.tar.gz org.eclipse.etrice-dbeba570c4936467bea37bdfa9213283e5a353d9.tar.xz org.eclipse.etrice-dbeba570c4936467bea37bdfa9213283e5a353d9.zip |
[ui.common] factored out common code of behavior and structure support
Diffstat (limited to 'plugins/org.eclipse.etrice.ui.common')
-rw-r--r-- | plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/support/CommonSupportUtil.java | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/support/CommonSupportUtil.java b/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/support/CommonSupportUtil.java new file mode 100644 index 000000000..b1229a25a --- /dev/null +++ b/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/support/CommonSupportUtil.java @@ -0,0 +1,52 @@ +/*******************************************************************************
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *******************************************************************************/
+
+package org.eclipse.etrice.ui.common.support;
+
+import java.util.Iterator;
+
+import org.eclipse.graphiti.features.IDeleteFeature;
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.context.impl.DeleteContext;
+import org.eclipse.graphiti.features.context.impl.MultiDeleteInfo;
+import org.eclipse.graphiti.mm.pictograms.Anchor;
+import org.eclipse.graphiti.mm.pictograms.Connection;
+import org.eclipse.graphiti.mm.pictograms.ContainerShape;
+import org.eclipse.graphiti.mm.pictograms.Shape;
+import org.eclipse.graphiti.services.Graphiti;
+
+/**
+ * @author Henrik Rentz-Reichert - Initial contribution and API
+ *
+ */
+public class CommonSupportUtil {
+
+ /**
+ * @param container
+ */
+ public static void deleteConnectionsRecursive(ContainerShape container, IFeatureProvider fp) {
+ for (Iterator<Anchor> iter = container.getAnchors().iterator(); iter.hasNext();) {
+ Anchor anchor = iter.next();
+ for (Iterator<Connection> iterator = Graphiti.getPeService().getAllConnections(anchor).iterator(); iterator.hasNext();) {
+ Connection connection = iterator.next();
+ DeleteContext ctx = new DeleteContext(connection);
+ ctx.setMultiDeleteInfo(new MultiDeleteInfo(false, false, 1));
+ IDeleteFeature deleteFeature = fp.getDeleteFeature(ctx);
+ if (deleteFeature!=null)
+ deleteFeature.delete(ctx);
+ }
+ }
+
+ // recursion
+ for (Shape child : container.getChildren()) {
+ if (child instanceof ContainerShape)
+ deleteConnectionsRecursive((ContainerShape) child, fp);
+ }
+ }
+
+}
|