Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: e50d90bf9e7ded85a558c76bff108a8b83c7f12f (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
/*******************************************************************************
 * Copyright (c) 2008 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * 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 {

	@Override
	public boolean canModify(Object element, String property) {
		if (SequencerColumnPresentation.COL_VALUE.equals(property)) {
			if (element instanceof SequencerControl) {
				return ((SequencerControl) element).isEditable();
			}
		}
		return false;
	}

	@Override
	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;
	}

	@Override
	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);
					}
				}
	        }
		}
	}

}

Back to the top