Revision 43743 trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/propertypage/BasePropertiesPageDialog.java
BasePropertiesPageDialog.java | ||
---|---|---|
9 | 9 |
import javax.swing.JComponent; |
10 | 10 |
import javax.swing.JTabbedPane; |
11 | 11 |
import org.gvsig.fmap.mapcontrol.MapControlLocator; |
12 |
import org.gvsig.propertypage.PropertiesPage.SetPageEnabledEvent; |
|
12 | 13 |
import org.gvsig.tools.ToolsLocator; |
13 | 14 |
import org.gvsig.tools.i18n.I18nManager; |
15 |
import org.gvsig.tools.swing.api.ActionListenerSupport; |
|
16 |
import org.gvsig.tools.util.Invocable; |
|
14 | 17 |
|
15 | 18 |
|
16 | 19 |
public class BasePropertiesPageDialog extends BasePropertiesPagePanelLayout implements org.gvsig.tools.swing.api.Component { |
... | ... | |
22 | 25 |
private String groupID; |
23 | 26 |
private List<PropertiesPage> pages = null; |
24 | 27 |
private int userAction = ACTION_ACCEPT; |
28 |
private JTabbedPane tabbedPane = null; |
|
25 | 29 |
|
26 | 30 |
public BasePropertiesPageDialog() { |
27 | 31 |
} |
... | ... | |
42 | 46 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
43 | 47 |
|
44 | 48 |
this.content.setLayout(new BorderLayout()); |
45 |
this.content.add(createPropertiesPagesPanel(), BorderLayout.CENTER ); |
|
49 |
Component contents = createPropertiesPagesPanel(); |
|
50 |
if( contents instanceof JTabbedPane ) { |
|
51 |
this.tabbedPane = (JTabbedPane) contents; |
|
52 |
} |
|
53 |
this.content.add(contents, BorderLayout.CENTER ); |
|
46 | 54 |
|
47 | 55 |
this.titleLabel.setText(""); |
48 | 56 |
|
49 | 57 |
this.acceptButton.setText(i18nManager.getTranslation("accept")); |
50 | 58 |
this.acceptButton.addActionListener( new ActionListener() { |
59 |
@Override |
|
51 | 60 |
public void actionPerformed(ActionEvent ae) { |
52 | 61 |
whenAccept(); |
53 | 62 |
} |
54 | 63 |
}); |
55 | 64 |
this.applyButton.setText(i18nManager.getTranslation("apply")); |
56 | 65 |
this.applyButton.addActionListener( new ActionListener() { |
66 |
@Override |
|
57 | 67 |
public void actionPerformed(ActionEvent ae) { |
58 | 68 |
whenApply(); |
59 | 69 |
} |
60 | 70 |
}); |
61 | 71 |
this.cancelButton.setText(i18nManager.getTranslation("cancel")); |
62 | 72 |
this.cancelButton.addActionListener( new ActionListener() { |
73 |
@Override |
|
63 | 74 |
public void actionPerformed(ActionEvent ae) { |
64 | 75 |
whenCancel(); |
65 | 76 |
} |
... | ... | |
75 | 86 |
JTabbedPane tabbedPane = new JTabbedPane(); |
76 | 87 |
for( int i=0; i<this.pages.size(); i++ ) { |
77 | 88 |
PropertiesPage page = this.pages.get(i); |
89 |
if( page instanceof ActionListenerSupport ) { |
|
90 |
((ActionListenerSupport)page).addActionListener(new ActionListener() { |
|
91 |
@Override |
|
92 |
public void actionPerformed(ActionEvent e) { |
|
93 |
if( e instanceof SetPageEnabledEvent ) { |
|
94 |
SetPageEnabledEvent ee = (SetPageEnabledEvent) e; |
|
95 |
setEnabledAt(ee.getFilter(), ee.isEnabled()); |
|
96 |
} |
|
97 |
} |
|
98 |
}); |
|
99 |
} |
|
78 | 100 |
tabbedPane.addTab(page.getTitle(), page.asJComponent()); |
79 | 101 |
} |
80 | 102 |
return tabbedPane; |
... | ... | |
125 | 147 |
this.setVisible(false); |
126 | 148 |
} |
127 | 149 |
|
150 |
@Override |
|
128 | 151 |
public JComponent asJComponent() { |
129 | 152 |
return this; |
130 | 153 |
} |
131 | 154 |
|
155 |
public void setEnabledAt(Invocable filter, boolean enabled) { |
|
156 |
if( this.tabbedPane==null ) { |
|
157 |
return; |
|
158 |
} |
|
159 |
for( int i=0; i<this.pages.size(); i++ ) { |
|
160 |
PropertiesPage page = this.pages.get(i); |
|
161 |
if( (Boolean)(filter.call(page)) ) { |
|
162 |
this.tabbedPane.setEnabledAt(i, enabled); |
|
163 |
} |
|
164 |
} |
|
165 |
} |
|
132 | 166 |
|
133 | 167 |
} |
Also available in: Unified diff