Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorddunne2008-02-05 18:07:49 +0000
committerddunne2008-02-05 18:07:49 +0000
commitd3a3fc36785556b484bd55eb982c304dc20d4b0a (patch)
treeb0a4335423a2a5064c573a2f5b55af148dfe66cf
parentacde3fdb1ace066cbb24a4311abef33421b4539c (diff)
downloadorg.eclipse.osee-d3a3fc36785556b484bd55eb982c304dc20d4b0a.tar.gz
org.eclipse.osee-d3a3fc36785556b484bd55eb982c304dc20d4b0a.tar.xz
org.eclipse.osee-d3a3fc36785556b484bd55eb982c304dc20d4b0a.zip
Add UpdateArtifactTypeImage Blam
-rw-r--r--org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/ArtifactSubtypeDescriptor.java685
-rw-r--r--org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/ConfigurationPersistenceManager.java1074
-rw-r--r--org.eclipse.osee.framework.ui.skynet/images/file.gifbin0 -> 354 bytes
-rw-r--r--org.eclipse.osee.framework.ui.skynet/plugin.xml8
-rw-r--r--org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/UpdateArtifactTypeImage.java84
-rw-r--r--org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XFileSelectionDialog.java83
-rw-r--r--org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/workflow/XWidgetFactory.java395
7 files changed, 1262 insertions, 1067 deletions
diff --git a/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/ArtifactSubtypeDescriptor.java b/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/ArtifactSubtypeDescriptor.java
index ffa0bb0dbe9..db3b07daad3 100644
--- a/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/ArtifactSubtypeDescriptor.java
+++ b/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/ArtifactSubtypeDescriptor.java
@@ -1,338 +1,347 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * 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
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.skynet.core.attribute;
-
-import static org.eclipse.osee.framework.ui.plugin.util.db.schemas.ChangeType.CONFLICTING;
-import static org.eclipse.osee.framework.ui.plugin.util.db.schemas.ChangeType.INCOMING;
-import static org.eclipse.osee.framework.ui.plugin.util.db.schemas.ChangeType.OUTGOING;
-import static org.eclipse.osee.framework.ui.plugin.util.db.schemas.SkynetDatabase.ModificationType.CHANGE;
-import static org.eclipse.osee.framework.ui.plugin.util.db.schemas.SkynetDatabase.ModificationType.DELETE;
-import static org.eclipse.osee.framework.ui.plugin.util.db.schemas.SkynetDatabase.ModificationType.NEW;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.ObjectStreamException;
-import java.io.Serializable;
-import java.sql.SQLException;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.ImageRegistry;
-import org.eclipse.osee.framework.skynet.core.SkynetActivator;
-import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.artifact.annotation.ArtifactAnnotation;
-import org.eclipse.osee.framework.skynet.core.artifact.factory.IArtifactFactory;
-import org.eclipse.osee.framework.skynet.core.revision.ConflictionType;
-import org.eclipse.osee.framework.skynet.core.transaction.TransactionId;
-import org.eclipse.osee.framework.ui.plugin.util.InputStreamImageDescriptor;
-import org.eclipse.osee.framework.ui.plugin.util.OverlayImage;
-import org.eclipse.osee.framework.ui.plugin.util.db.schemas.ChangeType;
-import org.eclipse.osee.framework.ui.plugin.util.db.schemas.SkynetDatabase.ModificationType;
-import org.eclipse.swt.graphics.Image;
-
-/**
- * Description of an Artifact subtype. The descriptor can be used to create new artifacts that are of the type of this
- * descriptor. <br/><br/> Descriptors can be acquired from the configuration manager.
- *
- * @see org.eclipse.osee.framework.skynet.core.attribute.ConfigurationPersistenceManager
- * @author Robert A. Fisher
- */
-public class ArtifactSubtypeDescriptor implements Serializable {
- private static final long serialVersionUID = 1L;
- private static final ImageDescriptor favorite = SkynetActivator.getInstance().getImageDescriptor("favorite.gif");
- private static final ImageDescriptor subscribed = SkynetActivator.getInstance().getImageDescriptor("subscribed.gif");
- private static final ImageDescriptor outNew = SkynetActivator.getInstance().getImageDescriptor("out_new.gif");
- private static final ImageDescriptor outChange = SkynetActivator.getInstance().getImageDescriptor("out_change.gif");
- private static final ImageDescriptor outDeleted = SkynetActivator.getInstance().getImageDescriptor("out_delete.gif");
- private static final ImageDescriptor incNew = SkynetActivator.getInstance().getImageDescriptor("inc_new.gif");
- private static final ImageDescriptor incChange = SkynetActivator.getInstance().getImageDescriptor("inc_change.gif");
- private static final ImageDescriptor incDeleted = SkynetActivator.getInstance().getImageDescriptor("inc_delete.gif");
- private static final ImageDescriptor conChange = SkynetActivator.getInstance().getImageDescriptor("con_change.gif");
- private static final ImageDescriptor conDeleted = SkynetActivator.getInstance().getImageDescriptor("con_delete.gif");
- private static final ImageDescriptor lockedAccess =
- SkynetActivator.getInstance().getImageDescriptor("green_lock.gif");
- private static final ImageDescriptor lockedNoAccess =
- SkynetActivator.getInstance().getImageDescriptor("red_lock.gif");
- private static final ImageDescriptor nextImageDesc =
- SkynetActivator.getInstance().getImageDescriptor("yellowN_8_8.gif");
- private static final ImageDescriptor releasedImageDesc =
- SkynetActivator.getInstance().getImageDescriptor("orangeR_8_8.gif");
- private static final ImageDescriptor metricsFromTasks =
- SkynetActivator.getInstance().getImageDescriptor("yellowT_8_8.gif");
- private static final String LOCKED_ACCESS = "locked access";
- private static final String LOCKED_NO_ACCESS = "locked No access";
- private static final String SUBSCRIBED = "subscribed";
- private static final String FAVORITE = "favorite";
- private static final String NEXT = "next";
- private static final String RELEASED = "released";
- private static final String WARNING = "warning";
- private static final String ERROR = "error";
- private static final String METRICS_FROM_TASKS = "metricsFromTasks";
- private static final String BASE = "base";
- private final int artTypeId;
- private final String factoryKey;
- private final IArtifactFactory factory;
- private String name;
- private TransactionId transactionId;
- transient private ImageRegistry imageRegistry;
- transient private final InputStreamImageDescriptor imageDescriptor;
-
- /**
- * @param artTypeId
- * @param factory
- * @param name
- */
- protected ArtifactSubtypeDescriptor(int artTypeId, String factoryKey, IArtifactFactory factory, String name, TransactionId transactionId, InputStreamImageDescriptor imageDescriptor) {
- this.artTypeId = artTypeId;
- this.factory = factory;
- this.name = name;
- this.factoryKey = factoryKey;
- this.transactionId = transactionId;
- this.imageDescriptor = imageDescriptor;
- this.imageRegistry = null;
- }
-
- // /**
- // * Constructor for deserialization
- // */
- // private ArtifactSubtypeDescriptor() {
- // this.artTypeId = 0;
- // this.factoryKey = null;
- // this.factory = null;
- // this.imageDescriptor = null;
- // this.name = null;
- // this.transactionId = null;
- // }
-
- /**
- * Get a new instance of the type of artifact described by this descriptor. This is just a convenience method that
- * calls makeNewArtifact on the known factory with this descriptor for the descriptor parameter, and the supplied
- * branch.
- *
- * @return Return artifact reference
- * @throws SQLException
- * @see IArtifactFactory#makeNewArtifact(ArtifactSubtypeDescriptor)
- */
- public Artifact makeNewArtifact() throws SQLException {
- return factory.makeNewArtifact(this);
- }
-
- /**
- * Get a new instance of the type of artifact described by this descriptor. This is just a convenience method that
- * calls makeNewArtifact on the known factory with this descriptor for the descriptor parameter, and the supplied
- * branch.
- *
- * @return Return artifact reference
- * @throws SQLException
- * @see IArtifactFactory#makeNewArtifact(ArtifactSubtypeDescriptor, String, String)
- */
- public Artifact makeNewArtifact(String guid, String humandReadableId) throws SQLException {
- return factory.makeNewArtifact(this, guid, humandReadableId);
- }
-
- /**
- * @return Returns the artTypeId.
- */
- public int getArtTypeId() {
- return artTypeId;
- }
-
- /**
- * @return Returns the factory.
- */
- public IArtifactFactory getFactory() {
- return factory;
- }
-
- /**
- * @return Returns the name.
- */
- public String getName() {
- return name;
- }
-
- /**
- * @return Returns the factoryKey.
- */
- public String getFactoryKey() {
- return factoryKey;
- }
-
- /**
- * @return Returns the transactionId.
- */
- public TransactionId getTransactionId() {
- return transactionId;
- }
-
- /**
- * Determine if this is the descriptor that produces the same type of artifact as an already existing artifact.
- *
- * @param artifact The artifact to compare against.
- * @return <b>true</b> if and only if this descriptor will give you the same type of artifact.
- */
- public boolean canProduceArtifact(Artifact artifact) {
- return artifact.getArtTypeId() == artTypeId && artifact.getFactoryId() == factory.getFactoryId();
- }
-
- public Image getImage() {
- checkImageRegistry();
- return imageRegistry.get(BASE);
- }
-
- public Image getLockedImage(boolean access) {
- checkImageRegistry();
- return imageRegistry.get(BASE + (access ? LOCKED_ACCESS : LOCKED_NO_ACCESS));
- }
-
- public Image getImage(ChangeType changeType, ModificationType modType) {
- if (changeType == null) throw new IllegalArgumentException("changeType can not be null.");
- if (modType == null) throw new IllegalArgumentException("modType can not be null.");
- if (changeType == CONFLICTING && modType == NEW) throw new IllegalArgumentException(
- "conflicting new artifacts are not supported");
-
- checkImageRegistry();
- return imageRegistry.get(BASE + changeType + modType);
- }
-
- public Image getImage(ConflictionType conType) {
- if (conType == null) throw new IllegalArgumentException("conType can not be null.");
- checkImageRegistry();
- return imageRegistry.get(BASE + conType);
-
- }
-
- public Image getImage(boolean isSubscribed, boolean isFavorite, ArtifactAnnotation.Type notifyType, boolean isMetricsFromTasks) {
- checkImageRegistry();
- String hashKey =
- BASE + (isSubscribed ? SUBSCRIBED : "") + (isFavorite ? FAVORITE : "") + ((notifyType == null || notifyType == ArtifactAnnotation.Type.None) ? "" : (notifyType == ArtifactAnnotation.Type.Error ? ERROR : WARNING) + (isMetricsFromTasks ? METRICS_FROM_TASKS : ""));
- Image image = imageRegistry.get(hashKey);
- if (image == null) {
-
- ImageDescriptor imageDesc = imageRegistry.getDescriptor(BASE);
- if (isSubscribed) imageDesc = new OverlayImage(imageDesc.createImage(), subscribed, 8, 6);
- if (isFavorite) imageDesc = new OverlayImage(imageDesc.createImage(), favorite, 7, 0);
- if (notifyType == ArtifactAnnotation.Type.Error)
- imageDesc =
- new OverlayImage(imageDesc.createImage(), ArtifactAnnotation.Type.Error.getImageOverlayDescriptor(),
- 0, 8);
- else if (notifyType == ArtifactAnnotation.Type.Warning) imageDesc =
- new OverlayImage(imageDesc.createImage(), ArtifactAnnotation.Type.Warning.getImageOverlayDescriptor(),
- 0, 8);
- if (isMetricsFromTasks) imageDesc = new OverlayImage(imageDesc.createImage(), metricsFromTasks, 0, 0);
- imageRegistry.put(hashKey, imageDesc);
- image = imageRegistry.get(hashKey);
- }
- return image;
- }
-
- public Image getImage(boolean next, boolean released) {
- checkImageRegistry();
- String hashKey = BASE + (next ? NEXT : "") + (released ? RELEASED : "");
- Image image = imageRegistry.get(hashKey);
- if (image == null) {
- ImageDescriptor imageDesc = imageRegistry.getDescriptor(BASE);
- if (next) imageDesc = new OverlayImage(imageDesc.createImage(), nextImageDesc, 8, 8);
- if (released) imageDesc = new OverlayImage(imageDesc.createImage(), releasedImageDesc, 8, 0);
- imageRegistry.put(hashKey, imageDesc);
- image = imageRegistry.get(hashKey);
- }
- return image;
- }
-
- public Image getAnnotationImage(ArtifactAnnotation.Type type) {
- checkImageRegistry();
- if (type == ArtifactAnnotation.Type.Error)
- return imageRegistry.get(BASE + ERROR);
- else if (type == ArtifactAnnotation.Type.Warning) return imageRegistry.get(BASE + WARNING);
- return getImage();
- }
-
- private void checkImageRegistry() {
- if (imageRegistry == null) {
- imageRegistry = new ImageRegistry();
-
- imageRegistry.put(BASE, imageDescriptor);
- imageRegistry.put(BASE + LOCKED_NO_ACCESS, new OverlayImage(imageRegistry.get(BASE), lockedNoAccess, 0, 7));
- imageRegistry.put(BASE + LOCKED_ACCESS, new OverlayImage(imageRegistry.get(BASE), lockedAccess, 0, 7));
- imageRegistry.put(BASE + INCOMING + DELETE, new OverlayImage(imageRegistry.get(BASE), incDeleted));
- imageRegistry.put(BASE + INCOMING + CHANGE, new OverlayImage(imageRegistry.get(BASE), incChange));
- imageRegistry.put(BASE + INCOMING + NEW, new OverlayImage(imageRegistry.get(BASE), incNew));
- imageRegistry.put(BASE + OUTGOING + DELETE, new OverlayImage(imageRegistry.get(BASE), outDeleted));
- imageRegistry.put(BASE + OUTGOING + CHANGE, new OverlayImage(imageRegistry.get(BASE), outChange));
- imageRegistry.put(BASE + OUTGOING + NEW, new OverlayImage(imageRegistry.get(BASE), outNew));
- imageRegistry.put(BASE + CONFLICTING + DELETE, new OverlayImage(imageRegistry.get(BASE), conDeleted));
- imageRegistry.put(BASE + CONFLICTING + CHANGE, new OverlayImage(imageRegistry.get(BASE), conChange));
- imageRegistry.put(BASE + WARNING, new OverlayImage(imageRegistry.get(BASE),
- ArtifactAnnotation.Type.Warning.getImageOverlayDescriptor(), 0, 8));
- imageRegistry.put(BASE + ERROR, new OverlayImage(imageRegistry.get(BASE),
- ArtifactAnnotation.Type.Error.getImageOverlayDescriptor(), 0, 8));
- }
- }
-
- /**
- * @return Returns the imageDescriptor.
- */
- public InputStreamImageDescriptor getImageDescriptor() {
- return imageDescriptor;
- }
-
- public String toString() {
- return name;
- }
-
- /**
- * @throws SQLException
- */
- public void delete() throws SQLException {
- // delete existing artifact of this type
- // for (Artifact artifact : artifactManager.getArtifactsFromSubtypeName(name,
- // transactionId.getBranch())) {
- // artifact.delete();
- // }
- // then delete the artifact type itself
- // OSEE_DEFINE_ARTIFACT_TYPE needs a MODIFICATION_ID column to support deleting artifact types
- }
-
- /**
- * Only store the identifying data since a manager controls this object.
- *
- * @param stream
- * @throws IOException
- */
- private void writeObject(ObjectOutputStream stream) throws IOException {
- stream.writeObject(name);
- stream.writeObject(transactionId);
- }
-
- /**
- * Initialize as a dumb object for portraying the object needed
- *
- * @param stream
- * @throws IOException
- * @throws ClassNotFoundException
- */
- private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
- name = (String) stream.readObject();
- transactionId = (TransactionId) stream.readObject();
- }
-
- /**
- * @return The ArtifactSubtypeDescriptor associated with the name and transactionId from this dumb object
- * @throws ObjectStreamException
- */
- private Object readResolve() throws ObjectStreamException {
- try {
- return ConfigurationPersistenceManager.getInstance().getArtifactSubtypeDescriptor(name, transactionId);
- } catch (SQLException e) {
- throw new RuntimeException("Error while resolving descriptor", e);
- }
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.skynet.core.attribute;
+
+import static org.eclipse.osee.framework.ui.plugin.util.db.schemas.ChangeType.CONFLICTING;
+import static org.eclipse.osee.framework.ui.plugin.util.db.schemas.ChangeType.INCOMING;
+import static org.eclipse.osee.framework.ui.plugin.util.db.schemas.ChangeType.OUTGOING;
+import static org.eclipse.osee.framework.ui.plugin.util.db.schemas.SkynetDatabase.ModificationType.CHANGE;
+import static org.eclipse.osee.framework.ui.plugin.util.db.schemas.SkynetDatabase.ModificationType.DELETE;
+import static org.eclipse.osee.framework.ui.plugin.util.db.schemas.SkynetDatabase.ModificationType.NEW;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamException;
+import java.io.Serializable;
+import java.sql.SQLException;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.osee.framework.skynet.core.SkynetActivator;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.annotation.ArtifactAnnotation;
+import org.eclipse.osee.framework.skynet.core.artifact.factory.IArtifactFactory;
+import org.eclipse.osee.framework.skynet.core.revision.ConflictionType;
+import org.eclipse.osee.framework.skynet.core.transaction.TransactionId;
+import org.eclipse.osee.framework.ui.plugin.util.InputStreamImageDescriptor;
+import org.eclipse.osee.framework.ui.plugin.util.OverlayImage;
+import org.eclipse.osee.framework.ui.plugin.util.db.schemas.ChangeType;
+import org.eclipse.osee.framework.ui.plugin.util.db.schemas.SkynetDatabase.ModificationType;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * Description of an Artifact subtype. The descriptor can be used to create new artifacts that are of the type of this
+ * descriptor. <br/><br/> Descriptors can be acquired from the configuration manager.
+ *
+ * @see org.eclipse.osee.framework.skynet.core.attribute.ConfigurationPersistenceManager
+ * @author Robert A. Fisher
+ */
+public class ArtifactSubtypeDescriptor implements Serializable {
+ private static final long serialVersionUID = 1L;
+ private static final ImageDescriptor favorite = SkynetActivator.getInstance().getImageDescriptor("favorite.gif");
+ private static final ImageDescriptor subscribed = SkynetActivator.getInstance().getImageDescriptor("subscribed.gif");
+ private static final ImageDescriptor outNew = SkynetActivator.getInstance().getImageDescriptor("out_new.gif");
+ private static final ImageDescriptor outChange = SkynetActivator.getInstance().getImageDescriptor("out_change.gif");
+ private static final ImageDescriptor outDeleted = SkynetActivator.getInstance().getImageDescriptor("out_delete.gif");
+ private static final ImageDescriptor incNew = SkynetActivator.getInstance().getImageDescriptor("inc_new.gif");
+ private static final ImageDescriptor incChange = SkynetActivator.getInstance().getImageDescriptor("inc_change.gif");
+ private static final ImageDescriptor incDeleted = SkynetActivator.getInstance().getImageDescriptor("inc_delete.gif");
+ private static final ImageDescriptor conChange = SkynetActivator.getInstance().getImageDescriptor("con_change.gif");
+ private static final ImageDescriptor conDeleted = SkynetActivator.getInstance().getImageDescriptor("con_delete.gif");
+ private static final ImageDescriptor lockedAccess =
+ SkynetActivator.getInstance().getImageDescriptor("green_lock.gif");
+ private static final ImageDescriptor lockedNoAccess =
+ SkynetActivator.getInstance().getImageDescriptor("red_lock.gif");
+ private static final ImageDescriptor nextImageDesc =
+ SkynetActivator.getInstance().getImageDescriptor("yellowN_8_8.gif");
+ private static final ImageDescriptor releasedImageDesc =
+ SkynetActivator.getInstance().getImageDescriptor("orangeR_8_8.gif");
+ private static final ImageDescriptor metricsFromTasks =
+ SkynetActivator.getInstance().getImageDescriptor("yellowT_8_8.gif");
+ private static final String LOCKED_ACCESS = "locked access";
+ private static final String LOCKED_NO_ACCESS = "locked No access";
+ private static final String SUBSCRIBED = "subscribed";
+ private static final String FAVORITE = "favorite";
+ private static final String NEXT = "next";
+ private static final String RELEASED = "released";
+ private static final String WARNING = "warning";
+ private static final String ERROR = "error";
+ private static final String METRICS_FROM_TASKS = "metricsFromTasks";
+ private static final String BASE = "base";
+ private final int artTypeId;
+ private final String factoryKey;
+ private final IArtifactFactory factory;
+ private String name;
+ private TransactionId transactionId;
+ transient private ImageRegistry imageRegistry;
+ transient private InputStreamImageDescriptor imageDescriptor;
+
+ /**
+ * @param artTypeId
+ * @param factory
+ * @param name
+ */
+ protected ArtifactSubtypeDescriptor(int artTypeId, String factoryKey, IArtifactFactory factory, String name, TransactionId transactionId, InputStreamImageDescriptor imageDescriptor) {
+ this.artTypeId = artTypeId;
+ this.factory = factory;
+ this.name = name;
+ this.factoryKey = factoryKey;
+ this.transactionId = transactionId;
+ this.imageDescriptor = imageDescriptor;
+ this.imageRegistry = null;
+ }
+
+ // /**
+ // * Constructor for deserialization
+ // */
+ // private ArtifactSubtypeDescriptor() {
+ // this.artTypeId = 0;
+ // this.factoryKey = null;
+ // this.factory = null;
+ // this.imageDescriptor = null;
+ // this.name = null;
+ // this.transactionId = null;
+ // }
+
+ /**
+ * Get a new instance of the type of artifact described by this descriptor. This is just a convenience method that
+ * calls makeNewArtifact on the known factory with this descriptor for the descriptor parameter, and the supplied
+ * branch.
+ *
+ * @return Return artifact reference
+ * @throws SQLException
+ * @see IArtifactFactory#makeNewArtifact(ArtifactSubtypeDescriptor)
+ */
+ public Artifact makeNewArtifact() throws SQLException {
+ return factory.makeNewArtifact(this);
+ }
+
+ /**
+ * Get a new instance of the type of artifact described by this descriptor. This is just a convenience method that
+ * calls makeNewArtifact on the known factory with this descriptor for the descriptor parameter, and the supplied
+ * branch.
+ *
+ * @return Return artifact reference
+ * @throws SQLException
+ * @see IArtifactFactory#makeNewArtifact(ArtifactSubtypeDescriptor, String, String)
+ */
+ public Artifact makeNewArtifact(String guid, String humandReadableId) throws SQLException {
+ return factory.makeNewArtifact(this, guid, humandReadableId);
+ }
+
+ /**
+ * @return Returns the artTypeId.
+ */
+ public int getArtTypeId() {
+ return artTypeId;
+ }
+
+ /**
+ * @return Returns the factory.
+ */
+ public IArtifactFactory getFactory() {
+ return factory;
+ }
+
+ /**
+ * @return Returns the name.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return Returns the factoryKey.
+ */
+ public String getFactoryKey() {
+ return factoryKey;
+ }
+
+ /**
+ * @return Returns the transactionId.
+ */
+ public TransactionId getTransactionId() {
+ return transactionId;
+ }
+
+ /**
+ * Determine if this is the descriptor that produces the same type of artifact as an already existing artifact.
+ *
+ * @param artifact The artifact to compare against.
+ * @return <b>true</b> if and only if this descriptor will give you the same type of artifact.
+ */
+ public boolean canProduceArtifact(Artifact artifact) {
+ return artifact.getArtTypeId() == artTypeId && artifact.getFactoryId() == factory.getFactoryId();
+ }
+
+ public Image getImage() {
+ checkImageRegistry();
+ return imageRegistry.get(BASE);
+ }
+
+ public Image getLockedImage(boolean access) {
+ checkImageRegistry();
+ return imageRegistry.get(BASE + (access ? LOCKED_ACCESS : LOCKED_NO_ACCESS));
+ }
+
+ public Image getImage(ChangeType changeType, ModificationType modType) {
+ if (changeType == null) throw new IllegalArgumentException("changeType can not be null.");
+ if (modType == null) throw new IllegalArgumentException("modType can not be null.");
+ if (changeType == CONFLICTING && modType == NEW) throw new IllegalArgumentException(
+ "conflicting new artifacts are not supported");
+
+ checkImageRegistry();
+ return imageRegistry.get(BASE + changeType + modType);
+ }
+
+ public Image getImage(ConflictionType conType) {
+ if (conType == null) throw new IllegalArgumentException("conType can not be null.");
+ checkImageRegistry();
+ return imageRegistry.get(BASE + conType);
+
+ }
+
+ public Image getImage(boolean isSubscribed, boolean isFavorite, ArtifactAnnotation.Type notifyType, boolean isMetricsFromTasks) {
+ checkImageRegistry();
+ String hashKey =
+ BASE + (isSubscribed ? SUBSCRIBED : "") + (isFavorite ? FAVORITE : "") + ((notifyType == null || notifyType == ArtifactAnnotation.Type.None) ? "" : (notifyType == ArtifactAnnotation.Type.Error ? ERROR : WARNING) + (isMetricsFromTasks ? METRICS_FROM_TASKS : ""));
+ Image image = imageRegistry.get(hashKey);
+ if (image == null) {
+
+ ImageDescriptor imageDesc = imageRegistry.getDescriptor(BASE);
+ if (isSubscribed) imageDesc = new OverlayImage(imageDesc.createImage(), subscribed, 8, 6);
+ if (isFavorite) imageDesc = new OverlayImage(imageDesc.createImage(), favorite, 7, 0);
+ if (notifyType == ArtifactAnnotation.Type.Error)
+ imageDesc =
+ new OverlayImage(imageDesc.createImage(), ArtifactAnnotation.Type.Error.getImageOverlayDescriptor(),
+ 0, 8);
+ else if (notifyType == ArtifactAnnotation.Type.Warning) imageDesc =
+ new OverlayImage(imageDesc.createImage(), ArtifactAnnotation.Type.Warning.getImageOverlayDescriptor(),
+ 0, 8);
+ if (isMetricsFromTasks) imageDesc = new OverlayImage(imageDesc.createImage(), metricsFromTasks, 0, 0);
+ imageRegistry.put(hashKey, imageDesc);
+ image = imageRegistry.get(hashKey);
+ }
+ return image;
+ }
+
+ public Image getImage(boolean next, boolean released) {
+ checkImageRegistry();
+ String hashKey = BASE + (next ? NEXT : "") + (released ? RELEASED : "");
+ Image image = imageRegistry.get(hashKey);
+ if (image == null) {
+ ImageDescriptor imageDesc = imageRegistry.getDescriptor(BASE);
+ if (next) imageDesc = new OverlayImage(imageDesc.createImage(), nextImageDesc, 8, 8);
+ if (released) imageDesc = new OverlayImage(imageDesc.createImage(), releasedImageDesc, 8, 0);
+ imageRegistry.put(hashKey, imageDesc);
+ image = imageRegistry.get(hashKey);
+ }
+ return image;
+ }
+
+ public Image getAnnotationImage(ArtifactAnnotation.Type type) {
+ checkImageRegistry();
+ if (type == ArtifactAnnotation.Type.Error)
+ return imageRegistry.get(BASE + ERROR);
+ else if (type == ArtifactAnnotation.Type.Warning) return imageRegistry.get(BASE + WARNING);
+ return getImage();
+ }
+
+ private void checkImageRegistry() {
+ if (imageRegistry == null) {
+ imageRegistry = new ImageRegistry();
+
+ imageRegistry.put(BASE, imageDescriptor);
+ imageRegistry.put(BASE + LOCKED_NO_ACCESS, new OverlayImage(imageRegistry.get(BASE), lockedNoAccess, 0, 7));
+ imageRegistry.put(BASE + LOCKED_ACCESS, new OverlayImage(imageRegistry.get(BASE), lockedAccess, 0, 7));
+ imageRegistry.put(BASE + INCOMING + DELETE, new OverlayImage(imageRegistry.get(BASE), incDeleted));
+ imageRegistry.put(BASE + INCOMING + CHANGE, new OverlayImage(imageRegistry.get(BASE), incChange));
+ imageRegistry.put(BASE + INCOMING + NEW, new OverlayImage(imageRegistry.get(BASE), incNew));
+ imageRegistry.put(BASE + OUTGOING + DELETE, new OverlayImage(imageRegistry.get(BASE), outDeleted));
+ imageRegistry.put(BASE + OUTGOING + CHANGE, new OverlayImage(imageRegistry.get(BASE), outChange));
+ imageRegistry.put(BASE + OUTGOING + NEW, new OverlayImage(imageRegistry.get(BASE), outNew));
+ imageRegistry.put(BASE + CONFLICTING + DELETE, new OverlayImage(imageRegistry.get(BASE), conDeleted));
+ imageRegistry.put(BASE + CONFLICTING + CHANGE, new OverlayImage(imageRegistry.get(BASE), conChange));
+ imageRegistry.put(BASE + WARNING, new OverlayImage(imageRegistry.get(BASE),
+ ArtifactAnnotation.Type.Warning.getImageOverlayDescriptor(), 0, 8));
+ imageRegistry.put(BASE + ERROR, new OverlayImage(imageRegistry.get(BASE),
+ ArtifactAnnotation.Type.Error.getImageOverlayDescriptor(), 0, 8));
+ }
+ }
+
+ /**
+ * @return Returns the imageDescriptor.
+ */
+ public InputStreamImageDescriptor getImageDescriptor() {
+ return imageDescriptor;
+ }
+
+ public String toString() {
+ return name;
+ }
+
+ /**
+ * @throws SQLException
+ */
+ public void delete() throws SQLException {
+ // delete existing artifact of this type
+ // for (Artifact artifact : artifactManager.getArtifactsFromSubtypeName(name,
+ // transactionId.getBranch())) {
+ // artifact.delete();
+ // }
+ // then delete the artifact type itself
+ // OSEE_DEFINE_ARTIFACT_TYPE needs a MODIFICATION_ID column to support deleting artifact types
+ }
+
+ /**
+ * Only store the identifying data since a manager controls this object.
+ *
+ * @param stream
+ * @throws IOException
+ */
+ private void writeObject(ObjectOutputStream stream) throws IOException {
+ stream.writeObject(name);
+ stream.writeObject(transactionId);
+ }
+
+ /**
+ * Initialize as a dumb object for portraying the object needed
+ *
+ * @param stream
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
+ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
+ name = (String) stream.readObject();
+ transactionId = (TransactionId) stream.readObject();
+ }
+
+ /**
+ * @return The ArtifactSubtypeDescriptor associated with the name and transactionId from this dumb object
+ * @throws ObjectStreamException
+ */
+ private Object readResolve() throws ObjectStreamException {
+ try {
+ return ConfigurationPersistenceManager.getInstance().getArtifactSubtypeDescriptor(name, transactionId);
+ } catch (SQLException e) {
+ throw new RuntimeException("Error while resolving descriptor", e);
+ }
+ }
+
+ /**
+ * @param imageDescriptor the imageDescriptor to set
+ */
+ public void setImageDescriptor(InputStreamImageDescriptor imageDescriptor) {
+ this.imageDescriptor = imageDescriptor;
+ // Clear out the image cache so it will be re-created
+ if (imageRegistry != null) imageRegistry = null;
+ }
+
+}
diff --git a/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/ConfigurationPersistenceManager.java b/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/ConfigurationPersistenceManager.java
index 6b942134eb7..29b53219488 100644
--- a/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/ConfigurationPersistenceManager.java
+++ b/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/ConfigurationPersistenceManager.java
@@ -1,532 +1,542 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * 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
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.osee.framework.skynet.core.attribute;
-
-import static org.eclipse.osee.framework.ui.plugin.util.db.schemas.SkynetDatabase.ARTIFACT_TYPE_TABLE;
-import static org.eclipse.osee.framework.ui.plugin.util.db.schemas.SkynetDatabase.ATTRIBUTE_BASE_TYPE_TABLE;
-import static org.eclipse.osee.framework.ui.plugin.util.db.schemas.SkynetDatabase.ATTR_BASE_TYPE_ID_SEQ;
-import static org.eclipse.osee.framework.ui.plugin.util.db.schemas.SkynetDatabase.ATTR_TYPE_ID_SEQ;
-import static org.eclipse.osee.framework.ui.plugin.util.db.schemas.SkynetDatabase.RELATION_LINK_TYPE_TABLE;
-import static org.eclipse.osee.framework.ui.plugin.util.db.schemas.SkynetDatabase.REL_LINK_TYPE_ID_SEQ;
-import java.io.ByteArrayInputStream;
-import java.net.URL;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.osee.framework.jdk.core.type.Pair;
-import org.eclipse.osee.framework.plugin.core.config.ConfigUtil;
-import org.eclipse.osee.framework.skynet.core.PersistenceManager;
-import org.eclipse.osee.framework.skynet.core.PersistenceManagerInit;
-import org.eclipse.osee.framework.skynet.core.SkynetActivator;
-import org.eclipse.osee.framework.skynet.core.artifact.Branch;
-import org.eclipse.osee.framework.skynet.core.artifact.factory.ArtifactFactoryCache;
-import org.eclipse.osee.framework.skynet.core.artifact.factory.IArtifactFactory;
-import org.eclipse.osee.framework.skynet.core.relation.DynamicRelationLinkDescriptor;
-import org.eclipse.osee.framework.skynet.core.relation.IRelationLinkDescriptor;
-import org.eclipse.osee.framework.skynet.core.relation.LinkDescriptorPersistenceMemo;
-import org.eclipse.osee.framework.skynet.core.relation.LinkSideRestriction;
-import org.eclipse.osee.framework.skynet.core.relation.RelationPersistenceManager;
-import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
-import org.eclipse.osee.framework.skynet.core.transaction.TransactionId;
-import org.eclipse.osee.framework.skynet.core.transaction.TransactionIdManager;
-import org.eclipse.osee.framework.skynet.core.transaction.data.AttributeTypeTransactionData;
-import org.eclipse.osee.framework.skynet.core.transaction.data.AttributeValidityTransactionData;
-import org.eclipse.osee.framework.skynet.core.transaction.data.RelationLinkTypeTransactionData;
-import org.eclipse.osee.framework.skynet.core.transaction.data.RelationLinkValidityTransactionData;
-import org.eclipse.osee.framework.ui.plugin.sql.SQL3DataType;
-import org.eclipse.osee.framework.ui.plugin.util.InputStreamImageDescriptor;
-import org.eclipse.osee.framework.ui.plugin.util.db.ConnectionHandler;
-import org.eclipse.osee.framework.ui.plugin.util.db.ConnectionHandlerStatement;
-import org.eclipse.osee.framework.ui.plugin.util.db.DbUtil;
-import org.eclipse.osee.framework.ui.plugin.util.db.Query;
-import org.eclipse.osee.framework.ui.plugin.util.db.schemas.SkynetDatabase;
-
-/**
- * @author Jeff C. Phillips
- */
-public class ConfigurationPersistenceManager implements PersistenceManager {
- private static final Logger logger = ConfigUtil.getConfigFactory().getLogger(ConfigurationPersistenceManager.class);
- private static final String SELECT_ATTRIBUTE_BASE_TYPE =
- "SELECT attr_base_type_id FROM " + ATTRIBUTE_BASE_TYPE_TABLE + " WHERE attribute_class = ?";
- private static final String SELECT_REL_LINK =
- "SELECT gamma_id, rel_link_type_id FROM " + RELATION_LINK_TYPE_TABLE + " WHERE type_name = ?";
- private static final String SELECT_ART_TYPE =
- "SELECT gamma_id, art_type_id FROM " + ARTIFACT_TYPE_TABLE + " WHERE name = ?";
- private final ArtifactSubtypeDescriptorCache cacheArtifactSubtypeDescriptors;
- private final DynamicAttributeDescriptorCache cacheDynamicAttributeDescriptors;
- private final AttributeTypeValidityCache cacheAttributeTypeValidity;
- private RelationPersistenceManager relationPersistenceManager;
- private ArtifactFactoryCache artifactFactoryCache;
- private TransactionIdManager transactionIdManager;
- private SkynetTransaction transaction;
- private HashMap<String, Pair<String, String>> imageMap;
- private static Pair<String, String> defaultIconLocation =
- new Pair<String, String>("org.eclipse.osee.framework.skynet.core", "images/laser_16_16.gif");
-
- private static final ConfigurationPersistenceManager instance = new ConfigurationPersistenceManager();
-
- private ConfigurationPersistenceManager() {
- super();
- this.cacheArtifactSubtypeDescriptors = new ArtifactSubtypeDescriptorCache();
- this.cacheDynamicAttributeDescriptors = new DynamicAttributeDescriptorCache();
- this.cacheAttributeTypeValidity = new AttributeTypeValidityCache();
- }
-
- public static ConfigurationPersistenceManager getInstance() {
- PersistenceManagerInit.initManagerWeb(instance);
- return instance;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.osee.framework.skynet.core.PersistenceManager#setRelatedManagers()
- */
- public void onManagerWebInit() throws Exception {
- relationPersistenceManager = RelationPersistenceManager.getInstance();
- artifactFactoryCache = ArtifactFactoryCache.getInstance();
- transactionIdManager = TransactionIdManager.getInstance();
- }
-
- public void makePersistent(Class<? extends Attribute> baseAttributeClass, String name, String defaultValue, String validityXml, int minOccurrences, int maxOccurrences, String tipText) throws SQLException {
-
- // If the attribute type does not exist add it, otherwise do nothing
- if (!cacheDynamicAttributeDescriptors.hasDescriptor(name, transaction.getBranch())) {
- checkTransaction();
-
- int attrTypeId = Query.getNextSeqVal(null, ATTR_TYPE_ID_SEQ);
- int gammaId = SkynetDatabase.getNextGammaId();
-
- int attrBaseTypeId = makePersistent(baseAttributeClass);
-
- transaction.addTransactionDataItem(new AttributeTypeTransactionData(attrTypeId, attrBaseTypeId, name,
- defaultValue, validityXml, minOccurrences, maxOccurrences, tipText, gammaId,
- transaction.getTransactionNumber()));
-
- // Add this new description to the cache
- DynamicAttributeDescriptor descriptor =
- new DynamicAttributeDescriptor(baseAttributeClass, name, defaultValue, validityXml, minOccurrences,
- maxOccurrences, tipText, attrTypeId, transaction.getTransactionId());
- cacheDynamicAttributeDescriptors.cache(descriptor);
- }
- }
-
- public int makePersistent(Class<? extends Attribute> baseClass) throws SQLException {
- int attrBaseTypeId = -1;
- String attributeClass = baseClass.getCanonicalName();
- if (attributeClass == null) {
- throw new IllegalArgumentException(
- "The baseClass argument must have a canonical name; it must be directly instantiable");
- }
-
- ConnectionHandlerStatement chStmt = null;
- try {
- chStmt = ConnectionHandler.runPreparedQuery(SELECT_ATTRIBUTE_BASE_TYPE, SQL3DataType.VARCHAR, attributeClass);
- ResultSet rSet = chStmt.getRset();
- if (rSet.next()) {
- attrBaseTypeId = rSet.getInt("attr_base_type_id");
- } else {
- attrBaseTypeId = insertAttributeBaseType(attributeClass);
- }
- } finally {
- DbUtil.close(chStmt);
- }
-
- return attrBaseTypeId;
- }
-
- protected int insertAttributeBaseType(String attributeClass) throws SQLException {
- int attrBaseTypeId = Query.getNextSeqVal(null, ATTR_BASE_TYPE_ID_SEQ);
-
- ConnectionHandler.runPreparedUpdate("INSERT INTO " + ATTRIBUTE_BASE_TYPE_TABLE + " (attr_base_type_id, attribute_class)" + " VALUES (" + attrBaseTypeId + ", '" + attributeClass + "')");
- return attrBaseTypeId;
- }
-
- /**
- * Persist a relation link type. If the <code>linkTypeName</code> is already in the database then then nothing is
- * done.
- *
- * @param linkTypeName The type name of the relation link to define.
- * @param sideAName The name for the 'a' side of the relation.
- * @param sideBName The name for the 'b' side of the relation.
- * @param abPhrasing The phrasing appropriate from the 'a' side to the 'b' side.
- * @param baPhrasing The phrasing appropriate from the 'b' side to the 'a' side.
- * @param shortName An abbreviated name to display for the link type.
- */
- public void persistRelationLinkType(String linkTypeName, String sideAName, String sideBName, String abPhrasing, String baPhrasing, String shortName, Branch branch) {
- if (linkTypeName == null || linkTypeName.equals("")) throw new IllegalArgumentException(
- "The relationName can not be null or empty");
- if (sideAName == null || sideAName.equals("")) throw new IllegalArgumentException(
- "The sideAName can not be null or empty");
- if (sideBName == null || sideBName.equals("")) throw new IllegalArgumentException(
- "The sideBName can not be null or empty");
- if (abPhrasing == null || abPhrasing.equals("")) throw new IllegalArgumentException(
- "The abPhrasing can not be null or empty");
- if (baPhrasing == null || baPhrasing.equals("")) throw new IllegalArgumentException(
- "The baPhrasing can not be null or empty");
- if (shortName == null || shortName.equals("")) throw new IllegalArgumentException(
- "The baPhrasing can not be null or empty");
-
- checkTransaction();
-
- ConnectionHandlerStatement chStmt = null;
- try {
- chStmt = ConnectionHandler.runPreparedQuery(SELECT_REL_LINK, SQL3DataType.VARCHAR, linkTypeName);
- if (chStmt.next()) {
- IRelationLinkDescriptor descriptor =
- relationPersistenceManager.getIRelationLinkDescriptor(linkTypeName, branch);
-
- if (descriptor == null) {
- transaction.addToTransactionTableBatch(chStmt.getRset().getInt("gamma_id"));
- TransactionId transactionId = transactionIdManager.getEditableTransactionId(branch);
- IRelationLinkDescriptor newDescriptor =
- new DynamicRelationLinkDescriptor(linkTypeName, sideAName, sideBName, abPhrasing, baPhrasing,
- shortName, transactionId);
- newDescriptor.setPersistenceMemo(new LinkDescriptorPersistenceMemo(chStmt.getRset().getInt(
- "rel_link_type_id")));
- relationPersistenceManager.cacheDescriptor(newDescriptor);
- }
- } else {
- // Since the relation isn't available, add the information to the database
- int relLinkTypeId =
- insertRelationInfo(linkTypeName, sideAName, sideBName, abPhrasing, baPhrasing, shortName);
-
- TransactionId transactionId = transactionIdManager.getEditableTransactionId(branch);
-
- IRelationLinkDescriptor descriptor =
- new DynamicRelationLinkDescriptor(linkTypeName, sideAName, sideBName, abPhrasing, baPhrasing,
- shortName, transactionId);
- descriptor.setPersistenceMemo(new LinkDescriptorPersistenceMemo(relLinkTypeId));
- relationPersistenceManager.cacheDescriptor(descriptor);
- }
- } catch (SQLException ex) {
- logger.log(Level.SEVERE, "Error encountered while persisting relation link type", ex);
- throw new RuntimeException(ex);
- } finally {
- DbUtil.close(chStmt);
- }
- }
-
- public int makeSubtypePersistent(String factory, String artifactTypeName, Branch branch) throws SQLException {
- return makeSubtypePersistent(factory, artifactTypeName, artifactTypeName, branch);
- }
-
- public int makeSubtypePersistent(String factoryName, String artifactTypeName, String factoryKey, Branch branch) throws SQLException {
- int artTypeId;
- ArtifactSubtypeDescriptor descriptor;
-
- ConnectionHandlerStatement chStmt = null;
- chStmt = ConnectionHandler.runPreparedQuery(SELECT_ART_TYPE, SQL3DataType.VARCHAR, artifactTypeName);
-
- if (chStmt.next()) {
- descriptor = cacheArtifactSubtypeDescriptors.getDescriptor(artifactTypeName, branch);
- if (descriptor == null) {
- artTypeId = chStmt.getRset().getInt("art_type_id");
- transaction.addToTransactionTableBatch(chStmt.getRset().getInt("gamma_id"));
- TransactionId transactionId = transactionIdManager.getEditableTransactionId(branch);
- InputStreamImageDescriptor imageDescriptor = getDefaultImageDescriptor(artifactTypeName);
- descriptor =
- new ArtifactSubtypeDescriptor(artTypeId, factoryKey,
- artifactFactoryCache.getFactoryFromName(factoryName), artifactTypeName, transactionId,
- imageDescriptor);
- cacheArtifactSubtypeDescriptors.cache(descriptor);
- } else {
- artTypeId = descriptor.getArtTypeId();
- // Check if anything valuable is different
- if (!descriptor.getFactoryKey().equals(factoryKey) || !descriptor.getFactory().getClass().getCanonicalName().equals(
- factoryName)) {
- putDescriptorInTransaction(descriptor);
- }
- }
- } else {
- descriptor = cacheArtifactSubtypeDescriptors.getDescriptor(artifactTypeName, branch);
- if (descriptor != null) {
- artTypeId = descriptor.getArtTypeId();
- // Check if anything valuable is different
- if (!descriptor.getFactoryKey().equals(factoryKey) || !descriptor.getFactory().getClass().getCanonicalName().equals(
- factoryName)) {
- putDescriptorInTransaction(descriptor);
- }
- } else {
- artTypeId = putNewDescriptorOnBranch(factoryName, artifactTypeName, factoryKey, branch);
- }
- }
- return artTypeId;
- }
-
- protected int putNewDescriptorOnBranch(String factoryName, String artifactTypeName, String factoryKey, Branch branch) throws SQLException {
- checkTransaction();
-
- ArtifactSubtypeDescriptor descriptor;
- int artTypeId = Query.getNextSeqVal(null, SkynetDatabase.ART_TYPE_ID_SEQ);
-
- // Handle null factoryKey's
- if (factoryKey == null) factoryKey = "";
-
- try {
-
- TransactionId transactionId = TransactionIdManager.getInstance().getEditableTransactionId(branch);
-
- InputStreamImageDescriptor imageDescriptor = getDefaultImageDescriptor(artifactTypeName);
- descriptor =
- new ArtifactSubtypeDescriptor(artTypeId, factoryKey,
- artifactFactoryCache.getFactoryFromName(factoryName), artifactTypeName, transactionId,
- imageDescriptor);
- putDescriptorInTransaction(descriptor);
- cacheArtifactSubtypeDescriptors.cache(descriptor);
- } catch (Exception ex) {
- throw new IllegalStateException(ex);
- }
- return descriptor.getArtTypeId();
- }
-
- private InputStreamImageDescriptor getDefaultImageDescriptor(String typeName) {
- if (imageMap == null) {
- imageMap = new HashMap<String, Pair<String, String>>();
- IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
- if (extensionRegistry != null) {
- IExtensionPoint point =
- extensionRegistry.getExtensionPoint("org.eclipse.osee.framework.skynet.core.ArtifactTypeImage");
- if (point != null) {
- IExtension[] extensions = point.getExtensions();
- for (IExtension extension : extensions) {
- IConfigurationElement[] elements = extension.getConfigurationElements();
- String artifact = null;
- String path = null;
- String bundle = null;
- for (IConfigurationElement el : elements) {
- if (el.getName().equals("ArtifactImage")) {
- artifact = el.getAttribute("ArtifactTypeName");
- path = el.getAttribute("ImagePath");
- bundle = el.getContributor().getName();
- imageMap.put(artifact, new Pair<String, String>(bundle, path));
- }
- }
- }
- }
- }
- }
- InputStreamImageDescriptor imageDescriptor;
- try {
- Pair<String, String> imagelocation = imageMap.get(typeName);
- if (imagelocation == null) {
- logger.log(Level.WARNING, "No image was defined for art type [" + typeName + "]");
- imagelocation = defaultIconLocation;
- }
- URL url = getUrl(imagelocation);
- if (url == null) {
- logger.log(Level.WARNING,
- "Unable to get url for type [" + typeName + "] bundle path " + imagelocation.getValue());
- url = getUrl(defaultIconLocation);
- }
- imageDescriptor = new InputStreamImageDescriptor(url.openStream());
- } catch (Exception ex) {
- logger.log(Level.SEVERE, "Icon for Artifact type " + typeName + " not found.", ex);
- imageDescriptor = new InputStreamImageDescriptor(new byte[0]);
- }
-
- return imageDescriptor;
- }
-
- private URL getUrl(Pair<String, String> location) {
- return Platform.getBundle(location.getKey()).getEntry(location.getValue());
- }
-
- private void putDescriptorInTransaction(ArtifactSubtypeDescriptor descriptor) throws SQLException {
- checkTransaction();
-
- int gammaId = SkynetDatabase.getNextGammaId();
-
- transaction.addToTransactionTableBatch(gammaId);
- transaction.addToBatch(
- "INSERT INTO " + ARTIFACT_TYPE_TABLE + " (art_type_id, factory_id, name, factory_key, gamma_id, image)" + " VALUES (?,?,?,?,?,?)",
- SQL3DataType.INTEGER, descriptor.getArtTypeId(), SQL3DataType.INTEGER,
- descriptor.getFactory().getFactoryId(), SQL3DataType.VARCHAR, descriptor.getName(), SQL3DataType.VARCHAR,
- descriptor.getFactoryKey(), SQL3DataType.INTEGER, gammaId, SQL3DataType.BLOB, new ByteArrayInputStream(
- descriptor.getImageDescriptor().getData()));
- }
-
- /**
- * Persists that a particular user defined attribute is valid for some artifact type.
- *
- * @param attributeType
- * @param artifactType
- * @throws SQLException
- */
- public void persistAttributeValidity(DynamicAttributeDescriptor attributeType, ArtifactSubtypeDescriptor artifactType) throws SQLException {
- checkTransaction();
-
- Collection<DynamicAttributeDescriptor> validityMap =
- cacheAttributeTypeValidity.getValidAttributeDescriptors(artifactType);
- if (validityMap == null || !validityMap.contains(attributeType)) {
- int gammaId = SkynetDatabase.getNextGammaId();
-
- cacheAttributeTypeValidity.add(attributeType, artifactType);
- transaction.addTransactionDataItem(new AttributeValidityTransactionData(artifactType.getArtTypeId(),
- attributeType.getAttrTypeId(), gammaId, transaction.getTransactionNumber()));
- }
- }
-
- public Collection<ArtifactSubtypeDescriptor> getArtifactSubtypeDescriptorsForAttribute(DynamicAttributeDescriptor attributeType) throws SQLException {
- return cacheAttributeTypeValidity.getArtifactSubtypeDescriptorsForAttribute(attributeType);
- }
-
- public ArtifactSubtypeDescriptor getArtifactSubtypeDescriptor(String name, Branch branch) throws SQLException {
- return cacheArtifactSubtypeDescriptors.getDescriptor(name, branch);
- }
-
- public Collection<ArtifactSubtypeDescriptor> getArtifactSubtypeDescriptors(Branch branch) throws SQLException {
- return cacheArtifactSubtypeDescriptors.getAllDescriptors(branch);
- }
-
- public ArtifactSubtypeDescriptor getArtifactSubtypeDescriptor(String name, TransactionId transactionId) throws SQLException {
- return cacheArtifactSubtypeDescriptors.getDescriptor(name, transactionId);
- }
-
- public Set<ArtifactSubtypeDescriptor> getArtifactSubtypeDescriptors(TransactionId transactionId) throws SQLException {
- return cacheArtifactSubtypeDescriptors.getAllDescriptors(transactionId);
- }
-
- public DynamicAttributeDescriptor getDynamicAttributeType(int attrTypeId, Branch branch) throws SQLException {
- return cacheDynamicAttributeDescriptors.getDescriptor(attrTypeId, branch);
- }
-
- public DynamicAttributeDescriptor getDynamicAttributeType(int attrTypeId, TransactionId transactionId) throws SQLException {
- return cacheDynamicAttributeDescriptors.getDescriptor(attrTypeId, transactionId);
- }
-
- public DynamicAttributeDescriptor getDynamicAttributeType(String attributeName, Branch branch) throws SQLException {
- return cacheDynamicAttributeDescriptors.getDescriptor(attributeName, branch);
- }
-
- public Collection<DynamicAttributeDescriptor> getDynamicAttributeDescriptors(Branch branch) throws SQLException {
- return cacheDynamicAttributeDescriptors.getAllDescriptors(branch);
- }
-
- public DynamicAttributeDescriptor getDynamicAttributeType(String attributeName, TransactionId transactionId) throws SQLException {
- return cacheDynamicAttributeDescriptors.getDescriptor(attributeName, transactionId);
- }
-
- public Collection<DynamicAttributeDescriptor> getDynamicAttributeDescriptors(TransactionId transactionId) throws SQLException {
- return cacheDynamicAttributeDescriptors.getAllDescriptors(transactionId);
- }
-
- public Collection<DynamicAttributeDescriptor> getAttributeTypesFromArtifactType(ArtifactSubtypeDescriptor descriptor) throws SQLException {
- return cacheAttributeTypeValidity.getValidAttributeDescriptors(descriptor);
- }
-
- public Set<String> getValidEnumerationAttributeValues(String attributeName, Branch branch) {
- Set<String> names = new HashSet<String>();
- try {
- DynamicAttributeDescriptor dad =
- ConfigurationPersistenceManager.getInstance().getDynamicAttributeType(attributeName, branch);
- String str = dad.getValidityXml();
- Matcher m = Pattern.compile("<Enum>(.*?)</Enum>").matcher(str);
- while (m.find())
- names.add(m.group(1));
- } catch (Exception ex) {
- SkynetActivator.getLogger().log(Level.SEVERE, "Error getting valid enumeration values", ex);
- }
- return names;
- }
-
- public int insertRelationInfo(String linkTypeName, String sideAName, String sideBName, String abPhrasing, String baPhrasing, String shortName) throws SQLException {
-
- int relLinkTypeId = Query.getNextSeqVal(null, REL_LINK_TYPE_ID_SEQ);
- int gammaId = SkynetDatabase.getNextGammaId();
-
- transaction.addTransactionDataItem(new RelationLinkTypeTransactionData(relLinkTypeId, linkTypeName, sideAName,
- sideBName, abPhrasing, baPhrasing, shortName, gammaId, transaction.getTransactionNumber()));
-
- return relLinkTypeId;
- }
-
- public void persistRelationLinkValidity(ArtifactSubtypeDescriptor artDescriptor, IRelationLinkDescriptor linkDescriptor, int sideAMax, int sideBMax) {
-
- checkTransaction();
-
- if (artDescriptor == null) throw new IllegalArgumentException("The artDescriptor can no be null");
- if (linkDescriptor == null) throw new IllegalArgumentException("The linkDescriptor can no be null");
- if (sideAMax < 0) throw new IllegalArgumentException("The sideAMax can no be negative");
- if (sideBMax < 0) throw new IllegalArgumentException("The sideBMax can no be negative");
-
- int artTypeId = artDescriptor.getArtTypeId();
- int relLinkTypeId = linkDescriptor.getPersistenceMemo().getLinkTypeId();
-
- try {
- // If this validity is already the current case, then ignore
- if (linkDescriptor.canLinkType(artTypeId) && linkDescriptor.getRestrictionSizeFor(artTypeId, true) == sideAMax && linkDescriptor.getRestrictionSizeFor(
- artTypeId, false) == sideBMax) return;
-
- int gammaId = SkynetDatabase.getNextGammaId();
-
- transaction.addTransactionDataItem(new RelationLinkValidityTransactionData(artTypeId, relLinkTypeId, sideAMax,
- sideBMax, gammaId, transaction.getTransactionNumber()));
-
- linkDescriptor.setLinkSideRestriction(artDescriptor.getArtTypeId(),
- new LinkSideRestriction(sideAMax, sideBMax));
- } catch (SQLException ex) {
- logger.log(Level.SEVERE, "Error encountered while persisting relation link type", ex);
- throw new RuntimeException(ex);
- }
- }
-
- public void startBatch(Branch branch) throws SQLException {
- // NOTE: the transaction level must be started before getting a SkynetTransaction since it may
- // perform SQL
- ConnectionHandler.startTransactionLevel(this);
- transaction = new SkynetTransaction(branch);
- }
-
- /**
- * Executes the transaction and then resets the transaction.
- */
- public void executeBatch() throws SQLException {
- checkTransaction();
-
- try {
- transaction.execute();
- ConnectionHandler.setTransactionLevelAsSuccessful(this);
- } finally {
- ConnectionHandler.endTransactionLevel(this);
- transaction = null;
- }
- }
-
- private void checkTransaction() {
- if (transaction == null) throw new RuntimeException("Batch has not been started");
- }
-
- public ArtifactSubtypeDescriptor getArtifactSubtypeDescriptor(int artTypeId, TransactionId transactionId) throws SQLException {
- return cacheArtifactSubtypeDescriptors.getDescriptor(artTypeId, transactionId);
- }
-
- public IArtifactFactory getFactoryFromId(int factoryId) {
- return artifactFactoryCache.getFactoryFromId(factoryId);
- }
-
- public IArtifactFactory getFactoryFromName(String factoryName) throws IllegalStateException {
- return artifactFactoryCache.getFactoryFromName(factoryName);
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.osee.framework.skynet.core.attribute;
+
+import static org.eclipse.osee.framework.ui.plugin.util.db.schemas.SkynetDatabase.ARTIFACT_TYPE_TABLE;
+import static org.eclipse.osee.framework.ui.plugin.util.db.schemas.SkynetDatabase.ATTRIBUTE_BASE_TYPE_TABLE;
+import static org.eclipse.osee.framework.ui.plugin.util.db.schemas.SkynetDatabase.ATTR_BASE_TYPE_ID_SEQ;
+import static org.eclipse.osee.framework.ui.plugin.util.db.schemas.SkynetDatabase.ATTR_TYPE_ID_SEQ;
+import static org.eclipse.osee.framework.ui.plugin.util.db.schemas.SkynetDatabase.RELATION_LINK_TYPE_TABLE;
+import static org.eclipse.osee.framework.ui.plugin.util.db.schemas.SkynetDatabase.REL_LINK_TYPE_ID_SEQ;
+import java.io.ByteArrayInputStream;
+import java.net.URL;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.osee.framework.jdk.core.type.Pair;
+import org.eclipse.osee.framework.plugin.core.config.ConfigUtil;
+import org.eclipse.osee.framework.skynet.core.PersistenceManager;
+import org.eclipse.osee.framework.skynet.core.PersistenceManagerInit;
+import org.eclipse.osee.framework.skynet.core.SkynetActivator;
+import org.eclipse.osee.framework.skynet.core.artifact.Branch;
+import org.eclipse.osee.framework.skynet.core.artifact.factory.ArtifactFactoryCache;
+import org.eclipse.osee.framework.skynet.core.artifact.factory.IArtifactFactory;
+import org.eclipse.osee.framework.skynet.core.relation.DynamicRelationLinkDescriptor;
+import org.eclipse.osee.framework.skynet.core.relation.IRelationLinkDescriptor;
+import org.eclipse.osee.framework.skynet.core.relation.LinkDescriptorPersistenceMemo;
+import org.eclipse.osee.framework.skynet.core.relation.LinkSideRestriction;
+import org.eclipse.osee.framework.skynet.core.relation.RelationPersistenceManager;
+import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
+import org.eclipse.osee.framework.skynet.core.transaction.TransactionId;
+import org.eclipse.osee.framework.skynet.core.transaction.TransactionIdManager;
+import org.eclipse.osee.framework.skynet.core.transaction.data.AttributeTypeTransactionData;
+import org.eclipse.osee.framework.skynet.core.transaction.data.AttributeValidityTransactionData;
+import org.eclipse.osee.framework.skynet.core.transaction.data.RelationLinkTypeTransactionData;
+import org.eclipse.osee.framework.skynet.core.transaction.data.RelationLinkValidityTransactionData;
+import org.eclipse.osee.framework.ui.plugin.sql.SQL3DataType;
+import org.eclipse.osee.framework.ui.plugin.util.InputStreamImageDescriptor;
+import org.eclipse.osee.framework.ui.plugin.util.db.ConnectionHandler;
+import org.eclipse.osee.framework.ui.plugin.util.db.ConnectionHandlerStatement;
+import org.eclipse.osee.framework.ui.plugin.util.db.DbUtil;
+import org.eclipse.osee.framework.ui.plugin.util.db.Query;
+import org.eclipse.osee.framework.ui.plugin.util.db.schemas.SkynetDatabase;
+
+/**
+ * @author Jeff C. Phillips
+ */
+public class ConfigurationPersistenceManager implements PersistenceManager {
+ private static final Logger logger = ConfigUtil.getConfigFactory().getLogger(ConfigurationPersistenceManager.class);
+ private static final String SELECT_ATTRIBUTE_BASE_TYPE =
+ "SELECT attr_base_type_id FROM " + ATTRIBUTE_BASE_TYPE_TABLE + " WHERE attribute_class = ?";
+ private static final String SELECT_REL_LINK =
+ "SELECT gamma_id, rel_link_type_id FROM " + RELATION_LINK_TYPE_TABLE + " WHERE type_name = ?";
+ private static final String SELECT_ART_TYPE =
+ "SELECT gamma_id, art_type_id FROM " + ARTIFACT_TYPE_TABLE + " WHERE name = ?";
+ private final ArtifactSubtypeDescriptorCache cacheArtifactSubtypeDescriptors;
+ private final DynamicAttributeDescriptorCache cacheDynamicAttributeDescriptors;
+ private final AttributeTypeValidityCache cacheAttributeTypeValidity;
+ private RelationPersistenceManager relationPersistenceManager;
+ private ArtifactFactoryCache artifactFactoryCache;
+ private TransactionIdManager transactionIdManager;
+ private SkynetTransaction transaction;
+ private HashMap<String, Pair<String, String>> imageMap;
+ private static Pair<String, String> defaultIconLocation =
+ new Pair<String, String>("org.eclipse.osee.framework.skynet.core", "images/laser_16_16.gif");
+
+ private static final ConfigurationPersistenceManager instance = new ConfigurationPersistenceManager();
+
+ private ConfigurationPersistenceManager() {
+ super();
+ this.cacheArtifactSubtypeDescriptors = new ArtifactSubtypeDescriptorCache();
+ this.cacheDynamicAttributeDescriptors = new DynamicAttributeDescriptorCache();
+ this.cacheAttributeTypeValidity = new AttributeTypeValidityCache();
+ }
+
+ public static ConfigurationPersistenceManager getInstance() {
+ PersistenceManagerInit.initManagerWeb(instance);
+ return instance;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.osee.framework.skynet.core.PersistenceManager#setRelatedManagers()
+ */
+ public void onManagerWebInit() throws Exception {
+ relationPersistenceManager = RelationPersistenceManager.getInstance();
+ artifactFactoryCache = ArtifactFactoryCache.getInstance();
+ transactionIdManager = TransactionIdManager.getInstance();
+ }
+
+ public void makePersistent(Class<? extends Attribute> baseAttributeClass, String name, String defaultValue, String validityXml, int minOccurrences, int maxOccurrences, String tipText) throws SQLException {
+
+ // If the attribute type does not exist add it, otherwise do nothing
+ if (!cacheDynamicAttributeDescriptors.hasDescriptor(name, transaction.getBranch())) {
+ checkTransaction();
+
+ int attrTypeId = Query.getNextSeqVal(null, ATTR_TYPE_ID_SEQ);
+ int gammaId = SkynetDatabase.getNextGammaId();
+
+ int attrBaseTypeId = makePersistent(baseAttributeClass);
+
+ transaction.addTransactionDataItem(new AttributeTypeTransactionData(attrTypeId, attrBaseTypeId, name,
+ defaultValue, validityXml, minOccurrences, maxOccurrences, tipText, gammaId,
+ transaction.getTransactionNumber()));
+
+ // Add this new description to the cache
+ DynamicAttributeDescriptor descriptor =
+ new DynamicAttributeDescriptor(baseAttributeClass, name, defaultValue, validityXml, minOccurrences,
+ maxOccurrences, tipText, attrTypeId, transaction.getTransactionId());
+ cacheDynamicAttributeDescriptors.cache(descriptor);
+ }
+ }
+
+ public int makePersistent(Class<? extends Attribute> baseClass) throws SQLException {
+ int attrBaseTypeId = -1;
+ String attributeClass = baseClass.getCanonicalName();
+ if (attributeClass == null) {
+ throw new IllegalArgumentException(
+ "The baseClass argument must have a canonical name; it must be directly instantiable");
+ }
+
+ ConnectionHandlerStatement chStmt = null;
+ try {
+ chStmt = ConnectionHandler.runPreparedQuery(SELECT_ATTRIBUTE_BASE_TYPE, SQL3DataType.VARCHAR, attributeClass);
+ ResultSet rSet = chStmt.getRset();
+ if (rSet.next()) {
+ attrBaseTypeId = rSet.getInt("attr_base_type_id");
+ } else {
+ attrBaseTypeId = insertAttributeBaseType(attributeClass);
+ }
+ } finally {
+ DbUtil.close(chStmt);
+ }
+
+ return attrBaseTypeId;
+ }
+
+ protected int insertAttributeBaseType(String attributeClass) throws SQLException {
+ int attrBaseTypeId = Query.getNextSeqVal(null, ATTR_BASE_TYPE_ID_SEQ);
+
+ ConnectionHandler.runPreparedUpdate("INSERT INTO " + ATTRIBUTE_BASE_TYPE_TABLE + " (attr_base_type_id, attribute_class)" + " VALUES (" + attrBaseTypeId + ", '" + attributeClass + "')");
+ return attrBaseTypeId;
+ }
+
+ /**
+ * Persist a relation link type. If the <code>linkTypeName</code> is already in the database then then nothing is
+ * done.
+ *
+ * @param linkTypeName The type name of the relation link to define.
+ * @param sideAName The name for the 'a' side of the relation.
+ * @param sideBName The name for the 'b' side of the relation.
+ * @param abPhrasing The phrasing appropriate from the 'a' side to the 'b' side.
+ * @param baPhrasing The phrasing appropriate from the 'b' side to the 'a' side.
+ * @param shortName An abbreviated name to display for the link type.
+ */
+ public void persistRelationLinkType(String linkTypeName, String sideAName, String sideBName, String abPhrasing, String baPhrasing, String shortName, Branch branch) {
+ if (linkTypeName == null || linkTypeName.equals("")) throw new IllegalArgumentException(
+ "The relationName can not be null or empty");
+ if (sideAName == null || sideAName.equals("")) throw new IllegalArgumentException(
+ "The sideAName can not be null or empty");
+ if (sideBName == null || sideBName.equals("")) throw new IllegalArgumentException(
+ "The sideBName can not be null or empty");
+ if (abPhrasing == null || abPhrasing.equals("")) throw new IllegalArgumentException(
+ "The abPhrasing can not be null or empty");
+ if (baPhrasing == null || baPhrasing.equals("")) throw new IllegalArgumentException(
+ "The baPhrasing can not be null or empty");
+ if (shortName == null || shortName.equals("")) throw new IllegalArgumentException(
+ "The baPhrasing can not be null or empty");
+
+ checkTransaction();
+
+ ConnectionHandlerStatement chStmt = null;
+ try {
+ chStmt = ConnectionHandler.runPreparedQuery(SELECT_REL_LINK, SQL3DataType.VARCHAR, linkTypeName);
+ if (chStmt.next()) {
+ IRelationLinkDescriptor descriptor =
+ relationPersistenceManager.getIRelationLinkDescriptor(linkTypeName, branch);
+
+ if (descriptor == null) {
+ transaction.addToTransactionTableBatch(chStmt.getRset().getInt("gamma_id"));
+ TransactionId transactionId = transactionIdManager.getEditableTransactionId(branch);
+ IRelationLinkDescriptor newDescriptor =
+ new DynamicRelationLinkDescriptor(linkTypeName, sideAName, sideBName, abPhrasing, baPhrasing,
+ shortName, transactionId);
+ newDescriptor.setPersistenceMemo(new LinkDescriptorPersistenceMemo(chStmt.getRset().getInt(
+ "rel_link_type_id")));
+ relationPersistenceManager.cacheDescriptor(newDescriptor);
+ }
+ } else {
+ // Since the relation isn't available, add the information to the database
+ int relLinkTypeId =
+ insertRelationInfo(linkTypeName, sideAName, sideBName, abPhrasing, baPhrasing, shortName);
+
+ TransactionId transactionId = transactionIdManager.getEditableTransactionId(branch);
+
+ IRelationLinkDescriptor descriptor =
+ new DynamicRelationLinkDescriptor(linkTypeName, sideAName, sideBName, abPhrasing, baPhrasing,
+ shortName, transactionId);
+ descriptor.setPersistenceMemo(new LinkDescriptorPersistenceMemo(relLinkTypeId));
+ relationPersistenceManager.cacheDescriptor(descriptor);
+ }
+ } catch (SQLException ex) {
+ logger.log(Level.SEVERE, "Error encountered while persisting relation link type", ex);
+ throw new RuntimeException(ex);
+ } finally {
+ DbUtil.close(chStmt);
+ }
+ }
+
+ public int makeSubtypePersistent(String factory, String artifactTypeName, Branch branch) throws SQLException {
+ return makeSubtypePersistent(factory, artifactTypeName, artifactTypeName, branch);
+ }
+
+ public int makeSubtypePersistent(String factoryName, String artifactTypeName, String factoryKey, Branch branch) throws SQLException {
+ int artTypeId;
+ ArtifactSubtypeDescriptor descriptor;
+
+ ConnectionHandlerStatement chStmt = null;
+ chStmt = ConnectionHandler.runPreparedQuery(SELECT_ART_TYPE, SQL3DataType.VARCHAR, artifactTypeName);
+
+ if (chStmt.next()) {
+ descriptor = cacheArtifactSubtypeDescriptors.getDescriptor(artifactTypeName, branch);
+ if (descriptor == null) {
+ artTypeId = chStmt.getRset().getInt("art_type_id");
+ transaction.addToTransactionTableBatch(chStmt.getRset().getInt("gamma_id"));
+ TransactionId transactionId = transactionIdManager.getEditableTransactionId(branch);
+ InputStreamImageDescriptor imageDescriptor = getDefaultImageDescriptor(artifactTypeName);
+ descriptor =
+ new ArtifactSubtypeDescriptor(artTypeId, factoryKey,
+ artifactFactoryCache.getFactoryFromName(factoryName), artifactTypeName, transactionId,
+ imageDescriptor);
+ cacheArtifactSubtypeDescriptors.cache(descriptor);
+ } else {
+ artTypeId = descriptor.getArtTypeId();
+ // Check if anything valuable is different
+ if (!descriptor.getFactoryKey().equals(factoryKey) || !descriptor.getFactory().getClass().getCanonicalName().equals(
+ factoryName)) {
+ putDescriptorInTransaction(descriptor);
+ }
+ }
+ } else {
+ descriptor = cacheArtifactSubtypeDescriptors.getDescriptor(artifactTypeName, branch);
+ if (descriptor != null) {
+ artTypeId = descriptor.getArtTypeId();
+ // Check if anything valuable is different
+ if (!descriptor.getFactoryKey().equals(factoryKey) || !descriptor.getFactory().getClass().getCanonicalName().equals(
+ factoryName)) {
+ putDescriptorInTransaction(descriptor);
+ }
+ } else {
+ artTypeId = putNewDescriptorOnBranch(factoryName, artifactTypeName, factoryKey, branch);
+ }
+ }
+ return artTypeId;
+ }
+
+ protected int putNewDescriptorOnBranch(String factoryName, String artifactTypeName, String factoryKey, Branch branch) throws SQLException {
+ checkTransaction();
+
+ ArtifactSubtypeDescriptor descriptor;
+ int artTypeId = Query.getNextSeqVal(null, SkynetDatabase.ART_TYPE_ID_SEQ);
+
+ // Handle null factoryKey's
+ if (factoryKey == null) factoryKey = "";
+
+ try {
+
+ TransactionId transactionId = TransactionIdManager.getInstance().getEditableTransactionId(branch);
+
+ InputStreamImageDescriptor imageDescriptor = getDefaultImageDescriptor(artifactTypeName);
+ descriptor =
+ new ArtifactSubtypeDescriptor(artTypeId, factoryKey,
+ artifactFactoryCache.getFactoryFromName(factoryName), artifactTypeName, transactionId,
+ imageDescriptor);
+ putDescriptorInTransaction(descriptor);
+ cacheArtifactSubtypeDescriptors.cache(descriptor);
+ } catch (Exception ex) {
+ throw new IllegalStateException(ex);
+ }
+ return descriptor.getArtTypeId();
+ }
+
+ private InputStreamImageDescriptor getDefaultImageDescriptor(String typeName) {
+ if (imageMap == null) {
+ imageMap = new HashMap<String, Pair<String, String>>();
+ IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
+ if (extensionRegistry != null) {
+ IExtensionPoint point =
+ extensionRegistry.getExtensionPoint("org.eclipse.osee.framework.skynet.core.ArtifactTypeImage");
+ if (point != null) {
+ IExtension[] extensions = point.getExtensions();
+ for (IExtension extension : extensions) {
+ IConfigurationElement[] elements = extension.getConfigurationElements();
+ String artifact = null;
+ String path = null;
+ String bundle = null;
+ for (IConfigurationElement el : elements) {
+ if (el.getName().equals("ArtifactImage")) {
+ artifact = el.getAttribute("ArtifactTypeName");
+ path = el.getAttribute("ImagePath");
+ bundle = el.getContributor().getName();
+ imageMap.put(artifact, new Pair<String, String>(bundle, path));
+ }
+ }
+ }
+ }
+ }
+ }
+ InputStreamImageDescriptor imageDescriptor;
+ try {
+ Pair<String, String> imagelocation = imageMap.get(typeName);
+ if (imagelocation == null) {
+ logger.log(Level.WARNING, "No image was defined for art type [" + typeName + "]");
+ imagelocation = defaultIconLocation;
+ }
+ URL url = getUrl(imagelocation);
+ if (url == null) {
+ logger.log(Level.WARNING,
+ "Unable to get url for type [" + typeName + "] bundle path " + imagelocation.getValue());
+ url = getUrl(defaultIconLocation);
+ }
+ imageDescriptor = new InputStreamImageDescriptor(url.openStream());
+ } catch (Exception ex) {
+ logger.log(Level.SEVERE, "Icon for Artifact type " + typeName + " not found.", ex);
+ imageDescriptor = new InputStreamImageDescriptor(new byte[0]);
+ }
+
+ return imageDescriptor;
+ }
+
+ private URL getUrl(Pair<String, String> location) {
+ return Platform.getBundle(location.getKey()).getEntry(location.getValue());
+ }
+
+ private void putDescriptorInTransaction(ArtifactSubtypeDescriptor descriptor) throws SQLException {
+ checkTransaction();
+
+ int gammaId = SkynetDatabase.getNextGammaId();
+
+ transaction.addToTransactionTableBatch(gammaId);
+ transaction.addToBatch(
+ "INSERT INTO " + ARTIFACT_TYPE_TABLE + " (art_type_id, factory_id, name, factory_key, gamma_id, image)" + " VALUES (?,?,?,?,?,?)",
+ SQL3DataType.INTEGER, descriptor.getArtTypeId(), SQL3DataType.INTEGER,
+ descriptor.getFactory().getFactoryId(), SQL3DataType.VARCHAR, descriptor.getName(), SQL3DataType.VARCHAR,
+ descriptor.getFactoryKey(), SQL3DataType.INTEGER, gammaId, SQL3DataType.BLOB, new ByteArrayInputStream(
+ descriptor.getImageDescriptor().getData()));
+ }
+
+ public static void updateArtifactTypeImage(ArtifactSubtypeDescriptor descriptor, InputStreamImageDescriptor imageDescriptor) throws SQLException {
+ // Update DB
+ ConnectionHandler.runPreparedUpdate("UPDATE " + ARTIFACT_TYPE_TABLE + " SET image = ? where art_type_id = ?",
+ SQL3DataType.BLOB, new ByteArrayInputStream(imageDescriptor.getData()), SQL3DataType.INTEGER,
+ descriptor.getArtTypeId());
+
+ // TODO Update descriptor's cached copy of image
+ descriptor.setImageDescriptor(imageDescriptor);
+ }
+
+ /**
+ * Persists that a particular user defined attribute is valid for some artifact type.
+ *
+ * @param attributeType
+ * @param artifactType
+ * @throws SQLException
+ */
+ public void persistAttributeValidity(DynamicAttributeDescriptor attributeType, ArtifactSubtypeDescriptor artifactType) throws SQLException {
+ checkTransaction();
+
+ Collection<DynamicAttributeDescriptor> validityMap =
+ cacheAttributeTypeValidity.getValidAttributeDescriptors(artifactType);
+ if (validityMap == null || !validityMap.contains(attributeType)) {
+ int gammaId = SkynetDatabase.getNextGammaId();
+
+ cacheAttributeTypeValidity.add(attributeType, artifactType);
+ transaction.addTransactionDataItem(new AttributeValidityTransactionData(artifactType.getArtTypeId(),
+ attributeType.getAttrTypeId(), gammaId, transaction.getTransactionNumber()));
+ }
+ }
+
+ public Collection<ArtifactSubtypeDescriptor> getArtifactSubtypeDescriptorsForAttribute(DynamicAttributeDescriptor attributeType) throws SQLException {
+ return cacheAttributeTypeValidity.getArtifactSubtypeDescriptorsForAttribute(attributeType);
+ }
+
+ public ArtifactSubtypeDescriptor getArtifactSubtypeDescriptor(String name, Branch branch) throws SQLException {
+ return cacheArtifactSubtypeDescriptors.getDescriptor(name, branch);
+ }
+
+ public Collection<ArtifactSubtypeDescriptor> getArtifactSubtypeDescriptors(Branch branch) throws SQLException {
+ return cacheArtifactSubtypeDescriptors.getAllDescriptors(branch);
+ }
+
+ public ArtifactSubtypeDescriptor getArtifactSubtypeDescriptor(String name, TransactionId transactionId) throws SQLException {
+ return cacheArtifactSubtypeDescriptors.getDescriptor(name, transactionId);
+ }
+
+ public Set<ArtifactSubtypeDescriptor> getArtifactSubtypeDescriptors(TransactionId transactionId) throws SQLException {
+ return cacheArtifactSubtypeDescriptors.getAllDescriptors(transactionId);
+ }
+
+ public DynamicAttributeDescriptor getDynamicAttributeType(int attrTypeId, Branch branch) throws SQLException {
+ return cacheDynamicAttributeDescriptors.getDescriptor(attrTypeId, branch);
+ }
+
+ public DynamicAttributeDescriptor getDynamicAttributeType(int attrTypeId, TransactionId transactionId) throws SQLException {
+ return cacheDynamicAttributeDescriptors.getDescriptor(attrTypeId, transactionId);
+ }
+
+ public DynamicAttributeDescriptor getDynamicAttributeType(String attributeName, Branch branch) throws SQLException {
+ return cacheDynamicAttributeDescriptors.getDescriptor(attributeName, branch);
+ }
+
+ public Collection<DynamicAttributeDescriptor> getDynamicAttributeDescriptors(Branch branch) throws SQLException {
+ return cacheDynamicAttributeDescriptors.getAllDescriptors(branch);
+ }
+
+ public DynamicAttributeDescriptor getDynamicAttributeType(String attributeName, TransactionId transactionId) throws SQLException {
+ return cacheDynamicAttributeDescriptors.getDescriptor(attributeName, transactionId);
+ }
+
+ public Collection<DynamicAttributeDescriptor> getDynamicAttributeDescriptors(TransactionId transactionId) throws SQLException {
+ return cacheDynamicAttributeDescriptors.getAllDescriptors(transactionId);
+ }
+
+ public Collection<DynamicAttributeDescriptor> getAttributeTypesFromArtifactType(ArtifactSubtypeDescriptor descriptor) throws SQLException {
+ return cacheAttributeTypeValidity.getValidAttributeDescriptors(descriptor);
+ }
+
+ public Set<String> getValidEnumerationAttributeValues(String attributeName, Branch branch) {
+ Set<String> names = new HashSet<String>();
+ try {
+ DynamicAttributeDescriptor dad =
+ ConfigurationPersistenceManager.getInstance().getDynamicAttributeType(attributeName, branch);
+ String str = dad.getValidityXml();
+ Matcher m = Pattern.compile("<Enum>(.*?)</Enum>").matcher(str);
+ while (m.find())
+ names.add(m.group(1));
+ } catch (Exception ex) {
+ SkynetActivator.getLogger().log(Level.SEVERE, "Error getting valid enumeration values", ex);
+ }
+ return names;
+ }
+
+ public int insertRelationInfo(String linkTypeName, String sideAName, String sideBName, String abPhrasing, String baPhrasing, String shortName) throws SQLException {
+
+ int relLinkTypeId = Query.getNextSeqVal(null, REL_LINK_TYPE_ID_SEQ);
+ int gammaId = SkynetDatabase.getNextGammaId();
+
+ transaction.addTransactionDataItem(new RelationLinkTypeTransactionData(relLinkTypeId, linkTypeName, sideAName,
+ sideBName, abPhrasing, baPhrasing, shortName, gammaId, transaction.getTransactionNumber()));
+
+ return relLinkTypeId;
+ }
+
+ public void persistRelationLinkValidity(ArtifactSubtypeDescriptor artDescriptor, IRelationLinkDescriptor linkDescriptor, int sideAMax, int sideBMax) {
+
+ checkTransaction();
+
+ if (artDescriptor == null) throw new IllegalArgumentException("The artDescriptor can no be null");
+ if (linkDescriptor == null) throw new IllegalArgumentException("The linkDescriptor can no be null");
+ if (sideAMax < 0) throw new IllegalArgumentException("The sideAMax can no be negative");
+ if (sideBMax < 0) throw new IllegalArgumentException("The sideBMax can no be negative");
+
+ int artTypeId = artDescriptor.getArtTypeId();
+ int relLinkTypeId = linkDescriptor.getPersistenceMemo().getLinkTypeId();
+
+ try {
+ // If this validity is already the current case, then ignore
+ if (linkDescriptor.canLinkType(artTypeId) && linkDescriptor.getRestrictionSizeFor(artTypeId, true) == sideAMax && linkDescriptor.getRestrictionSizeFor(
+ artTypeId, false) == sideBMax) return;
+
+ int gammaId = SkynetDatabase.getNextGammaId();
+
+ transaction.addTransactionDataItem(new RelationLinkValidityTransactionData(artTypeId, relLinkTypeId, sideAMax,
+ sideBMax, gammaId, transaction.getTransactionNumber()));
+
+ linkDescriptor.setLinkSideRestriction(artDescriptor.getArtTypeId(),
+ new LinkSideRestriction(sideAMax, sideBMax));
+ } catch (SQLException ex) {
+ logger.log(Level.SEVERE, "Error encountered while persisting relation link type", ex);
+ throw new RuntimeException(ex);
+ }
+ }
+
+ public void startBatch(Branch branch) throws SQLException {
+ // NOTE: the transaction level must be started before getting a SkynetTransaction since it may
+ // perform SQL
+ ConnectionHandler.startTransactionLevel(this);
+ transaction = new SkynetTransaction(branch);
+ }
+
+ /**
+ * Executes the transaction and then resets the transaction.
+ */
+ public void executeBatch() throws SQLException {
+ checkTransaction();
+
+ try {
+ transaction.execute();
+ ConnectionHandler.setTransactionLevelAsSuccessful(this);
+ } finally {
+ ConnectionHandler.endTransactionLevel(this);
+ transaction = null;
+ }
+ }
+
+ private void checkTransaction() {
+ if (transaction == null) throw new RuntimeException("Batch has not been started");
+ }
+
+ public ArtifactSubtypeDescriptor getArtifactSubtypeDescriptor(int artTypeId, TransactionId transactionId) throws SQLException {
+ return cacheArtifactSubtypeDescriptors.getDescriptor(artTypeId, transactionId);
+ }
+
+ public IArtifactFactory getFactoryFromId(int factoryId) {
+ return artifactFactoryCache.getFactoryFromId(factoryId);
+ }
+
+ public IArtifactFactory getFactoryFromName(String factoryName) throws IllegalStateException {
+ return artifactFactoryCache.getFactoryFromName(factoryName);
+ }
+}
diff --git a/org.eclipse.osee.framework.ui.skynet/images/file.gif b/org.eclipse.osee.framework.ui.skynet/images/file.gif
new file mode 100644
index 00000000000..d05c905d2da
--- /dev/null
+++ b/org.eclipse.osee.framework.ui.skynet/images/file.gif
Binary files differ
diff --git a/org.eclipse.osee.framework.ui.skynet/plugin.xml b/org.eclipse.osee.framework.ui.skynet/plugin.xml
index 6716ad72fbd..a243f556e55 100644
--- a/org.eclipse.osee.framework.ui.skynet/plugin.xml
+++ b/org.eclipse.osee.framework.ui.skynet/plugin.xml
@@ -546,5 +546,11 @@
<Operation
className="org.eclipse.osee.framework.ui.skynet.blam.operation.DeleteArchivedBranches">
</Operation>
- </extension>
+ </extension>
+ <extension
+ point="org.eclipse.osee.framework.ui.skynet.BlamOperation">
+ <Operation
+ className="org.eclipse.osee.framework.ui.skynet.blam.operation.UpdateArtifactTypeImage">
+ </Operation>
+ </extension>
</plugin>
diff --git a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/UpdateArtifactTypeImage.java b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/UpdateArtifactTypeImage.java
new file mode 100644
index 00000000000..791c9a56066
--- /dev/null
+++ b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/UpdateArtifactTypeImage.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.ui.skynet.blam.operation;
+
+import java.io.File;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.osee.framework.skynet.core.attribute.ArtifactSubtypeDescriptor;
+import org.eclipse.osee.framework.skynet.core.attribute.ConfigurationPersistenceManager;
+import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
+import org.eclipse.osee.framework.ui.plugin.util.Displays;
+import org.eclipse.osee.framework.ui.plugin.util.InputStreamImageDescriptor;
+import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
+import org.eclipse.osee.framework.ui.skynet.blam.BlamVariableMap;
+import org.eclipse.osee.framework.ui.skynet.util.OSEELog;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public class UpdateArtifactTypeImage implements BlamOperation {
+
+ public static String ARTIFACT_TYPE_NAME = "Select Artifact Type";
+ public static String SELECT_IMAGE = "Select Image GIF";
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.framework.ui.skynet.blam.operation.BlamOperation#runOperation(org.eclipse.osee.framework.ui.skynet.blam.BlamVariableMap, org.eclipse.osee.framework.skynet.core.artifact.Branch, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void runOperation(final BlamVariableMap variableMap, IProgressMonitor monitor) throws Exception {
+ Displays.ensureInDisplayThread(new Runnable() {
+ public void run() {
+ try {
+ String filename = variableMap.getString(SELECT_IMAGE);
+ if (filename == null) {
+ AWorkbench.popup("ERROR", "Must enter full path to image.");
+ return;
+ }
+ File imageFile = new File(filename);
+ if (!imageFile.exists()) {
+ AWorkbench.popup("ERROR", "Invalid image filename.");
+ return;
+ }
+ ArtifactSubtypeDescriptor artifactSubtypeDescriptor =
+ variableMap.getArtifactSubtypeDescriptor("Select Artifact Type");
+ if (!MessageDialog.openConfirm(
+ Display.getCurrent().getActiveShell(),
+ "Update Artifact Type Image",
+ "Set Image for Artifact Type \"" + artifactSubtypeDescriptor.getName() + "\" to \"" + filename + "?")) {
+ return;
+ }
+
+ InputStreamImageDescriptor imageDescriptor =
+ new InputStreamImageDescriptor(imageFile.toURL().openStream());
+ ConfigurationPersistenceManager.updateArtifactTypeImage(artifactSubtypeDescriptor, imageDescriptor);
+ } catch (Exception ex) {
+ OSEELog.logException(SkynetGuiPlugin.class, ex, true);
+ }
+ };
+ });
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.framework.ui.skynet.blam.operation.BlamOperation#getDescriptionUsage()
+ */
+ public String getDescriptionUsage() {
+ return "This BLAM will import the selected 16x16 pixel gif image as the image for the selected artifact type. Existing image will be overwritten.\n\nNOTE: Change default branch for other Artifact Types.";
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.framework.ui.skynet.blam.operation.BlamOperation#getXWidgetXml()
+ */
+ public String getXWidgetsXml() {
+ return "<xWidgets><XWidget xwidgetType=\"XFileSelectionDialog\" displayName=\"" + SELECT_IMAGE + "\" /><XWidget xwidgetType=\"XArtifactTypeListViewer\" displayName=\"" + ARTIFACT_TYPE_NAME + "\" /></xWidgets>";
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XFileSelectionDialog.java b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XFileSelectionDialog.java
new file mode 100644
index 00000000000..c1bf2203ff2
--- /dev/null
+++ b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XFileSelectionDialog.java
@@ -0,0 +1,83 @@
+/*
+ * Created on Feb 4, 2008
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.framework.ui.skynet.widgets;
+
+import java.io.File;
+import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.FileDialog;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class XFileSelectionDialog extends XText {
+
+ private String defaultFileSelection;
+
+ public XFileSelectionDialog() {
+ super();
+ }
+
+ /**
+ * @param displayLabel
+ */
+ public XFileSelectionDialog(String displayLabel) {
+ super(displayLabel);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.framework.ui.skynet.widgets.XText#createWidgets(org.eclipse.swt.widgets.Composite, int, boolean)
+ */
+ @Override
+ public void createWidgets(final Composite parent, int horizontalSpan, boolean fillText) {
+ super.createWidgets(parent, horizontalSpan, fillText);
+
+ Button fileDialog = new Button(parent, SWT.NONE);
+ fileDialog.setImage(SkynetGuiPlugin.getInstance().getImage("file.gif"));
+ fileDialog.addSelectionListener(new SelectionListener() {
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ FileDialog dialog = new FileDialog(Display.getCurrent().getActiveShell(), SWT.OPEN);
+ dialog.setFilterExtensions(new String[] {"*.*"});
+ String defaultDir = getDefaultFileSelection();
+ File dir = new File(defaultDir != null ? defaultDir : "");
+ if (dir.isFile() || dir.isDirectory())
+ dialog.setFilterPath(defaultDir);
+ else
+ dialog.setFilterPath("c:\\");
+
+ String result = dialog.open();
+ if (result != null && !result.equals("")) {
+ setText(dialog.getFilterPath() + File.separatorChar + dialog.getFileName());
+ }
+ }
+ });
+ }
+
+ /**
+ * @return the defaultFileSelection
+ */
+ public String getDefaultFileSelection() {
+ return defaultFileSelection;
+ }
+
+ /**
+ * @param defaultFileSelection the defaultFileSelection to set
+ */
+ public void setDefaultFileSelection(String defaultFileSelection) {
+ this.defaultFileSelection = defaultFileSelection;
+ }
+
+}
diff --git a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/workflow/XWidgetFactory.java b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/workflow/XWidgetFactory.java
index 51e4de7b9d7..c6edea5ca9e 100644
--- a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/workflow/XWidgetFactory.java
+++ b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/workflow/XWidgetFactory.java
@@ -1,196 +1,199 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * 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
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.ui.skynet.widgets.workflow;
-
-import java.util.HashSet;
-import java.util.Set;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
-import org.eclipse.osee.framework.ui.skynet.util.OSEELog;
-import org.eclipse.osee.framework.ui.skynet.widgets.SkynetSpellModifyDictionary;
-import org.eclipse.osee.framework.ui.skynet.widgets.XArtifactTypeListViewer;
-import org.eclipse.osee.framework.ui.skynet.widgets.XAttributeTypeListViewer;
-import org.eclipse.osee.framework.ui.skynet.widgets.XBranchListViewer;
-import org.eclipse.osee.framework.ui.skynet.widgets.XCheckBox;
-import org.eclipse.osee.framework.ui.skynet.widgets.XCheckBoxDam;
-import org.eclipse.osee.framework.ui.skynet.widgets.XCombo;
-import org.eclipse.osee.framework.ui.skynet.widgets.XComboDam;
-import org.eclipse.osee.framework.ui.skynet.widgets.XDate;
-import org.eclipse.osee.framework.ui.skynet.widgets.XDateDam;
-import org.eclipse.osee.framework.ui.skynet.widgets.XFloat;
-import org.eclipse.osee.framework.ui.skynet.widgets.XFloatDam;
-import org.eclipse.osee.framework.ui.skynet.widgets.XHyperlabelMemberSelDam;
-import org.eclipse.osee.framework.ui.skynet.widgets.XInteger;
-import org.eclipse.osee.framework.ui.skynet.widgets.XLabel;
-import org.eclipse.osee.framework.ui.skynet.widgets.XLabelDam;
-import org.eclipse.osee.framework.ui.skynet.widgets.XList;
-import org.eclipse.osee.framework.ui.skynet.widgets.XListDam;
-import org.eclipse.osee.framework.ui.skynet.widgets.XListDropViewer;
-import org.eclipse.osee.framework.ui.skynet.widgets.XRelationTypeListViewer;
-import org.eclipse.osee.framework.ui.skynet.widgets.XText;
-import org.eclipse.osee.framework.ui.skynet.widgets.XTextDam;
-import org.eclipse.osee.framework.ui.skynet.widgets.XTextResourceDropDam;
-import org.eclipse.osee.framework.ui.skynet.widgets.XWidget;
-import org.osgi.framework.Bundle;
-
-/**
- * @author Jeff C. Phillips
- */
-public class XWidgetFactory {
-
- private static final XWidgetFactory reference = new XWidgetFactory();
-
- private XWidgetFactory() {
-
- }
-
- public static XWidgetFactory getInstance() {
- return reference;
- }
-
- public XWidget createXWidget(String xWidgetName, String name, boolean labelAfter, DynamicXWidgetLayoutData xWidgetLayoutData) {
- XWidget xWidget = null;
-
- // Look for widget provider to create widget
- for (IXWidgetProvider widgetProviders : getXWidgetProviders()) {
- xWidget = widgetProviders.createXWidget(xWidgetName, name, labelAfter, xWidgetLayoutData);
- if (xWidget != null) return xWidget;
- }
-
- // Otherwise, use default widget creation
- if (xWidgetName.equals("XText"))
- xWidget = new XText(name);
- else if (xWidgetName.equals("XInteger"))
- xWidget = new XInteger(name);
- else if (xWidgetName.equals("XTextDam"))
- xWidget = new XTextDam(name);
- else if (xWidgetName.equals("XLabelDam"))
- xWidget = new XLabelDam(name);
- else if (xWidgetName.equals("XDate"))
- xWidget = new XDate(name);
- else if (xWidgetName.equals("XDateDam"))
- xWidget = new XDateDam(name);
- else if (xWidgetName.equals("XTextResourceDropDam"))
- xWidget = new XTextResourceDropDam(name);
- else if (xWidgetName.equals("XFloat"))
- xWidget = new XFloat(name);
- else if (xWidgetName.equals("XFloatDam"))
- xWidget = new XFloatDam(name);
- else if (xWidgetName.equals("XLabel"))
- xWidget = new XLabel(name);
- else if (xWidgetName.equals("XCheckBox")) {
- XCheckBox checkBox = new XCheckBox(name);
- checkBox.setLabelAfter(labelAfter);
- xWidget = checkBox;
- } else if (xWidgetName.equals("XCheckBoxDam")) {
- XCheckBoxDam checkBox = new XCheckBoxDam(name);
- checkBox.setLabelAfter(labelAfter);
- xWidget = checkBox;
- } else if (xWidgetName.startsWith("XComboDam")) {
- String values[] =
- xWidgetLayoutData.getDynamicXWidgetLayout().getOptionResolver().getWidgetOptions(xWidgetLayoutData);
- if (values.length > 0) {
- xWidget = new XComboDam(name);
- XComboDam combo = new XComboDam(name);
- combo.setDataStrings(values);
- xWidget = combo;
- } else
- throw new IllegalArgumentException(
- "Invalid XComboDam. " + "Must be \"XComboDam(option1,option2,option3)\"");
- } else if (xWidgetName.startsWith("XCombo")) {
- String values[] =
- xWidgetLayoutData.getDynamicXWidgetLayout().getOptionResolver().getWidgetOptions(xWidgetLayoutData);
- if (values.length > 0) {
- XCombo combo = new XCombo(name);
- combo.setDataStrings(values);
- xWidget = combo;
- } else
- throw new IllegalArgumentException("Invalid XCombo. " + "Must be \"XCombo(option1,option2,option3)\"");
- } else if (xWidgetName.startsWith("XListDam")) {
- String values[] =
- xWidgetLayoutData.getDynamicXWidgetLayout().getOptionResolver().getWidgetOptions(xWidgetLayoutData);
- if (values.length > 0) {
- XListDam list = new XListDam(name);
- list.add(values);
- xWidget = list;
- } else
- throw new IllegalArgumentException("Invalid XList. " + "Must be \"XList(option1,option2,option3)\"");
- } else if (xWidgetName.equals("XHyperlabelMemberSelDam")) {
- xWidget = new XHyperlabelMemberSelDam(name);
- } else if (xWidgetName.startsWith("XListDropViewer")) {
- xWidget = new XListDropViewer(name);
- } else if (xWidgetName.equals("XArtifactTypeListViewer")) {
- xWidget = new XArtifactTypeListViewer();
- } else if (xWidgetName.equals("XAttributeTypeListViewer")) {
- xWidget = new XAttributeTypeListViewer();
- } else if (xWidgetName.equals("XRelationTypeListViewer")) {
- xWidget = new XRelationTypeListViewer();
- } else if (xWidgetName.equals("XBranchListViewer")) {
- xWidget = new XBranchListViewer();
- } else if (xWidgetName.startsWith("XList")) {
- String values[] =
- xWidgetLayoutData.getDynamicXWidgetLayout().getOptionResolver().getWidgetOptions(xWidgetLayoutData);
- if (values.length > 0) {
- XList list = new XList(name);
- list.add(values);
- xWidget = list;
- } else
- throw new IllegalArgumentException("Invalid XList. " + "Must be \"XList(option1,option2,option3)\"");
- } else {
- throw new IllegalArgumentException("Unhandled XWidget \"" + xWidgetName);
- }
- if (xWidget instanceof XText) {
- ((XText) xWidget).addXTextSpellModifyDictionary(new SkynetSpellModifyDictionary());
- }
- return xWidget;
- }
-
- private static Set<IXWidgetProvider> widgetProviders;
-
- @SuppressWarnings("deprecation")
- private static Set<IXWidgetProvider> getXWidgetProviders() {
- widgetProviders = new HashSet<IXWidgetProvider>();
- IExtensionPoint point =
- Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.osee.framework.ui.skynet.XWidgetProvider");
- if (point == null) {
- OSEELog.logSevere(SkynetGuiPlugin.class, "Can't access XWidgetProvider extension point", true);
- return null;
- }
- IExtension[] extensions = point.getExtensions();
- for (IExtension extension : extensions) {
- IConfigurationElement[] elements = extension.getConfigurationElements();
- String classname = null;
- String bundleName = null;
- for (IConfigurationElement el : elements) {
- if (el.getName().equals("XWidgetProvider")) {
- classname = el.getAttribute("classname");
- bundleName = el.getContributor().getName();
- if (classname != null && bundleName != null) {
- Bundle bundle = Platform.getBundle(bundleName);
- try {
- Class<?> taskClass = bundle.loadClass(classname);
- Object obj = taskClass.newInstance();
- widgetProviders.add((IXWidgetProvider) obj);
- } catch (Exception ex) {
- OSEELog.logException(SkynetGuiPlugin.class, "Error loading XWidgetProvider extension", ex, true);
- }
- }
-
- }
- }
- }
- return widgetProviders;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.ui.skynet.widgets.workflow;
+
+import java.util.HashSet;
+import java.util.Set;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
+import org.eclipse.osee.framework.ui.skynet.util.OSEELog;
+import org.eclipse.osee.framework.ui.skynet.widgets.SkynetSpellModifyDictionary;
+import org.eclipse.osee.framework.ui.skynet.widgets.XArtifactTypeListViewer;
+import org.eclipse.osee.framework.ui.skynet.widgets.XAttributeTypeListViewer;
+import org.eclipse.osee.framework.ui.skynet.widgets.XBranchListViewer;
+import org.eclipse.osee.framework.ui.skynet.widgets.XCheckBox;
+import org.eclipse.osee.framework.ui.skynet.widgets.XCheckBoxDam;
+import org.eclipse.osee.framework.ui.skynet.widgets.XCombo;
+import org.eclipse.osee.framework.ui.skynet.widgets.XComboDam;
+import org.eclipse.osee.framework.ui.skynet.widgets.XDate;
+import org.eclipse.osee.framework.ui.skynet.widgets.XDateDam;
+import org.eclipse.osee.framework.ui.skynet.widgets.XFileSelectionDialog;
+import org.eclipse.osee.framework.ui.skynet.widgets.XFloat;
+import org.eclipse.osee.framework.ui.skynet.widgets.XFloatDam;
+import org.eclipse.osee.framework.ui.skynet.widgets.XHyperlabelMemberSelDam;
+import org.eclipse.osee.framework.ui.skynet.widgets.XInteger;
+import org.eclipse.osee.framework.ui.skynet.widgets.XLabel;
+import org.eclipse.osee.framework.ui.skynet.widgets.XLabelDam;
+import org.eclipse.osee.framework.ui.skynet.widgets.XList;
+import org.eclipse.osee.framework.ui.skynet.widgets.XListDam;
+import org.eclipse.osee.framework.ui.skynet.widgets.XListDropViewer;
+import org.eclipse.osee.framework.ui.skynet.widgets.XRelationTypeListViewer;
+import org.eclipse.osee.framework.ui.skynet.widgets.XText;
+import org.eclipse.osee.framework.ui.skynet.widgets.XTextDam;
+import org.eclipse.osee.framework.ui.skynet.widgets.XTextResourceDropDam;
+import org.eclipse.osee.framework.ui.skynet.widgets.XWidget;
+import org.osgi.framework.Bundle;
+
+/**
+ * @author Jeff C. Phillips
+ */
+public class XWidgetFactory {
+
+ private static final XWidgetFactory reference = new XWidgetFactory();
+
+ private XWidgetFactory() {
+
+ }
+
+ public static XWidgetFactory getInstance() {
+ return reference;
+ }
+
+ public XWidget createXWidget(String xWidgetName, String name, boolean labelAfter, DynamicXWidgetLayoutData xWidgetLayoutData) {
+ XWidget xWidget = null;
+
+ // Look for widget provider to create widget
+ for (IXWidgetProvider widgetProviders : getXWidgetProviders()) {
+ xWidget = widgetProviders.createXWidget(xWidgetName, name, labelAfter, xWidgetLayoutData);
+ if (xWidget != null) return xWidget;
+ }
+
+ // Otherwise, use default widget creation
+ if (xWidgetName.equals("XText"))
+ xWidget = new XText(name);
+ else if (xWidgetName.equals("XInteger"))
+ xWidget = new XInteger(name);
+ else if (xWidgetName.equals("XTextDam"))
+ xWidget = new XTextDam(name);
+ else if (xWidgetName.equals("XLabelDam"))
+ xWidget = new XLabelDam(name);
+ else if (xWidgetName.equals("XDate"))
+ xWidget = new XDate(name);
+ else if (xWidgetName.equals("XFileSelectionDialog"))
+ xWidget = new XFileSelectionDialog(name);
+ else if (xWidgetName.equals("XDateDam"))
+ xWidget = new XDateDam(name);
+ else if (xWidgetName.equals("XTextResourceDropDam"))
+ xWidget = new XTextResourceDropDam(name);
+ else if (xWidgetName.equals("XFloat"))
+ xWidget = new XFloat(name);
+ else if (xWidgetName.equals("XFloatDam"))
+ xWidget = new XFloatDam(name);
+ else if (xWidgetName.equals("XLabel"))
+ xWidget = new XLabel(name);
+ else if (xWidgetName.equals("XCheckBox")) {
+ XCheckBox checkBox = new XCheckBox(name);
+ checkBox.setLabelAfter(labelAfter);
+ xWidget = checkBox;
+ } else if (xWidgetName.equals("XCheckBoxDam")) {
+ XCheckBoxDam checkBox = new XCheckBoxDam(name);
+ checkBox.setLabelAfter(labelAfter);
+ xWidget = checkBox;
+ } else if (xWidgetName.startsWith("XComboDam")) {
+ String values[] =
+ xWidgetLayoutData.getDynamicXWidgetLayout().getOptionResolver().getWidgetOptions(xWidgetLayoutData);
+ if (values.length > 0) {
+ xWidget = new XComboDam(name);
+ XComboDam combo = new XComboDam(name);
+ combo.setDataStrings(values);
+ xWidget = combo;
+ } else
+ throw new IllegalArgumentException(
+ "Invalid XComboDam. " + "Must be \"XComboDam(option1,option2,option3)\"");
+ } else if (xWidgetName.startsWith("XCombo")) {
+ String values[] =
+ xWidgetLayoutData.getDynamicXWidgetLayout().getOptionResolver().getWidgetOptions(xWidgetLayoutData);
+ if (values.length > 0) {
+ XCombo combo = new XCombo(name);
+ combo.setDataStrings(values);
+ xWidget = combo;
+ } else
+ throw new IllegalArgumentException("Invalid XCombo. " + "Must be \"XCombo(option1,option2,option3)\"");
+ } else if (xWidgetName.startsWith("XListDam")) {
+ String values[] =
+ xWidgetLayoutData.getDynamicXWidgetLayout().getOptionResolver().getWidgetOptions(xWidgetLayoutData);
+ if (values.length > 0) {
+ XListDam list = new XListDam(name);
+ list.add(values);
+ xWidget = list;
+ } else
+ throw new IllegalArgumentException("Invalid XList. " + "Must be \"XList(option1,option2,option3)\"");
+ } else if (xWidgetName.equals("XHyperlabelMemberSelDam")) {
+ xWidget = new XHyperlabelMemberSelDam(name);
+ } else if (xWidgetName.startsWith("XListDropViewer")) {
+ xWidget = new XListDropViewer(name);
+ } else if (xWidgetName.equals("XArtifactTypeListViewer")) {
+ xWidget = new XArtifactTypeListViewer();
+ } else if (xWidgetName.equals("XAttributeTypeListViewer")) {
+ xWidget = new XAttributeTypeListViewer();
+ } else if (xWidgetName.equals("XRelationTypeListViewer")) {
+ xWidget = new XRelationTypeListViewer();
+ } else if (xWidgetName.equals("XBranchListViewer")) {
+ xWidget = new XBranchListViewer();
+ } else if (xWidgetName.startsWith("XList")) {
+ String values[] =
+ xWidgetLayoutData.getDynamicXWidgetLayout().getOptionResolver().getWidgetOptions(xWidgetLayoutData);
+ if (values.length > 0) {
+ XList list = new XList(name);
+ list.add(values);
+ xWidget = list;
+ } else
+ throw new IllegalArgumentException("Invalid XList. " + "Must be \"XList(option1,option2,option3)\"");
+ } else {
+ throw new IllegalArgumentException("Unhandled XWidget \"" + xWidgetName);
+ }
+ if (xWidget instanceof XText) {
+ ((XText) xWidget).addXTextSpellModifyDictionary(new SkynetSpellModifyDictionary());
+ }
+ return xWidget;
+ }
+
+ private static Set<IXWidgetProvider> widgetProviders;
+
+ @SuppressWarnings("deprecation")
+ private static Set<IXWidgetProvider> getXWidgetProviders() {
+ widgetProviders = new HashSet<IXWidgetProvider>();
+ IExtensionPoint point =
+ Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.osee.framework.ui.skynet.XWidgetProvider");
+ if (point == null) {
+ OSEELog.logSevere(SkynetGuiPlugin.class, "Can't access XWidgetProvider extension point", true);
+ return null;
+ }
+ IExtension[] extensions = point.getExtensions();
+ for (IExtension extension : extensions) {
+ IConfigurationElement[] elements = extension.getConfigurationElements();
+ String classname = null;
+ String bundleName = null;
+ for (IConfigurationElement el : elements) {
+ if (el.getName().equals("XWidgetProvider")) {
+ classname = el.getAttribute("classname");
+ bundleName = el.getContributor().getName();
+ if (classname != null && bundleName != null) {
+ Bundle bundle = Platform.getBundle(bundleName);
+ try {
+ Class<?> taskClass = bundle.loadClass(classname);
+ Object obj = taskClass.newInstance();
+ widgetProviders.add((IXWidgetProvider) obj);
+ } catch (Exception ex) {
+ OSEELog.logException(SkynetGuiPlugin.class, "Error loading XWidgetProvider extension", ex, true);
+ }
+ }
+
+ }
+ }
+ }
+ return widgetProviders;
+ }
+
+}

Back to the top