();
+ private Prefix prefix = null;
+ private Multiplicity defaultMultiplicity = null;
+ private String[] arguments = null;
+ private int defaultMinData = 0;
+ private int defaultMaxData = 0;
+ private StringBuffer checkErrors = null;
+
+/**
+ * Constructor
+ *
+ * @param args The command line arguments to check
+ * @param prefix The prefix to use for all command line options. It can only be set here for all options at
+ * the same time
+ * @param defaultMultiplicity The default multiplicity to use for all options (can be overridden when adding an option)
+ * @param defMinData The default minimum number of data items for all sets (can be overridden when adding a set)
+ * @param defMaxData The default maximum number of data items for all sets (can be overridden when adding a set)
+ *
+ * @throws IllegalArgumentException If either args
, prefix
, or defaultMultiplicity
+ * is null
- or if the data range values don't make sense
+ */
+
+ public Options(String args[], Prefix prefix, Multiplicity defaultMultiplicity, int defMinData, int defMaxData) {
+
+ if (args == null) throw new IllegalArgumentException(CLASS + ": args may not be null");
+ if (prefix == null) throw new IllegalArgumentException(CLASS + ": prefix may not be null");
+ if (defaultMultiplicity == null) throw new IllegalArgumentException(CLASS + ": defaultMultiplicity may not be null");
+
+ if (defMinData < 0) throw new IllegalArgumentException(CLASS + ": defMinData must be >= 0");
+ if (defMaxData < defMinData) throw new IllegalArgumentException(CLASS + ": defMaxData must be >= defMinData");
+
+ arguments = new String[args.length];
+ int i = 0;
+ for (String s : args)
+ arguments[i++] = s;
+
+ this.prefix = prefix;
+ this.defaultMultiplicity = defaultMultiplicity;
+ this.defaultMinData = defMinData;
+ this.defaultMaxData = defMaxData;
+
+ }
+
+/**
+ * Constructor
+ *
+ * @param args The command line arguments to check
+ * @param prefix The prefix to use for all command line options. It can only be set here for all options at
+ * the same time
+ * @param defaultMultiplicity The default multiplicity to use for all options (can be overridden when adding an option)
+ * @param data The default minimum and maximum number of data items for all sets (can be overridden when adding a set)
+ *
+ * @throws IllegalArgumentException If either args
, prefix
, or defaultMultiplicity
+ * is null
- or if the data range value doesn't make sense
+ */
+
+ public Options(String args[], Prefix prefix, Multiplicity defaultMultiplicity, int data) {
+ this(args, prefix, defaultMultiplicity, data, data);
+ }
+
+/**
+ * Constructor. The default number of data items is set to 0.
+ *
+ * @param args The command line arguments to check
+ * @param prefix The prefix to use for all command line options. It can only be set here for all options at
+ * the same time
+ * @param defaultMultiplicity The default multiplicity to use for all options (can be overridden when adding an option)
+ *
+ * @throws IllegalArgumentException If either args
, prefix
, or defaultMultiplicity
+ * is null
+ */
+
+ public Options(String args[], Prefix prefix, Multiplicity defaultMultiplicity) {
+ this(args, prefix, defaultMultiplicity, 0, 0);
+ }
+
+/**
+ * Constructor. The prefix is set to {@link Prefix#DASH}.
+ *
+ * @param args The command line arguments to check
+ * @param defaultMultiplicity The default multiplicity to use for all options (can be overridden when adding an option)
+ * @param defMinData The default minimum number of data items for all sets (can be overridden when adding a set)
+ * @param defMaxData The default maximum number of data items for all sets (can be overridden when adding a set)
+ *
+ * @throws IllegalArgumentException If either args
or defaultMultiplicity
+ * is null
- or if the data range values don't make sense
+ */
+
+ public Options(String args[], Multiplicity defaultMultiplicity, int defMinData, int defMaxData) {
+ this(args, Prefix.DASH, defaultMultiplicity, defMinData, defMaxData);
+ }
+
+/**
+ * Constructor. The prefix is set to {@link Prefix#DASH}.
+ *
+ * @param args The command line arguments to check
+ * @param defaultMultiplicity The default multiplicity to use for all options (can be overridden when adding an option)
+ * @param data The default minimum and maximum number of data items for all sets (can be overridden when adding a set)
+ *
+ * @throws IllegalArgumentException If either args
or defaultMultiplicity
+ * is null
- or if the data range value doesn't make sense
+ */
+
+ public Options(String args[], Multiplicity defaultMultiplicity, int data) {
+ this(args, Prefix.DASH, defaultMultiplicity, data, data);
+ }
+
+/**
+ * Constructor. The prefix is set to {@link Prefix#DASH}, and the default number of data items is set to 0.
+ *
+ * @param args The command line arguments to check
+ * @param defaultMultiplicity The default multiplicity to use for all options (can be overridden when adding an option)
+ *
+ * @throws IllegalArgumentException If either args
or defaultMultiplicity
+ * is null
+ */
+
+ public Options(String args[], Multiplicity defaultMultiplicity) {
+ this(args, Prefix.DASH, defaultMultiplicity, 0, 0);
+ }
+
+/**
+ * Constructor. The prefix is set to {@link Prefix#DASH}, the default number of data items is set to 0, and
+ * the multiplicity is set to {@link Multiplicity#ONCE}.
+ *
+ * @param args The command line arguments to check
+ *
+ * @throws IllegalArgumentException If args
is null
+ */
+
+ public Options(String args[]) {
+ this(args, Prefix.DASH, Multiplicity.ONCE);
+ }
+
+/**
+ * Constructor. The prefix is set to {@link Prefix#DASH}, and
+ * the multiplicity is set to {@link Multiplicity#ONCE}.
+ *
+ * @param args The command line arguments to check
+ * @param data The default minimum and maximum number of data items for all sets (can be overridden when adding a set)
+ *
+ * @throws IllegalArgumentException If args
is null
- or if the data range value doesn't make sense
+ */
+
+ public Options(String args[], int data) {
+ this(args, Prefix.DASH, Multiplicity.ONCE, data, data);
+ }
+
+/**
+ * Constructor. The prefix is set to {@link Prefix#DASH}, and
+ * the multiplicity is set to {@link Multiplicity#ONCE}.
+ *
+ * @param args The command line arguments to check
+ * @param defMinData The default minimum number of data items for all sets (can be overridden when adding a set)
+ * @param defMaxData The default maximum number of data items for all sets (can be overridden when adding a set)
+ *
+ * @throws IllegalArgumentException If args
is null
- or if the data range values don't make sense
+ */
+
+ public Options(String args[], int defMinData, int defMaxData) {
+ this(args, Prefix.DASH, Multiplicity.ONCE, defMinData, defMaxData);
+ }
+
+/**
+ * Constructor. The default number of data items is set to 0, and
+ * the multiplicity is set to {@link Multiplicity#ONCE}.
+ *
+ * @param args The command line arguments to check
+ * @param prefix The prefix to use for all command line options. It can only be set here for all options at
+ * the same time
+ *
+ * @throws IllegalArgumentException If either args
or prefix
is null
+ */
+
+ public Options(String args[], Prefix prefix) {
+ this(args, prefix, Multiplicity.ONCE, 0, 0);
+ }
+
+/**
+ * Constructor. The multiplicity is set to {@link Multiplicity#ONCE}.
+ *
+ * @param args The command line arguments to check
+ * @param prefix The prefix to use for all command line options. It can only be set here for all options at
+ * @param data The default minimum and maximum number of data items for all sets (can be overridden when adding a set)
+ *
+ * @throws IllegalArgumentException If either args
or prefix
is null
+ * - or if the data range value doesn't make sense
+ */
+
+ public Options(String args[], Prefix prefix, int data) {
+ this(args, prefix, Multiplicity.ONCE, data, data);
+ }
+
+/**
+ * Constructor. The multiplicity is set to {@link Multiplicity#ONCE}.
+ *
+ * @param args The command line arguments to check
+ * @param prefix The prefix to use for all command line options. It can only be set here for all options at
+ * the same time
+ * @param defMinData The default minimum number of data items for all sets (can be overridden when adding a set)
+ * @param defMaxData The default maximum number of data items for all sets (can be overridden when adding a set)
+ *
+ * @throws IllegalArgumentException If either args
or prefix
is null
+ * - or if the data range values don't make sense
+ */
+
+ public Options(String args[], Prefix prefix, int defMinData, int defMaxData) {
+ this(args, prefix, Multiplicity.ONCE, defMinData, defMaxData);
+ }
+
+/**
+ * Return the (first) matching set. This invocation does not ignore unmatched options and requires that
+ * data items are the last ones on the command line.
+ *
+ * @return The first set which matches (i. e. the check()
method returns true
) - or
+ * null
, if no set matches.
+ */
+
+ public OptionSet getMatchingSet() {
+ return getMatchingSet(false, true);
+ }
+
+/**
+ * Return the (first) matching set.
+ *
+ * @param ignoreUnmatched A boolean to select whether unmatched options can be ignored in the checks or not
+ * @param requireDataLast A boolean to indicate whether the data items have to be the last ones on the command line or not
+ *
+ * @return The first set which matches (i. e. the check()
method returns true
) - or
+ * null
, if no set matches.
+ */
+
+ public OptionSet getMatchingSet(boolean ignoreUnmatched, boolean requireDataLast) {
+ for (String setName : optionSets.keySet())
+ if (check(setName, ignoreUnmatched, requireDataLast))
+ return optionSets.get(setName);
+ return null;
+ }
+
+/**
+ * Add an option set.
+ *
+ * @param setName The name for the set. This must be a unique identifier
+ * @param minData The minimum number of data items for this set
+ * @param maxData The maximum number of data items for this set
+ *
+ * @return The new Optionset
instance created. This is useful to allow chaining of addOption()
+ * calls right after this method
+ */
+
+ public OptionSet addSet(String setName, int minData, int maxData) {
+ if (setName == null) throw new IllegalArgumentException(CLASS + ": setName may not be null");
+ if (optionSets.containsKey(setName)) throw new IllegalArgumentException(CLASS + ": a set with the name "
+ + setName + " has already been defined");
+ OptionSet os = new OptionSet(prefix, defaultMultiplicity, setName, minData, maxData);
+ optionSets.put(setName, os);
+ return os;
+ }
+
+/**
+ * Add an option set.
+ *
+ * @param setName The name for the set. This must be a unique identifier
+ * @param data The minimum and maximum number of data items for this set
+ *
+ * @return The new Optionset
instance created. This is useful to allow chaining of addOption()
+ * calls right after this method
+ */
+
+ public OptionSet addSet(String setName, int data) {
+ return addSet(setName, data, data);
+ }
+
+/**
+ * Add an option set. The defaults for the number of data items are used.
+ *
+ * @param setName The name for the set. This must be a unique identifier
+ *
+ * @return The new Optionset
instance created. This is useful to allow chaining of addOption()
+ * calls right after this method
+ */
+
+ public OptionSet addSet(String setName) {
+ return addSet(setName, defaultMinData, defaultMaxData);
+ }
+
+/**
+ * Return an option set - or null
, if no set with the given name exists
+ *
+ * @param setName The name for the set to retrieve
+ *
+ * @return The set to retrieve (or null
, if no set with the given name exists)
+ */
+
+ public OptionSet getSet(String setName) {
+ return optionSets.get(setName);
+ }
+
+/**
+ * This returns the (anonymous) default set
+ *
+ * @return The default set
+ */
+
+ public OptionSet getSet() {
+ if (getSet(DEFAULT_SET) == null)
+ addSet(DEFAULT_SET, defaultMinData, defaultMaxData);
+ return getSet(DEFAULT_SET);
+ }
+
+/**
+ * The error messages collected during the last option check (invocation of any of the check()
methods). This
+ * is useful to determine what was wrong with the command line arguments provided
+ *
+ * @return A string with all collected error messages
+ */
+
+ public String getCheckErrors() {
+ return checkErrors.toString();
+ }
+
+/**
+ * Run the checks for the default set. ignoreUnmatched
is set to false
, and
+ * requireDataLast
is set to true
.
+ *
+ * @return A boolean indicating whether all checks were successful or not
+ */
+
+ public boolean check() {
+ return check(DEFAULT_SET, false, true);
+ }
+
+/**
+ * Run the checks for the default set.
+ *
+ * @param ignoreUnmatched A boolean to select whether unmatched options can be ignored in the checks or not
+ * @param requireDataLast A boolean to indicate whether the data items have to be the last ones on the command line or not
+ *
+ * @return A boolean indicating whether all checks were successful or not
+ */
+
+ public boolean check(boolean ignoreUnmatched, boolean requireDataLast) {
+ return check(DEFAULT_SET, ignoreUnmatched, requireDataLast);
+ }
+
+/**
+ * Run the checks for the given set. ignoreUnmatched
is set to false
, and
+ * requireDataLast
is set to true
.
+ *
+ * @param setName The name for the set to check
+ *
+ * @return A boolean indicating whether all checks were successful or not
+ *
+ * @throws IllegalArgumentException If either setName
is null
, or the set is unknown.
+ */
+
+ public boolean check(String setName) {
+ return check(setName, false, true);
+ }
+
+/**
+ * Run the checks for the given set.
+ *
+ * @param setName The name for the set to check
+ * @param ignoreUnmatched A boolean to select whether unmatched options can be ignored in the checks or not
+ * @param requireDataLast A boolean to indicate whether the data items have to be the last ones on the command line or not
+ *
+ * @return A boolean indicating whether all checks were successful or not
+ *
+ * @throws IllegalArgumentException If either setName
is null
, or the set is unknown.
+ */
+
+ public boolean check(String setName, boolean ignoreUnmatched, boolean requireDataLast) {
+
+ if (setName == null) throw new IllegalArgumentException(CLASS + ": setName may not be null");
+ if (optionSets.get(setName) == null) throw new IllegalArgumentException(CLASS + ": Unknown OptionSet: " + setName);
+
+ checkErrors = new StringBuffer();
+ checkErrors.append("Checking set ");
+ checkErrors.append(setName);
+ checkErrors.append('\n');
+
+//.... Access the data for the set to use
+
+ OptionSet set = optionSets.get(setName);
+ java.util.ArrayList options = set.getOptionData();
+ java.util.ArrayList data = set.getData();
+ java.util.ArrayList unmatched = set.getUnmatched();
+
+//.... Catch some trivial cases
+
+ if (options.size() == 0) { // No options have been defined at all
+ if (arguments.length == 0) { // No arguments have been given: in this case, this is a success
+ return true;
+ } else {
+ checkErrors.append("No options have been defined, nothing to check\n");
+ return false;
+ }
+ } else if (arguments.length == 0) { // Options have been defined, but no arguments given
+ checkErrors.append("Options have been defined, but no arguments have been given; nothing to check\n");
+ return false;
+ }
+
+//.... Parse all the arguments given
+
+ int ipos = 0;
+ int offset = 0;
+ java.util.regex.Matcher m = null;
+ String value = null;
+ String detail = null;
+ String next = null;
+ String key = null;
+ String pre = Character.toString(prefix.getName());
+ boolean add = true;
+ boolean[] matched = new boolean[arguments.length];
+
+ for (int i = 0; i < matched.length; i++) // Initially, we assume there was no match at all
+ matched[i] = false;
+
+ while (true) {
+
+ value = null;
+ detail = null;
+ offset = 0;
+ add = true;
+ key = arguments[ipos];
+
+ for (OptionData optionData : options) { // For each argument, we may need to check all defined options
+ m = optionData.getPattern().matcher(key);
+ if (m.lookingAt()) {
+ if (optionData.useValue()) { // The code section for value options
+ if (optionData.useDetail()) {
+ detail = m.group(1);
+ offset = 2; // required for correct Matcher.group access below
+ }
+ if (optionData.getSeparator() == Separator.BLANK) { // In this case, the next argument must be the value
+ if (ipos + 1 == arguments.length) { // The last argument, thus no value follows it: Error
+ checkErrors.append("At end of arguments - no value found following argument ");
+ checkErrors.append(key);
+ checkErrors.append('\n');
+ add = false;
+ } else {
+ next = arguments[ipos + 1];
+ if (next.startsWith(pre)) { // The next one is an argument, not a value: Error
+ checkErrors.append("No value found following argument ");
+ checkErrors.append(key);
+ checkErrors.append('\n');
+ add = false;
+ } else {
+ value = next;
+ matched[ipos++] = true; // Mark the key and the value
+ matched[ipos] = true;
+ }
+ }
+ } else { // The value follows the separator in this case
+ value = m.group(1 + offset);
+ matched[ipos] = true;
+ }
+ } else { // Simple, non-value options
+ matched[ipos] = true;
+ }
+
+ if (add) optionData.addResult(value, detail); // Store the result
+ break; // No need to check more options, we have a match
+ }
+ }
+
+ ipos++; // Advance to the next argument to check
+ if (ipos >= arguments.length) break; // Terminating condition for the check loop
+
+ }
+
+//.... Identify unmatched arguments and actual (non-option) data
+
+ int first = -1; // Required later for requireDataLast
+ for (int i = 0; i < matched.length; i++) { // Assemble the list of unmatched options
+ if (!matched[i]) {
+ if (arguments[i].startsWith(pre)) { // This is an unmatched option
+ unmatched.add(arguments[i]);
+ checkErrors.append("No matching option found for argument ");
+ checkErrors.append(arguments[i]);
+ checkErrors.append('\n');
+ } else { // This is actual data
+ if (first < 0) first = i;
+ data.add(arguments[i]);
+ }
+ }
+ }
+
+//.... Checks to determine overall success; start with multiplicity of options
+
+ boolean err = true;
+
+ for (OptionData optionData : options) {
+
+ key = optionData.getKey();
+ err = false; // Local check result for one option
+
+ switch (optionData.getMultiplicity()) {
+ case ONCE: if (optionData.getResultCount() != 1) err = true; break;
+ case ONCE_OR_MORE: if (optionData.getResultCount() == 0) err = true; break;
+ case ZERO_OR_ONE: if (optionData.getResultCount() > 1) err = true; break;
+ case ZERO_OR_MORE: break;
+ }
+
+ if (err) {
+ checkErrors.append("Wrong number of occurences found for argument ");
+ checkErrors.append(prefix.getName());
+ checkErrors.append(key);
+ checkErrors.append('\n');
+ return false;
+ }
+
+ }
+
+//.... Check range for data
+
+ if (data.size() < set.getMinData() || data.size() > set.getMaxData()) {
+ checkErrors.append("Invalid number of data arguments: ");
+ checkErrors.append(data.size());
+ checkErrors.append(" (allowed range: ");
+ checkErrors.append(set.getMinData());
+ checkErrors.append(" ... ");
+ checkErrors.append(set.getMaxData());
+ checkErrors.append(")\n");
+ return false;
+ }
+
+//.... Check for location of the data in the list of command line arguments
+
+ if (requireDataLast) {
+ if (first + data.size() != arguments.length) {
+ checkErrors.append("Invalid data specification: data arguments are not the last ones on the command line\n");
+ return false;
+ }
+ }
+
+//.... Check for unmatched arguments
+
+ if (!ignoreUnmatched && unmatched.size() > 0) return false; // Don't accept unmatched arguments
+
+//.... If we made it to here, all checks were successful
+
+ return true;
+
+ }
+
+/**
+ * Add the given non-value option to all known sets.
+ * See {@link OptionSet#addOption(String)} for details.
+ */
+
+ public void addOptionAllSets(String key) {
+ for (String setName : optionSets.keySet())
+ optionSets.get(setName).addOption(key, defaultMultiplicity);
+ }
+
+/**
+ * Add the given non-value option to all known sets.
+ * See {@link OptionSet#addOption(String, Options.Multiplicity)} for details.
+ */
+
+ public void addOptionAllSets(String key, Multiplicity multiplicity) {
+ for (String setName : optionSets.keySet())
+ optionSets.get(setName).addOption(key, false, Separator.NONE, false, multiplicity);
+ }
+
+/**
+ * Add the given value option to all known sets.
+ * See {@link OptionSet#addOption(String, Options.Separator)} for details.
+ */
+
+ public void addOptionAllSets(String key, Separator separator) {
+ for (String setName : optionSets.keySet())
+ optionSets.get(setName).addOption(key, false, separator, true, defaultMultiplicity);
+ }
+
+/**
+ * Add the given value option to all known sets.
+ * See {@link OptionSet#addOption(String, Options.Separator, Options.Multiplicity)} for details.
+ */
+
+ public void addOptionAllSets(String key, Separator separator, Multiplicity multiplicity) {
+ for (String setName : optionSets.keySet())
+ optionSets.get(setName).addOption(key, false, separator, true, multiplicity);
+ }
+
+/**
+ * Add the given value option to all known sets.
+ * See {@link OptionSet#addOption(String, boolean, Options.Separator)} for details.
+ */
+
+ public void addOptionAllSets(String key, boolean details, Separator separator) {
+ for (String setName : optionSets.keySet())
+ optionSets.get(setName).addOption(key, details, separator, true, defaultMultiplicity);
+ }
+
+/**
+ * Add the given value option to all known sets.
+ * See {@link OptionSet#addOption(String, boolean, Options.Separator, Options.Multiplicity)} for details.
+ */
+
+ public void addOptionAllSets(String key, boolean details, Separator separator, Multiplicity multiplicity) {
+ for (String setName : optionSets.keySet())
+ optionSets.get(setName).addOption(key, details, separator, true, multiplicity);
+ }
+
+/**
+ * This is the overloaded {@link Object#toString()} method, and it is provided mainly for debugging
+ * purposes.
+ *
+ * @return A string representing the instance
+ */
+
+ public String toString() {
+
+ StringBuffer sb = new StringBuffer();
+
+ for (OptionSet set : optionSets.values()) {
+ sb.append("Set: ");
+ sb.append(set.getSetName());
+ sb.append('\n');
+ for (OptionData data : set.getOptionData()) {
+ sb.append(data.toString());
+ sb.append('\n');
+ }
+ }
+
+ return sb.toString();
+
+ }
+
+}
+
+
diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/AboutDialog.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/AboutDialog.java
index e33b483..8b0745c 100644
--- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/AboutDialog.java
+++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/AboutDialog.java
@@ -133,7 +133,7 @@ public class AboutDialog extends Dialog {
// links are activated on mouse down when the control key is held down
// if ((event.stateMask & SWT.MOD1) != 0) {
try {
- int offset = ((StyledText)event.widget).getOffsetAtLocation(new Point (event.x, event.y));
+ int offset = ((StyledText)event.widget).getOffsetAtPoint(new Point (event.x, event.y));
StyleRange style = ((StyledText)event.widget).getStyleRangeAtOffset(offset);
if (style != null && style.underline && style.underlineStyle == SWT.UNDERLINE_LINK) {
Desktop.getDesktop().browse(new java.net.URI(style.data.toString()));
diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java
index b46b2c9..36061ab 100644
--- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java
+++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java
@@ -14,6 +14,7 @@ import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
@@ -31,6 +32,7 @@ import javax.inject.Named;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
@@ -55,9 +57,16 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseTrackListener;
+import org.eclipse.swt.events.MouseWheelListener;
import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.ITxRelation;
@@ -71,6 +80,8 @@ import com.minres.scviewer.database.ui.GotoDirection;
import com.minres.scviewer.database.ui.ICursor;
import com.minres.scviewer.database.ui.IWaveformViewer;
import com.minres.scviewer.database.ui.TrackEntry;
+import com.minres.scviewer.database.ui.TrackEntry.ValueDisplay;
+import com.minres.scviewer.database.ui.TrackEntry.WaveDisplay;
import com.minres.scviewer.database.ui.WaveformColors;
import com.minres.scviewer.e4.application.Messages;
import com.minres.scviewer.e4.application.internal.status.WaveStatusBarControl;
@@ -98,6 +109,10 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
/** The Constant SHOWN_WAVEFORM. */
protected static final String SHOWN_WAVEFORM = "SHOWN_WAVEFORM"; //$NON-NLS-1$
+ protected static final String VALUE_DISPLAY = ".VALUE_DISPLAY"; //$NON-NLS-1$
+
+ protected static final String WAVE_DISPLAY = ".WAVE_DISPLAY"; //$NON-NLS-1$
+
/** The Constant SHOWN_CURSOR. */
protected static final String SHOWN_CURSOR = "SHOWN_CURSOR"; //$NON-NLS-1$
@@ -137,7 +152,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
@Inject
ESelectionService selectionService;
- /** The e part service. */
+ /** The part service. */
@Inject
EPartService ePartService;
@@ -232,6 +247,106 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
selectionService.setSelection(event.getSelection());
}
});
+ waveformPane.getWaveformControl().addMouseTrackListener(new MouseTrackListener() {
+
+ @Override
+ public void mouseHover(MouseEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void mouseExit(MouseEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void mouseEnter(MouseEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+ });
+
+ waveformPane.getWaveformControl().addMouseWheelListener(new MouseWheelListener() {
+
+ @Override
+ public void mouseScrolled(MouseEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+ });
+
+ waveformPane.getWaveformControl().addListener(SWT.KeyDown, new Listener() {
+
+ @Override
+ public void handleEvent(Event e) {
+ int state = e.stateMask & SWT.MODIFIER_MASK;
+ if(Platform.OS_MACOSX.equals(Platform.getOS())) { //swap cammnd and control for MacOSX
+ if((state&SWT.COMMAND)!=0) {
+ state&=~SWT.COMMAND;
+ state|=SWT.CONTROL;
+ } else if((state&SWT.CONTROL)!=0) {
+ state&=~SWT.CONTROL;
+ state|=SWT.COMMAND;
+ }
+ }
+ if(state==SWT.ALT) {
+ switch(e.keyCode) {
+ case SWT.ARROW_LEFT:
+ waveformPane.scrollHorizontal(-100);
+ return;
+ case SWT.ARROW_RIGHT:
+ waveformPane.scrollHorizontal(100);
+ return;
+ case SWT.KEYPAD_ADD:
+ return;
+ case SWT.KEYPAD_SUBTRACT:
+ return;
+ }
+ } else if(state==SWT.CTRL) {
+ int zoomlevel = waveformPane.getZoomLevel();
+ switch(e.keyCode) {
+ case '+':
+ case SWT.KEYPAD_ADD:
+ if(zoomlevel>0)
+ waveformPane.setZoomLevel(zoomlevel-1);
+ return;
+ case '-':
+ case SWT.KEYPAD_SUBTRACT:
+ if(zoomlevel 0)
loadDatabase(persistedState);
eventBroker.post(WaveStatusBarControl.ZOOM_LEVEL, zoomLevel[waveformPane.getZoomLevel()]);
+// menuService.registerContextMenu(waveformPane.getNameControl(),
+// "com.minres.scviewer.e4.application.popupmenu.namecontext"); //$NON-NLS-1$
menuService.registerContextMenu(waveformPane.getNameControl(),
- "com.minres.scviewer.e4.application.popupmenu.namecontext"); //$NON-NLS-1$
+ "com.minres.scviewer.e4.application.popupmenu.wavecontext"); //$NON-NLS-1$
menuService.registerContextMenu(waveformPane.getValueControl(),
- "com.minres.scviewer.e4.application.popupmenu.namecontext"); //$NON-NLS-1$
+ "com.minres.scviewer.e4.application.popupmenu.wavecontext"); //$NON-NLS-1$
menuService.registerContextMenu(waveformPane.getWaveformControl(),
"com.minres.scviewer.e4.application.popupmenu.wavecontext"); //$NON-NLS-1$
ePartService.addPartListener(new PartListener() {
@@ -380,7 +497,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
*/
@Inject
@Optional
- public void setPartInput(@Named("input") Object partInput) {
+ public void setPartInput(@Named("input") Object partInput, @Named("config") Object partConfig) {
if (partInput instanceof File) {
filesToLoad = new ArrayList();
File file = (File) partInput;
@@ -404,6 +521,9 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
}
if (filesToLoad.size() > 0)
loadDatabase(persistedState);
+ if(partConfig instanceof String) {
+ loadState((String) partConfig);
+ }
}
}
@@ -412,7 +532,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
*/
@Focus
public void setFocus() {
- myParent.setFocus();
+ waveformPane.getWaveformControl().setFocus();
}
/**
@@ -459,12 +579,13 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
FileInputStream in = new FileInputStream(fileName);
props.load(in);
in.close();
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ HashMap propMap = new HashMap((Map) props);
+ restoreWaveformViewerState(propMap);
+ } catch(FileNotFoundException e) {
} catch (IOException e) {
e.printStackTrace();
}
- @SuppressWarnings({ "unchecked", "rawtypes" })
- HashMap propMap = new HashMap((Map) props);
- restoreWaveformViewerState(propMap);
}
/**
@@ -478,6 +599,8 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
index = 0;
for (TrackEntry trackEntry : waveformPane.getStreamList()) {
persistedState.put(SHOWN_WAVEFORM + index, trackEntry.waveform.getFullName());
+ persistedState.put(SHOWN_WAVEFORM + index + VALUE_DISPLAY, trackEntry.valueDisplay.toString());
+ persistedState.put(SHOWN_WAVEFORM + index + WAVE_DISPLAY, trackEntry.waveDisplay.toString());
index++;
}
List cursors = waveformPane.getCursorList();
@@ -501,8 +624,16 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
List res = new LinkedList<>();
for (int i = 0; i < waves; i++) {
IWaveform extends IWaveformEvent> waveform = database.getStreamByName(state.get(SHOWN_WAVEFORM + i));
- if (waveform != null)
- res.add(new TrackEntry(waveform));
+ if (waveform != null) {
+ TrackEntry t = new TrackEntry(waveform);
+ res.add(t);
+ String v = state.get(SHOWN_WAVEFORM + i + VALUE_DISPLAY);
+ if(v!=null)
+ t.valueDisplay=ValueDisplay.valueOf(v);
+ String s = state.get(SHOWN_WAVEFORM + i + WAVE_DISPLAY);
+ if(s!=null)
+ t.waveDisplay=WaveDisplay.valueOf(s);
+ }
}
if (res.size() > 0)
waveformPane.getStreamList().addAll(res);
@@ -658,6 +789,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
index++;
waveformPane.getStreamList().addAll(index, streams);
}
+ setFocus();
}
/**
@@ -724,6 +856,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
* @param level the new zoom level
*/
public void setZoomLevel(Integer level) {
+ //System.out.println("setZoomLevel() - ZoomLevel: " + level);
if (level < 0)
level = 0;
if (level > zoomLevel.length - 1)
@@ -732,11 +865,43 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
updateAll();
}
+ //FIXME: need to use unitString and unitMultiplier from class WaveformCanvas which is located in >com.minres.scviewer.database.swt.internal.
+ //Trying to import com.minres.scviewer.database.swt.internal.WaveformCanvas results in the error:
+ //'Access restriction: The type 'WaveformCanvas' is not API (restriction on required project 'com.minres.scviewer.database.ui.swt')'.
+ public final static String[] unitString={"fs", "ps", "ns", "�s", "ms"};//, "s"};
+ public final static int[] unitMultiplier={1, 3, 10, 30, 100, 300};
+
/**
* Sets the zoom fit.
*/
public void setZoomFit() {
- waveformPane.setZoomLevel(6);
+
+ //actual max time of signal
+ long maxTime = waveformPane.getMaxTime();
+
+ //get area actually capable of displaying data, i.e. area of the receiver which is capable of displaying data
+ Rectangle clientArea = myParent.getClientArea();
+ long clientAreaWidth = clientArea.width;
+
+ //System.out.println("ZoomLevel[] Array (Length " + zoomLevel.length + "): " + Arrays.toString(zoomLevel));
+ //System.out.println("ClientArea myParent: " + myParent.getClientArea());
+ //System.out.println("MaxTime: " + maxTime);
+ //System.out.println("clientAreaWidth: " + clientAreaWidth);
+
+ boolean foundZoom=false;
+ //try to find existing zoomlevel where scaleFactor*clientAreaWidth >= maxTime, if one is found set it as new zoomlevel
+ for (int level=0; level= maxTime) {
+ setZoomLevel(level);
+ foundZoom=true;
+ break;
+ }
+ }
+ //if no zoom level is found, set biggest one available
+ if(!foundZoom) setZoomLevel(unitMultiplier.length*unitString.length-1);
+
updateAll();
}
@@ -878,5 +1043,9 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
if(navigationRelationType!=relationType) waveformPane.setHighliteRelation(relationType);
navigationRelationType=relationType;
}
+
+ public void update() {
+ waveformPane.update();
+ }
}
\ No newline at end of file
diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/DefaultValuesInitializer.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/DefaultValuesInitializer.java
index 4cdcf2b..17afd9b 100644
--- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/DefaultValuesInitializer.java
+++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/DefaultValuesInitializer.java
@@ -41,12 +41,15 @@ public class DefaultValuesInitializer extends AbstractPreferenceInitializer {
colors[WaveformColors.TX_BG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
colors[WaveformColors.TX_BG_HIGHLITE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN);
colors[WaveformColors.TX_BORDER.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
- colors[WaveformColors.SIGNAL0.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN);
- colors[WaveformColors.SIGNAL1.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN);
+ colors[WaveformColors.SIGNAL0.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
+ colors[WaveformColors.SIGNAL1.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
colors[WaveformColors.SIGNALZ.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW);
colors[WaveformColors.SIGNALX.ordinal()] = SWTResourceManager.getColor(255, 51, 51);
colors[WaveformColors.SIGNALU.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_YELLOW);
+ colors[WaveformColors.SIGNAL_REAL.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW);
+ colors[WaveformColors.SIGNAL_NAN.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
colors[WaveformColors.SIGNAL_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
+ colors[WaveformColors.SIGNAL_REAL.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW);
colors[WaveformColors.CURSOR.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
colors[WaveformColors.CURSOR_DRAG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GRAY);
colors[WaveformColors.CURSOR_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/provider/TxDbLabelProvider.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/provider/TxDbLabelProvider.java
index eab365c..ab0bd3b 100644
--- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/provider/TxDbLabelProvider.java
+++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/provider/TxDbLabelProvider.java
@@ -20,7 +20,7 @@ import org.eclipse.wb.swt.ResourceManager;
import com.minres.scviewer.database.IHierNode;
import com.minres.scviewer.database.ISignal;
-import com.minres.scviewer.database.ISignalChangeMulti;
+import com.minres.scviewer.database.ISignalChangeBitVector;
import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.e4.application.parts.LoadingWaveformDb;
@@ -101,7 +101,7 @@ public class TxDbLabelProvider implements ILabelProvider {
return stream;
}else if(element instanceof ISignal>){
Object o = ((ISignal>)element).getEvents().firstEntry().getValue();
- if(o instanceof ISignalChangeMulti)
+ if(o instanceof ISignalChangeBitVector)
return wave;
else
return signal;
diff --git a/com.minres.scviewer.e4.application/src/org/eclipse/wb/swt/ResourceManager.java b/com.minres.scviewer.e4.application/src/org/eclipse/wb/swt/ResourceManager.java
index ddf492f..98642cf 100644
--- a/com.minres.scviewer.e4.application/src/org/eclipse/wb/swt/ResourceManager.java
+++ b/com.minres.scviewer.e4.application/src/org/eclipse/wb/swt/ResourceManager.java
@@ -147,15 +147,15 @@ public class ResourceManager extends SWTResourceManager {
CompositeImageDescriptor compositImageDesc = new CompositeImageDescriptor() {
@Override
protected void drawCompositeImage(int width, int height) {
- drawImage(baseImage.getImageData(), 0, 0);
+ drawImage(createCachedImageDataProvider(baseImage), 0, 0);
if (corner == TOP_LEFT) {
- drawImage(decorator.getImageData(), 0, 0);
+ drawImage(createCachedImageDataProvider(decorator), 0, 0);
} else if (corner == TOP_RIGHT) {
- drawImage(decorator.getImageData(), bib.width - dib.width, 0);
+ drawImage(createCachedImageDataProvider(decorator), bib.width - dib.width, 0);
} else if (corner == BOTTOM_LEFT) {
- drawImage(decorator.getImageData(), 0, bib.height - dib.height);
+ drawImage(createCachedImageDataProvider(decorator), 0, bib.height - dib.height);
} else if (corner == BOTTOM_RIGHT) {
- drawImage(decorator.getImageData(), bib.width - dib.width, bib.height - dib.height);
+ drawImage(createCachedImageDataProvider(decorator), bib.width - dib.width, bib.height - dib.height);
}
}
@Override
diff --git a/com.minres.scviewer.e4.product/pom.xml b/com.minres.scviewer.e4.product/pom.xml
index 92a039e..ff56ab9 100644
--- a/com.minres.scviewer.e4.product/pom.xml
+++ b/com.minres.scviewer.e4.product/pom.xml
@@ -6,11 +6,10 @@
com.minres.scviewer
com.minres.scviewer.parent
- 1.0.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
../com.minres.scviewer.parent
com.minres.scviewer.e4.product
- 1.3.0-SNAPSHOT
eclipse-repository
com.minres.scviewer
diff --git a/com.minres.scviewer.e4.product/scviewer.product b/com.minres.scviewer.e4.product/scviewer.product
index c5b250e..615d49f 100644
--- a/com.minres.scviewer.e4.product/scviewer.product
+++ b/com.minres.scviewer.e4.product/scviewer.product
@@ -1,7 +1,7 @@
-
+
@@ -72,8 +72,10 @@
+
+
@@ -118,6 +120,7 @@
+
diff --git a/com.minres.scviewer.parent/pom.xml b/com.minres.scviewer.parent/pom.xml
index e69be6d..736e844 100644
--- a/com.minres.scviewer.parent/pom.xml
+++ b/com.minres.scviewer.parent/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.minres.scviewer
com.minres.scviewer.parent
- 1.0.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
pom
../com.minres.scviewer.target
diff --git a/com.minres.scviewer.target/neon.target b/com.minres.scviewer.target/neon.target
new file mode 100644
index 0000000..d84fbf9
--- /dev/null
+++ b/com.minres.scviewer.target/neon.target
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+x86_64
+de_DE
+
+
+-Dosgi.requiredJavaVersion=1.7 -XX:MaxPermSize=256 -Xms40m -Xmx2G
+
+
\ No newline at end of file
diff --git a/com.minres.scviewer.target/photon.target b/com.minres.scviewer.target/photon.target
index 91b11cc..5d6c71b 100644
--- a/com.minres.scviewer.target/photon.target
+++ b/com.minres.scviewer.target/photon.target
@@ -6,6 +6,8 @@
+
+
diff --git a/com.minres.scviewer.ui/.settings/org.eclipse.jdt.groovy.core.prefs b/com.minres.scviewer.ui/.settings/org.eclipse.jdt.groovy.core.prefs
index 021403d..bde59a0 100644
--- a/com.minres.scviewer.ui/.settings/org.eclipse.jdt.groovy.core.prefs
+++ b/com.minres.scviewer.ui/.settings/org.eclipse.jdt.groovy.core.prefs
@@ -1,2 +1,3 @@
eclipse.preferences.version=1
groovy.compiler.level=26
+groovy.script.filters=**/*.dsld,y,**/*.gradle,n
diff --git a/com.minres.scviewer.ui/META-INF/MANIFEST.MF b/com.minres.scviewer.ui/META-INF/MANIFEST.MF
index fc9a3e3..60150bc 100644
--- a/com.minres.scviewer.ui/META-INF/MANIFEST.MF
+++ b/com.minres.scviewer.ui/META-INF/MANIFEST.MF
@@ -23,3 +23,4 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Import-Package: com.google.common.collect
Service-Component: OSGI-INF/component.xml
+Automatic-Module-Name: com.minres.scviewer.ui
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 3663aab..66402d9 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
@@ -347,12 +347,18 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
addStreamToList(stream);
}
- public void removeStreamFromList(IWaveform extends IWaveformEvent> obj){
- if(getEditorInput() instanceof TxEditorInput && ((TxEditorInput) getEditorInput()).getStreamNames().contains(obj.getFullName())){
- ((TxEditorInput) getEditorInput()).getStreamNames().remove(obj.getFullName());
- txDisplay.getStreamList().remove(obj);
- } else
- txDisplay.getStreamList().remove(obj);
+ public void removeStreamFromList(IWaveform extends IWaveformEvent> waveform){
+ if(getEditorInput() instanceof TxEditorInput && ((TxEditorInput) getEditorInput()).getStreamNames().contains(waveform.getFullName())){
+ ((TxEditorInput) getEditorInput()).getStreamNames().remove(waveform.getFullName());
+ }
+ TrackEntry entry=null;
+ for(TrackEntry e:txDisplay.getStreamList()) {
+ if(e.waveform==waveform) {
+ entry=e;
+ break;
+ }
+ }
+ txDisplay.getStreamList().remove(entry);
}
public void removeStreamsFromList(IWaveform extends IWaveformEvent>[] iWaveforms){
diff --git a/com.opcoach.e4.preferences/META-INF/MANIFEST.MF b/com.opcoach.e4.preferences/META-INF/MANIFEST.MF
index f49535b..5ec77eb 100644
--- a/com.opcoach.e4.preferences/META-INF/MANIFEST.MF
+++ b/com.opcoach.e4.preferences/META-INF/MANIFEST.MF
@@ -16,3 +16,4 @@ Require-Bundle: javax.inject,
Export-Package: com.opcoach.e4.preferences,
com.opcoach.e4.preferences.handlers
Bundle-ActivationPolicy: lazy
+Automatic-Module-Name: com.opcoach.e4.preferences