blob: cbb99c61402a2a5561e2517563b8703ccea2c50d (
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
/*******************************************************************************
* Copyright (c) 2012 Wind River Systems, Inc. and others. 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:
* Wind River Systems - initial API and implementation
*******************************************************************************/
package org.eclipse.tcf.te.launch.ui.internal.viewer;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.tcf.te.launch.ui.internal.ImageConsts;
import org.eclipse.tcf.te.launch.ui.model.LaunchNode;
import org.eclipse.tcf.te.ui.jface.images.AbstractImageDescriptor;
/**
* Launch node image descriptor implementation.
*/
public class LaunchNodeImageDescriptor extends AbstractImageDescriptor {
// the base image to decorate with overlays
private Image baseImage;
// the image size
private Point imageSize;
// Flags representing the object states to decorate
private boolean isValid;
/**
* Constructor.
*/
public LaunchNodeImageDescriptor(final ImageRegistry registry, final Image baseImage, final LaunchNode node) {
super(registry);
this.baseImage = baseImage;
imageSize = new Point(baseImage.getImageData().width, baseImage.getImageData().height);
// Determine the current object state to decorate
initialize(node);
// build up the key for the image registry
defineKey(baseImage.hashCode());
}
/**
* Initialize the image descriptor from the launch node.
*
* @param node The launch node. Must not be <code>null</code>.
*/
protected void initialize(LaunchNode node) {
Assert.isNotNull(node);
isValid = node.isValidFor(null);
}
protected void defineKey(int hashCode) {
String key = "LaunchNodeID:" + //$NON-NLS-1$
hashCode + ":" + //$NON-NLS-1$
isValid;
setDecriptorKey(key);
}
/* (non-Javadoc)
* @see org.eclipse.jface.resource.CompositeImageDescriptor#drawCompositeImage(int, int)
*/
@Override
protected void drawCompositeImage(int width, int height) {
drawCentered(baseImage, width, height);
if (!isValid) {
drawBottomRight(ImageConsts.RED_X_OVR);
}
}
/* (non-Javadoc)
* @see org.eclipse.jface.resource.CompositeImageDescriptor#getSize()
*/
@Override
protected Point getSize() {
return imageSize;
}
/* (non-Javadoc)
* @see org.eclipse.tcf.te.tcf.ide.util.ui.AbstractImageDescriptor#getBaseImage()
*/
@Override
protected Image getBaseImage() {
return baseImage;
}
}
|