Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/MidiEventLabelProvider.java26
-rw-r--r--org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/TrackColumnPresentation.java23
-rw-r--r--org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/TrackLabelProvider.java8
3 files changed, 44 insertions, 13 deletions
diff --git a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/MidiEventLabelProvider.java b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/MidiEventLabelProvider.java
index 955b12846..b357c67b7 100644
--- a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/MidiEventLabelProvider.java
+++ b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/MidiEventLabelProvider.java
@@ -11,6 +11,8 @@
package org.eclipse.debug.examples.ui.midi.adapters;
import javax.sound.midi.MidiEvent;
+import javax.sound.midi.MidiMessage;
+import javax.sound.midi.ShortMessage;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.internal.ui.model.elements.ElementLabelProvider;
@@ -29,18 +31,28 @@ public class MidiEventLabelProvider extends ElementLabelProvider {
*/
protected String getLabel(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException {
MidiEvent event = (MidiEvent) elementPath.getLastSegment();
+ MidiMessage message = event.getMessage();
if (TrackColumnPresentation.COL_TICK.equals(columnId)) {
return Long.toString(event.getTick());
- } else if (TrackColumnPresentation.COL_MESSAGE.equals(columnId)) {
- byte[] bytes = event.getMessage().getMessage();
+ } else if (TrackColumnPresentation.COL_BYTES.equals(columnId)) {
+ byte[] bytes = message.getMessage();
StringBuffer buffer = new StringBuffer();
- int status = event.getMessage().getStatus();
- appendByte(buffer, status);
- for (int i = 1; i < bytes.length; i++) {
+ for (int i = 0; i < message.getLength(); i++) {
buffer.append(' ');
appendByte(buffer, bytes[i]);
}
return buffer.toString();
+ } else if (TrackColumnPresentation.COL_COMMAND.equals(columnId)) {
+ if (message instanceof ShortMessage) {
+ ShortMessage sm = (ShortMessage) message;
+ StringBuffer buf = new StringBuffer();
+ appendByte(buf, (byte)sm.getCommand());
+ return buf.toString();
+ }
+ } else if (TrackColumnPresentation.COL_CHANNEL.equals(columnId)) {
+ if (message instanceof ShortMessage) {
+ return Integer.toString(((ShortMessage)message).getChannel());
+ }
}
return "";
}
@@ -51,8 +63,8 @@ public class MidiEventLabelProvider extends ElementLabelProvider {
* @param buffer
* @param b
*/
- private void appendByte(StringBuffer buffer, int b) {
- String hex = Integer.toHexString(b).toUpperCase();
+ private void appendByte(StringBuffer buffer, byte b) {
+ String hex = Integer.toHexString(b & 0xFF).toUpperCase();
for (int i = hex.length(); i < 2; i++) {
buffer.append('0');
}
diff --git a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/TrackColumnPresentation.java b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/TrackColumnPresentation.java
index c09337169..05713db26 100644
--- a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/TrackColumnPresentation.java
+++ b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/TrackColumnPresentation.java
@@ -23,12 +23,19 @@ public class TrackColumnPresentation extends AbstractColumnPresentation {
* Column identifiers
*/
public static final String COL_TICK = "TICK";
- public static final String COL_MESSAGE = "MESSAGE";
+ public static final String COL_BYTES = "BYTES";
+ public static final String COL_COMMAND = "COMMAND";
+ public static final String COL_CHANNEL = "CHANNEL";
/**
* All columns
*/
- public static final String[] COLUMN_IDS = new String[]{COL_TICK, COL_MESSAGE};
+ public static final String[] COLUMN_IDS = new String[]{COL_TICK, COL_BYTES, COL_COMMAND, COL_CHANNEL};
+
+ /**
+ * Initial columns
+ */
+ public static final String[] COLUMN_INITIAL = new String[]{COL_TICK, COL_BYTES};
/**
* Column presentation ID.
@@ -49,8 +56,14 @@ public class TrackColumnPresentation extends AbstractColumnPresentation {
if (COL_TICK.equals(id)) {
return "Tick";
}
- if (COL_MESSAGE.equals(id)) {
- return "Message";
+ if (COL_BYTES.equals(id)) {
+ return "Bytes";
+ }
+ if (COL_CHANNEL.equals(id)) {
+ return "Channel";
+ }
+ if (COL_COMMAND.equals(id)) {
+ return "Command";
}
return "";
}
@@ -66,7 +79,7 @@ public class TrackColumnPresentation extends AbstractColumnPresentation {
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation#getInitialColumns()
*/
public String[] getInitialColumns() {
- return COLUMN_IDS;
+ return COLUMN_INITIAL;
}
/* (non-Javadoc)
diff --git a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/TrackLabelProvider.java b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/TrackLabelProvider.java
index eb48c3494..fa8f891fb 100644
--- a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/TrackLabelProvider.java
+++ b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/TrackLabelProvider.java
@@ -38,7 +38,13 @@ public class TrackLabelProvider extends ElementLabelProvider {
break;
}
}
- return "Track " + i;
+ StringBuffer buf = new StringBuffer();
+ buf.append("Track ");
+ buf.append(i);
+ buf.append(" [");
+ buf.append(track.size());
+ buf.append(" events]");
+ return buf.toString();
}
}

Back to the top