1 |
/* |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
* |
4 |
* Copyright (C) 2005-2007 Grigor Iliev <grigor@grigoriliev.com> |
* Copyright (C) 2005-2008 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
* |
6 |
* This file is part of JSampler. |
* This file is part of JSampler. |
7 |
* |
* |
98 |
private final FantasiaMenuBar menuBar = new FantasiaMenuBar(); |
private final FantasiaMenuBar menuBar = new FantasiaMenuBar(); |
99 |
private final JPanel rootPane = new JPanel(); |
private final JPanel rootPane = new JPanel(); |
100 |
private final MainPane mainPane = new MainPane(); |
private final MainPane mainPane = new MainPane(); |
|
private final DevicesPane devicesPane = new DevicesPane(); |
|
|
private final JScrollPane spDevicesPane = new JScrollPane(); |
|
101 |
|
|
102 |
private final JMenu recentScriptsMenu = |
private final JMenu recentScriptsMenu = |
103 |
new JMenu(i18n.getMenuLabel("actions.recentScripts")); |
new JMenu(i18n.getMenuLabel("actions.recentScripts")); |
104 |
|
|
105 |
private final JSplitPane hSplitPane; |
private final JSplitPane hSplitPane; |
106 |
|
|
107 |
private final SidePane sidePane = new SidePane(); |
private final LeftSidePane leftSidePane = new LeftSidePane(); |
108 |
|
private final RightSidePane rightSidePane = new RightSidePane(); |
109 |
private final JPanel rightPane; |
private final JPanel rightPane; |
110 |
|
|
111 |
private final LSConsoleFrame lsConsoleFrame = new LSConsoleFrame(); |
private final LSConsoleFrame lsConsoleFrame = new LSConsoleFrame(); |
115 |
private final JCheckBoxMenuItem cbmiToolBarVisible = |
private final JCheckBoxMenuItem cbmiToolBarVisible = |
116 |
new JCheckBoxMenuItem(i18n.getMenuLabel("view.toolBar")); |
new JCheckBoxMenuItem(i18n.getMenuLabel("view.toolBar")); |
117 |
|
|
118 |
private final JCheckBoxMenuItem cbmiSidePaneVisible = |
private final JCheckBoxMenuItem cbmiLeftSidePaneVisible = |
119 |
new JCheckBoxMenuItem(i18n.getMenuLabel("view.sidePane")); |
new JCheckBoxMenuItem(i18n.getMenuLabel("view.leftSidePane")); |
120 |
|
|
121 |
private final JCheckBoxMenuItem cbmiDevicesPaneVisible = |
private final JCheckBoxMenuItem cbmiRightSidePaneVisible = |
122 |
new JCheckBoxMenuItem(i18n.getMenuLabel("view.devicesPane")); |
new JCheckBoxMenuItem(i18n.getMenuLabel("view.rightSidePane")); |
123 |
|
|
124 |
/** Creates a new instance of <code>MainFrame</code> */ |
/** Creates a new instance of <code>MainFrame</code> */ |
125 |
public |
public |
135 |
hSplitPane = new JSplitPane ( |
hSplitPane = new JSplitPane ( |
136 |
JSplitPane.HORIZONTAL_SPLIT, |
JSplitPane.HORIZONTAL_SPLIT, |
137 |
true, // continuousLayout |
true, // continuousLayout |
138 |
sidePane, rightPane |
leftSidePane, rightPane |
139 |
); |
); |
140 |
hSplitPane.setResizeWeight(0.5); |
hSplitPane.setResizeWeight(0.5); |
141 |
|
|
166 |
|
|
167 |
c.fill = GridBagConstraints.BOTH; |
c.fill = GridBagConstraints.BOTH; |
168 |
|
|
|
spDevicesPane.setViewportView(devicesPane); |
|
|
spDevicesPane.setBorder(BorderFactory.createEmptyBorder()); |
|
|
int h = spDevicesPane.getMinimumSize().height; |
|
|
spDevicesPane.setMinimumSize(new Dimension(200, h)); |
|
|
|
|
169 |
c.gridx = 1; |
c.gridx = 1; |
170 |
c.gridy = 0; |
c.gridy = 0; |
171 |
c.weightx = 1.0; |
c.weightx = 1.0; |
172 |
c.weighty = 1.0; |
c.weighty = 1.0; |
173 |
c.insets = new Insets(0, 3, 3, 0); |
c.insets = new Insets(0, 3, 0, 0); |
174 |
gridbag.setConstraints(spDevicesPane, c); |
gridbag.setConstraints(rightSidePane, c); |
175 |
p.add(spDevicesPane); |
p.add(rightSidePane); |
176 |
|
|
177 |
c.gridx = 0; |
c.gridx = 0; |
178 |
c.gridy = 0; |
c.gridy = 0; |
179 |
c.weightx = 0.0; |
c.weightx = 0.0; |
180 |
c.weighty = 1.0; |
c.weighty = 1.0; |
181 |
c.insets = new Insets(0, 3, 3, 3); |
c.insets = new Insets(0, 3, 0, 3); |
182 |
c.fill = GridBagConstraints.VERTICAL; |
c.fill = GridBagConstraints.VERTICAL; |
183 |
gridbag.setConstraints(mainPane, c); |
gridbag.setConstraints(mainPane, c); |
184 |
p.add(mainPane); |
p.add(mainPane); |
239 |
if(dlg.isCancelled()) return; |
if(dlg.isCancelled()) return; |
240 |
} |
} |
241 |
|
|
242 |
sidePane.savePreferences(); |
leftSidePane.savePreferences(); |
243 |
|
rightSidePane.savePreferences(); |
244 |
|
|
245 |
int i = hSplitPane.getDividerLocation(); |
int i = hSplitPane.getDividerLocation(); |
246 |
preferences().setIntProperty("MainFrame.hSplitDividerLocation", i); |
preferences().setIntProperty("MainFrame.hSplitDividerLocation", i); |
391 |
cbmiToolBarVisible.setSelected(b); |
cbmiToolBarVisible.setSelected(b); |
392 |
showToolBar(b); |
showToolBar(b); |
393 |
|
|
394 |
cbmiSidePaneVisible.setAccelerator(KeyStroke.getKeyStroke ( |
cbmiLeftSidePaneVisible.setAccelerator(KeyStroke.getKeyStroke ( |
395 |
KeyEvent.VK_L, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK |
KeyEvent.VK_L, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK |
396 |
)); |
)); |
397 |
m.add(cbmiSidePaneVisible); |
m.add(cbmiLeftSidePaneVisible); |
398 |
|
|
399 |
cbmiSidePaneVisible.addActionListener(new ActionListener() { |
cbmiLeftSidePaneVisible.addActionListener(new ActionListener() { |
400 |
public void |
public void |
401 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
402 |
showSidePane(cbmiSidePaneVisible.getState()); |
showSidePane(cbmiLeftSidePaneVisible.getState()); |
403 |
} |
} |
404 |
}); |
}); |
405 |
|
|
406 |
b = preferences().getBoolProperty("sidePane.visible"); |
b = preferences().getBoolProperty("leftSidePane.visible"); |
407 |
cbmiSidePaneVisible.setSelected(b); |
cbmiLeftSidePaneVisible.setSelected(b); |
408 |
showSidePane(b); |
showSidePane(b); |
409 |
|
|
410 |
cbmiDevicesPaneVisible.setAccelerator(KeyStroke.getKeyStroke ( |
cbmiRightSidePaneVisible.setAccelerator(KeyStroke.getKeyStroke ( |
411 |
KeyEvent.VK_R, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK |
KeyEvent.VK_R, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK |
412 |
)); |
)); |
413 |
m.add(cbmiDevicesPaneVisible); |
m.add(cbmiRightSidePaneVisible); |
414 |
|
|
415 |
cbmiDevicesPaneVisible.addActionListener(new ActionListener() { |
cbmiRightSidePaneVisible.addActionListener(new ActionListener() { |
416 |
public void |
public void |
417 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
418 |
showDevicesPane(cbmiDevicesPaneVisible.getState()); |
showDevicesPane(cbmiRightSidePaneVisible.getState()); |
419 |
} |
} |
420 |
}); |
}); |
421 |
|
|
422 |
b = preferences().getBoolProperty("devicesPane.visible"); |
b = preferences().getBoolProperty("rightSidePane.visible"); |
423 |
cbmiDevicesPaneVisible.setSelected(b); |
cbmiRightSidePaneVisible.setSelected(b); |
424 |
showDevicesPane(b); |
showDevicesPane(b); |
425 |
|
|
426 |
|
|
625 |
|
|
626 |
private void |
private void |
627 |
showSidePane(boolean b) { |
showSidePane(boolean b) { |
628 |
preferences().setBoolProperty("sidePane.visible", b); |
preferences().setBoolProperty("leftSidePane.visible", b); |
629 |
rootPane.remove(rightPane); |
rootPane.remove(rightPane); |
630 |
rootPane.remove(hSplitPane); |
rootPane.remove(hSplitPane); |
631 |
|
|
657 |
|
|
658 |
private void |
private void |
659 |
showDevicesPane(boolean b) { |
showDevicesPane(boolean b) { |
660 |
preferences().setBoolProperty("devicesPane.visible", b); |
preferences().setBoolProperty("rightSidePane.visible", b); |
661 |
|
|
662 |
int width = sidePane.getWidth(); |
int width = leftSidePane.getWidth(); |
663 |
int height = sidePane.getPreferredSize().height; |
int height = leftSidePane.getPreferredSize().height; |
664 |
if(width != 0) sidePane.setPreferredSize(new Dimension(width, height)); |
if(width != 0) leftSidePane.setPreferredSize(new Dimension(width, height)); |
665 |
|
|
666 |
if(b) { |
if(b) { |
667 |
int w = preferences().getIntProperty("devicesPane.width", 200); |
int w = preferences().getIntProperty("devicesPane.width", 200); |
668 |
|
|
669 |
int h = spDevicesPane.getPreferredSize().height; |
int h = rightSidePane.getPreferredSize().height; |
670 |
spDevicesPane.setPreferredSize(new Dimension(w, h)); |
rightSidePane.setPreferredSize(new Dimension(w, h)); |
671 |
} else { |
} else { |
672 |
int w = spDevicesPane.getWidth(); |
int w = rightSidePane.getWidth(); |
673 |
if(w > 0 && w < 200) w = 200; |
if(w > 0 && w < 200) w = 200; |
674 |
if(w != 0) preferences().setIntProperty("devicesPane.width", w); |
if(w != 0) preferences().setIntProperty("devicesPane.width", w); |
675 |
} |
} |
676 |
|
|
677 |
hSplitPane.setResizeWeight(0.0); |
hSplitPane.setResizeWeight(0.0); |
678 |
spDevicesPane.setVisible(b); |
rightSidePane.setVisible(b); |
679 |
hSplitPane.resetToPreferredSizes(); |
hSplitPane.resetToPreferredSizes(); |
680 |
|
|
681 |
int w = getPreferredSize().width; |
int w = getPreferredSize().width; |
694 |
|
|
695 |
private void |
private void |
696 |
sidePanesVisibilityChanged() { |
sidePanesVisibilityChanged() { |
697 |
boolean sidePaneVisible = cbmiSidePaneVisible.isSelected(); |
boolean leftSidePaneVisible = cbmiLeftSidePaneVisible.isSelected(); |
698 |
boolean devicesPaneVisible = cbmiDevicesPaneVisible.isSelected(); |
boolean rightSidePaneVisible = cbmiRightSidePaneVisible.isSelected(); |
699 |
|
|
700 |
if(sidePaneVisible && devicesPaneVisible) { |
if(leftSidePaneVisible && rightSidePaneVisible) { |
701 |
hSplitPane.setResizeWeight(0.5); |
hSplitPane.setResizeWeight(0.5); |
702 |
} else if(sidePaneVisible && !devicesPaneVisible) { |
} else if(leftSidePaneVisible && !rightSidePaneVisible) { |
703 |
hSplitPane.setResizeWeight(1.0); |
hSplitPane.setResizeWeight(1.0); |
704 |
} |
} |
705 |
|
|
706 |
if(!sidePaneVisible && !devicesPaneVisible) { |
if(!leftSidePaneVisible && !rightSidePaneVisible) { |
707 |
standardBar.showFantasiaLogo(false); |
standardBar.showFantasiaLogo(false); |
708 |
if(isResizable()) setResizable(false); |
if(isResizable()) setResizable(false); |
709 |
} else { |
} else { |