diff --git a/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF b/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF index 7c8389f..8407a07 100644 --- a/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF +++ b/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: com.minres.scviewer.e4.application;singleton:=true -Bundle-Version: 2.1.1.qualifier +Bundle-Version: 2.1.2.qualifier Bundle-Vendor: %Bundle-Vendor Require-Bundle: javax.inject;bundle-version="1.0.0", org.eclipse.core.runtime;bundle-version="3.11.1", diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/DesignBrowser.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/DesignBrowser.java index f2444fa..b9a92dd 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/DesignBrowser.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/DesignBrowser.java @@ -199,12 +199,16 @@ public class DesignBrowser { @Override public void selectionChanged(SelectionChangedEvent event) { ISelection selection=event.getSelection(); - if( selection instanceof IStructuredSelection) { + if( selection instanceof IStructuredSelection) { Object object= ((IStructuredSelection)selection).getFirstElement(); - if(object instanceof IHierNode&& ((IHierNode)object).getChildNodes().size()!=0){ + if(object instanceof IHierNode && ((IHierNode)object).getChildNodes().size()!=0){ txTableViewer.setInput(object); updateButtons(); } + else { //if selection is changed but empty + txTableViewer.setInput(null); + updateButtons(); + } } } }); @@ -250,8 +254,8 @@ public class DesignBrowser { @Override public void selectionChanged(SelectionChangedEvent event) { - selectionService.setSelection(event.getSelection()); - updateButtons(); + selectionService.setSelection(event.getSelection()); + updateButtons(); } }); diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java index 26d42c6..27bd372 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java @@ -249,6 +249,10 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis }); waveformPane = factory.createPanel(parent); waveformPane.setMaxTime(0); + + //set selection to empty selection when opening a new waveformPane + selectionService.setSelection(new StructuredSelection()); + waveformPane.addPropertyChangeListener(IWaveformViewer.CURSOR_PROPERTY, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { @@ -268,11 +272,13 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis eventBroker.post(WaveStatusBarControl.MARKER_DIFF, waveformPane.getScaledTime(cursor - time)); } }); + waveformPane.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { - if (event.getSelection() instanceof IStructuredSelection) + if (event.getSelection() instanceof IStructuredSelection) { selectionService.setSelection(event.getSelection()); + } } }); waveformPane.getWaveformControl().addMouseTrackListener(new MouseTrackListener() { diff --git a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/Hex.java b/com.minres.scviewer.ui/src/com/minres/scviewer/ui/Hex.java new file mode 100644 index 0000000..c68ed72 --- /dev/null +++ b/com.minres.scviewer.ui/src/com/minres/scviewer/ui/Hex.java @@ -0,0 +1,36 @@ +package com.minres.scviewer.ui; +public final class Hex { + public static byte[] decode(final String hex) { + if (hex.length() % 2 != 0) { + throw new IllegalArgumentException("A hex string must contain an even number of characters: " + hex); + } + + byte[] out = new byte[hex.length() / 2]; + + for (int i = 0; i < hex.length(); i += 2) { + int high = Character.digit(hex.charAt(i), 16); + int low = Character.digit(hex.charAt(i + 1), 16); + if (high == -1 || low == -1) { + throw new IllegalArgumentException("A hex string can only contain the characters 0-9, A-F, a-f: " + hex); + } + + out[i / 2] = (byte) (high * 16 + low); + } + + return out; + } + + private static final char[] UPPER_HEX_DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', }; + + public static String encode(final byte[] bytes) { + StringBuilder stringBuilder = new StringBuilder(bytes.length * 2); + for (byte cur : bytes) { + stringBuilder.append(UPPER_HEX_DIGITS[(cur >> 4) & 0xF]); + stringBuilder.append(UPPER_HEX_DIGITS[(cur & 0xF)]); + } + return stringBuilder.toString(); + } + + private Hex() { + } +} \ No newline at end of file diff --git a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/TxEditorInputFactory.java b/com.minres.scviewer.ui/src/com/minres/scviewer/ui/TxEditorInputFactory.java index fae3c0c..cb58c0b 100644 --- a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/TxEditorInputFactory.java +++ b/com.minres.scviewer.ui/src/com/minres/scviewer/ui/TxEditorInputFactory.java @@ -71,7 +71,7 @@ public class TxEditorInputFactory implements IElementFactory { String listData = memento.getString(TAG_STREAMLIST); if (listData != null) { try { - ByteArrayInputStream bais = new ByteArrayInputStream(javax.xml.bind.DatatypeConverter.parseHexBinary(listData)); + ByteArrayInputStream bais = new ByteArrayInputStream(Hex.decode(listData)); ObjectInputStream ois = new ObjectInputStream(bais); Object obj = ois.readObject(); if(obj instanceof List) @@ -107,8 +107,9 @@ public class TxEditorInputFactory implements IElementFactory { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(input.getStreamNames()); - memento.putString(TAG_STREAMLIST, javax.xml.bind.DatatypeConverter.printHexBinary(baos.toByteArray())); + memento.putString(TAG_STREAMLIST, Hex.encode(baos.toByteArray())); } catch (IOException e) { } } + }