Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.debug.examples.core/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.debug.examples.core/plugin.xml9
-rw-r--r--org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/midi/launcher/MidiLaunch.java145
-rw-r--r--org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/midi/launcher/MidiLaunchDelegate.java117
-rw-r--r--org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/midi/launcher/SequencerControl.java112
-rw-r--r--org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/midi/launcher/TempoControl.java107
-rw-r--r--org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/midi/launcher/TimeControl.java86
-rw-r--r--org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/DebugCorePlugin.java7
-rw-r--r--org.eclipse.debug.examples.ui/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.debug.examples.ui/icons/full/obj16/note.gifbin0 -> 895 bytes
-rw-r--r--org.eclipse.debug.examples.ui/plugin.xml62
-rw-r--r--org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/ControlCellModifier.java67
-rw-r--r--org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/ControlEditor.java41
-rw-r--r--org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/ControlEventHandler.java49
-rw-r--r--org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/ControlLabelProvider.java40
-rw-r--r--org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/ControlsMementoProvider.java42
-rw-r--r--org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/MidiAdapterFactory.java81
-rw-r--r--org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/SequencerColumnFactory.java45
-rw-r--r--org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/SequencerColumnPresentation.java79
-rw-r--r--org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/SequencerContentProvider.java92
-rw-r--r--org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/SequencerControlsModelProxy.java71
-rw-r--r--org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/SequencerModelProxyFactory.java39
-rw-r--r--org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/TrackLabelProvider.java35
-rw-r--r--org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/detailpanes/ControlDetailPaneFactory.java90
-rw-r--r--org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/detailpanes/TempoSliderDetailPane.java108
-rw-r--r--org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/launcher/MidiMainTab.java168
-rw-r--r--org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/launcher/MidiTabGroup.java33
-rw-r--r--org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/DebugUIPlugin.java8
28 files changed, 1735 insertions, 4 deletions
diff --git a/org.eclipse.debug.examples.core/META-INF/MANIFEST.MF b/org.eclipse.debug.examples.core/META-INF/MANIFEST.MF
index 0de72ed97..2401c49ee 100644
--- a/org.eclipse.debug.examples.core/META-INF/MANIFEST.MF
+++ b/org.eclipse.debug.examples.core/META-INF/MANIFEST.MF
@@ -9,7 +9,8 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.variables,
org.eclipse.debug.core
Eclipse-LazyStart: true
-Export-Package: org.eclipse.debug.examples.core.pda,
+Export-Package: org.eclipse.debug.examples.core.midi.launcher,
+ org.eclipse.debug.examples.core.pda,
org.eclipse.debug.examples.core.pda.breakpoints,
org.eclipse.debug.examples.core.pda.launcher,
org.eclipse.debug.examples.core.pda.model,
diff --git a/org.eclipse.debug.examples.core/plugin.xml b/org.eclipse.debug.examples.core/plugin.xml
index 0133be329..90ceead9c 100644
--- a/org.eclipse.debug.examples.core/plugin.xml
+++ b/org.eclipse.debug.examples.core/plugin.xml
@@ -22,6 +22,15 @@
</extension>
<!--#endif-->
+ <extension
+ point="org.eclipse.debug.core.launchConfigurationTypes">
+ <launchConfigurationType
+ delegate="org.eclipse.debug.examples.core.midi.launcher.MidiLaunchDelegate"
+ name="MIDI Sequence"
+ id="midi.launchType"
+ modes="run, debug"/>
+ </extension>
+
<!--#ifdef ex4-->
<!--#else-->
<extension
diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/midi/launcher/MidiLaunch.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/midi/launcher/MidiLaunch.java
new file mode 100644
index 000000000..b47b5a276
--- /dev/null
+++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/midi/launcher/MidiLaunch.java
@@ -0,0 +1,145 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.examples.core.midi.launcher;
+
+import javax.sound.midi.MidiFileFormat;
+import javax.sound.midi.Sequencer;
+
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.Launch;
+import org.eclipse.debug.core.model.ISuspendResume;
+
+/**
+ * A launch containing a MIDI sequencer.
+ *
+ * @since 1.0
+ */
+public class MidiLaunch extends Launch implements ISuspendResume {
+
+ /**
+ * MIDI Sequencer
+ */
+ private Sequencer fSequencer;
+
+ /**
+ * MIDI file format
+ */
+ private MidiFileFormat fFormat;
+
+ /**
+ * Constructs a new MIDI launch.
+ *
+ * @param launchConfiguration configuration to play
+ * @param mode mode to play in
+ */
+ public MidiLaunch(ILaunchConfiguration launchConfiguration, String mode) {
+ super(launchConfiguration, mode, null);
+ }
+
+ /**
+ * Sets the sequencer used to play MIDI files.
+ *
+ * @param sequencer
+ */
+ public void setSequencer(Sequencer sequencer) {
+ fSequencer = sequencer;
+ fireChanged();
+ }
+
+ /**
+ * Sets the format of the sequence
+ * @param format
+ */
+ public void setFormat(MidiFileFormat format) {
+ fFormat = format;
+ }
+
+ /**
+ * Returns the sequencer used to play MIDI files.
+ *
+ * @return the sequencer used to play MIDI files
+ */
+ public Sequencer getSequencer() {
+ return fSequencer;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.Launch#canTerminate()
+ */
+ public boolean canTerminate() {
+ return getSequencer().isOpen();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.Launch#isTerminated()
+ */
+ public boolean isTerminated() {
+ if (fSequencer != null) {
+ return !fSequencer.isOpen();
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.Launch#terminate()
+ */
+ public void terminate() throws DebugException {
+ getSequencer().stop();
+ getSequencer().close();
+ fireTerminate();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#canResume()
+ */
+ public boolean canResume() {
+ return isSuspended();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#canSuspend()
+ */
+ public boolean canSuspend() {
+ if (fSequencer != null) {
+ return fSequencer.isRunning();
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#isSuspended()
+ */
+ public boolean isSuspended() {
+ if (fSequencer != null) {
+ return fSequencer.isOpen() & !fSequencer.isRunning();
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#resume()
+ */
+ public void resume() throws DebugException {
+ getSequencer().start();
+ fireChanged();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#suspend()
+ */
+ public void suspend() throws DebugException {
+ getSequencer().stop();
+ fireChanged();
+ }
+
+
+}
diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/midi/launcher/MidiLaunchDelegate.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/midi/launcher/MidiLaunchDelegate.java
new file mode 100644
index 000000000..221fef395
--- /dev/null
+++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/midi/launcher/MidiLaunchDelegate.java
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.examples.core.midi.launcher;
+
+import java.io.BufferedInputStream;
+import java.io.IOException;
+
+import javax.sound.midi.InvalidMidiDataException;
+import javax.sound.midi.MidiFileFormat;
+import javax.sound.midi.MidiSystem;
+import javax.sound.midi.MidiUnavailableException;
+import javax.sound.midi.Sequencer;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
+import org.eclipse.debug.examples.core.pda.DebugCorePlugin;
+
+/**
+ * Creates and starts a MIDI sequencer.
+ *
+ * @since 1.0
+ */
+public class MidiLaunchDelegate extends LaunchConfigurationDelegate {
+
+ /**
+ * Identifier for the MIDI launch configuration type
+ * (value <code>midi.launchType</code>)
+ */
+ public static final String ID_MIDI_LAUNCH_CONFIGURATION_TYPE = "midi.launchType";
+
+ /**
+ * Launch configuration attribute for the MIDI file to play
+ * (value <code>midi.file</code>)
+ */
+ public static final String ATTR_MIDI_FILE = "midi.file";
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
+ String fileName = configuration.getAttribute(ATTR_MIDI_FILE, (String)null);
+ if (fileName == null) {
+ abort("MIDI file not specified.", null);
+ }
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IFile file = root.getFile(new Path(fileName));
+ if (!file.exists()) {
+ abort("MIDI file does not exist.", null);
+ }
+ Sequencer sequencer = null;
+ MidiFileFormat fileFormat = null;
+ try {
+ sequencer = MidiSystem.getSequencer();
+ sequencer.open();
+ IPath location = file.getLocation();
+ if (location != null) {
+ fileFormat = MidiSystem.getMidiFileFormat(location.toFile());
+ }
+ } catch (MidiUnavailableException e) {
+ abort("Cannot initialize sequencer.", e);
+ } catch (InvalidMidiDataException e) {
+ abort("Invalid MIDI file.", e);
+ } catch (IOException e) {
+ abort("Error reading MIDI file.", e);
+ }
+ BufferedInputStream stream = new BufferedInputStream(file.getContents());
+ try {
+ sequencer.setSequence(stream);
+ } catch (IOException e) {
+ abort("Error reading MIDI file", e);
+ } catch (InvalidMidiDataException e) {
+ abort("Inavlid MIDI file.", e);
+ }
+ MidiLaunch midiLaunch = (MidiLaunch)launch;
+ midiLaunch.setSequencer(sequencer);
+ midiLaunch.setFormat(fileFormat);
+ sequencer.start();
+ }
+
+ /**
+ * Throws an exception with a new status containing the given
+ * message and optional exception.
+ *
+ * @param message error message
+ * @param e underlying exception
+ * @throws CoreException
+ */
+ private void abort(String message, Throwable e) throws CoreException {
+ throw new CoreException(new Status(IStatus.ERROR, DebugCorePlugin.getDefault().getDescriptor().getUniqueIdentifier(), 0, message, e));
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate2#getLaunch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
+ */
+ public ILaunch getLaunch(ILaunchConfiguration configuration, String mode) throws CoreException {
+ return new MidiLaunch(configuration, mode);
+ }
+
+}
diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/midi/launcher/SequencerControl.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/midi/launcher/SequencerControl.java
new file mode 100644
index 000000000..945036875
--- /dev/null
+++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/midi/launcher/SequencerControl.java
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.examples.core.midi.launcher;
+
+import javax.sound.midi.Sequencer;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugPlugin;
+
+/**
+ * Controls some aspect of a MIDI sequencer.
+ *
+ * @since 1.0
+ */
+public abstract class SequencerControl {
+
+ /**
+ * The launch
+ */
+ private MidiLaunch fLaunch;
+
+ /**
+ * Control name
+ */
+ private String fName;
+
+ /**
+ * Constructs a control with the given name.
+ */
+ public SequencerControl(String name, MidiLaunch launch) {
+ fName = name;
+ fLaunch = launch;
+ }
+
+ /**
+ * Returns the launch this control is associated with.
+ *
+ * @return MIDI launch
+ */
+ public MidiLaunch getLaunch() {
+ return fLaunch;
+ }
+
+ /**
+ * Returns the sequencer associated with this control.
+ *
+ * @return associated sequencer
+ */
+ public Sequencer getSequencer() {
+ return fLaunch.getSequencer();
+ }
+
+ /**
+ * Returns the name of this control.
+ *
+ * @return control name
+ */
+ public String getName() {
+ return fName;
+ }
+
+ /**
+ * Returns this controls current value.
+ *
+ * @return current value
+ */
+ public abstract String getValue();
+
+ /**
+ * Whether this contol's value can be modified.
+ *
+ * @return Whether this contol's value can be modified
+ */
+ public abstract boolean isEditable();
+
+ /**
+ * Returns a status indicating if the given value is
+ * a valid value for this control to accept.
+ *
+ * @param value new value
+ * @return whether the value is valid
+ */
+ public abstract IStatus validateValue(String value);
+
+ /**
+ * Sets the value of this control to the given value
+ * and returns a status indicating if the value was
+ * successfully set.
+ *
+ * @param newValue value
+ * @return whether successful
+ */
+ public abstract IStatus setValue(String newValue);
+
+ /**
+ * Fires a debug event.
+ *
+ * @param event debug event to fire
+ */
+ public void fireEvent(DebugEvent event) {
+ DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] {event});
+ }
+}
diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/midi/launcher/TempoControl.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/midi/launcher/TempoControl.java
new file mode 100644
index 000000000..f6cc7f2ad
--- /dev/null
+++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/midi/launcher/TempoControl.java
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.examples.core.midi.launcher;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.examples.core.pda.DebugCorePlugin;
+
+/**
+ * Controls the tempo of a sequencer.
+ *
+ * @since 1.0
+ */
+public class TempoControl extends SequencerControl {
+
+ /**
+ * Constructs a tempo control for the given launch.
+ */
+ public TempoControl(MidiLaunch launch) {
+ super("Tempo (BPM)", launch);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.examples.core.midi.launcher.SequencerControl#getValue()
+ */
+ public String getValue() {
+ float bpm = getSequencer().getTempoInBPM();
+ return Float.toString(bpm);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.examples.core.midi.launcher.SequencerControl#isEditable()
+ */
+ public boolean isEditable() {
+ return getSequencer().isOpen();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.examples.core.midi.launcher.SequencerControl#setValue(java.lang.String)
+ */
+ public IStatus setValue(String newValue) {
+ try {
+ float value = getFloat(newValue);
+ getSequencer().setTempoInBPM(value);
+ fireEvent(new DebugEvent(this, DebugEvent.CHANGE));
+ return Status.OK_STATUS;
+ } catch (CoreException e) {
+ return e.getStatus();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.examples.core.midi.launcher.SequencerControl#validateValue(java.lang.String)
+ */
+ public IStatus validateValue(String value) {
+ try {
+ getFloat(value);
+ return Status.OK_STATUS;
+ } catch (CoreException e) {
+ return e.getStatus();
+ }
+ }
+
+ /**
+ * Returns a float for the string.
+ *
+ * @param value string
+ * @return float
+ * @throws CoreException if not a valid value
+ */
+ protected float getFloat(String value) throws CoreException {
+ try {
+ return Float.parseFloat(value);
+ } catch (NumberFormatException e) {
+ throw new CoreException(new Status(IStatus.ERROR, DebugCorePlugin.PLUGIN_ID, "Tempo must be a number", e));
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object obj) {
+ if (obj instanceof TempoControl) {
+ return ((TempoControl)obj).getSequencer().equals(getSequencer());
+
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode() {
+ return getSequencer().hashCode() + getClass().hashCode();
+ }
+
+}
diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/midi/launcher/TimeControl.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/midi/launcher/TimeControl.java
new file mode 100644
index 000000000..6f0be95e4
--- /dev/null
+++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/midi/launcher/TimeControl.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.examples.core.midi.launcher;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.examples.core.pda.DebugCorePlugin;
+
+/**
+ * Controls the location of the sequencer in microseconds.
+ *
+ * @since 1.0
+ */
+public class TimeControl extends SequencerControl {
+
+ /**
+ * @param name
+ * @param launch
+ */
+ public TimeControl(MidiLaunch launch) {
+ super("Time" , launch);
+ }
+
+ /**
+ * Returns a long for the string.
+ *
+ * @param value string
+ * @return long
+ * @throws CoreException if not a valid value
+ */
+ protected long getLong(String value) throws CoreException {
+ try {
+ return Long.parseLong(value);
+ } catch (NumberFormatException e) {
+ throw new CoreException(new Status(IStatus.ERROR, DebugCorePlugin.PLUGIN_ID, "Time must be a number", e));
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.examples.core.midi.launcher.SequencerControl#getValue()
+ */
+ public String getValue() {
+ long position = getSequencer().getMicrosecondPosition();
+ int milli = (int) (position & 0x3F);
+ int sec = (int) (position / 1000000);
+ StringBuffer clock = new StringBuffer();
+ clock.append(sec);
+ clock.append(':');
+ clock.append(milli);
+ return clock.toString();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.examples.core.midi.launcher.SequencerControl#isEditable()
+ */
+ public boolean isEditable() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.examples.core.midi.launcher.SequencerControl#setValue(java.lang.String)
+ */
+ public IStatus setValue(String newValue) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.examples.core.midi.launcher.SequencerControl#validateValue(java.lang.String)
+ */
+ public IStatus validateValue(String value) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/DebugCorePlugin.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/DebugCorePlugin.java
index f58fe8613..be74eb78a 100644
--- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/DebugCorePlugin.java
+++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/DebugCorePlugin.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation 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
@@ -55,6 +55,11 @@ public class DebugCorePlugin extends Plugin {
public static final String ID_PDA_LAUNCH_CONFIGURATION_TYPE = "pda.launchType";
/**
+ * Plug-in identifier.
+ */
+ public static final String PLUGIN_ID = "org.eclipse.debug.examples.core";
+
+ /**
* The constructor.
*/
public DebugCorePlugin() {
diff --git a/org.eclipse.debug.examples.ui/META-INF/MANIFEST.MF b/org.eclipse.debug.examples.ui/META-INF/MANIFEST.MF
index 0b61b2dbd..a2ac9041e 100644
--- a/org.eclipse.debug.examples.ui/META-INF/MANIFEST.MF
+++ b/org.eclipse.debug.examples.ui/META-INF/MANIFEST.MF
@@ -15,7 +15,8 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ui.ide,
org.eclipse.debug.examples.core
Eclipse-LazyStart: true
-Export-Package: org.eclipse.debug.examples.ui.pda,
+Export-Package: org.eclipse.debug.examples.ui.midi.launcher,
+ org.eclipse.debug.examples.ui.pda,
org.eclipse.debug.examples.ui.pda.adapters,
org.eclipse.debug.examples.ui.pda.breakpoints,
org.eclipse.debug.examples.ui.pda.editor,
diff --git a/org.eclipse.debug.examples.ui/icons/full/obj16/note.gif b/org.eclipse.debug.examples.ui/icons/full/obj16/note.gif
new file mode 100644
index 000000000..7bc1e0813
--- /dev/null
+++ b/org.eclipse.debug.examples.ui/icons/full/obj16/note.gif
Binary files differ
diff --git a/org.eclipse.debug.examples.ui/plugin.xml b/org.eclipse.debug.examples.ui/plugin.xml
index 3cc918c18..6809c0442 100644
--- a/org.eclipse.debug.examples.ui/plugin.xml
+++ b/org.eclipse.debug.examples.ui/plugin.xml
@@ -10,6 +10,11 @@
description="Specify and launch a PDA program"
id="pda.tabGroup"
type="pda.launchType"/>
+ <launchConfigurationTabGroup
+ class="org.eclipse.debug.examples.ui.midi.launcher.MidiTabGroup"
+ description="Play a MIDI file"
+ id="midi.tabGroup"
+ type="midi.launchType"/>
</extension>
<extension
point="org.eclipse.debug.ui.launchConfigurationTypeImages">
@@ -17,6 +22,10 @@
icon="icons/full/obj16/pda.gif"
configTypeID="pda.launchType"
id="pda.typeImage"/>
+ <launchConfigurationTypeImage
+ icon="icons/full/obj16/note.gif"
+ configTypeID="midi.launchType"
+ id="midi.typeImage"/>
</extension>
<extension
point="org.eclipse.debug.ui.launchShortcuts">
@@ -171,4 +180,57 @@
</factory>
-->
</extension>
+
+ <extension
+ point="org.eclipse.core.runtime.adapters">
+ <factory
+ class="org.eclipse.debug.examples.ui.midi.adapters.MidiAdapterFactory"
+ adaptableType="org.eclipse.debug.examples.core.midi.launcher.MidiLaunch">
+ <adapter type="org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider"/>
+ <adapter
+ type="org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory">
+ </adapter>
+ <adapter
+ type="org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactory">
+ </adapter>
+ <adapter
+ type="org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider">
+ </adapter>
+ </factory>
+ <factory
+ class="org.eclipse.debug.examples.ui.midi.adapters.MidiAdapterFactory"
+ adaptableType="javax.sound.midi.Track">
+ <adapter type="org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider"/>
+ </factory>
+ <factory
+ adaptableType="org.eclipse.debug.examples.core.midi.launcher.SequencerControl"
+ class="org.eclipse.debug.examples.ui.midi.adapters.MidiAdapterFactory">
+ <adapter
+ type="org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider">
+ </adapter>
+ <adapter
+ type="org.eclipse.debug.internal.ui.viewers.model.provisional.IElementEditor">
+ </adapter>
+ </factory>
+ </extension>
+ <extension
+ point="org.eclipse.debug.ui.detailPaneFactories">
+ <detailFactories
+ class="org.eclipse.debug.examples.ui.midi.detailpanes.ControlDetailPaneFactory"
+ id="org.eclipse.debug.examples.ui.controlFactory">
+ <enablement>
+ <with
+ variable="selection">
+ <count
+ value="1">
+ </count>
+ <iterate>
+ <instanceof
+ value="org.eclipse.debug.examples.core.midi.launcher.TempoControl">
+ </instanceof>
+ </iterate>
+ </with>
+ </enablement>
+ </detailFactories>
+ </extension>
</plugin>
diff --git a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/ControlCellModifier.java b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/ControlCellModifier.java
new file mode 100644
index 000000000..100f20e5a
--- /dev/null
+++ b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/ControlCellModifier.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.examples.ui.midi.adapters;
+
+import org.eclipse.debug.examples.core.midi.launcher.SequencerControl;
+import org.eclipse.jface.viewers.ICellModifier;
+
+/**
+ * A cell modifier for a sequencer control. Provides current
+ * values of controls and updates control values in the sequencer
+ * as they are changed in the UI.
+ *
+ * @since 1.0
+ */
+public class ControlCellModifier implements ICellModifier {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ICellModifier#canModify(java.lang.Object, java.lang.String)
+ */
+ public boolean canModify(Object element, String property) {
+ if (SequencerColumnPresentation.COL_VALUE.equals(property)) {
+ if (element instanceof SequencerControl) {
+ return ((SequencerControl) element).isEditable();
+ }
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ICellModifier#getValue(java.lang.Object, java.lang.String)
+ */
+ public Object getValue(Object element, String property) {
+ if (SequencerColumnPresentation.COL_VALUE.equals(property)) {
+ if (element instanceof SequencerControl) {
+ SequencerControl control = (SequencerControl) element;
+ return control.getValue();
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ICellModifier#modify(java.lang.Object, java.lang.String, java.lang.Object)
+ */
+ public void modify(Object element, String property, Object value) {
+ Object oldValue = getValue(element, property);
+ if (!value.equals(oldValue)) {
+ if (SequencerColumnPresentation.COL_VALUE.equals(property)) {
+ if (element instanceof SequencerControl) {
+ if (value instanceof String) {
+ SequencerControl control = (SequencerControl) element;
+ control.setValue((String) value);
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/ControlEditor.java b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/ControlEditor.java
new file mode 100644
index 000000000..ecb05ae8b
--- /dev/null
+++ b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/ControlEditor.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.examples.ui.midi.adapters;
+
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementEditor;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ICellModifier;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * Provides cell editors and modifiers for sequencer controls.
+ *
+ * @since 1.0
+ */
+public class ControlEditor implements IElementEditor {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IElementEditor#getCellEditor(org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, java.lang.String, java.lang.Object, org.eclipse.swt.widgets.Composite)
+ */
+ public CellEditor getCellEditor(IPresentationContext context, String columnId, Object element, Composite parent) {
+ return new TextCellEditor(parent);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IElementEditor#getCellModifier(org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, java.lang.Object)
+ */
+ public ICellModifier getCellModifier(IPresentationContext context, Object element) {
+ return new ControlCellModifier();
+ }
+
+}
diff --git a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/ControlEventHandler.java b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/ControlEventHandler.java
new file mode 100644
index 000000000..3766b9025
--- /dev/null
+++ b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/ControlEventHandler.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.examples.ui.midi.adapters;
+
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.examples.core.midi.launcher.MidiLaunch;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta;
+import org.eclipse.debug.internal.ui.viewers.update.DebugEventHandler;
+
+/**
+ * Listens to events from sequencer controls and fires corresponding
+ * deltas to update the viewer.
+ *
+ * @since 1.0
+ */
+public class ControlEventHandler extends DebugEventHandler {
+
+ private MidiLaunch fLaunch;
+
+ /**
+ * @param proxy
+ */
+ public ControlEventHandler(SequencerControlsModelProxy proxy) {
+ super(proxy);
+ fLaunch = proxy.getMidiLaunch();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.update.DebugEventHandler#handlesEvent(org.eclipse.debug.core.DebugEvent)
+ */
+ protected boolean handlesEvent(DebugEvent event) {
+ return true;
+ }
+
+ protected void refreshRoot(DebugEvent event) {
+ ModelDelta delta = new ModelDelta(fLaunch, IModelDelta.CONTENT);
+ fireDelta(delta);
+ }
+
+}
diff --git a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/ControlLabelProvider.java b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/ControlLabelProvider.java
new file mode 100644
index 000000000..f54234bf8
--- /dev/null
+++ b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/ControlLabelProvider.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.examples.ui.midi.adapters;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.examples.core.midi.launcher.SequencerControl;
+import org.eclipse.debug.internal.ui.model.elements.ElementLabelProvider;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
+import org.eclipse.jface.viewers.TreePath;
+
+/**
+ * Label provider for a sequencer control.
+ *
+ * @since 1.0
+ */
+public class ControlLabelProvider extends ElementLabelProvider {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.model.elements.ElementLabelProvider#getLabel(org.eclipse.jface.viewers.TreePath, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, java.lang.String)
+ */
+ protected String getLabel(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException {
+ SequencerControl control = (SequencerControl) elementPath.getLastSegment();
+ if (SequencerColumnPresentation.COL_NAME.equals(columnId)) {
+ return control.getName();
+ }
+ if (SequencerColumnPresentation.COL_VALUE.equals(columnId)) {
+ return control.getValue();
+ }
+ return "";
+ }
+
+}
diff --git a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/ControlsMementoProvider.java b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/ControlsMementoProvider.java
new file mode 100644
index 000000000..0dd91e62e
--- /dev/null
+++ b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/ControlsMementoProvider.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.examples.ui.midi.adapters;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.examples.core.midi.launcher.MidiLaunch;
+import org.eclipse.debug.examples.core.midi.launcher.TempoControl;
+import org.eclipse.debug.internal.ui.model.elements.DebugElementMementoProvider;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
+import org.eclipse.ui.IMemento;
+
+/**
+ * Provides mementos for sequencer elements.
+ *
+ * @since 1.0
+ */
+public class ControlsMementoProvider extends DebugElementMementoProvider {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.model.elements.DebugElementMementoProvider#getElementName(java.lang.Object, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext)
+ */
+ protected String getElementName(Object element, IPresentationContext context) throws CoreException {
+ if (element instanceof MidiLaunch) {
+ return "SEQUENCER";
+ }
+ if (element instanceof TempoControl) {
+ return "TEMPO_CONTROL";
+ }
+ return null;
+ }
+
+
+
+}
diff --git a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/MidiAdapterFactory.java b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/MidiAdapterFactory.java
new file mode 100644
index 000000000..1876feb1c
--- /dev/null
+++ b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/MidiAdapterFactory.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.examples.ui.midi.adapters;
+
+import javax.sound.midi.Track;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.debug.examples.core.midi.launcher.MidiLaunch;
+import org.eclipse.debug.examples.core.midi.launcher.SequencerControl;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementEditor;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactory;
+
+/**
+ * Adapter factory for MIDI elements.
+ *
+ * @since 1.0
+ */
+public class MidiAdapterFactory implements IAdapterFactory {
+
+ private static IElementContentProvider fgSequencerContentProvider = new SequencerContentProvider();
+
+ private static IElementLabelProvider fgTrackLabelProvider = new TrackLabelProvider();
+ private static IElementLabelProvider fgControlLabelProvider = new ControlLabelProvider();
+
+ private static IColumnPresentationFactory fgSequencerColumnFactory = new SequencerColumnFactory();
+
+ private static IModelProxyFactory fgSequencerModelProxyFactory = new SequencerModelProxyFactory();
+
+ private static IElementMementoProvider fgMementoProvider = new ControlsMementoProvider();
+
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ if (IElementContentProvider.class.equals(adapterType)) {
+ if (adaptableObject instanceof MidiLaunch) {
+ return fgSequencerContentProvider;
+ }
+ }
+ if (IElementLabelProvider.class.equals(adapterType)) {
+ if (adaptableObject instanceof Track) {
+ return fgTrackLabelProvider;
+ }
+ if (adaptableObject instanceof SequencerControl) {
+ return fgControlLabelProvider;
+ }
+ }
+ if (IColumnPresentationFactory.class.equals(adapterType)) {
+ if (adaptableObject instanceof MidiLaunch) {
+ return fgSequencerColumnFactory;
+ }
+ }
+ if (IElementEditor.class.equals(adapterType)) {
+ if (adaptableObject instanceof SequencerControl) {
+ return new ControlEditor();
+ }
+ }
+ if (IModelProxyFactory.class.equals(adapterType)) {
+ if (adaptableObject instanceof MidiLaunch) {
+ return fgSequencerModelProxyFactory;
+ }
+ }
+ if (IElementMementoProvider.class.equals(adapterType)) {
+ return fgMementoProvider;
+ }
+ return null;
+ }
+
+ public Class[] getAdapterList() {
+ return new Class[]{IElementContentProvider.class, IElementLabelProvider.class};
+ }
+}
diff --git a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/SequencerColumnFactory.java b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/SequencerColumnFactory.java
new file mode 100644
index 000000000..c102fdc37
--- /dev/null
+++ b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/SequencerColumnFactory.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.examples.ui.midi.adapters;
+
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
+import org.eclipse.debug.ui.IDebugUIConstants;
+
+/**
+ * Column presentation factory for a sequencer.
+ *
+ * @since 1.0
+ */
+public class SequencerColumnFactory implements IColumnPresentationFactory {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory#createColumnPresentation(org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, java.lang.Object)
+ */
+ public IColumnPresentation createColumnPresentation(IPresentationContext context, Object element) {
+ if (IDebugUIConstants.ID_VARIABLE_VIEW.equals(context.getId())) {
+ return new SequencerColumnPresentation();
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory#getColumnPresentationId(org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, java.lang.Object)
+ */
+ public String getColumnPresentationId(IPresentationContext context, Object element) {
+ if (IDebugUIConstants.ID_VARIABLE_VIEW.equals(context.getId())) {
+ return SequencerColumnPresentation.ID;
+ }
+ return null;
+ }
+
+}
diff --git a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/SequencerColumnPresentation.java b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/SequencerColumnPresentation.java
new file mode 100644
index 000000000..4542f844e
--- /dev/null
+++ b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/SequencerColumnPresentation.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.examples.ui.midi.adapters;
+
+import org.eclipse.debug.internal.ui.viewers.provisional.AbstractColumnPresentation;
+
+/**
+ * Columns for sequencer in the variables view.
+ *
+ * @since 1.0
+ */
+public class SequencerColumnPresentation extends AbstractColumnPresentation {
+
+ /**
+ * Column identifiers
+ */
+ public static final String COL_NAME = "NAME";
+ public static final String COL_VALUE = "VALUE";
+
+ /**
+ * All columns
+ */
+ public static final String[] COLUMN_IDS = new String[]{COL_NAME, COL_VALUE};
+
+ /**
+ * Column presentation ID.
+ */
+ public static final String ID = "org.eclipse.debug.examples.ui.midi.columnPresentation";
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation#getAvailableColumns()
+ */
+ public String[] getAvailableColumns() {
+ return COLUMN_IDS;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation#getHeader(java.lang.String)
+ */
+ public String getHeader(String id) {
+ if (COL_NAME.equals(id)) {
+ return "Control";
+ }
+ if (COL_VALUE.equals(id)) {
+ return "Value";
+ }
+ return "";
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation#getId()
+ */
+ public String getId() {
+ return ID;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation#getInitialColumns()
+ */
+ public String[] getInitialColumns() {
+ return COLUMN_IDS;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation#isOptional()
+ */
+ public boolean isOptional() {
+ return false;
+ }
+
+}
diff --git a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/SequencerContentProvider.java b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/SequencerContentProvider.java
new file mode 100644
index 000000000..b4c04b6f5
--- /dev/null
+++ b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/SequencerContentProvider.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.examples.ui.midi.adapters;
+
+import javax.sound.midi.Sequencer;
+import javax.sound.midi.Track;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.examples.core.midi.launcher.MidiLaunch;
+import org.eclipse.debug.examples.core.midi.launcher.SequencerControl;
+import org.eclipse.debug.examples.core.midi.launcher.TempoControl;
+import org.eclipse.debug.examples.core.midi.launcher.TimeControl;
+import org.eclipse.debug.internal.ui.model.elements.ElementContentProvider;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;
+import org.eclipse.debug.ui.IDebugUIConstants;
+
+/**
+ * Provides content for a MIDI sequencer element (MIDI launch).
+ *
+ * @since 1.0
+ */
+public class SequencerContentProvider extends ElementContentProvider {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.model.elements.ElementContentProvider#getChildCount(java.lang.Object, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate)
+ */
+ protected int getChildCount(Object element, IPresentationContext context, IViewerUpdate monitor) throws CoreException {
+ if (IDebugUIConstants.ID_DEBUG_VIEW.equals(context.getId())) {
+ return getTracks((MidiLaunch) element).length;
+ } else if (IDebugUIConstants.ID_VARIABLE_VIEW.equals(context.getId())) {
+ return 2;
+ }
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.model.elements.ElementContentProvider#getChildren(java.lang.Object, int, int, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate)
+ */
+ protected Object[] getChildren(Object parent, int index, int length, IPresentationContext context, IViewerUpdate monitor) throws CoreException {
+ if (IDebugUIConstants.ID_DEBUG_VIEW.equals(context.getId())) {
+ return getElements(getTracks((MidiLaunch) parent), index, length);
+ } else if (IDebugUIConstants.ID_VARIABLE_VIEW.equals(context.getId())) {
+ return getElements(getControls((MidiLaunch) parent), index, length);
+ }
+ return EMPTY;
+ }
+
+ /**
+ * Returns the controls for this sequencer.
+ *
+ * @param launch midi launch
+ * @return controls
+ */
+ public SequencerControl[] getControls(MidiLaunch launch) {
+ return new SequencerControl[]{
+ new TempoControl(launch),
+ new TimeControl(launch)
+ };
+ }
+
+ /**
+ * Returns all tracks in the sequence.
+ *
+ * @param launch MIDI launch
+ *@return tracks
+ */
+ public Track[] getTracks(MidiLaunch launch) {
+ Sequencer sequencer = launch.getSequencer();
+ if (sequencer != null) {
+ return sequencer.getSequence().getTracks();
+ }
+ return new Track[0];
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.model.elements.ElementContentProvider#supportsContextId(java.lang.String)
+ */
+ protected boolean supportsContextId(String id) {
+ return IDebugUIConstants.ID_DEBUG_VIEW.equals(id)
+ || IDebugUIConstants.ID_VARIABLE_VIEW.equals(id);
+ }
+
+}
diff --git a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/SequencerControlsModelProxy.java b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/SequencerControlsModelProxy.java
new file mode 100644
index 000000000..ec3439a10
--- /dev/null
+++ b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/SequencerControlsModelProxy.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.examples.ui.midi.adapters;
+
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.examples.core.midi.launcher.MidiLaunch;
+import org.eclipse.debug.examples.core.midi.launcher.SequencerControl;
+import org.eclipse.debug.internal.ui.viewers.update.DebugEventHandler;
+import org.eclipse.debug.internal.ui.viewers.update.EventHandlerModelProxy;
+
+/**
+ * Model proxy for a sequencer in the variables view. Listens
+ * to events from controls to update the viewer when the user
+ * changes a control's value.
+ *
+ * @since 1.0
+ */
+public class SequencerControlsModelProxy extends EventHandlerModelProxy {
+
+ /**
+ * Associated launch
+ */
+ private MidiLaunch fLaunch;
+
+ /**
+ * Constructs a model proxy to update based on changes in controls
+ * for the associated sequencer.
+ *
+ * @param launch MIDI launch
+ */
+ public SequencerControlsModelProxy(MidiLaunch launch) {
+ fLaunch = launch;
+ }
+
+ /**
+ * Returns the launch assocaited with this proxy.
+ *
+ * @return MIDI launch
+ */
+ protected MidiLaunch getMidiLaunch() {
+ return fLaunch;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.update.EventHandlerModelProxy#createEventHandlers()
+ */
+ protected DebugEventHandler[] createEventHandlers() {
+ return new DebugEventHandler[]{new ControlEventHandler(this)};
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.update.EventHandlerModelProxy#containsEvent(org.eclipse.debug.core.DebugEvent)
+ */
+ protected boolean containsEvent(DebugEvent event) {
+ if (event.getSource() instanceof SequencerControl) {
+ return ((SequencerControl)event.getSource()).getLaunch().equals(fLaunch);
+ }
+ return false;
+ }
+
+
+
+}
diff --git a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/SequencerModelProxyFactory.java b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/SequencerModelProxyFactory.java
new file mode 100644
index 000000000..cc6f658e4
--- /dev/null
+++ b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/SequencerModelProxyFactory.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.examples.ui.midi.adapters;
+
+import org.eclipse.debug.examples.core.midi.launcher.MidiLaunch;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxy;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactory;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
+import org.eclipse.debug.ui.IDebugUIConstants;
+
+/**
+ * Factory to create a model proxy for sequencer controls in
+ * the variables view.
+ *
+ * @since 1.0
+ */
+public class SequencerModelProxyFactory implements IModelProxyFactory {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactory#createModelProxy(java.lang.Object, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext)
+ */
+ public IModelProxy createModelProxy(Object element, IPresentationContext context) {
+ if (IDebugUIConstants.ID_VARIABLE_VIEW.equals(context.getId())) {
+ if (element instanceof MidiLaunch) {
+ return new SequencerControlsModelProxy((MidiLaunch)element);
+ }
+ }
+ return null;
+ }
+
+}
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
new file mode 100644
index 000000000..e27d4227b
--- /dev/null
+++ b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/TrackLabelProvider.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.examples.ui.midi.adapters;
+
+import javax.sound.midi.Track;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.internal.ui.model.elements.ElementLabelProvider;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
+import org.eclipse.jface.viewers.TreePath;
+
+/**
+ * Provides labels for MIDI tracks.
+ *
+ * @since 1.0
+ */
+public class TrackLabelProvider extends ElementLabelProvider {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.model.elements.ElementLabelProvider#getLabel(org.eclipse.jface.viewers.TreePath, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, java.lang.String)
+ */
+ protected String getLabel(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException {
+ Track track = (Track) elementPath.getLastSegment();
+ return "Track";
+ }
+
+}
diff --git a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/detailpanes/ControlDetailPaneFactory.java b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/detailpanes/ControlDetailPaneFactory.java
new file mode 100644
index 000000000..d258abf7d
--- /dev/null
+++ b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/detailpanes/ControlDetailPaneFactory.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.examples.ui.midi.detailpanes;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.debug.examples.core.midi.launcher.TempoControl;
+import org.eclipse.debug.ui.IDetailPane;
+import org.eclipse.debug.ui.IDetailPaneFactory;
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+/**
+ * Creates detail panes for sequencer controls.
+ *
+ * @since 1.0
+ */
+public class ControlDetailPaneFactory implements IDetailPaneFactory {
+
+ /**
+ * Identifier for the tempo slider detail pane
+ */
+ public static final String ID_TEMPO_SLIDER = "TEMPO_SLIDER";
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.IDetailPaneFactory#createDetailPane(java.lang.String)
+ */
+ public IDetailPane createDetailPane(String paneID) {
+ if (ID_TEMPO_SLIDER.equals(paneID)) {
+ return new TempoSliderDetailPane();
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.IDetailPaneFactory#getDefaultDetailPane(org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ public String getDefaultDetailPane(IStructuredSelection selection) {
+ if (selection.size() == 1) {
+ Object element = selection.getFirstElement();
+ if (element instanceof TempoControl) {
+ return ID_TEMPO_SLIDER;
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.IDetailPaneFactory#getDetailPaneDescription(java.lang.String)
+ */
+ public String getDetailPaneDescription(String paneID) {
+ if (ID_TEMPO_SLIDER.equals(paneID)) {
+ return "Tempo Slider";
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.IDetailPaneFactory#getDetailPaneName(java.lang.String)
+ */
+ public String getDetailPaneName(String paneID) {
+ if (ID_TEMPO_SLIDER.equals(paneID)) {
+ return "Tempo Slider";
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.IDetailPaneFactory#getDetailPaneTypes(org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ public Set getDetailPaneTypes(IStructuredSelection selection) {
+ Set set = new HashSet();
+ if (selection.size() == 1) {
+ Object element = selection.getFirstElement();
+ if (element instanceof TempoControl) {
+ set.add(ID_TEMPO_SLIDER);
+ }
+ }
+ return set;
+ }
+
+}
diff --git a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/detailpanes/TempoSliderDetailPane.java b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/detailpanes/TempoSliderDetailPane.java
new file mode 100644
index 000000000..d5e1c7bb7
--- /dev/null
+++ b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/detailpanes/TempoSliderDetailPane.java
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.examples.ui.midi.detailpanes;
+
+import org.eclipse.debug.examples.core.midi.launcher.TempoControl;
+import org.eclipse.debug.ui.IDetailPane;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Slider;
+import org.eclipse.ui.IWorkbenchPartSite;
+
+/**
+ * A slider to control tempo.
+ *
+ * @since 1.0
+ */
+public class TempoSliderDetailPane implements IDetailPane {
+
+ private Slider fSlider;
+ private TempoControl fControl;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.IDetailPane#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public Control createControl(Composite parent) {
+ fSlider = new Slider(parent, SWT.HORIZONTAL);
+ fSlider.setMinimum(20);
+ fSlider.setMaximum(500);
+ fSlider.addSelectionListener(new SelectionAdapter(){
+ public void widgetSelected(SelectionEvent e) {
+ int selection = fSlider.getSelection();
+ if (fControl != null) {
+ fControl.setValue(Integer.toString(selection));
+ }
+ }
+ });
+ return fSlider;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.IDetailPane#display(org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ public void display(IStructuredSelection selection) {
+ fControl = null;
+ if (selection == null || selection.isEmpty()) {
+ fSlider.setEnabled(false);
+ } else {
+ fSlider.setEnabled(true);
+ fControl = (TempoControl) selection.getFirstElement();
+ int bpm = (int)fControl.getSequencer().getTempoInBPM();
+ fSlider.setSelection(bpm);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.IDetailPane#dispose()
+ */
+ public void dispose() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.IDetailPane#getDescription()
+ */
+ public String getDescription() {
+ return "Tempo (beats per minute)";
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.IDetailPane#getID()
+ */
+ public String getID() {
+ return ControlDetailPaneFactory.ID_TEMPO_SLIDER;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.IDetailPane#getName()
+ */
+ public String getName() {
+ return "Tempo Slider (BPM)";
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.IDetailPane#init(org.eclipse.ui.IWorkbenchPartSite)
+ */
+ public void init(IWorkbenchPartSite partSite) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.IDetailPane#setFocus()
+ */
+ public boolean setFocus() {
+ fSlider.setFocus();
+ return true;
+ }
+
+}
diff --git a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/launcher/MidiMainTab.java b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/launcher/MidiMainTab.java
new file mode 100644
index 000000000..80dff6a7b
--- /dev/null
+++ b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/launcher/MidiMainTab.java
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.examples.ui.midi.launcher;
+
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.examples.core.midi.launcher.MidiLaunchDelegate;
+import org.eclipse.debug.examples.ui.pda.DebugUIPlugin;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.ResourceListSelectionDialog;
+
+
+/**
+ * Tab to specify the MIDI file to play.
+ *
+ * @since 1.0
+ */
+public class MidiMainTab extends AbstractLaunchConfigurationTab {
+
+ private Text fFileText;
+ private Button fFileButton;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ Font font = parent.getFont();
+
+ Composite comp = new Composite(parent, SWT.NONE);
+ setControl(comp);
+ GridLayout topLayout = new GridLayout();
+ topLayout.verticalSpacing = 0;
+ topLayout.numColumns = 3;
+ comp.setLayout(topLayout);
+ comp.setFont(font);
+
+ createVerticalSpacer(comp, 3);
+
+ Label programLabel = new Label(comp, SWT.NONE);
+ programLabel.setText("&Midi File:");
+ GridData gd = new GridData(GridData.BEGINNING);
+ programLabel.setLayoutData(gd);
+ programLabel.setFont(font);
+
+ fFileText = new Text(comp, SWT.SINGLE | SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ fFileText.setLayoutData(gd);
+ fFileText.setFont(font);
+ fFileText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ updateLaunchConfigurationDialog();
+ }
+ });
+
+ fFileButton = createPushButton(comp, "&Browse...", null); //$NON-NLS-1$
+ fFileButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ browseMidiFiles();
+ }
+ });
+ }
+
+ /**
+ * Open a resource chooser to select a MIDI file
+ */
+ protected void browseMidiFiles() {
+ ResourceListSelectionDialog dialog = new ResourceListSelectionDialog(getShell(), ResourcesPlugin.getWorkspace().getRoot(), IResource.FILE);
+ dialog.setTitle("MIDI File");
+ dialog.setMessage("Select MIDI File");
+ if (dialog.open() == Window.OK) {
+ Object[] files = dialog.getResult();
+ IFile file = (IFile) files[0];
+ fFileText.setText(file.getFullPath().toString());
+ }
+
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
+ */
+ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
+ */
+ public void initializeFrom(ILaunchConfiguration configuration) {
+ try {
+ String file = null;
+ file = configuration.getAttribute(MidiLaunchDelegate.ATTR_MIDI_FILE, (String)null);
+ if (file != null) {
+ fFileText.setText(file);
+ }
+ } catch (CoreException e) {
+ setErrorMessage(e.getMessage());
+ }
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
+ */
+ public void performApply(ILaunchConfigurationWorkingCopy configuration) {
+ String file = fFileText.getText().trim();
+ if (file.length() == 0) {
+ file = null;
+ }
+ configuration.setAttribute(MidiLaunchDelegate.ATTR_MIDI_FILE, file);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
+ */
+ public String getName() {
+ return "Main";
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration)
+ */
+ public boolean isValid(ILaunchConfiguration launchConfig) {
+ setErrorMessage(null);
+ setMessage(null);
+ String text = fFileText.getText();
+ if (text.length() > 0) {
+ IPath path = new Path(text);
+ if (ResourcesPlugin.getWorkspace().getRoot().findMember(path) == null) {
+ setErrorMessage("File does not exist");
+ return false;
+ }
+ } else {
+ setMessage("Select a MIDI file");
+ }
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getImage()
+ */
+ public Image getImage() {
+ return DebugUIPlugin.getDefault().getImageRegistry().get(DebugUIPlugin.IMG_OBJ_MIDI);
+ }
+}
diff --git a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/launcher/MidiTabGroup.java b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/launcher/MidiTabGroup.java
new file mode 100644
index 000000000..52e8b9dbd
--- /dev/null
+++ b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/launcher/MidiTabGroup.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.examples.ui.midi.launcher;
+
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
+import org.eclipse.debug.ui.CommonTab;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+
+/**
+ * Tab group for a MIDI file.
+ *
+ * @since 1.0
+ */
+public class MidiTabGroup extends AbstractLaunchConfigurationTabGroup {
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#createTabs(org.eclipse.debug.ui.ILaunchConfigurationDialog, java.lang.String)
+ */
+ public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
+ setTabs(new ILaunchConfigurationTab[] {
+ new MidiMainTab(),
+ new CommonTab()
+ });
+ }
+}
diff --git a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/DebugUIPlugin.java b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/DebugUIPlugin.java
index 9202d2d93..743b82ffd 100644
--- a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/DebugUIPlugin.java
+++ b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/DebugUIPlugin.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation 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
@@ -60,6 +60,11 @@ public class DebugUIPlugin extends AbstractUIPlugin {
public final static String IMG_OBJ_PDA = "IMB_OBJ_PDA";
/**
+ * MIDI file image
+ */
+ public final static String IMG_OBJ_MIDI = "IMB_OBJ_MIDI";
+
+ /**
* Keyword color
*/
public final static RGB KEYWORD = new RGB(0,0,255);
@@ -142,6 +147,7 @@ public class DebugUIPlugin extends AbstractUIPlugin {
*/
protected void initializeImageRegistry(ImageRegistry reg) {
declareImage(IMG_OBJ_PDA, PATH_OBJECT + "pda.gif");
+ declareImage(IMG_OBJ_MIDI, PATH_OBJECT + "note.gif");
declareImage(IMG_ELCL_POP, PATH_ELOCALTOOL + "pop.gif");
declareImage(IMG_DLCL_POP, PATH_DLOCALTOOL + "pop.gif");
declareImage(IMG_ELCL_PUSH, PATH_ELOCALTOOL + "push.gif");

Back to the top