Revision 38608 branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/project/documents/view/legend/gui/ThemeManagerWindow.java
ThemeManagerWindow.java | ||
---|---|---|
50 | 50 |
import java.util.ArrayList; |
51 | 51 |
import java.util.Hashtable; |
52 | 52 |
|
53 |
import javax.swing.JOptionPane; |
|
53 | 54 |
import javax.swing.JPanel; |
54 | 55 |
import javax.swing.JTabbedPane; |
55 | 56 |
import javax.swing.event.ChangeListener; |
56 | 57 |
|
57 | 58 |
import org.gvsig.andami.PluginServices; |
58 | 59 |
import org.gvsig.andami.messages.NotificationManager; |
60 |
import org.gvsig.andami.ui.mdiFrame.MDIFrame; |
|
59 | 61 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
62 |
import org.gvsig.andami.ui.mdiManager.MDIManagerFactory; |
|
60 | 63 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
64 |
import org.gvsig.app.ApplicationLocator; |
|
65 |
import org.gvsig.app.ApplicationManager; |
|
61 | 66 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
62 | 67 |
import org.gvsig.fmap.mapcontext.layers.FLyrDefault; |
63 | 68 |
import org.gvsig.gui.beans.swing.JButton; |
69 |
import org.slf4j.Logger; |
|
70 |
import org.slf4j.LoggerFactory; |
|
64 | 71 |
|
65 | 72 |
|
66 | 73 |
/** |
... | ... | |
69 | 76 |
* @version 01-feb-2007 |
70 | 77 |
*/ |
71 | 78 |
public final class ThemeManagerWindow extends JPanel implements IWindow, ActionListener { |
79 |
private static final Logger logger = LoggerFactory.getLogger(ThemeManagerWindow.class); |
|
80 |
|
|
72 | 81 |
private static final long serialVersionUID = 4650656815369149211L; |
73 | 82 |
private static int selectedTabIndex = 0; |
74 | 83 |
private static ArrayList<Class<? extends AbstractThemeManagerPage>> pages = |
... | ... | |
96 | 105 |
} |
97 | 106 |
|
98 | 107 |
private void initialize() { |
108 |
StringBuffer msgerr = new StringBuffer(); |
|
99 | 109 |
for (int i = 0; i < pages.size(); i++) { |
100 | 110 |
Class<? extends AbstractThemeManagerPage> pageClass = pages.get(i); |
101 | 111 |
AbstractThemeManagerPage tab = null; |
102 | 112 |
try { |
103 | 113 |
tab = pageClass.newInstance(); |
104 |
} catch (InstantiationException e) { |
|
105 |
NotificationManager.addError("Trying to instantiate an interface" + |
|
106 |
" or abstract class + "+pageClass.getName(), e); |
|
107 |
} catch (IllegalAccessException e) { |
|
108 |
NotificationManager.addError("IllegalAccessException: does " + |
|
109 |
pageClass.getName() + " class have an anonymous" + |
|
110 |
" constructor?", e); |
|
114 |
} catch (Exception e) { |
|
115 |
msgerr.append(translate("_Cant_add_property_page_related_to_{0}", pageClass.getName())) |
|
116 |
.append("\n"); |
|
117 |
logger.info("Can't instance propety page from class "+pageClass.getName(),e); |
|
118 |
continue; |
|
111 | 119 |
} |
112 | 120 |
if (tab!=null){ |
113 | 121 |
if (s.get(tab.getClass()).contains(layer.getClass())){ |
114 |
tab.setModel(layer); |
|
115 |
tabs.addTab(tab.getName(), tab); |
|
122 |
String tabName = null; |
|
123 |
try { |
|
124 |
tab.setModel(layer); |
|
125 |
tabName = tab.getName(); |
|
126 |
} catch( Throwable ex) { |
|
127 |
msgerr.append(translate("_Cant_initialice_property_page_{0}", tabName)) |
|
128 |
.append("\n"); |
|
129 |
logger.info("Can't set model of property page '"+tabName+"' from class '"+pageClass.getName()+"'."); |
|
130 |
} |
|
131 |
tabs.addTab(tabName, tab); |
|
116 | 132 |
} |
117 | 133 |
} |
118 | 134 |
} |
... | ... | |
138 | 154 |
}); |
139 | 155 |
add(getPanelButtons(), java.awt.BorderLayout.SOUTH); |
140 | 156 |
setSize(new Dimension(780, 540)); |
157 |
if( msgerr.length()>0 ) { |
|
158 |
PluginServices.getMainFrame().messageDialog(msgerr.toString(), "_Warning", JOptionPane.WARNING_MESSAGE); |
|
159 |
} |
|
141 | 160 |
} |
142 | 161 |
|
162 |
private String translate(String msg, String arg1) { |
|
163 |
String[] args = null; |
|
164 |
String translation = null; |
|
165 |
if (msg == null) { |
|
166 |
return ""; |
|
167 |
} |
|
168 |
if( arg1 != null ) { |
|
169 |
args = new String[] { arg1 }; |
|
170 |
} |
|
171 |
translation = org.gvsig.i18n.Messages.getText(msg, args); |
|
172 |
if (translation == null) { |
|
173 |
return "_"+msg.replace("_", " "); |
|
174 |
} |
|
175 |
return translation; |
|
176 |
} |
|
177 |
|
|
143 | 178 |
private JPanel getPanelButtons() { |
144 | 179 |
if (panelButtons == null) { |
145 | 180 |
panelButtons = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5,5)); |
Also available in: Unified diff