diff --git a/plugins/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/SQLiteDbLoader.java b/plugins/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/SQLiteDbLoader.java
index 335e38a..e9e9a21 100644
--- a/plugins/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/SQLiteDbLoader.java
+++ b/plugins/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/SQLiteDbLoader.java
@@ -111,7 +111,7 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
pcs.firePropertyChange(IWaveformDbLoader.LOADING_FINISHED, null, null);
} catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException
| InvocationTargetException | SQLException | IntrospectionException e) {
- throw new InputFormatException();
+ throw new InputFormatException(e.toString());
}
}
diff --git a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TextDbLoader.java b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TextDbLoader.java
index cdfabb9..ac0c1d9 100644
--- a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TextDbLoader.java
+++ b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TextDbLoader.java
@@ -165,8 +165,8 @@ public class TextDbLoader implements IWaveformDbLoader {
try {
mapDbFile = File.createTempFile("." + file.getName(), ".mapdb", null /* file.parentFile */);
Files.delete(Paths.get(mapDbFile.getPath()));
- } catch (IOException e1) {
- throw new InputFormatException();
+ } catch (IOException e) {
+ throw new InputFormatException(e.toString());
}
mapDb = DBMaker.fileDB(mapDbFile).fileMmapEnable() // Always enable mmap
.fileMmapEnableIfSupported().fileMmapPreclearDisable().allocateStartSize(512l * 1024l * 1024l)
@@ -180,9 +180,7 @@ public class TextDbLoader implements IWaveformDbLoader {
transactions = parser.txSink.create();
} catch (IllegalArgumentException | ArrayIndexOutOfBoundsException e) {
} catch (Exception e) {
- System.out.println("---->>> Exception " + e.toString() + " caught while loading database");
- e.printStackTrace();
- throw new InputFormatException();
+ throw new InputFormatException(e.toString());
}
for (TxStream stream : txStreams.values()) {
Thread t = new Thread() {
@@ -297,8 +295,9 @@ public class TextDbLoader implements IWaveformDbLoader {
*
* @param inputStream the input stream
* @throws IOException Signals that an I/O exception has occurred.
+ * @throws InputFormatException Signals that the input format is wrong
*/
- void parseInput(InputStream inputStream) throws IOException {
+ void parseInput(InputStream inputStream) throws IOException, InputFormatException {
reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
String curLine = reader.readLine();
String nextLine = null;
@@ -336,8 +335,9 @@ public class TextDbLoader implements IWaveformDbLoader {
* @param nextLine the next line
* @return the string
* @throws IOException Signals that an I/O exception has occurred.
+ * @throws InputFormatException Signals that the input format is wrong
*/
- private String parseLine(String curLine, String nextLine) throws IOException {
+ private String parseLine(String curLine, String nextLine) throws IOException, InputFormatException {
String[] tokens = curLine.split("\\s+");
if ("tx_record_attribute".equals(tokens[0])) {
Long id = Long.parseLong(tokens[1]);
@@ -441,10 +441,8 @@ public class TextDbLoader implements IWaveformDbLoader {
}
} else if (")".equals(tokens[0])) {
generator = null;
- } else if ("a".equals(tokens[0])) {// matcher = line =~ /^a\s+(.+)$/
- System.out.println("Don't know what to do with: '" + curLine + "'");
} else
- System.out.println("Don't know what to do with: '" + curLine + "'");
+ throw new InputFormatException("Don't know what to do with: '" + curLine + "'");
return nextLine;
}
diff --git a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/WaveformView.java b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/WaveformView.java
index 8313895..6fb28d4 100644
--- a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/WaveformView.java
+++ b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/WaveformView.java
@@ -771,8 +771,6 @@ public class WaveformView implements IWaveformView {
if (currentTxSelection != null)
currentTxSelection = null;
selectionChanged = true;
- } else {
- System.err.println("Invalid selection");
}
}
} else {
diff --git a/plugins/com.minres.scviewer.database.ui.swt/src/org/eclipse/wb/swt/SWTResourceManager.java b/plugins/com.minres.scviewer.database.ui.swt/src/org/eclipse/wb/swt/SWTResourceManager.java
index d8a2858..0024a03 100644
--- a/plugins/com.minres.scviewer.database.ui.swt/src/org/eclipse/wb/swt/SWTResourceManager.java
+++ b/plugins/com.minres.scviewer.database.ui.swt/src/org/eclipse/wb/swt/SWTResourceManager.java
@@ -29,14 +29,17 @@ 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.
+ * 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
+ * !!! 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
*/
@@ -46,57 +49,54 @@ public class SWTResourceManager {
// Color
//
////////////////////////////////////////////////////////////////////////////
- private static Map m_colorMap = new HashMap();
+ private static Map colorMap = new HashMap<>();
+
+ private SWTResourceManager() {}
+
/**
* Returns the system {@link Color} matching the specific ID.
*
- * @param systemColorID
- * the ID value for the color
+ * @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
+ * @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
+ * @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;
+ return colorMap.computeIfAbsent(rgb, k -> new Color(Display.getCurrent(), rgb));
}
+
/**
* Dispose of all the cached {@link Color}'s.
*/
public static void disposeColors() {
- for (Color color : m_colorMap.values()) {
+ for (Color color : colorMap.values()) {
color.dispose();
}
- m_colorMap.clear();
+ colorMap.clear();
}
+
////////////////////////////////////////////////////////////////////////////
//
// Image
@@ -105,12 +105,12 @@ public class SWTResourceManager {
/**
* Maps image paths to images.
*/
- private static Map m_imageMap = new HashMap();
+ private static Map imageMap = new HashMap<>();
+
/**
* Returns an {@link Image} encoded by the specified {@link InputStream}.
*
- * @param stream
- * the {@link InputStream} encoding the image data
+ * @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 {
@@ -125,52 +125,55 @@ public class SWTResourceManager {
stream.close();
}
}
+
/**
* Returns an {@link Image} stored in the file at the specified path.
*
- * @param path
- * the path to the image file
+ * @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);
+ Image image = imageMap.get(path);
if (image == null) {
try {
image = getImage(new FileInputStream(path));
- m_imageMap.put(path, image);
+ imageMap.put(path, image);
} catch (Exception e) {
image = getMissingImage();
- m_imageMap.put(path, image);
+ imageMap.put(path, image);
}
}
return image;
}
+
/**
- * Returns an {@link Image} stored in the file at the specified path relative to the specified class.
+ * 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 '/'
+ * @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);
+ Image image = imageMap.get(key);
if (image == null) {
try {
image = getImage(clazz.getResourceAsStream(path));
- m_imageMap.put(key, image);
+ imageMap.put(key, image);
} catch (Exception e) {
image = getMissingImage();
- m_imageMap.put(key, image);
+ 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.
+ * @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);
@@ -182,6 +185,7 @@ public class SWTResourceManager {
//
return image;
}
+
/**
* Style constant for placing decorator image in top left corner of base image.
*/
@@ -191,11 +195,13 @@ public class SWTResourceManager {
*/
public static final int TOP_RIGHT = 2;
/**
- * Style constant for placing decorator image in bottom left corner of base image.
+ * 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.
+ * Style constant for placing decorator image in bottom right corner of base
+ * image.
*/
public static final int BOTTOM_RIGHT = 4;
/**
@@ -206,83 +212,77 @@ public class SWTResourceManager {
* Maps images to decorated images.
*/
@SuppressWarnings("unchecked")
- private static Map>[] m_decoratedImageMap = new Map[LAST_CORNER_KEY];
+ private static Map>[] 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
+ * @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
+ * @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];
+ Map> cornerDecoratedImageMap = decoratedImageMap[corner];
if (cornerDecoratedImageMap == null) {
- cornerDecoratedImageMap = new HashMap>();
- m_decoratedImageMap[corner] = cornerDecoratedImageMap;
+ cornerDecoratedImageMap = new HashMap<>();
+ 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) {
+ Map decoratedMap = cornerDecoratedImageMap.computeIfAbsent(baseImage,
+ k -> new HashMap());
+ return decoratedMap.computeIfAbsent(decorator, k -> {
Rectangle bib = baseImage.getBounds();
Rectangle dib = decorator.getBounds();
- //
- result = new Image(Display.getCurrent(), bib.width, bib.height);
- //
+ Image result = new Image(Display.getCurrent(), bib.width, bib.height);
GC gc = new GC(result);
gc.drawImage(baseImage, 0, 0);
- if (corner == TOP_LEFT) {
+ switch (corner) {
+ case TOP_LEFT:
gc.drawImage(decorator, 0, 0);
- } else if (corner == TOP_RIGHT) {
+ break;
+ case TOP_RIGHT:
gc.drawImage(decorator, bib.width - dib.width, 0);
- } else if (corner == BOTTOM_LEFT) {
+ break;
+ case BOTTOM_LEFT:
gc.drawImage(decorator, 0, bib.height - dib.height);
- } else if (corner == BOTTOM_RIGHT) {
+ break;
+ case BOTTOM_RIGHT:
gc.drawImage(decorator, bib.width - dib.width, bib.height - dib.height);
+ break;
+ default:
+ // do nothing
}
gc.dispose();
- //
- decoratedMap.put(decorator, result);
- }
- return 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();
+ for (Image image : imageMap.values()) {
+ image.dispose();
}
+ imageMap.clear();
// dispose decorated images
- for (int i = 0; i < m_decoratedImageMap.length; i++) {
- Map> cornerDecoratedImageMap = m_decoratedImageMap[i];
+ for (int i = 0; i < decoratedImageMap.length; i++) {
+ Map> cornerDecoratedImageMap = decoratedImageMap[i];
if (cornerDecoratedImageMap != null) {
for (Map decoratedMap : cornerDecoratedImageMap.values()) {
for (Image image : decoratedMap.values()) {
@@ -294,6 +294,7 @@ public class SWTResourceManager {
}
}
}
+
////////////////////////////////////////////////////////////////////////////
//
// Font
@@ -302,45 +303,39 @@ public class SWTResourceManager {
/**
* Maps font names to fonts.
*/
- private static Map m_fontMap = new HashMap();
+ private static Map fontMap = new HashMap<>();
/**
* Maps fonts to their bold versions.
*/
- private static Map m_fontToBoldFontMap = new HashMap();
+ private static Map 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
+ * @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.
+ * 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
+ * @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) {
+ return fontMap.computeIfAbsent(fontName, k -> {
FontData fontData = new FontData(name, size, style);
if (strikeout || underline) {
try {
@@ -354,47 +349,45 @@ public class SWTResourceManager {
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$
+ } catch (Exception e) {
}
}
- font = new Font(Display.getCurrent(), fontData);
- m_fontMap.put(fontName, font);
- }
- return font;
+ return new Font(Display.getCurrent(), fontData);
+
+ });
+
}
+
/**
* Returns a bold version of the given {@link Font}.
*
- * @param baseFont
- * the {@link Font} for which a bold version is desired
+ * @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();
+ return fontToBoldFontMap.computeIfAbsent(baseFont, k -> {
+ 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;
+ return new Font(Display.getCurrent(), data.getName(), data.getHeight(), SWT.BOLD);
+ });
}
+
/**
* Dispose all of the cached {@link Font}'s.
*/
public static void disposeFonts() {
// clear fonts
- for (Font font : m_fontMap.values()) {
+ for (Font font : fontMap.values()) {
font.dispose();
}
- m_fontMap.clear();
+ fontMap.clear();
// clear bold fonts
- for (Font font : m_fontToBoldFontMap.values()) {
+ for (Font font : fontToBoldFontMap.values()) {
font.dispose();
}
- m_fontToBoldFontMap.clear();
+ fontToBoldFontMap.clear();
}
+
////////////////////////////////////////////////////////////////////////////
//
// Cursor
@@ -403,40 +396,38 @@ public class SWTResourceManager {
/**
* Maps IDs to cursors.
*/
- private static Map m_idToCursorMap = new HashMap();
+ private static Map idToCursorMap = new HashMap<>();
+
/**
* Returns the system cursor matching the specific ID.
*
- * @param id
- * int The ID value for the cursor
+ * @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;
+ return idToCursorMap.computeIfAbsent(key, k -> new Cursor(Display.getDefault(), id));
}
+
/**
* Dispose all of the cached cursors.
*/
public static void disposeCursors() {
- for (Cursor cursor : m_idToCursorMap.values()) {
+ for (Cursor cursor : idToCursorMap.values()) {
cursor.dispose();
}
- m_idToCursorMap.clear();
+ 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).
+ * 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();
diff --git a/plugins/com.minres.scviewer.database.vcd/src/com/minres/scviewer/database/vcd/VCDDbLoader.java b/plugins/com.minres.scviewer.database.vcd/src/com/minres/scviewer/database/vcd/VCDDbLoader.java
index 1d5c165..c92e032 100644
--- a/plugins/com.minres.scviewer.database.vcd/src/com/minres/scviewer/database/vcd/VCDDbLoader.java
+++ b/plugins/com.minres.scviewer.database.vcd/src/com/minres/scviewer/database/vcd/VCDDbLoader.java
@@ -113,9 +113,9 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
moduleStack=null;
} catch(IOException e) {
moduleStack=null;
- throw new InputFormatException();
+ throw new InputFormatException(e.toString());
}
- if(!res) throw new InputFormatException();
+ if(!res) throw new InputFormatException("Could not parse VCD file");
// calculate max time of this database
for(IWaveform waveform:signals) {
NavigableMap events =waveform.getEvents();
diff --git a/plugins/com.minres.scviewer.database/src/com/minres/scviewer/database/InputFormatException.java b/plugins/com.minres.scviewer.database/src/com/minres/scviewer/database/InputFormatException.java
index 0945c0b..cf46fbd 100644
--- a/plugins/com.minres.scviewer.database/src/com/minres/scviewer/database/InputFormatException.java
+++ b/plugins/com.minres.scviewer.database/src/com/minres/scviewer/database/InputFormatException.java
@@ -15,6 +15,18 @@ package com.minres.scviewer.database;
*/
public class InputFormatException extends Exception {
+ /** The message. */
+ public final String message;
+
+ /**
+ * Instantiates a new input format exception.
+ *
+ * @param string the string
+ */
+ public InputFormatException(String string) {
+ message=string;
+ }
+
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 8676129878197783368L;
diff --git a/plugins/com.minres.scviewer.e4.application/Application.e4xmi b/plugins/com.minres.scviewer.e4.application/Application.e4xmi
index 491b550..bdf9b97 100644
--- a/plugins/com.minres.scviewer.e4.application/Application.e4xmi
+++ b/plugins/com.minres.scviewer.e4.application/Application.e4xmi
@@ -287,5 +287,5 @@
-
+
diff --git a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/AppModelId.java b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/AppModelId.java
index 7b372a6..a28bac2 100644
--- a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/AppModelId.java
+++ b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/AppModelId.java
@@ -8,7 +8,7 @@ public class AppModelId {
public static final String ADDON_ORG_ECLIPSE_E4_UI_WORKBENCH_COMMANDS_MODEL = "org.eclipse.e4.ui.workbench.commands.model";
public static final String ADDON_ORG_ECLIPSE_E4_UI_WORKBENCH_CONTEXTS_MODEL = "org.eclipse.e4.ui.workbench.contexts.model";
public static final String ADDON_ORG_ECLIPSE_E4_UI_WORKBENCH_HANDLER_MODEL = "org.eclipse.e4.ui.workbench.handler.model";
- public static final String ADDON_ORG_ECLIPSE_E4_UI_WORKBENC__H_ADDONS_DNDADDON_DNDADDON = "org.eclipse.e4.ui.workbench.addons.dndaddon.DnDAddon";
+ public static final String ADDON_ORG_ECLIPSE_E4_UI_WORKBENCH_ADDONS_DNDADDON_DNDADDON = "org.eclipse.e4.ui.workbench.addons.dndaddon.DnDAddon";
public static final String APPLICATION_ORG_ECLIPSE_E4_IDE_APPLICATION = "org.eclipse.e4.ide.application";
public static final String BINDINGCONTEXT_ORG_ECLIPSE_UI_CONTEXTS_DIALOG = "org.eclipse.ui.contexts.dialog";
public static final String BINDINGCONTEXT_ORG_ECLIPSE_UI_CONTEXTS_DIALOGANDWINDOW = "org.eclipse.ui.contexts.dialogAndWindow";
@@ -152,4 +152,6 @@ public class AppModelId {
public static final String TRIMBAR_ORG_ECLIPSE_UI_MAIN_TOOLBAR = "org.eclipse.ui.main.toolbar";
public static final String TRIMBAR_ORG_ECLIPSE_UI_TRIM_STATUS = "org.eclipse.ui.trim.status";
public static final String WINDOW_COM_MINRES_SCVIEWER_E4_APPLICATION_DIALOG_ABOUTSCVIEWER = "com.minres.scviewer.e4.application.dialog.aboutscviewer";
+
+ private AppModelId(){}
}
\ No newline at end of file
diff --git a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/E4LifeCycle.java b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/E4LifeCycle.java
index 4ef9f5b..812260c 100644
--- a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/E4LifeCycle.java
+++ b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/E4LifeCycle.java
@@ -12,12 +12,12 @@ package com.minres.scviewer.e4.application;
import java.io.IOException;
-import javax.annotation.PostConstruct;
import javax.inject.Inject;
import org.eclipse.core.runtime.Platform;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.services.events.IEventBroker;
+import org.eclipse.e4.core.services.log.Logger;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.model.application.ui.basic.MPartStack;
@@ -32,9 +32,6 @@ import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState;
import org.eclipse.equinox.app.IApplicationContext;
import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.swt.widgets.Display;
-import org.osgi.service.event.Event;
-import org.osgi.service.event.EventHandler;
-import org.eclipse.e4.core.services.log.Logger;
import com.minres.scviewer.e4.application.options.Options;
import com.minres.scviewer.e4.application.options.Options.Multiplicity;
@@ -49,15 +46,6 @@ import com.minres.scviewer.e4.application.options.Options.Separator;
public class E4LifeCycle {
@Inject private Logger logger;
-
- /**
- * Post construct.
- *
- * @param eventBroker the event broker
- */
- @PostConstruct
- private static void postConstruct(final IEventBroker eventBroker) {
- }
/**
* Post context create. Open a database if given on command line using the OpenViewHandler
@@ -68,47 +56,44 @@ public class E4LifeCycle {
@PostContextCreate
void postContextCreate(IApplicationContext appContext, final IEventBroker eventBroker,
final IEclipseContext workbenchContext) {
-
+
final String[] args = (String[])appContext.getArguments().get(IApplicationContext.APPLICATION_ARGS);
final Options opt = new Options(args, 0, Integer.MAX_VALUE);
opt.getSet()
- .addOption("clearPersistedState", Multiplicity.ZERO_OR_ONE)
- .addOption("c", Separator.BLANK, Multiplicity.ZERO_OR_ONE);
+ .addOption("clearPersistedState", Multiplicity.ZERO_OR_ONE)
+ .addOption("c", Separator.BLANK, Multiplicity.ZERO_OR_ONE);
if (!opt.check(Options.DEFAULT_SET, true, false)) {
logger.error(opt.getCheckErrors());
System.exit(1);
}
- eventBroker.subscribe(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE, new EventHandler() {
- @Override
- public void handleEvent(Event event) {
- Location instanceLocation = Platform.getInstanceLocation();
- try {
- boolean isLocked = instanceLocation.isLocked();
- if(isLocked)
- instanceLocation.release();
- } catch (IOException e) { }
- if(!opt.getSet().getData().isEmpty()) {
- Display.getCurrent().timerExec (100, () -> {
- MApplication app= workbenchContext.get(MApplication.class);
- EModelService modelService = workbenchContext.get(EModelService.class);
- EPartService partService= workbenchContext.get(EPartService.class);
- MPart part = partService .createPart("com.minres.scviewer.e4.application.partdescriptor.waveformviewer"); //$NON-NLS-1$
- part.setLabel(opt.getSet().getData().get(0));
- MPartStack partStack = (MPartStack)modelService.find("org.eclipse.editorss", app); //$NON-NLS-1$
- partStack.getChildren().add(part);
- partService.showPart(part, PartState.CREATE);
- partService.showPart(part, PartState.ACTIVATE);
- IEclipseContext ctx = part.getContext();
- ctx.modify("input", opt.getSet().getData());
- String confFile =opt.getSet().isSet("c")?opt.getSet().getOption("c").getResultValue(0):"";
- ctx.modify("config", confFile); //$NON-NLS-1$
- });
- }
+ eventBroker.subscribe(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE, event -> {
+ Location instanceLocation = Platform.getInstanceLocation();
+ try {
+ boolean isLocked = instanceLocation.isLocked();
+ if(isLocked)
+ instanceLocation.release();
+ } catch (IOException e) { }
+ if(!opt.getSet().getData().isEmpty()) {
+ Display.getCurrent().timerExec (100, () -> {
+ MApplication app= workbenchContext.get(MApplication.class);
+ EModelService modelService = workbenchContext.get(EModelService.class);
+ EPartService partService= workbenchContext.get(EPartService.class);
+ MPart part = partService .createPart("com.minres.scviewer.e4.application.partdescriptor.waveformviewer"); //$NON-NLS-1$
+ part.setLabel(opt.getSet().getData().get(0));
+ MPartStack partStack = (MPartStack)modelService.find("org.eclipse.editorss", app); //$NON-NLS-1$
+ partStack.getChildren().add(part);
+ partService.showPart(part, PartState.CREATE);
+ partService.showPart(part, PartState.ACTIVATE);
+ IEclipseContext ctx = part.getContext();
+ ctx.modify("input", opt.getSet().getData());
+ String confFile =opt.getSet().isSet("c")?opt.getSet().getOption("c").getResultValue(0):"";
+ ctx.modify("config", confFile); //$NON-NLS-1$
+ });
}
});
}
-
+
/**
* Pre save.
*
diff --git a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/status/HeapStatus.java b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/status/HeapStatus.java
index 0aa356b..6bc4bf8 100644
--- a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/status/HeapStatus.java
+++ b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/status/HeapStatus.java
@@ -53,8 +53,34 @@ public class HeapStatus extends Composite {
private Image disabledGcImage;
/** The arm col. */
- private Color bgCol, usedMemCol, lowMemCol, freeMemCol, topLeftCol, bottomRightCol, sepCol, textCol, markCol,
- armCol;
+ private Color bgCol;
+
+ /** The used mem col. */
+ private Color usedMemCol;
+
+ /** The low mem col. */
+ private Color lowMemCol;
+
+ /** The free mem col. */
+ private Color freeMemCol;
+
+ /** The top left col. */
+ private Color topLeftCol;
+
+ /** The bottom right col. */
+ private Color bottomRightCol;
+
+ /** The sep col. */
+ private Color sepCol;
+
+ /** The text col. */
+ private Color textCol;
+
+ /** The mark col. */
+ private Color markCol;
+
+ /** The arm col. */
+ private Color armCol;
/** The button. */
private Canvas button;
@@ -241,6 +267,11 @@ public class HeapStatus extends Composite {
});
}
+ /**
+ * Sets the background.
+ *
+ * @param color the new background
+ */
/*
* (non-Javadoc)
*
@@ -254,6 +285,11 @@ public class HeapStatus extends Composite {
button.update();
}
+ /**
+ * Sets the foreground.
+ *
+ * @param color the new foreground
+ */
/*
* (non-Javadoc)
*
@@ -272,6 +308,11 @@ public class HeapStatus extends Composite {
button.update();
}
+ /**
+ * Gets the foreground.
+ *
+ * @return the foreground
+ */
/*
* (non-Javadoc)
*
@@ -329,6 +370,14 @@ public class HeapStatus extends Composite {
}
}
+ /**
+ * Compute size.
+ *
+ * @param wHint the w hint
+ * @param hHint the h hint
+ * @param changed the changed
+ * @return the point
+ */
/*
* (non-Javadoc)
*
@@ -681,6 +730,9 @@ public class HeapStatus extends Composite {
super("&Set Mark");
}
+ /**
+ * Run.
+ */
/*
* (non-Javadoc)
*
@@ -704,6 +756,9 @@ public class HeapStatus extends Composite {
super("&Clear Mark");
}
+ /**
+ * Run.
+ */
/*
* (non-Javadoc)
*
@@ -729,6 +784,9 @@ public class HeapStatus extends Composite {
setChecked(showMax);
}
+ /**
+ * Run.
+ */
/*
* (non-Javadoc)
*
diff --git a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/AboutDialog.java b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/AboutDialog.java
index 2be95b1..c5a96bf 100644
--- a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/AboutDialog.java
+++ b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/AboutDialog.java
@@ -109,10 +109,7 @@ public class AboutDialog extends Dialog {
styleRange.fontStyle = SWT.BOLD;
styledText.setStyleRange(styleRange);
///^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/
- Pattern pattern = Pattern.compile("https?:\\/\\/([\\da-z\\.-]+)\\.([a-z\\.]{2,6})([\\/\\w\\.-]*)*\\/?"); //$NON-NLS-1$
- // in case you would like to ignore case sensitivity,
- // you could use this statement:
- // Pattern pattern = Pattern.compile("\\s+", Pattern.CASE_INSENSITIVE);
+ Pattern pattern = Pattern.compile("https?:\\/\\/([\\da-z\\.-]+)\\.([a-z\\.]{2,6})([\\/\\w\\.-]*)*\\/?"/*, Pattern.CASE_INSENSITIVE*/); //$NON-NLS-1$
Matcher matcher = pattern.matcher(productTitle+copyrightText);
// check all occurance
while (matcher.find()) {
diff --git a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/FileBrowserDialog.java b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/FileBrowserDialog.java
index 8d86b03..24a1074 100644
--- a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/FileBrowserDialog.java
+++ b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/FileBrowserDialog.java
@@ -46,6 +46,7 @@ import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.wb.swt.ResourceManager;
+import org.eclipse.wb.swt.SWTResourceManager;
import com.minres.scviewer.e4.application.Constants;
@@ -249,7 +250,7 @@ public class FileBrowserDialog extends TrayDialog {
fileNameEntry = new Text(bottomBar, SWT.BORDER);
fileNameEntry.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
- fileNameEntry.setEditable(false); //TODO: temporary disabled
+ fileNameEntry.setEditable(false);
fileNameEntry.setEnabled(false);
filterCombo = new Combo(bottomBar, SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY);
@@ -457,7 +458,7 @@ public class FileBrowserDialog extends TrayDialog {
@Override
public Color getForeground(Object element) {
- return globber.matches(element) || ((File)element).isDirectory()? null: ResourceManager.getColor(SWT.COLOR_GRAY);
+ return globber.matches(element) || ((File)element).isDirectory()? null: SWTResourceManager.getColor(SWT.COLOR_GRAY);
}
}
diff --git a/plugins/com.minres.scviewer.e4.application/src/org/eclipse/wb/swt/ResourceManager.java b/plugins/com.minres.scviewer.e4.application/src/org/eclipse/wb/swt/ResourceManager.java
index f7b6899..d7d88a0 100644
--- a/plugins/com.minres.scviewer.e4.application/src/org/eclipse/wb/swt/ResourceManager.java
+++ b/plugins/com.minres.scviewer.e4.application/src/org/eclipse/wb/swt/ResourceManager.java
@@ -138,35 +138,33 @@ public class ResourceManager extends SWTResourceManager {
decoratedImageMap[corner] = cornerDecoratedImageMap;
}
Map decoratedMap = cornerDecoratedImageMap.computeIfAbsent(baseImage, k -> new HashMap());
- Image result = decoratedMap.get(decorator);
- if (result == null) {
- final Rectangle bib = baseImage.getBounds();
- final Rectangle dib = decorator.getBounds();
- final Point baseImageSize = new Point(bib.width, bib.height);
- CompositeImageDescriptor compositImageDesc = new CompositeImageDescriptor() {
- @Override
- protected void drawCompositeImage(int width, int height) {
- drawImage(createCachedImageDataProvider(baseImage), 0, 0);
- if (corner == TOP_LEFT) {
- drawImage(getUnzoomedImageDataProvider(decorator.getImageData()) , 0, 0);
- } else if (corner == TOP_RIGHT) {
- drawImage(getUnzoomedImageDataProvider(decorator.getImageData()), bib.width - dib.width, 0);
- } else if (corner == BOTTOM_LEFT) {
- drawImage(getUnzoomedImageDataProvider(decorator.getImageData()), 0, bib.height - dib.height);
- } else if (corner == BOTTOM_RIGHT) {
- drawImage(getUnzoomedImageDataProvider(decorator.getImageData()), bib.width - dib.width, bib.height - dib.height);
- }
+ return decoratedMap.computeIfAbsent(decorator, k -> createImage(baseImage, decorator, corner));
+ }
+
+ private static Image createImage(final Image baseImage, final Image decorator, final int corner) {
+ final Rectangle bib = baseImage.getBounds();
+ final Rectangle dib = decorator.getBounds();
+ final Point baseImageSize = new Point(bib.width, bib.height);
+ CompositeImageDescriptor compositImageDesc = new CompositeImageDescriptor() {
+ @Override
+ protected void drawCompositeImage(int width, int height) {
+ drawImage(createCachedImageDataProvider(baseImage), 0, 0);
+ if (corner == TOP_LEFT) {
+ drawImage(getUnzoomedImageDataProvider(decorator.getImageData()) , 0, 0);
+ } else if (corner == TOP_RIGHT) {
+ drawImage(getUnzoomedImageDataProvider(decorator.getImageData()), bib.width - dib.width, 0);
+ } else if (corner == BOTTOM_LEFT) {
+ drawImage(getUnzoomedImageDataProvider(decorator.getImageData()), 0, bib.height - dib.height);
+ } else if (corner == BOTTOM_RIGHT) {
+ drawImage(getUnzoomedImageDataProvider(decorator.getImageData()), bib.width - dib.width, bib.height - dib.height);
}
- @Override
- protected Point getSize() {
- return baseImageSize;
- }
- };
- //
- result = compositImageDesc.createImage();
- decoratedMap.put(decorator, result);
- }
- return result;
+ }
+ @Override
+ protected Point getSize() {
+ return baseImageSize;
+ }
+ };
+ return compositImageDesc.createImage();
}
private static ImageDataProvider getUnzoomedImageDataProvider(ImageData imageData) {
diff --git a/tests/com.minres.scviewer.database.test/META-INF/MANIFEST.MF b/tests/com.minres.scviewer.database.test/META-INF/MANIFEST.MF
index 75886f0..011837d 100644
--- a/tests/com.minres.scviewer.database.test/META-INF/MANIFEST.MF
+++ b/tests/com.minres.scviewer.database.test/META-INF/MANIFEST.MF
@@ -5,11 +5,12 @@ Bundle-SymbolicName: com.minres.scviewer.database.test
Bundle-Version: 1.0.1.qualifier
Bundle-Vendor: MINRES Technologies GmbH
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Require-Bundle: org.junit,
- com.minres.scviewer.database,
+Require-Bundle: com.minres.scviewer.database,
com.minres.scviewer.database.sqlite;bundle-version="1.0.0",
com.minres.scviewer.database.text;bundle-version="1.0.0",
- com.minres.scviewer.database.vcd;bundle-version="1.0.0"
+ com.minres.scviewer.database.vcd;bundle-version="1.0.0",
+ org.junit,
+ org.junit.jupiter.api
Bundle-ActivationPolicy: lazy
Service-Component: OSGI-INF/component.xml
Automatic-Module-Name: com.minres.scviewer.database.test
diff --git a/tests/com.minres.scviewer.database.test/src/com/minres/scviewer/database/test/DatabaseServicesTest.java b/tests/com.minres.scviewer.database.test/src/com/minres/scviewer/database/test/DatabaseServicesTest.java
index b17f7c2..8d000f6 100644
--- a/tests/com.minres.scviewer.database.test/src/com/minres/scviewer/database/test/DatabaseServicesTest.java
+++ b/tests/com.minres.scviewer.database.test/src/com/minres/scviewer/database/test/DatabaseServicesTest.java
@@ -17,22 +17,15 @@ import static org.junit.Assert.assertTrue;
import java.io.File;
import java.util.List;
import java.util.Map.Entry;
-import java.util.NavigableMap;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import com.minres.scviewer.database.AssociationType;
-import com.minres.scviewer.database.DataType;
-import com.minres.scviewer.database.EventKind;
import com.minres.scviewer.database.IEvent;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.IWaveformDbFactory;
-import com.minres.scviewer.database.tx.ITx;
-import com.minres.scviewer.database.tx.ITxAttribute;
-import com.minres.scviewer.database.tx.ITxEvent;
public class DatabaseServicesTest {
@@ -127,37 +120,6 @@ public class DatabaseServicesTest {
assertEquals(1, waveformDb.getChildNodes().size());
}
- //@Test
- public void testTxLDb() throws Exception {
- File f = new File("inputs/my_ldb.txldb").getAbsoluteFile();
- assertTrue(f.exists());
- waveformDb.load(f);
- assertNotNull(waveformDb);
- assertEquals(1, waveformDb.getChildNodes().size());
- List waves = waveformDb.getAllWaves();
- assertEquals(3, waves.size());
- IWaveform stream = waves.get(0);
- NavigableMap eventsList = stream.getEvents();
- assertEquals(27, eventsList.size());
- Entry eventEntry = eventsList.firstEntry();
- assertEquals(100000000L, (long) eventEntry.getKey());
- IEvent[] events = eventEntry.getValue();
- assertEquals(1, events.length);
- IEvent event = events[0];
- assertEquals(EventKind.BEGIN, event.getKind());
- assertTrue(event instanceof ITxEvent);
- ITx tx = ((ITxEvent)event).getTransaction();
- assertEquals(3L, (long) tx.getId());
- List attrs = tx.getAttributes();
- assertEquals(1, attrs.size());
- ITxAttribute attr = attrs.get(0);
- assertEquals("data", attr.getName());
- assertEquals(DataType.UNSIGNED, attr.getDataType());
- assertEquals(AssociationType.END, attr.getType());
- assertTrue(attr.getValue() instanceof Integer);
- assertEquals(0, (int) attr.getValue());
- }
-
@Test
public void testHierarchicalVCD() throws Exception {
File f = new File("inputs/simple_system.vcd").getAbsoluteFile();