75 |
private final JComboBox cbOrchestras = new JComboBox(); |
private final JComboBox cbOrchestras = new JComboBox(); |
76 |
private final OrchestraPane orchestraPane = new OrchestraPane(); |
private final OrchestraPane orchestraPane = new OrchestraPane(); |
77 |
|
|
78 |
|
/** |
79 |
|
* Because the orchestras are added after the view is created, |
80 |
|
* we need to remember the orchestra used in the previous session. |
81 |
|
*/ |
82 |
|
private int orchIdx; |
83 |
|
|
84 |
/** Creates a new instance of <code>OrchestrasPane</code> */ |
/** Creates a new instance of <code>OrchestrasPane</code> */ |
85 |
public |
public |
86 |
OrchestrasPane() { |
OrchestrasPane() { |
110 |
add(taskPaneContainer, BorderLayout.NORTH); |
add(taskPaneContainer, BorderLayout.NORTH); |
111 |
add(new InstrumentsPane()); |
add(new InstrumentsPane()); |
112 |
|
|
113 |
|
orchIdx = preferences().getIntProperty("OrchestrasPane.OrchestraIndex", 0); |
114 |
|
|
115 |
cbOrchestras.addActionListener(new ActionListener() { |
cbOrchestras.addActionListener(new ActionListener() { |
116 |
public void |
public void |
117 |
actionPerformed(ActionEvent e) { orchestraChanged(); } |
actionPerformed(ActionEvent e) { orchestraChanged(); } |
123 |
|
|
124 |
CC.getOrchestras().addOrchestraListListener(getHandler()); |
CC.getOrchestras().addOrchestraListListener(getHandler()); |
125 |
cbOrchestras.setEnabled(cbOrchestras.getItemCount() != 0); |
cbOrchestras.setEnabled(cbOrchestras.getItemCount() != 0); |
126 |
|
|
127 |
|
|
128 |
|
if(CC.getOrchestras().getOrchestraCount() > orchIdx) { |
129 |
|
cbOrchestras.setSelectedIndex(orchIdx); |
130 |
|
orchIdx = -1; |
131 |
|
} |
132 |
} |
} |
133 |
|
|
134 |
public void |
public void |
147 |
if(s != null && s.length() == 0) s = null; |
if(s != null && s.length() == 0) s = null; |
148 |
cbOrchestras.setToolTipText(s); |
cbOrchestras.setToolTipText(s); |
149 |
} |
} |
150 |
|
|
151 |
|
int i = cbOrchestras.getSelectedIndex(); |
152 |
|
if(i >= 0) preferences().setIntProperty("OrchestrasPane.OrchestraIndex", i); |
153 |
} |
} |
154 |
|
|
155 |
class InstrumentsPane extends JPanel { |
class InstrumentsPane extends JPanel { |
281 |
entryAdded(ListEvent<OrchestraModel> e) { |
entryAdded(ListEvent<OrchestraModel> e) { |
282 |
if(cbOrchestras.getItemCount() == 0) cbOrchestras.setEnabled(true); |
if(cbOrchestras.getItemCount() == 0) cbOrchestras.setEnabled(true); |
283 |
cbOrchestras.addItem(e.getEntry()); |
cbOrchestras.addItem(e.getEntry()); |
284 |
|
|
285 |
|
// we do this because the orchestras are added after creation of the view. |
286 |
|
if(orchIdx != -1 && cbOrchestras.getItemCount() > orchIdx) { |
287 |
|
cbOrchestras.setSelectedIndex(orchIdx); |
288 |
|
orchIdx = -1; |
289 |
|
} |
290 |
} |
} |
291 |
|
|
292 |
/** Invoked when an orchestra is removed from the orchestra list. */ |
/** Invoked when an orchestra is removed from the orchestra list. */ |
294 |
entryRemoved(ListEvent<OrchestraModel> e) { |
entryRemoved(ListEvent<OrchestraModel> e) { |
295 |
cbOrchestras.removeItem(e.getEntry()); |
cbOrchestras.removeItem(e.getEntry()); |
296 |
if(cbOrchestras.getItemCount() == 0) cbOrchestras.setEnabled(false); |
if(cbOrchestras.getItemCount() == 0) cbOrchestras.setEnabled(false); |
297 |
|
|
298 |
|
if(orchIdx != -1) orchIdx = -1; |
299 |
} |
} |
300 |
|
|
301 |
/** Invoked when the name of orchestra is changed. */ |
/** Invoked when the name of orchestra is changed. */ |