Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Wright2008-01-28 10:04:24 -0500
committerDarin Wright2008-01-28 10:04:24 -0500
commitdf58149b7c876b39c609e095fb247a356fe402cc (patch)
treed9f91b962628b8e372e39cb7622d0819d64001a3 /org.eclipse.debug.examples.ui
parentb4150306417b8daa5a0847c09392316930014fd7 (diff)
downloadeclipse.platform.debug-df58149b7c876b39c609e095fb247a356fe402cc.tar.gz
eclipse.platform.debug-df58149b7c876b39c609e095fb247a356fe402cc.tar.xz
eclipse.platform.debug-df58149b7c876b39c609e095fb247a356fe402cc.zip
initial release of additional MIDI example
Diffstat (limited to 'org.eclipse.debug.examples.ui')
-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
20 files changed, 1151 insertions, 2 deletions
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