m@37973
|
1 |
/*
|
m@37973
|
2 |
* IsacToolPanel.java
|
m@37973
|
3 |
* part of the Isac plugin for the jEdit text editor
|
m@37973
|
4 |
* Copyright Gadei
|
m@37973
|
5 |
* jgellene@nyc.rr.com
|
m@37973
|
6 |
*
|
m@37973
|
7 |
* This program is free software; you can redistribute it and/or
|
m@37973
|
8 |
* modify it under the terms of the GNU General Public License
|
m@37973
|
9 |
* as published by the Free Software Foundation; either version 2
|
m@37973
|
10 |
* of the License, or any later version.
|
m@37973
|
11 |
*
|
m@37973
|
12 |
* This program is distributed in the hope that it will be useful,
|
m@37973
|
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
m@37973
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
m@37973
|
15 |
* GNU General Public License for more details.
|
m@37973
|
16 |
*
|
m@37973
|
17 |
* You should have received a copy of the GNU General Public License
|
m@37973
|
18 |
* along with this program; if not, write to the Free Software
|
m@37973
|
19 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
m@37973
|
20 |
*
|
m@37973
|
21 |
* $Id: IsacToolPanel.java 12504 2008-04-22 23:12:43Z ezust $
|
m@37973
|
22 |
*/
|
m@37973
|
23 |
|
m@37973
|
24 |
import java.awt.event.ActionEvent;
|
m@37973
|
25 |
import java.awt.event.ActionListener;
|
m@37973
|
26 |
|
m@37973
|
27 |
import javax.swing.AbstractButton;
|
m@37973
|
28 |
import javax.swing.Box;
|
m@37973
|
29 |
import javax.swing.BoxLayout;
|
m@37973
|
30 |
import javax.swing.JLabel;
|
m@37973
|
31 |
import javax.swing.JPanel;
|
m@37973
|
32 |
|
m@37973
|
33 |
import org.gjt.sp.jedit.GUIUtilities;
|
m@37973
|
34 |
import org.gjt.sp.jedit.jEdit;
|
m@37973
|
35 |
import org.gjt.sp.jedit.gui.RolloverButton;
|
m@37973
|
36 |
|
m@37973
|
37 |
public class IsacToolPanel extends JPanel {
|
m@37973
|
38 |
private Isac pad;
|
m@37973
|
39 |
|
m@37973
|
40 |
private JLabel label;
|
m@37973
|
41 |
|
m@37973
|
42 |
public IsacToolPanel(Isac qnpad) {
|
m@37973
|
43 |
setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
|
m@37973
|
44 |
pad = qnpad;
|
m@37973
|
45 |
|
m@37973
|
46 |
Box labelBox = new Box(BoxLayout.Y_AXIS);
|
m@37973
|
47 |
labelBox.add(Box.createGlue());
|
m@37973
|
48 |
|
m@37973
|
49 |
label = new JLabel(pad.getFilename());
|
m@37973
|
50 |
label.setVisible(jEdit.getProperty(
|
m@37973
|
51 |
IsacPlugin.OPTION_PREFIX + "show-filepath").equals(
|
m@37973
|
52 |
"true"));
|
m@37973
|
53 |
|
m@37973
|
54 |
labelBox.add(label);
|
m@37973
|
55 |
labelBox.add(Box.createGlue());
|
m@37973
|
56 |
|
m@37973
|
57 |
add(labelBox);
|
m@37973
|
58 |
|
m@37973
|
59 |
add(Box.createGlue());
|
m@37973
|
60 |
|
m@37973
|
61 |
add(makeCustomButton("isac.choose-file", new ActionListener() {
|
m@37973
|
62 |
public void actionPerformed(ActionEvent evt) {
|
m@37973
|
63 |
IsacToolPanel.this.pad.chooseFile();
|
m@37973
|
64 |
}
|
m@37973
|
65 |
}));
|
m@37973
|
66 |
add(makeCustomButton("isac.save-file", new ActionListener() {
|
m@37973
|
67 |
public void actionPerformed(ActionEvent evt) {
|
m@37973
|
68 |
IsacToolPanel.this.pad.saveFile();
|
m@37973
|
69 |
}
|
m@37973
|
70 |
}));
|
m@37973
|
71 |
add(makeCustomButton("isac.copy-to-buffer",
|
m@37973
|
72 |
new ActionListener() {
|
m@37973
|
73 |
public void actionPerformed(ActionEvent evt) {
|
m@37973
|
74 |
IsacToolPanel.this.pad.copyToBuffer();
|
m@37973
|
75 |
}
|
m@37973
|
76 |
}));
|
m@37973
|
77 |
}
|
m@37973
|
78 |
|
m@37973
|
79 |
void propertiesChanged() {
|
m@37973
|
80 |
label.setText(pad.getFilename());
|
m@37973
|
81 |
label.setVisible(jEdit.getProperty(
|
m@37973
|
82 |
IsacPlugin.OPTION_PREFIX + "show-filepath").equals(
|
m@37973
|
83 |
"true"));
|
m@37973
|
84 |
}
|
m@37973
|
85 |
|
m@37973
|
86 |
private AbstractButton makeCustomButton(String name, ActionListener listener) {
|
m@37973
|
87 |
String toolTip = jEdit.getProperty(name.concat(".label"));
|
m@37973
|
88 |
AbstractButton b = new RolloverButton(GUIUtilities.loadIcon(jEdit
|
m@37973
|
89 |
.getProperty(name + ".icon")));
|
m@37973
|
90 |
if (listener != null) {
|
m@37973
|
91 |
b.addActionListener(listener);
|
m@37973
|
92 |
b.setEnabled(true);
|
m@37973
|
93 |
} else {
|
m@37973
|
94 |
b.setEnabled(false);
|
m@37973
|
95 |
}
|
m@37973
|
96 |
b.setToolTipText(toolTip);
|
m@37973
|
97 |
return b;
|
m@37973
|
98 |
}
|
m@37973
|
99 |
|
m@37973
|
100 |
}
|