diff options
author | donald.g.dunne | 2016-03-17 15:44:01 +0000 |
---|---|---|
committer | donald.g.dunne | 2016-03-17 17:43:58 +0000 |
commit | 360372feffdb92a1daef07d6b2b5d589eb656be6 (patch) | |
tree | 172c85b164102e163afa47c47e9c61b7355b4c6b | |
parent | fc93c49a5cc550d26e7caccc82174903b0bb722e (diff) | |
download | org.eclipse.osee-360372feffdb92a1daef07d6b2b5d589eb656be6.tar.gz org.eclipse.osee-360372feffdb92a1daef07d6b2b5d589eb656be6.tar.xz org.eclipse.osee-360372feffdb92a1daef07d6b2b5d589eb656be6.zip |
feature[ats_ATS277469]: Create Implementation Details types and images
Change-Id: I42532c6acef9ce4a2c840600a68b3f7ea98286a1
11 files changed, 183 insertions, 8 deletions
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF index af95cd02414..47c646a2523 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF @@ -22,6 +22,8 @@ Import-Package: com.google.common.base;version="15.0.0", org.apache.commons.io, org.apache.commons.lang, org.apache.commons.lang.mutable, + org.codehaus.jackson, + org.codehaus.jackson.map, org.eclipse.birt.chart.device, org.eclipse.birt.chart.exception, org.eclipse.birt.chart.factory, diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/images/implementationDetails.xcf b/plugins/org.eclipse.osee.framework.ui.skynet/images/implementationDetails.xcf Binary files differindex e7c0f7f1b7f..78b449f748c 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/images/implementationDetails.xcf +++ b/plugins/org.eclipse.osee.framework.ui.skynet/images/implementationDetails.xcf diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/images/implementation_details_data_definition.gif b/plugins/org.eclipse.osee.framework.ui.skynet/images/implementation_details_data_definition.gif Binary files differindex 0d0c882fa3c..a6acae99f16 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/images/implementation_details_data_definition.gif +++ b/plugins/org.eclipse.osee.framework.ui.skynet/images/implementation_details_data_definition.gif diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/images/implementation_details_drawing.gif b/plugins/org.eclipse.osee.framework.ui.skynet/images/implementation_details_drawing.gif Binary files differindex c997773666b..8b58e9c9880 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/images/implementation_details_drawing.gif +++ b/plugins/org.eclipse.osee.framework.ui.skynet/images/implementation_details_drawing.gif diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/images/implementation_details_function.gif b/plugins/org.eclipse.osee.framework.ui.skynet/images/implementation_details_function.gif Binary files differindex f357e177a76..e0f6d2ab002 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/images/implementation_details_function.gif +++ b/plugins/org.eclipse.osee.framework.ui.skynet/images/implementation_details_function.gif diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/images/implementation_details_procedure.gif b/plugins/org.eclipse.osee.framework.ui.skynet/images/implementation_details_procedure.gif Binary files differindex 44e8b757d39..fe34a885ed3 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/images/implementation_details_procedure.gif +++ b/plugins/org.eclipse.osee.framework.ui.skynet/images/implementation_details_procedure.gif diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/FrameworkArtifactImageProvider.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/FrameworkArtifactImageProvider.java index cc7bdfa13c9..e0256ffd7da 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/FrameworkArtifactImageProvider.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/FrameworkArtifactImageProvider.java @@ -9,15 +9,31 @@ import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager; ******************************/ package org.eclipse.osee.framework.ui.skynet; +import java.net.URI; +import java.net.URL; import java.util.Collection; +import java.util.logging.Level; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriBuilder; +import org.codehaus.jackson.map.ObjectMapper; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.osee.framework.core.client.OseeClientProperties; +import org.eclipse.osee.framework.core.data.IArtifactType; import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; +import org.eclipse.osee.framework.jdk.core.util.Strings; +import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.skynet.core.User; import org.eclipse.osee.framework.skynet.core.UserManager; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; +import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager; import org.eclipse.osee.framework.skynet.core.types.IArtifact; import org.eclipse.osee.framework.ui.plugin.PluginUiImage; +import org.eclipse.osee.framework.ui.skynet.util.DynamicImage; +import org.eclipse.osee.framework.ui.skynet.util.DynamicImages; import org.eclipse.osee.framework.ui.swt.ImageManager; +import org.eclipse.osee.jaxrs.client.JaxRsClient; +import org.eclipse.swt.graphics.Image; /** * @author Donald G. Dunne @@ -44,23 +60,81 @@ public class FrameworkArtifactImageProvider extends ArtifactImageProvider { FrameworkImage.IMPLEMENTATION_DETAILS_DRAWING, this); ArtifactImageManager.registerBaseImage(CoreArtifactTypes.ImplementationDetailsDataDefinition, FrameworkImage.IMPLEMENTATION_DETAILS_DATA_DEFINITION, this); + readDynamicImagesFromUrl(); ArtifactImageManager.registerOverrideImageProvider(this, CoreArtifactTypes.User); } + private void readDynamicImagesFromUrl() { + + try { + String appServer = OseeClientProperties.getOseeApplicationServer(); + URI uri = UriBuilder.fromUri(appServer).path("images.json").build(); + + // first, retrieve the images.json file to see if there are any images + String imagesJson = JaxRsClient.newClient().target(uri).request(MediaType.TEXT_PLAIN).get(String.class); + if (Strings.isValid(imagesJson)) { + + ObjectMapper mapper = new ObjectMapper(); + + // read images.xml + DynamicImages images = mapper.readValue(imagesJson, DynamicImages.class); + + // for each image + for (DynamicImage dynamicImage : images.getImages()) { + + try { + // get image from url + if (Strings.isValid(dynamicImage.getImageUrl())) { + + URL url = new URL(dynamicImage.getImageUrl()); + Image image = ImageDescriptor.createFromURL(url).createImage(); + if (image != null) { + // get artifact type + IArtifactType artifactType = null; + if (Strings.isNumeric(dynamicImage.getArtifactTypeUuid())) { + artifactType = + ArtifactTypeManager.getTypeByGuid(Long.valueOf(dynamicImage.getArtifactTypeUuid())); + } + if (artifactType == null && Strings.isValid(dynamicImage.getArtifactTypeName())) { + artifactType = ArtifactTypeManager.getType(dynamicImage.getArtifactTypeName()); + } + if (artifactType != null) { + // register image for artifact type + ArtifactImageManager.registerBaseImage(artifactType, ImageManager.createKeyedImage( + artifactType.getGuid().toString(), ImageDescriptor.createFromImage(image)), this); + } + } + } + } catch (Exception ex) { + OseeLog.logf(FrameworkArtifactImageProvider.class, Level.SEVERE, ex, "Error processing image [%s]", + dynamicImage); + } + } + } + + } catch (Exception ex) { + OseeLog.logf(FrameworkArtifactImageProvider.class, Level.SEVERE, ex, + "Error processing dynamic artifact images."); + } + + } + @Override public String setupImage(IArtifact artifact) throws OseeCoreException { Artifact aArtifact = artifact.getFullArtifact(); if (aArtifact.isDeleted()) { return null; - } else if (((User) aArtifact).isSystemUser()) { - return ImageManager.setupImage(FrameworkImage.USER_GREY); - } else if (!((User) aArtifact).isActive()) { - return ImageManager.setupImage(FrameworkImage.USER_YELLOW); - } else if (((User) aArtifact).equals(UserManager.getUser())) { - return ImageManager.setupImage(FrameworkImage.USER_RED); } - + if (aArtifact.isOfType(CoreArtifactTypes.User)) { + if (((User) aArtifact).isSystemUser()) { + return ImageManager.setupImage(FrameworkImage.USER_GREY); + } else if (!((User) aArtifact).isActive()) { + return ImageManager.setupImage(FrameworkImage.USER_YELLOW); + } else if (((User) aArtifact).equals(UserManager.getUser())) { + return ImageManager.setupImage(FrameworkImage.USER_RED); + } + } return super.setupImage(artifact); } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/DynamicImage.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/DynamicImage.java new file mode 100644 index 00000000000..618780b4a61 --- /dev/null +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/DynamicImage.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2015 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.util; + +import javax.xml.bind.annotation.XmlRootElement; + +/** + * @author Donald G. Dunne + */ +@XmlRootElement +public class DynamicImage { + + private String imageUrl; + private String artifactTypeName; + private String artifactTypeUuid; + + public String getImageUrl() { + return imageUrl; + } + + public void setImageUrl(String imageUrl) { + this.imageUrl = imageUrl; + } + + public String getArtifactTypeName() { + return artifactTypeName; + } + + public void setArtifactTypeName(String artifactTypeName) { + this.artifactTypeName = artifactTypeName; + } + + public String getArtifactTypeUuid() { + return artifactTypeUuid; + } + + public void setArtifactTypeUuid(String artifactTypeUuid) { + this.artifactTypeUuid = artifactTypeUuid; + } + +} diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/DynamicImages.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/DynamicImages.java new file mode 100644 index 00000000000..0a1d9f1fc68 --- /dev/null +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/DynamicImages.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2015 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.util; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * @author Donald G. Dunne + */ +@XmlRootElement +public class DynamicImages { + + public List<DynamicImage> images = new ArrayList<>(); + + public List<DynamicImage> getImages() { + return images; + } + +} diff --git a/plugins/org.eclipse.osee.framework.ui.swt/src/org/eclipse/osee/framework/ui/swt/ImageManager.java b/plugins/org.eclipse.osee.framework.ui.swt/src/org/eclipse/osee/framework/ui/swt/ImageManager.java index 7aa237c188a..9bbc2b6aa64 100644 --- a/plugins/org.eclipse.osee.framework.ui.swt/src/org/eclipse/osee/framework/ui/swt/ImageManager.java +++ b/plugins/org.eclipse.osee.framework.ui.swt/src/org/eclipse/osee/framework/ui/swt/ImageManager.java @@ -79,7 +79,8 @@ public final class ImageManager { ImageDescriptor imageDescriptor = imageEnum.createImageDescriptor(); if (imageDescriptor == null) { if (!imageKey.contains("nothere.gif")) { - OseeLog.logf(Activator.class, Level.SEVERE, "Unable to load the image for [%s]", imageEnum.getImageKey()); + OseeLog.logf(Activator.class, Level.SEVERE, "Unable to load the image for [%s]", + imageEnum.getImageKey()); } return setupImage(MISSING); } @@ -109,6 +110,10 @@ public final class ImageManager { return AbstractUIPlugin.imageDescriptorFromPlugin(symbolicBundleName, imagePath + File.separator + imageFileName); } + public static KeyedImage createKeyedImage(String imageKey, ImageDescriptor descriptor) { + return new KeyedImagePair(imageKey, descriptor); + } + private static final class KeyedImagePair implements KeyedImage { private final ImageDescriptor descriptor; private final String imageKey; diff --git a/plugins/org.eclipse.osee.web.ui/src/images.json.example b/plugins/org.eclipse.osee.web.ui/src/images.json.example new file mode 100644 index 00000000000..bc54cd3e12a --- /dev/null +++ b/plugins/org.eclipse.osee.web.ui/src/images.json.example @@ -0,0 +1,16 @@ +// Example of images.json file. If images.json file exists, the client will use this file +// to register images for any artifact types specified. Simply provide the imageUrl, artifact type +// name and uuid and these images will be used. +// 1. Copy this file and rename it to images.json +// 2. Remove these comments, they are not valid json +// 3. Edit for your artifact types and image urls +// 4. Restart the org.eclipse.osee.web.ui bundle or server for it to take affect. +{ + "images": [ + { + "imageUrl": "http://osee.msc.az.boeing.com/libs/images/my_image.gif", + "artifactTypeName": "Implementation Details Procedure", + "artifactTypeUuid": "69914" + } + ] +}
\ No newline at end of file |