Compare commits
1 Commits
feature/cu
...
feature/he
Author | SHA1 | Date | |
---|---|---|---|
ccc8d80ac2 |
@ -12,8 +12,7 @@
|
|||||||
<booleanAttribute key="M2_UPDATE_SNAPSHOTS" value="false"/>
|
<booleanAttribute key="M2_UPDATE_SNAPSHOTS" value="false"/>
|
||||||
<stringAttribute key="M2_USER_SETTINGS" value=""/>
|
<stringAttribute key="M2_USER_SETTINGS" value=""/>
|
||||||
<booleanAttribute key="M2_WORKSPACE_RESOLUTION" value="true"/>
|
<booleanAttribute key="M2_WORKSPACE_RESOLUTION" value="true"/>
|
||||||
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_ATTR_USE_ARGFILE" value="false"/>
|
|
||||||
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_CLASSPATH_ONLY_JAR" value="false"/>
|
|
||||||
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
|
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
|
||||||
|
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/AdoptOpenJDK 8 [1.8.0_232]"/>
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${project_loc:com.minres.scviewer.parent}"/>
|
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${project_loc:com.minres.scviewer.parent}"/>
|
||||||
</launchConfiguration>
|
</launchConfiguration>
|
||||||
|
17
.project
@ -1,17 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<projectDescription>
|
|
||||||
<name>com.minres.scviewer.parent</name>
|
|
||||||
<comment></comment>
|
|
||||||
<projects>
|
|
||||||
</projects>
|
|
||||||
<buildSpec>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
</buildSpec>
|
|
||||||
<natures>
|
|
||||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
|
||||||
</natures>
|
|
||||||
</projectDescription>
|
|
28
README.md
@ -31,15 +31,14 @@ Legend:
|
|||||||
* Context any means Name List, Value List or Waveform
|
* Context any means Name List, Value List or Waveform
|
||||||
|
|
||||||
| Input | Modifier | Context | Action |
|
| Input | Modifier | Context | Action |
|
||||||
|------------|----------|----------|-----------------------------------|
|
|-----------|----------|----------|-----------------------------------|
|
||||||
| LMB click | | any | select |
|
| LMB klick | | any | select |
|
||||||
| LMB click | Shift | Waveform | move selected marker to position |
|
| LMB klick | Shift | Waveform | move selected marker to position |
|
||||||
| LMB click | Control | Waveform | move cursor to position |
|
| LMB klick | Control | Waveform | move cursor to position |
|
||||||
| LMB drag | | Waveform | zoom to range |
|
| LMB drag | | Waveform | zoom to range |
|
||||||
| MMB click | | Waveform | move selected marker to position |
|
| MMB klick | | Waveform | move selected marker to position |
|
||||||
| MScrl | | any | scroll window up/down |
|
| MScrl | | any | scroll window up/down |
|
||||||
| MScrl | Shift | any | scroll window left/right |
|
| MScrl | Shift | any | scroll window left/right |
|
||||||
| MScrl | Control | Waveform | zoom in/out |
|
|
||||||
| Key left | | Waveform | scroll window to the left (slow) |
|
| Key left | | Waveform | scroll window to the left (slow) |
|
||||||
| Key right | | Waveform | scroll window to the right (slow) |
|
| Key right | | Waveform | scroll window to the right (slow) |
|
||||||
| Key left | Shift | Waveform | scroll window to the left (fast) |
|
| Key left | Shift | Waveform | scroll window to the left (fast) |
|
||||||
@ -53,20 +52,3 @@ Legend:
|
|||||||
| Key Pos1 | | Waveform | jump to selected marker |
|
| Key Pos1 | | Waveform | jump to selected marker |
|
||||||
| Key End | | Waveform | jump to cursor |
|
| Key End | | Waveform | jump to cursor |
|
||||||
| Key Del | | any | delete selected entries |
|
| Key Del | | any | delete selected entries |
|
||||||
| LMB click | | ZoomBar | increment/decrement 1 page |
|
|
||||||
| LMB drag | | ZoomBar | drag both markers (pan) |
|
|
||||||
| LMB drag | Control | ZoomBar | drag one marker (zoom) |
|
|
||||||
| MMB drag | | ZoomBar | drag one marker (zoom) |
|
|
||||||
| xMB dclick | | ZoomBar | pan to position |
|
|
||||||
| MScrl | | ZoomBar | scroll window left/right |
|
|
||||||
| MScrl | Shift | ZoomBar | scroll window left/right double speed |
|
|
||||||
| MScrl | Control | ZoomBar | zoom in/out |
|
|
||||||
| Key left | | ZoomBar | scroll window to the left (slow) |
|
|
||||||
| Key right | | ZoomBar | scroll window to the right (slow) |
|
|
||||||
| Key up | | ZoomBar | scroll window to the left (slow) |
|
|
||||||
| Key down | | ZoomBar | scroll window to the right (slow) |
|
|
||||||
| Key PgUp | | ZoomBar | scroll window to the left (fast) |
|
|
||||||
| Key PgDown | | ZoomBar | scroll window to the right (fast) |
|
|
||||||
| Key Pos1 | | ZoomBar | scroll to begin |
|
|
||||||
| Key End | | ZoomBar | scroll to end |
|
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.minres.scviewer</groupId>
|
<groupId>com.minres.scviewer</groupId>
|
||||||
<artifactId>com.minres.scviewer.parent</artifactId>
|
<artifactId>com.minres.scviewer.parent</artifactId>
|
||||||
<version>2.15.1</version>
|
<version>2.14.1</version>
|
||||||
<relativePath>../..</relativePath>
|
<relativePath>../../..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<version>3.0.0-SNAPSHOT</version>
|
<version>3.0.0-SNAPSHOT</version>
|
||||||
</project>
|
</project>
|
||||||
|
@ -64,4 +64,11 @@
|
|||||||
version="0.0.0"
|
version="0.0.0"
|
||||||
unpack="false"/>
|
unpack="false"/>
|
||||||
|
|
||||||
|
<plugin
|
||||||
|
id="com.minres.scviewer.help"
|
||||||
|
download-size="0"
|
||||||
|
install-size="0"
|
||||||
|
version="0.0.0"
|
||||||
|
unpack="false"/>
|
||||||
|
|
||||||
</feature>
|
</feature>
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.minres.scviewer</groupId>
|
<groupId>com.minres.scviewer</groupId>
|
||||||
<artifactId>com.minres.scviewer.parent</artifactId>
|
<artifactId>com.minres.scviewer.parent</artifactId>
|
||||||
<version>2.15.1</version>
|
<version>2.14.1</version>
|
||||||
<relativePath>../..</relativePath>
|
<relativePath>../../..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<version>1.1.0-SNAPSHOT</version>
|
<version>1.1.0-SNAPSHOT</version>
|
||||||
</project>
|
</project>
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.minres.scviewer</groupId>
|
<groupId>com.minres.scviewer</groupId>
|
||||||
<artifactId>com.minres.scviewer.parent</artifactId>
|
<artifactId>com.minres.scviewer.parent</artifactId>
|
||||||
<version>2.15.1</version>
|
<version>2.14.1</version>
|
||||||
<relativePath>../..</relativePath>
|
<relativePath>../../..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
</project>
|
</project>
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.minres.scviewer</groupId>
|
<groupId>com.minres.scviewer</groupId>
|
||||||
<artifactId>com.minres.scviewer.parent</artifactId>
|
<artifactId>com.minres.scviewer.parent</artifactId>
|
||||||
<version>2.15.1</version>
|
<version>2.14.1</version>
|
||||||
<relativePath>../..</relativePath>
|
<relativePath>../../..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<version>1.1.0-SNAPSHOT</version>
|
<version>1.1.0-SNAPSHOT</version>
|
||||||
</project>
|
</project>
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.minres.scviewer</groupId>
|
<groupId>com.minres.scviewer</groupId>
|
||||||
<artifactId>com.minres.scviewer.parent</artifactId>
|
<artifactId>com.minres.scviewer.parent</artifactId>
|
||||||
<version>2.15.1</version>
|
<version>2.14.1</version>
|
||||||
<relativePath>../..</relativePath>
|
<relativePath>../../..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<version>1.1.0-SNAPSHOT</version>
|
<version>1.1.0-SNAPSHOT</version>
|
||||||
</project>
|
</project>
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.minres.scviewer</groupId>
|
<groupId>com.minres.scviewer</groupId>
|
||||||
<artifactId>com.minres.scviewer.parent</artifactId>
|
<artifactId>com.minres.scviewer.parent</artifactId>
|
||||||
<version>2.15.1</version>
|
<version>2.14.1</version>
|
||||||
<relativePath>../..</relativePath>
|
<relativePath>../../..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<packaging>eclipse-plugin</packaging>
|
<packaging>eclipse-plugin</packaging>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
|||||||
Bundle-ManifestVersion: 2
|
Bundle-ManifestVersion: 2
|
||||||
Bundle-Name: Textual transaction database
|
Bundle-Name: Textual transaction database
|
||||||
Bundle-SymbolicName: com.minres.scviewer.database.text
|
Bundle-SymbolicName: com.minres.scviewer.database.text
|
||||||
Bundle-Version: 4.0.1.qualifier
|
Bundle-Version: 4.0.0.qualifier
|
||||||
Bundle-Vendor: MINRES Technologies GmbH
|
Bundle-Vendor: MINRES Technologies GmbH
|
||||||
Bundle-RequiredExecutionEnvironment: JavaSE-11
|
Bundle-RequiredExecutionEnvironment: JavaSE-11
|
||||||
Import-Package: org.osgi.framework;version="1.3.0"
|
Import-Package: org.osgi.framework;version="1.3.0"
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>com.minres.scviewer.database.text</artifactId>
|
<artifactId>com.minres.scviewer.database.text</artifactId>
|
||||||
<version>4.0.1-SNAPSHOT</version>
|
<version>4.0.0-SNAPSHOT</version>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.minres.scviewer</groupId>
|
<groupId>com.minres.scviewer</groupId>
|
||||||
<artifactId>com.minres.scviewer.parent</artifactId>
|
<artifactId>com.minres.scviewer.parent</artifactId>
|
||||||
<version>2.15.1</version>
|
<version>2.14.1</version>
|
||||||
<relativePath>../..</relativePath>
|
<relativePath>../../..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<packaging>eclipse-plugin</packaging>
|
<packaging>eclipse-plugin</packaging>
|
||||||
|
|
||||||
|
@ -345,10 +345,10 @@ public class TextDbLoader implements IWaveformDbLoader {
|
|||||||
String curLine = reader.readLine();
|
String curLine = reader.readLine();
|
||||||
String nextLine = null;
|
String nextLine = null;
|
||||||
while ((nextLine = reader.readLine()) != null && curLine != null) {
|
while ((nextLine = reader.readLine()) != null && curLine != null) {
|
||||||
curLine = parseLine(curLine, nextLine, false);
|
curLine = parseLine(curLine, nextLine);
|
||||||
}
|
}
|
||||||
if (curLine != null)
|
if (curLine != null)
|
||||||
parseLine(curLine, nextLine, true);
|
parseLine(curLine, nextLine);
|
||||||
for(Entry<Long, ScvTx> e: transactionById.entrySet()) {
|
for(Entry<Long, ScvTx> e: transactionById.entrySet()) {
|
||||||
ScvTx scvTx = e.getValue();
|
ScvTx scvTx = e.getValue();
|
||||||
scvTx.endTime=loader.maxTime;
|
scvTx.endTime=loader.maxTime;
|
||||||
@ -385,16 +385,16 @@ public class TextDbLoader implements IWaveformDbLoader {
|
|||||||
* @throws IOException Signals that an I/O exception has occurred.
|
* @throws IOException Signals that an I/O exception has occurred.
|
||||||
* @throws InputFormatException Signals that the input format is wrong
|
* @throws InputFormatException Signals that the input format is wrong
|
||||||
*/
|
*/
|
||||||
private String parseLine(String curLine, String nextLine, boolean last) throws IOException, InputFormatException {
|
private String parseLine(String curLine, String nextLine) throws IOException, InputFormatException {
|
||||||
String[] tokens = curLine.split("\\s+");
|
String[] tokens = curLine.split("\\s+");
|
||||||
if ("tx_record_attribute".equals(tokens[0]) && tokens.length>4) {
|
if ("tx_record_attribute".equals(tokens[0])) {
|
||||||
Long id = Long.parseLong(tokens[1]);
|
Long id = Long.parseLong(tokens[1]);
|
||||||
String name = tokens[2].substring(1, tokens[2].length()-1);
|
String name = tokens[2].substring(1, tokens[2].length()-1);
|
||||||
DataType type = DataType.valueOf(tokens[3]);
|
DataType type = DataType.valueOf(tokens[3]);
|
||||||
String remaining = tokens.length > 5 ? String.join(" ", Arrays.copyOfRange(tokens, 5, tokens.length)) : "";
|
String remaining = tokens.length > 5 ? String.join(" ", Arrays.copyOfRange(tokens, 5, tokens.length)) : "";
|
||||||
TxAttributeType attrType = getAttrType(name, type, AssociationType.RECORD);
|
TxAttributeType attrType = getAttrType(name, type, AssociationType.RECORD);
|
||||||
transactionById.get(id).attributes.add(new TxAttribute(attrType, getAttrString(attrType, remaining)));
|
transactionById.get(id).attributes.add(new TxAttribute(attrType, getAttrString(attrType, remaining)));
|
||||||
} else if ("tx_begin".equals(tokens[0]) && tokens.length>4) {
|
} else if ("tx_begin".equals(tokens[0])) {
|
||||||
Long id = Long.parseLong(tokens[1]);
|
Long id = Long.parseLong(tokens[1]);
|
||||||
Long genId = Long.parseLong(tokens[2]);
|
Long genId = Long.parseLong(tokens[2]);
|
||||||
TxGenerator gen = loader.txGenerators.get(genId);
|
TxGenerator gen = loader.txGenerators.get(genId);
|
||||||
@ -413,7 +413,7 @@ public class TextDbLoader implements IWaveformDbLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
transactionById.put(id, scvTx);
|
transactionById.put(id, scvTx);
|
||||||
} else if ("tx_end".equals(tokens[0]) && tokens.length>4) {
|
} else if ("tx_end".equals(tokens[0])) {
|
||||||
Long id = Long.parseLong(tokens[1]);
|
Long id = Long.parseLong(tokens[1]);
|
||||||
ScvTx scvTx = transactionById.get(id);
|
ScvTx scvTx = transactionById.get(id);
|
||||||
assert Long.parseLong(tokens[2]) == scvTx.generatorId;
|
assert Long.parseLong(tokens[2]) == scvTx.generatorId;
|
||||||
@ -443,7 +443,7 @@ public class TextDbLoader implements IWaveformDbLoader {
|
|||||||
}
|
}
|
||||||
txSink.put(scvTx.getId(), scvTx);
|
txSink.put(scvTx.getId(), scvTx);
|
||||||
transactionById.remove(id);
|
transactionById.remove(id);
|
||||||
} else if ("tx_relation".equals(tokens[0]) && tokens.length>3) {
|
} else if ("tx_relation".equals(tokens[0])) {
|
||||||
Long tr2 = Long.parseLong(tokens[2]);
|
Long tr2 = Long.parseLong(tokens[2]);
|
||||||
Long tr1 = Long.parseLong(tokens[3]);
|
Long tr1 = Long.parseLong(tokens[3]);
|
||||||
String relType = tokens[1].substring(1, tokens[1].length() - 1);
|
String relType = tokens[1].substring(1, tokens[1].length() - 1);
|
||||||
@ -483,7 +483,7 @@ public class TextDbLoader implements IWaveformDbLoader {
|
|||||||
}
|
}
|
||||||
} else if (")".equals(tokens[0])) {
|
} else if (")".equals(tokens[0])) {
|
||||||
generator = null;
|
generator = null;
|
||||||
} else if(!last)
|
} else
|
||||||
throw new InputFormatException("Don't know what to do with: '" + curLine + "'");
|
throw new InputFormatException("Don't know what to do with: '" + curLine + "'");
|
||||||
return nextLine;
|
return nextLine;
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.minres.scviewer</groupId>
|
<groupId>com.minres.scviewer</groupId>
|
||||||
<artifactId>com.minres.scviewer.parent</artifactId>
|
<artifactId>com.minres.scviewer.parent</artifactId>
|
||||||
<version>2.15.1</version>
|
<version>2.14.1</version>
|
||||||
<relativePath>../..</relativePath>
|
<relativePath>../../..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<version>4.0.0-SNAPSHOT</version>
|
<version>4.0.0-SNAPSHOT</version>
|
||||||
</project>
|
</project>
|
||||||
|
@ -79,17 +79,23 @@ public interface IWaveformView extends PropertyChangeListener, ISelectionProvide
|
|||||||
|
|
||||||
public void setHighliteRelation(RelationType relationType);
|
public void setHighliteRelation(RelationType relationType);
|
||||||
|
|
||||||
|
public long getMaxTime();
|
||||||
|
|
||||||
public void setMaxTime(long maxTime);
|
public void setMaxTime(long maxTime);
|
||||||
|
|
||||||
|
public void setZoomLevel(int scale);
|
||||||
|
|
||||||
|
public int getZoomLevel();
|
||||||
|
|
||||||
public void setCursorTime(long time);
|
public void setCursorTime(long time);
|
||||||
|
|
||||||
public void setMarkerTime(int marker, long time);
|
public void setMarkerTime(long time, int index);
|
||||||
|
|
||||||
public long getCursorTime();
|
public long getCursorTime();
|
||||||
|
|
||||||
public int getSelectedMarker();
|
public int getSelectedMarkerId();
|
||||||
|
|
||||||
public long getMarkerTime(int marker);
|
public long getMarkerTime(int index);
|
||||||
|
|
||||||
public void addPropertyChangeListener(PropertyChangeListener listener);
|
public void addPropertyChangeListener(PropertyChangeListener listener);
|
||||||
|
|
||||||
@ -99,8 +105,16 @@ public interface IWaveformView extends PropertyChangeListener, ISelectionProvide
|
|||||||
|
|
||||||
public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener);
|
public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener);
|
||||||
|
|
||||||
|
public String getScaledTime(long time);
|
||||||
|
|
||||||
|
public String[] getZoomLevels();
|
||||||
|
|
||||||
public List<ICursor> getCursorList();
|
public List<ICursor> getCursorList();
|
||||||
|
|
||||||
|
public long getBaselineTime();
|
||||||
|
|
||||||
|
public void setBaselineTime(Long scale);
|
||||||
|
|
||||||
public void scrollHorizontal(int percent);
|
public void scrollHorizontal(int percent);
|
||||||
|
|
||||||
public void scrollTo(int pos);
|
public void scrollTo(int pos);
|
||||||
@ -110,7 +124,4 @@ public interface IWaveformView extends PropertyChangeListener, ISelectionProvide
|
|||||||
public void deleteSelectedTracks();
|
public void deleteSelectedTracks();
|
||||||
|
|
||||||
public TrackEntry addWaveform(IWaveform waveform, int pos);
|
public TrackEntry addWaveform(IWaveform waveform, int pos);
|
||||||
|
|
||||||
public IWaveformZoom getWaveformZoom();
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,24 +0,0 @@
|
|||||||
package com.minres.scviewer.database.ui;
|
|
||||||
|
|
||||||
public interface IWaveformZoom {
|
|
||||||
|
|
||||||
long getMaxVisibleTime();
|
|
||||||
|
|
||||||
long getMinVisibleTime();
|
|
||||||
|
|
||||||
void setMinVisibleTime(long scale);
|
|
||||||
|
|
||||||
long getMaxTime();
|
|
||||||
|
|
||||||
long getScale();
|
|
||||||
|
|
||||||
void setScale(long factor);
|
|
||||||
|
|
||||||
void setVisibleRange(long startTime, long endTime);
|
|
||||||
|
|
||||||
void centerAt(long time);
|
|
||||||
|
|
||||||
void zoom(ZoomKind kind);
|
|
||||||
|
|
||||||
String timeToString(long time);
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
package com.minres.scviewer.database.ui;
|
|
||||||
|
|
||||||
public enum ZoomKind {IN, OUT, FIT, FULL}
|
|
@ -4,8 +4,8 @@ import java.text.DecimalFormat;
|
|||||||
|
|
||||||
public class Constants {
|
public class Constants {
|
||||||
|
|
||||||
public static final String[] UNIT_STRING={"fs", "ps", "ns", "us", "ms", "s"};
|
public static final String[] UNIT_STRING={"fs", "ps", "ns", "us", "ms"};//, "s"};
|
||||||
public static final long[] UNIT_MULTIPLIER={1l, 1000l, 1000l*1000, 1000l*1000*1000, 1000l*1000*1000*1000, 1000l*1000*1000*1000*1000 };
|
public static final long[] UNIT_MULTIPLIER={1, 1000, 1000*1000, 1000*1000*1000, 1000*1000*1000*1000, 1000*1000*1000*1000*1000 };
|
||||||
|
|
||||||
//public static final int[] UNIT_MULTIPLIER={1, 3, 10, 30, 100, 300};
|
//public static final int[] UNIT_MULTIPLIER={1, 3, 10, 30, 100, 300};
|
||||||
public static final long[] SCALE_MULTIPLIER={1, 2, 5, 10, 20, 50, 100, 200, 500};
|
public static final long[] SCALE_MULTIPLIER={1, 2, 5, 10, 20, 50, 100, 200, 500};
|
||||||
@ -16,32 +16,19 @@ public class Constants {
|
|||||||
public static final DecimalFormat TIME_FORMAT_FS = new DecimalFormat("#");
|
public static final DecimalFormat TIME_FORMAT_FS = new DecimalFormat("#");
|
||||||
public static final DecimalFormat TIME_FORMAT_PS = new DecimalFormat("#");
|
public static final DecimalFormat TIME_FORMAT_PS = new DecimalFormat("#");
|
||||||
public static final DecimalFormat TIME_FORMAT_NS = new DecimalFormat("#.0##");
|
public static final DecimalFormat TIME_FORMAT_NS = new DecimalFormat("#.0##");
|
||||||
public static final DecimalFormat TIME_FORMAT_UMS = new DecimalFormat("#.0#####");
|
public static final DecimalFormat TIME_FORMAT_US = new DecimalFormat("#.0#####");
|
||||||
public static final long[] POWERS_OF_TEN = {
|
public static final DecimalFormat TIME_FORMAT_MS = new DecimalFormat("#.0#####");
|
||||||
1L,
|
|
||||||
10L,
|
|
||||||
100L,
|
|
||||||
1_000L,
|
|
||||||
10_000L,
|
|
||||||
100_000L,
|
|
||||||
1_000_000L,
|
|
||||||
10_000_000L,
|
|
||||||
100_000_000L,
|
|
||||||
1_000_000_000L,
|
|
||||||
10_000_000_000L,
|
|
||||||
100_000_000_000L,
|
|
||||||
1_000_000_000_000L,
|
|
||||||
10_000_000_000_000L,
|
|
||||||
100_000_000_000_000L,
|
|
||||||
1_000_000_000_000_000L};
|
|
||||||
|
|
||||||
public static DecimalFormat getTimeFormatForLevel(int idx) {
|
|
||||||
switch(idx) {
|
public static DecimalFormat getTimeFormatForLevel(int level) {
|
||||||
|
switch(level/SCALE_MULTIPLIER.length) {
|
||||||
case 0: return TIME_FORMAT_FS;
|
case 0: return TIME_FORMAT_FS;
|
||||||
case 1: return TIME_FORMAT_PS;
|
case 1: return TIME_FORMAT_PS;
|
||||||
case 2: return TIME_FORMAT_NS;
|
case 2: return TIME_FORMAT_NS;
|
||||||
|
case 3: return TIME_FORMAT_US;
|
||||||
|
case 4: return TIME_FORMAT_MS;
|
||||||
default:
|
default:
|
||||||
return TIME_FORMAT_UMS;
|
return TIME_FORMAT_FS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private Constants() {}
|
private Constants() {}
|
||||||
|
@ -13,7 +13,6 @@ package com.minres.scviewer.database.ui.swt;
|
|||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Plugin;
|
import org.eclipse.core.runtime.Plugin;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.wb.swt.SWTResourceManager;
|
|
||||||
import org.osgi.framework.BundleContext;
|
import org.osgi.framework.BundleContext;
|
||||||
|
|
||||||
public class DatabaseUiPlugin extends Plugin {
|
public class DatabaseUiPlugin extends Plugin {
|
||||||
@ -25,7 +24,6 @@ public class DatabaseUiPlugin extends Plugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop(BundleContext context) throws Exception {
|
public void stop(BundleContext context) throws Exception {
|
||||||
SWTResourceManager.dispose();
|
|
||||||
getLog().log(new Status(IStatus.OK, "org.eclipse.e4.core", "Stopping org.eclipse.e4.core bundle..."));
|
getLog().log(new Status(IStatus.OK, "org.eclipse.e4.core", "Stopping org.eclipse.e4.core bundle..."));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -75,7 +75,7 @@ public class ArrowPainter implements IPainter {
|
|||||||
this.tx = newTx;
|
this.tx = newTx;
|
||||||
iRect = new LinkedList<>();
|
iRect = new LinkedList<>();
|
||||||
oRect = new LinkedList<>();
|
oRect = new LinkedList<>();
|
||||||
scaleFactor = waveCanvas.getScale();
|
scaleFactor = waveCanvas.getScaleFactor();
|
||||||
if (tx != null) {
|
if (tx != null) {
|
||||||
calculateGeometries();
|
calculateGeometries();
|
||||||
}
|
}
|
||||||
@ -133,7 +133,7 @@ public class ArrowPainter implements IPainter {
|
|||||||
Color highliteColor = waveCanvas.styleProvider.getColor(WaveformColors.REL_ARROW_HIGHLITE);
|
Color highliteColor = waveCanvas.styleProvider.getColor(WaveformColors.REL_ARROW_HIGHLITE);
|
||||||
|
|
||||||
if(tx==null) return;
|
if(tx==null) return;
|
||||||
scaleFactor = waveCanvas.getScale();
|
scaleFactor = waveCanvas.getScaleFactor();
|
||||||
if(calculateGeometries())
|
if(calculateGeometries())
|
||||||
return;
|
return;
|
||||||
int correctionValue = (int)(selectionOffset);
|
int correctionValue = (int)(selectionOffset);
|
||||||
|
@ -15,6 +15,7 @@ import org.eclipse.swt.graphics.Rectangle;
|
|||||||
|
|
||||||
import com.minres.scviewer.database.ui.ICursor;
|
import com.minres.scviewer.database.ui.ICursor;
|
||||||
import com.minres.scviewer.database.ui.WaveformColors;
|
import com.minres.scviewer.database.ui.WaveformColors;
|
||||||
|
import com.minres.scviewer.database.ui.swt.Constants;
|
||||||
|
|
||||||
public class CursorPainter implements IPainter, ICursor {
|
public class CursorPainter implements IPainter, ICursor {
|
||||||
|
|
||||||
@ -65,7 +66,7 @@ public class CursorPainter implements IPainter, ICursor {
|
|||||||
Rectangle area = proj.unProject(clientRect);
|
Rectangle area = proj.unProject(clientRect);
|
||||||
if(!waveCanvas.painterList.isEmpty()){
|
if(!waveCanvas.painterList.isEmpty()){
|
||||||
|
|
||||||
long scaleFactor=waveCanvas.getScale();
|
long scaleFactor=waveCanvas.getScaleFactor();
|
||||||
long beginPos = area.x;
|
long beginPos = area.x;
|
||||||
|
|
||||||
maxPosX = area.x + area.width;
|
maxPosX = area.x + area.width;
|
||||||
@ -83,7 +84,8 @@ public class CursorPainter implements IPainter, ICursor {
|
|||||||
proj.drawLine(x, top, x, area.y+area.height);
|
proj.drawLine(x, top, x, area.y+area.height);
|
||||||
proj.setBackground(drawColor);
|
proj.setBackground(drawColor);
|
||||||
proj.setForeground(textColor);
|
proj.setForeground(textColor);
|
||||||
proj.drawText(waveCanvas.timeToString(time), x+1, top);
|
double dTime=time;
|
||||||
|
proj.drawText(Constants.getTimeFormatForLevel(waveCanvas.getZoomLevel()).format(dTime/waveCanvas.getScaleFactorPow10())+waveCanvas.getUnitStr(), x+1, top);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@ package com.minres.scviewer.database.ui.swt.internal;
|
|||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.graphics.Color;
|
import org.eclipse.swt.graphics.Color;
|
||||||
import org.eclipse.swt.graphics.GC;
|
import org.eclipse.swt.graphics.GC;
|
||||||
import org.eclipse.swt.graphics.Point;
|
|
||||||
import org.eclipse.swt.graphics.Rectangle;
|
import org.eclipse.swt.graphics.Rectangle;
|
||||||
import org.eclipse.wb.swt.SWTResourceManager;
|
import org.eclipse.wb.swt.SWTResourceManager;
|
||||||
|
|
||||||
@ -38,26 +37,26 @@ public class RulerPainter implements IPainter {
|
|||||||
Color headerBgColor = waveCanvas.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
|
Color headerBgColor = waveCanvas.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
|
||||||
if(headerBgColor.isDisposed())
|
if(headerBgColor.isDisposed())
|
||||||
headerBgColor=SWTResourceManager.getColor(255,255,255);
|
headerBgColor=SWTResourceManager.getColor(255,255,255);
|
||||||
|
String unit=waveCanvas.getUnitStr();
|
||||||
|
long unitMultiplier=waveCanvas.getUnitMultiplier();
|
||||||
|
long scaleFactor=waveCanvas.getScaleFactor();
|
||||||
|
|
||||||
long scaleFactor=waveCanvas.getScale();
|
long startPos=area.x*scaleFactor;
|
||||||
long startTime=waveCanvas.getMinVisibleTime();
|
long startVal=startPos - proj.getTranslation().x*scaleFactor;
|
||||||
long endTime=waveCanvas.getMaxVisibleTime();
|
long endPos=startPos+area.width*scaleFactor;
|
||||||
|
|
||||||
|
long rulerTickMinor = RULER_TICK_MINOR*scaleFactor;
|
||||||
|
long rulerTickMajor = RULER_TICK_MAJOR*scaleFactor;
|
||||||
|
|
||||||
long multiplier = Constants.POWERS_OF_TEN[waveCanvas.getScaleMagnitude()];
|
|
||||||
long rulerTickMinor = RULER_TICK_MINOR*multiplier;
|
|
||||||
long rulerTickMajor = RULER_TICK_MAJOR*multiplier;
|
|
||||||
if((endTime-startTime)/rulerTickMinor>area.width/5) {
|
|
||||||
rulerTickMinor*=10;
|
|
||||||
rulerTickMajor*=10;
|
|
||||||
}
|
|
||||||
int minorTickY = waveCanvas.rulerHeight-5;
|
int minorTickY = waveCanvas.rulerHeight-5;
|
||||||
int majorTickY = waveCanvas.rulerHeight-15;
|
int majorTickY = waveCanvas.rulerHeight-15;
|
||||||
int textY=waveCanvas.rulerHeight-30;
|
int textY=waveCanvas.rulerHeight-30;
|
||||||
int baselineY=waveCanvas.rulerHeight - 1;
|
int baselineY=waveCanvas.rulerHeight - 1;
|
||||||
int bottom=waveCanvas.rulerHeight - 2;
|
int bottom=waveCanvas.rulerHeight - 2;
|
||||||
|
|
||||||
long startTickTime = startTime+rulerTickMinor-(startTime % rulerTickMinor);
|
long modulo = startVal % rulerTickMinor;
|
||||||
long majorTickDist = rulerTickMajor/scaleFactor;
|
long startMinorIncrPos = startPos+rulerTickMinor-modulo;
|
||||||
|
long startMinorIncrVal = startVal+rulerTickMinor-modulo;
|
||||||
|
|
||||||
gc.setBackground(waveCanvas.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
|
gc.setBackground(waveCanvas.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
|
||||||
gc.fillRectangle(new Rectangle(area.x, area.y, area.width, waveCanvas.rulerHeight));
|
gc.fillRectangle(new Rectangle(area.x, area.y, area.width, waveCanvas.rulerHeight));
|
||||||
@ -65,20 +64,20 @@ public class RulerPainter implements IPainter {
|
|||||||
gc.fillRectangle(new Rectangle(area.x, area.y, area.width, baselineY));
|
gc.fillRectangle(new Rectangle(area.x, area.y, area.width, baselineY));
|
||||||
gc.setForeground(headerFgColor);
|
gc.setForeground(headerFgColor);
|
||||||
gc.drawLine(area.x, area.y+bottom, area.x+area.width, area.y+bottom);
|
gc.drawLine(area.x, area.y+bottom, area.x+area.width, area.y+bottom);
|
||||||
int maxTextLength=0;
|
boolean allMarker=true;
|
||||||
for (long tickTime = startTickTime; tickTime < endTime; tickTime+= rulerTickMinor) {
|
for (long pos = startMinorIncrPos, tick = startMinorIncrVal; pos < endPos; pos+= rulerTickMinor, tick += rulerTickMinor) {
|
||||||
if ((tickTime % rulerTickMajor) == 0) {
|
if ((tick % rulerTickMajor) == 0) {
|
||||||
Point textSize = gc.textExtent(waveCanvas.timeToString(tickTime));
|
String text = Constants.getTimeFormatForLevel(waveCanvas.getZoomLevel()).format(tick/scaleFactor*unitMultiplier);
|
||||||
maxTextLength=textSize.x>maxTextLength?textSize.x:maxTextLength;
|
if(text.length()>8) allMarker=false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
boolean drawEvery = majorTickDist>maxTextLength;
|
boolean drawText = true;
|
||||||
boolean drawText=true;
|
for (long pos = startMinorIncrPos, tick = startMinorIncrVal; pos < endPos; pos+= rulerTickMinor, tick += rulerTickMinor) {
|
||||||
for (long tickTime = startTickTime; tickTime < endTime; tickTime+= rulerTickMinor) {
|
int x0Pos = (int) (pos/scaleFactor);
|
||||||
int x0Pos = (int) (tickTime/scaleFactor) + proj.getTranslation().x;
|
long x0Val = tick/scaleFactor;
|
||||||
if ((tickTime % rulerTickMajor) == 0) {
|
if ((tick % rulerTickMajor) == 0) {
|
||||||
if(drawEvery || drawText)
|
if(allMarker || drawText)
|
||||||
gc.drawText(waveCanvas.timeToString(tickTime), x0Pos, area.y+textY);
|
gc.drawText(Constants.getTimeFormatForLevel(waveCanvas.getZoomLevel()).format(x0Val*unitMultiplier)+unit, x0Pos, area.y+textY);
|
||||||
gc.drawLine(x0Pos, area.y+majorTickY, x0Pos,area.y+ bottom);
|
gc.drawLine(x0Pos, area.y+majorTickY, x0Pos,area.y+ bottom);
|
||||||
drawText=!drawText;
|
drawText=!drawText;
|
||||||
} else {
|
} else {
|
||||||
|
@ -82,7 +82,7 @@ public class SignalPainter extends TrackPainter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int getXPosEnd(long time) {
|
private int getXPosEnd(long time) {
|
||||||
long ltmp = time / this.waveCanvas.getScale();
|
long ltmp = time / this.waveCanvas.getScaleFactor();
|
||||||
return ltmp > maxPosX ? maxPosX : (int) ltmp;
|
return ltmp > maxPosX ? maxPosX : (int) ltmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ public class SignalPainter extends TrackPainter {
|
|||||||
proj.setFillRule(SWT.FILL_EVEN_ODD);
|
proj.setFillRule(SWT.FILL_EVEN_ODD);
|
||||||
proj.fillRectangle(area);
|
proj.fillRectangle(area);
|
||||||
|
|
||||||
long scaleFactor = this.waveCanvas.getScale();
|
long scaleFactor = this.waveCanvas.getScaleFactor();
|
||||||
long beginPos = area.x;
|
long beginPos = area.x;
|
||||||
long beginTime = beginPos*scaleFactor;
|
long beginTime = beginPos*scaleFactor;
|
||||||
long endTime = beginTime + area.width*scaleFactor;
|
long endTime = beginTime + area.width*scaleFactor;
|
||||||
@ -114,7 +114,7 @@ public class SignalPainter extends TrackPainter {
|
|||||||
yOffsetT = this.waveCanvas.styleProvider.getTrackHeight() / 5 + area.y;
|
yOffsetT = this.waveCanvas.styleProvider.getTrackHeight() / 5 + area.y;
|
||||||
yOffsetM = this.waveCanvas.styleProvider.getTrackHeight() / 2 + area.y;
|
yOffsetM = this.waveCanvas.styleProvider.getTrackHeight() / 2 + area.y;
|
||||||
yOffsetB = 4 * this.waveCanvas.styleProvider.getTrackHeight() / 5 + area.y;
|
yOffsetB = 4 * this.waveCanvas.styleProvider.getTrackHeight() / 5 + area.y;
|
||||||
int xSigChangeBeginVal = Math.max(area.x, (int) (left.time / this.waveCanvas.getScale()));
|
int xSigChangeBeginVal = Math.max(area.x, (int) (left.time / this.waveCanvas.getScaleFactor()));
|
||||||
int xSigChangeBeginPos = area.x;
|
int xSigChangeBeginPos = area.x;
|
||||||
int xSigChangeEndPos = Math.max(area.x, getXPosEnd(right.time));
|
int xSigChangeEndPos = Math.max(area.x, getXPosEnd(right.time));
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ public class SignalPainter extends TrackPainter {
|
|||||||
right.time = endTime;
|
right.time = endTime;
|
||||||
} else {
|
} else {
|
||||||
multiple = true;
|
multiple = true;
|
||||||
long eTime = (xSigChangeBeginVal + 1) * this.waveCanvas.getScale();
|
long eTime = (xSigChangeBeginVal + 1) * this.waveCanvas.getScaleFactor();
|
||||||
right.set(entries.floorEntry(eTime), endTime);
|
right.set(entries.floorEntry(eTime), endTime);
|
||||||
right.time = eTime;
|
right.time = eTime;
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@ public class SignalPainter extends TrackPainter {
|
|||||||
multiple = false;
|
multiple = false;
|
||||||
if (xSigChangeEndPos == xSigChangeBeginPos) {
|
if (xSigChangeEndPos == xSigChangeBeginPos) {
|
||||||
multiple = true;
|
multiple = true;
|
||||||
long eTime = (xSigChangeBeginPos + 1) * this.waveCanvas.getScale();
|
long eTime = (xSigChangeBeginPos + 1) * this.waveCanvas.getScaleFactor();
|
||||||
EventEntry entry = entries.floorEntry(eTime);
|
EventEntry entry = entries.floorEntry(eTime);
|
||||||
if(entry!=null && entry.timestamp> right.time)
|
if(entry!=null && entry.timestamp> right.time)
|
||||||
right.set(entry, endTime);
|
right.set(entry, endTime);
|
||||||
|
@ -67,7 +67,7 @@ public class StreamPainter extends TrackPainter{
|
|||||||
proj.setFillRule(SWT.FILL_EVEN_ODD);
|
proj.setFillRule(SWT.FILL_EVEN_ODD);
|
||||||
proj.fillRectangle(area);
|
proj.fillRectangle(area);
|
||||||
|
|
||||||
long scaleFactor = this.waveCanvas.getScale();
|
long scaleFactor = this.waveCanvas.getScaleFactor();
|
||||||
long beginPos = area.x;
|
long beginPos = area.x;
|
||||||
long beginTime = beginPos*scaleFactor;
|
long beginTime = beginPos*scaleFactor;
|
||||||
long endTime = beginTime + area.width*scaleFactor;
|
long endTime = beginTime + area.width*scaleFactor;
|
||||||
@ -130,8 +130,8 @@ public class StreamPainter extends TrackPainter{
|
|||||||
|
|
||||||
int offset = concurrencyIndex*this.waveCanvas.styleProvider.getTrackHeight();
|
int offset = concurrencyIndex*this.waveCanvas.styleProvider.getTrackHeight();
|
||||||
Rectangle bb = new Rectangle(
|
Rectangle bb = new Rectangle(
|
||||||
(int)(tx.getBeginTime()/this.waveCanvas.getScale()), area.y+offset+txBase,
|
(int)(tx.getBeginTime()/this.waveCanvas.getScaleFactor()), area.y+offset+txBase,
|
||||||
(int)((tx.getEndTime()-tx.getBeginTime())/this.waveCanvas.getScale()), txHeight);
|
(int)((tx.getEndTime()-tx.getBeginTime())/this.waveCanvas.getScaleFactor()), txHeight);
|
||||||
|
|
||||||
if(bb.x+bb.width<area.x || bb.x>area.x+area.width) return;
|
if(bb.x+bb.width<area.x || bb.x>area.x+area.width) return;
|
||||||
if(bb.width==0){
|
if(bb.width==0){
|
||||||
@ -155,7 +155,7 @@ public class StreamPainter extends TrackPainter{
|
|||||||
|
|
||||||
public ITx getClicked(Point point) {
|
public ITx getClicked(Point point) {
|
||||||
int lane=point.y/waveCanvas.styleProvider.getTrackHeight();
|
int lane=point.y/waveCanvas.styleProvider.getTrackHeight();
|
||||||
EventEntry firstTx=stream.getEvents().floorEntry(point.x*waveCanvas.getScale());
|
EventEntry firstTx=stream.getEvents().floorEntry(point.x*waveCanvas.getScaleFactor());
|
||||||
if(firstTx!=null){
|
if(firstTx!=null){
|
||||||
do {
|
do {
|
||||||
ITx tx = getTxFromEntry(lane, point.x, firstTx.events);
|
ITx tx = getTxFromEntry(lane, point.x, firstTx.events);
|
||||||
@ -175,9 +175,9 @@ public class StreamPainter extends TrackPainter{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected ITx getTxFromEntry(int lane, int offset, IEvent[] firstTx) {
|
protected ITx getTxFromEntry(int lane, int offset, IEvent[] firstTx) {
|
||||||
long timePoint=offset*waveCanvas.getScale();
|
long timePoint=offset*waveCanvas.getScaleFactor();
|
||||||
long timePointLow=(offset-5)*waveCanvas.getScale();
|
long timePointLow=(offset-5)*waveCanvas.getScaleFactor();
|
||||||
long timePointHigh=(offset+5)*waveCanvas.getScale();
|
long timePointHigh=(offset+5)*waveCanvas.getScaleFactor();
|
||||||
for(IEvent e:firstTx){
|
for(IEvent e:firstTx){
|
||||||
if(e instanceof ITxEvent) {
|
if(e instanceof ITxEvent) {
|
||||||
ITxEvent evt = (ITxEvent) e;
|
ITxEvent evt = (ITxEvent) e;
|
||||||
|
@ -43,7 +43,6 @@ public class TrackAreaPainter implements IPainter {
|
|||||||
Integer firstKey=trackVerticalOffset.floorKey(area.y);
|
Integer firstKey=trackVerticalOffset.floorKey(area.y);
|
||||||
if(firstKey==null) firstKey=trackVerticalOffset.firstKey();
|
if(firstKey==null) firstKey=trackVerticalOffset.firstKey();
|
||||||
Integer lastKey = trackVerticalOffset.floorKey(area.y+area.height);
|
Integer lastKey = trackVerticalOffset.floorKey(area.y+area.height);
|
||||||
//if(lastKey==null) lastKey= trackVerticalOffset.lastKey();
|
|
||||||
Rectangle subArea = new Rectangle(area.x, 0, area.width, 0);
|
Rectangle subArea = new Rectangle(area.x, 0, area.width, 0);
|
||||||
if(lastKey.equals(firstKey)){
|
if(lastKey.equals(firstKey)){
|
||||||
subArea.y=firstKey;
|
subArea.y=firstKey;
|
||||||
|
@ -42,27 +42,20 @@ import com.minres.scviewer.database.tx.ITx;
|
|||||||
import com.minres.scviewer.database.tx.ITxEvent;
|
import com.minres.scviewer.database.tx.ITxEvent;
|
||||||
import com.minres.scviewer.database.ui.IWaveformStyleProvider;
|
import com.minres.scviewer.database.ui.IWaveformStyleProvider;
|
||||||
import com.minres.scviewer.database.ui.IWaveformView;
|
import com.minres.scviewer.database.ui.IWaveformView;
|
||||||
import com.minres.scviewer.database.ui.IWaveformZoom;
|
|
||||||
import com.minres.scviewer.database.ui.TrackEntry;
|
import com.minres.scviewer.database.ui.TrackEntry;
|
||||||
import com.minres.scviewer.database.ui.ZoomKind;
|
|
||||||
import com.minres.scviewer.database.ui.swt.Constants;
|
import com.minres.scviewer.database.ui.swt.Constants;
|
||||||
import com.minres.scviewer.database.ui.swt.internal.slider.ZoomBar;
|
|
||||||
|
|
||||||
public class WaveformCanvas extends Canvas implements IWaveformZoom{
|
public class WaveformCanvas extends Canvas {
|
||||||
|
|
||||||
public static final long ZOOM_FIT = -2;
|
|
||||||
|
|
||||||
public static final long ZOOM_FULL = -1;
|
|
||||||
|
|
||||||
private static final int INITIAL_ZOOM_BAR_MAX = 1000;
|
|
||||||
|
|
||||||
private boolean doubleBuffering = true;
|
private boolean doubleBuffering = true;
|
||||||
|
|
||||||
IWaveformStyleProvider styleProvider;
|
IWaveformStyleProvider styleProvider;
|
||||||
|
|
||||||
private int scaleMagnitude = 6;
|
private long scaleFactor = 1000000L; // 1ns
|
||||||
|
|
||||||
private long scaleFactor = Constants.POWERS_OF_TEN[scaleMagnitude];
|
String unit="ns";
|
||||||
|
|
||||||
|
private int level = 12;
|
||||||
|
|
||||||
private long maxTime;
|
private long maxTime;
|
||||||
|
|
||||||
@ -84,23 +77,22 @@ public class WaveformCanvas extends Canvas implements IWaveformZoom{
|
|||||||
|
|
||||||
private List<CursorPainter> cursorPainters;
|
private List<CursorPainter> cursorPainters;
|
||||||
|
|
||||||
private ZoomBar horizontal;
|
|
||||||
|
|
||||||
private int[] lastHorSelection;
|
|
||||||
|
|
||||||
private long sliderScaleFactor = 1;
|
|
||||||
|
|
||||||
private ScrollBar vertical;
|
|
||||||
|
|
||||||
HashMap<IWaveform, IWaveformPainter> wave2painterMap;
|
HashMap<IWaveform, IWaveformPainter> wave2painterMap;
|
||||||
|
/**
|
||||||
public WaveformCanvas(final Composite parent, int style, IWaveformStyleProvider styleProvider, ZoomBar.IProvider scrollbarProvider) {
|
* Constructor for ScrollableCanvas.
|
||||||
super(parent, (style & ~SWT.H_SCROLL) | SWT.DOUBLE_BUFFERED | SWT.NO_BACKGROUND | SWT.V_SCROLL );
|
*
|
||||||
|
* @param parent
|
||||||
|
* the parent of this control.super(parent, style | SWT.DOUBLE_BUFFERED | SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE | SWT.V_SCROLL | SWT.H_SCROLL);
|
||||||
|
* @param style
|
||||||
|
* the style of this control.
|
||||||
|
*/
|
||||||
|
public WaveformCanvas(final Composite parent, int style, IWaveformStyleProvider styleProvider) {
|
||||||
|
super(parent, style | SWT.DOUBLE_BUFFERED | SWT.NO_BACKGROUND | SWT.V_SCROLL | SWT.H_SCROLL);
|
||||||
this.styleProvider=styleProvider;
|
this.styleProvider=styleProvider;
|
||||||
addControlListener(new ControlAdapter() { /* resize listener. */
|
addControlListener(new ControlAdapter() { /* resize listener. */
|
||||||
@Override
|
@Override
|
||||||
public void controlResized(ControlEvent event) {
|
public void controlResized(ControlEvent event) {
|
||||||
syncSb();
|
syncScrollBars();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
addPaintListener((final PaintEvent event) -> paint(event.gc));
|
addPaintListener((final PaintEvent event) -> paint(event.gc));
|
||||||
@ -110,8 +102,6 @@ public class WaveformCanvas extends Canvas implements IWaveformZoom{
|
|||||||
cursorPainters= new ArrayList<>();
|
cursorPainters= new ArrayList<>();
|
||||||
wave2painterMap=new HashMap<>();
|
wave2painterMap=new HashMap<>();
|
||||||
|
|
||||||
horizontal = scrollbarProvider.getScrollBar();
|
|
||||||
vertical = getVerticalBar();
|
|
||||||
initScrollBars();
|
initScrollBars();
|
||||||
// order is important: it is bottom to top
|
// order is important: it is bottom to top
|
||||||
trackAreaPainter=new TrackAreaPainter(this);
|
trackAreaPainter=new TrackAreaPainter(this);
|
||||||
@ -120,10 +110,10 @@ public class WaveformCanvas extends Canvas implements IWaveformZoom{
|
|||||||
painterList.add(arrowPainter);
|
painterList.add(arrowPainter);
|
||||||
rulerPainter=new RulerPainter(this);
|
rulerPainter=new RulerPainter(this);
|
||||||
painterList.add(rulerPainter);
|
painterList.add(rulerPainter);
|
||||||
CursorPainter cp = new CursorPainter(this, getScale() * 10, cursorPainters.size()-1);
|
CursorPainter cp = new CursorPainter(this, scaleFactor * 10, cursorPainters.size()-1);
|
||||||
painterList.add(cp);
|
painterList.add(cp);
|
||||||
cursorPainters.add(cp);
|
cursorPainters.add(cp);
|
||||||
CursorPainter marker = new CursorPainter(this, getScale() * 100, cursorPainters.size()-1);
|
CursorPainter marker = new CursorPainter(this, scaleFactor * 100, cursorPainters.size()-1);
|
||||||
painterList.add(marker);
|
painterList.add(marker);
|
||||||
cursorPainters.add(marker);
|
cursorPainters.add(marker);
|
||||||
wave2painterMap=new HashMap<>();
|
wave2painterMap=new HashMap<>();
|
||||||
@ -155,107 +145,117 @@ public class WaveformCanvas extends Canvas implements IWaveformZoom{
|
|||||||
|
|
||||||
public void setOrigin(int x, int y) {
|
public void setOrigin(int x, int y) {
|
||||||
checkWidget();
|
checkWidget();
|
||||||
|
ScrollBar hBar = getHorizontalBar();
|
||||||
|
hBar.setSelection(-x);
|
||||||
|
x = -hBar.getSelection();
|
||||||
|
ScrollBar vBar = getVerticalBar();
|
||||||
|
vBar.setSelection(-y);
|
||||||
|
y = -vBar.getSelection();
|
||||||
origin.x = x;
|
origin.x = x;
|
||||||
origin.y = y;
|
origin.y = y;
|
||||||
syncSb();
|
syncScrollBars();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getMaxTime() {
|
public long getMaxTime() {
|
||||||
return maxTime;
|
return maxTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxTime(long maxTime) {
|
public void setMaxTime(long maxTime) {
|
||||||
this.maxTime = maxTime;
|
this.maxTime = maxTime;
|
||||||
if(maxTime>INITIAL_ZOOM_BAR_MAX) {
|
syncScrollBars();
|
||||||
long maxBarTime = maxTime;
|
|
||||||
while(maxBarTime>Integer.MAX_VALUE) maxBarTime/=1000;
|
|
||||||
horizontal.setMaximum((int) maxBarTime);
|
|
||||||
}
|
|
||||||
sliderScaleFactor = maxTime/horizontal.getMaximum();
|
|
||||||
syncSb();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public int getZoomLevel() {
|
||||||
public long getScale() {
|
return level;
|
||||||
return scaleFactor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public int getMaxZoomLevel(){
|
||||||
public void setScale(long factor) {
|
return Constants.SCALE_MULTIPLIER.length*Constants.UNIT_STRING.length-1;
|
||||||
setScalingFactor(factor, (getMaxVisibleTime()+getMinVisibleTime())/2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void setZoomLevel(int level) {
|
||||||
public void setVisibleRange(long startTime, long endTime) {
|
long tc=cursorPainters.get(0).getTime(); // cursor time
|
||||||
assert(startTime<endTime);
|
setZoomLevel(level, tc);
|
||||||
long time_diff = endTime-startTime;
|
|
||||||
long factor = (time_diff*11/10)/getClientArea().width;
|
|
||||||
setScalingFactor(factor, startTime+time_diff/2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Override
|
public void setZoomLevel(int level, long centerTime) {
|
||||||
public void setScalingFactor(long factor, long centerTime) {
|
if(level<0) {
|
||||||
Rectangle clientArea = getClientArea();
|
if(level<-1) {
|
||||||
long clientAreaWidth = clientArea.width;
|
|
||||||
long maxFactor=maxTime/clientAreaWidth;
|
|
||||||
if(factor<0) {
|
|
||||||
if(factor== ZOOM_FIT) {
|
|
||||||
long cTime = getCursorPainters().get(0).getTime();
|
long cTime = getCursorPainters().get(0).getTime();
|
||||||
long time_diff = centerTime>cTime?centerTime-cTime:cTime-centerTime;
|
long time_diff = centerTime>cTime?centerTime-cTime:cTime-centerTime;
|
||||||
|
level = findFitZoomLevel(time_diff);
|
||||||
centerTime = (centerTime>cTime?cTime:centerTime)+time_diff/2;
|
centerTime = (centerTime>cTime?cTime:centerTime)+time_diff/2;
|
||||||
factor = (time_diff*11/10)/clientAreaWidth;
|
} else
|
||||||
} else if(factor== ZOOM_FULL)
|
level = findFitZoomLevel(maxTime);
|
||||||
factor = maxFactor;
|
if(level<0) level = 0;
|
||||||
}
|
}
|
||||||
if(factor==0)
|
//FIXME: keep center if zoom-out and cursor is not in view
|
||||||
factor=1;
|
if(level<Constants.SCALE_MULTIPLIER.length*Constants.UNIT_STRING.length){
|
||||||
else if(factor>maxFactor)
|
int scale = level%Constants.SCALE_MULTIPLIER.length;
|
||||||
factor=maxFactor;
|
int unit = level/Constants.SCALE_MULTIPLIER.length;
|
||||||
if(factor!=getScale() || (getMaxVisibleTime()+getMinVisibleTime()/2) != centerTime) {
|
this.scaleFactor = Constants.UNIT_MULTIPLIER[unit]*Constants.SCALE_MULTIPLIER[scale];
|
||||||
updateScaleFactor(factor);
|
|
||||||
ITx tx = arrowPainter.getTx();
|
ITx tx = arrowPainter.getTx();
|
||||||
arrowPainter.setTx(null);
|
arrowPainter.setTx(null);
|
||||||
/*
|
/*
|
||||||
* xc = tc/oldScaleFactor
|
* xc = tc/oldScaleFactor
|
||||||
* xoffs = xc+origin.x
|
* xoffs = xc+origin.x
|
||||||
* xcn = tc/newScaleFactor
|
* xcn = tc/newScaleFactor
|
||||||
* t0n = (xcn-xoffs)*getScale()
|
* t0n = (xcn-xoffs)*scaleFactor
|
||||||
*/
|
*/
|
||||||
|
Rectangle clientArea = getClientArea();
|
||||||
|
long clientAreaWidth = clientArea.width;
|
||||||
long xoffs = clientAreaWidth/2;
|
long xoffs = clientAreaWidth/2;
|
||||||
long xcn=centerTime/getScale(); // new total x-offset
|
long xcn=centerTime/scaleFactor; // new total x-offset
|
||||||
long originX=xcn-xoffs;
|
long originX=xcn-xoffs;
|
||||||
if(originX>0) {
|
if(originX>0) {
|
||||||
origin.x=(int) -originX; // new cursor time offset relative to left border
|
origin.x=(int) -originX; // new cursor time offset relative to left border
|
||||||
}else {
|
}else {
|
||||||
origin.x=0;
|
origin.x=0;
|
||||||
}
|
}
|
||||||
syncSb();
|
syncScrollBars();
|
||||||
arrowPainter.setTx(tx);
|
arrowPainter.setTx(tx);
|
||||||
redraw();
|
redraw();
|
||||||
|
this.level = level;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateScaleFactor(long factor) {
|
private int findFitZoomLevel(long duration) {
|
||||||
scaleFactor = factor;
|
//get area actually capable of displaying data, i.e. area of the receiver which is capable of displaying data
|
||||||
scaleMagnitude = 0;
|
Rectangle clientArea = getClientArea();
|
||||||
for(int i=Constants.POWERS_OF_TEN.length-1; i>0; i--) {
|
long clientAreaWidth = clientArea.width;
|
||||||
if(scaleFactor>=Constants.POWERS_OF_TEN[i]) {
|
//try to find existing zoomlevel where scaleFactor*clientAreaWidth >= maxTime, if one is found set it as new zoomlevel
|
||||||
scaleMagnitude = i;
|
for(int unitIdx=0; unitIdx<Constants.UNIT_STRING.length; unitIdx++) {
|
||||||
break;
|
long magnitudeMultiplier = Constants.UNIT_MULTIPLIER[unitIdx];
|
||||||
|
for (int scaleIdx=0; scaleIdx<Constants.SCALE_MULTIPLIER.length; scaleIdx++){
|
||||||
|
long scaleFactor = magnitudeMultiplier * Constants.SCALE_MULTIPLIER[scaleIdx];
|
||||||
|
long range = scaleFactor*clientAreaWidth;
|
||||||
|
if( range >= duration)
|
||||||
|
return unitIdx*Constants.SCALE_MULTIPLIER.length+scaleIdx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public long getScaleFactor() {
|
||||||
public String timeToString(long time) {
|
return scaleFactor;
|
||||||
int idx = scaleMagnitude/3;
|
}
|
||||||
double fTime = (double)time/Constants.UNIT_MULTIPLIER[idx];
|
|
||||||
return Constants.getTimeFormatForLevel(idx).format(fTime)+Constants.UNIT_STRING[idx];
|
public long getScaleFactorPow10() {
|
||||||
|
int scale = level/Constants.SCALE_MULTIPLIER.length;
|
||||||
|
double res = Math.pow(1000, scale);
|
||||||
|
return (long) res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUnitStr(){
|
||||||
|
return Constants.UNIT_STRING[level/Constants.SCALE_MULTIPLIER.length];
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getUnitMultiplier(){
|
||||||
|
return Constants.SCALE_MULTIPLIER[level%Constants.SCALE_MULTIPLIER.length];
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getTimeForOffset(int xOffset){
|
public long getTimeForOffset(int xOffset){
|
||||||
return (xOffset-origin.x) * getScale();
|
return (xOffset-origin.x) * scaleFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPainter(IPainter painter) {
|
public void addPainter(IPainter painter) {
|
||||||
@ -275,7 +275,7 @@ public class WaveformCanvas extends Canvas implements IWaveformZoom{
|
|||||||
void clearAllWaveformPainter(boolean update) {
|
void clearAllWaveformPainter(boolean update) {
|
||||||
trackAreaPainter.trackVerticalOffset.clear();
|
trackAreaPainter.trackVerticalOffset.clear();
|
||||||
wave2painterMap.clear();
|
wave2painterMap.clear();
|
||||||
if(update) syncSb();
|
if(update) syncScrollBars();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addWaveformPainter(IWaveformPainter painter) {
|
public void addWaveformPainter(IWaveformPainter painter) {
|
||||||
@ -285,7 +285,7 @@ public class WaveformCanvas extends Canvas implements IWaveformZoom{
|
|||||||
void addWaveformPainter(IWaveformPainter painter, boolean update) {
|
void addWaveformPainter(IWaveformPainter painter, boolean update) {
|
||||||
trackAreaPainter.addTrackPainter(painter);
|
trackAreaPainter.addTrackPainter(painter);
|
||||||
wave2painterMap.put(painter.getTrackEntry().waveform, painter);
|
wave2painterMap.put(painter.getTrackEntry().waveform, painter);
|
||||||
if(update) syncSb();
|
if(update) syncScrollBars();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<CursorPainter> getCursorPainters() {
|
public List<CursorPainter> getCursorPainters() {
|
||||||
@ -294,41 +294,26 @@ public class WaveformCanvas extends Canvas implements IWaveformZoom{
|
|||||||
|
|
||||||
/* Initialize the scrollbar and register listeners. */
|
/* Initialize the scrollbar and register listeners. */
|
||||||
private void initScrollBars() {
|
private void initScrollBars() {
|
||||||
|
ScrollBar horizontal = getHorizontalBar();
|
||||||
horizontal.setEnabled(false);
|
horizontal.setEnabled(false);
|
||||||
horizontal.setVisible(true);
|
horizontal.setVisible(true);
|
||||||
horizontal.addSelectionListener(new SelectionAdapter() {
|
horizontal.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent event) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
if (!painterList.isEmpty()) {
|
if (painterList.isEmpty())
|
||||||
int[] sel = horizontal.getSelection();
|
return;
|
||||||
long lowerTime = sel[0]*sliderScaleFactor;
|
setOrigin(-((ScrollBar) event.widget).getSelection(), origin.y);
|
||||||
long upperTime = sel[1]*sliderScaleFactor;
|
|
||||||
if(sel[1]-sel[0] != lastHorSelection[1]-lastHorSelection[0]) {
|
|
||||||
long time_diff = upperTime-lowerTime;
|
|
||||||
long factor = time_diff/getClientArea().width;
|
|
||||||
setScalingFactor(factor, lowerTime+time_diff/2);
|
|
||||||
} else {
|
|
||||||
origin.x = -(int) (lowerTime/getScale());
|
|
||||||
WaveformCanvas.this.getDisplay().asyncExec(() -> {redraw();});
|
|
||||||
}
|
|
||||||
lastHorSelection=sel;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
horizontal.setMinimum(0);
|
ScrollBar vertical = getVerticalBar();
|
||||||
horizontal.setMaximum(INITIAL_ZOOM_BAR_MAX);
|
|
||||||
lastHorSelection = horizontal.getSelection();
|
|
||||||
|
|
||||||
vertical.setEnabled(false);
|
vertical.setEnabled(false);
|
||||||
vertical.setVisible(true);
|
vertical.setVisible(true);
|
||||||
vertical.addSelectionListener(new SelectionAdapter() {
|
vertical.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent event) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
if (!painterList.isEmpty()) {
|
if (painterList.isEmpty())
|
||||||
origin.y=-vertical.getSelection();
|
return;
|
||||||
fireSelectionEvent();
|
setOrigin(origin.x, -((ScrollBar) event.widget).getSelection());
|
||||||
WaveformCanvas.this.getDisplay().asyncExec(() -> {redraw();});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -338,48 +323,50 @@ public class WaveformCanvas extends Canvas implements IWaveformZoom{
|
|||||||
* range, it will correct it. This function considers only following factors
|
* range, it will correct it. This function considers only following factors
|
||||||
* :<b> transform, image size, client area</b>.
|
* :<b> transform, image size, client area</b>.
|
||||||
*/
|
*/
|
||||||
public void syncSb() {
|
public void syncScrollBars() {
|
||||||
if (!painterList.isEmpty()) {
|
if (painterList.isEmpty()) {
|
||||||
syncHSb();
|
|
||||||
syncVSb();
|
|
||||||
fireSelectionEvent();
|
|
||||||
}
|
|
||||||
redraw();
|
redraw();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void syncVSb() {
|
|
||||||
Rectangle clientArea=getClientArea();
|
|
||||||
int height = trackAreaPainter.getHeight(); // incl. Ruler
|
int height = trackAreaPainter.getHeight(); // incl. Ruler
|
||||||
int clientHeight = clientArea.height;
|
long width = maxTime / scaleFactor;
|
||||||
vertical.setIncrement(clientHeight / 100);
|
Rectangle clientArea=getClientArea();
|
||||||
vertical.setPageIncrement(clientHeight/2);
|
ScrollBar horizontal = getHorizontalBar();
|
||||||
if (height > clientHeight) { /* image is higher than client area */
|
horizontal.setIncrement(getClientArea().width / 100);
|
||||||
|
horizontal.setPageIncrement(getClientArea().width);
|
||||||
|
int clientWidthw = clientArea.width;
|
||||||
|
if (width > clientWidthw) { /* image is wider than client area */
|
||||||
|
horizontal.setMinimum(0);
|
||||||
|
horizontal.setMaximum((int)width);
|
||||||
|
horizontal.setEnabled(true);
|
||||||
|
if (-origin.x > horizontal.getMaximum() - clientWidthw) {
|
||||||
|
origin.x = -horizontal.getMaximum() + clientWidthw;
|
||||||
|
}
|
||||||
|
} else { /* image is narrower than client area */
|
||||||
|
horizontal.setEnabled(false);
|
||||||
|
}
|
||||||
|
horizontal.setThumb(clientWidthw);
|
||||||
|
horizontal.setSelection(-origin.x);
|
||||||
|
|
||||||
|
ScrollBar vertical = getVerticalBar();
|
||||||
|
vertical.setIncrement(getClientArea().height / 100);
|
||||||
|
vertical.setPageIncrement(getClientArea().height);
|
||||||
|
int clientHeighth = clientArea.height;
|
||||||
|
if (height > clientHeighth) { /* image is higher than client area */
|
||||||
vertical.setMinimum(0);
|
vertical.setMinimum(0);
|
||||||
vertical.setMaximum(height);
|
vertical.setMaximum(height);
|
||||||
vertical.setEnabled(true);
|
vertical.setEnabled(true);
|
||||||
if ( -origin.y > vertical.getMaximum() - clientHeight) {
|
if ( -origin.y > vertical.getMaximum() - clientHeighth) {
|
||||||
origin.y = -vertical.getMaximum() + clientHeight;
|
origin.y = -vertical.getMaximum() + clientHeighth;
|
||||||
}
|
}
|
||||||
} else { /* image is less higher than client area */
|
} else { /* image is less higher than client area */
|
||||||
vertical.setMaximum(clientHeight);
|
vertical.setMaximum(clientHeighth);
|
||||||
vertical.setEnabled(false);
|
vertical.setEnabled(false);
|
||||||
}
|
}
|
||||||
vertical.setThumb(clientHeight);
|
vertical.setThumb(clientHeighth);
|
||||||
vertical.setSelection(-origin.y);
|
vertical.setSelection(-origin.y);
|
||||||
}
|
redraw();
|
||||||
|
fireSelectionEvent();
|
||||||
private void syncHSb() {
|
|
||||||
horizontal.setEnabled(wave2painterMap.size()>0);
|
|
||||||
Rectangle clientArea=getClientArea();
|
|
||||||
int clientWidth = clientArea.width;
|
|
||||||
if(sliderScaleFactor>0) {
|
|
||||||
int lower = (int) ( ( -origin.x * getScale()) / sliderScaleFactor);
|
|
||||||
int upper = (int) (((clientWidth-origin.x) * getScale()) / sliderScaleFactor);
|
|
||||||
lastHorSelection = new int[] {Math.max(lower,0), Math.min(upper, horizontal.getMaximum())};
|
|
||||||
horizontal.setSelection(lastHorSelection);
|
|
||||||
}
|
|
||||||
long width = maxTime / getScale();
|
|
||||||
horizontal.setButtonsEnabled(width > clientWidth);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Paint function */
|
/* Paint function */
|
||||||
@ -429,7 +416,7 @@ public class WaveformCanvas extends Canvas implements IWaveformZoom{
|
|||||||
result.add(entry.getValue().getTrackEntry());
|
result.add(entry.getValue().getTrackEntry());
|
||||||
}
|
}
|
||||||
} else if (p instanceof CursorPainter) {
|
} else if (p instanceof CursorPainter) {
|
||||||
if (Math.abs(point.x - origin.x - ((CursorPainter) p).getTime()/getScale()) < 2) {
|
if (Math.abs(point.x - origin.x - ((CursorPainter) p).getTime()/scaleFactor) < 2) {
|
||||||
result.add(p);
|
result.add(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -457,11 +444,11 @@ public class WaveformCanvas extends Canvas implements IWaveformZoom{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void reveal(ITx tx) {
|
public void reveal(ITx tx) {
|
||||||
int lower = (int) (tx.getBeginTime() / getScale());
|
int lower = (int) (tx.getBeginTime() / scaleFactor);
|
||||||
int higher = (int) (tx.getEndTime() / getScale());
|
int higher = (int) (tx.getEndTime() / scaleFactor);
|
||||||
Point size = getSize();
|
Point size = getSize();
|
||||||
size.x -= vertical.getSize().x + 2;
|
size.x -= getVerticalBar().getSize().x + 2;
|
||||||
size.y -= horizontal.getSize().y;
|
size.y -= getHorizontalBar().getSize().y;
|
||||||
if (lower < -origin.x) {
|
if (lower < -origin.x) {
|
||||||
setOrigin(-lower, origin.y);
|
setOrigin(-lower, origin.y);
|
||||||
} else if (higher > (size.x - origin.x)) {
|
} else if (higher > (size.x - origin.x)) {
|
||||||
@ -490,8 +477,9 @@ public class WaveformCanvas extends Canvas implements IWaveformZoom{
|
|||||||
if(te.waveform == waveform) {
|
if(te.waveform == waveform) {
|
||||||
Point size = getSize();
|
Point size = getSize();
|
||||||
size.y -=+rulerHeight;
|
size.y -=+rulerHeight;
|
||||||
if((horizontal.getStyle()&SWT.SCROLLBAR_OVERLAY)!=0 && horizontal.isVisible())
|
ScrollBar sb = getHorizontalBar();
|
||||||
size.y-= horizontal.getSize().y;
|
if((sb.getStyle()&SWT.SCROLLBAR_OVERLAY)!=0 && sb.isVisible())
|
||||||
|
size.y-= getHorizontalBar().getSize().y;
|
||||||
int top = te.vOffset;
|
int top = te.vOffset;
|
||||||
int bottom = top + styleProvider.getTrackHeight();
|
int bottom = top + styleProvider.getTrackHeight();
|
||||||
if (top < -origin.y) {
|
if (top < -origin.y) {
|
||||||
@ -504,10 +492,10 @@ public class WaveformCanvas extends Canvas implements IWaveformZoom{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void reveal(long time) {
|
public void reveal(long time) {
|
||||||
int scaledTime = (int) (time / getScale());
|
int scaledTime = (int) (time / scaleFactor);
|
||||||
Point size = getSize();
|
Point size = getSize();
|
||||||
size.x -= vertical.getSize().x + 2;
|
size.x -= getVerticalBar().getSize().x + 2;
|
||||||
size.y -= horizontal.getSize().y;
|
size.y -= getHorizontalBar().getSize().y;
|
||||||
if (scaledTime < -origin.x) {
|
if (scaledTime < -origin.x) {
|
||||||
setOrigin(-scaledTime+10, origin.y);
|
setOrigin(-scaledTime+10, origin.y);
|
||||||
} else if (scaledTime > (size.x - origin.x)) {
|
} else if (scaledTime > (size.x - origin.x)) {
|
||||||
@ -515,9 +503,8 @@ public class WaveformCanvas extends Canvas implements IWaveformZoom{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void centerAt(long time) {
|
public void centerAt(long time) {
|
||||||
int scaledTime = (int) (time / getScale());
|
int scaledTime = (int) (time / scaleFactor);
|
||||||
int newX = -scaledTime+getWidth()/2;
|
int newX = -scaledTime+getWidth()/2;
|
||||||
setOrigin(newX>0?0:newX, origin.y);
|
setOrigin(newX>0?0:newX, origin.y);
|
||||||
}
|
}
|
||||||
@ -554,55 +541,16 @@ public class WaveformCanvas extends Canvas implements IWaveformZoom{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long getMaxVisibleTime() {
|
||||||
@Override
|
return (getClientArea().width+origin.x)*scaleFactor;
|
||||||
public long getMaxVisibleTime() {
|
|
||||||
return (getClientArea().width-origin.x)*getScale();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
long getMinVisibleTime() {
|
||||||
public long getMinVisibleTime() {
|
return origin.x * scaleFactor;
|
||||||
return -origin.x * getScale();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setMinVisibleTime(long time) {
|
|
||||||
long duration = getMaxVisibleTime()-getMinVisibleTime();
|
|
||||||
if(time>0) {
|
|
||||||
if((time+duration)<getMaxTime()) {
|
|
||||||
int scaledTime = (int) (time / getScale());
|
|
||||||
setOrigin(-scaledTime, origin.y);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
setOrigin(0, origin.y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void zoom(ZoomKind kind) {
|
|
||||||
switch(kind) {
|
|
||||||
case IN:
|
|
||||||
setScale(getScale()/2);
|
|
||||||
break;
|
|
||||||
case OUT:
|
|
||||||
setScale(getScale()*2);
|
|
||||||
break;
|
|
||||||
case FIT:
|
|
||||||
setScalingFactor(WaveformCanvas.ZOOM_FIT, cursorPainters.get(1).getTime());
|
|
||||||
break;
|
|
||||||
case FULL:
|
|
||||||
setScale(WaveformCanvas.ZOOM_FULL);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStyleProvider(IWaveformStyleProvider styleProvider) {
|
public void setStyleProvider(IWaveformStyleProvider styleProvider) {
|
||||||
this.styleProvider=styleProvider;
|
this.styleProvider=styleProvider;
|
||||||
redraw();
|
redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getScaleMagnitude() {
|
|
||||||
return scaleMagnitude;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -89,9 +89,8 @@ import com.minres.scviewer.database.ui.GotoDirection;
|
|||||||
import com.minres.scviewer.database.ui.ICursor;
|
import com.minres.scviewer.database.ui.ICursor;
|
||||||
import com.minres.scviewer.database.ui.IWaveformStyleProvider;
|
import com.minres.scviewer.database.ui.IWaveformStyleProvider;
|
||||||
import com.minres.scviewer.database.ui.IWaveformView;
|
import com.minres.scviewer.database.ui.IWaveformView;
|
||||||
import com.minres.scviewer.database.ui.IWaveformZoom;
|
|
||||||
import com.minres.scviewer.database.ui.TrackEntry;
|
import com.minres.scviewer.database.ui.TrackEntry;
|
||||||
import com.minres.scviewer.database.ui.swt.internal.slider.ZoomBar;
|
import com.minres.scviewer.database.ui.swt.Constants;
|
||||||
|
|
||||||
public class WaveformView implements IWaveformView {
|
public class WaveformView implements IWaveformView {
|
||||||
|
|
||||||
@ -113,10 +112,6 @@ public class WaveformView implements IWaveformView {
|
|||||||
|
|
||||||
private final Canvas valueList;
|
private final Canvas valueList;
|
||||||
|
|
||||||
private final Control nameFill;
|
|
||||||
|
|
||||||
private final Control valueFill;
|
|
||||||
|
|
||||||
final WaveformCanvas waveformCanvas;
|
final WaveformCanvas waveformCanvas;
|
||||||
|
|
||||||
final ToolTipHandler toolTipHandler;
|
final ToolTipHandler toolTipHandler;
|
||||||
@ -127,6 +122,12 @@ public class WaveformView implements IWaveformView {
|
|||||||
|
|
||||||
protected ObservableList<TrackEntry> streams;
|
protected ObservableList<TrackEntry> streams;
|
||||||
|
|
||||||
|
private boolean waveformsContainTx=false;
|
||||||
|
|
||||||
|
public boolean isWaveformsContainTx() {
|
||||||
|
return waveformsContainTx;
|
||||||
|
}
|
||||||
|
|
||||||
int selectedMarker = 0;
|
int selectedMarker = 0;
|
||||||
|
|
||||||
private int tracksVerticalHeight;
|
private int tracksVerticalHeight;
|
||||||
@ -165,7 +166,8 @@ public class WaveformView implements IWaveformView {
|
|||||||
: streams.subList(firstIdx, lastIdx + 1);
|
: streams.subList(firstIdx, lastIdx + 1);
|
||||||
setSelection(new StructuredSelection(res), (e.stateMask & SWT.CTRL) != 0, false);
|
setSelection(new StructuredSelection(res), (e.stateMask & SWT.CTRL) != 0, false);
|
||||||
} else
|
} else
|
||||||
setSelection(new StructuredSelection(entry.getValue()), (e.stateMask & SWT.CTRL) != 0, false);
|
setSelection(new StructuredSelection(entry.getValue()), (e.stateMask & SWT.CTRL) != 0,
|
||||||
|
false);
|
||||||
} else {
|
} else {
|
||||||
setSelection(new StructuredSelection(entry.getValue()), (e.stateMask & SWT.CTRL) != 0, false);
|
setSelection(new StructuredSelection(entry.getValue()), (e.stateMask & SWT.CTRL) != 0, false);
|
||||||
}
|
}
|
||||||
@ -207,17 +209,41 @@ public class WaveformView implements IWaveformView {
|
|||||||
asyncUpdate(e.widget);
|
asyncUpdate(e.widget);
|
||||||
long startTime = waveformCanvas.getTimeForOffset(start.x);
|
long startTime = waveformCanvas.getTimeForOffset(start.x);
|
||||||
long endTime = waveformCanvas.getTimeForOffset(end.x);
|
long endTime = waveformCanvas.getTimeForOffset(end.x);
|
||||||
if(startTime<endTime) {
|
long targetTimeRange = endTime - startTime;
|
||||||
waveformCanvas.setVisibleRange(startTime, endTime);
|
|
||||||
} else if(start.x!=end.x){
|
|
||||||
long targetTimeRange = startTime-endTime;
|
|
||||||
long currentTimeRange = waveformCanvas.getMaxVisibleTime() - waveformCanvas.getMinVisibleTime();
|
long currentTimeRange = waveformCanvas.getMaxVisibleTime() - waveformCanvas.getMinVisibleTime();
|
||||||
long factor = currentTimeRange/targetTimeRange *waveformCanvas.getScale();
|
if (targetTimeRange == 0)
|
||||||
waveformCanvas.setScalingFactor(factor, (startTime+endTime)/2);
|
return;
|
||||||
|
long relation = currentTimeRange / targetTimeRange;
|
||||||
|
long i = 1;
|
||||||
|
int level = 0;
|
||||||
|
do {
|
||||||
|
if (relation < 0) {
|
||||||
|
if (-relation < i) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
level--;
|
||||||
|
if (-relation < i * 3) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
level--;
|
||||||
|
} else {
|
||||||
|
if (relation < i) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
level++;
|
||||||
|
if (relation < i * 3) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
level++;
|
||||||
|
}
|
||||||
|
i = i * 10;
|
||||||
|
} while (i < 10000);
|
||||||
|
if (i < 10000) {
|
||||||
|
int curLevel = waveformCanvas.getZoomLevel();
|
||||||
|
waveformCanvas.setZoomLevel(curLevel - level, (startTime + endTime) / 2);
|
||||||
}
|
}
|
||||||
} else if( isShift) { // set marker (button 1 and shift)
|
} else if( isShift) { // set marker (button 1 and shift)
|
||||||
setMarkerTime(selectedMarker, snapOffsetToEvent(start));
|
setMarkerTime(snapOffsetToEvent(start), selectedMarker);
|
||||||
} else if(isCtrl) { // set cursor (button 1 and ctrl)
|
} else if(isCtrl) { // set cursor (button 1 and ctrl)
|
||||||
setCursorTime(snapOffsetToEvent(start));
|
setCursorTime(snapOffsetToEvent(start));
|
||||||
} else { // set cursor (button 1 only)
|
} else { // set cursor (button 1 only)
|
||||||
@ -229,14 +255,14 @@ public class WaveformView implements IWaveformView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (e.button == 2) { // set marker (button 2)
|
} else if (e.button == 2) { // set marker (button 2)
|
||||||
setMarkerTime(selectedMarker, snapOffsetToEvent(start));
|
setMarkerTime(snapOffsetToEvent(start), selectedMarker);
|
||||||
}
|
}
|
||||||
asyncUpdate(e.widget);
|
asyncUpdate(e.widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected long snapOffsetToEvent(Point p) {
|
protected long snapOffsetToEvent(Point p) {
|
||||||
long time = waveformCanvas.getTimeForOffset(p.x);
|
long time = waveformCanvas.getTimeForOffset(p.x);
|
||||||
long scaling = 5 * waveformCanvas.getScale();
|
long scaling = 5 * waveformCanvas.getScaleFactor();
|
||||||
for (Object o : waveformCanvas.getElementsAt(p)) {
|
for (Object o : waveformCanvas.getElementsAt(p)) {
|
||||||
EventEntry floorEntry = null;
|
EventEntry floorEntry = null;
|
||||||
EventEntry ceilEntry = null;
|
EventEntry ceilEntry = null;
|
||||||
@ -269,27 +295,8 @@ public class WaveformView implements IWaveformView {
|
|||||||
@Override
|
@Override
|
||||||
public void handleEvent(Event e) {
|
public void handleEvent(Event e) {
|
||||||
switch (e.type) {
|
switch (e.type) {
|
||||||
case SWT.MouseWheel:
|
// case SWT.MouseWheel:
|
||||||
if((e.stateMask & SWT.CTRL) != 0) {
|
// break;
|
||||||
if(e.count<0) // up scroll
|
|
||||||
waveformCanvas.setScale(waveformCanvas.getScale()*11/10);
|
|
||||||
else // down scroll
|
|
||||||
waveformCanvas.setScale(waveformCanvas.getScale()*10/11);
|
|
||||||
e.doit=false;
|
|
||||||
} else if((e.stateMask & SWT.SHIFT) != 0) {
|
|
||||||
long upper = waveformCanvas.getMaxVisibleTime();
|
|
||||||
long lower = waveformCanvas.getMinVisibleTime();
|
|
||||||
long duration = upper-lower;
|
|
||||||
if(e.count<0) { // up scroll
|
|
||||||
long newLower = Math.min(waveformCanvas.getMaxTime()-duration, lower+duration/10);
|
|
||||||
waveformCanvas.setMinVisibleTime(newLower);
|
|
||||||
} else {// down scroll
|
|
||||||
long newLower = Math.max(0, lower-duration/10);
|
|
||||||
waveformCanvas.setMinVisibleTime(newLower);
|
|
||||||
}
|
|
||||||
e.doit=false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SWT.MouseDown:
|
case SWT.MouseDown:
|
||||||
start = new Point(e.x, e.y);
|
start = new Point(e.x, e.y);
|
||||||
end = new Point(e.x, e.y);
|
end = new Point(e.x, e.y);
|
||||||
@ -348,25 +355,7 @@ public class WaveformView implements IWaveformView {
|
|||||||
rightSash.setBackground(SWTResourceManager.getColor(SWT.COLOR_GRAY));
|
rightSash.setBackground(SWTResourceManager.getColor(SWT.COLOR_GRAY));
|
||||||
|
|
||||||
Composite valuePane = new Composite(rightSash, SWT.NONE);
|
Composite valuePane = new Composite(rightSash, SWT.NONE);
|
||||||
|
waveformCanvas = new WaveformCanvas(rightSash, SWT.NONE, styleProvider);
|
||||||
Composite waveformPane = new Composite(rightSash, SWT.NONE);
|
|
||||||
GridLayout gl_waveformPane = new GridLayout(1, false);
|
|
||||||
gl_waveformPane.verticalSpacing = 0;
|
|
||||||
gl_waveformPane.marginWidth = 0;
|
|
||||||
gl_waveformPane.marginHeight = 0;
|
|
||||||
waveformPane.setLayout(gl_waveformPane);
|
|
||||||
|
|
||||||
waveformCanvas = new WaveformCanvas(waveformPane, SWT.NONE | SWT.V_SCROLL /*| SWT.H_SCROLL*/, styleProvider, new ZoomBar.IProvider() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ZoomBar getScrollBar() {
|
|
||||||
ZoomBar timeSliderPane = new ZoomBar(waveformPane, SWT.NONE);
|
|
||||||
GridData gd_timeSliderPane = new GridData(SWT.FILL, SWT.BOTTOM, false, false, 1, 1);
|
|
||||||
timeSliderPane.setLayoutData(gd_timeSliderPane);
|
|
||||||
return timeSliderPane;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
waveformCanvas.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
|
|
||||||
|
|
||||||
// create the name pane
|
// create the name pane
|
||||||
createTextPane(namePane, "Name");
|
createTextPane(namePane, "Name");
|
||||||
@ -383,10 +372,7 @@ public class WaveformView implements IWaveformView {
|
|||||||
@Override
|
@Override
|
||||||
public void controlResized(ControlEvent e) {
|
public void controlResized(ControlEvent e) {
|
||||||
nameListScrolled.getVerticalBar().setVisible(false);
|
nameListScrolled.getVerticalBar().setVisible(false);
|
||||||
if(nameListScrolled.getSize().y == nameList.getSize().y) {
|
|
||||||
((GridData)nameFill.getLayoutData()).heightHint=18;
|
|
||||||
namePane.layout();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
nameList = new Canvas(nameListScrolled, SWT.NONE) {
|
nameList = new Canvas(nameListScrolled, SWT.NONE) {
|
||||||
@ -405,7 +391,6 @@ public class WaveformView implements IWaveformView {
|
|||||||
});
|
});
|
||||||
nameList.addMouseListener(nameValueMouseListener);
|
nameList.addMouseListener(nameValueMouseListener);
|
||||||
nameListScrolled.setContent(nameList);
|
nameListScrolled.setContent(nameList);
|
||||||
nameFill = createFill(namePane);
|
|
||||||
|
|
||||||
createTextPane(valuePane, "Value");
|
createTextPane(valuePane, "Value");
|
||||||
|
|
||||||
@ -419,10 +404,7 @@ public class WaveformView implements IWaveformView {
|
|||||||
@Override
|
@Override
|
||||||
public void controlResized(ControlEvent e) {
|
public void controlResized(ControlEvent e) {
|
||||||
valueListScrolled.getVerticalBar().setVisible(false);
|
valueListScrolled.getVerticalBar().setVisible(false);
|
||||||
if(valueListScrolled.getSize().y == valueList.getSize().y) {
|
|
||||||
((GridData)valueFill.getLayoutData()).heightHint=18;
|
|
||||||
valuePane.layout();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
valueList = new Canvas(valueListScrolled, SWT.NONE) {
|
valueList = new Canvas(valueListScrolled, SWT.NONE) {
|
||||||
@ -441,7 +423,6 @@ public class WaveformView implements IWaveformView {
|
|||||||
});
|
});
|
||||||
valueList.addMouseListener(nameValueMouseListener);
|
valueList.addMouseListener(nameValueMouseListener);
|
||||||
valueListScrolled.setContent(valueList);
|
valueListScrolled.setContent(valueList);
|
||||||
valueFill = createFill(valuePane);
|
|
||||||
|
|
||||||
waveformCanvas.setMaxTime(1);
|
waveformCanvas.setMaxTime(1);
|
||||||
waveformCanvas.addPaintListener(waveformMouseListener);
|
waveformCanvas.addPaintListener(waveformMouseListener);
|
||||||
@ -488,26 +469,6 @@ public class WaveformView implements IWaveformView {
|
|||||||
|
|
||||||
toolTipHandler = new ToolTipHandler(parent.getShell());
|
toolTipHandler = new ToolTipHandler(parent.getShell());
|
||||||
toolTipHandler.activateHoverHelp(waveformCanvas);
|
toolTipHandler.activateHoverHelp(waveformCanvas);
|
||||||
// This is the filter that prevents the default handling of mouse wheel in waveformCanvas
|
|
||||||
getControl().getDisplay().addFilter(SWT.MouseWheel, new Listener() {
|
|
||||||
@Override
|
|
||||||
public void handleEvent(Event e) {
|
|
||||||
// Check if it's the correct widget
|
|
||||||
if(e.widget.equals(waveformCanvas) && (e.stateMask & SWT.CTRL) != 0) {
|
|
||||||
waveformMouseListener.handleEvent(e);
|
|
||||||
e.doit = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private Control createFill(Composite pane) {
|
|
||||||
Label cLabel = new Label(pane, SWT.NONE);
|
|
||||||
cLabel.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND));
|
|
||||||
GridData gd_cLabel = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
|
|
||||||
gd_cLabel.heightHint = 0;
|
|
||||||
cLabel.setLayoutData(gd_cLabel);
|
|
||||||
return cLabel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createTextPane(Composite namePane, String text) {
|
private void createTextPane(Composite namePane, String text) {
|
||||||
@ -557,6 +518,7 @@ public class WaveformView implements IWaveformView {
|
|||||||
boolean even = true;
|
boolean even = true;
|
||||||
TextLayout tl = new TextLayout(waveformCanvas.getDisplay());
|
TextLayout tl = new TextLayout(waveformCanvas.getDisplay());
|
||||||
tl.setFont(styleProvider.getNameFont());
|
tl.setFont(styleProvider.getNameFont());
|
||||||
|
waveformsContainTx=false;
|
||||||
for (TrackEntry streamEntry : streams) {
|
for (TrackEntry streamEntry : streams) {
|
||||||
streamEntry.height = styleProvider.getTrackHeight();
|
streamEntry.height = styleProvider.getTrackHeight();
|
||||||
streamEntry.vOffset = tracksVerticalHeight;
|
streamEntry.vOffset = tracksVerticalHeight;
|
||||||
@ -564,6 +526,7 @@ public class WaveformView implements IWaveformView {
|
|||||||
streamEntry.currentValue = "";
|
streamEntry.currentValue = "";
|
||||||
streamEntry.height *= streamEntry.waveform.getRowCount();
|
streamEntry.height *= streamEntry.waveform.getRowCount();
|
||||||
painter = new StreamPainter(waveformCanvas, even, streamEntry);
|
painter = new StreamPainter(waveformCanvas, even, streamEntry);
|
||||||
|
waveformsContainTx=true;
|
||||||
} else if (streamEntry.waveform.getType() == WaveformType.SIGNAL) {
|
} else if (streamEntry.waveform.getType() == WaveformType.SIGNAL) {
|
||||||
streamEntry.currentValue = "---";
|
streamEntry.currentValue = "---";
|
||||||
painter = new SignalPainter(waveformCanvas, even, streamEntry);
|
painter = new SignalPainter(waveformCanvas, even, streamEntry);
|
||||||
@ -575,7 +538,7 @@ public class WaveformView implements IWaveformView {
|
|||||||
tracksVerticalHeight += streamEntry.height;
|
tracksVerticalHeight += streamEntry.height;
|
||||||
even = !even;
|
even = !even;
|
||||||
}
|
}
|
||||||
waveformCanvas.syncSb();
|
waveformCanvas.syncScrollBars();
|
||||||
nameList.setSize(nameMaxWidth + 15, tracksVerticalHeight);
|
nameList.setSize(nameMaxWidth + 15, tracksVerticalHeight);
|
||||||
nameListScrolled.setMinSize(nameMaxWidth + 15, tracksVerticalHeight);
|
nameListScrolled.setMinSize(nameMaxWidth + 15, tracksVerticalHeight);
|
||||||
nameList.redraw();
|
nameList.redraw();
|
||||||
@ -799,9 +762,8 @@ public class WaveformView implements IWaveformView {
|
|||||||
if (!add)
|
if (!add)
|
||||||
currentWaveformSelection.clear();
|
currentWaveformSelection.clear();
|
||||||
List<?> selList = sel.toList();
|
List<?> selList = sel.toList();
|
||||||
for(Object o: selList) {
|
if (selList.get(0) instanceof ITx) {
|
||||||
if (o instanceof ITx) {
|
ITx txSel = (ITx) selList.get(0);
|
||||||
ITx txSel = (ITx) o;
|
|
||||||
TrackEntry trackEntry = selList.size() == 2 && selList.get(1) instanceof TrackEntry
|
TrackEntry trackEntry = selList.size() == 2 && selList.get(1) instanceof TrackEntry
|
||||||
? (TrackEntry) selList.get(1)
|
? (TrackEntry) selList.get(1)
|
||||||
: null;
|
: null;
|
||||||
@ -816,14 +778,12 @@ public class WaveformView implements IWaveformView {
|
|||||||
currentWaveformSelection.clear();
|
currentWaveformSelection.clear();
|
||||||
currentWaveformSelection.add(trackEntry);
|
currentWaveformSelection.add(trackEntry);
|
||||||
selectionChanged = true;
|
selectionChanged = true;
|
||||||
} else if (o instanceof TrackEntry) {
|
} else if (selList.size() == 1 && selList.get(0) instanceof TrackEntry) {
|
||||||
TrackEntry e = (TrackEntry)o;
|
currentWaveformSelection.add((TrackEntry) selList.get(0));
|
||||||
if(!currentWaveformSelection.contains(e))
|
if (currentTxSelection != null)
|
||||||
currentWaveformSelection.add(e);
|
currentTxSelection = null;
|
||||||
selectionChanged = true;
|
selectionChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (currentTxSelection != null || !currentWaveformSelection.isEmpty())
|
if (currentTxSelection != null || !currentWaveformSelection.isEmpty())
|
||||||
@ -1165,6 +1125,16 @@ public class WaveformView implements IWaveformView {
|
|||||||
this.waveformCanvas.setHighliteRelation(relationType);
|
this.waveformCanvas.setHighliteRelation(relationType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see com.minres.scviewer.database.swt.IWaveformPanel#getMaxTime()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public long getMaxTime() {
|
||||||
|
return waveformCanvas.getMaxTime();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
@ -1175,6 +1145,31 @@ public class WaveformView implements IWaveformView {
|
|||||||
this.waveformCanvas.setMaxTime(maxTime);
|
this.waveformCanvas.setMaxTime(maxTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see com.minres.scviewer.database.swt.IWaveformPanel#setZoomLevel(int)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setZoomLevel(int scale) {
|
||||||
|
if(scale<-1) {
|
||||||
|
waveformCanvas.setZoomLevel(scale, getMarkerTime(selectedMarker));
|
||||||
|
} else {
|
||||||
|
waveformCanvas.setZoomLevel(scale);
|
||||||
|
waveformCanvas.reveal(getCursorTime());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see com.minres.scviewer.database.swt.IWaveformPanel#getZoomLevel()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int getZoomLevel() {
|
||||||
|
return waveformCanvas.getZoomLevel();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
@ -1193,10 +1188,10 @@ public class WaveformView implements IWaveformView {
|
|||||||
* @see com.minres.scviewer.database.swt.IWaveformPanel#setMarkerTime(long, int)
|
* @see com.minres.scviewer.database.swt.IWaveformPanel#setMarkerTime(long, int)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setMarkerTime(int marker, long time) {
|
public void setMarkerTime(long time, int index) {
|
||||||
if (waveformCanvas.getCursorPainters().size() > marker + 1) {
|
if (waveformCanvas.getCursorPainters().size() > index + 1) {
|
||||||
final Long oldVal = waveformCanvas.getCursorPainters().get(1 + marker).getTime();
|
final Long oldVal = waveformCanvas.getCursorPainters().get(1 + index).getTime();
|
||||||
waveformCanvas.getCursorPainters().get(1 + marker).setTime(time);
|
waveformCanvas.getCursorPainters().get(1 + index).setTime(time);
|
||||||
pcs.firePropertyChange(MARKER_PROPERTY, oldVal, time);
|
pcs.firePropertyChange(MARKER_PROPERTY, oldVal, time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1217,7 +1212,7 @@ public class WaveformView implements IWaveformView {
|
|||||||
* @see com.minres.scviewer.database.swt.IWaveformPanel#getActMarkerTime()
|
* @see com.minres.scviewer.database.swt.IWaveformPanel#getActMarkerTime()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getSelectedMarker() {
|
public int getSelectedMarkerId() {
|
||||||
return selectedMarker;
|
return selectedMarker;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1469,16 +1464,58 @@ public class WaveformView implements IWaveformView {
|
|||||||
return this.pcs.hasListeners(propertyName);
|
return this.pcs.hasListeners(propertyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see com.minres.scviewer.database.swt.IWaveformPanel#getScaledTime(long)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getScaledTime(long time) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
double dTime = time;
|
||||||
|
double scaledTime = dTime / waveformCanvas.getScaleFactorPow10();
|
||||||
|
return sb.append(Constants.getTimeFormatForLevel(waveformCanvas.getZoomLevel()).format(scaledTime)).append(waveformCanvas.getUnitStr()).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see com.minres.scviewer.database.swt.IWaveformPanel#getZoomLevels()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String[] getZoomLevels() {
|
||||||
|
String[] res = new String[Constants.SCALE_MULTIPLIER.length * Constants.UNIT_STRING.length];
|
||||||
|
int index = 0;
|
||||||
|
for (String unit : Constants.UNIT_STRING) {
|
||||||
|
for (long factor : Constants.SCALE_MULTIPLIER) {
|
||||||
|
res[index++] = Long.toString(factor) + unit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getBaselineTime() {
|
||||||
|
return -waveformCanvas.getScaleFactorPow10() * waveformCanvas.getOrigin().x;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBaselineTime(Long time) {
|
||||||
|
Point origin = waveformCanvas.getOrigin();
|
||||||
|
origin.x = (int) (-time / waveformCanvas.getScaleFactorPow10());
|
||||||
|
waveformCanvas.setOrigin(origin);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void scrollHorizontal(int percent) {
|
public void scrollHorizontal(int percent) {
|
||||||
if (percent < -100)
|
if (percent < -100)
|
||||||
percent = -100;
|
percent = -100;
|
||||||
if (percent > 100)
|
if (percent > 100)
|
||||||
percent = 100;
|
percent = 100;
|
||||||
long minTime = waveformCanvas.getMinVisibleTime();
|
int diff = (waveformCanvas.getWidth() * percent) / 100;
|
||||||
long duration = waveformCanvas.getMaxVisibleTime()-minTime;
|
Point o = waveformCanvas.getOrigin();
|
||||||
long diff = (duration * percent) / 100;
|
waveformCanvas.setOrigin(o.x - diff, o.y);
|
||||||
waveformCanvas.setMinVisibleTime(minTime+diff);
|
waveformCanvas.redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1526,13 +1563,4 @@ public class WaveformView implements IWaveformView {
|
|||||||
getStreamList().add(idx, e);
|
getStreamList().add(idx, e);
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean waveformsContainsTx() {
|
|
||||||
return streams.stream().filter(e -> e.waveform.getType() == WaveformType.TRANSACTION).findFirst().isPresent();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IWaveformZoom getWaveformZoom() {
|
|
||||||
return waveformCanvas;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
package com.minres.scviewer.database.ui.swt.internal.slider;
|
|
||||||
|
|
||||||
import org.eclipse.swt.widgets.Display;
|
|
||||||
|
|
||||||
public class ActionTimer implements Runnable {
|
|
||||||
|
|
||||||
public static final int INITIAL_DELAY = 300;
|
|
||||||
public static final int FAST_DELAY = 50;
|
|
||||||
|
|
||||||
private final Display display;
|
|
||||||
private final TimerAction timerAction;
|
|
||||||
|
|
||||||
public interface TimerAction extends Runnable {
|
|
||||||
boolean isEnabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ActionTimer( TimerAction timerAction, Display display ) {
|
|
||||||
this.display = display;
|
|
||||||
this.timerAction = timerAction;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void activate() {
|
|
||||||
if( timerAction.isEnabled() ) {
|
|
||||||
display.timerExec( INITIAL_DELAY, this );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if( timerAction.isEnabled() ) {
|
|
||||||
timerAction.run();
|
|
||||||
display.timerExec( FAST_DELAY, this );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,192 +0,0 @@
|
|||||||
package com.minres.scviewer.database.ui.swt.internal.slider;
|
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.SWTException;
|
|
||||||
import org.eclipse.swt.events.MouseAdapter;
|
|
||||||
import org.eclipse.swt.events.MouseEvent;
|
|
||||||
import org.eclipse.swt.events.MouseTrackAdapter;
|
|
||||||
import org.eclipse.swt.events.SelectionListener;
|
|
||||||
import org.eclipse.swt.graphics.GC;
|
|
||||||
import org.eclipse.swt.graphics.Image;
|
|
||||||
import org.eclipse.swt.graphics.Point;
|
|
||||||
import org.eclipse.swt.widgets.Composite;
|
|
||||||
import org.eclipse.swt.widgets.Display;
|
|
||||||
import org.eclipse.swt.widgets.Event;
|
|
||||||
|
|
||||||
public class ImageButton extends Composite
|
|
||||||
{
|
|
||||||
private Image hoverImage;
|
|
||||||
private Image normalImage;
|
|
||||||
private Image pressedImage;
|
|
||||||
private Image disabledImage;
|
|
||||||
private int width;
|
|
||||||
private int height;
|
|
||||||
private boolean hover;
|
|
||||||
private boolean pressed;
|
|
||||||
private boolean autoFire;
|
|
||||||
private ActionTimer actionTimer;
|
|
||||||
private ActionTimer.TimerAction timerAction;
|
|
||||||
|
|
||||||
public ImageButton(Composite parent, int style) {
|
|
||||||
super(parent, style);
|
|
||||||
timerAction = new ActionTimer.TimerAction() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public boolean isEnabled() {
|
|
||||||
return pressed;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
actionTimer = new ActionTimer(timerAction, this.getDisplay() );
|
|
||||||
addListener(SWT.Dispose, event -> {
|
|
||||||
if (hoverImage != null) hoverImage.dispose();
|
|
||||||
if (normalImage != null) normalImage.dispose();
|
|
||||||
if (pressedImage != null) pressedImage.dispose();
|
|
||||||
if (disabledImage != null) disabledImage.dispose();
|
|
||||||
});
|
|
||||||
addListener(SWT.Paint, event -> {
|
|
||||||
paintControl(event);
|
|
||||||
});
|
|
||||||
addMouseTrackListener(new MouseTrackAdapter() {
|
|
||||||
public void mouseEnter(MouseEvent arg0) {
|
|
||||||
if(isEnabled()) {
|
|
||||||
hover=true;
|
|
||||||
redraw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void mouseExit(MouseEvent arg0) {
|
|
||||||
if(isEnabled()) {
|
|
||||||
hover=false;
|
|
||||||
redraw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
addMouseListener(new MouseAdapter() {
|
|
||||||
@Override
|
|
||||||
public void mouseDown(MouseEvent e) {
|
|
||||||
if(isEnabled()) {
|
|
||||||
pressed=true;
|
|
||||||
notifyListeners();
|
|
||||||
if(autoFire) actionTimer.activate();
|
|
||||||
redraw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseUp(MouseEvent e) {
|
|
||||||
pressed=false;
|
|
||||||
redraw();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void paintControl(Event event) {
|
|
||||||
GC gc = event.gc;
|
|
||||||
if (hoverImage != null) {
|
|
||||||
if(pressed)
|
|
||||||
gc.drawImage(pressedImage, 1, 1);
|
|
||||||
else if(hover) {
|
|
||||||
gc.drawImage(hoverImage, 1, 1);
|
|
||||||
} else if(isEnabled()){
|
|
||||||
gc.drawImage(normalImage, 1, 1);
|
|
||||||
} else
|
|
||||||
gc.drawImage(disabledImage, 1, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setImage(Image[] imgs) {
|
|
||||||
assert(imgs.length==3);
|
|
||||||
Display d = Display.getDefault();
|
|
||||||
normalImage = new Image(d, imgs[0], SWT.IMAGE_COPY);
|
|
||||||
hoverImage = new Image(d, imgs[1], SWT.IMAGE_COPY);
|
|
||||||
pressedImage = new Image(d, imgs[2], SWT.IMAGE_COPY);
|
|
||||||
disabledImage = new Image(d, imgs[0], SWT.IMAGE_DISABLE);
|
|
||||||
width = imgs[0].getBounds().width;
|
|
||||||
height = imgs[0].getBounds().height;
|
|
||||||
redraw();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Point computeSize(int wHint, int hHint, boolean changed) {
|
|
||||||
int overallWidth = width;
|
|
||||||
int overallHeight = height;
|
|
||||||
if (wHint != SWT.DEFAULT && wHint < overallWidth)
|
|
||||||
overallWidth = wHint;
|
|
||||||
if (hHint != SWT.DEFAULT && hHint < overallHeight)
|
|
||||||
overallHeight = hHint;
|
|
||||||
return new Point(overallWidth + 2, overallHeight + 2);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Adds the listener to the collection of listeners who will be notified when
|
|
||||||
* the user changes the receiver's value, by sending it one of the messages
|
|
||||||
* defined in the <code>SelectionListener</code> interface.
|
|
||||||
* <p>
|
|
||||||
* <code>widgetSelected</code> is called when the user changes the receiver's
|
|
||||||
* value. <code>widgetDefaultSelected</code> is not called.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param listener the listener which should be notified
|
|
||||||
*
|
|
||||||
* @exception IllegalArgumentException
|
|
||||||
* <ul>
|
|
||||||
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
|
|
||||||
* </ul>
|
|
||||||
* @exception SWTException
|
|
||||||
* <ul>
|
|
||||||
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been
|
|
||||||
* disposed</li>
|
|
||||||
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
|
|
||||||
* thread that created the receiver</li>
|
|
||||||
* </ul>
|
|
||||||
*
|
|
||||||
* @see SelectionListener
|
|
||||||
* @see #removeSelectionListener
|
|
||||||
*/
|
|
||||||
public void addSelectionListener(final SelectionListener listener) {
|
|
||||||
checkWidget();
|
|
||||||
SelectionListenerUtil.addSelectionListener(this, listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the listener from the collection of listeners who will be notified
|
|
||||||
* when the user changes the receiver's value.
|
|
||||||
*
|
|
||||||
* @param listener the listener which should no longer be notified
|
|
||||||
*
|
|
||||||
* @exception IllegalArgumentException
|
|
||||||
* <ul>
|
|
||||||
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
|
|
||||||
* </ul>
|
|
||||||
* @exception SWTException
|
|
||||||
* <ul>
|
|
||||||
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been
|
|
||||||
* disposed</li>
|
|
||||||
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
|
|
||||||
* thread that created the receiver</li>
|
|
||||||
* </ul>
|
|
||||||
*
|
|
||||||
* @see SelectionListener
|
|
||||||
* @see #addSelectionListener
|
|
||||||
*/
|
|
||||||
public void removeSelectionListener(final SelectionListener listener) {
|
|
||||||
checkWidget();
|
|
||||||
SelectionListenerUtil.removeSelectionListener(this, listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void notifyListeners() {
|
|
||||||
Event e = new Event();
|
|
||||||
e.widget=this;
|
|
||||||
e.type=SWT.Selection;
|
|
||||||
SelectionListenerUtil.fireSelectionListeners(this,e);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAutoFire() {
|
|
||||||
return autoFire;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAutoFire(boolean autoFire) {
|
|
||||||
this.autoFire = autoFire;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,631 +0,0 @@
|
|||||||
package com.minres.scviewer.database.ui.swt.internal.slider;
|
|
||||||
|
|
||||||
import java.text.Format;
|
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.events.MouseEvent;
|
|
||||||
import org.eclipse.swt.events.MouseTrackAdapter;
|
|
||||||
import org.eclipse.swt.events.PaintEvent;
|
|
||||||
import org.eclipse.swt.events.SelectionListener;
|
|
||||||
import org.eclipse.swt.graphics.GC;
|
|
||||||
import org.eclipse.swt.graphics.Image;
|
|
||||||
import org.eclipse.swt.graphics.Point;
|
|
||||||
import org.eclipse.swt.graphics.Rectangle;
|
|
||||||
import org.eclipse.swt.widgets.Canvas;
|
|
||||||
import org.eclipse.swt.widgets.Composite;
|
|
||||||
import org.eclipse.swt.widgets.Event;
|
|
||||||
import org.eclipse.wb.swt.SWTResourceManager;
|
|
||||||
|
|
||||||
public class RangeSlider extends Canvas {
|
|
||||||
|
|
||||||
private static final int NONE = 0;
|
|
||||||
private static final int UPPER = 1 << 0;
|
|
||||||
private static final int LOWER = 1 << 1;
|
|
||||||
private static final int BOTH = UPPER | LOWER;
|
|
||||||
|
|
||||||
private final int minHeight;
|
|
||||||
private final int markerWidth;
|
|
||||||
private final int thumbWidth = 0;
|
|
||||||
private final Image[] slider, sliderHover, sliderDrag;
|
|
||||||
|
|
||||||
private int minimum;
|
|
||||||
private int maximum;
|
|
||||||
private int lowerValue;
|
|
||||||
private int upperValue;
|
|
||||||
|
|
||||||
private int increment;
|
|
||||||
private int pageIncrement;
|
|
||||||
private int selectedElement;
|
|
||||||
private boolean upperHover, lowerHover;
|
|
||||||
private int previousUpperValue, previousLowerValue;
|
|
||||||
private int startDragUpperValue, startDragLowerValue;
|
|
||||||
private Point startDragPoint;
|
|
||||||
private final boolean isFullSelection=false;
|
|
||||||
private final boolean isHighQuality;
|
|
||||||
private final boolean isOn;
|
|
||||||
private Format toolTipFormatter;
|
|
||||||
private String clientToolTipText;
|
|
||||||
private StringBuffer toolTip;
|
|
||||||
private Point coordUpper;
|
|
||||||
private Point coordLower;
|
|
||||||
|
|
||||||
public RangeSlider(final Composite parent, final int style) {
|
|
||||||
super(parent, SWT.DOUBLE_BUFFERED | ((style & SWT.BORDER) == SWT.BORDER ? SWT.BORDER : SWT.NONE));
|
|
||||||
slider = new Image[] {
|
|
||||||
SWTResourceManager.getImage(this.getClass(), "marker_l.png"),
|
|
||||||
SWTResourceManager.getImage(this.getClass(), "marker_r.png")};
|
|
||||||
sliderHover = new Image[] {
|
|
||||||
SWTResourceManager.getImage(this.getClass(), "marker_l_hover.png"),
|
|
||||||
SWTResourceManager.getImage(this.getClass(), "marker_r_hover.png")};
|
|
||||||
sliderDrag = new Image[] {
|
|
||||||
SWTResourceManager.getImage(this.getClass(), "marker_l_pressed.png"),
|
|
||||||
SWTResourceManager.getImage(this.getClass(), "marker_r_pressed.png")};
|
|
||||||
Rectangle imgSize = slider[0].getBounds();
|
|
||||||
minHeight =imgSize.height+2;
|
|
||||||
markerWidth = imgSize.width;
|
|
||||||
minimum = lowerValue = 0;
|
|
||||||
maximum = upperValue = 100;
|
|
||||||
increment = 1;
|
|
||||||
pageIncrement = 10;
|
|
||||||
isHighQuality = (style & SWT.HIGH) == SWT.HIGH;
|
|
||||||
isOn = (style & SWT.ON) == SWT.ON;
|
|
||||||
selectedElement = NONE;
|
|
||||||
|
|
||||||
addMouseListeners();
|
|
||||||
addListener(SWT.Resize, event -> {
|
|
||||||
});
|
|
||||||
addListener(SWT.KeyDown, event -> {
|
|
||||||
handleKeyDown(event);
|
|
||||||
});
|
|
||||||
addPaintListener(event -> {
|
|
||||||
drawWidget(event);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getStyle() {
|
|
||||||
return super.getStyle() | //
|
|
||||||
(isOn ? SWT.ON : SWT.NONE) | //
|
|
||||||
(isFullSelection ? SWT.CONTROL : SWT.NONE) | //
|
|
||||||
(isHighQuality ? SWT.HIGH : SWT.NONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addMouseListeners() {
|
|
||||||
addListener(SWT.MouseDown, e -> {
|
|
||||||
if (e.button == 1 || e.button == 2) {
|
|
||||||
selectKnobs(e);
|
|
||||||
selectedElement = (lowerHover ? LOWER : NONE) | (upperHover ? UPPER : NONE);
|
|
||||||
if (selectedElement!=NONE) {
|
|
||||||
if((e.stateMask & SWT.CTRL)==0 && e.button != 2)
|
|
||||||
selectedElement=BOTH;
|
|
||||||
startDragLowerValue = previousLowerValue = lowerValue;
|
|
||||||
startDragUpperValue = previousUpperValue = upperValue;
|
|
||||||
startDragPoint = new Point(e.x, e.y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
addListener(SWT.MouseUp, e -> {
|
|
||||||
if (selectedElement!=NONE) {
|
|
||||||
startDragPoint = null;
|
|
||||||
validateNewValues(e);
|
|
||||||
super.setToolTipText(clientToolTipText);
|
|
||||||
selectedElement=NONE;
|
|
||||||
redraw();
|
|
||||||
} else if (e.button == 1) {
|
|
||||||
if(e.x<coordLower.x) {
|
|
||||||
translateValues(-pageIncrement);
|
|
||||||
validateNewValues(e);
|
|
||||||
redraw();
|
|
||||||
} else if(e.x>coordUpper.x+markerWidth) {
|
|
||||||
translateValues(pageIncrement);
|
|
||||||
validateNewValues(e);
|
|
||||||
redraw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
addListener(SWT.MouseDoubleClick, event -> {
|
|
||||||
handleMouseDoubleClick(event);
|
|
||||||
});
|
|
||||||
|
|
||||||
addListener(SWT.MouseMove, event -> {
|
|
||||||
handleMouseMove(event);
|
|
||||||
});
|
|
||||||
|
|
||||||
addListener(SWT.MouseWheel, event -> {
|
|
||||||
handleMouseWheel(event);
|
|
||||||
});
|
|
||||||
|
|
||||||
addListener(SWT.MouseHover, event -> {
|
|
||||||
handleMouseHover(event);
|
|
||||||
});
|
|
||||||
|
|
||||||
addMouseTrackListener(new MouseTrackAdapter() {
|
|
||||||
public void mouseExit(MouseEvent event) {
|
|
||||||
lowerHover = upperHover = false;
|
|
||||||
redraw();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void validateNewValues(final Event e) {
|
|
||||||
if (upperValue != previousUpperValue || lowerValue != previousLowerValue) {
|
|
||||||
if (!SelectionListenerUtil.fireSelectionListeners(this,e)) {
|
|
||||||
upperValue = previousUpperValue;
|
|
||||||
lowerValue = previousLowerValue;
|
|
||||||
}
|
|
||||||
previousUpperValue = upperValue;
|
|
||||||
previousLowerValue = lowerValue;
|
|
||||||
increment = Math.max(1, (upperValue-lowerValue)/100);
|
|
||||||
pageIncrement = Math.max(1, (upperValue-lowerValue)/2);
|
|
||||||
redraw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean busy = false;
|
|
||||||
|
|
||||||
private void handleMouseMove(final Event e) {
|
|
||||||
if (selectedElement==NONE) {
|
|
||||||
final boolean wasUpper = upperHover;
|
|
||||||
final boolean wasLower = lowerHover;
|
|
||||||
selectKnobs(e);
|
|
||||||
if (wasUpper != upperHover || wasLower != lowerHover) {
|
|
||||||
redraw();
|
|
||||||
}
|
|
||||||
} else { // dragInProgress
|
|
||||||
final int x = e.x;
|
|
||||||
if (selectedElement == BOTH) {
|
|
||||||
final int diff = (int) ((startDragPoint.x - x) / computePixelSizeForSlider()) + minimum;
|
|
||||||
int newUpper = startDragUpperValue - diff;
|
|
||||||
int newLower = startDragLowerValue - diff;
|
|
||||||
if (newUpper > maximum) {
|
|
||||||
newUpper = maximum;
|
|
||||||
newLower = maximum - (startDragUpperValue - startDragLowerValue);
|
|
||||||
} else if (newLower < minimum) {
|
|
||||||
newLower = minimum;
|
|
||||||
newUpper = minimum + startDragUpperValue - startDragLowerValue;
|
|
||||||
}
|
|
||||||
upperValue = newUpper;
|
|
||||||
lowerValue = newLower;
|
|
||||||
handleToolTip(lowerValue, upperValue);
|
|
||||||
} else if (selectedElement == UPPER) {
|
|
||||||
upperValue = (int) Math.round((double)(x - markerWidth) / computePixelSizeForSlider()) + minimum;
|
|
||||||
checkUpperValue();
|
|
||||||
handleToolTip(upperValue);
|
|
||||||
} else if (selectedElement == LOWER){
|
|
||||||
lowerValue = (int) Math.round((double)(x - markerWidth) / computePixelSizeForSlider()) + minimum;
|
|
||||||
checkLowerValue();
|
|
||||||
handleToolTip(lowerValue);
|
|
||||||
}
|
|
||||||
if (isOn && !busy) {
|
|
||||||
validateNewValues(e);
|
|
||||||
busy=true;
|
|
||||||
getDisplay().timerExec(50, ()->{busy=false;});
|
|
||||||
} else {
|
|
||||||
redraw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isBetweenKnobs(int x, int y) {
|
|
||||||
return x < coordUpper.x && x > coordLower.x && y >= minHeight/3 && y <= minHeight/3 + getClientArea().height - 2*minHeight/3;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void selectKnobs(final Event e) {
|
|
||||||
if (coordLower != null) {
|
|
||||||
final Rectangle imgBounds = slider[0].getBounds();
|
|
||||||
final int x = e.x, y = e.y;
|
|
||||||
lowerHover = x >= coordLower.x && x <= coordLower.x + imgBounds.width && y >= coordLower.y && y <= coordLower.y + imgBounds.height;
|
|
||||||
upperHover = ((e.stateMask & (SWT.CTRL | SWT.SHIFT)) != 0 || !lowerHover) && //
|
|
||||||
x >= coordUpper.x && x <= coordUpper.x + imgBounds.width && //
|
|
||||||
y >= coordUpper.y && y <= coordUpper.y + imgBounds.height;
|
|
||||||
lowerHover &= (e.stateMask & SWT.CTRL) != 0 || !upperHover;
|
|
||||||
if (!lowerHover && !upperHover && isBetweenKnobs(x, y)) {
|
|
||||||
lowerHover = upperHover = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getCursorValue(int x, int y) {
|
|
||||||
int value = -1;
|
|
||||||
final Rectangle clientArea = getClientArea();
|
|
||||||
if (x < clientArea.width - 2*markerWidth && x >= markerWidth && y >= minHeight/3 && y <= clientArea.height - minHeight/3) {
|
|
||||||
value = (int) Math.round((x - 9d) / computePixelSizeForSlider()) + minimum;
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleMouseDoubleClick(final Event e) {
|
|
||||||
final int value = getCursorValue(e.x, e.y);
|
|
||||||
if (value >= 0) {
|
|
||||||
if (value > upperValue) {
|
|
||||||
translateValues(value-upperValue);
|
|
||||||
} else if (value < lowerValue) {
|
|
||||||
translateValues(value-lowerValue);
|
|
||||||
}
|
|
||||||
validateNewValues(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleToolTip(int... values) {
|
|
||||||
if (toolTipFormatter != null) {
|
|
||||||
try {
|
|
||||||
if (values.length == 1) {
|
|
||||||
toolTip.setLength(0);
|
|
||||||
toolTipFormatter.format(values[0], toolTip, null);
|
|
||||||
super.setToolTipText(toolTip.toString());
|
|
||||||
} else if (values.length == 2) {
|
|
||||||
toolTip.setLength(0);
|
|
||||||
toolTipFormatter.format(values[0], toolTip, null);
|
|
||||||
toolTip.append(" \u2194 "); // LEFT RIGHT ARROW
|
|
||||||
toolTipFormatter.format(values[1], toolTip, null);
|
|
||||||
super.setToolTipText(toolTip.toString());
|
|
||||||
}
|
|
||||||
} catch (final IllegalArgumentException ex) {
|
|
||||||
super.setToolTipText(clientToolTipText);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleMouseHover(final Event e) {
|
|
||||||
if (selectedElement!=NONE && toolTipFormatter != null) {
|
|
||||||
final int value = getCursorValue(e.x, e.y);
|
|
||||||
if (value >= 0) {
|
|
||||||
try {
|
|
||||||
toolTip.setLength(0);
|
|
||||||
toolTipFormatter.format(value, toolTip, null);
|
|
||||||
super.setToolTipText(toolTip.toString());
|
|
||||||
} catch (final IllegalArgumentException ex) {
|
|
||||||
super.setToolTipText(clientToolTipText);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
super.setToolTipText(clientToolTipText);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setToolTipFormatter(Format formatter) {
|
|
||||||
toolTip = formatter != null ? new StringBuffer() : null;
|
|
||||||
toolTipFormatter = formatter;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setToolTipText(String string) {
|
|
||||||
super.setToolTipText(clientToolTipText = string);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleMouseWheel(final Event e) {
|
|
||||||
previousLowerValue = lowerValue;
|
|
||||||
previousUpperValue = upperValue;
|
|
||||||
final int amount = Math.max(1, ((e.stateMask & SWT.SHIFT) != 0 ? (upperValue-lowerValue)/6 : (upperValue-lowerValue)/15));
|
|
||||||
if ((e.stateMask&SWT.CTRL)==0) {
|
|
||||||
int newLower = lowerValue + e.count * amount;
|
|
||||||
int newUpper = upperValue + e.count * amount;
|
|
||||||
if (newUpper > maximum) {
|
|
||||||
newUpper = maximum;
|
|
||||||
newLower = maximum - (upperValue - lowerValue);
|
|
||||||
} else if (newLower < minimum) {
|
|
||||||
newLower = minimum;
|
|
||||||
newUpper = minimum + upperValue - lowerValue;
|
|
||||||
}
|
|
||||||
upperValue = newUpper;
|
|
||||||
lowerValue = newLower;
|
|
||||||
} else {
|
|
||||||
int newLower = lowerValue + e.count * amount/2;
|
|
||||||
int newUpper = upperValue - e.count * amount/2;
|
|
||||||
int dist = newUpper - newLower;
|
|
||||||
if (newUpper > maximum) {
|
|
||||||
newUpper = maximum;
|
|
||||||
newLower = maximum - dist;
|
|
||||||
} else if (newLower < minimum) {
|
|
||||||
newLower = minimum;
|
|
||||||
newUpper = minimum + dist;
|
|
||||||
}
|
|
||||||
if(newUpper<=newLower) {
|
|
||||||
newLower=lowerValue + (upperValue - lowerValue)/2;
|
|
||||||
newUpper=newLower+1;
|
|
||||||
}
|
|
||||||
upperValue = newUpper;
|
|
||||||
lowerValue = newLower;
|
|
||||||
}
|
|
||||||
validateNewValues(e);
|
|
||||||
e.doit = false; // we are consuming this event
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkLowerValue() {
|
|
||||||
if (lowerValue < minimum) {
|
|
||||||
lowerValue = minimum;
|
|
||||||
} else if (lowerValue > (upperValue-thumbWidth)) {
|
|
||||||
lowerValue = (upperValue-thumbWidth);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkUpperValue() {
|
|
||||||
if (upperValue > maximum) {
|
|
||||||
upperValue = maximum;
|
|
||||||
} else if (upperValue < (lowerValue+thumbWidth)) {
|
|
||||||
upperValue = lowerValue+thumbWidth;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private float computePixelSizeForSlider() {
|
|
||||||
return (getClientArea().width - 2.0f*markerWidth) / (maximum - minimum);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void drawWidget(final PaintEvent e) {
|
|
||||||
final Rectangle rect = getClientArea();
|
|
||||||
if (rect.width == 0 || rect.height == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
e.gc.setAdvanced(true);
|
|
||||||
e.gc.setAntialias(SWT.ON);
|
|
||||||
drawBackground(e.gc);
|
|
||||||
if (lowerHover || (selectedElement & LOWER) != 0) {
|
|
||||||
coordUpper = drawMarker(e.gc, upperValue, true);
|
|
||||||
coordLower = drawMarker(e.gc, lowerValue, false);
|
|
||||||
} else {
|
|
||||||
coordLower = drawMarker(e.gc, lowerValue, false);
|
|
||||||
coordUpper = drawMarker(e.gc, upperValue, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void drawBackground(final GC gc) {
|
|
||||||
final Rectangle clientArea = getClientArea();
|
|
||||||
gc.setBackground(getBackground());
|
|
||||||
gc.fillRectangle(clientArea);
|
|
||||||
if (isEnabled()) {
|
|
||||||
gc.setForeground(getForeground());
|
|
||||||
} else {
|
|
||||||
gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_GRAY));
|
|
||||||
}
|
|
||||||
gc.drawRoundRectangle(markerWidth, minHeight/3, clientArea.width - 2*markerWidth, clientArea.height - 2*minHeight/3, 3, 3);
|
|
||||||
|
|
||||||
final float pixelSize = computePixelSizeForSlider();
|
|
||||||
final int startX = (int) (pixelSize * lowerValue);
|
|
||||||
final int endX = (int) (pixelSize * upperValue);
|
|
||||||
if (isEnabled()) {
|
|
||||||
gc.setBackground(getForeground());
|
|
||||||
} else {
|
|
||||||
gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_GRAY));
|
|
||||||
}
|
|
||||||
gc.fillRectangle(markerWidth+startX, minHeight/3, endX - startX, clientArea.height - 2*minHeight/3);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private Point drawMarker(final GC gc, final int value, final boolean upper) {
|
|
||||||
final float pixelSize = computePixelSizeForSlider();
|
|
||||||
int x = (int) (pixelSize * value);
|
|
||||||
final int idx = upper?1:0;
|
|
||||||
Image image;
|
|
||||||
if (upper) {
|
|
||||||
if (upperHover) {
|
|
||||||
image = (selectedElement & UPPER) != 0 ? sliderDrag[idx] : sliderHover[idx];
|
|
||||||
} else {
|
|
||||||
image = slider[idx];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (lowerHover) {
|
|
||||||
image = (selectedElement & LOWER) != 0 ? sliderDrag[idx] : sliderHover[idx];
|
|
||||||
} else {
|
|
||||||
image = slider[idx];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(upper)
|
|
||||||
x+=slider[idx].getBounds().width;
|
|
||||||
if (isEnabled()) {
|
|
||||||
gc.drawImage(image, x, getClientArea().height / 2 - slider[idx].getBounds().height / 2);
|
|
||||||
} else {
|
|
||||||
final Image temp = new Image(getDisplay(), image, SWT.IMAGE_DISABLE);
|
|
||||||
gc.drawImage(temp, x, getClientArea().height / 2 - slider[idx].getBounds().height / 2);
|
|
||||||
temp.dispose();
|
|
||||||
}
|
|
||||||
return new Point(x, getClientArea().height / 2 - slider[idx].getBounds().height / 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void moveCursorPosition(int xDelta, int yDelta) {
|
|
||||||
final Point cursorPosition = getDisplay().getCursorLocation();
|
|
||||||
cursorPosition.x += xDelta;
|
|
||||||
cursorPosition.y += yDelta;
|
|
||||||
getDisplay().setCursorLocation(cursorPosition);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleKeyDown(final Event event) {
|
|
||||||
int accelerator = (event.stateMask & SWT.SHIFT) != 0 ? 10 : (event.stateMask & SWT.CTRL) != 0 ? 2 : 1;
|
|
||||||
if (selectedElement != NONE) {
|
|
||||||
switch (event.keyCode) {
|
|
||||||
case SWT.ESC:
|
|
||||||
startDragPoint = null;
|
|
||||||
upperValue = startDragUpperValue;
|
|
||||||
lowerValue = startDragLowerValue;
|
|
||||||
validateNewValues(event);
|
|
||||||
selectedElement = NONE;
|
|
||||||
if (!isOn) {
|
|
||||||
redraw();
|
|
||||||
}
|
|
||||||
event.doit = false;
|
|
||||||
break;
|
|
||||||
case SWT.ARROW_UP:
|
|
||||||
accelerator = -accelerator;
|
|
||||||
case SWT.ARROW_LEFT:
|
|
||||||
moveCursorPosition(-accelerator, 0);
|
|
||||||
event.doit = false;
|
|
||||||
break;
|
|
||||||
case SWT.ARROW_DOWN:
|
|
||||||
accelerator = -accelerator;
|
|
||||||
case SWT.ARROW_RIGHT:
|
|
||||||
moveCursorPosition(accelerator, 0);
|
|
||||||
event.doit = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
previousLowerValue = lowerValue;
|
|
||||||
previousUpperValue = upperValue;
|
|
||||||
|
|
||||||
switch (event.keyCode) {
|
|
||||||
case SWT.HOME:
|
|
||||||
if ((event.stateMask & (SWT.SHIFT| SWT.CTRL)) == 0) {
|
|
||||||
upperValue = minimum + upperValue - lowerValue;
|
|
||||||
lowerValue = minimum;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SWT.END:
|
|
||||||
if ((event.stateMask & (SWT.SHIFT| SWT.CTRL)) == 0) {
|
|
||||||
lowerValue = maximum - (upperValue - lowerValue);
|
|
||||||
upperValue = maximum;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SWT.PAGE_UP:
|
|
||||||
translateValues(-accelerator * pageIncrement);
|
|
||||||
break;
|
|
||||||
case SWT.PAGE_DOWN:
|
|
||||||
translateValues( accelerator * pageIncrement);
|
|
||||||
break;
|
|
||||||
case SWT.ARROW_DOWN:
|
|
||||||
case SWT.ARROW_RIGHT:
|
|
||||||
translateValues( accelerator * increment);
|
|
||||||
break;
|
|
||||||
case SWT.ARROW_UP:
|
|
||||||
case SWT.ARROW_LEFT:
|
|
||||||
translateValues(-accelerator * increment);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (previousLowerValue != lowerValue || previousUpperValue != upperValue) {
|
|
||||||
checkLowerValue();
|
|
||||||
checkUpperValue();
|
|
||||||
validateNewValues(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void translateValues(int amount) {
|
|
||||||
int newLower = lowerValue + amount;
|
|
||||||
int newUpper = upperValue + amount;
|
|
||||||
if (newUpper > maximum) {
|
|
||||||
newUpper = maximum;
|
|
||||||
newLower = maximum - (upperValue - lowerValue);
|
|
||||||
} else if (newLower < minimum) {
|
|
||||||
newLower = minimum;
|
|
||||||
newUpper = minimum + upperValue - lowerValue;
|
|
||||||
}
|
|
||||||
upperValue = newUpper;
|
|
||||||
lowerValue = newLower;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addSelectionListener(final SelectionListener listener) {
|
|
||||||
checkWidget();
|
|
||||||
SelectionListenerUtil.addSelectionListener(this, listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeSelectionListener(final SelectionListener listener) {
|
|
||||||
checkWidget();
|
|
||||||
SelectionListenerUtil.removeSelectionListener(this, listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Point computeSize(final int wHint, final int hHint, final boolean changed) {
|
|
||||||
checkWidget();
|
|
||||||
final int width = Math.max(2*markerWidth+100, wHint);
|
|
||||||
final int height = Math.max(minHeight, hHint);
|
|
||||||
return new Point(width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int[] getSelection() {
|
|
||||||
checkWidget();
|
|
||||||
return new int[] {lowerValue, upperValue};
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getIncrement() {
|
|
||||||
checkWidget();
|
|
||||||
return increment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMaximum() {
|
|
||||||
checkWidget();
|
|
||||||
return maximum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMinimum() {
|
|
||||||
checkWidget();
|
|
||||||
return minimum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPageIncrement() {
|
|
||||||
checkWidget();
|
|
||||||
return pageIncrement;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMaximum(final int value) {
|
|
||||||
setLimits(minimum, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMinimum(final int value) {
|
|
||||||
setLimits(value, maximum);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLimits(final int min, final int max) {
|
|
||||||
checkWidget();
|
|
||||||
if (min >= 0 && min < max && (min != minimum || max != maximum)) {
|
|
||||||
minimum = min;
|
|
||||||
maximum = max;
|
|
||||||
if (lowerValue < minimum) {
|
|
||||||
lowerValue = minimum;
|
|
||||||
} else if (lowerValue > maximum) {
|
|
||||||
lowerValue = maximum;
|
|
||||||
}
|
|
||||||
if (upperValue < minimum) {
|
|
||||||
upperValue = minimum;
|
|
||||||
} else if (upperValue > maximum) {
|
|
||||||
upperValue = maximum;
|
|
||||||
}
|
|
||||||
redraw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getUpperValue() {
|
|
||||||
checkWidget();
|
|
||||||
return upperValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUpperValue(final int value) {
|
|
||||||
setValues(lowerValue, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLowerValue() {
|
|
||||||
checkWidget();
|
|
||||||
return lowerValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLowerValue(final int value) {
|
|
||||||
setValues(value, upperValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValues(final int[] values) {
|
|
||||||
if (values.length == 2) {
|
|
||||||
setValues(values[0], values[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValues(final int lowerValue, final int upperValue) {
|
|
||||||
setValues(lowerValue, upperValue, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValues(final int lowerValue, final int upperValue, boolean update) {
|
|
||||||
checkWidget();
|
|
||||||
if (lowerValue <= upperValue && lowerValue >= minimum && upperValue <= maximum && (this.lowerValue != lowerValue || this.upperValue != upperValue)) {
|
|
||||||
this.lowerValue = lowerValue;
|
|
||||||
this.upperValue = upperValue;
|
|
||||||
if(update) {
|
|
||||||
Event e = new Event();
|
|
||||||
e.type=SWT.Selection;
|
|
||||||
e.doit=true;
|
|
||||||
validateNewValues(e);
|
|
||||||
} else {
|
|
||||||
increment = Math.max(1, (upperValue-lowerValue)/100);
|
|
||||||
pageIncrement = Math.max(1, (upperValue-lowerValue)/2);
|
|
||||||
}
|
|
||||||
redraw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
package com.minres.scviewer.database.ui.swt.internal.slider;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
|
|
||||||
public class ReflectionUtils {
|
|
||||||
/**
|
|
||||||
* Call a method using introspection (so ones can call a private or protected method)
|
|
||||||
* @param object object on which the method will be called
|
|
||||||
* @param methodName method name
|
|
||||||
* @param args arguments of this method (can be null)
|
|
||||||
* @return the value returned by this method (if this method returns a value)
|
|
||||||
*/
|
|
||||||
public static Object callMethod(final Object object, final String methodName, final Object... args) {
|
|
||||||
if (object == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
final Class<?>[] array = new Class<?>[args == null ? 0 : args.length];
|
|
||||||
int index = 0;
|
|
||||||
if (args != null) {
|
|
||||||
for (final Object o : args) {
|
|
||||||
array[index++] = o == null ? Object.class : o.getClass();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return callMethodWithClassType(object, methodName, array, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Object callMethodWithClassType(final Object object, final String methodName, final Class<?>[] array, final Object... args) {
|
|
||||||
Class<?> currentClass = object.getClass();
|
|
||||||
Method method = null;
|
|
||||||
while (currentClass != null) {
|
|
||||||
try {
|
|
||||||
method = currentClass.getDeclaredMethod(methodName, array);
|
|
||||||
break;
|
|
||||||
} catch (final NoSuchMethodException nsme) {
|
|
||||||
currentClass = currentClass.getSuperclass();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
method.setAccessible(true);
|
|
||||||
return method.invoke(object, args);
|
|
||||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,74 +0,0 @@
|
|||||||
package com.minres.scviewer.database.ui.swt.internal.slider;
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.events.SelectionListener;
|
|
||||||
import org.eclipse.swt.widgets.Control;
|
|
||||||
import org.eclipse.swt.widgets.Event;
|
|
||||||
import org.eclipse.swt.widgets.Listener;
|
|
||||||
import org.eclipse.swt.widgets.TypedListener;
|
|
||||||
|
|
||||||
public class SelectionListenerUtil {
|
|
||||||
/**
|
|
||||||
* Add a <code>SelectionListener</code> to a given Control
|
|
||||||
*
|
|
||||||
* @param control control on which the selection listener is added
|
|
||||||
* @param listener listener to add
|
|
||||||
*/
|
|
||||||
public static void addSelectionListener(final Control control, final SelectionListener listener) {
|
|
||||||
if (listener == null) {
|
|
||||||
SWT.error(SWT.ERROR_NULL_ARGUMENT);
|
|
||||||
}
|
|
||||||
TypedListener typedListener = new TypedListener(listener);
|
|
||||||
control.addListener(SWT.Selection, typedListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove a <code>SelectionListener</code> of a given Control
|
|
||||||
*
|
|
||||||
* @param control control on which the selection listener is removed
|
|
||||||
* @param listener listener to remove
|
|
||||||
*/
|
|
||||||
public static void removeSelectionListener(final Control control, final SelectionListener listener) {
|
|
||||||
if (listener == null) {
|
|
||||||
SWT.error(SWT.ERROR_NULL_ARGUMENT);
|
|
||||||
}
|
|
||||||
final Listener[] listeners = control.getListeners(SWT.Selection);
|
|
||||||
for (Listener l : listeners) {
|
|
||||||
if (l instanceof TypedListener) {
|
|
||||||
TypedListener typedListener = (TypedListener) l;
|
|
||||||
if (typedListener.getEventListener() == listener) {
|
|
||||||
ReflectionUtils.callMethod(control, "removeListener", SWT.Selection, ((TypedListener) l).getEventListener());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fire the selection listeners of a given control
|
|
||||||
*
|
|
||||||
* @param control the control that fires the event
|
|
||||||
* @param sourceEvent mouse event
|
|
||||||
* @return true if the selection could be changed, false otherwise
|
|
||||||
*/
|
|
||||||
public static boolean fireSelectionListeners(final Control control, final Event sourceEvent) {
|
|
||||||
for (final Listener listener : control.getListeners(SWT.Selection)) {
|
|
||||||
final Event event = new Event();
|
|
||||||
|
|
||||||
event.button = sourceEvent==null?1:sourceEvent.button;
|
|
||||||
event.display = control.getDisplay();
|
|
||||||
event.item = null;
|
|
||||||
event.widget = control;
|
|
||||||
event.data = sourceEvent == null ? null : sourceEvent.data;
|
|
||||||
event.time = sourceEvent == null ? 0 : sourceEvent.time;
|
|
||||||
event.x = sourceEvent == null ? 0 : sourceEvent.x;
|
|
||||||
event.y = sourceEvent == null ? 0 : sourceEvent.y;
|
|
||||||
event.type = SWT.Selection;
|
|
||||||
|
|
||||||
listener.handleEvent(event);
|
|
||||||
if (!event.doit) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,127 +0,0 @@
|
|||||||
package com.minres.scviewer.database.ui.swt.internal.slider;
|
|
||||||
|
|
||||||
import java.text.Format;
|
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.events.SelectionAdapter;
|
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
|
||||||
import org.eclipse.swt.events.SelectionListener;
|
|
||||||
import org.eclipse.swt.graphics.Image;
|
|
||||||
import org.eclipse.swt.layout.GridData;
|
|
||||||
import org.eclipse.swt.layout.GridLayout;
|
|
||||||
import org.eclipse.swt.widgets.Composite;
|
|
||||||
import org.eclipse.wb.swt.SWTResourceManager;
|
|
||||||
|
|
||||||
public class ZoomBar extends Composite {
|
|
||||||
|
|
||||||
static public interface IProvider {
|
|
||||||
ZoomBar getScrollBar();
|
|
||||||
}
|
|
||||||
|
|
||||||
final RangeSlider timeSlider;
|
|
||||||
final ImageButton leftButton;
|
|
||||||
final ImageButton rightButton;
|
|
||||||
/**
|
|
||||||
* Create the composite.
|
|
||||||
* @param parent
|
|
||||||
* @param style
|
|
||||||
*/
|
|
||||||
public ZoomBar(Composite parent, int style) {
|
|
||||||
super(parent, SWT.NO_FOCUS);
|
|
||||||
GridLayout gridLayout = new GridLayout(3, false);
|
|
||||||
gridLayout.horizontalSpacing = 0;
|
|
||||||
gridLayout.verticalSpacing = 0;
|
|
||||||
gridLayout.marginWidth = 0;
|
|
||||||
gridLayout.marginHeight = 0;
|
|
||||||
setLayout(gridLayout);
|
|
||||||
|
|
||||||
leftButton = new ImageButton(this, SWT.NONE);
|
|
||||||
GridData gd_leftButton = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
|
|
||||||
gd_leftButton.widthHint=14;
|
|
||||||
gd_leftButton.heightHint=18;
|
|
||||||
leftButton.setLayoutData(gd_leftButton);
|
|
||||||
leftButton.setImage(new Image[] {
|
|
||||||
SWTResourceManager.getImage(this.getClass(), "arrow_left.png"),
|
|
||||||
SWTResourceManager.getImage(this.getClass(), "arrow_left_hover.png"),
|
|
||||||
SWTResourceManager.getImage(this.getClass(), "arrow_left_pressed.png")});
|
|
||||||
leftButton.setAutoFire(true);
|
|
||||||
|
|
||||||
timeSlider = new RangeSlider(this, SWT.ON|SWT.HIGH|SWT.SMOOTH|SWT.CONTROL);
|
|
||||||
timeSlider.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
|
|
||||||
|
|
||||||
rightButton = new ImageButton(this, SWT.NONE);
|
|
||||||
GridData gd_rightButton = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
|
|
||||||
gd_rightButton.widthHint=18;
|
|
||||||
gd_rightButton.heightHint=18;
|
|
||||||
rightButton.setLayoutData(gd_rightButton);
|
|
||||||
rightButton.setImage(new Image[] {
|
|
||||||
SWTResourceManager.getImage(this.getClass(), "arrow_right.png"),
|
|
||||||
SWTResourceManager.getImage(this.getClass(), "arrow_right_hover.png"),
|
|
||||||
SWTResourceManager.getImage(this.getClass(), "arrow_right_pressed.png")});
|
|
||||||
rightButton.setAutoFire(true);
|
|
||||||
|
|
||||||
leftButton.addSelectionListener(new SelectionAdapter() {
|
|
||||||
@Override
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
int[] value = timeSlider.getSelection();
|
|
||||||
int incr=timeSlider.getIncrement();
|
|
||||||
int lower = Math.max(timeSlider.getMinimum(), value[0]-incr);
|
|
||||||
timeSlider.setValues(lower, lower + (value[1]-value[0]), true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
rightButton.addSelectionListener(new SelectionAdapter() {
|
|
||||||
@Override
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
int[] value = timeSlider.getSelection();
|
|
||||||
int incr=timeSlider.getIncrement();
|
|
||||||
int upper = Math.min(timeSlider.getMaximum(), value[1]+incr);
|
|
||||||
timeSlider.setValues(upper - (value[1]-value[0]), upper, true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void setEnabled (boolean enabled) {
|
|
||||||
timeSlider.setEnabled(enabled);
|
|
||||||
leftButton.setEnabled(enabled);
|
|
||||||
rightButton.setEnabled(enabled);
|
|
||||||
super.setEnabled(enabled);
|
|
||||||
redraw();
|
|
||||||
}
|
|
||||||
public void setButtonsEnabled (boolean enabled) {
|
|
||||||
leftButton.setEnabled(enabled);
|
|
||||||
rightButton.setEnabled(enabled);
|
|
||||||
redraw();
|
|
||||||
}
|
|
||||||
public void setToolTipFormatter(Format formatter){
|
|
||||||
timeSlider.setToolTipFormatter(formatter);
|
|
||||||
}
|
|
||||||
public void setToolTipText(String string) {
|
|
||||||
timeSlider.setToolTipText(string);
|
|
||||||
}
|
|
||||||
public void setSelection(int sel) {
|
|
||||||
timeSlider.setLowerValue(sel);
|
|
||||||
}
|
|
||||||
public void setSelection(int[] sel) {
|
|
||||||
assert(sel.length==2);
|
|
||||||
timeSlider.setValues(sel[0], sel[1]);
|
|
||||||
}
|
|
||||||
public int[] getSelection() {
|
|
||||||
return timeSlider.getSelection();
|
|
||||||
}
|
|
||||||
public void addSelectionListener(SelectionListener selectionListener) {
|
|
||||||
timeSlider.addSelectionListener(selectionListener);
|
|
||||||
}
|
|
||||||
public void setMinimum(int value) {
|
|
||||||
timeSlider.setMinimum(value);
|
|
||||||
}
|
|
||||||
public void setMaximum(int value) {
|
|
||||||
timeSlider.setMaximum(value);
|
|
||||||
}
|
|
||||||
public int getMaximum() {
|
|
||||||
return timeSlider.getMaximum();
|
|
||||||
}
|
|
||||||
public int getMinimum() {
|
|
||||||
return timeSlider.getMinimum();
|
|
||||||
}
|
|
||||||
}
|
|
Before Width: | Height: | Size: 352 B |
Before Width: | Height: | Size: 326 B |
Before Width: | Height: | Size: 352 B |
Before Width: | Height: | Size: 305 B |
Before Width: | Height: | Size: 302 B |
Before Width: | Height: | Size: 339 B |
Before Width: | Height: | Size: 350 B |
Before Width: | Height: | Size: 336 B |
Before Width: | Height: | Size: 352 B |
Before Width: | Height: | Size: 329 B |
Before Width: | Height: | Size: 326 B |
Before Width: | Height: | Size: 349 B |
@ -1,18 +0,0 @@
|
|||||||
package com.minres.scviewer.database.ui.swt.sb;
|
|
||||||
|
|
||||||
import org.eclipse.swt.widgets.Display;
|
|
||||||
|
|
||||||
public class ActionScheduler {
|
|
||||||
|
|
||||||
private final Display display;
|
|
||||||
private final Runnable action;
|
|
||||||
|
|
||||||
public ActionScheduler( Display display, Runnable action ) {
|
|
||||||
this.display = display;
|
|
||||||
this.action = action;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void schedule( int delay ) {
|
|
||||||
display.timerExec( delay, action );
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
package com.minres.scviewer.database.ui.swt.sb;
|
|
||||||
|
|
||||||
import org.eclipse.swt.events.MouseEvent;
|
|
||||||
import org.eclipse.swt.graphics.Point;
|
|
||||||
import org.eclipse.swt.widgets.Control;
|
|
||||||
|
|
||||||
public class ButtonClick {
|
|
||||||
|
|
||||||
public static final int LEFT_BUTTON = 1;
|
|
||||||
|
|
||||||
private boolean armed;
|
|
||||||
|
|
||||||
public boolean isArmed() {
|
|
||||||
return armed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void arm( MouseEvent event ) {
|
|
||||||
if( event.button == LEFT_BUTTON ) {
|
|
||||||
armed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void disarm() {
|
|
||||||
armed = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void trigger( MouseEvent event, Runnable action ) {
|
|
||||||
try {
|
|
||||||
doTrigger( event, action );
|
|
||||||
} finally {
|
|
||||||
disarm();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doTrigger( MouseEvent event, Runnable action ) {
|
|
||||||
if( armed && inRange( event ) ) {
|
|
||||||
action.run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean inRange( MouseEvent event ) {
|
|
||||||
Point size = ( ( Control )event.widget ).getSize();
|
|
||||||
return event.x >= 0 && event.x <= size.x && event.y >= 0 && event.y <= size.y;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,98 +0,0 @@
|
|||||||
package com.minres.scviewer.database.ui.swt.sb;
|
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.events.ControlAdapter;
|
|
||||||
import org.eclipse.swt.events.ControlEvent;
|
|
||||||
import org.eclipse.swt.events.MouseEvent;
|
|
||||||
import org.eclipse.swt.events.MouseListener;
|
|
||||||
import org.eclipse.swt.events.MouseTrackListener;
|
|
||||||
import org.eclipse.swt.graphics.Color;
|
|
||||||
import org.eclipse.swt.widgets.Composite;
|
|
||||||
import org.eclipse.swt.widgets.Label;
|
|
||||||
|
|
||||||
|
|
||||||
class ClickControl extends ControlAdapter implements ViewComponent, MouseDownActionTimer.TimerAction, MouseListener, MouseTrackListener {
|
|
||||||
|
|
||||||
private final MouseDownActionTimer mouseDownActionTimer;
|
|
||||||
private final ClickAction clickAction;
|
|
||||||
private final ButtonClick buttonClick;
|
|
||||||
private final Label control;
|
|
||||||
private final ImageUpdate imageUpdate;
|
|
||||||
|
|
||||||
public interface ClickAction extends Runnable {
|
|
||||||
void setCoordinates( int x, int y );
|
|
||||||
}
|
|
||||||
|
|
||||||
ClickControl( Composite parent, ClickAction clickAction, int maxExtension ) {
|
|
||||||
this.control = new Label( parent, SWT.NONE );
|
|
||||||
this.imageUpdate = new ImageUpdate( control, maxExtension );
|
|
||||||
this.buttonClick = new ButtonClick();
|
|
||||||
this.mouseDownActionTimer = new MouseDownActionTimer( this, buttonClick, control.getDisplay() );
|
|
||||||
this.clickAction = clickAction;
|
|
||||||
this.control.addMouseTrackListener( this );
|
|
||||||
this.control.addMouseListener( this );
|
|
||||||
this.control.addControlListener( this );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void controlResized( ControlEvent event ) {
|
|
||||||
imageUpdate.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Label getControl() {
|
|
||||||
return control;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseDown( MouseEvent event ) {
|
|
||||||
buttonClick.arm( event );
|
|
||||||
clickAction.setCoordinates( event.x, event.y );
|
|
||||||
mouseDownActionTimer.activate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseUp( MouseEvent event ) {
|
|
||||||
buttonClick.trigger( event, clickAction );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
clickAction.run();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEnabled() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseExit( MouseEvent event ) {
|
|
||||||
buttonClick.disarm();
|
|
||||||
}
|
|
||||||
|
|
||||||
void setForeground( Color color ) {
|
|
||||||
imageUpdate.setForeground( color );
|
|
||||||
}
|
|
||||||
|
|
||||||
Color getForeground() {
|
|
||||||
return imageUpdate.getForeground();
|
|
||||||
}
|
|
||||||
|
|
||||||
void setBackground( Color color ) {
|
|
||||||
imageUpdate.setBackground( color );
|
|
||||||
}
|
|
||||||
|
|
||||||
Color getBackground() {
|
|
||||||
return imageUpdate.getBackground();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseEnter( MouseEvent event ) {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseHover( MouseEvent event ) {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseDoubleClick( MouseEvent event ) {}
|
|
||||||
}
|
|
@ -1,105 +0,0 @@
|
|||||||
package com.minres.scviewer.database.ui.swt.sb;
|
|
||||||
|
|
||||||
import static java.lang.Math.max;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.math.RoundingMode;
|
|
||||||
|
|
||||||
class ComponentDistribution {
|
|
||||||
|
|
||||||
private static final int MIN_DRAG_LENGTH = 17;
|
|
||||||
|
|
||||||
final int upFastLength;
|
|
||||||
final int dragStart;
|
|
||||||
final int dragLength;
|
|
||||||
final int downFastStart;
|
|
||||||
final int downFastLength;
|
|
||||||
final int downStart;
|
|
||||||
final int buttonLen;
|
|
||||||
|
|
||||||
ComponentDistribution( int buttonLen, int len, int range, int pos, int thumb ) {
|
|
||||||
int slideLen = slideLen( buttonLen, len );
|
|
||||||
int relDragLen = relDragLen( slideLen, range, thumb );
|
|
||||||
int minDragLength = max( MIN_DRAG_LENGTH, buttonLen );
|
|
||||||
int interval = interval( range, relDragLen, minDragLength );
|
|
||||||
this.dragLength = dragLen( minDragLength, relDragLen );
|
|
||||||
this.upFastLength = upFastLen( minDragLength, interval, pos, slideLen, relDragLen, dragLength );
|
|
||||||
this.downStart = downStart( buttonLen, len );
|
|
||||||
this.downFastStart = downFastStart( buttonLen, upFastLength, dragLength );
|
|
||||||
this.dragStart = dragStart( buttonLen, upFastLength );
|
|
||||||
this.downFastLength = downFastLen( minDragLength, interval, pos, slideLen, relDragLen, dragLength, upFastLength );
|
|
||||||
this.buttonLen = buttonLen;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int slideLen( int buttonLen, int len ) {
|
|
||||||
return len - buttonLen * 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int relDragLen( int slideLen, int range, int thumb ) {
|
|
||||||
return divide( slideLen * thumb, range );
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int interval( int range, int relDragLen, int minDragLength ) {
|
|
||||||
int result = range;
|
|
||||||
if( useMinDragLen( minDragLength, relDragLen ) ) {
|
|
||||||
result += minDragLength - relDragLen / 2;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int dragLen( int buttonLen, int relDragLen ) {
|
|
||||||
return max( relDragLen, buttonLen );
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int upFastLen( int buttonLen, int range, int pos, int slideLen, int relDragLen, int dragLen ) {
|
|
||||||
int result = slideLen * pos / range;
|
|
||||||
if( useMinDragLen( buttonLen, relDragLen ) ) {
|
|
||||||
result -= divide( ( dragLen - relDragLen ) * pos, range );
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int downStart( int buttonLen, int len ) {
|
|
||||||
return len - buttonLen;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int downFastStart( int buttonLen, int upFastLength, int dragLength ) {
|
|
||||||
return buttonLen + upFastLength + dragLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int dragStart( int buttonLen, int upFastLen ) {
|
|
||||||
return buttonLen + upFastLen;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int downFastLen(
|
|
||||||
int buttonLen, int range, int pos, int slideLen, int relDragLen, int dragLen, int upFastLen )
|
|
||||||
{
|
|
||||||
int result = divide( slideLen * ( range - pos ), range ) - dragLen;
|
|
||||||
if( useMinDragLen( buttonLen, relDragLen ) ) {
|
|
||||||
result += divide( ( dragLen - relDragLen ) * pos, range );
|
|
||||||
}
|
|
||||||
return adjustDownFastLen( result, slideLen, dragLen, upFastLen );
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean useMinDragLen( int buttonLen, int relDragLen ) {
|
|
||||||
return relDragLen < buttonLen;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int divide( int dividend, int divisor ) {
|
|
||||||
BigDecimal bigDividend = new BigDecimal( dividend );
|
|
||||||
BigDecimal bigDivisor = new BigDecimal( divisor );
|
|
||||||
return bigDividend .divide( bigDivisor, 0, RoundingMode.HALF_EVEN ) .intValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int adjustDownFastLen( int tentative, int slideLen, int dragLen, int upFastLen ) {
|
|
||||||
// TODO [fappel]: Without this there is a flickering of the downFast label of one pixel.
|
|
||||||
// Check whether this can be resolved by better rounding or whatsoever.
|
|
||||||
int result = tentative;
|
|
||||||
if( slideLen < upFastLen + dragLen + result ) {
|
|
||||||
result--;
|
|
||||||
} else if( slideLen > upFastLen + dragLen + result ) {
|
|
||||||
result++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
package com.minres.scviewer.database.ui.swt.sb;
|
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
|
|
||||||
import com.minres.scviewer.database.ui.swt.sb.ClickControl.ClickAction;
|
|
||||||
|
|
||||||
class Decrementer implements ClickAction {
|
|
||||||
|
|
||||||
private final FlatScrollBar scrollBar;
|
|
||||||
|
|
||||||
Decrementer( FlatScrollBar scrollBar ) {
|
|
||||||
this.scrollBar = scrollBar;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
int selection = scrollBar.getSelection() - scrollBar.getIncrement();
|
|
||||||
scrollBar.setSelectionInternal( selection, SWT.ARROW_UP );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCoordinates( int x, int y ) {
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,203 +0,0 @@
|
|||||||
package com.minres.scviewer.database.ui.swt.sb;
|
|
||||||
|
|
||||||
import static com.minres.scviewer.database.ui.swt.sb.FlatScrollBar.BAR_BREADTH;
|
|
||||||
import static java.lang.Math.max;
|
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.graphics.Point;
|
|
||||||
import org.eclipse.swt.graphics.Rectangle;
|
|
||||||
import org.eclipse.swt.widgets.Composite;
|
|
||||||
import org.eclipse.swt.widgets.Control;
|
|
||||||
|
|
||||||
enum Direction {
|
|
||||||
|
|
||||||
HORIZONTAL( SWT.HORIZONTAL ) {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void layout( FlatScrollBar scrollBar, int buttonLength ) {
|
|
||||||
ComponentDistribution distribution = calculateComponentDistribution( scrollBar, buttonLength );
|
|
||||||
Rectangle[] componentBounds = calculateComponentBounds( distribution, scrollBar );
|
|
||||||
applyComponentBounds( scrollBar, componentBounds );
|
|
||||||
}
|
|
||||||
|
|
||||||
private ComponentDistribution calculateComponentDistribution( FlatScrollBar scrollBar, int buttonLength ) {
|
|
||||||
return calculateComponentDistribution( scrollBar, buttonLength, getControlBounds( scrollBar ).width );
|
|
||||||
}
|
|
||||||
|
|
||||||
private Rectangle[] calculateComponentBounds( ComponentDistribution distribution, FlatScrollBar scrollBar ) {
|
|
||||||
int width = getControlBounds( scrollBar ).width;
|
|
||||||
int height = getControlBounds( scrollBar ).height - FlatScrollBar.BAR_BREADTH + 1;
|
|
||||||
int balance = getRoundingBalance( distribution, scrollBar );
|
|
||||||
return new Rectangle[] {
|
|
||||||
calcButtons( distribution, width, $( 0, CLEARANCE, distribution.buttonLen, height ) ),
|
|
||||||
$( distribution.buttonLen, CLEARANCE, distribution.upFastLength, height ),
|
|
||||||
calcDrag( distribution, $( distribution.dragStart, CLEARANCE, distribution.dragLength + balance, height ) ),
|
|
||||||
$( distribution.downFastStart, CLEARANCE, distribution.downFastLength - balance, height ),
|
|
||||||
calcButtons( distribution, width, $( distribution.downStart, CLEARANCE, distribution.buttonLen, height ) )
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private Rectangle calcButtons( ComponentDistribution distribution, int length, Rectangle bounds ) {
|
|
||||||
Rectangle result = bounds;
|
|
||||||
if( length <= distribution.buttonLen* 2 ) {
|
|
||||||
int downStart = calcDownStartForSmallLength( bounds.x, length );
|
|
||||||
result = $( downStart, CLEARANCE, length / 2, bounds.height );
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void setDefaultSize( Control control ) {
|
|
||||||
Point size = control.getSize();
|
|
||||||
control.setSize( size.x, FlatScrollBar.BAR_BREADTH );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Point computeSize( Composite composite, int wHint, int hHint, boolean changed ) {
|
|
||||||
int x = wHint == SWT.DEFAULT ? composite.getParent().getClientArea().width : wHint;
|
|
||||||
return new Point( x, FlatScrollBar.BAR_BREADTH );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void expand( Control control, int maxExpansion ) {
|
|
||||||
Rectangle bounds = control.getBounds();
|
|
||||||
int expand = expand( bounds.height, maxExpansion );
|
|
||||||
control.setBounds( bounds.x, bounds.y - expand, bounds.width, bounds.height + expand );
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
VERTICAL( SWT.VERTICAL ) {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void layout( FlatScrollBar scrollBar, int buttonLength ) {
|
|
||||||
ComponentDistribution calculation = calculateComponentDistribution( scrollBar, buttonLength );
|
|
||||||
applyComponentBounds( scrollBar, calculateComponentBounds( calculation, scrollBar ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
private ComponentDistribution calculateComponentDistribution( FlatScrollBar scrollBar, int buttonLength ) {
|
|
||||||
return calculateComponentDistribution( scrollBar, buttonLength, getControlBounds( scrollBar ).height );
|
|
||||||
}
|
|
||||||
|
|
||||||
private Rectangle[] calculateComponentBounds( ComponentDistribution distribution, FlatScrollBar scrollBar ) {
|
|
||||||
int width = getControlBounds( scrollBar ).width - FlatScrollBar.BAR_BREADTH + 1;
|
|
||||||
int height = getControlBounds( scrollBar ).height;
|
|
||||||
int balance = getRoundingBalance( distribution, scrollBar );
|
|
||||||
return new Rectangle[] {
|
|
||||||
calculateButtons( distribution, height, $( CLEARANCE, 0, width, distribution.buttonLen ) ),
|
|
||||||
$( CLEARANCE, distribution.buttonLen, width, distribution.upFastLength ),
|
|
||||||
calcDrag( distribution, $( CLEARANCE, distribution.dragStart, width, distribution.dragLength + balance ) ),
|
|
||||||
$( CLEARANCE, distribution.downFastStart, width, distribution.downFastLength - balance ),
|
|
||||||
calculateButtons( distribution, height, $( CLEARANCE, distribution.downStart, width, distribution.buttonLen ) )
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private Rectangle calculateButtons( ComponentDistribution distribution, int length, Rectangle bounds ) {
|
|
||||||
Rectangle result = bounds;
|
|
||||||
if( length <= distribution.buttonLen * 2 ) {
|
|
||||||
int downStart = calcDownStartForSmallLength( bounds.y, length );
|
|
||||||
result = $( CLEARANCE, downStart, bounds.width, length / 2 );
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void setDefaultSize( Control control ) {
|
|
||||||
Point size = control.getSize();
|
|
||||||
control.setSize( FlatScrollBar.BAR_BREADTH, size.y );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Point computeSize( Composite composite, int wHint, int hHint, boolean changed ) {
|
|
||||||
int y = hHint == SWT.DEFAULT ? composite.getParent().getClientArea().height : hHint;
|
|
||||||
return new Point( FlatScrollBar.BAR_BREADTH, y );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void expand( Control control, int maxExpansion ) {
|
|
||||||
Rectangle bounds = control.getBounds();
|
|
||||||
int expand = expand( bounds.width, maxExpansion );
|
|
||||||
control.setBounds( bounds.x - expand, bounds.y, bounds.width + expand, bounds.height );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static final Rectangle EMPTY_RECTANGLE = $( 0, 0, 0, 0 );
|
|
||||||
static final int CLEARANCE = BAR_BREADTH - 2;
|
|
||||||
|
|
||||||
private final int value;
|
|
||||||
|
|
||||||
protected abstract void layout( FlatScrollBar scrollBar, int buttonLength );
|
|
||||||
protected abstract void setDefaultSize( Control control );
|
|
||||||
protected abstract Point computeSize( Composite comp, int wHint, int hHint, boolean changed );
|
|
||||||
protected abstract void expand( Control control, int maxExpansion );
|
|
||||||
|
|
||||||
Direction( int value ) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int value() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ComponentDistribution calculateComponentDistribution(
|
|
||||||
FlatScrollBar scrollBar , int buttonLength , int length )
|
|
||||||
{
|
|
||||||
int range = scrollBar.getMaximum() - scrollBar.getMinimum();
|
|
||||||
int position = scrollBar.getSelection() - scrollBar.getMinimum();
|
|
||||||
int thumb = scrollBar.getThumb();
|
|
||||||
return new ComponentDistribution( buttonLength, length, range, position, thumb );
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Rectangle getControlBounds( FlatScrollBar scrollBar ) {
|
|
||||||
return scrollBar.getClientArea();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void applyComponentBounds( FlatScrollBar scrollBar, Rectangle[] bounds ) {
|
|
||||||
scrollBar.up.getControl().setBounds( bounds[ 0 ] );
|
|
||||||
scrollBar.upFast.getControl().setBounds( bounds[ 1 ] );
|
|
||||||
scrollBar.drag.getControl().setBounds( bounds[ 2 ] );
|
|
||||||
scrollBar.downFast.getControl().setBounds( bounds[ 3 ] );
|
|
||||||
scrollBar.down.getControl().setBounds( bounds[ 4 ] );
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO [fappel]: There is a 1 pixel rounding problem at the seam of drag/downFast with down.
|
|
||||||
// Seems to work but I would prefer a better solution if possible
|
|
||||||
private static int getRoundingBalance( ComponentDistribution calculation, FlatScrollBar scrollBar ) {
|
|
||||||
int result = 0;
|
|
||||||
int maximumSelection = scrollBar.getMaximum() - scrollBar.getThumb();
|
|
||||||
if( scrollBar.getSelection() == maximumSelection && 0 != calculation.downFastLength ) {
|
|
||||||
result = 1;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int expand( int toExpand, int maxExpansion ) {
|
|
||||||
return max( 0, FlatScrollBar.BAR_BREADTH + maxExpansion - max( FlatScrollBar.BAR_BREADTH, toExpand ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Rectangle calcDrag( ComponentDistribution distribution, Rectangle bounds ) {
|
|
||||||
Rectangle result = bounds;
|
|
||||||
if( isUndercutOfDragVisibility( distribution ) ) {
|
|
||||||
result = EMPTY_RECTANGLE;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isUndercutOfDragVisibility( ComponentDistribution distribution ) {
|
|
||||||
return distribution.dragLength + distribution.buttonLen >= distribution.downStart;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int calcDownStartForSmallLength( int position, int length ) {
|
|
||||||
int result = position;
|
|
||||||
if( isDownStartPosition( position ) ) {
|
|
||||||
result = length / 2;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
private static boolean isDownStartPosition( int position ) {
|
|
||||||
return position > 0 || position < 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Rectangle $( int x, int y, int width, int height ) {
|
|
||||||
return new Rectangle( x, y , width , height );
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,105 +0,0 @@
|
|||||||
package com.minres.scviewer.database.ui.swt.sb;
|
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.events.ControlAdapter;
|
|
||||||
import org.eclipse.swt.events.ControlEvent;
|
|
||||||
import org.eclipse.swt.events.DragDetectEvent;
|
|
||||||
import org.eclipse.swt.events.DragDetectListener;
|
|
||||||
import org.eclipse.swt.events.MouseEvent;
|
|
||||||
import org.eclipse.swt.events.MouseListener;
|
|
||||||
import org.eclipse.swt.events.MouseMoveListener;
|
|
||||||
import org.eclipse.swt.graphics.Color;
|
|
||||||
import org.eclipse.swt.graphics.Point;
|
|
||||||
import org.eclipse.swt.widgets.Composite;
|
|
||||||
import org.eclipse.swt.widgets.Label;
|
|
||||||
|
|
||||||
|
|
||||||
class DragControl
|
|
||||||
extends ControlAdapter
|
|
||||||
implements ViewComponent, DragDetectListener, MouseListener, MouseMoveListener
|
|
||||||
{
|
|
||||||
|
|
||||||
private final DragDetector dragDetector;
|
|
||||||
private final ImageUpdate imageUpdate;
|
|
||||||
private final DragAction dragAction;
|
|
||||||
private final Label control;
|
|
||||||
|
|
||||||
private Point startingPosition;
|
|
||||||
|
|
||||||
public interface DragAction {
|
|
||||||
void start();
|
|
||||||
void run( int startX, int startY, int currentX, int currentY );
|
|
||||||
void end();
|
|
||||||
}
|
|
||||||
|
|
||||||
DragControl( Composite parent, DragAction dragAction, int maxExpansion ) {
|
|
||||||
this.control = new Label( parent, SWT.NONE );
|
|
||||||
this.imageUpdate = new ImageUpdate( control, maxExpansion );
|
|
||||||
this.dragDetector = new DragDetector( control, 0 );
|
|
||||||
this.dragAction = dragAction;
|
|
||||||
initializeControl();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Label getControl() {
|
|
||||||
return control;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dragDetected( DragDetectEvent event ) {
|
|
||||||
if( startingPosition != null ) {
|
|
||||||
dragAction.run( startingPosition.x, startingPosition.y, event.x, event.y );
|
|
||||||
}
|
|
||||||
dragDetector.dragHandled();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseDown( MouseEvent event ) {
|
|
||||||
startingPosition = new Point( event.x, event.y );
|
|
||||||
dragAction.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseUp( MouseEvent event ) {
|
|
||||||
if( startingPosition != null ) {
|
|
||||||
dragAction.end();
|
|
||||||
}
|
|
||||||
startingPosition = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseMove( MouseEvent event ) {
|
|
||||||
dragDetector.mouseMove( event );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void controlResized( ControlEvent event ) {
|
|
||||||
imageUpdate.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void setForeground( Color color ) {
|
|
||||||
imageUpdate.setForeground( color );
|
|
||||||
}
|
|
||||||
|
|
||||||
Color getForeground() {
|
|
||||||
return imageUpdate.getForeground();
|
|
||||||
}
|
|
||||||
|
|
||||||
Color getBackground() {
|
|
||||||
return imageUpdate.getBackground();
|
|
||||||
}
|
|
||||||
|
|
||||||
void setBackground( Color color ) {
|
|
||||||
imageUpdate.setBackground( color );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initializeControl( ) {
|
|
||||||
control.addMouseListener( this );
|
|
||||||
control.addMouseMoveListener( this );
|
|
||||||
control.addControlListener( this );
|
|
||||||
control.addDragDetectListener( this );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseDoubleClick( MouseEvent event ) {}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
package com.minres.scviewer.database.ui.swt.sb;
|
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.events.MouseEvent;
|
|
||||||
import org.eclipse.swt.widgets.Control;
|
|
||||||
import org.eclipse.swt.widgets.Event;
|
|
||||||
|
|
||||||
// TODO [fappel]: This is a workaround for a problem described here:
|
|
||||||
// http://stackoverflow.com/questions/3908290/mousedown-events-are-not-delivered-until-mouseup-when-a-drag-source-is-present
|
|
||||||
// This seems to be related to https://bugs.eclipse.org/bugs/show_bug.cgi?id=328396
|
|
||||||
// which is resolved. As it did not work on my setup I adapted the workaround of the last
|
|
||||||
// stackoverflow answer.
|
|
||||||
|
|
||||||
public class DragDetector {
|
|
||||||
|
|
||||||
int lastMouseX;
|
|
||||||
int lastMouseY;
|
|
||||||
boolean dragEventGenerated;
|
|
||||||
|
|
||||||
private final Control control;
|
|
||||||
private final int sensibility;
|
|
||||||
|
|
||||||
public DragDetector( Control control, int sensibility ) {
|
|
||||||
this.control = control;
|
|
||||||
this.sensibility = sensibility;
|
|
||||||
this.control.setDragDetect( false );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void mouseMove( MouseEvent e ) {
|
|
||||||
if( ( e.stateMask & SWT.BUTTON1 ) > 0 ) {
|
|
||||||
int deltaX = lastMouseX - e.x;
|
|
||||||
int deltaY = lastMouseY - e.y;
|
|
||||||
int dragDistance = deltaX * deltaX + deltaY * deltaY;
|
|
||||||
if( !dragEventGenerated && dragDistance > sensibility ) {
|
|
||||||
dragEventGenerated = true;
|
|
||||||
Event event = createDragEvent( e );
|
|
||||||
control.notifyListeners( SWT.DragDetect, event );
|
|
||||||
}
|
|
||||||
lastMouseX = e.x;
|
|
||||||
lastMouseY = e.y;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dragHandled() {
|
|
||||||
dragEventGenerated = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Event createDragEvent( MouseEvent e ) {
|
|
||||||
Event event = new Event();
|
|
||||||
event.type = SWT.DragDetect;
|
|
||||||
event.display = control.getDisplay();
|
|
||||||
event.widget = control;
|
|
||||||
event.button = e.button;
|
|
||||||
event.stateMask = e.stateMask;
|
|
||||||
event.time = e.time;
|
|
||||||
event.x = e.x;
|
|
||||||
event.y = e.y;
|
|
||||||
return event;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,59 +0,0 @@
|
|||||||
package com.minres.scviewer.database.ui.swt.sb;
|
|
||||||
|
|
||||||
import static com.minres.scviewer.database.ui.swt.sb.Direction.HORIZONTAL;
|
|
||||||
import static com.minres.scviewer.database.ui.swt.sb.ShiftData.calculateSelectionRange;
|
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.graphics.Point;
|
|
||||||
|
|
||||||
import com.minres.scviewer.database.ui.swt.sb.DragControl.DragAction;
|
|
||||||
|
|
||||||
final class DragShifter implements DragAction {
|
|
||||||
|
|
||||||
private final FlatScrollBar scrollBar;
|
|
||||||
private final int buttonLength;
|
|
||||||
|
|
||||||
public DragShifter( FlatScrollBar scrollBar, int buttonLength ) {
|
|
||||||
this.scrollBar = scrollBar;
|
|
||||||
this.buttonLength = buttonLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void start() {
|
|
||||||
scrollBar.notifyListeners( SWT.DRAG );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run( int startX, int startY, int currentX, int currentY ) {
|
|
||||||
ShiftData shiftData = newShiftData( startX, startY, currentX, currentY );
|
|
||||||
if( shiftData.canShift() ) {
|
|
||||||
int selectionRange = calculateSelectionRange( scrollBar );
|
|
||||||
int selectionDelta = shiftData.calculateSelectionDelta( selectionRange );
|
|
||||||
int selection = scrollBar.getSelection() + selectionDelta;
|
|
||||||
scrollBar.setSelectionInternal( selection, SWT.DRAG );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void end() {
|
|
||||||
scrollBar.notifyListeners( SWT.NONE );
|
|
||||||
}
|
|
||||||
|
|
||||||
private ShiftData newShiftData( int startX, int startY, int currentX, int currentY ) {
|
|
||||||
ShiftData result;
|
|
||||||
if( scrollBar.direction == HORIZONTAL ) {
|
|
||||||
result = new ShiftData( buttonLength, getScrollBarSize().x, getDragSize().x, currentX - startX );
|
|
||||||
} else {
|
|
||||||
result = new ShiftData( buttonLength, getScrollBarSize().y, getDragSize().y, currentY - startY );
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Point getScrollBarSize() {
|
|
||||||
return scrollBar.getSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Point getDragSize() {
|
|
||||||
return scrollBar.drag.getControl().getSize();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
package com.minres.scviewer.database.ui.swt.sb;
|
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.graphics.Point;
|
|
||||||
import org.eclipse.swt.graphics.Rectangle;
|
|
||||||
import org.eclipse.swt.widgets.Display;
|
|
||||||
|
|
||||||
import com.minres.scviewer.database.ui.swt.sb.ClickControl.ClickAction;
|
|
||||||
|
|
||||||
class FastDecrementer implements ClickAction {
|
|
||||||
|
|
||||||
private final FlatScrollBar scrollBar;
|
|
||||||
|
|
||||||
private int x;
|
|
||||||
private int y;
|
|
||||||
|
|
||||||
FastDecrementer( FlatScrollBar scrollBar ) {
|
|
||||||
this.scrollBar = scrollBar;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Rectangle drag = getDragBounds();
|
|
||||||
Point mouse = getMouseLocation();
|
|
||||||
if( mouse.x <= drag.x || mouse.y <= drag.y ) {
|
|
||||||
int selection = scrollBar.getSelection() - scrollBar.getPageIncrement();
|
|
||||||
scrollBar.setSelectionInternal( selection, SWT.PAGE_UP );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCoordinates( int x, int y ) {
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Point getMouseLocation() {
|
|
||||||
return getDisplay().map( scrollBar.upFast.getControl(), null, x, y );
|
|
||||||
}
|
|
||||||
|
|
||||||
private Rectangle getDragBounds() {
|
|
||||||
Rectangle dragBounds = scrollBar.drag.getControl().getBounds();
|
|
||||||
return getDisplay().map( scrollBar, null, dragBounds );
|
|
||||||
}
|
|
||||||
|
|
||||||
private Display getDisplay() {
|
|
||||||
return scrollBar.getDisplay();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
package com.minres.scviewer.database.ui.swt.sb;
|
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.graphics.Point;
|
|
||||||
import org.eclipse.swt.graphics.Rectangle;
|
|
||||||
import org.eclipse.swt.widgets.Display;
|
|
||||||
|
|
||||||
import com.minres.scviewer.database.ui.swt.sb.ClickControl.ClickAction;
|
|
||||||
|
|
||||||
class FastIncrementer implements ClickAction {
|
|
||||||
|
|
||||||
private final FlatScrollBar scrollBar;
|
|
||||||
|
|
||||||
private Point mouse;
|
|
||||||
|
|
||||||
FastIncrementer( FlatScrollBar scrollBar ) {
|
|
||||||
this.scrollBar = scrollBar;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Rectangle drag = getDragBounds();
|
|
||||||
if( mouse.x > drag.x + drag.width || mouse.y > drag.y + drag.height ) {
|
|
||||||
int selection = scrollBar.getSelection() + scrollBar.getPageIncrement();
|
|
||||||
scrollBar.setSelectionInternal( selection, SWT.PAGE_DOWN );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCoordinates( int x, int y ) {
|
|
||||||
mouse = getMouseLocation( x, y );
|
|
||||||
}
|
|
||||||
|
|
||||||
private Point getMouseLocation(int x, int y) {
|
|
||||||
return Display.getCurrent().map( scrollBar.downFast.getControl(), null, x, y );
|
|
||||||
}
|
|
||||||
|
|
||||||
private Rectangle getDragBounds() {
|
|
||||||
Rectangle dragBounds = scrollBar.drag.getControl().getBounds();
|
|
||||||
return Display.getCurrent().map( scrollBar, null, dragBounds );
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,295 +0,0 @@
|
|||||||
package com.minres.scviewer.database.ui.swt.sb;
|
|
||||||
|
|
||||||
import static com.minres.scviewer.database.ui.swt.sb.UntypedSelectionAdapter.lookup;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
|
||||||
import org.eclipse.swt.events.SelectionListener;
|
|
||||||
import org.eclipse.swt.graphics.Color;
|
|
||||||
import org.eclipse.swt.widgets.Composite;
|
|
||||||
import org.eclipse.swt.widgets.Display;
|
|
||||||
import org.eclipse.swt.widgets.Event;
|
|
||||||
import org.eclipse.swt.widgets.Layout;
|
|
||||||
import org.eclipse.swt.widgets.Listener;
|
|
||||||
|
|
||||||
public class FlatScrollBar extends Composite {
|
|
||||||
|
|
||||||
public static final int BAR_BREADTH = 6;
|
|
||||||
|
|
||||||
static final int DEFAULT_MINIMUM = 0;
|
|
||||||
static final int DEFAULT_MAXIMUM = 100;
|
|
||||||
static final int DEFAULT_INCREMENT = 1;
|
|
||||||
static final int DEFAULT_THUMB = 10;
|
|
||||||
static final int DEFAULT_PAGE_INCREMENT = DEFAULT_THUMB;
|
|
||||||
static final int DEFAULT_SELECTION = 0;
|
|
||||||
static final int DEFAULT_BUTTON_LENGTH = 0;
|
|
||||||
static final int DEFAULT_MAX_EXPANSION = Direction.CLEARANCE + 2;
|
|
||||||
|
|
||||||
final ClickControl up;
|
|
||||||
final ClickControl upFast;
|
|
||||||
final DragControl drag;
|
|
||||||
final ClickControl downFast;
|
|
||||||
final ClickControl down;
|
|
||||||
final Direction direction;
|
|
||||||
final MouseWheelShifter mouseWheelHandler;
|
|
||||||
final Collection<SelectionListener> listeners;
|
|
||||||
|
|
||||||
private int minimum;
|
|
||||||
private int maximum;
|
|
||||||
private int increment;
|
|
||||||
private int pageIncrement;
|
|
||||||
private int thumb;
|
|
||||||
private int selection;
|
|
||||||
private boolean onDrag;
|
|
||||||
private int buttonLength;
|
|
||||||
|
|
||||||
public FlatScrollBar( final Composite parent, int style ) {
|
|
||||||
this( parent, style, DEFAULT_BUTTON_LENGTH, DEFAULT_MAX_EXPANSION );
|
|
||||||
}
|
|
||||||
|
|
||||||
FlatScrollBar( Composite parent, int style, int buttonLength, int maxExpansion ) {
|
|
||||||
super( parent, SWT.NONE );
|
|
||||||
super.setLayout( new FlatScrollBarLayout( getDirection( style ) ) );
|
|
||||||
this.minimum = DEFAULT_MINIMUM;
|
|
||||||
this.maximum = DEFAULT_MAXIMUM;
|
|
||||||
this.increment = DEFAULT_INCREMENT;
|
|
||||||
this.pageIncrement = DEFAULT_PAGE_INCREMENT;
|
|
||||||
this.thumb = DEFAULT_THUMB;
|
|
||||||
this.selection = DEFAULT_SELECTION;
|
|
||||||
this.buttonLength = buttonLength;
|
|
||||||
this.direction = getDirection( style );
|
|
||||||
this.direction.setDefaultSize( this );
|
|
||||||
this.up = new ClickControl( this, new Decrementer( this ), maxExpansion );
|
|
||||||
this.upFast = new ClickControl( this, new FastDecrementer( this ), maxExpansion );
|
|
||||||
this.drag = new DragControl( this, new DragShifter( this, buttonLength ), maxExpansion );
|
|
||||||
this.downFast = new ClickControl( this, new FastIncrementer( this ), maxExpansion );
|
|
||||||
this.down = new ClickControl( this, new Incrementer( this ), maxExpansion );
|
|
||||||
this.mouseWheelHandler = new MouseWheelShifter( this, parent, buttonLength );
|
|
||||||
this.listeners = new HashSet<SelectionListener>();
|
|
||||||
addMouseTrackListener( new MouseTracker( this, maxExpansion ) );
|
|
||||||
addControlListener( new ResizeObserver( this ) );
|
|
||||||
setDefaultColorScheme();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setLayout( Layout layout ) {
|
|
||||||
throw new UnsupportedOperationException( FlatScrollBar.class.getName() + " does not allow to change layout." );
|
|
||||||
};
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getStyle() {
|
|
||||||
return direction != null ? super.getStyle() | direction.value() : super.getStyle();
|
|
||||||
};
|
|
||||||
|
|
||||||
Direction getDirection() {
|
|
||||||
return direction;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMinimum( int minimum ) {
|
|
||||||
if( this.minimum != minimum && minimum >= 0 && minimum < maximum ) {
|
|
||||||
this.minimum = minimum;
|
|
||||||
adjustThumb();
|
|
||||||
adjustSelection();
|
|
||||||
layout();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMinimum() {
|
|
||||||
return minimum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMaximum( int maximum ) {
|
|
||||||
if( this.maximum != maximum && maximum >= 0 && maximum > minimum ) {
|
|
||||||
this.maximum = maximum;
|
|
||||||
adjustThumb();
|
|
||||||
adjustSelection();
|
|
||||||
layout();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMaximum() {
|
|
||||||
return maximum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setThumb( int thumb ) {
|
|
||||||
if( this.thumb != thumb && thumb >= 1 ) {
|
|
||||||
this.thumb = thumb;
|
|
||||||
adjustThumb();
|
|
||||||
adjustSelection();
|
|
||||||
layout();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getThumb() {
|
|
||||||
return thumb;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIncrement( int increment ) {
|
|
||||||
if( this.increment != increment ) {
|
|
||||||
this.increment = increment;
|
|
||||||
layout();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getIncrement() {
|
|
||||||
return increment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPageIncrement( int pageIncrement ) {
|
|
||||||
this.pageIncrement = pageIncrement;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPageIncrement() {
|
|
||||||
return pageIncrement;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSelection( int selection ) {
|
|
||||||
if( !onDrag ) {
|
|
||||||
updateSelection( selection );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSelection() {
|
|
||||||
return selection;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addSelectionListener( SelectionListener selectionListener ) {
|
|
||||||
listeners.add( selectionListener );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeSelectionListener( SelectionListener selectionListener ) {
|
|
||||||
listeners.remove( selectionListener );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addListener( int eventType, final Listener listener ) {
|
|
||||||
if( eventType == SWT.Selection ) {
|
|
||||||
addSelectionListener( new UntypedSelectionAdapter( listener ) );
|
|
||||||
} else {
|
|
||||||
super.addListener( eventType, listener );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeListener( int eventType, Listener listener ) {
|
|
||||||
if( eventType == SWT.Selection ) {
|
|
||||||
removeSelectionListener( lookup( listeners, listener ) );
|
|
||||||
} else {
|
|
||||||
super.removeListener( eventType, listener );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void layout() {
|
|
||||||
direction.layout( this, buttonLength );
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIncrementButtonLength( int length ) {
|
|
||||||
this.buttonLength = length;
|
|
||||||
layout();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getIncrementButtonLength() {
|
|
||||||
return buttonLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIncrementColor( Color color ) {
|
|
||||||
up.setForeground( color );
|
|
||||||
down.setForeground( color );
|
|
||||||
}
|
|
||||||
|
|
||||||
public Color getIncrementColor() {
|
|
||||||
return up.getForeground();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPageIncrementColor( Color color ) {
|
|
||||||
upFast.setForeground( color );
|
|
||||||
downFast.setForeground( color );
|
|
||||||
}
|
|
||||||
|
|
||||||
public Color getPageIncrementColor() {
|
|
||||||
return upFast.getForeground();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setThumbColor( Color color ) {
|
|
||||||
drag.setForeground( color );
|
|
||||||
}
|
|
||||||
|
|
||||||
public Color getThumbColor() {
|
|
||||||
return drag.getForeground();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBackground( Color color ) {
|
|
||||||
up.setBackground( color );
|
|
||||||
upFast.setBackground( color );
|
|
||||||
drag.setBackground( color );
|
|
||||||
downFast.setBackground( color );
|
|
||||||
down.setBackground( color );
|
|
||||||
super.setBackground( color );
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setSelectionInternal( int selection, int detail ) {
|
|
||||||
int oldSelection = this.selection;
|
|
||||||
updateSelection( selection );
|
|
||||||
if( oldSelection != this.selection ) {
|
|
||||||
notifyListeners( detail );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateSelection( int selection ) {
|
|
||||||
if( this.selection != selection ) {
|
|
||||||
this.selection = selection;
|
|
||||||
adjustSelection();
|
|
||||||
layout();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void notifyListeners( int detail ) {
|
|
||||||
updateOnDrag( detail );
|
|
||||||
SelectionEvent selectionEvent = createEvent( detail );
|
|
||||||
for( SelectionListener listener : listeners ) {
|
|
||||||
listener.widgetSelected( selectionEvent );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateOnDrag( int detail ) {
|
|
||||||
onDrag = ( onDrag || ( SWT.DRAG & detail ) > 0 ) && ( SWT.NONE != detail );
|
|
||||||
}
|
|
||||||
|
|
||||||
private SelectionEvent createEvent( int detail ) {
|
|
||||||
Event event = new Event();
|
|
||||||
event.widget = this;
|
|
||||||
event.detail = detail;
|
|
||||||
return new SelectionEvent( event );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void adjustThumb() {
|
|
||||||
if( thumb > maximum - minimum ) {
|
|
||||||
thumb = Math.min( maximum - minimum, thumb );
|
|
||||||
thumb = Math.max( 1, thumb );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void adjustSelection() {
|
|
||||||
selection = Math.min( selection, maximum - thumb );
|
|
||||||
selection = Math.max( selection, minimum );
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Direction getDirection( int style ) {
|
|
||||||
return ( style & SWT.HORIZONTAL ) > 0 ? Direction.HORIZONTAL : Direction.VERTICAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setDefaultColorScheme() {
|
|
||||||
up.setForeground( Display.getCurrent().getSystemColor( SWT.COLOR_WIDGET_NORMAL_SHADOW ) );
|
|
||||||
upFast.setForeground( Display.getCurrent().getSystemColor( SWT.COLOR_WIDGET_BACKGROUND ) );
|
|
||||||
drag.setForeground( Display.getCurrent().getSystemColor( SWT.COLOR_WIDGET_FOREGROUND ) );
|
|
||||||
downFast.setForeground( Display.getCurrent().getSystemColor( SWT.COLOR_WIDGET_BACKGROUND ) );
|
|
||||||
down.setForeground( Display.getCurrent().getSystemColor( SWT.COLOR_WIDGET_NORMAL_SHADOW ) );
|
|
||||||
setBackground( getBackground() );
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
package com.minres.scviewer.database.ui.swt.sb;
|
|
||||||
|
|
||||||
import org.eclipse.swt.graphics.Point;
|
|
||||||
import org.eclipse.swt.widgets.Composite;
|
|
||||||
import org.eclipse.swt.widgets.Layout;
|
|
||||||
|
|
||||||
class FlatScrollBarLayout extends Layout {
|
|
||||||
|
|
||||||
private final Direction direction;
|
|
||||||
|
|
||||||
public FlatScrollBarLayout( Direction orientation ) {
|
|
||||||
this.direction = orientation;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void layout( Composite composite, boolean flushCache ) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Point computeSize( Composite composite, int wHint, int hHint, boolean flushCache ) {
|
|
||||||
return direction.computeSize( composite, wHint, hHint, flushCache );
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,109 +0,0 @@
|
|||||||
package com.minres.scviewer.database.ui.swt.sb;
|
|
||||||
|
|
||||||
import static java.lang.Math.min;
|
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.graphics.Color;
|
|
||||||
import org.eclipse.swt.graphics.GC;
|
|
||||||
import org.eclipse.swt.graphics.Image;
|
|
||||||
import org.eclipse.swt.widgets.Display;
|
|
||||||
|
|
||||||
class ImageDrawer {
|
|
||||||
|
|
||||||
static final String IMAGE_DRAWER_IS_DISPOSED = "ImageDrawer is disposed.";
|
|
||||||
|
|
||||||
private final int maxExpansion;
|
|
||||||
|
|
||||||
private Color background;
|
|
||||||
private Color foreground;
|
|
||||||
|
|
||||||
ImageDrawer( int expansion ) {
|
|
||||||
this( expansion, getSystemColor( SWT.COLOR_WIDGET_DARK_SHADOW ), getSystemColor( SWT.COLOR_LIST_BACKGROUND ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
ImageDrawer( int expansion, Color background, Color foreground ) {
|
|
||||||
this.maxExpansion = expansion;
|
|
||||||
this.foreground = defensiveCopy( background );
|
|
||||||
this.background = defensiveCopy( foreground );
|
|
||||||
}
|
|
||||||
|
|
||||||
void setForeground( Color foreground ) {
|
|
||||||
checkDisposed();
|
|
||||||
if( foreground != null ) {
|
|
||||||
this.foreground = prepareColorAttribute( this.foreground, foreground );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Color getForeground() {
|
|
||||||
checkDisposed();
|
|
||||||
return foreground;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setBackground( Color background ) {
|
|
||||||
checkDisposed();
|
|
||||||
if( background != null ) {
|
|
||||||
this.background = prepareColorAttribute( this.background, background );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Color getBackground() {
|
|
||||||
checkDisposed();
|
|
||||||
return background;
|
|
||||||
}
|
|
||||||
|
|
||||||
Image draw( int width, int height ) {
|
|
||||||
checkDisposed();
|
|
||||||
Image result = new Image( getDisplay(), width, height );
|
|
||||||
GC gc = new GC( result );
|
|
||||||
try {
|
|
||||||
draw( gc, width, height );
|
|
||||||
} finally {
|
|
||||||
gc.dispose();
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean isDisposed() {
|
|
||||||
return background.isDisposed();
|
|
||||||
}
|
|
||||||
|
|
||||||
void dispose() {
|
|
||||||
if( !isDisposed() ) {
|
|
||||||
this.background.dispose();
|
|
||||||
this.foreground.dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void draw( GC gc, int width, int height ) {
|
|
||||||
gc.setBackground( background );
|
|
||||||
gc.fillRectangle( 0, 0, width, height );
|
|
||||||
gc.setBackground( foreground );
|
|
||||||
gc.setAdvanced( true );
|
|
||||||
gc.setAntialias( SWT.ON );
|
|
||||||
int arc = min( width, height ) == 1 ? 1 : maxExpansion + 2;
|
|
||||||
gc.fillRoundRectangle( 0, 0, width, height, arc, arc );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkDisposed() {
|
|
||||||
if( isDisposed() ) {
|
|
||||||
throw new IllegalStateException( IMAGE_DRAWER_IS_DISPOSED );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Color getSystemColor( int colorCode ) {
|
|
||||||
return getDisplay().getSystemColor( colorCode );
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Color prepareColorAttribute( Color oldColor, Color newColor ) {
|
|
||||||
oldColor.dispose();
|
|
||||||
return defensiveCopy( newColor );
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Color defensiveCopy( Color background ) {
|
|
||||||
return new Color( getDisplay(), background.getRGB() );
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Display getDisplay() {
|
|
||||||
return Display.getCurrent();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
package com.minres.scviewer.database.ui.swt.sb;
|
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.graphics.Color;
|
|
||||||
import org.eclipse.swt.graphics.Point;
|
|
||||||
import org.eclipse.swt.widgets.Label;
|
|
||||||
|
|
||||||
class ImageUpdate {
|
|
||||||
|
|
||||||
private final ImageDrawer imageDrawer;
|
|
||||||
private final Label control;
|
|
||||||
|
|
||||||
ImageUpdate( Label control, int maxExpansion ) {
|
|
||||||
this.imageDrawer = new ImageDrawer( maxExpansion );
|
|
||||||
this.control = control;
|
|
||||||
this.control.addListener( SWT.Dispose, evt -> imageDrawer.dispose() );
|
|
||||||
}
|
|
||||||
|
|
||||||
void setForeground( Color color ) {
|
|
||||||
imageDrawer.setForeground( color );
|
|
||||||
}
|
|
||||||
|
|
||||||
Color getForeground() {
|
|
||||||
return imageDrawer.getForeground();
|
|
||||||
}
|
|
||||||
|
|
||||||
void setBackground( Color color ) {
|
|
||||||
imageDrawer.setBackground( color );
|
|
||||||
}
|
|
||||||
|
|
||||||
Color getBackground() {
|
|
||||||
return imageDrawer.getBackground();
|
|
||||||
}
|
|
||||||
|
|
||||||
void update() {
|
|
||||||
if( !control.isDisposed() ) {
|
|
||||||
if( control.getImage() != null ) {
|
|
||||||
control.getImage().dispose();
|
|
||||||
}
|
|
||||||
Point size = control.getSize();
|
|
||||||
if( size.x > 0 && size.y > 0 ) {
|
|
||||||
control.setImage( imageDrawer.draw( size.x, size.y ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
package com.minres.scviewer.database.ui.swt.sb;
|
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
|
|
||||||
import com.minres.scviewer.database.ui.swt.sb.ClickControl.ClickAction;
|
|
||||||
|
|
||||||
class Incrementer implements ClickAction {
|
|
||||||
|
|
||||||
private final FlatScrollBar scrollBar;
|
|
||||||
|
|
||||||
Incrementer( FlatScrollBar scrollBar ) {
|
|
||||||
this.scrollBar = scrollBar;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
int selection = scrollBar.getSelection() + scrollBar.getIncrement();
|
|
||||||
scrollBar.setSelectionInternal( selection, SWT.ARROW_DOWN );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCoordinates( int x, int y ) {
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
package com.minres.scviewer.database.ui.swt.sb;
|
|
||||||
|
|
||||||
import org.eclipse.swt.widgets.Display;
|
|
||||||
|
|
||||||
public class MouseDownActionTimer implements Runnable {
|
|
||||||
|
|
||||||
public static final int INITIAL_DELAY = 300;
|
|
||||||
public static final int FAST_DELAY = 50;
|
|
||||||
|
|
||||||
private final ActionScheduler scheduler;
|
|
||||||
private final TimerAction timerAction;
|
|
||||||
private final ButtonClick mouseClick;
|
|
||||||
|
|
||||||
public interface TimerAction extends Runnable {
|
|
||||||
boolean isEnabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
public MouseDownActionTimer( TimerAction timerAction, ButtonClick mouseClick, Display display ) {
|
|
||||||
this.scheduler = new ActionScheduler( display, this );
|
|
||||||
this.timerAction = timerAction;
|
|
||||||
this.mouseClick = mouseClick;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void activate() {
|
|
||||||
if( timerAction.isEnabled() ) {
|
|
||||||
scheduler.schedule( INITIAL_DELAY );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if( mouseClick.isArmed() && timerAction.isEnabled() ) {
|
|
||||||
timerAction.run();
|
|
||||||
scheduler.schedule( FAST_DELAY );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,66 +0,0 @@
|
|||||||
package com.minres.scviewer.database.ui.swt.sb;
|
|
||||||
|
|
||||||
import org.eclipse.swt.events.DisposeEvent;
|
|
||||||
import org.eclipse.swt.events.DisposeListener;
|
|
||||||
import org.eclipse.swt.events.MouseEvent;
|
|
||||||
import org.eclipse.swt.events.MouseTrackAdapter;
|
|
||||||
import org.eclipse.swt.graphics.Rectangle;
|
|
||||||
import org.eclipse.swt.widgets.Display;
|
|
||||||
|
|
||||||
class MouseTracker extends MouseTrackAdapter implements Runnable, DisposeListener {
|
|
||||||
|
|
||||||
static final int DELAY = 500;
|
|
||||||
|
|
||||||
private final FlatScrollBar scrollBar;
|
|
||||||
private final int maxExpansion;
|
|
||||||
|
|
||||||
private Rectangle expandedBounds;
|
|
||||||
private Rectangle originBounds;
|
|
||||||
private boolean mouseOver;
|
|
||||||
private boolean disposed;
|
|
||||||
|
|
||||||
MouseTracker( FlatScrollBar scrollBar, int maxExpansion ) {
|
|
||||||
this.scrollBar = scrollBar;
|
|
||||||
this.maxExpansion = maxExpansion;
|
|
||||||
this.scrollBar.addDisposeListener( this );
|
|
||||||
this.scrollBar.up.getControl().addMouseTrackListener( this );
|
|
||||||
this.scrollBar.upFast.getControl().addMouseTrackListener( this );
|
|
||||||
this.scrollBar.drag.getControl().addMouseTrackListener( this );
|
|
||||||
this.scrollBar.downFast.getControl().addMouseTrackListener( this );
|
|
||||||
this.scrollBar.down.getControl().addMouseTrackListener( this );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseEnter( MouseEvent event ) {
|
|
||||||
mouseOver = true;
|
|
||||||
if( !disposed && originBounds == null ) {
|
|
||||||
originBounds = scrollBar.getBounds();
|
|
||||||
scrollBar.getDirection().expand( scrollBar, maxExpansion );
|
|
||||||
expandedBounds = scrollBar.getBounds();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseExit( MouseEvent event ) {
|
|
||||||
mouseOver = false;
|
|
||||||
if( !disposed ) {
|
|
||||||
Display.getCurrent().timerExec( DELAY, this );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if( !disposed && !mouseOver ) {
|
|
||||||
if( scrollBar.getBounds().equals( expandedBounds ) ) {
|
|
||||||
scrollBar.setBounds( originBounds );
|
|
||||||
}
|
|
||||||
originBounds = null;
|
|
||||||
expandedBounds = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void widgetDisposed( DisposeEvent e ) {
|
|
||||||
disposed = true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,69 +0,0 @@
|
|||||||
package com.minres.scviewer.database.ui.swt.sb;
|
|
||||||
|
|
||||||
import static com.minres.scviewer.database.ui.swt.sb.Direction.HORIZONTAL;
|
|
||||||
import static com.minres.scviewer.database.ui.swt.sb.ShiftData.calculateSelectionRange;
|
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.events.DisposeEvent;
|
|
||||||
import org.eclipse.swt.events.DisposeListener;
|
|
||||||
import org.eclipse.swt.graphics.Point;
|
|
||||||
import org.eclipse.swt.widgets.Composite;
|
|
||||||
import org.eclipse.swt.widgets.Event;
|
|
||||||
import org.eclipse.swt.widgets.Listener;
|
|
||||||
|
|
||||||
public class MouseWheelShifter implements Listener, DisposeListener {
|
|
||||||
|
|
||||||
private final FlatScrollBar scrollBar;
|
|
||||||
private final Composite parent;
|
|
||||||
private final int buttonLength;
|
|
||||||
|
|
||||||
MouseWheelShifter( FlatScrollBar scrollBar, Composite parent, int buttonLength ) {
|
|
||||||
this.scrollBar = scrollBar;
|
|
||||||
this.parent = parent;
|
|
||||||
this.buttonLength = buttonLength;
|
|
||||||
parent.addListener( getListenerType(), this );
|
|
||||||
scrollBar.addDisposeListener( this );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleEvent( Event event ) {
|
|
||||||
handleMouseWheelScroll( event );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void widgetDisposed( DisposeEvent e ) {
|
|
||||||
parent.removeListener( getListenerType(), this );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleMouseWheelScroll( Event event ) {
|
|
||||||
ShiftData shiftData = newShiftData( event.count );
|
|
||||||
if( shiftData.canShift() ) {
|
|
||||||
int selectionRange = calculateSelectionRange( scrollBar );
|
|
||||||
int selectionDelta = shiftData.calculateSelectionDelta( selectionRange );
|
|
||||||
int selection = scrollBar.getSelection() - selectionDelta;
|
|
||||||
scrollBar.setSelectionInternal( selection, scrollBar.direction.value() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private ShiftData newShiftData( int delta ) {
|
|
||||||
ShiftData result;
|
|
||||||
if( scrollBar.direction == Direction.HORIZONTAL ) {
|
|
||||||
result = new ShiftData( buttonLength, getScrollBarSize().x, getDragSize().x, delta );
|
|
||||||
} else {
|
|
||||||
result = new ShiftData( buttonLength, getScrollBarSize().y, getDragSize().y, delta );
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Point getScrollBarSize() {
|
|
||||||
return scrollBar.getSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Point getDragSize() {
|
|
||||||
return scrollBar.drag.getControl().getSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getListenerType() {
|
|
||||||
return scrollBar.direction == HORIZONTAL ? SWT.MouseHorizontalWheel: SWT.MouseVerticalWheel;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
package com.minres.scviewer.database.ui.swt.sb;
|
|
||||||
|
|
||||||
import org.eclipse.swt.events.ControlAdapter;
|
|
||||||
import org.eclipse.swt.events.ControlEvent;
|
|
||||||
|
|
||||||
class ResizeObserver extends ControlAdapter {
|
|
||||||
|
|
||||||
private final FlatScrollBar flatScrollBar;
|
|
||||||
|
|
||||||
public ResizeObserver( FlatScrollBar flatScrollBar ) {
|
|
||||||
this.flatScrollBar = flatScrollBar;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void controlResized( ControlEvent event ) {
|
|
||||||
flatScrollBar.layout();
|
|
||||||
flatScrollBar.moveAbove( null );
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
package com.minres.scviewer.database.ui.swt.sb;
|
|
||||||
|
|
||||||
import static com.minres.scviewer.database.ui.swt.sb.ComponentDistribution.divide;
|
|
||||||
|
|
||||||
class ShiftData {
|
|
||||||
|
|
||||||
private final int slidePixels;
|
|
||||||
private final int movedPixels;
|
|
||||||
private final int buttonLength;
|
|
||||||
|
|
||||||
ShiftData( int buttonLength, int scrollBarPixels, int dragPixels, int movedPixels ) {
|
|
||||||
this.buttonLength = buttonLength;
|
|
||||||
this.slidePixels = calculateSlidePixels( scrollBarPixels, dragPixels );
|
|
||||||
this.movedPixels = movedPixels;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean canShift( ) {
|
|
||||||
return slidePixels > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int calculateSelectionDelta( int selectionRange ) {
|
|
||||||
return divide( movedPixels * selectionRange, slidePixels );
|
|
||||||
}
|
|
||||||
|
|
||||||
static int calculateSelectionRange( FlatScrollBar scrollBar ) {
|
|
||||||
return scrollBar.getMaximum() - scrollBar.getMinimum() - scrollBar.getThumb();
|
|
||||||
}
|
|
||||||
|
|
||||||
private int calculateSlidePixels( int scrollBarPixels, int dragPixels ) {
|
|
||||||
return scrollBarPixels - 2 * buttonLength - dragPixels;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
package com.minres.scviewer.database.ui.swt.sb;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
import org.eclipse.swt.events.SelectionAdapter;
|
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
|
||||||
import org.eclipse.swt.events.SelectionListener;
|
|
||||||
import org.eclipse.swt.widgets.Event;
|
|
||||||
import org.eclipse.swt.widgets.Listener;
|
|
||||||
|
|
||||||
class UntypedSelectionAdapter extends SelectionAdapter {
|
|
||||||
|
|
||||||
final Listener listener;
|
|
||||||
|
|
||||||
UntypedSelectionAdapter( Listener listener ) {
|
|
||||||
this.listener = listener;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void widgetSelected( SelectionEvent selectionEvent ) {
|
|
||||||
Event event = new Event();
|
|
||||||
event.widget = selectionEvent.widget;
|
|
||||||
event.detail = selectionEvent.detail;
|
|
||||||
listener.handleEvent( event );
|
|
||||||
}
|
|
||||||
|
|
||||||
static SelectionListener lookup( Collection<SelectionListener> listeners, Listener untypedListener ) {
|
|
||||||
for( SelectionListener listener : listeners ) {
|
|
||||||
if( isAdapterType( listener ) && matches( untypedListener, listener ) ) {
|
|
||||||
return listener;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isAdapterType( SelectionListener listener ) {
|
|
||||||
return listener instanceof UntypedSelectionAdapter;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean matches( Listener untypedListener, SelectionListener listener ) {
|
|
||||||
return ( ( UntypedSelectionAdapter )listener ).listener == untypedListener;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
package com.minres.scviewer.database.ui.swt.sb;
|
|
||||||
|
|
||||||
import org.eclipse.swt.widgets.Control;
|
|
||||||
|
|
||||||
public interface ViewComponent {
|
|
||||||
Control getControl();
|
|
||||||
}
|
|
@ -29,14 +29,17 @@ import org.eclipse.swt.graphics.Rectangle;
|
|||||||
import org.eclipse.swt.widgets.Display;
|
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.
|
||||||
* <p>
|
* <p>
|
||||||
* !!! IMPORTANT !!! Application code must explicitly invoke the <code>dispose()</code> method to release the
|
* !!! IMPORTANT !!! Application code must explicitly invoke the
|
||||||
* operating system resources managed by cached objects when those objects and OS resources are no longer
|
* <code>dispose()</code> 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)
|
* needed (e.g. on application shutdown)
|
||||||
* <p>
|
* <p>
|
||||||
* This class may be freely distributed as part of any application or plugin.
|
* This class may be freely distributed as part of any application or plugin.
|
||||||
* <p>
|
* <p>
|
||||||
|
*
|
||||||
* @author scheglov_ke
|
* @author scheglov_ke
|
||||||
* @author Dan Rubel
|
* @author Dan Rubel
|
||||||
*/
|
*/
|
||||||
@ -46,57 +49,54 @@ public class SWTResourceManager {
|
|||||||
// Color
|
// Color
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
private static Map<RGB, Color> m_colorMap = new HashMap<RGB, Color>();
|
private static Map<RGB, Color> colorMap = new HashMap<>();
|
||||||
|
|
||||||
|
private SWTResourceManager() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the system {@link Color} matching the specific ID.
|
* Returns the system {@link Color} matching the specific ID.
|
||||||
*
|
*
|
||||||
* @param systemColorID
|
* @param systemColorID the ID value for the color
|
||||||
* the ID value for the color
|
|
||||||
* @return the system {@link Color} matching the specific ID
|
* @return the system {@link Color} matching the specific ID
|
||||||
*/
|
*/
|
||||||
public static Color getColor(int systemColorID) {
|
public static Color getColor(int systemColorID) {
|
||||||
Display display = Display.getCurrent();
|
Display display = Display.getCurrent();
|
||||||
return display.getSystemColor(systemColorID);
|
return display.getSystemColor(systemColorID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@link Color} given its red, green and blue component values.
|
* Returns a {@link Color} given its red, green and blue component values.
|
||||||
*
|
*
|
||||||
* @param r
|
* @param r the red component of the color
|
||||||
* the red component of the color
|
* @param g the green component of the color
|
||||||
* @param g
|
* @param b the blue component of the color
|
||||||
* the green component of the color
|
* @return the {@link Color} matching the given red, green and blue component
|
||||||
* @param b
|
* values
|
||||||
* 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) {
|
public static Color getColor(int r, int g, int b) {
|
||||||
return getColor(new RGB(r, g, b));
|
return getColor(new RGB(r, g, b));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@link Color} given its RGB value.
|
* Returns a {@link Color} given its RGB value.
|
||||||
*
|
*
|
||||||
* @param rgb
|
* @param rgb the {@link RGB} value of the color
|
||||||
* the {@link RGB} value of the color
|
|
||||||
* @return the {@link Color} matching the RGB value
|
* @return the {@link Color} matching the RGB value
|
||||||
*/
|
*/
|
||||||
public static Color getColor(RGB rgb) {
|
public static Color getColor(RGB rgb) {
|
||||||
Color color = m_colorMap.get(rgb);
|
return colorMap.computeIfAbsent(rgb, k -> new Color(Display.getCurrent(), 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.
|
* Dispose of all the cached {@link Color}'s.
|
||||||
*/
|
*/
|
||||||
public static void disposeColors() {
|
public static void disposeColors() {
|
||||||
for (Color color : m_colorMap.values()) {
|
for (Color color : colorMap.values()) {
|
||||||
color.dispose();
|
color.dispose();
|
||||||
}
|
}
|
||||||
m_colorMap.clear();
|
colorMap.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Image
|
// Image
|
||||||
@ -105,12 +105,12 @@ public class SWTResourceManager {
|
|||||||
/**
|
/**
|
||||||
* Maps image paths to images.
|
* Maps image paths to images.
|
||||||
*/
|
*/
|
||||||
private static Map<String, Image> m_imageMap = new HashMap<String, Image>();
|
private static Map<String, Image> imageMap = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an {@link Image} encoded by the specified {@link InputStream}.
|
* Returns an {@link Image} encoded by the specified {@link InputStream}.
|
||||||
*
|
*
|
||||||
* @param stream
|
* @param stream the {@link InputStream} encoding the image data
|
||||||
* the {@link InputStream} encoding the image data
|
|
||||||
* @return the {@link Image} encoded by the specified input stream
|
* @return the {@link Image} encoded by the specified input stream
|
||||||
*/
|
*/
|
||||||
protected static Image getImage(InputStream stream) throws IOException {
|
protected static Image getImage(InputStream stream) throws IOException {
|
||||||
@ -125,52 +125,55 @@ public class SWTResourceManager {
|
|||||||
stream.close();
|
stream.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an {@link Image} stored in the file at the specified path.
|
* Returns an {@link Image} stored in the file at the specified path.
|
||||||
*
|
*
|
||||||
* @param path
|
* @param path the path to the image file
|
||||||
* the path to the image file
|
|
||||||
* @return the {@link Image} stored in the file at the specified path
|
* @return the {@link Image} stored in the file at the specified path
|
||||||
*/
|
*/
|
||||||
public static Image getImage(String path) {
|
public static Image getImage(String path) {
|
||||||
Image image = m_imageMap.get(path);
|
Image image = imageMap.get(path);
|
||||||
if (image == null) {
|
if (image == null) {
|
||||||
try {
|
try {
|
||||||
image = getImage(new FileInputStream(path));
|
image = getImage(new FileInputStream(path));
|
||||||
m_imageMap.put(path, image);
|
imageMap.put(path, image);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
image = getMissingImage();
|
image = getMissingImage();
|
||||||
m_imageMap.put(path, image);
|
imageMap.put(path, image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 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
|
* @param clazz the {@link Class} relative to which to find the image
|
||||||
* the {@link Class} relative to which to find the image
|
* @param path the path to the image file, if starts with <code>'/'</code>
|
||||||
* @param path
|
|
||||||
* the path to the image file, if starts with <code>'/'</code>
|
|
||||||
* @return the {@link Image} stored in the file at the specified path
|
* @return the {@link Image} stored in the file at the specified path
|
||||||
*/
|
*/
|
||||||
public static Image getImage(Class<?> clazz, String path) {
|
public static Image getImage(Class<?> clazz, String path) {
|
||||||
String key = clazz.getName() + '|' + path;
|
String key = clazz.getName() + '|' + path;
|
||||||
Image image = m_imageMap.get(key);
|
Image image = imageMap.get(key);
|
||||||
if (image == null) {
|
if (image == null) {
|
||||||
try {
|
try {
|
||||||
image = getImage(clazz.getResourceAsStream(path));
|
image = getImage(clazz.getResourceAsStream(path));
|
||||||
m_imageMap.put(key, image);
|
imageMap.put(key, image);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
image = getMissingImage();
|
image = getMissingImage();
|
||||||
m_imageMap.put(key, image);
|
imageMap.put(key, image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int MISSING_IMAGE_SIZE = 10;
|
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() {
|
private static Image getMissingImage() {
|
||||||
Image image = new Image(Display.getCurrent(), MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE);
|
Image image = new Image(Display.getCurrent(), MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE);
|
||||||
@ -182,6 +185,7 @@ public class SWTResourceManager {
|
|||||||
//
|
//
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Style constant for placing decorator image in top left corner of base 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;
|
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;
|
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;
|
public static final int BOTTOM_RIGHT = 4;
|
||||||
/**
|
/**
|
||||||
@ -206,83 +212,77 @@ public class SWTResourceManager {
|
|||||||
* Maps images to decorated images.
|
* Maps images to decorated images.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private static Map<Image, Map<Image, Image>>[] m_decoratedImageMap = new Map[LAST_CORNER_KEY];
|
private static Map<Image, Map<Image, Image>>[] decoratedImageMap = new Map[LAST_CORNER_KEY];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an {@link Image} composed of a base image decorated by another image.
|
* Returns an {@link Image} composed of a base image decorated by another image.
|
||||||
*
|
*
|
||||||
* @param baseImage
|
* @param baseImage the base {@link Image} that should be decorated
|
||||||
* the base {@link Image} that should be decorated
|
* @param decorator the {@link Image} to decorate the base image
|
||||||
* @param decorator
|
|
||||||
* the {@link Image} to decorate the base image
|
|
||||||
* @return {@link Image} The resulting decorated image
|
* @return {@link Image} The resulting decorated image
|
||||||
*/
|
*/
|
||||||
public static Image decorateImage(Image baseImage, Image decorator) {
|
public static Image decorateImage(Image baseImage, Image decorator) {
|
||||||
return decorateImage(baseImage, decorator, BOTTOM_RIGHT);
|
return decorateImage(baseImage, decorator, BOTTOM_RIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an {@link Image} composed of a base image decorated by another image.
|
* Returns an {@link Image} composed of a base image decorated by another image.
|
||||||
*
|
*
|
||||||
* @param baseImage
|
* @param baseImage the base {@link Image} that should be decorated
|
||||||
* the base {@link Image} that should be decorated
|
* @param decorator the {@link Image} to decorate the base image
|
||||||
* @param decorator
|
* @param corner the corner to place decorator image
|
||||||
* the {@link Image} to decorate the base image
|
|
||||||
* @param corner
|
|
||||||
* the corner to place decorator image
|
|
||||||
* @return the resulting decorated {@link Image}
|
* @return the resulting decorated {@link Image}
|
||||||
*/
|
*/
|
||||||
public static Image decorateImage(final Image baseImage, final Image decorator, final int corner) {
|
public static Image decorateImage(final Image baseImage, final Image decorator, final int corner) {
|
||||||
if (corner <= 0 || corner >= LAST_CORNER_KEY) {
|
if (corner <= 0 || corner >= LAST_CORNER_KEY) {
|
||||||
throw new IllegalArgumentException("Wrong decorate corner");
|
throw new IllegalArgumentException("Wrong decorate corner");
|
||||||
}
|
}
|
||||||
Map<Image, Map<Image, Image>> cornerDecoratedImageMap = m_decoratedImageMap[corner];
|
Map<Image, Map<Image, Image>> cornerDecoratedImageMap = decoratedImageMap[corner];
|
||||||
if (cornerDecoratedImageMap == null) {
|
if (cornerDecoratedImageMap == null) {
|
||||||
cornerDecoratedImageMap = new HashMap<Image, Map<Image, Image>>();
|
cornerDecoratedImageMap = new HashMap<>();
|
||||||
m_decoratedImageMap[corner] = cornerDecoratedImageMap;
|
decoratedImageMap[corner] = cornerDecoratedImageMap;
|
||||||
}
|
}
|
||||||
Map<Image, Image> decoratedMap = cornerDecoratedImageMap.get(baseImage);
|
Map<Image, Image> decoratedMap = cornerDecoratedImageMap.computeIfAbsent(baseImage,
|
||||||
if (decoratedMap == null) {
|
k -> new HashMap<Image, Image>());
|
||||||
decoratedMap = new HashMap<Image, Image>();
|
return decoratedMap.computeIfAbsent(decorator, k -> {
|
||||||
cornerDecoratedImageMap.put(baseImage, decoratedMap);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
Image result = decoratedMap.get(decorator);
|
|
||||||
if (result == null) {
|
|
||||||
Rectangle bib = baseImage.getBounds();
|
Rectangle bib = baseImage.getBounds();
|
||||||
Rectangle dib = decorator.getBounds();
|
Rectangle dib = decorator.getBounds();
|
||||||
//
|
Image result = new Image(Display.getCurrent(), bib.width, bib.height);
|
||||||
result = new Image(Display.getCurrent(), bib.width, bib.height);
|
|
||||||
//
|
|
||||||
GC gc = new GC(result);
|
GC gc = new GC(result);
|
||||||
gc.drawImage(baseImage, 0, 0);
|
gc.drawImage(baseImage, 0, 0);
|
||||||
if (corner == TOP_LEFT) {
|
switch (corner) {
|
||||||
|
case TOP_LEFT:
|
||||||
gc.drawImage(decorator, 0, 0);
|
gc.drawImage(decorator, 0, 0);
|
||||||
} else if (corner == TOP_RIGHT) {
|
break;
|
||||||
|
case TOP_RIGHT:
|
||||||
gc.drawImage(decorator, bib.width - dib.width, 0);
|
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);
|
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);
|
gc.drawImage(decorator, bib.width - dib.width, bib.height - dib.height);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// do nothing
|
||||||
}
|
}
|
||||||
gc.dispose();
|
gc.dispose();
|
||||||
//
|
|
||||||
decoratedMap.put(decorator, result);
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dispose all of the cached {@link Image}'s.
|
* Dispose all of the cached {@link Image}'s.
|
||||||
*/
|
*/
|
||||||
public static void disposeImages() {
|
public static void disposeImages() {
|
||||||
// dispose loaded images
|
// dispose loaded images
|
||||||
{
|
for (Image image : imageMap.values()) {
|
||||||
for (Image image : m_imageMap.values()) {
|
|
||||||
image.dispose();
|
image.dispose();
|
||||||
}
|
}
|
||||||
m_imageMap.clear();
|
imageMap.clear();
|
||||||
}
|
|
||||||
// dispose decorated images
|
// dispose decorated images
|
||||||
for (int i = 0; i < m_decoratedImageMap.length; i++) {
|
for (int i = 0; i < decoratedImageMap.length; i++) {
|
||||||
Map<Image, Map<Image, Image>> cornerDecoratedImageMap = m_decoratedImageMap[i];
|
Map<Image, Map<Image, Image>> cornerDecoratedImageMap = decoratedImageMap[i];
|
||||||
if (cornerDecoratedImageMap != null) {
|
if (cornerDecoratedImageMap != null) {
|
||||||
for (Map<Image, Image> decoratedMap : cornerDecoratedImageMap.values()) {
|
for (Map<Image, Image> decoratedMap : cornerDecoratedImageMap.values()) {
|
||||||
for (Image image : decoratedMap.values()) {
|
for (Image image : decoratedMap.values()) {
|
||||||
@ -294,6 +294,7 @@ public class SWTResourceManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Font
|
// Font
|
||||||
@ -302,45 +303,39 @@ public class SWTResourceManager {
|
|||||||
/**
|
/**
|
||||||
* Maps font names to fonts.
|
* Maps font names to fonts.
|
||||||
*/
|
*/
|
||||||
private static Map<String, Font> m_fontMap = new HashMap<String, Font>();
|
private static Map<String, Font> fontMap = new HashMap<>();
|
||||||
/**
|
/**
|
||||||
* Maps fonts to their bold versions.
|
* Maps fonts to their bold versions.
|
||||||
*/
|
*/
|
||||||
private static Map<Font, Font> m_fontToBoldFontMap = new HashMap<Font, Font>();
|
private static Map<Font, Font> fontToBoldFontMap = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@link Font} based on its name, height and style.
|
* Returns a {@link Font} based on its name, height and style.
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name the name of the font
|
||||||
* the name of the font
|
* @param height the height of the font
|
||||||
* @param height
|
* @param style the style of the font
|
||||||
* the height of the font
|
|
||||||
* @param style
|
|
||||||
* the style of the font
|
|
||||||
* @return {@link Font} The font matching the name, height and style
|
* @return {@link Font} The font matching the name, height and style
|
||||||
*/
|
*/
|
||||||
public static Font getFont(String name, int height, int style) {
|
public static Font getFont(String name, int height, int style) {
|
||||||
return getFont(name, height, style, false, false);
|
return getFont(name, height, style, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@link Font} based on its name, height and style. Windows-specific strikeout and underline
|
* Returns a {@link Font} based on its name, height and style. Windows-specific
|
||||||
* flags are also supported.
|
* strikeout and underline flags are also supported.
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name the name of the font
|
||||||
* the name of the font
|
* @param size the size of the font
|
||||||
* @param size
|
* @param style the style of the font
|
||||||
* the size of the font
|
* @param strikeout the strikeout flag (warning: Windows only)
|
||||||
* @param style
|
* @param underline the underline flag (warning: Windows only)
|
||||||
* the style of the font
|
* @return {@link Font} The font matching the name, height, style, strikeout and
|
||||||
* @param strikeout
|
* underline
|
||||||
* 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) {
|
public static Font getFont(String name, int size, int style, boolean strikeout, boolean underline) {
|
||||||
String fontName = name + '|' + size + '|' + style + '|' + strikeout + '|' + underline;
|
String fontName = name + '|' + size + '|' + style + '|' + strikeout + '|' + underline;
|
||||||
Font font = m_fontMap.get(fontName);
|
return fontMap.computeIfAbsent(fontName, k -> {
|
||||||
if (font == null) {
|
|
||||||
FontData fontData = new FontData(name, size, style);
|
FontData fontData = new FontData(name, size, style);
|
||||||
if (strikeout || underline) {
|
if (strikeout || underline) {
|
||||||
try {
|
try {
|
||||||
@ -354,47 +349,45 @@ public class SWTResourceManager {
|
|||||||
logFontClass.getField("lfUnderline").set(logFont, Byte.valueOf((byte) 1)); //$NON-NLS-1$
|
logFontClass.getField("lfUnderline").set(logFont, Byte.valueOf((byte) 1)); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Exception 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);
|
return new Font(Display.getCurrent(), fontData);
|
||||||
m_fontMap.put(fontName, font);
|
|
||||||
}
|
});
|
||||||
return font;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a bold version of the given {@link Font}.
|
* Returns a bold version of the given {@link Font}.
|
||||||
*
|
*
|
||||||
* @param baseFont
|
* @param baseFont the {@link Font} for which a bold version is desired
|
||||||
* the {@link Font} for which a bold version is desired
|
|
||||||
* @return the bold version of the given {@link Font}
|
* @return the bold version of the given {@link Font}
|
||||||
*/
|
*/
|
||||||
public static Font getBoldFont(Font baseFont) {
|
public static Font getBoldFont(Font baseFont) {
|
||||||
Font font = m_fontToBoldFontMap.get(baseFont);
|
return fontToBoldFontMap.computeIfAbsent(baseFont, k -> {
|
||||||
if (font == null) {
|
FontData[] fontDatas = baseFont.getFontData();
|
||||||
FontData fontDatas[] = baseFont.getFontData();
|
|
||||||
FontData data = fontDatas[0];
|
FontData data = fontDatas[0];
|
||||||
font = new Font(Display.getCurrent(), data.getName(), data.getHeight(), SWT.BOLD);
|
return 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.
|
* Dispose all of the cached {@link Font}'s.
|
||||||
*/
|
*/
|
||||||
public static void disposeFonts() {
|
public static void disposeFonts() {
|
||||||
// clear fonts
|
// clear fonts
|
||||||
for (Font font : m_fontMap.values()) {
|
for (Font font : fontMap.values()) {
|
||||||
font.dispose();
|
font.dispose();
|
||||||
}
|
}
|
||||||
m_fontMap.clear();
|
fontMap.clear();
|
||||||
// clear bold fonts
|
// clear bold fonts
|
||||||
for (Font font : m_fontToBoldFontMap.values()) {
|
for (Font font : fontToBoldFontMap.values()) {
|
||||||
font.dispose();
|
font.dispose();
|
||||||
}
|
}
|
||||||
m_fontToBoldFontMap.clear();
|
fontToBoldFontMap.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Cursor
|
// Cursor
|
||||||
@ -403,40 +396,38 @@ public class SWTResourceManager {
|
|||||||
/**
|
/**
|
||||||
* Maps IDs to cursors.
|
* Maps IDs to cursors.
|
||||||
*/
|
*/
|
||||||
private static Map<Integer, Cursor> m_idToCursorMap = new HashMap<Integer, Cursor>();
|
private static Map<Integer, Cursor> idToCursorMap = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the system cursor matching the specific ID.
|
* Returns the system cursor matching the specific ID.
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id int The ID value for the cursor
|
||||||
* int The ID value for the cursor
|
|
||||||
* @return Cursor The system cursor matching the specific ID
|
* @return Cursor The system cursor matching the specific ID
|
||||||
*/
|
*/
|
||||||
public static Cursor getCursor(int id) {
|
public static Cursor getCursor(int id) {
|
||||||
Integer key = Integer.valueOf(id);
|
Integer key = Integer.valueOf(id);
|
||||||
Cursor cursor = m_idToCursorMap.get(key);
|
return idToCursorMap.computeIfAbsent(key, k -> new Cursor(Display.getDefault(), id));
|
||||||
if (cursor == null) {
|
|
||||||
cursor = new Cursor(Display.getDefault(), id);
|
|
||||||
m_idToCursorMap.put(key, cursor);
|
|
||||||
}
|
|
||||||
return cursor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dispose all of the cached cursors.
|
* Dispose all of the cached cursors.
|
||||||
*/
|
*/
|
||||||
public static void disposeCursors() {
|
public static void disposeCursors() {
|
||||||
for (Cursor cursor : m_idToCursorMap.values()) {
|
for (Cursor cursor : idToCursorMap.values()) {
|
||||||
cursor.dispose();
|
cursor.dispose();
|
||||||
}
|
}
|
||||||
m_idToCursorMap.clear();
|
idToCursorMap.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// General
|
// General
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
/**
|
/**
|
||||||
* Dispose of cached objects and their underlying OS resources. This should only be called when the cached
|
* Dispose of cached objects and their underlying OS resources. This should only
|
||||||
* objects are no longer needed (e.g. on application shutdown).
|
* be called when the cached objects are no longer needed (e.g. on application
|
||||||
|
* shutdown).
|
||||||
*/
|
*/
|
||||||
public static void dispose() {
|
public static void dispose() {
|
||||||
disposeColors();
|
disposeColors();
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.minres.scviewer</groupId>
|
<groupId>com.minres.scviewer</groupId>
|
||||||
<artifactId>com.minres.scviewer.parent</artifactId>
|
<artifactId>com.minres.scviewer.parent</artifactId>
|
||||||
<version>2.15.1</version>
|
<version>2.14.1</version>
|
||||||
<relativePath>../..</relativePath>
|
<relativePath>../../..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<packaging>eclipse-plugin</packaging>
|
<packaging>eclipse-plugin</packaging>
|
||||||
</project>
|
</project>
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.minres.scviewer</groupId>
|
<groupId>com.minres.scviewer</groupId>
|
||||||
<artifactId>com.minres.scviewer.parent</artifactId>
|
<artifactId>com.minres.scviewer.parent</artifactId>
|
||||||
<version>2.15.1</version>
|
<version>2.14.1</version>
|
||||||
<relativePath>../..</relativePath>
|
<relativePath>../../..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<packaging>eclipse-plugin</packaging>
|
<packaging>eclipse-plugin</packaging>
|
||||||
<version>4.0.0-SNAPSHOT</version>
|
<version>4.0.0-SNAPSHOT</version>
|
||||||
|
@ -12,19 +12,18 @@
|
|||||||
<children xsi:type="basic:Part" xmi:id="_hXh-kEYFEeyPM8G0E2EYww" elementId="com.minres.scviewer.e4.application.dialog.onlinehelp" toBeRendered="false" visible="false" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.parts.HelpDialog" label="SCViewer Online Help" bindingContexts="_95Pfu3NmEeWBq8z1Dv39LA" closeable="true"/>
|
<children xsi:type="basic:Part" xmi:id="_hXh-kEYFEeyPM8G0E2EYww" elementId="com.minres.scviewer.e4.application.dialog.onlinehelp" toBeRendered="false" visible="false" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.parts.HelpDialog" label="SCViewer Online Help" bindingContexts="_95Pfu3NmEeWBq8z1Dv39LA" closeable="true"/>
|
||||||
<mainMenu xmi:id="_95PfyXNmEeWBq8z1Dv39LA" elementId="menu:org.eclipse.ui.main.menu">
|
<mainMenu xmi:id="_95PfyXNmEeWBq8z1Dv39LA" elementId="menu:org.eclipse.ui.main.menu">
|
||||||
<children xsi:type="menu:Menu" xmi:id="_95QGwHNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.menu.file" label="File">
|
<children xsi:type="menu:Menu" xmi:id="_95QGwHNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.menu.file" label="File">
|
||||||
<children xsi:type="menu:HandledMenuItem" xmi:id="_igsK0BkREeudD5MqrWoETQ" elementId="" label="Open Database" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/folder_database.png" mnemonics="" command="_95PfwHNmEeWBq8z1Dv39LA"/>
|
<children xsi:type="menu:HandledMenuItem" xmi:id="_igsK0BkREeudD5MqrWoETQ" elementId="" label="Open Database" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/folder_database.png" mnemonics="M1+O" command="_95PfwHNmEeWBq8z1Dv39LA"/>
|
||||||
<children xsi:type="menu:HandledMenuItem" xmi:id="_VJG3YHgvEeWwZ-9vrAR2UQ" elementId="" label="Re-load Database" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/database_refresh.png" mnemonics="" command="_srACsBkREeudD5MqrWoETQ"/>
|
<children xsi:type="menu:HandledMenuItem" xmi:id="_VJG3YHgvEeWwZ-9vrAR2UQ" elementId="" label="Re-load Database" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/database_refresh.png" mnemonics="M1+R" command="_srACsBkREeudD5MqrWoETQ"/>
|
||||||
<children xsi:type="menu:HandledMenuItem" xmi:id="_e7MOYJedEeW09eyIbHsdvg" elementId="" label="Load active tab settings" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/folder_page.png" command="_7-AIMJebEeW09eyIbHsdvg">
|
<children xsi:type="menu:HandledMenuItem" xmi:id="_e7MOYJedEeW09eyIbHsdvg" elementId="" label="Load active tab settings" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/folder_page.png" command="_7-AIMJebEeW09eyIbHsdvg">
|
||||||
<parameters xmi:id="_4vtYgJehEeW09eyIbHsdvg" elementId="com.minres.scviewer.e4.application.parameter.30" name="com.minres.scviewer.e4.application.commandparameter.loadStore" value="load"/>
|
<parameters xmi:id="_4vtYgJehEeW09eyIbHsdvg" elementId="com.minres.scviewer.e4.application.parameter.30" name="com.minres.scviewer.e4.application.commandparameter.loadStore" value="load"/>
|
||||||
</children>
|
</children>
|
||||||
<children xsi:type="menu:HandledMenuItem" xmi:id="_95QGwnNmEeWBq8z1Dv39LA" label="Save active tab settings" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/script_save.png" mnemonics="" command="_7-AIMJebEeW09eyIbHsdvg">
|
<children xsi:type="menu:HandledMenuItem" xmi:id="_95QGwnNmEeWBq8z1Dv39LA" label="Save active tab settings" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/script_save.png" command="_7-AIMJebEeW09eyIbHsdvg">
|
||||||
<parameters xmi:id="_61QIsJehEeW09eyIbHsdvg" elementId="com.minres.scviewer.e4.application.parameter.31" name="com.minres.scviewer.e4.application.commandparameter.loadStore" value="store"/>
|
<parameters xmi:id="_61QIsJehEeW09eyIbHsdvg" elementId="com.minres.scviewer.e4.application.parameter.31" name="com.minres.scviewer.e4.application.commandparameter.loadStore" value="store"/>
|
||||||
</children>
|
</children>
|
||||||
<children xsi:type="menu:HandledMenuItem" xmi:id="_95QGw3NmEeWBq8z1Dv39LA" label="Quit" command="_95PfvHNmEeWBq8z1Dv39LA"/>
|
<children xsi:type="menu:HandledMenuItem" xmi:id="_95QGw3NmEeWBq8z1Dv39LA" label="Quit" command="_95PfvHNmEeWBq8z1Dv39LA"/>
|
||||||
</children>
|
</children>
|
||||||
<children xsi:type="menu:Menu" xmi:id="_ZyHC0HgvEeWwZ-9vrAR2UQ" elementId="" label="Edit">
|
<children xsi:type="menu:Menu" xmi:id="_ZyHC0HgvEeWwZ-9vrAR2UQ" elementId="" label="Edit">
|
||||||
<children xsi:type="menu:HandledMenuItem" xmi:id="_FiwZcEhdEeyp3vLifEzGbQ" elementId="com.minres.scviewer.e4.application.handledmenuitem.delete" label="Delete" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/cross.png" command="_WUZ2wHXHEeWwZ-9vrAR2UQ"/>
|
<children xsi:type="menu:HandledMenuItem" xmi:id="_cPlx4HgvEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledmenuitem.delete" label="Delete" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/cross.png" command="_WUZ2wHXHEeWwZ-9vrAR2UQ"/>
|
||||||
<children xsi:type="menu:HandledMenuItem" xmi:id="_cPlx4HgvEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledmenuitem.delete" label="Select All" iconURI="" command="_bV-TMHXHEeWwZ-9vrAR2UQ"/>
|
|
||||||
</children>
|
</children>
|
||||||
<children xsi:type="menu:Menu" xmi:id="_XmZY4HchEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.menu.navigate" label="Navigate">
|
<children xsi:type="menu:Menu" xmi:id="_XmZY4HchEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.menu.navigate" label="Navigate">
|
||||||
<children xsi:type="menu:Menu" xmi:id="_VCn_cHgwEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.menu.waveform" label="Waveform ...">
|
<children xsi:type="menu:Menu" xmi:id="_VCn_cHgwEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.menu.waveform" label="Waveform ...">
|
||||||
@ -81,6 +80,41 @@
|
|||||||
<children xsi:type="menu:HandledToolItem" xmi:id="_FrGmEHcjEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledtoolitem.movestreamdown" label="Move Stream down" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/down_blue.png" tooltip="Move stream/waveform in list down" command="_N_sOkHXHEeWwZ-9vrAR2UQ">
|
<children xsi:type="menu:HandledToolItem" xmi:id="_FrGmEHcjEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledtoolitem.movestreamdown" label="Move Stream down" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/down_blue.png" tooltip="Move stream/waveform in list down" command="_N_sOkHXHEeWwZ-9vrAR2UQ">
|
||||||
<parameters xmi:id="_VA_yAHcjEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.parameter.9" name="com.minres.scviewer.e4.application.command.movewaveformupCommand.parameter.dir" value="down"/>
|
<parameters xmi:id="_VA_yAHcjEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.parameter.9" name="com.minres.scviewer.e4.application.command.movewaveformupCommand.parameter.dir" value="down"/>
|
||||||
</children>
|
</children>
|
||||||
|
<children xsi:type="menu:ToolBarSeparator" xmi:id="_srcD0HgwEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.toolbarseparator.3"/>
|
||||||
|
<children xsi:type="menu:HandledToolItem" xmi:id="_GKi7IHcjEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledtoolitem.previousevent" label="Previous Event" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/reverse_blue.png" tooltip="Navigate to previous event in stream/waveform" command="_79rx4HabEeWwZ-9vrAR2UQ">
|
||||||
|
<parameters xmi:id="_XS7YYHcjEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.parameter.10" name="com.minres.scviewer.e4.application.command.navigateEventCommand.parameter.dir" value="prev"/>
|
||||||
|
</children>
|
||||||
|
<children xsi:type="menu:HandledToolItem" xmi:id="_GjlGMHcjEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledtoolitem.nextevent" label="Next Event" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/play_blue.png" tooltip="Navigate to next event in stream/waveform" command="_79rx4HabEeWwZ-9vrAR2UQ">
|
||||||
|
<parameters xmi:id="_ZzTqcHcjEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.parameter.11" name="com.minres.scviewer.e4.application.command.navigateEventCommand.parameter.dir" value="next"/>
|
||||||
|
</children>
|
||||||
|
<children xsi:type="menu:ToolBarSeparator" xmi:id="_tcxaIHgwEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.toolbarseparator.4"/>
|
||||||
|
<children xsi:type="menu:HandledToolItem" xmi:id="_HdKZkHcjEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledtoolitem.previoustransaction" label="Previous Transaction" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/reverse_green.png" tooltip="Navigate to previous transaction" command="_Gn3lEHXKEeWwZ-9vrAR2UQ">
|
||||||
|
<parameters xmi:id="_cuGAkHcjEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.parameter.12" name="com.minres.scviewer.e4.application.command.navigateTransCommand.parameter.dir" value="prev"/>
|
||||||
|
</children>
|
||||||
|
<children xsi:type="menu:ToolControl" xmi:id="_LtQhcIuKEeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.toolcontrol.0" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.elements.RelationTypeToolControl"/>
|
||||||
|
<children xsi:type="menu:DirectToolItem" xmi:id="_Z7ZQkIuJEeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.directtoolitem.nextprevinstream" toBeRendered="false" visible="false" label="Next/Prev in stream">
|
||||||
|
<menu xmi:id="_aPyMMIuJEeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.menu.2">
|
||||||
|
<children xsi:type="menu:DynamicMenuContribution" xmi:id="_cnNWkIuJEeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.dynamicmenucontribution.2" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.parts.NavigateContribution"/>
|
||||||
|
</menu>
|
||||||
|
</children>
|
||||||
|
<children xsi:type="menu:HandledToolItem" xmi:id="_H7bp8HcjEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledtoolitem.nexttransaction" label="Next Transaction" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/play_green.png" tooltip="Navigate to next transaction" command="_Gn3lEHXKEeWwZ-9vrAR2UQ">
|
||||||
|
<parameters xmi:id="_fiO8IHcjEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.parameter.13" name="com.minres.scviewer.e4.application.command.navigateTransCommand.parameter.dir" value="next"/>
|
||||||
|
</children>
|
||||||
|
</children>
|
||||||
|
<children xsi:type="menu:ToolBar" xmi:id="_oQdMUHcqEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.toolbar.1">
|
||||||
|
<children xsi:type="menu:HandledToolItem" xmi:id="_LFGfsEZEEeyKK_icsY7Xjg" elementId="com.minres.scviewer.e4.application.handledtoolitem.zoomfull" label="Zoom full" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/zoom_full.png" tooltip="Zoom full range" command="_693GoHcqEeWwZ-9vrAR2UQ">
|
||||||
|
<parameters xmi:id="_LFGfsUZEEeyKK_icsY7Xjg" elementId="com.minres.scviewer.e4.application.parameter.full" name="com.minres.scviewer.e4.application.command.zoomcommand.parameter.level" value="full"/>
|
||||||
|
</children>
|
||||||
|
<children xsi:type="menu:HandledToolItem" xmi:id="_5DrGQHf4EeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledtoolitem.zoomfit" label="Zoom fit" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/zoom_fit.png" tooltip="Zoom between cursor and marker" command="_693GoHcqEeWwZ-9vrAR2UQ">
|
||||||
|
<parameters xmi:id="_5DrGQXf4EeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.parameter.fit" name="com.minres.scviewer.e4.application.command.zoomcommand.parameter.level" value="fit"/>
|
||||||
|
</children>
|
||||||
|
<children xsi:type="menu:ToolBarSeparator" xmi:id="_p1AvUHcqEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.toolbarseparator.1"/>
|
||||||
|
<children xsi:type="menu:HandledToolItem" xmi:id="_XMQPAHcrEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledtoolitem.zoomin" label="Zoom in" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/magnifier_zoom_in.png" tooltip="Zoom in by a factor of 3" command="_693GoHcqEeWwZ-9vrAR2UQ">
|
||||||
|
<parameters xmi:id="_fi5w4HcrEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.parameter.in" name="com.minres.scviewer.e4.application.command.zoomcommand.parameter.level" value="in"/>
|
||||||
|
</children>
|
||||||
|
<children xsi:type="menu:HandledToolItem" xmi:id="_XqTc8HcrEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledtoolitem.zoomout" label="Zoom out" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/magifier_zoom_out.png" tooltip="Zoom out by a factor of 3" command="_693GoHcqEeWwZ-9vrAR2UQ">
|
||||||
|
<parameters xmi:id="_d7OBYHcrEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.parameter.out" name="com.minres.scviewer.e4.application.command.zoomcommand.parameter.level" value="out"/>
|
||||||
|
</children>
|
||||||
</children>
|
</children>
|
||||||
<children xsi:type="menu:ToolBar" xmi:id="_fwn8wGtTEeqmlpoaaMHoiw" elementId="com.minres.scviewer.e4.application.toolbar.2">
|
<children xsi:type="menu:ToolBar" xmi:id="_fwn8wGtTEeqmlpoaaMHoiw" elementId="com.minres.scviewer.e4.application.toolbar.2">
|
||||||
<children xsi:type="menu:HandledToolItem" xmi:id="_j-XIgGtTEeqmlpoaaMHoiw" elementId="com.minres.scviewer.e4.application.handledtoolitem.txdetails" label="TX Details" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/application_side_expand.png" tooltip="Show tx details parts" selected="true" type="Check" command="_Fj1gQEYoEeyKK_icsY7Xjg">
|
<children xsi:type="menu:HandledToolItem" xmi:id="_j-XIgGtTEeqmlpoaaMHoiw" elementId="com.minres.scviewer.e4.application.handledtoolitem.txdetails" label="TX Details" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/application_side_expand.png" tooltip="Show tx details parts" selected="true" type="Check" command="_Fj1gQEYoEeyKK_icsY7Xjg">
|
||||||
@ -100,6 +134,9 @@
|
|||||||
</children>
|
</children>
|
||||||
</trimBars>
|
</trimBars>
|
||||||
</children>
|
</children>
|
||||||
|
<children xsi:type="basic:Window" xmi:id="_Gm0qAEamEeyPDuc8x6Ggxw" elementId="com.minres.scviewer.e4.application.window.help" toBeRendered="false" selectedElement="_M5eT0EamEeyPDuc8x6Ggxw" label="SC Viewer Help" width="800" height="600">
|
||||||
|
<children xsi:type="basic:Part" xmi:id="_M5eT0EamEeyPDuc8x6Ggxw" elementId="com.minres.scviewer.e4.application.part.container" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.parts.help.HelpBrowser"/>
|
||||||
|
</children>
|
||||||
<handlers xmi:id="_95PfvXNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.handler.quitCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.QuitHandler" command="_95PfvHNmEeWBq8z1Dv39LA"/>
|
<handlers xmi:id="_95PfvXNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.handler.quitCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.QuitHandler" command="_95PfvHNmEeWBq8z1Dv39LA"/>
|
||||||
<handlers xmi:id="_95PfwXNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.handler.openCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.OpenHandler" command="_95PfwHNmEeWBq8z1Dv39LA"/>
|
<handlers xmi:id="_95PfwXNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.handler.openCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.OpenHandler" command="_95PfwHNmEeWBq8z1Dv39LA"/>
|
||||||
<handlers xmi:id="_95PfxHNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.handler.saveCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.SaveHandler" command="_95Pfw3NmEeWBq8z1Dv39LA"/>
|
<handlers xmi:id="_95PfxHNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.handler.saveCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.SaveHandler" command="_95Pfw3NmEeWBq8z1Dv39LA"/>
|
||||||
@ -119,7 +156,16 @@
|
|||||||
<bindings xmi:id="_95Pfv3NmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.keybinding.quit" keySequence="M1+Q" command="_95PfvHNmEeWBq8z1Dv39LA">
|
<bindings xmi:id="_95Pfv3NmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.keybinding.quit" keySequence="M1+Q" command="_95PfvHNmEeWBq8z1Dv39LA">
|
||||||
<tags>type:user</tags>
|
<tags>type:user</tags>
|
||||||
</bindings>
|
</bindings>
|
||||||
<bindings xmi:id="_2-008EhnEeyp3vLifEzGbQ" elementId="com.minres.scviewer.e4.application.keybinding.help" keySequence="F1" command="_lqjIYEYEEeyPM8G0E2EYww"/>
|
</bindingTables>
|
||||||
|
<bindingTables xmi:id="_zZFy0GVNEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.bindingtable.waveform" bindingContext="_q4VSsGVNEeqSQM-A6dw9ig">
|
||||||
|
<bindings xmi:id="_1o3dEGVNEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.keybinding.zoom_in" keySequence="M1++" command="_693GoHcqEeWwZ-9vrAR2UQ">
|
||||||
|
<tags>type:user</tags>
|
||||||
|
<parameters xmi:id="_53UagGVNEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.parameter.33" name="com.minres.scviewer.e4.application.command.zoomcommand.parameter.level" value="in"/>
|
||||||
|
</bindings>
|
||||||
|
<bindings xmi:id="_8i3awGVNEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.keybinding.zoom_out" keySequence="M1+-" command="_693GoHcqEeWwZ-9vrAR2UQ">
|
||||||
|
<tags>type:user</tags>
|
||||||
|
<parameters xmi:id="__UCh4GVNEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.parameter.34" name="com.minres.scviewer.e4.application.command.zoomcommand.parameter.level" value="out"/>
|
||||||
|
</bindings>
|
||||||
</bindingTables>
|
</bindingTables>
|
||||||
<bindingTables xmi:id="_XullMGVOEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.bindingtable.window" bindingContext="_95PfunNmEeWBq8z1Dv39LA">
|
<bindingTables xmi:id="_XullMGVOEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.bindingtable.window" bindingContext="_95PfunNmEeWBq8z1Dv39LA">
|
||||||
<bindings xmi:id="_95PfwnNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.keybinding.load" keySequence="M1+L" command="_7-AIMJebEeW09eyIbHsdvg">
|
<bindings xmi:id="_95PfwnNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.keybinding.load" keySequence="M1+L" command="_7-AIMJebEeW09eyIbHsdvg">
|
||||||
@ -136,22 +182,20 @@
|
|||||||
<bindings xmi:id="_3PRIQGVPEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.keybinding.open" keySequence="M1+O" command="_95PfwHNmEeWBq8z1Dv39LA">
|
<bindings xmi:id="_3PRIQGVPEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.keybinding.open" keySequence="M1+O" command="_95PfwHNmEeWBq8z1Dv39LA">
|
||||||
<tags>type:user</tags>
|
<tags>type:user</tags>
|
||||||
</bindings>
|
</bindings>
|
||||||
<bindings xmi:id="_QcOn8EheEeyp3vLifEzGbQ" elementId="com.minres.scviewer.e4.application.keybinding.1" keySequence="M1+A" command="_bV-TMHXHEeWwZ-9vrAR2UQ"/>
|
</bindingTables>
|
||||||
<bindings xmi:id="_1o3dEGVNEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.keybinding.zoom_in" keySequence="M1++" command="_693GoHcqEeWwZ-9vrAR2UQ">
|
<bindingTables xmi:id="_mnMrUGVmEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.bindingtable.0" bindingContext="_iQ3kQGVmEeqSQM-A6dw9ig">
|
||||||
|
<bindings xmi:id="_n9yDwGVmEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.keybinding.0" keySequence="M1+A" command="_bV-TMHXHEeWwZ-9vrAR2UQ">
|
||||||
<tags>type:user</tags>
|
<tags>type:user</tags>
|
||||||
<parameters xmi:id="_53UagGVNEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.parameter.33" name="com.minres.scviewer.e4.application.command.zoomcommand.parameter.level" value="in"/>
|
|
||||||
</bindings>
|
</bindings>
|
||||||
<bindings xmi:id="_8i3awGVNEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.keybinding.zoom_out" keySequence="M1+-" command="_693GoHcqEeWwZ-9vrAR2UQ">
|
|
||||||
<tags>type:user</tags>
|
|
||||||
<parameters xmi:id="__UCh4GVNEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.parameter.34" name="com.minres.scviewer.e4.application.command.zoomcommand.parameter.level" value="out"/>
|
|
||||||
</bindings>
|
|
||||||
<bindings xmi:id="_KjmnsEheEeyp3vLifEzGbQ" elementId="com.minres.scviewer.e4.application.keybinding.0" keySequence="M1+R" command="_srACsBkREeudD5MqrWoETQ"/>
|
|
||||||
</bindingTables>
|
</bindingTables>
|
||||||
<rootContext xmi:id="_95PfuXNmEeWBq8z1Dv39LA" elementId="org.eclipse.ui.contexts.dialogAndWindow" name="In Dialog and Windows">
|
<rootContext xmi:id="_95PfuXNmEeWBq8z1Dv39LA" elementId="org.eclipse.ui.contexts.dialogAndWindow" name="In Dialog and Windows">
|
||||||
<children xmi:id="_95PfunNmEeWBq8z1Dv39LA" elementId="org.eclipse.ui.contexts.window" name="In Windows"/>
|
<children xmi:id="_95PfunNmEeWBq8z1Dv39LA" elementId="org.eclipse.ui.contexts.window" name="In Windows">
|
||||||
|
<children xmi:id="_q4VSsGVNEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.bindingcontext.waveform" name="In Waveform Part"/>
|
||||||
|
<children xmi:id="_iQ3kQGVmEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.bindingcontext.indesignbrowser" name="In DesignBrowser"/>
|
||||||
|
</children>
|
||||||
<children xmi:id="_95Pfu3NmEeWBq8z1Dv39LA" elementId="org.eclipse.ui.contexts.dialog" name="In Dialogs"/>
|
<children xmi:id="_95Pfu3NmEeWBq8z1Dv39LA" elementId="org.eclipse.ui.contexts.dialog" name="In Dialogs"/>
|
||||||
</rootContext>
|
</rootContext>
|
||||||
<descriptors xmi:id="_KicY0HRMEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.partdescriptor.waveformviewer" label="SCViewer" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/scviewer.png" allowMultiple="true" category="General" closeable="true" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.parts.WaveformViewer">
|
<descriptors xmi:id="_KicY0HRMEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.partdescriptor.waveformviewer" label="SCViewer" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/scviewer.png" bindingContexts="_q4VSsGVNEeqSQM-A6dw9ig" allowMultiple="true" category="General" closeable="true" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.parts.WaveformViewer">
|
||||||
<tags>categoryTag:General</tags>
|
<tags>categoryTag:General</tags>
|
||||||
<handlers xmi:id="_BSIuEHacEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handler.navigateEventCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.NavigateEvent" command="_79rx4HabEeWwZ-9vrAR2UQ"/>
|
<handlers xmi:id="_BSIuEHacEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handler.navigateEventCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.NavigateEvent" command="_79rx4HabEeWwZ-9vrAR2UQ"/>
|
||||||
<handlers xmi:id="_JpdGwHXKEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handler.navigateTransCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.NavigateTrans" command="_Gn3lEHXKEeWwZ-9vrAR2UQ"/>
|
<handlers xmi:id="_JpdGwHXKEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handler.navigateTransCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.NavigateTrans" command="_Gn3lEHXKEeWwZ-9vrAR2UQ"/>
|
||||||
@ -160,7 +204,6 @@
|
|||||||
<handlers xmi:id="_Du1NAHcrEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handler.zoomCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.ZoomHandler" command="_693GoHcqEeWwZ-9vrAR2UQ"/>
|
<handlers xmi:id="_Du1NAHcrEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handler.zoomCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.ZoomHandler" command="_693GoHcqEeWwZ-9vrAR2UQ"/>
|
||||||
<handlers xmi:id="_bxt4QM3rEei6rfTGo88R-w" elementId="com.minres.scviewer.e4.application.handler.changeWaveDisplay" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.ChangeWaveformDisplay" command="_FZunYM2PEei6rfTGo88R-w"/>
|
<handlers xmi:id="_bxt4QM3rEei6rfTGo88R-w" elementId="com.minres.scviewer.e4.application.handler.changeWaveDisplay" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.ChangeWaveformDisplay" command="_FZunYM2PEei6rfTGo88R-w"/>
|
||||||
<handlers xmi:id="_bxw7kM3rEei6rfTGo88R-w" elementId="com.minres.scviewer.e4.application.handler.changeValueDisplay" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.ChangeValueDisplay" command="_4C_asM3ZEei6rfTGo88R-w"/>
|
<handlers xmi:id="_bxw7kM3rEei6rfTGo88R-w" elementId="com.minres.scviewer.e4.application.handler.changeValueDisplay" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.ChangeValueDisplay" command="_4C_asM3ZEei6rfTGo88R-w"/>
|
||||||
<handlers xmi:id="_ZVHbYE-JEeyuGJbYVZjX8w" elementId="com.minres.scviewer.e4.application.handler.panCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.PanHandler" command="_y2BUsE-HEeyuGJbYVZjX8w"/>
|
|
||||||
<menus xsi:type="menu:PopupMenu" xmi:id="_TwzrsHWSEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.popupmenu.namecontext" label="Name Menu">
|
<menus xsi:type="menu:PopupMenu" xmi:id="_TwzrsHWSEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.popupmenu.namecontext" label="Name Menu">
|
||||||
<children xsi:type="menu:HandledMenuItem" xmi:id="_Vco7YHWSEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledmenuitem.moveup" label="Move up" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/up_blue.png" tooltip="Move stream/waveform in list up" command="_N_sOkHXHEeWwZ-9vrAR2UQ">
|
<children xsi:type="menu:HandledMenuItem" xmi:id="_Vco7YHWSEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledmenuitem.moveup" label="Move up" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/up_blue.png" tooltip="Move stream/waveform in list up" command="_N_sOkHXHEeWwZ-9vrAR2UQ">
|
||||||
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_elFdcHr_EeWVM_sKoXvptg" coreExpressionId="com.minres.scviewer.e4.application.oneWaveSeleted"/>
|
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_elFdcHr_EeWVM_sKoXvptg" coreExpressionId="com.minres.scviewer.e4.application.oneWaveSeleted"/>
|
||||||
@ -207,50 +250,7 @@
|
|||||||
<visibleWhen xsi:type="ui:ImperativeExpression" xmi:id="_Se1voBlEEeuiP60JNw0iiA" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.SearchHandler"/>
|
<visibleWhen xsi:type="ui:ImperativeExpression" xmi:id="_Se1voBlEEeuiP60JNw0iiA" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.SearchHandler"/>
|
||||||
</children>
|
</children>
|
||||||
</menus>
|
</menus>
|
||||||
<toolbar xmi:id="_ReeeAE-DEeyuGJbYVZjX8w" elementId="com.minres.scviewer.e4.application.toolbar.3">
|
|
||||||
<children xsi:type="menu:HandledToolItem" xmi:id="_GKi7IHcjEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledtoolitem.previousevent" label="Previous Event" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/previous-green.png" tooltip="Navigate to previous event in stream/waveform" command="_79rx4HabEeWwZ-9vrAR2UQ">
|
|
||||||
<parameters xmi:id="_XS7YYHcjEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.parameter.10" name="com.minres.scviewer.e4.application.command.navigateEventCommand.parameter.dir" value="prev"/>
|
|
||||||
</children>
|
|
||||||
<children xsi:type="menu:HandledToolItem" xmi:id="_GjlGMHcjEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledtoolitem.nextevent" label="Next Event" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/next-green.png" tooltip="Navigate to next event in stream/waveform" command="_79rx4HabEeWwZ-9vrAR2UQ">
|
|
||||||
<parameters xmi:id="_ZzTqcHcjEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.parameter.11" name="com.minres.scviewer.e4.application.command.navigateEventCommand.parameter.dir" value="next"/>
|
|
||||||
</children>
|
|
||||||
<children xsi:type="menu:ToolBarSeparator" xmi:id="_tcxaIHgwEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.toolbarseparator.4"/>
|
|
||||||
<children xsi:type="menu:HandledToolItem" xmi:id="_HdKZkHcjEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledtoolitem.previoustransaction" label="Previous Transaction" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/reverse_green.png" tooltip="Navigate to previous transaction" command="_Gn3lEHXKEeWwZ-9vrAR2UQ">
|
|
||||||
<parameters xmi:id="_cuGAkHcjEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.parameter.12" name="com.minres.scviewer.e4.application.command.navigateTransCommand.parameter.dir" value="prev"/>
|
|
||||||
</children>
|
|
||||||
<children xsi:type="menu:ToolControl" xmi:id="_LtQhcIuKEeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.toolcontrol.0" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.elements.RelationTypeToolControl"/>
|
|
||||||
<children xsi:type="menu:HandledToolItem" xmi:id="_H7bp8HcjEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledtoolitem.nexttransaction" label="Next Transaction" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/play_green.png" tooltip="Navigate to next transaction" command="_Gn3lEHXKEeWwZ-9vrAR2UQ">
|
|
||||||
<parameters xmi:id="_fiO8IHcjEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.parameter.13" name="com.minres.scviewer.e4.application.command.navigateTransCommand.parameter.dir" value="next"/>
|
|
||||||
</children>
|
|
||||||
<children xsi:type="menu:ToolBarSeparator" xmi:id="_dOLmYE-DEeyuGJbYVZjX8w" elementId="com.minres.scviewer.e4.application.toolbarseparator.0"/>
|
|
||||||
<children xsi:type="menu:HandledToolItem" xmi:id="_dPFBcE-HEeyuGJbYVZjX8w" elementId="com.minres.scviewer.e4.application.handledtoolitem.panleft" label="Pan left" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/reverse_blue.png" tooltip="Pan left" command="_y2BUsE-HEeyuGJbYVZjX8w">
|
|
||||||
<parameters xmi:id="_jkVBYE-JEeyuGJbYVZjX8w" elementId="com.minres.scviewer.e4.application.parameter.14" name="com.minres.scviewer.e4.application.command.pancommand.parameter.direction" value="left"/>
|
|
||||||
</children>
|
|
||||||
<children xsi:type="menu:HandledToolItem" xmi:id="_Z-blgE-GEeyuGJbYVZjX8w" elementId="com.minres.scviewer.e4.application.handledtoolitem.pancursor" label="Pan to cursor" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/center_blue.png" tooltip="Center on cursor" command="_y2BUsE-HEeyuGJbYVZjX8w">
|
|
||||||
<parameters xmi:id="_Z-blgU-GEeyuGJbYVZjX8w" elementId="com.minres.scviewer.e4.application.parameter.out" name="com.minres.scviewer.e4.application.command.pancommand.parameter.direction" value="cursor"/>
|
|
||||||
</children>
|
|
||||||
<children xsi:type="menu:HandledToolItem" xmi:id="_ejt5IE-HEeyuGJbYVZjX8w" elementId="com.minres.scviewer.e4.application.handledtoolitem.panright" label="Pan right" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/play_blue.png" tooltip="Pan right" command="_y2BUsE-HEeyuGJbYVZjX8w">
|
|
||||||
<parameters xmi:id="_f4awUE-JEeyuGJbYVZjX8w" elementId="com.minres.scviewer.e4.application.parameter.out" name="com.minres.scviewer.e4.application.command.pancommand.parameter.direction" value="right"/>
|
|
||||||
</children>
|
|
||||||
<children xsi:type="menu:ToolBarSeparator" xmi:id="_b7RFoE-GEeyuGJbYVZjX8w" elementId="com.minres.scviewer.e4.application.toolbarseparator.1"/>
|
|
||||||
<children xsi:type="menu:HandledToolItem" xmi:id="_qA5D4E-DEeyuGJbYVZjX8w" elementId="com.minres.scviewer.e4.application.handledtoolitem.zoomfull" label="Zoom full" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/zoom_full.png" tooltip="Zoom full range" command="_693GoHcqEeWwZ-9vrAR2UQ">
|
|
||||||
<parameters xmi:id="_qA5D4U-DEeyuGJbYVZjX8w" elementId="com.minres.scviewer.e4.application.parameter.full" name="com.minres.scviewer.e4.application.command.zoomcommand.parameter.level" value="full"/>
|
|
||||||
</children>
|
|
||||||
<children xsi:type="menu:HandledToolItem" xmi:id="_qA65EE-DEeyuGJbYVZjX8w" elementId="com.minres.scviewer.e4.application.handledtoolitem.zoomfit" label="Zoom fit" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/zoom_fit.png" tooltip="Zoom between cursor and marker" command="_693GoHcqEeWwZ-9vrAR2UQ">
|
|
||||||
<parameters xmi:id="_qA65EU-DEeyuGJbYVZjX8w" elementId="com.minres.scviewer.e4.application.parameter.fit" name="com.minres.scviewer.e4.application.command.zoomcommand.parameter.level" value="fit"/>
|
|
||||||
</children>
|
|
||||||
<children xsi:type="menu:ToolBarSeparator" xmi:id="_qA8HME-DEeyuGJbYVZjX8w" elementId="com.minres.scviewer.e4.application.toolbarseparator.1"/>
|
|
||||||
<children xsi:type="menu:HandledToolItem" xmi:id="_qA8uQE-DEeyuGJbYVZjX8w" elementId="com.minres.scviewer.e4.application.handledtoolitem.zoomin" label="Zoom in" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/magnifier_zoom_in.png" tooltip="Zoom in" command="_693GoHcqEeWwZ-9vrAR2UQ">
|
|
||||||
<parameters xmi:id="_qA8uQU-DEeyuGJbYVZjX8w" elementId="com.minres.scviewer.e4.application.parameter.in" name="com.minres.scviewer.e4.application.command.zoomcommand.parameter.level" value="in"/>
|
|
||||||
</children>
|
|
||||||
<children xsi:type="menu:HandledToolItem" xmi:id="_qA98YE-DEeyuGJbYVZjX8w" elementId="com.minres.scviewer.e4.application.handledtoolitem.zoomout" label="Zoom out" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/magifier_zoom_out.png" tooltip="Zoom out" command="_693GoHcqEeWwZ-9vrAR2UQ">
|
|
||||||
<parameters xmi:id="_qA98YU-DEeyuGJbYVZjX8w" elementId="com.minres.scviewer.e4.application.parameter.out" name="com.minres.scviewer.e4.application.command.zoomcommand.parameter.level" value="out"/>
|
|
||||||
</children>
|
|
||||||
</toolbar>
|
|
||||||
</descriptors>
|
</descriptors>
|
||||||
<snippets xsi:type="basic:Window" xmi:id="_R8mJUEhwEeyp3vLifEzGbQ" elementId="com.minres.scviewer.e4.application.window.help" selectedElement="_R8mJUUhwEeyp3vLifEzGbQ" label="SC Viewer Help" width="800" height="600">
|
|
||||||
<children xsi:type="basic:Part" xmi:id="_R8mJUUhwEeyp3vLifEzGbQ" elementId="com.minres.scviewer.e4.application.part.container" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.parts.help.HelpBrowser"/>
|
|
||||||
</snippets>
|
|
||||||
<commands xmi:id="_95PfvHNmEeWBq8z1Dv39LA" elementId="org.eclipse.ui.file.exit" commandName="Quit Command"/>
|
<commands xmi:id="_95PfvHNmEeWBq8z1Dv39LA" elementId="org.eclipse.ui.file.exit" commandName="Quit Command"/>
|
||||||
<commands xmi:id="_95PfwHNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.open" commandName="Open Command"/>
|
<commands xmi:id="_95PfwHNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.open" commandName="Open Command"/>
|
||||||
<commands xmi:id="_95Pfw3NmEeWBq8z1Dv39LA" elementId="org.eclipse.ui.file.save" commandName="Save Command"/>
|
<commands xmi:id="_95Pfw3NmEeWBq8z1Dv39LA" elementId="org.eclipse.ui.file.save" commandName="Save Command"/>
|
||||||
@ -295,9 +295,6 @@
|
|||||||
<commands xmi:id="_-9ED4B06EeuiP60JNw0iiA" elementId="com.minres.scviewer.e4.application.command.update" commandName="Update"/>
|
<commands xmi:id="_-9ED4B06EeuiP60JNw0iiA" elementId="com.minres.scviewer.e4.application.command.update" commandName="Update"/>
|
||||||
<commands xmi:id="_lqjIYEYEEeyPM8G0E2EYww" elementId="org.eclipse.ui.help.helpAction" commandName="Help Command"/>
|
<commands xmi:id="_lqjIYEYEEeyPM8G0E2EYww" elementId="org.eclipse.ui.help.helpAction" commandName="Help Command"/>
|
||||||
<commands xmi:id="_Fj1gQEYoEeyKK_icsY7Xjg" elementId="com.minres.scviewer.e4.application.command.enabletxdetails" commandName="Enable Tx Details" description="Show tx details parts"/>
|
<commands xmi:id="_Fj1gQEYoEeyKK_icsY7Xjg" elementId="com.minres.scviewer.e4.application.command.enabletxdetails" commandName="Enable Tx Details" description="Show tx details parts"/>
|
||||||
<commands xmi:id="_y2BUsE-HEeyuGJbYVZjX8w" elementId="com.minres.scviewer.e4.application.command.pancommand" commandName="Pan Command">
|
|
||||||
<parameters xmi:id="_y2BUsU-HEeyuGJbYVZjX8w" elementId="com.minres.scviewer.e4.application.command.pancommand.parameter.direction" name="direction" optional="false"/>
|
|
||||||
</commands>
|
|
||||||
<addons xmi:id="_95PfsnNmEeWBq8z1Dv39LA" elementId="org.eclipse.e4.core.commands.service" contributionURI="bundleclass://org.eclipse.e4.core.commands/org.eclipse.e4.core.commands.CommandServiceAddon"/>
|
<addons xmi:id="_95PfsnNmEeWBq8z1Dv39LA" elementId="org.eclipse.e4.core.commands.service" contributionURI="bundleclass://org.eclipse.e4.core.commands/org.eclipse.e4.core.commands.CommandServiceAddon"/>
|
||||||
<addons xmi:id="_95Pfs3NmEeWBq8z1Dv39LA" elementId="org.eclipse.e4.ui.contexts.service" contributionURI="bundleclass://org.eclipse.e4.ui.services/org.eclipse.e4.ui.services.ContextServiceAddon"/>
|
<addons xmi:id="_95Pfs3NmEeWBq8z1Dv39LA" elementId="org.eclipse.e4.ui.contexts.service" contributionURI="bundleclass://org.eclipse.e4.ui.services/org.eclipse.e4.ui.services.ContextServiceAddon"/>
|
||||||
<addons xmi:id="_95PftHNmEeWBq8z1Dv39LA" elementId="org.eclipse.e4.ui.bindings.service" contributionURI="bundleclass://org.eclipse.e4.ui.bindings/org.eclipse.e4.ui.bindings.BindingServiceAddon"/>
|
<addons xmi:id="_95PftHNmEeWBq8z1Dv39LA" elementId="org.eclipse.e4.ui.bindings.service" contributionURI="bundleclass://org.eclipse.e4.ui.bindings/org.eclipse.e4.ui.bindings.BindingServiceAddon"/>
|
||||||
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
|||||||
Bundle-ManifestVersion: 2
|
Bundle-ManifestVersion: 2
|
||||||
Bundle-Name: %Bundle-Name
|
Bundle-Name: %Bundle-Name
|
||||||
Bundle-SymbolicName: com.minres.scviewer.e4.application;singleton:=true
|
Bundle-SymbolicName: com.minres.scviewer.e4.application;singleton:=true
|
||||||
Bundle-Version: 2.15.1
|
Bundle-Version: 2.14.1
|
||||||
Bundle-Vendor: %Bundle-Vendor
|
Bundle-Vendor: %Bundle-Vendor
|
||||||
Require-Bundle: javax.inject;bundle-version="1.0.0",
|
Require-Bundle: javax.inject;bundle-version="1.0.0",
|
||||||
org.eclipse.core.runtime;bundle-version="3.11.1",
|
org.eclipse.core.runtime;bundle-version="3.11.1",
|
||||||
@ -35,7 +35,8 @@ Require-Bundle: javax.inject;bundle-version="1.0.0",
|
|||||||
org.eclipse.equinox.p2.core;bundle-version="2.6.300",
|
org.eclipse.equinox.p2.core;bundle-version="2.6.300",
|
||||||
org.eclipse.equinox.p2.engine;bundle-version="2.6.600",
|
org.eclipse.equinox.p2.engine;bundle-version="2.6.600",
|
||||||
org.eclipse.equinox.p2.operations;bundle-version="2.5.700",
|
org.eclipse.equinox.p2.operations;bundle-version="2.5.700",
|
||||||
org.eclipse.equinox.p2.metadata.repository;bundle-version="1.3.400"
|
org.eclipse.equinox.p2.metadata.repository;bundle-version="1.3.400",
|
||||||
|
org.eclipse.help.base;bundle-version="4.2.900"
|
||||||
Bundle-RequiredExecutionEnvironment: JavaSE-11
|
Bundle-RequiredExecutionEnvironment: JavaSE-11
|
||||||
Import-Package: com.minres.scviewer.database,
|
Import-Package: com.minres.scviewer.database,
|
||||||
javax.annotation;version="1.0.0";resolution:=optional,
|
javax.annotation;version="1.0.0";resolution:=optional,
|
||||||
|
Before Width: | Height: | Size: 600 B |
Before Width: | Height: | Size: 519 B |
Before Width: | Height: | Size: 524 B |
@ -6,8 +6,8 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.minres.scviewer</groupId>
|
<groupId>com.minres.scviewer</groupId>
|
||||||
<artifactId>com.minres.scviewer.parent</artifactId>
|
<artifactId>com.minres.scviewer.parent</artifactId>
|
||||||
<version>2.15.1</version>
|
<version>2.14.1</version>
|
||||||
<relativePath>../..</relativePath>
|
<relativePath>../../..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<packaging>eclipse-plugin</packaging>
|
<packaging>eclipse-plugin</packaging>
|
||||||
</project>
|
</project>
|
||||||
|
@ -10,24 +10,41 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package com.minres.scviewer.e4.application.handlers;
|
package com.minres.scviewer.e4.application.handlers;
|
||||||
|
|
||||||
import org.eclipse.e4.core.di.annotations.CanExecute;
|
import java.io.File;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.e4.core.di.annotations.Execute;
|
import org.eclipse.e4.core.di.annotations.Execute;
|
||||||
import org.eclipse.e4.ui.model.application.MApplication;
|
import org.eclipse.e4.ui.model.application.MApplication;
|
||||||
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
|
import org.eclipse.e4.ui.model.application.ui.MUIElement;
|
||||||
import org.eclipse.e4.ui.workbench.modeling.EModelService;
|
import org.eclipse.e4.ui.workbench.modeling.EModelService;
|
||||||
|
import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
|
||||||
|
import org.eclipse.help.HelpSystem;
|
||||||
|
import org.eclipse.help.IHelp;
|
||||||
|
import org.eclipse.help.standalone.Help;
|
||||||
|
import org.eclipse.osgi.service.datalocation.Location;
|
||||||
|
|
||||||
public class HelpHandler {
|
public class HelpHandler {
|
||||||
|
|
||||||
|
static final String DIALOG_ID="com.minres.scviewer.e4.application.dialog.onlinehelp"; //$NON-NLS-1$
|
||||||
static final String WINDOW_ID="com.minres.scviewer.e4.application.window.help"; //$NON-NLS-1$
|
static final String WINDOW_ID="com.minres.scviewer.e4.application.window.help"; //$NON-NLS-1$
|
||||||
@CanExecute
|
|
||||||
public boolean canExecute(MApplication app) {
|
|
||||||
return !app.getChildren().stream().filter(e -> e.getElementId().equals(WINDOW_ID)).findFirst().isPresent();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Execute
|
@Execute
|
||||||
public void execute(MApplication app, MWindow window, EModelService modelService /*@Named("mdialog01.dialog.0") MDialog dialog*/) {
|
public void execute(MApplication app, /*MWindow window,*/ EModelService ms /*@Named("mdialog01.dialog.0") MDialog dialog*/) {
|
||||||
MWindow newWin = (MWindow)modelService.cloneSnippet(app, WINDOW_ID, null);
|
// MPart mel = (MPart) ms.find(DIALOG_ID, app); //$NON-NLS-1$
|
||||||
app.getChildren().add(newWin);
|
// mel.setToBeRendered(true);
|
||||||
|
// mel.setToBeRendered(false);
|
||||||
|
try {
|
||||||
|
File installDir = Paths.get(Platform.getInstallLocation().getURL().toURI()).toFile();
|
||||||
|
File instanceDir = Paths.get(Platform.getInstanceLocation().getURL().toURI()).toFile();
|
||||||
|
Help helpSystem = new Help(new String[] {"-eclipseHome", installDir.getAbsolutePath(), "-data", instanceDir.getAbsolutePath()});
|
||||||
|
helpSystem.start();
|
||||||
|
helpSystem.displayHelp("/com.minres.scviewer.help/toc.xml");
|
||||||
|
} catch (Exception e) {
|
||||||
|
MUIElement w = ms.find(WINDOW_ID, app);
|
||||||
|
if(w!=null) w.setToBeRendered(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ import org.eclipse.e4.core.di.annotations.CanExecute;
|
|||||||
import org.eclipse.e4.core.di.annotations.Execute;
|
import org.eclipse.e4.core.di.annotations.Execute;
|
||||||
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
||||||
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
||||||
|
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
|
||||||
import com.minres.scviewer.database.IWaveform;
|
import com.minres.scviewer.database.IWaveform;
|
||||||
@ -30,23 +31,19 @@ public class NavigateEvent {
|
|||||||
final static String PARAMTER_ID="com.minres.scviewer.e4.application.command.navigateEventCommand.parameter.dir"; //$NON-NLS-1$
|
final static String PARAMTER_ID="com.minres.scviewer.e4.application.command.navigateEventCommand.parameter.dir"; //$NON-NLS-1$
|
||||||
|
|
||||||
@CanExecute
|
@CanExecute
|
||||||
public Boolean canExecute(EPartService partService){
|
public Boolean canExecute(ESelectionService selectionService){
|
||||||
MPart part = partService.getActivePart();
|
Object sel = selectionService.getSelection();
|
||||||
if(part.getObject() instanceof WaveformViewer){
|
|
||||||
Object sel = ((WaveformViewer)part.getObject()).getSelection();
|
|
||||||
if( sel instanceof IStructuredSelection) {
|
if( sel instanceof IStructuredSelection) {
|
||||||
if(((IStructuredSelection)sel).isEmpty()) return false;
|
|
||||||
Object o= ((IStructuredSelection)sel).getFirstElement();
|
Object o= ((IStructuredSelection)sel).getFirstElement();
|
||||||
return o instanceof IWaveform || o instanceof ITx || o instanceof TrackEntry;
|
return o instanceof IWaveform || o instanceof ITx || o instanceof TrackEntry;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Execute
|
@Execute
|
||||||
public void execute(@Named(PARAMTER_ID) String param, EPartService partService) {
|
public void execute(@Named(PARAMTER_ID) String param, EPartService partService) {
|
||||||
// public void execute(EPartService partService) {
|
// public void execute(EPartService partService) {
|
||||||
// String param="next";
|
// String param="next";
|
||||||
MPart part = partService.getActivePart();
|
MPart part = partService.getActivePart();
|
||||||
Object obj = part.getObject();
|
Object obj = part.getObject();
|
||||||
if(obj instanceof WaveformViewer){
|
if(obj instanceof WaveformViewer){
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2015-2021 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 com.minres.scviewer.e4.application.handlers;
|
|
||||||
|
|
||||||
import javax.inject.Named;
|
|
||||||
|
|
||||||
import org.eclipse.e4.core.di.annotations.CanExecute;
|
|
||||||
import org.eclipse.e4.core.di.annotations.Execute;
|
|
||||||
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
|
||||||
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
|
||||||
|
|
||||||
import com.minres.scviewer.e4.application.parts.WaveformViewer;
|
|
||||||
|
|
||||||
public class PanHandler {
|
|
||||||
|
|
||||||
final static String PARAMTER_ID="com.minres.scviewer.e4.application.command.pancommand.parameter.direction"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
@CanExecute
|
|
||||||
public boolean canExecute(EPartService partService) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Execute
|
|
||||||
public void execute(@Named(PARAMTER_ID) String level, EPartService partService) {
|
|
||||||
MPart part = partService.getActivePart();
|
|
||||||
Object obj = part.getObject();
|
|
||||||
if(obj instanceof WaveformViewer){
|
|
||||||
WaveformViewer waveformViewerPart = (WaveformViewer) obj;
|
|
||||||
if("left".equalsIgnoreCase(level)) //$NON-NLS-1$
|
|
||||||
waveformViewerPart.pan(-1);
|
|
||||||
else if("right".equalsIgnoreCase(level)) //$NON-NLS-1$
|
|
||||||
waveformViewerPart.pan(+1);
|
|
||||||
else if("cursor".equalsIgnoreCase(level)) //$NON-NLS-1$
|
|
||||||
waveformViewerPart.pan(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -11,26 +11,33 @@
|
|||||||
|
|
||||||
package com.minres.scviewer.e4.application.handlers;
|
package com.minres.scviewer.e4.application.handlers;
|
||||||
|
|
||||||
import org.eclipse.e4.core.di.annotations.CanExecute;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.eclipse.e4.core.di.annotations.Execute;
|
import org.eclipse.e4.core.di.annotations.Execute;
|
||||||
|
import org.eclipse.e4.core.di.annotations.Optional;
|
||||||
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
||||||
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
||||||
|
|
||||||
import com.minres.scviewer.e4.application.parts.WaveformViewer;
|
import com.minres.scviewer.e4.application.parts.DesignBrowser;
|
||||||
|
|
||||||
public class SelectAllHandler {
|
public class SelectAllHandler {
|
||||||
|
|
||||||
@CanExecute
|
@Inject @Optional DesignBrowser designBrowser;
|
||||||
public boolean canExecute(EPartService partService) {
|
|
||||||
MPart part = partService.getActivePart();
|
|
||||||
return part.getObject() instanceof WaveformViewer;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Execute
|
@Execute
|
||||||
public void execute(EPartService partService) {
|
public void execute(EPartService partService) {
|
||||||
|
if(designBrowser==null) designBrowser = getListPart(partService);
|
||||||
|
if(designBrowser!=null){
|
||||||
|
designBrowser.selectAllWaveforms();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected DesignBrowser getListPart(EPartService partService){
|
||||||
MPart part = partService.getActivePart();
|
MPart part = partService.getActivePart();
|
||||||
if(part.getObject() instanceof WaveformViewer)
|
if(part.getObject() instanceof DesignBrowser)
|
||||||
((WaveformViewer) part.getObject()).selectAll();
|
return (DesignBrowser) part.getObject();
|
||||||
|
else
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -18,7 +18,6 @@ import org.eclipse.e4.core.di.annotations.Execute;
|
|||||||
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
||||||
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
||||||
|
|
||||||
import com.minres.scviewer.database.ui.ZoomKind;
|
|
||||||
import com.minres.scviewer.e4.application.parts.WaveformViewer;
|
import com.minres.scviewer.e4.application.parts.WaveformViewer;
|
||||||
|
|
||||||
public class ZoomHandler {
|
public class ZoomHandler {
|
||||||
@ -36,14 +35,15 @@ public class ZoomHandler {
|
|||||||
Object obj = part.getObject();
|
Object obj = part.getObject();
|
||||||
if(obj instanceof WaveformViewer){
|
if(obj instanceof WaveformViewer){
|
||||||
WaveformViewer waveformViewerPart = (WaveformViewer) obj;
|
WaveformViewer waveformViewerPart = (WaveformViewer) obj;
|
||||||
|
int zoomLevel = waveformViewerPart.getZoomLevel();
|
||||||
if("in".equalsIgnoreCase(level)) //$NON-NLS-1$
|
if("in".equalsIgnoreCase(level)) //$NON-NLS-1$
|
||||||
waveformViewerPart.zoom(ZoomKind.IN);
|
waveformViewerPart.setZoomLevel(zoomLevel-1);
|
||||||
else if("out".equalsIgnoreCase(level)) //$NON-NLS-1$
|
else if("out".equalsIgnoreCase(level)) //$NON-NLS-1$
|
||||||
waveformViewerPart.zoom(ZoomKind.OUT);
|
waveformViewerPart.setZoomLevel(zoomLevel+1);
|
||||||
else if("fit".equalsIgnoreCase(level)) //$NON-NLS-1$
|
else if("fit".equalsIgnoreCase(level)) //$NON-NLS-1$
|
||||||
waveformViewerPart.zoom(ZoomKind.FIT);
|
waveformViewerPart.setZoomFit();
|
||||||
else if("full".equalsIgnoreCase(level)) //$NON-NLS-1$
|
else if("full".equalsIgnoreCase(level)) //$NON-NLS-1$
|
||||||
waveformViewerPart.zoom(ZoomKind.FULL);
|
waveformViewerPart.setZoomFull();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,9 @@ import com.minres.scviewer.e4.application.Messages;
|
|||||||
*/
|
*/
|
||||||
public class WaveStatusBarControl extends StatusBarControl {
|
public class WaveStatusBarControl extends StatusBarControl {
|
||||||
|
|
||||||
|
/** The Constant ZOOM_LEVEL. */
|
||||||
|
public static final String ZOOM_LEVEL="ZoomLevelUpdate"; //$NON-NLS-1$
|
||||||
|
|
||||||
/** The Constant CURSOR_TIME. */
|
/** The Constant CURSOR_TIME. */
|
||||||
public static final String CURSOR_TIME="CursorPosUpdate"; //$NON-NLS-1$
|
public static final String CURSOR_TIME="CursorPosUpdate"; //$NON-NLS-1$
|
||||||
|
|
||||||
@ -42,7 +45,7 @@ public class WaveStatusBarControl extends StatusBarControl {
|
|||||||
|
|
||||||
|
|
||||||
/** The zoom contribution. */
|
/** The zoom contribution. */
|
||||||
StatusLineContributionItem cursorContribution, markerContribution, markerDiffContribution;
|
StatusLineContributionItem cursorContribution, markerContribution, markerDiffContribution, zoomContribution;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new wave status bar control.
|
* Instantiates a new wave status bar control.
|
||||||
@ -56,9 +59,11 @@ public class WaveStatusBarControl extends StatusBarControl {
|
|||||||
cursorContribution = new StatusLineContributionItem(Messages.WaveStatusBarControl_5, true, 20);
|
cursorContribution = new StatusLineContributionItem(Messages.WaveStatusBarControl_5, true, 20);
|
||||||
markerContribution = new StatusLineContributionItem(Messages.WaveStatusBarControl_6, true, 20);
|
markerContribution = new StatusLineContributionItem(Messages.WaveStatusBarControl_6, true, 20);
|
||||||
markerDiffContribution = new StatusLineContributionItem(Messages.WaveStatusBarControl_7, true, 20);
|
markerDiffContribution = new StatusLineContributionItem(Messages.WaveStatusBarControl_7, true, 20);
|
||||||
|
zoomContribution = new StatusLineContributionItem(Messages.WaveStatusBarControl_8, true, 8);
|
||||||
manager.appendToGroup(StatusLineManager.BEGIN_GROUP,cursorContribution);
|
manager.appendToGroup(StatusLineManager.BEGIN_GROUP,cursorContribution);
|
||||||
manager.appendToGroup(StatusLineManager.BEGIN_GROUP,markerContribution);
|
manager.appendToGroup(StatusLineManager.BEGIN_GROUP,markerContribution);
|
||||||
manager.appendToGroup(StatusLineManager.BEGIN_GROUP,markerDiffContribution);
|
manager.appendToGroup(StatusLineManager.BEGIN_GROUP,markerDiffContribution);
|
||||||
|
manager.appendToGroup(StatusLineManager.BEGIN_GROUP, zoomContribution);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -83,6 +88,17 @@ public class WaveStatusBarControl extends StatusBarControl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the zoom event.
|
||||||
|
*
|
||||||
|
* @param text the text
|
||||||
|
* @return the zoom event
|
||||||
|
*/
|
||||||
|
@Inject @Optional
|
||||||
|
public void getZoomEvent(@UIEventTopic(ZOOM_LEVEL) String text) {
|
||||||
|
zoomContribution.setText(text);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the cursor event.
|
* Gets the cursor event.
|
||||||
*
|
*
|
||||||
|
@ -85,7 +85,7 @@ HelpDialog_2=Stop
|
|||||||
HelpDialog_3=Refresh
|
HelpDialog_3=Refresh
|
||||||
HelpDialog_4=Go
|
HelpDialog_4=Go
|
||||||
HelpDialog_5=Address
|
HelpDialog_5=Address
|
||||||
HelpDialog_6=https://minres.github.io/SCViewer/#key-shortcuts
|
HelpDialog_6=https://git.minres.com/VP-Tools/SCViewer/src/branch/master/README.md\#key-shortcuts
|
||||||
HelpDialog_7=Could not instantiate Browser:
|
HelpDialog_7=Could not instantiate Browser:
|
||||||
marker=Marker
|
marker=Marker
|
||||||
marker_text=Marker TExt
|
marker_text=Marker TExt
|
||||||
|
@ -227,10 +227,6 @@ public class DesignBrowser {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public Control getControl() {
|
|
||||||
return top;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the table composite.
|
* Creates the table composite.
|
||||||
*
|
*
|
||||||
|
@ -94,7 +94,6 @@ import com.minres.scviewer.database.ui.IWaveformView;
|
|||||||
import com.minres.scviewer.database.ui.TrackEntry;
|
import com.minres.scviewer.database.ui.TrackEntry;
|
||||||
import com.minres.scviewer.database.ui.TrackEntry.ValueDisplay;
|
import com.minres.scviewer.database.ui.TrackEntry.ValueDisplay;
|
||||||
import com.minres.scviewer.database.ui.TrackEntry.WaveDisplay;
|
import com.minres.scviewer.database.ui.TrackEntry.WaveDisplay;
|
||||||
import com.minres.scviewer.database.ui.ZoomKind;
|
|
||||||
import com.minres.scviewer.database.ui.swt.Constants;
|
import com.minres.scviewer.database.ui.swt.Constants;
|
||||||
import com.minres.scviewer.database.ui.swt.IToolTipContentProvider;
|
import com.minres.scviewer.database.ui.swt.IToolTipContentProvider;
|
||||||
import com.minres.scviewer.database.ui.swt.IToolTipHelpTextProvider;
|
import com.minres.scviewer.database.ui.swt.IToolTipHelpTextProvider;
|
||||||
@ -132,7 +131,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
|||||||
protected static final String SHOWN_CURSOR = "SHOWN_CURSOR"; //$NON-NLS-1$
|
protected static final String SHOWN_CURSOR = "SHOWN_CURSOR"; //$NON-NLS-1$
|
||||||
|
|
||||||
/** The Constant ZOOM_LEVEL. */
|
/** The Constant ZOOM_LEVEL. */
|
||||||
protected static final String SCALING_FACTOR = "SCALING_FACTOR"; //$NON-NLS-1$
|
protected static final String ZOOM_LEVEL = "ZOOM_LEVEL"; //$NON-NLS-1$
|
||||||
|
|
||||||
/** The Constant BASE_LINE_TIME. */
|
/** The Constant BASE_LINE_TIME. */
|
||||||
protected static final String BASE_LINE_TIME = "BASE_LINE_TIME"; //$NON-NLS-1$
|
protected static final String BASE_LINE_TIME = "BASE_LINE_TIME"; //$NON-NLS-1$
|
||||||
@ -152,6 +151,9 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
|||||||
/** The Constant TX_DETAILS_SHOWN. */
|
/** The Constant TX_DETAILS_SHOWN. */
|
||||||
protected static final String TX_DETAILS_SHOWN = "TX_DETAILS_SHOWN"; //$NON-NLS-1$
|
protected static final String TX_DETAILS_SHOWN = "TX_DETAILS_SHOWN"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
/** The zoom level. */
|
||||||
|
private String[] zoomLevel;
|
||||||
|
|
||||||
/** The Constant ID. */
|
/** The Constant ID. */
|
||||||
public static final String ID = "com.minres.scviewer.ui.TxEditorPart"; //$NON-NLS-1$
|
public static final String ID = "com.minres.scviewer.ui.TxEditorPart"; //$NON-NLS-1$
|
||||||
|
|
||||||
@ -297,15 +299,15 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
|||||||
|
|
||||||
waveformPane.addPropertyChangeListener(IWaveformView.CURSOR_PROPERTY, evt -> {
|
waveformPane.addPropertyChangeListener(IWaveformView.CURSOR_PROPERTY, evt -> {
|
||||||
Long time = (Long) evt.getNewValue();
|
Long time = (Long) evt.getNewValue();
|
||||||
eventBroker.post(WaveStatusBarControl.CURSOR_TIME, waveformPane.getWaveformZoom().timeToString(time));
|
eventBroker.post(WaveStatusBarControl.CURSOR_TIME, waveformPane.getScaledTime(time));
|
||||||
long marker = waveformPane.getMarkerTime(waveformPane.getSelectedMarker());
|
long marker = waveformPane.getMarkerTime(waveformPane.getSelectedMarkerId());
|
||||||
eventBroker.post(WaveStatusBarControl.MARKER_DIFF, waveformPane.getWaveformZoom().timeToString(time - marker));
|
eventBroker.post(WaveStatusBarControl.MARKER_DIFF, waveformPane.getScaledTime(time - marker));
|
||||||
});
|
});
|
||||||
waveformPane.addPropertyChangeListener(IWaveformView.MARKER_PROPERTY, evt -> {
|
waveformPane.addPropertyChangeListener(IWaveformView.MARKER_PROPERTY, evt -> {
|
||||||
Long time = (Long) evt.getNewValue();
|
Long time = (Long) evt.getNewValue();
|
||||||
eventBroker.post(WaveStatusBarControl.MARKER_TIME, waveformPane.getWaveformZoom().timeToString(time));
|
eventBroker.post(WaveStatusBarControl.MARKER_TIME, waveformPane.getScaledTime(time));
|
||||||
long cursor = waveformPane.getCursorTime();
|
long cursor = waveformPane.getCursorTime();
|
||||||
eventBroker.post(WaveStatusBarControl.MARKER_DIFF, waveformPane.getWaveformZoom().timeToString(cursor - time));
|
eventBroker.post(WaveStatusBarControl.MARKER_DIFF, waveformPane.getScaledTime(cursor - time));
|
||||||
});
|
});
|
||||||
|
|
||||||
waveformPane.addSelectionChangedListener(event -> {
|
waveformPane.addSelectionChangedListener(event -> {
|
||||||
@ -317,14 +319,17 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
|||||||
waveformPane.getWaveformControl().addListener(SWT.KeyDown, e -> {
|
waveformPane.getWaveformControl().addListener(SWT.KeyDown, e -> {
|
||||||
if((e.stateMask&SWT.MOD3)!=0) { // Alt key
|
if((e.stateMask&SWT.MOD3)!=0) { // Alt key
|
||||||
} else if((e.stateMask&SWT.MOD1)!=0) { //Ctrl/Cmd
|
} else if((e.stateMask&SWT.MOD1)!=0) { //Ctrl/Cmd
|
||||||
|
int zoomlevel = waveformPane.getZoomLevel();
|
||||||
switch(e.keyCode) {
|
switch(e.keyCode) {
|
||||||
case '+':
|
case '+':
|
||||||
case SWT.KEYPAD_ADD:
|
case SWT.KEYPAD_ADD:
|
||||||
waveformPane.getWaveformZoom().zoom(ZoomKind.IN);
|
if(zoomlevel>0)
|
||||||
|
waveformPane.setZoomLevel(zoomlevel-1);
|
||||||
return;
|
return;
|
||||||
case '-':
|
case '-':
|
||||||
case SWT.KEYPAD_SUBTRACT:
|
case SWT.KEYPAD_SUBTRACT:
|
||||||
waveformPane.getWaveformZoom().zoom(ZoomKind.OUT);
|
if(zoomlevel<waveformPane.getZoomLevels().length-1)
|
||||||
|
waveformPane.setZoomLevel(zoomlevel+1);
|
||||||
return;
|
return;
|
||||||
case SWT.ARROW_UP:
|
case SWT.ARROW_UP:
|
||||||
waveformPane.moveSelectedTrack(-1);
|
waveformPane.moveSelectedTrack(-1);
|
||||||
@ -332,8 +337,6 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
|||||||
case SWT.ARROW_DOWN:
|
case SWT.ARROW_DOWN:
|
||||||
waveformPane.moveSelectedTrack(1);
|
waveformPane.moveSelectedTrack(1);
|
||||||
return;
|
return;
|
||||||
case 'a':
|
|
||||||
selectAll();
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -376,6 +379,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
zoomLevel = waveformPane.getZoomLevels();
|
||||||
checkForUpdates = store.getBoolean(PreferenceConstants.DATABASE_RELOAD, true);
|
checkForUpdates = store.getBoolean(PreferenceConstants.DATABASE_RELOAD, true);
|
||||||
filesToLoad = new ArrayList<>();
|
filesToLoad = new ArrayList<>();
|
||||||
persistedState = part.getPersistedState();
|
persistedState = part.getPersistedState();
|
||||||
@ -386,6 +390,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
|||||||
}
|
}
|
||||||
if (!filesToLoad.isEmpty())
|
if (!filesToLoad.isEmpty())
|
||||||
loadDatabase(persistedState);
|
loadDatabase(persistedState);
|
||||||
|
eventBroker.post(WaveStatusBarControl.ZOOM_LEVEL, zoomLevel[waveformPane.getZoomLevel()]);
|
||||||
menuService.registerContextMenu(waveformPane.getNameControl(), MENU_CONTEXT);
|
menuService.registerContextMenu(waveformPane.getNameControl(), MENU_CONTEXT);
|
||||||
menuService.registerContextMenu(waveformPane.getValueControl(), MENU_CONTEXT);
|
menuService.registerContextMenu(waveformPane.getValueControl(), MENU_CONTEXT);
|
||||||
menuService.registerContextMenu(waveformPane.getWaveformControl(), MENU_CONTEXT);
|
menuService.registerContextMenu(waveformPane.getWaveformControl(), MENU_CONTEXT);
|
||||||
@ -743,8 +748,8 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
|||||||
persistingState.put(SHOWN_CURSOR + index, Long.toString(cursor.getTime()));
|
persistingState.put(SHOWN_CURSOR + index, Long.toString(cursor.getTime()));
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
persistingState.put(SCALING_FACTOR, Long.toString(waveformPane.getWaveformZoom().getScale()));
|
persistingState.put(ZOOM_LEVEL, Integer.toString(waveformPane.getZoomLevel()));
|
||||||
persistingState.put(BASE_LINE_TIME, Long.toString(waveformPane.getWaveformZoom().getMinVisibleTime()));
|
persistingState.put(BASE_LINE_TIME, Long.toString(waveformPane.getBaselineTime()));
|
||||||
|
|
||||||
// get selected transaction of a stream
|
// get selected transaction of a stream
|
||||||
ISelection selection = waveformPane.getSelection();
|
ISelection selection = waveformPane.getSelection();
|
||||||
@ -787,15 +792,18 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
|||||||
protected void restoreWaveformViewerState(Map<String, String> state) {
|
protected void restoreWaveformViewerState(Map<String, String> state) {
|
||||||
Integer waves = state.containsKey(SHOWN_WAVEFORM+"S") ? Integer.parseInt(state.get(SHOWN_WAVEFORM + "S")):0; //$NON-NLS-1$ //$NON-NLS-2$
|
Integer waves = state.containsKey(SHOWN_WAVEFORM+"S") ? Integer.parseInt(state.get(SHOWN_WAVEFORM + "S")):0; //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
List<TrackEntry> trackEntries = new LinkedList<>();
|
List<TrackEntry> trackEntries = new LinkedList<>();
|
||||||
List<TrackEntry> selectedTrackEntries = new LinkedList<>();
|
|
||||||
for (int i = 0; i < waves; i++) {
|
for (int i = 0; i < waves; i++) {
|
||||||
IWaveform waveform = database.getStreamByName(state.get(SHOWN_WAVEFORM + i));
|
IWaveform waveform = database.getStreamByName(state.get(SHOWN_WAVEFORM + i));
|
||||||
if (waveform != null) {
|
if (waveform != null) {
|
||||||
TrackEntry trackEntry = waveformPane.addWaveform(waveform, -1);
|
TrackEntry trackEntry = waveformPane.addWaveform(waveform, -1);
|
||||||
//check if t is selected
|
//check if t is selected
|
||||||
|
boolean isSelected = Boolean.parseBoolean(state.get(SHOWN_WAVEFORM + i + WAVEFORM_SELECTED));
|
||||||
|
if(isSelected) {
|
||||||
|
trackEntry.selected = true;
|
||||||
|
} else {
|
||||||
|
trackEntry.selected = false;
|
||||||
|
}
|
||||||
trackEntries.add(trackEntry);
|
trackEntries.add(trackEntry);
|
||||||
if(Boolean.parseBoolean(state.get(SHOWN_WAVEFORM + i + WAVEFORM_SELECTED)))
|
|
||||||
selectedTrackEntries.add(trackEntry);
|
|
||||||
String v = state.get(SHOWN_WAVEFORM + i + VALUE_DISPLAY);
|
String v = state.get(SHOWN_WAVEFORM + i + VALUE_DISPLAY);
|
||||||
if(v!=null)
|
if(v!=null)
|
||||||
trackEntry.valueDisplay=ValueDisplay.valueOf(v);
|
trackEntry.valueDisplay=ValueDisplay.valueOf(v);
|
||||||
@ -812,17 +820,17 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
|||||||
cursors.get(i).setTime(time);
|
cursors.get(i).setTime(time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (state.containsKey(SCALING_FACTOR)) {
|
if (state.containsKey(ZOOM_LEVEL)) {
|
||||||
try {
|
try {
|
||||||
long scale = Long.parseLong(state.get(SCALING_FACTOR));
|
Integer scale = Integer.parseInt(state.get(ZOOM_LEVEL));
|
||||||
waveformPane.getWaveformZoom().setScale(scale);
|
waveformPane.setZoomLevel(scale);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (state.containsKey(BASE_LINE_TIME)) {
|
if (state.containsKey(BASE_LINE_TIME)) {
|
||||||
try {
|
try {
|
||||||
Long scale = Long.parseLong(state.get(BASE_LINE_TIME));
|
Long scale = Long.parseLong(state.get(BASE_LINE_TIME));
|
||||||
waveformPane.getWaveformZoom().setMinVisibleTime(scale);
|
waveformPane.setBaselineTime(scale);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -853,8 +861,6 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
|||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ISelection sel = new StructuredSelection(selectedTrackEntries);
|
|
||||||
waveformPane.setSelection(sel);
|
|
||||||
updateAll();
|
updateAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -863,11 +869,12 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
|||||||
*/
|
*/
|
||||||
private void updateAll() {
|
private void updateAll() {
|
||||||
eventBroker.post(ACTIVE_WAVEFORMVIEW, this);
|
eventBroker.post(ACTIVE_WAVEFORMVIEW, this);
|
||||||
|
eventBroker.post(WaveStatusBarControl.ZOOM_LEVEL, zoomLevel[waveformPane.getZoomLevel()]);
|
||||||
long cursor = waveformPane.getCursorTime();
|
long cursor = waveformPane.getCursorTime();
|
||||||
long marker = waveformPane.getMarkerTime(waveformPane.getSelectedMarker());
|
long marker = waveformPane.getMarkerTime(waveformPane.getSelectedMarkerId());
|
||||||
eventBroker.post(WaveStatusBarControl.CURSOR_TIME, waveformPane.getWaveformZoom().timeToString(cursor));
|
eventBroker.post(WaveStatusBarControl.CURSOR_TIME, waveformPane.getScaledTime(cursor));
|
||||||
eventBroker.post(WaveStatusBarControl.MARKER_TIME, waveformPane.getWaveformZoom().timeToString(marker));
|
eventBroker.post(WaveStatusBarControl.MARKER_TIME, waveformPane.getScaledTime(marker));
|
||||||
eventBroker.post(WaveStatusBarControl.MARKER_DIFF, waveformPane.getWaveformZoom().timeToString(cursor - marker));
|
eventBroker.post(WaveStatusBarControl.MARKER_DIFF, waveformPane.getScaledTime(cursor - marker));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1038,35 +1045,44 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the zoom according to kind.
|
* Sets the zoom level.
|
||||||
*
|
*
|
||||||
* @param kind the type of zoom to execute
|
* @param level the new zoom level
|
||||||
*/
|
*/
|
||||||
public void zoom(ZoomKind kind) {
|
public void setZoomLevel(Integer level) {
|
||||||
waveformPane.getWaveformZoom().zoom(kind);
|
if (level < 0)
|
||||||
|
level = 0;
|
||||||
|
if (level > zoomLevel.length - 1)
|
||||||
|
level = zoomLevel.length - 1;
|
||||||
|
waveformPane.setZoomLevel(level);
|
||||||
updateAll();
|
updateAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the zoom kind.
|
* Sets the zoom fit.
|
||||||
*
|
|
||||||
* @param direction the direction of the pan (-1, 0, 1)
|
|
||||||
*/
|
*/
|
||||||
public void pan(int direction) {
|
public void setZoomFit() {
|
||||||
switch(direction) {
|
waveformPane.setZoomLevel(-2);
|
||||||
case -1:
|
|
||||||
waveformPane.scrollHorizontal(-10);
|
|
||||||
return;
|
|
||||||
case 1:
|
|
||||||
waveformPane.scrollHorizontal(10);
|
|
||||||
return;
|
|
||||||
case 0:
|
|
||||||
waveformPane.scrollTo(IWaveformView.CURSOR_POS);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
updateAll();
|
updateAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the zoom fit.
|
||||||
|
*/
|
||||||
|
public void setZoomFull() {
|
||||||
|
waveformPane.setZoomLevel(-1);
|
||||||
|
updateAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the zoom level.
|
||||||
|
*
|
||||||
|
* @return the zoom level
|
||||||
|
*/
|
||||||
|
public int getZoomLevel() {
|
||||||
|
return waveformPane.getZoomLevel();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the selection.
|
* Gets the selection.
|
||||||
*
|
*
|
||||||
@ -1095,7 +1111,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
|||||||
* @return the scaled time
|
* @return the scaled time
|
||||||
*/
|
*/
|
||||||
public String getScaledTime(Long time) {
|
public String getScaledTime(Long time) {
|
||||||
return waveformPane.getWaveformZoom().timeToString(time);
|
return waveformPane.getScaledTime(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1221,6 +1237,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
|||||||
public void widgetDisposed(DisposeEvent e) {
|
public void widgetDisposed(DisposeEvent e) {
|
||||||
disposeListenerNumber -= 1;
|
disposeListenerNumber -= 1;
|
||||||
if( disposeListenerNumber == 0) { //if the last tab is closed, reset statusbar
|
if( disposeListenerNumber == 0) { //if the last tab is closed, reset statusbar
|
||||||
|
eventBroker.post(WaveStatusBarControl.ZOOM_LEVEL, null);
|
||||||
eventBroker.post(WaveStatusBarControl.CURSOR_TIME, null);
|
eventBroker.post(WaveStatusBarControl.CURSOR_TIME, null);
|
||||||
eventBroker.post(WaveStatusBarControl.MARKER_TIME, null);
|
eventBroker.post(WaveStatusBarControl.MARKER_TIME, null);
|
||||||
eventBroker.post(WaveStatusBarControl.MARKER_DIFF, null);
|
eventBroker.post(WaveStatusBarControl.MARKER_DIFF, null);
|
||||||
@ -1252,11 +1269,4 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
|||||||
} catch (BackingStoreException e) {}
|
} catch (BackingStoreException e) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectAll() {
|
|
||||||
List<TrackEntry> entries = waveformPane.getStreamList();
|
|
||||||
ISelection sel = new StructuredSelection(entries);
|
|
||||||
waveformPane.setSelection(sel);
|
|
||||||
designBrowser.selectAllWaveforms();
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -5,8 +5,6 @@ import java.io.File;
|
|||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.eclipse.e4.core.contexts.IEclipseContext;
|
|
||||||
import org.eclipse.e4.ui.model.application.ui.MUIElement;
|
|
||||||
import org.eclipse.jface.dialogs.MessageDialog;
|
import org.eclipse.jface.dialogs.MessageDialog;
|
||||||
import org.eclipse.jface.resource.ImageDescriptor;
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
import org.eclipse.jface.resource.ResourceLocator;
|
import org.eclipse.jface.resource.ResourceLocator;
|
||||||
@ -31,10 +29,6 @@ import com.minres.scviewer.e4.application.Messages;
|
|||||||
|
|
||||||
public class HelpBrowser {
|
public class HelpBrowser {
|
||||||
|
|
||||||
@Inject IEclipseContext ctx;
|
|
||||||
|
|
||||||
@Inject MUIElement element;
|
|
||||||
|
|
||||||
private static void decorateItem(ToolItem item, String label, String imageName) {
|
private static void decorateItem(ToolItem item, String label, String imageName) {
|
||||||
String fullpath = File.separator+"icons"+File.separator+imageName; //$NON-NLS-1$
|
String fullpath = File.separator+"icons"+File.separator+imageName; //$NON-NLS-1$
|
||||||
ImageDescriptor descr = ResourceLocator.imageDescriptorFromBundle("com.minres.scviewer.e4.application", fullpath).orElse(null); //$NON-NLS-1$
|
ImageDescriptor descr = ResourceLocator.imageDescriptorFromBundle("com.minres.scviewer.e4.application", fullpath).orElse(null); //$NON-NLS-1$
|
||||||
@ -47,12 +41,13 @@ public class HelpBrowser {
|
|||||||
item.setData(label);
|
item.setData(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public HelpBrowser() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
protected Control createComposite(Composite container) {
|
protected Control createComposite(Composite container) {
|
||||||
// container.getShell().addListener(SWT.Close, e -> {
|
|
||||||
// e.doit= false;
|
|
||||||
// element.setVisible(false);
|
|
||||||
// });
|
|
||||||
GridLayout gridLayout = new GridLayout();
|
GridLayout gridLayout = new GridLayout();
|
||||||
gridLayout.numColumns = 3;
|
gridLayout.numColumns = 3;
|
||||||
container.setLayout(gridLayout);
|
container.setLayout(gridLayout);
|
||||||
@ -147,7 +142,5 @@ public class HelpBrowser {
|
|||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleShellCloseEvent(){
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
7
plugins/com.minres.scviewer.help/.classpath
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||||
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry kind="output" path="bin"/>
|
||||||
|
</classpath>
|
28
plugins/com.minres.scviewer.help/.project
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>com.minres.scviewer.help</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.pde.PluginNature</nature>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
@ -0,0 +1,9 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=11
|
||||||
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||||
|
org.eclipse.jdt.core.compiler.release=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.source=11
|
8
plugins/com.minres.scviewer.help/META-INF/MANIFEST.MF
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
Manifest-Version: 1.0
|
||||||
|
Bundle-ManifestVersion: 2
|
||||||
|
Bundle-Name: SCViewer Help
|
||||||
|
Bundle-SymbolicName: com.minres.scviewer.help;singleton:=true
|
||||||
|
Bundle-Version: 1.0.0.qualifier
|
||||||
|
Bundle-Vendor: MINRES Technologies GmbH
|
||||||
|
Automatic-Module-Name: com.minres.scviewer.help
|
||||||
|
Bundle-RequiredExecutionEnvironment: JavaSE-11
|
7
plugins/com.minres.scviewer.help/build.properties
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
source.. = src/
|
||||||
|
output.. = bin/
|
||||||
|
bin.includes = plugin.xml,\
|
||||||
|
META-INF/,\
|
||||||
|
.,\
|
||||||
|
html/,\
|
||||||
|
*.xml
|
@ -0,0 +1,13 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||||
|
<title>Main Topic</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1>Main Topic</h1>
|
||||||
|
Please enter your text here.
|
||||||
|
</body>
|
||||||
|
</html>
|
13
plugins/com.minres.scviewer.help/html/concepts/subtopic.html
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||||
|
<title>Sub Topic</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1>Sub Topic</h1>
|
||||||
|
Please enter your text here.
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,13 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||||
|
<title>Sub Topic 2</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1>Sub Topic 2</h1>
|
||||||
|
Please enter your text here.
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,13 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||||
|
<title>Main Topic</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1>Main Topic</h1>
|
||||||
|
Please enter your text here.
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,13 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||||
|
<title>Sub Topic</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1>Sub Topic</h1>
|
||||||
|
Please enter your text here.
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,13 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||||
|
<title>Sub Topic 2</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1>Sub Topic 2</h1>
|
||||||
|
Please enter your text here.
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,13 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||||
|
<title>Main Topic</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1>Main Topic</h1>
|
||||||
|
Please enter your text here.
|
||||||
|
</body>
|
||||||
|
</html>
|