Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: a69e40801b74c43c03e24f1c83812ed7a0eb2e88 (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
/*******************************************************************************
 * Copyright (c) 2008, 2018 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.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;
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-NLS-1$

	/**
	 * Identifier for the clock slider detail pane
	 */
	public static final String ID_CLOCK_SLIDER = "CLOCK_SLIDER"; //$NON-NLS-1$

	@Override
	public IDetailPane createDetailPane(String paneID) {
		if (ID_TEMPO_SLIDER.equals(paneID)) {
			return new TempoSliderDetailPane();
		}
		if (ID_CLOCK_SLIDER.equals(paneID)) {
			return new ClockSliderDetailPane();
		}
		return null;
	}

	@Override
	public String getDefaultDetailPane(IStructuredSelection selection) {
		if (selection.size() == 1) {
			Object element = selection.getFirstElement();
			if (element instanceof TempoControl) {
				return ID_TEMPO_SLIDER;
			}
			if (element instanceof ClockControl) {
				return ID_CLOCK_SLIDER;
			}
		}
		return null;
	}

	@Override
	public String getDetailPaneDescription(String paneID) {
		if (ID_TEMPO_SLIDER.equals(paneID)) {
			return "Tempo Slider"; //$NON-NLS-1$
		}
		if (ID_CLOCK_SLIDER.equals(paneID)) {
			return "Clock Slider"; //$NON-NLS-1$
		}
		return null;
	}

	@Override
	public String getDetailPaneName(String paneID) {
		if (ID_TEMPO_SLIDER.equals(paneID)) {
			return "Tempo Slider"; //$NON-NLS-1$
		}
		if (ID_CLOCK_SLIDER.equals(paneID)) {
			return "Clock Slider"; //$NON-NLS-1$
		}
		return null;
	}

	@Override
	public Set<String> getDetailPaneTypes(IStructuredSelection selection) {
		Set<String> set = new HashSet<>();
		if (selection.size() == 1) {
			Object element = selection.getFirstElement();
			if (element instanceof TempoControl) {
				set.add(ID_TEMPO_SLIDER);
			}
			if (element instanceof ClockControl) {
				set.add(ID_CLOCK_SLIDER);
			}
		}
		return set;
	}

}

Back to the top