Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 81d480f10c76dbf6e2ee8f75a23ab7ec12df3c74 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*******************************************************************************
 * Copyright (c) 2008, 2018 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});
	}

	@Override
	public boolean equals(Object obj) {
		if (obj != null) {
			if (getClass().equals(obj.getClass())) {
				return ((SequencerControl)obj).getSequencer().equals(getSequencer());

			}
		}
		return false;
	}

	@Override
	public int hashCode() {
		return getSequencer().hashCode() + getClass().hashCode();
	}
}

Back to the top