=UTF-8
diff --git a/com.minres.scviewer.database.swt/.settings/org.eclipse.jdt.core.prefs b/com.minres.scviewer.database.swt/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..f42de36
--- /dev/null
+++ b/com.minres.scviewer.database.swt/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.7
diff --git a/com.minres.scviewer.database.swt/.settings/org.eclipse.m2e.core.prefs b/com.minres.scviewer.database.swt/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000..f897a7f
--- /dev/null
+++ b/com.minres.scviewer.database.swt/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/com.minres.scviewer.database.swt/.settings/org.eclipse.pde.core.prefs b/com.minres.scviewer.database.swt/.settings/org.eclipse.pde.core.prefs
new file mode 100644
index 0000000..f29e940
--- /dev/null
+++ b/com.minres.scviewer.database.swt/.settings/org.eclipse.pde.core.prefs
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+pluginProject.extensions=false
+resolve.requirebundle=false
diff --git a/com.minres.scviewer.database.swt/META-INF/MANIFEST.MF b/com.minres.scviewer.database.swt/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..99006e9
--- /dev/null
+++ b/com.minres.scviewer.database.swt/META-INF/MANIFEST.MF
@@ -0,0 +1,15 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: SWT widget
+Bundle-SymbolicName: com.minres.scviewer.database.swt
+Bundle-Version: 1.0.0.qualifier
+Bundle-Vendor: MINRES Technologies GmbH
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Require-Bundle: org.eclipse.swt;bundle-version="3.103.1",
+ com.minres.scviewer.database;bundle-version="1.0.0",
+ com.google.guava;bundle-version="15.0.0",
+ org.eclipse.jface,
+ org.eclipse.equinox.registry
+Export-Package: com.minres.scviewer.database.swt
+Bundle-ClassPath: .,
+ swing2swt.jar
diff --git a/com.minres.scviewer.database.swt/build.properties b/com.minres.scviewer.database.swt/build.properties
new file mode 100644
index 0000000..8a5bcac
--- /dev/null
+++ b/com.minres.scviewer.database.swt/build.properties
@@ -0,0 +1,15 @@
+###############################################################################
+# Copyright (c) 2014, 2015 MINRES Technologies GmbH 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:
+# MINRES Technologies GmbH - initial API and implementation
+###############################################################################
+bin.includes = META-INF/,\
+ .,\
+ swing2swt.jar
+source.. = src/
+jars.compile.order = .
diff --git a/com.minres.scviewer.database.swt/pom.xml b/com.minres.scviewer.database.swt/pom.xml
new file mode 100644
index 0000000..9430967
--- /dev/null
+++ b/com.minres.scviewer.database.swt/pom.xml
@@ -0,0 +1,12 @@
+
+ 4.0.0
+ com.minres.scviewer.database.swt
+ 1.0.0-SNAPSHOT
+ eclipse-plugin
+
+ com.minres.scviewer
+ com.minres.scviewer.parent
+ 1.0.0-SNAPSHOT
+ ../com.minres.scviewer.parent
+
+
\ No newline at end of file
diff --git a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/handler/GotoDirection.java b/com.minres.scviewer.database.swt/src/com/minres/scviewer/database/swt/GotoDirection.java
similarity index 87%
rename from com.minres.scviewer.ui/src/com/minres/scviewer/ui/handler/GotoDirection.java
rename to com.minres.scviewer.database.swt/src/com/minres/scviewer/database/swt/GotoDirection.java
index 27f0192..ea04179 100644
--- a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/handler/GotoDirection.java
+++ b/com.minres.scviewer.database.swt/src/com/minres/scviewer/database/swt/GotoDirection.java
@@ -8,6 +8,6 @@
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
-package com.minres.scviewer.ui.handler;
+package com.minres.scviewer.database.swt;
public enum GotoDirection {PREV, NEXT}
\ No newline at end of file
diff --git a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/swt/TxDisplay.java b/com.minres.scviewer.database.swt/src/com/minres/scviewer/database/swt/TxDisplay.java
similarity index 97%
rename from com.minres.scviewer.ui/src/com/minres/scviewer/ui/swt/TxDisplay.java
rename to com.minres.scviewer.database.swt/src/com/minres/scviewer/database/swt/TxDisplay.java
index 9a63447..e551bc5 100644
--- a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/swt/TxDisplay.java
+++ b/com.minres.scviewer.database.swt/src/com/minres/scviewer/database/swt/TxDisplay.java
@@ -8,7 +8,7 @@
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
-package com.minres.scviewer.ui.swt;
+package com.minres.scviewer.database.swt;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -60,7 +60,14 @@ import com.minres.scviewer.database.ITxEvent;
import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformEvent;
-import com.minres.scviewer.ui.handler.GotoDirection;
+import com.minres.scviewer.database.swt.internal.CursorPainter;
+import com.minres.scviewer.database.swt.internal.IWaveformPainter;
+import com.minres.scviewer.database.swt.internal.ObservableList;
+import com.minres.scviewer.database.swt.internal.Ruler;
+import com.minres.scviewer.database.swt.internal.SignalPainter;
+import com.minres.scviewer.database.swt.internal.StreamPainter;
+import com.minres.scviewer.database.swt.internal.TrackPainter;
+import com.minres.scviewer.database.swt.internal.WaveformCanvas;
public class TxDisplay implements PropertyChangeListener, ISelectionProvider, MouseListener{
private ListenerList listeners = new ListenerList();
diff --git a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/swt/CursorPainter.java b/com.minres.scviewer.database.swt/src/com/minres/scviewer/database/swt/internal/CursorPainter.java
similarity index 88%
rename from com.minres.scviewer.ui/src/com/minres/scviewer/ui/swt/CursorPainter.java
rename to com.minres.scviewer.database.swt/src/com/minres/scviewer/database/swt/internal/CursorPainter.java
index 77a020a..8e3079d 100644
--- a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/swt/CursorPainter.java
+++ b/com.minres.scviewer.database.swt/src/com/minres/scviewer/database/swt/internal/CursorPainter.java
@@ -8,12 +8,12 @@
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
-package com.minres.scviewer.ui.swt;
+package com.minres.scviewer.database.swt.internal;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle;
-class CursorPainter implements IPainter {
+public class CursorPainter implements IPainter {
/**
*
@@ -25,7 +25,7 @@ class CursorPainter implements IPainter {
* @param i
* @param txDisplay
*/
- CursorPainter(WaveformCanvas txDisplay, long time) {
+ public CursorPainter(WaveformCanvas txDisplay, long time) {
this.waveCanvas = txDisplay;
this.time=time;
}
diff --git a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/swt/IPainter.java b/com.minres.scviewer.database.swt/src/com/minres/scviewer/database/swt/internal/IPainter.java
similarity index 93%
rename from com.minres.scviewer.ui/src/com/minres/scviewer/ui/swt/IPainter.java
rename to com.minres.scviewer.database.swt/src/com/minres/scviewer/database/swt/internal/IPainter.java
index e57cedc..086ec2b 100644
--- a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/swt/IPainter.java
+++ b/com.minres.scviewer.database.swt/src/com/minres/scviewer/database/swt/internal/IPainter.java
@@ -8,7 +8,7 @@
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
-package com.minres.scviewer.ui.swt;
+package com.minres.scviewer.database.swt.internal;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle;
diff --git a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/swt/IWaveformPainter.java b/com.minres.scviewer.database.swt/src/com/minres/scviewer/database/swt/internal/IWaveformPainter.java
similarity index 92%
rename from com.minres.scviewer.ui/src/com/minres/scviewer/ui/swt/IWaveformPainter.java
rename to com.minres.scviewer.database.swt/src/com/minres/scviewer/database/swt/internal/IWaveformPainter.java
index 6d93718..2c6304e 100644
--- a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/swt/IWaveformPainter.java
+++ b/com.minres.scviewer.database.swt/src/com/minres/scviewer/database/swt/internal/IWaveformPainter.java
@@ -8,7 +8,7 @@
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
-package com.minres.scviewer.ui.swt;
+package com.minres.scviewer.database.swt.internal;
public interface IWaveformPainter extends IPainter {
diff --git a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/swt/ObservableList.java b/com.minres.scviewer.database.swt/src/com/minres/scviewer/database/swt/internal/ObservableList.java
similarity index 99%
rename from com.minres.scviewer.ui/src/com/minres/scviewer/ui/swt/ObservableList.java
rename to com.minres.scviewer.database.swt/src/com/minres/scviewer/database/swt/internal/ObservableList.java
index a9ee2d7..9b4238a 100644
--- a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/swt/ObservableList.java
+++ b/com.minres.scviewer.database.swt/src/com/minres/scviewer/database/swt/internal/ObservableList.java
@@ -8,7 +8,7 @@
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
-package com.minres.scviewer.ui.swt;
+package com.minres.scviewer.database.swt.internal;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
diff --git a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/swt/Ruler.java b/com.minres.scviewer.database.swt/src/com/minres/scviewer/database/swt/internal/Ruler.java
similarity index 91%
rename from com.minres.scviewer.ui/src/com/minres/scviewer/ui/swt/Ruler.java
rename to com.minres.scviewer.database.swt/src/com/minres/scviewer/database/swt/internal/Ruler.java
index 8faf9f2..32c7c41 100644
--- a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/swt/Ruler.java
+++ b/com.minres.scviewer.database.swt/src/com/minres/scviewer/database/swt/internal/Ruler.java
@@ -8,7 +8,7 @@
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
-package com.minres.scviewer.ui.swt;
+package com.minres.scviewer.database.swt.internal;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
@@ -21,11 +21,9 @@ import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;
-import com.minres.scviewer.ui.TxEditorPlugin;
-
public class Ruler extends Composite {
- static final int height = 20;
+ public static final int height = 20;
static final int tickY = 15;
static final int majorTickY = 5;
@@ -35,7 +33,6 @@ public class Ruler extends Composite {
private int length;
private long start;
- private TxEditorPlugin plugin;
private Color headerBgColor;
private Color headerFgColor;
private int bottom;
@@ -46,16 +43,11 @@ public class Ruler extends Composite {
private long rulerTickMajor = rulerTickMajorC*scaleFactor;
private String unit="";
- Ruler(Composite parent, int style) {
+ public Ruler(Composite parent, int style) {
super(parent, style | SWT.DOUBLE_BUFFERED | SWT.NO_BACKGROUND);
this.length=0;
headerBgColor=getDisplay().getSystemColor(SWT.COLOR_WHITE);
headerFgColor=getDisplay().getSystemColor(SWT.COLOR_BLACK);
- plugin=TxEditorPlugin.getDefault();
- if(plugin!=null){
- headerBgColor=plugin.getColor(TxEditorPlugin.headerBgColor);
- headerFgColor=plugin.getColor(TxEditorPlugin.headerFgColor);
- }
addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
Ruler.this.widgetDisposed(e);
diff --git a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/swt/SignalPainter.java b/com.minres.scviewer.database.swt/src/com/minres/scviewer/database/swt/internal/SignalPainter.java
similarity index 98%
rename from com.minres.scviewer.ui/src/com/minres/scviewer/ui/swt/SignalPainter.java
rename to com.minres.scviewer.database.swt/src/com/minres/scviewer/database/swt/internal/SignalPainter.java
index b838117..9dc2000 100644
--- a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/swt/SignalPainter.java
+++ b/com.minres.scviewer.database.swt/src/com/minres/scviewer/database/swt/internal/SignalPainter.java
@@ -8,7 +8,7 @@
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
-package com.minres.scviewer.ui.swt;
+package com.minres.scviewer.database.swt.internal;
import java.util.Map.Entry;
import java.util.NavigableMap;
@@ -24,7 +24,7 @@ import com.minres.scviewer.database.IWaveformEvent;
import com.minres.scviewer.database.ISignalChangeMulti;
import com.minres.scviewer.database.ISignalChangeSingle;
-class SignalPainter implements IWaveformPainter {
+public class SignalPainter implements IWaveformPainter {
/**
*
diff --git a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/swt/StreamPainter.java b/com.minres.scviewer.database.swt/src/com/minres/scviewer/database/swt/internal/StreamPainter.java
similarity index 98%
rename from com.minres.scviewer.ui/src/com/minres/scviewer/ui/swt/StreamPainter.java
rename to com.minres.scviewer.database.swt/src/com/minres/scviewer/database/swt/internal/StreamPainter.java
index b3d6799..d324117 100644
--- a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/swt/StreamPainter.java
+++ b/com.minres.scviewer.database.swt/src/com/minres/scviewer/database/swt/internal/StreamPainter.java
@@ -8,7 +8,7 @@
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
-package com.minres.scviewer.ui.swt;
+package com.minres.scviewer.database.swt.internal;
import java.util.Collection;
import java.util.List;
@@ -25,7 +25,7 @@ import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.ITxEvent;
import com.minres.scviewer.database.ITxStream;
-class StreamPainter implements IWaveformPainter{
+public class StreamPainter implements IWaveformPainter{
/**
*
diff --git a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/swt/TrackPainter.java b/com.minres.scviewer.database.swt/src/com/minres/scviewer/database/swt/internal/TrackPainter.java
similarity index 91%
rename from com.minres.scviewer.ui/src/com/minres/scviewer/ui/swt/TrackPainter.java
rename to com.minres.scviewer.database.swt/src/com/minres/scviewer/database/swt/internal/TrackPainter.java
index 5720eb1..817354d 100644
--- a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/swt/TrackPainter.java
+++ b/com.minres.scviewer.database.swt/src/com/minres/scviewer/database/swt/internal/TrackPainter.java
@@ -8,14 +8,14 @@
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
-package com.minres.scviewer.ui.swt;
+package com.minres.scviewer.database.swt.internal;
import java.util.Map.Entry;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle;
-class TrackPainter implements IPainter {
+public class TrackPainter implements IPainter {
/**
*
@@ -25,7 +25,7 @@ class TrackPainter implements IPainter {
/**
* @param txDisplay
*/
- TrackPainter(WaveformCanvas waveCanvas) {
+ public TrackPainter(WaveformCanvas waveCanvas) {
this.waveCanvas = waveCanvas;
}
diff --git a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/swt/WaveformCanvas.java b/com.minres.scviewer.database.swt/src/com/minres/scviewer/database/swt/internal/WaveformCanvas.java
similarity index 99%
rename from com.minres.scviewer.ui/src/com/minres/scviewer/ui/swt/WaveformCanvas.java
rename to com.minres.scviewer.database.swt/src/com/minres/scviewer/database/swt/internal/WaveformCanvas.java
index 066ec64..e234834 100644
--- a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/swt/WaveformCanvas.java
+++ b/com.minres.scviewer.database.swt/src/com/minres/scviewer/database/swt/internal/WaveformCanvas.java
@@ -8,7 +8,7 @@
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
-package com.minres.scviewer.ui.swt;
+package com.minres.scviewer.database.swt.internal;
import java.util.HashMap;
import java.util.LinkedList;
diff --git a/com.minres.scviewer.database.swt/src/org/eclipse/wb/swt/SWTResourceManager.java b/com.minres.scviewer.database.swt/src/org/eclipse/wb/swt/SWTResourceManager.java
new file mode 100644
index 0000000..53472ad
--- /dev/null
+++ b/com.minres.scviewer.database.swt/src/org/eclipse/wb/swt/SWTResourceManager.java
@@ -0,0 +1,447 @@
+/*******************************************************************************
+ * Copyright (c) 2014, 2015 MINRES Technologies GmbH 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:
+ * MINRES Technologies GmbH - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wb.swt;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * Utility class for managing OS resources associated with SWT controls such as colors, fonts, images, etc.
+ *
+ * !!! IMPORTANT !!! Application code must explicitly invoke the dispose()
method to release the
+ * operating system resources managed by cached objects when those objects and OS resources are no longer
+ * needed (e.g. on application shutdown)
+ *
+ * This class may be freely distributed as part of any application or plugin.
+ *
+ * @author scheglov_ke
+ * @author Dan Rubel
+ */
+public class SWTResourceManager {
+ ////////////////////////////////////////////////////////////////////////////
+ //
+ // Color
+ //
+ ////////////////////////////////////////////////////////////////////////////
+ private static Map m_colorMap = new HashMap();
+ /**
+ * Returns the system {@link Color} matching the specific ID.
+ *
+ * @param systemColorID
+ * the ID value for the color
+ * @return the system {@link Color} matching the specific ID
+ */
+ public static Color getColor(int systemColorID) {
+ Display display = Display.getCurrent();
+ return display.getSystemColor(systemColorID);
+ }
+ /**
+ * Returns a {@link Color} given its red, green and blue component values.
+ *
+ * @param r
+ * the red component of the color
+ * @param g
+ * the green component of the color
+ * @param b
+ * the blue component of the color
+ * @return the {@link Color} matching the given red, green and blue component values
+ */
+ public static Color getColor(int r, int g, int b) {
+ return getColor(new RGB(r, g, b));
+ }
+ /**
+ * Returns a {@link Color} given its RGB value.
+ *
+ * @param rgb
+ * the {@link RGB} value of the color
+ * @return the {@link Color} matching the RGB value
+ */
+ public static Color getColor(RGB rgb) {
+ Color color = m_colorMap.get(rgb);
+ if (color == null) {
+ Display display = Display.getCurrent();
+ color = new Color(display, rgb);
+ m_colorMap.put(rgb, color);
+ }
+ return color;
+ }
+ /**
+ * Dispose of all the cached {@link Color}'s.
+ */
+ public static void disposeColors() {
+ for (Color color : m_colorMap.values()) {
+ color.dispose();
+ }
+ m_colorMap.clear();
+ }
+ ////////////////////////////////////////////////////////////////////////////
+ //
+ // Image
+ //
+ ////////////////////////////////////////////////////////////////////////////
+ /**
+ * Maps image paths to images.
+ */
+ private static Map m_imageMap = new HashMap();
+ /**
+ * Returns an {@link Image} encoded by the specified {@link InputStream}.
+ *
+ * @param stream
+ * the {@link InputStream} encoding the image data
+ * @return the {@link Image} encoded by the specified input stream
+ */
+ protected static Image getImage(InputStream stream) throws IOException {
+ try {
+ Display display = Display.getCurrent();
+ ImageData data = new ImageData(stream);
+ if (data.transparentPixel > 0) {
+ return new Image(display, data, data.getTransparencyMask());
+ }
+ return new Image(display, data);
+ } finally {
+ stream.close();
+ }
+ }
+ /**
+ * Returns an {@link Image} stored in the file at the specified path.
+ *
+ * @param path
+ * the path to the image file
+ * @return the {@link Image} stored in the file at the specified path
+ */
+ public static Image getImage(String path) {
+ Image image = m_imageMap.get(path);
+ if (image == null) {
+ try {
+ image = getImage(new FileInputStream(path));
+ m_imageMap.put(path, image);
+ } catch (Exception e) {
+ image = getMissingImage();
+ m_imageMap.put(path, image);
+ }
+ }
+ return image;
+ }
+ /**
+ * Returns an {@link Image} stored in the file at the specified path relative to the specified class.
+ *
+ * @param clazz
+ * the {@link Class} relative to which to find the image
+ * @param path
+ * the path to the image file, if starts with '/'
+ * @return the {@link Image} stored in the file at the specified path
+ */
+ public static Image getImage(Class> clazz, String path) {
+ String key = clazz.getName() + '|' + path;
+ Image image = m_imageMap.get(key);
+ if (image == null) {
+ try {
+ image = getImage(clazz.getResourceAsStream(path));
+ m_imageMap.put(key, image);
+ } catch (Exception e) {
+ image = getMissingImage();
+ m_imageMap.put(key, image);
+ }
+ }
+ return image;
+ }
+ private static final int MISSING_IMAGE_SIZE = 10;
+ /**
+ * @return the small {@link Image} that can be used as placeholder for missing image.
+ */
+ private static Image getMissingImage() {
+ Image image = new Image(Display.getCurrent(), MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE);
+ //
+ GC gc = new GC(image);
+ gc.setBackground(getColor(SWT.COLOR_RED));
+ gc.fillRectangle(0, 0, MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE);
+ gc.dispose();
+ //
+ return image;
+ }
+ /**
+ * Style constant for placing decorator image in top left corner of base image.
+ */
+ public static final int TOP_LEFT = 1;
+ /**
+ * Style constant for placing decorator image in top right corner of base image.
+ */
+ public static final int TOP_RIGHT = 2;
+ /**
+ * Style constant for placing decorator image in bottom left corner of base image.
+ */
+ public static final int BOTTOM_LEFT = 3;
+ /**
+ * Style constant for placing decorator image in bottom right corner of base image.
+ */
+ public static final int BOTTOM_RIGHT = 4;
+ /**
+ * Internal value.
+ */
+ protected static final int LAST_CORNER_KEY = 5;
+ /**
+ * Maps images to decorated images.
+ */
+ @SuppressWarnings("unchecked")
+ private static Map>[] m_decoratedImageMap = new Map[LAST_CORNER_KEY];
+ /**
+ * Returns an {@link Image} composed of a base image decorated by another image.
+ *
+ * @param baseImage
+ * the base {@link Image} that should be decorated
+ * @param decorator
+ * the {@link Image} to decorate the base image
+ * @return {@link Image} The resulting decorated image
+ */
+ public static Image decorateImage(Image baseImage, Image decorator) {
+ return decorateImage(baseImage, decorator, BOTTOM_RIGHT);
+ }
+ /**
+ * Returns an {@link Image} composed of a base image decorated by another image.
+ *
+ * @param baseImage
+ * the base {@link Image} that should be decorated
+ * @param decorator
+ * the {@link Image} to decorate the base image
+ * @param corner
+ * the corner to place decorator image
+ * @return the resulting decorated {@link Image}
+ */
+ public static Image decorateImage(final Image baseImage, final Image decorator, final int corner) {
+ if (corner <= 0 || corner >= LAST_CORNER_KEY) {
+ throw new IllegalArgumentException("Wrong decorate corner");
+ }
+ Map> cornerDecoratedImageMap = m_decoratedImageMap[corner];
+ if (cornerDecoratedImageMap == null) {
+ cornerDecoratedImageMap = new HashMap>();
+ m_decoratedImageMap[corner] = cornerDecoratedImageMap;
+ }
+ Map decoratedMap = cornerDecoratedImageMap.get(baseImage);
+ if (decoratedMap == null) {
+ decoratedMap = new HashMap();
+ cornerDecoratedImageMap.put(baseImage, decoratedMap);
+ }
+ //
+ Image result = decoratedMap.get(decorator);
+ if (result == null) {
+ Rectangle bib = baseImage.getBounds();
+ Rectangle dib = decorator.getBounds();
+ //
+ result = new Image(Display.getCurrent(), bib.width, bib.height);
+ //
+ GC gc = new GC(result);
+ gc.drawImage(baseImage, 0, 0);
+ if (corner == TOP_LEFT) {
+ gc.drawImage(decorator, 0, 0);
+ } else if (corner == TOP_RIGHT) {
+ gc.drawImage(decorator, bib.width - dib.width, 0);
+ } else if (corner == BOTTOM_LEFT) {
+ gc.drawImage(decorator, 0, bib.height - dib.height);
+ } else if (corner == BOTTOM_RIGHT) {
+ gc.drawImage(decorator, bib.width - dib.width, bib.height - dib.height);
+ }
+ gc.dispose();
+ //
+ decoratedMap.put(decorator, result);
+ }
+ return result;
+ }
+ /**
+ * Dispose all of the cached {@link Image}'s.
+ */
+ public static void disposeImages() {
+ // dispose loaded images
+ {
+ for (Image image : m_imageMap.values()) {
+ image.dispose();
+ }
+ m_imageMap.clear();
+ }
+ // dispose decorated images
+ for (int i = 0; i < m_decoratedImageMap.length; i++) {
+ Map> cornerDecoratedImageMap = m_decoratedImageMap[i];
+ if (cornerDecoratedImageMap != null) {
+ for (Map decoratedMap : cornerDecoratedImageMap.values()) {
+ for (Image image : decoratedMap.values()) {
+ image.dispose();
+ }
+ decoratedMap.clear();
+ }
+ cornerDecoratedImageMap.clear();
+ }
+ }
+ }
+ ////////////////////////////////////////////////////////////////////////////
+ //
+ // Font
+ //
+ ////////////////////////////////////////////////////////////////////////////
+ /**
+ * Maps font names to fonts.
+ */
+ private static Map m_fontMap = new HashMap();
+ /**
+ * Maps fonts to their bold versions.
+ */
+ private static Map m_fontToBoldFontMap = new HashMap();
+ /**
+ * Returns a {@link Font} based on its name, height and style.
+ *
+ * @param name
+ * the name of the font
+ * @param height
+ * the height of the font
+ * @param style
+ * the style of the font
+ * @return {@link Font} The font matching the name, height and style
+ */
+ public static Font getFont(String name, int height, int style) {
+ return getFont(name, height, style, false, false);
+ }
+ /**
+ * Returns a {@link Font} based on its name, height and style. Windows-specific strikeout and underline
+ * flags are also supported.
+ *
+ * @param name
+ * the name of the font
+ * @param size
+ * the size of the font
+ * @param style
+ * the style of the font
+ * @param strikeout
+ * the strikeout flag (warning: Windows only)
+ * @param underline
+ * the underline flag (warning: Windows only)
+ * @return {@link Font} The font matching the name, height, style, strikeout and underline
+ */
+ public static Font getFont(String name, int size, int style, boolean strikeout, boolean underline) {
+ String fontName = name + '|' + size + '|' + style + '|' + strikeout + '|' + underline;
+ Font font = m_fontMap.get(fontName);
+ if (font == null) {
+ FontData fontData = new FontData(name, size, style);
+ if (strikeout || underline) {
+ try {
+ Class> logFontClass = Class.forName("org.eclipse.swt.internal.win32.LOGFONT"); //$NON-NLS-1$
+ Object logFont = FontData.class.getField("data").get(fontData); //$NON-NLS-1$
+ if (logFont != null && logFontClass != null) {
+ if (strikeout) {
+ logFontClass.getField("lfStrikeOut").set(logFont, Byte.valueOf((byte) 1)); //$NON-NLS-1$
+ }
+ if (underline) {
+ logFontClass.getField("lfUnderline").set(logFont, Byte.valueOf((byte) 1)); //$NON-NLS-1$
+ }
+ }
+ } catch (Throwable e) {
+ System.err.println("Unable to set underline or strikeout" + " (probably on a non-Windows platform). " + e); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ font = new Font(Display.getCurrent(), fontData);
+ m_fontMap.put(fontName, font);
+ }
+ return font;
+ }
+ /**
+ * Returns a bold version of the given {@link Font}.
+ *
+ * @param baseFont
+ * the {@link Font} for which a bold version is desired
+ * @return the bold version of the given {@link Font}
+ */
+ public static Font getBoldFont(Font baseFont) {
+ Font font = m_fontToBoldFontMap.get(baseFont);
+ if (font == null) {
+ FontData fontDatas[] = baseFont.getFontData();
+ FontData data = fontDatas[0];
+ font = new Font(Display.getCurrent(), data.getName(), data.getHeight(), SWT.BOLD);
+ m_fontToBoldFontMap.put(baseFont, font);
+ }
+ return font;
+ }
+ /**
+ * Dispose all of the cached {@link Font}'s.
+ */
+ public static void disposeFonts() {
+ // clear fonts
+ for (Font font : m_fontMap.values()) {
+ font.dispose();
+ }
+ m_fontMap.clear();
+ // clear bold fonts
+ for (Font font : m_fontToBoldFontMap.values()) {
+ font.dispose();
+ }
+ m_fontToBoldFontMap.clear();
+ }
+ ////////////////////////////////////////////////////////////////////////////
+ //
+ // Cursor
+ //
+ ////////////////////////////////////////////////////////////////////////////
+ /**
+ * Maps IDs to cursors.
+ */
+ private static Map m_idToCursorMap = new HashMap();
+ /**
+ * Returns the system cursor matching the specific ID.
+ *
+ * @param id
+ * int The ID value for the cursor
+ * @return Cursor The system cursor matching the specific ID
+ */
+ public static Cursor getCursor(int id) {
+ Integer key = Integer.valueOf(id);
+ Cursor cursor = m_idToCursorMap.get(key);
+ if (cursor == null) {
+ cursor = new Cursor(Display.getDefault(), id);
+ m_idToCursorMap.put(key, cursor);
+ }
+ return cursor;
+ }
+ /**
+ * Dispose all of the cached cursors.
+ */
+ public static void disposeCursors() {
+ for (Cursor cursor : m_idToCursorMap.values()) {
+ cursor.dispose();
+ }
+ m_idToCursorMap.clear();
+ }
+ ////////////////////////////////////////////////////////////////////////////
+ //
+ // General
+ //
+ ////////////////////////////////////////////////////////////////////////////
+ /**
+ * Dispose of cached objects and their underlying OS resources. This should only be called when the cached
+ * objects are no longer needed (e.g. on application shutdown).
+ */
+ public static void dispose() {
+ disposeColors();
+ disposeImages();
+ disposeFonts();
+ disposeCursors();
+ }
+}
\ No newline at end of file
diff --git a/com.minres.scviewer.ui/swing2swt.jar b/com.minres.scviewer.database.swt/swing2swt.jar
similarity index 100%
rename from com.minres.scviewer.ui/swing2swt.jar
rename to com.minres.scviewer.database.swt/swing2swt.jar
diff --git a/com.minres.scviewer.database.test/src/com/minres/scviewer/database/test/DatabaseServicesTest.java b/com.minres.scviewer.database.test/src/com/minres/scviewer/database/test/DatabaseServicesTest.java
index ded2470..55ab621 100644
--- a/com.minres.scviewer.database.test/src/com/minres/scviewer/database/test/DatabaseServicesTest.java
+++ b/com.minres.scviewer.database.test/src/com/minres/scviewer/database/test/DatabaseServicesTest.java
@@ -13,7 +13,6 @@ package com.minres.scviewer.database.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import java.io.File;
diff --git a/com.minres.scviewer.feature/feature.properties b/com.minres.scviewer.feature/feature.properties
index 08e61d2..5a1a376 100644
--- a/com.minres.scviewer.feature/feature.properties
+++ b/com.minres.scviewer.feature/feature.properties
@@ -1,7 +1,7 @@
featureName=SystemC simulation results viewer
providerName=MINRES Technologies GmbH
updateSiteName=SC Viewer Updates
-description=SystemC simulation results viewer dependencies
+description=A viewer for SystemC Verification Library transactions and VCD signals.
licenseURL=license.html
license=\
ECLIPSE FOUNDATION SOFTWARE USER AGREEMENT\n\
diff --git a/com.minres.scviewer.feature/feature.xml b/com.minres.scviewer.feature/feature.xml
index 65218da..30da863 100644
--- a/com.minres.scviewer.feature/feature.xml
+++ b/com.minres.scviewer.feature/feature.xml
@@ -6,8 +6,9 @@
provider-name="%providerName">
- A viewer for SystemC Verification Library transactions. It supports
-a SQLite based recording as well as the built-in text base recording.
+ A viewer for SystemC Verification Library transactions and VCD
+signals. It supports a SQLite based recording as well as the built-in
+text base recording.
@@ -81,4 +82,18 @@ http://www.eclipse.org/legal/epl-v10.html
install-size="0"
version="0.0.0"/>
+
+
+
+
diff --git a/com.minres.scviewer.parent/pom.xml b/com.minres.scviewer.parent/pom.xml
index e4d49e3..5494a79 100644
--- a/com.minres.scviewer.parent/pom.xml
+++ b/com.minres.scviewer.parent/pom.xml
@@ -10,9 +10,9 @@
../com.minres.scviewer.database.sqlite
../com.minres.scviewer.database.text
../com.minres.scviewer.database.vcd
- ../com.minres.scviewer.feature
+ ../com.minres.scviewer.database.swt
../com.minres.scviewer.ui
-
+ ../com.minres.scviewer.feature
../com.minres.scviewer.updateSite
../com.minres.scviewer.database.test
diff --git a/com.minres.scviewer.ui/.classpath b/com.minres.scviewer.ui/.classpath
index fffb3a2..b9a5b1e 100644
--- a/com.minres.scviewer.ui/.classpath
+++ b/com.minres.scviewer.ui/.classpath
@@ -2,7 +2,6 @@
-
-
+
diff --git a/com.minres.scviewer.ui/.settings/org.eclipse.core.resources.prefs b/com.minres.scviewer.ui/.settings/org.eclipse.core.resources.prefs
index 14960bd..99f26c0 100644
--- a/com.minres.scviewer.ui/.settings/org.eclipse.core.resources.prefs
+++ b/com.minres.scviewer.ui/.settings/org.eclipse.core.resources.prefs
@@ -1,3 +1,2 @@
eclipse.preferences.version=1
-encoding//src/com/minres/scviewer/ui/swt/TxDisplay.java=UTF-8
encoding/=UTF-8
diff --git a/com.minres.scviewer.ui/META-INF/MANIFEST.MF b/com.minres.scviewer.ui/META-INF/MANIFEST.MF
index acc0c5c..819353b 100644
--- a/com.minres.scviewer.ui/META-INF/MANIFEST.MF
+++ b/com.minres.scviewer.ui/META-INF/MANIFEST.MF
@@ -6,6 +6,7 @@ Bundle-Version: 1.0.0.qualifier
Bundle-Activator: com.minres.scviewer.ui.TxEditorPlugin
Bundle-Vendor: MINRES Technologies GmbH
Require-Bundle: com.minres.scviewer.database;bundle-version="1.0.0",
+ com.minres.scviewer.database.swt;bundle-version="1.0.0",
org.eclipse.core.runtime,
org.eclipse.core.resources,
org.eclipse.jface.text,
@@ -19,6 +20,4 @@ Require-Bundle: com.minres.scviewer.database;bundle-version="1.0.0",
org.eclipse.jface
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ActivationPolicy: lazy
-Bundle-ClassPath: .,
- swing2swt.jar
Import-Package: com.google.common.collect
diff --git a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/TxEditorPart.java b/com.minres.scviewer.ui/src/com/minres/scviewer/ui/TxEditorPart.java
index 2ff0cc6..fe8d05c 100644
--- a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/TxEditorPart.java
+++ b/com.minres.scviewer.ui/src/com/minres/scviewer/ui/TxEditorPart.java
@@ -46,8 +46,8 @@ import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.IWaveformEvent;
import com.minres.scviewer.database.WaveformDb;
-import com.minres.scviewer.ui.handler.GotoDirection;
-import com.minres.scviewer.ui.swt.TxDisplay;
+import com.minres.scviewer.database.swt.GotoDirection;
+import com.minres.scviewer.database.swt.TxDisplay;
import com.minres.scviewer.ui.views.TxOutlinePage;
public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPageContributor {
@@ -162,7 +162,8 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
}
final File[] files=filesToLoad.toArray(new File[filesToLoad.size()]);
- ps.busyCursorWhile(new IRunnableWithProgress() {
+ ps.run(true, false, new IRunnableWithProgress() {
+ //ps.busyCursorWhile(new IRunnableWithProgress() {
public void run(IProgressMonitor pm) throws InvocationTargetException {
pm.beginTask("Loading database "+files[0].getName(), files.length);
try {
diff --git a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/handler/GotoNext.java b/com.minres.scviewer.ui/src/com/minres/scviewer/ui/handler/GotoNext.java
index d54fd43..c22a412 100644
--- a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/handler/GotoNext.java
+++ b/com.minres.scviewer.ui/src/com/minres/scviewer/ui/handler/GotoNext.java
@@ -16,6 +16,7 @@ import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.handlers.HandlerUtil;
+import com.minres.scviewer.database.swt.GotoDirection;
import com.minres.scviewer.ui.TxEditorPart;
public class GotoNext extends AbstractHandler {
diff --git a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/handler/GotoPrev.java b/com.minres.scviewer.ui/src/com/minres/scviewer/ui/handler/GotoPrev.java
index f2d7a1e..d5e34e8 100644
--- a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/handler/GotoPrev.java
+++ b/com.minres.scviewer.ui/src/com/minres/scviewer/ui/handler/GotoPrev.java
@@ -16,6 +16,7 @@ import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.handlers.HandlerUtil;
+import com.minres.scviewer.database.swt.GotoDirection;
import com.minres.scviewer.ui.TxEditorPart;
public class GotoPrev extends AbstractHandler {