svn-gvsig-desktop / trunk / extensions / extRemoteSensing / src / org / gvsig / remotesensing / decisiontrees / gui / listener / ClassEditorPanelListener.java @ 17773
History | View | Annotate | Download (2.25 KB)
1 | 17757 | dguerrero | package org.gvsig.remotesensing.decisiontrees.gui.listener; |
---|---|---|---|
2 | |||
3 | import java.awt.Color; |
||
4 | import java.awt.event.ActionEvent; |
||
5 | import java.awt.event.ActionListener; |
||
6 | |||
7 | import javax.swing.JColorChooser; |
||
8 | import javax.swing.JDialog; |
||
9 | |||
10 | import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
||
11 | import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent; |
||
12 | import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener; |
||
13 | import org.gvsig.gui.beans.messages.Messages; |
||
14 | 17773 | dguerrero | import org.gvsig.remotesensing.decisiontrees.DecisionTreeNode; |
15 | 17757 | dguerrero | import org.gvsig.remotesensing.decisiontrees.gui.ClassEditorPanel; |
16 | 17773 | dguerrero | import org.jgraph.graph.DefaultGraphCell; |
17 | 17757 | dguerrero | |
18 | import com.iver.andami.PluginServices; |
||
19 | |||
20 | public class ClassEditorPanelListener implements ActionListener, ButtonsPanelListener { |
||
21 | |||
22 | private ClassEditorPanel classEditorPanel = null; |
||
23 | JColorChooser colorChooser = null; |
||
24 | JDialog dialog = null; |
||
25 | |||
26 | public ClassEditorPanelListener(ClassEditorPanel classEditorPanel) {
|
||
27 | this.classEditorPanel = classEditorPanel;
|
||
28 | colorChooser = new JColorChooser(); |
||
29 | dialog = JColorChooser.createDialog(classEditorPanel.getJButtonColor(), Messages.getText("select_color"), true, colorChooser, this, null); |
||
30 | } |
||
31 | |||
32 | public void actionPerformed(ActionEvent e) { |
||
33 | if (e.getSource() == classEditorPanel.getJButtonColor()){
|
||
34 | colorChooser.setColor(Color.RED);
|
||
35 | dialog.setVisible(true);
|
||
36 | classEditorPanel.getJButtonColor().setBackground(colorChooser.getColor()); |
||
37 | } |
||
38 | } |
||
39 | |||
40 | public void actionButtonPressed(ButtonsPanelEvent e) { |
||
41 | if (e.getButton() == ButtonsPanel.BUTTON_CANCEL || e.getButton() == ButtonsPanel.BUTTON_ACCEPT) {
|
||
42 | close(); |
||
43 | } |
||
44 | |||
45 | if (e.getButton() == ButtonsPanel.BUTTON_ACCEPT) {
|
||
46 | 17773 | dguerrero | DefaultGraphCell cell = classEditorPanel.getDecisionTreePanel().getSelectedCell(); |
47 | DecisionTreeNode node = (DecisionTreeNode)cell.getUserObject(); |
||
48 | node.setClassID(Integer.valueOf(classEditorPanel.getJtextValue().getText()).intValue());
|
||
49 | classEditorPanel.getDecisionTreePanel().getClassColors().put(new Integer(node.getClassID()), |
||
50 | classEditorPanel.getJButtonColor().getBackground()); |
||
51 | 17757 | dguerrero | } |
52 | } |
||
53 | |||
54 | private void close() { |
||
55 | try {
|
||
56 | PluginServices.getMDIManager().closeWindow(classEditorPanel.getClassEditorDialog()); |
||
57 | } catch (ArrayIndexOutOfBoundsException e) { |
||
58 | //Si la ventana no se puede eliminar no hacemos nada
|
||
59 | } |
||
60 | } |
||
61 | |||
62 | } |