Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Wright2008-02-01 03:26:19 +0000
committerDarin Wright2008-02-01 03:26:19 +0000
commit134d409a2d2a15ee251ce1c96576028e6c36f736 (patch)
treef622e314dfa2d8496f0b3cd2d61f7e9a3b9da6d0 /org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core
parent1ff19b0d40844b4970d3d599b43ccfe5616094e2 (diff)
downloadeclipse.platform.debug-134d409a2d2a15ee251ce1c96576028e6c36f736.tar.gz
eclipse.platform.debug-134d409a2d2a15ee251ce1c96576028e6c36f736.tar.xz
eclipse.platform.debug-134d409a2d2a15ee251ce1c96576028e6c36f736.zip
clock slider/control
Diffstat (limited to 'org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core')
-rw-r--r--org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/midi/launcher/ClockControl.java93
-rw-r--r--org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/midi/launcher/LengthControl.java36
-rw-r--r--org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/midi/launcher/SequencerControl.java8
-rw-r--r--org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/midi/launcher/TimeControl.java41
4 files changed, 149 insertions, 29 deletions
diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/midi/launcher/ClockControl.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/midi/launcher/ClockControl.java
new file mode 100644
index 000000000..639f1acf5
--- /dev/null
+++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/midi/launcher/ClockControl.java
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * 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 location of the sequencer in microseconds.
+ *
+ * @since 1.0
+ */
+public class ClockControl extends TimeControl {
+
+ /**
+ * @param launch
+ */
+ public ClockControl(MidiLaunch launch) {
+ super("Time" , launch);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.examples.core.midi.launcher.TimeControl#getTimeValue()
+ */
+ protected long getTimeValue() {
+ return getSequencer().getMicrosecondPosition();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.examples.core.midi.launcher.SequencerControl#isEditable()
+ */
+ public boolean isEditable() {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.examples.core.midi.launcher.SequencerControl#setValue(java.lang.String)
+ */
+ public IStatus setValue(String newValue) {
+ try {
+ long value = getLong(newValue);
+ getSequencer().setMicrosecondPosition(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 {
+ getLong(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 long getLong(String value) throws CoreException {
+ try {
+ if (value.indexOf(':') == -1) {
+ long secs = Long.parseLong(value);
+ return secs * 1000000;
+ }
+ } catch (NumberFormatException e) {
+ throw new CoreException(new Status(IStatus.ERROR, DebugCorePlugin.PLUGIN_ID, "Time must be an integer (seconds) or 00:00 (minutes:seconds) format", e));
+ }
+ return 0L;
+ }
+
+
+}
diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/midi/launcher/LengthControl.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/midi/launcher/LengthControl.java
new file mode 100644
index 000000000..3a754c91a
--- /dev/null
+++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/midi/launcher/LengthControl.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * 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;
+
+
+/**
+ * Describes the length of the sequence in microseconds.
+ *
+ * @since 1.0
+ */
+public class LengthControl extends TimeControl {
+
+ /**
+ * @param launch
+ */
+ public LengthControl(MidiLaunch launch) {
+ super("Duration" , launch);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.examples.core.midi.launcher.TimeControl#getTimeValue()
+ */
+ protected long getTimeValue() {
+ return getSequencer().getMicrosecondLength();
+ }
+
+
+}
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
index fcc56c97c..3274582cc 100644
--- 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
@@ -114,9 +114,11 @@ public abstract class SequencerControl {
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(Object obj) {
- if (obj.getClass().equals(getClass())) {
- return ((SequencerControl)obj).getSequencer().equals(getSequencer());
-
+ if (obj != null) {
+ if (getClass().equals(obj.getClass())) {
+ return ((SequencerControl)obj).getSequencer().equals(getSequencer());
+
+ }
}
return false;
}
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
index 19200ba0e..93aa54df4 100644
--- 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
@@ -10,46 +10,31 @@
*******************************************************************************/
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.
+ * Displays a time value based on underlying microsecond value
*
* @since 1.0
*/
-public class TimeControl extends SequencerControl {
+public abstract class TimeControl extends SequencerControl {
/**
+ * Constructs a time control with the given name for the
+ * given launch.
+ *
* @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));
- }
+ public TimeControl(String name, MidiLaunch launch) {
+ super(name, launch);
}
/* (non-Javadoc)
* @see org.eclipse.debug.examples.core.midi.launcher.SequencerControl#getValue()
*/
public String getValue() {
- long position = getSequencer().getMicrosecondPosition();
+ long position = getTimeValue();
int milli = (int) (position & 0x3F);
int sec = (int) (position / 1000000);
int min = sec / 60;
@@ -71,12 +56,18 @@ public class TimeControl extends SequencerControl {
}
return clock.toString();
}
+
+ /**
+ * Provided by subclasses for the control.
+ *
+ * @return time in microseconds
+ */
+ protected abstract long getTimeValue();
/* (non-Javadoc)
* @see org.eclipse.debug.examples.core.midi.launcher.SequencerControl#isEditable()
*/
public boolean isEditable() {
- // TODO Auto-generated method stub
return false;
}
@@ -84,7 +75,6 @@ public class TimeControl extends SequencerControl {
* @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;
}
@@ -92,7 +82,6 @@ public class TimeControl extends SequencerControl {
* @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;
}

Back to the top