blob: cde7bbe3f0f752e4e7947110afc33353b6bed8ac (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
/*******************************************************************************
* Copyright (c) 2009 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;
import java.io.ByteArrayInputStream;
import java.util.logging.Level;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.ui.swt.KeyedImage;
import org.eclipse.osee.framework.ui.swt.ProgramImage;
import org.eclipse.swt.graphics.ImageData;
/**
* @author Ryan D. Brooks
*/
public class BaseImage implements KeyedImage {
private final IArtifactType artifactType;
private final byte[] imageData;
private BaseImage(IArtifactType artifactType, byte[] imageData) {
this.artifactType = artifactType;
this.imageData = imageData;
}
@Override
public ImageDescriptor createImageDescriptor() {
return ImageDescriptor.createFromImageData(new ImageData(new ByteArrayInputStream(imageData)));
}
@Override
public String getImageKey() {
return SkynetGuiPlugin.PLUGIN_ID + ".artifact_type." + artifactType.getName();
}
public static KeyedImage getBaseImageEnum(IArtifactType artifactType, byte[] imageData) {
if (ArtifactImageManager.getOverrideImageEnum() != null) {
return ArtifactImageManager.getOverrideImageEnum();
}
return new BaseImage(artifactType, imageData);
}
public static KeyedImage getBaseImageEnum(IArtifactType artifactType) {
if (ArtifactImageManager.getOverrideImageEnum() != null) {
return ArtifactImageManager.getOverrideImageEnum();
}
// Check extensions
KeyedImage oseeImage = ArtifactImageManager.getArtifactTypeImage(artifactType);
if (oseeImage != null) {
return oseeImage;
}
return FrameworkImage.LASER;
}
public static KeyedImage getBaseImageEnum(Artifact artifact) {
if (ArtifactImageManager.getOverrideImageEnum() != null) {
return ArtifactImageManager.getOverrideImageEnum();
}
try {
String extension = artifact.getSoleAttributeValue(CoreAttributeTypes.Extension, "");
if (Strings.isValid(extension)) {
return new ProgramImage(extension);
}
} catch (Exception ex) {
OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
}
return getBaseImageEnum(artifact.getArtifactType());
}
}
|