Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.debug.examples.ui')
-rw-r--r--org.eclipse.debug.examples.ui/plugin.xml11
-rw-r--r--org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/ControlEventHandler.java10
-rw-r--r--org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/SequencerContentProvider.java8
-rw-r--r--org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/SequencerControlsModelProxy.java17
-rw-r--r--org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/detailpanes/ClockSliderDetailPane.java111
-rw-r--r--org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/detailpanes/ControlDetailPaneFactory.java21
6 files changed, 169 insertions, 9 deletions
diff --git a/org.eclipse.debug.examples.ui/plugin.xml b/org.eclipse.debug.examples.ui/plugin.xml
index c84e5956a..a646b37c0 100644
--- a/org.eclipse.debug.examples.ui/plugin.xml
+++ b/org.eclipse.debug.examples.ui/plugin.xml
@@ -252,9 +252,14 @@
value="1">
</count>
<iterate>
- <instanceof
- value="org.eclipse.debug.examples.core.midi.launcher.TempoControl">
- </instanceof>
+ <or>
+ <instanceof
+ value="org.eclipse.debug.examples.core.midi.launcher.TempoControl">
+ </instanceof>
+ <instanceof
+ value="org.eclipse.debug.examples.core.midi.launcher.ClockControl">
+ </instanceof>
+ </or>
</iterate>
</with>
</enablement>
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
index 9472914a9..363718233 100644
--- 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
@@ -15,7 +15,7 @@ import java.util.TimerTask;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.examples.core.midi.launcher.MidiLaunch;
-import org.eclipse.debug.examples.core.midi.launcher.TimeControl;
+import org.eclipse.debug.examples.core.midi.launcher.ClockControl;
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;
@@ -45,6 +45,12 @@ public class ControlEventHandler extends DebugEventHandler {
super(proxy);
fLaunch = proxy.getMidiLaunch();
}
+
+ protected void init() {
+ if (!fLaunch.isSuspended() && !fLaunch.isTerminated() && !fLaunch.isDisconnected()) {
+ startTimer();
+ }
+ }
/* (non-Javadoc)
* @see org.eclipse.debug.internal.ui.viewers.update.DebugEventHandler#handlesEvent(org.eclipse.debug.core.DebugEvent)
@@ -87,7 +93,7 @@ public class ControlEventHandler extends DebugEventHandler {
fTimer.schedule(new TimerTask() {
public void run() {
ModelDelta delta = new ModelDelta(fLaunch, IModelDelta.NO_CHANGE);
- delta = delta.addNode(new TimeControl(fLaunch), IModelDelta.STATE);
+ delta = delta.addNode(new ClockControl(fLaunch), IModelDelta.STATE);
fireDelta(delta);
}
}, 0, 100);
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
index b4c04b6f5..1f57c9b1a 100644
--- 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
@@ -14,10 +14,11 @@ import javax.sound.midi.Sequencer;
import javax.sound.midi.Track;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.examples.core.midi.launcher.LengthControl;
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.examples.core.midi.launcher.ClockControl;
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;
@@ -37,7 +38,7 @@ public class SequencerContentProvider extends ElementContentProvider {
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 3;
}
return 0;
}
@@ -63,7 +64,8 @@ public class SequencerContentProvider extends ElementContentProvider {
public SequencerControl[] getControls(MidiLaunch launch) {
return new SequencerControl[]{
new TempoControl(launch),
- new TimeControl(launch)
+ new ClockControl(launch),
+ new LengthControl(launch)
};
}
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
index ac0e0b3a7..e200493fe 100644
--- 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
@@ -17,6 +17,7 @@ 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;
+import org.eclipse.jface.viewers.Viewer;
/**
* Model proxy for a sequencer in the variables view. Listens
@@ -33,6 +34,11 @@ public class SequencerControlsModelProxy extends EventHandlerModelProxy {
private MidiLaunch fLaunch;
/**
+ * Event handler
+ */
+ private ControlEventHandler fHandler;
+
+ /**
* Constructs a model proxy to update based on changes in controls
* for the associated sequencer.
*
@@ -42,6 +48,14 @@ public class SequencerControlsModelProxy extends EventHandlerModelProxy {
fLaunch = launch;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.provisional.AbstractModelProxy#installed(org.eclipse.jface.viewers.Viewer)
+ */
+ public void installed(Viewer viewer) {
+ super.installed(viewer);
+ fHandler.init();
+ }
+
/**
* Returns the launch assocaited with this proxy.
*
@@ -55,7 +69,8 @@ public class SequencerControlsModelProxy extends EventHandlerModelProxy {
* @see org.eclipse.debug.internal.ui.viewers.update.EventHandlerModelProxy#createEventHandlers()
*/
protected DebugEventHandler[] createEventHandlers() {
- return new DebugEventHandler[]{new ControlEventHandler(this)};
+ fHandler = new ControlEventHandler(this);
+ return new DebugEventHandler[]{fHandler};
}
/* (non-Javadoc)
diff --git a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/detailpanes/ClockSliderDetailPane.java b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/detailpanes/ClockSliderDetailPane.java
new file mode 100644
index 000000000..234618f4a
--- /dev/null
+++ b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/detailpanes/ClockSliderDetailPane.java
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * 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.ClockControl;
+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 the clock position.
+ *
+ * @since 1.0
+ */
+public class ClockSliderDetailPane implements IDetailPane {
+
+ private Slider fSlider;
+ private ClockControl 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(0);
+ fSlider.setMaximum(1000);
+ 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 = (ClockControl) selection.getFirstElement();
+ int max = (int)fControl.getSequencer().getMicrosecondLength() / 1000000;
+ long micro = fControl.getSequencer().getMicrosecondPosition();
+ int seconds = (int) micro / 1000000;
+ fSlider.setMaximum(max);
+ fSlider.setSelection(seconds);
+ }
+ }
+
+ /* (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 "Location (seconds)";
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.IDetailPane#getID()
+ */
+ public String getID() {
+ return ControlDetailPaneFactory.ID_CLOCK_SLIDER;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.IDetailPane#getName()
+ */
+ public String getName() {
+ return "Clock Slider (seconds)";
+ }
+
+ /* (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/detailpanes/ControlDetailPaneFactory.java b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/detailpanes/ControlDetailPaneFactory.java
index d258abf7d..10353fd57 100644
--- 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
@@ -13,6 +13,7 @@ package org.eclipse.debug.examples.ui.midi.detailpanes;
import java.util.HashSet;
import java.util.Set;
+import org.eclipse.debug.examples.core.midi.launcher.ClockControl;
import org.eclipse.debug.examples.core.midi.launcher.TempoControl;
import org.eclipse.debug.ui.IDetailPane;
import org.eclipse.debug.ui.IDetailPaneFactory;
@@ -29,6 +30,11 @@ public class ControlDetailPaneFactory implements IDetailPaneFactory {
* Identifier for the tempo slider detail pane
*/
public static final String ID_TEMPO_SLIDER = "TEMPO_SLIDER";
+
+ /**
+ * Identifier for the clock slider detail pane
+ */
+ public static final String ID_CLOCK_SLIDER = "CLOCK_SLIDER";
/* (non-Javadoc)
* @see org.eclipse.debug.ui.IDetailPaneFactory#createDetailPane(java.lang.String)
@@ -37,6 +43,9 @@ public class ControlDetailPaneFactory implements IDetailPaneFactory {
if (ID_TEMPO_SLIDER.equals(paneID)) {
return new TempoSliderDetailPane();
}
+ if (ID_CLOCK_SLIDER.equals(paneID)) {
+ return new ClockSliderDetailPane();
+ }
return null;
}
@@ -49,6 +58,9 @@ public class ControlDetailPaneFactory implements IDetailPaneFactory {
if (element instanceof TempoControl) {
return ID_TEMPO_SLIDER;
}
+ if (element instanceof ClockControl) {
+ return ID_CLOCK_SLIDER;
+ }
}
return null;
}
@@ -60,6 +72,9 @@ public class ControlDetailPaneFactory implements IDetailPaneFactory {
if (ID_TEMPO_SLIDER.equals(paneID)) {
return "Tempo Slider";
}
+ if (ID_CLOCK_SLIDER.equals(paneID)) {
+ return "Clock Slider";
+ }
return null;
}
@@ -70,6 +85,9 @@ public class ControlDetailPaneFactory implements IDetailPaneFactory {
if (ID_TEMPO_SLIDER.equals(paneID)) {
return "Tempo Slider";
}
+ if (ID_CLOCK_SLIDER.equals(paneID)) {
+ return "Clock Slider";
+ }
return null;
}
@@ -83,6 +101,9 @@ public class ControlDetailPaneFactory implements IDetailPaneFactory {
if (element instanceof TempoControl) {
set.add(ID_TEMPO_SLIDER);
}
+ if (element instanceof ClockControl) {
+ set.add(ID_CLOCK_SLIDER);
+ }
}
return set;
}

Back to the top