Revision 43913
trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/pom.xml | ||
---|---|---|
336 | 336 |
<scope>runtime</scope> |
337 | 337 |
</dependency> |
338 | 338 |
<dependency> |
339 |
<groupId>com.github.lespaul361</groupId> |
|
340 |
<artifactId>JCommunique</artifactId> |
|
341 |
<scope>runtime</scope> |
|
342 |
</dependency> |
|
343 |
<dependency> |
|
339 | 344 |
<groupId>com.jtattoo</groupId> |
340 | 345 |
<artifactId>JTattoo</artifactId> |
341 | 346 |
<scope>runtime</scope> |
trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/resources-application/gvSIG.sh | ||
---|---|---|
626 | 626 |
# Launch gvSIG # |
627 | 627 |
################ |
628 | 628 |
|
629 |
# For Java parameters documentation and more parameters look at: |
|
630 |
# http://download.oracle.com/javase/6/docs/technotes/tools/windows/java.html |
|
631 |
# http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html |
|
632 |
CMD="\"${JAVA}\" \ |
|
633 |
$FORCE_JAVA_32BITS \ |
|
634 |
-Xms${GVSIG_INITIAL_MEM} \ |
|
635 |
-Xmx${GVSIG_MAX_MEM} \ |
|
636 |
${DEBUG_OPTIONS} \ |
|
637 |
-Djava.library.path=\"${GVSIG_NATIVE_LIBS}\" \ |
|
638 |
${GVSIG_PROPERTIES} \ |
|
639 |
-cp \"${GVSIG_CLASSPATH}\" \ |
|
640 |
${GVSIG_JAVA_PARAMS} \ |
|
641 |
${GVSIG_LAUNCHER} ${GVSIG_PARAMS}" |
|
629 |
launch_gvSIG() { |
|
630 |
# For Java parameters documentation and more parameters look at: |
|
631 |
# http://download.oracle.com/javase/6/docs/technotes/tools/windows/java.html |
|
632 |
# http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html |
|
633 |
CMD="\"${JAVA}\" \ |
|
634 |
$FORCE_JAVA_32BITS \ |
|
635 |
-Xms${GVSIG_INITIAL_MEM} \ |
|
636 |
-Xmx${GVSIG_MAX_MEM} \ |
|
637 |
${DEBUG_OPTIONS} \ |
|
638 |
-Djava.library.path=\"${GVSIG_NATIVE_LIBS}\" \ |
|
639 |
${GVSIG_PROPERTIES} \ |
|
640 |
-cp \"${GVSIG_CLASSPATH}\" \ |
|
641 |
${GVSIG_JAVA_PARAMS} \ |
|
642 |
${GVSIG_LAUNCHER} ${GVSIG_PARAMS}" |
|
642 | 643 |
|
643 |
logger_info Launching gvSIG: "${CMD}" |
|
644 |
eval "$CMD" |
|
644 |
logger_info Launching gvSIG: "${CMD}" |
|
645 |
eval "$CMD" |
|
646 |
} |
|
647 |
|
|
648 |
if [ "${ARGS/*--lib*/--lib}" != "--lib" ] ; then |
|
649 |
launch_gvSIG |
|
650 |
fi |
|
651 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/ui/mdiFrame/MDIFrame.java | ||
---|---|---|
1397 | 1397 |
} |
1398 | 1398 |
} |
1399 | 1399 |
|
1400 |
@Override |
|
1400 | 1401 |
public void message(String msg, int messageTyoe) { |
1401 | 1402 |
this.getStatusBar().message(msg, messageTyoe); |
1402 | 1403 |
} |
... | ... | |
1936 | 1937 |
return helper.confirmDialog(message, title, optionType, messageType); |
1937 | 1938 |
} |
1938 | 1939 |
|
1940 |
|
|
1939 | 1941 |
@Override |
1940 | 1942 |
public int confirmDialog(String message, String title, int optionType, |
1941 | 1943 |
int messageType, String msgid) { |
... | ... | |
2004 | 2006 |
public File[] showSaveFileDialog(String title, File initialPath) { |
2005 | 2007 |
return showChooserDialog(title, JFileChooser.SAVE_DIALOG, JFileChooser.FILES_ONLY, false, initialPath, null, false); |
2006 | 2008 |
} |
2007 |
|
|
2009 |
|
|
2008 | 2010 |
private void addControl(JComponent control) { |
2009 | 2011 |
controls.add(control); |
2010 | 2012 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/ui/mdiFrame/DefaultThreadSafeDialogs.java | ||
---|---|---|
100 | 100 |
return this.statusbar; |
101 | 101 |
} |
102 | 102 |
|
103 |
private void message(String message, int messageType) { |
|
103 |
@Override |
|
104 |
public void message(String message, int messageType) { |
|
104 | 105 |
this.getStatusbar().message(message, messageType); |
105 | 106 |
} |
106 | 107 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/PluginsLibrary.java | ||
---|---|---|
29 | 29 |
import org.gvsig.andami.impl.DefaultPluginsManager; |
30 | 30 |
import org.gvsig.andami.installer.icontheme.IconThemeInstallerFactory.RegisterIconThemeInstaller; |
31 | 31 |
import org.gvsig.andami.installer.translations.TranslationsInstallerFactory.RegisterTranslationsInstaller; |
32 |
import org.gvsig.andami.ui.mdiFrame.DefaultThreadSafeDialogs; |
|
32 | 33 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
33 | 34 |
import org.gvsig.installer.lib.api.InstallerLibrary; |
34 | 35 |
import org.gvsig.tools.ToolsLocator; |
35 | 36 |
import org.gvsig.tools.library.AbstractLibrary; |
36 | 37 |
import org.gvsig.tools.library.LibraryException; |
38 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
37 | 39 |
import org.gvsig.tools.util.Caller; |
38 | 40 |
import org.gvsig.tools.util.impl.DefaultCaller; |
39 | 41 |
|
... | ... | |
52 | 54 |
PluginsLocator.registerLocaleManager(DefaultLocaleManager.class); |
53 | 55 |
|
54 | 56 |
ToolsLocator.registerDefaultFirewallManager(DefaultFirewallConfiguration.class); |
57 |
ToolsSwingLocator.registerThreadSafeDialogsManager(DefaultThreadSafeDialogs.class); |
|
55 | 58 |
|
56 | 59 |
// Force initialize of the LocaleManager |
57 | 60 |
PluginsLocator.getLocaleManager(); |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.coreplugin.app/org.gvsig.coreplugin.app.mainplugin/src/main/java/org/gvsig/coreplugin/preferences/general/appearance/AppearancePage.java | ||
---|---|---|
160 | 160 |
} else { |
161 | 161 |
DefaultComboBoxModel model = new DefaultComboBoxModel(); |
162 | 162 |
for( LookAndFeelInfo laf : lafs ) { |
163 |
model.addElement(new ListElement<>(laf.getName(), laf)); |
|
163 |
model.addElement(new ListElement<>(laf.getName(), laf.getClassName()));
|
|
164 | 164 |
} |
165 | 165 |
this.cboLookAndFeel.setModel(model); |
166 | 166 |
this.cboLookAndFeel.setEnabled(true); |
167 |
this.cboLookAndFeel.setSelectedItem(Launcher.getAndamiConfig().getLookAndFeel()); |
|
167 |
ListElement.setSelected(cboLookAndFeel, Launcher.getAndamiConfig().getLookAndFeel()); |
|
168 |
|
|
168 | 169 |
} |
169 | 170 |
this.translateAll(); |
170 | 171 |
} |
... | ... | |
200 | 201 |
this.cboLookAndFeel.setSelectedIndex(0); |
201 | 202 |
String currentLaF = getCurrentLookAndFeel(); |
202 | 203 |
if( !StringUtils.isEmpty(currentLaF) ) { |
203 |
DefaultComboBoxModel<ListElement<LookAndFeelInfo>> model = (DefaultComboBoxModel<ListElement<LookAndFeelInfo>>) this.cboLookAndFeel.getModel(); |
|
204 |
for( int i=0; i<model.getSize() ; i++ ) { |
|
205 |
ListElement<LookAndFeelInfo> element = model.getElementAt(i); |
|
206 |
if( currentLaF.equals(element.getValue().getClassName()) ) { |
|
207 |
this.cboLookAndFeel.setSelectedIndex(i); |
|
208 |
break; |
|
209 |
} |
|
210 |
} |
|
204 |
ListElement.setSelected(cboLookAndFeel, currentLaF); |
|
205 |
} else { |
|
206 |
this.cboLookAndFeel.setSelectedIndex(-1); |
|
211 | 207 |
} |
212 | 208 |
this.cboLookAndFeel.setEnabled(true); |
213 | 209 |
} else { |
... | ... | |
250 | 246 |
ToolsUtilLocator.getFileDialogChooserManager().setUseNativeFileChooser(this.chkUseNativeFileChooser.isSelected()); |
251 | 247 |
|
252 | 248 |
if( this.cboLookAndFeel.isEnabled() ) { |
253 |
ListElement<LookAndFeelInfo> element = (ListElement<LookAndFeelInfo>) this.cboLookAndFeel.getSelectedItem(); |
|
254 |
if( element!=null ) { |
|
255 |
String lookAndFeel = element.getValue().getClassName(); |
|
256 |
Launcher.getAndamiConfig().setLookAndFeel(lookAndFeel); |
|
249 |
String lookAndFeel = (String) ListElement.getSelected(cboLookAndFeel); |
|
250 |
if( lookAndFeel!=null ) { |
|
251 |
Launcher.getAndamiConfig().setLookAndFeel(lookAndFeel); |
|
257 | 252 |
} |
258 | 253 |
} |
259 | 254 |
} |
... | ... | |
265 | 260 |
|
266 | 261 |
@Override |
267 | 262 |
public boolean isValueChanged() { |
268 |
PluginsManager pluginsManager = PluginsLocator.getManager(); |
|
269 |
PluginServices plugin = pluginsManager.getPlugin(PreferencesExtension.class); |
|
270 |
|
|
271 |
DynObject pluginProperties = plugin.getPluginProperties(); |
|
272 |
|
|
273 | 263 |
boolean changed = false; |
274 | 264 |
|
275 | 265 |
if( !changed ) { |
... | ... | |
277 | 267 |
} |
278 | 268 |
if( !changed ) { |
279 | 269 |
if( this.cboLookAndFeel.isEnabled() ) { |
280 |
ListElement<LookAndFeelInfo> element = (ListElement<LookAndFeelInfo>) this.cboLookAndFeel.getSelectedItem();
|
|
281 |
if( element!=null ) {
|
|
282 |
changed = !element.getValue().getClassName().equalsIgnoreCase(getCurrentLookAndFeel());
|
|
283 |
} |
|
270 |
String lookAndFeel = (String) ListElement.getSelected(cboLookAndFeel);
|
|
271 |
if( lookAndFeel!=null ) {
|
|
272 |
changed = !lookAndFeel.equalsIgnoreCase(getCurrentLookAndFeel());
|
|
273 |
}
|
|
284 | 274 |
} |
285 | 275 |
} |
286 | 276 |
return changed; |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.coreplugin.app/org.gvsig.coreplugin.app.mainplugin/src/main/java/org/gvsig/coreplugin/preferences/general/IconThemePage.java | ||
---|---|---|
22 | 22 |
*/ |
23 | 23 |
package org.gvsig.coreplugin.preferences.general; |
24 | 24 |
|
25 |
import com.lowagie.text.ListItem; |
|
25 | 26 |
import java.awt.BorderLayout; |
26 | 27 |
import java.util.prefs.Preferences; |
27 | 28 |
|
28 |
import javax.swing.ComboBoxModel; |
|
29 |
import javax.swing.DefaultComboBoxModel;
|
|
29 | 30 |
import javax.swing.ImageIcon; |
30 | 31 |
import javax.swing.JPanel; |
31 |
import javax.swing.event.ListDataListener;
|
|
32 |
import org.apache.commons.lang3.StringUtils;
|
|
32 | 33 |
|
33 | 34 |
import org.gvsig.andami.IconThemeHelper; |
34 | 35 |
import org.gvsig.andami.preferences.AbstractPreferencePage; |
35 | 36 |
import org.gvsig.andami.preferences.StoreException; |
36 | 37 |
import org.gvsig.i18n.Messages; |
38 |
import org.gvsig.tools.swing.api.ListElement; |
|
37 | 39 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
38 | 40 |
import org.gvsig.tools.swing.icontheme.IconTheme; |
39 | 41 |
import org.gvsig.tools.swing.icontheme.IconThemeManager; |
... | ... | |
81 | 83 |
final IconThemeManager iconManager = ToolsSwingLocator.getIconThemeManager(); |
82 | 84 |
Preferences prefs = Preferences.userRoot().node("gvsig.icontheme"); |
83 | 85 |
String themeId = prefs.get("default-theme",null); |
84 |
panel.combo_selection.setSelectedItem(iconManager.get(themeId));
|
|
86 |
ListElement.setSelected(panel.combo_selection, iconManager.get(themeId));
|
|
85 | 87 |
} |
86 | 88 |
|
87 | 89 |
@Override |
88 | 90 |
public void storeValues() throws StoreException { |
89 |
IconTheme iconTheme = (IconTheme) panel.combo_selection.getSelectedItem();
|
|
91 |
IconTheme iconTheme = (IconTheme) ListElement.getSelected(panel.combo_selection);
|
|
90 | 92 |
if (iconTheme != null && iconTheme != iconTheme.getDefault()) { |
91 | 93 |
Preferences prefs = Preferences.userRoot().node("gvsig.icontheme"); |
92 | 94 |
prefs.put("default-theme", iconTheme.getID()); |
... | ... | |
125 | 127 |
|
126 | 128 |
this.panel = new IconThemePageLayout(); |
127 | 129 |
|
128 |
panel.combo_selection.setModel(new ComboBoxModel() { |
|
129 |
IconTheme selected = null; |
|
130 |
DefaultComboBoxModel<ListElement<IconTheme>> model = new DefaultComboBoxModel<>(); |
|
131 |
for (int i = 0; i < iconManager.getCount(); i++) { |
|
132 |
IconTheme iconTheme = iconManager.get(i); |
|
133 |
model.addElement(new ListElement<>( |
|
134 |
StringUtils.abbreviate(iconTheme.toString(), 60), |
|
135 |
iconTheme |
|
136 |
) |
|
137 |
); |
|
138 |
} |
|
139 |
this.panel.combo_selection.setModel(model); |
|
130 | 140 |
|
131 |
@Override |
|
132 |
public void removeListDataListener(ListDataListener arg0) { |
|
133 |
// Do nothing |
|
134 |
} |
|
135 |
|
|
136 |
@Override |
|
137 |
public int getSize() { |
|
138 |
return iconManager.getCount(); |
|
139 |
} |
|
140 |
|
|
141 |
@Override |
|
142 |
public Object getElementAt(int arg0) { |
|
143 |
return iconManager.get(arg0); |
|
144 |
} |
|
145 |
|
|
146 |
@Override |
|
147 |
public void addListDataListener(ListDataListener arg0) { |
|
148 |
// Do nothing |
|
149 |
} |
|
150 |
|
|
151 |
@Override |
|
152 |
public void setSelectedItem(Object arg0) { |
|
153 |
this.selected = (IconTheme) arg0; |
|
154 |
} |
|
155 |
|
|
156 |
@Override |
|
157 |
public Object getSelectedItem() { |
|
158 |
return this.selected; |
|
159 |
} |
|
160 |
}); |
|
161 |
|
|
162 | 141 |
// Traducir las etiquetas del panel |
163 | 142 |
panel.label_title.setText(translate(panel.label_title.getText())); |
164 | 143 |
panel.label_selection.setText(translate(panel.label_selection.getText())); |
... | ... | |
185 | 164 |
// theme.export(f); |
186 | 165 |
// } |
187 | 166 |
// } |
167 |
|
|
168 |
|
|
169 |
@Override |
|
170 |
public boolean isResizeable() { |
|
171 |
return true; |
|
172 |
} |
|
173 |
|
|
188 | 174 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.snapping.app/org.gvsig.snapping.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/gui/ViewSnappingPropertiesPage.java | ||
---|---|---|
191 | 191 |
getJTxtTolerance().setText(String.valueOf(mapControlManager.getTolerance())); |
192 | 192 |
} |
193 | 193 |
|
194 |
@Override |
|
195 |
public void setData(Object data) { |
|
196 |
|
|
197 |
} |
|
198 |
|
|
194 | 199 |
public boolean whenAccept() { |
195 | 200 |
isAcceppted = true; |
196 | 201 |
return whenApply(); |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.snapping.app/org.gvsig.snapping.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/gui/ViewSnappingPropertiesPageFactory.java | ||
---|---|---|
17 | 17 |
return true; |
18 | 18 |
} |
19 | 19 |
|
20 |
public PropertiesPage create(Object obj) {
|
|
21 |
return new ViewSnappingPropertiesPage((ViewDocument)obj);
|
|
20 |
public PropertiesPage create(Object container, Object data) {
|
|
21 |
return new ViewSnappingPropertiesPage((ViewDocument)data);
|
|
22 | 22 |
} |
23 | 23 |
|
24 | 24 |
public String getGroupID() { |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/project/documents/table/gui/GeneralTablePropertiesPageFactory.java | ||
---|---|---|
20 | 20 |
} |
21 | 21 |
|
22 | 22 |
@Override |
23 |
public PropertiesPage create(Object obj) {
|
|
24 |
return new GeneralTablePropertiesPage((TableDocument)obj);
|
|
23 |
public PropertiesPage create(Object container, Object data) {
|
|
24 |
return new GeneralTablePropertiesPage((TableDocument)data);
|
|
25 | 25 |
} |
26 | 26 |
|
27 | 27 |
@Override |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/project/documents/table/gui/GeneralTablePropertiesPage.java | ||
---|---|---|
44 | 44 |
} |
45 | 45 |
} |
46 | 46 |
|
47 |
@Override |
|
48 |
public void setData(Object data) { |
|
49 |
|
|
50 |
} |
|
51 |
|
|
47 | 52 |
private void initComponents() { |
48 | 53 |
txtName.setText(tableDocument.getName()); |
49 | 54 |
txtDate.setText(tableDocument.getCreationDate()); |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/ProjectExtension.java | ||
---|---|---|
59 | 59 |
import org.gvsig.andami.Launcher.TerminationProcess; |
60 | 60 |
import org.gvsig.andami.PluginServices; |
61 | 61 |
import org.gvsig.andami.PluginsLocator; |
62 |
import org.gvsig.andami.PluginsManager; |
|
62 | 63 |
import org.gvsig.andami.actioninfo.ActionInfo; |
63 | 64 |
import org.gvsig.andami.actioninfo.ActionInfoManager; |
64 | 65 |
import org.gvsig.andami.messages.NotificationManager; |
... | ... | |
76 | 77 |
import org.gvsig.app.project.Project; |
77 | 78 |
import org.gvsig.app.project.ProjectManager; |
78 | 79 |
import org.gvsig.app.project.documents.gui.ProjectWindow; |
80 |
import org.gvsig.app.project.documents.gui.projectpanel.ProjectDocumentsPanelPageFactory; |
|
79 | 81 |
import org.gvsig.app.project.documents.view.ViewManager; |
80 | 82 |
import org.gvsig.gui.beans.swing.JFileChooser; |
83 |
import org.gvsig.propertypage.PropertiesPageManager; |
|
81 | 84 |
import org.gvsig.tools.ToolsLocator; |
82 | 85 |
import org.gvsig.tools.dataTypes.DataTypes; |
83 | 86 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
84 | 87 |
import org.gvsig.tools.i18n.I18nManager; |
85 | 88 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
89 |
import org.gvsig.tools.util.ToolsUtilLocator; |
|
86 | 90 |
import org.gvsig.utils.GenericFileFilter; |
87 | 91 |
import org.gvsig.utils.save.AfterSavingListener; |
88 | 92 |
import org.gvsig.utils.save.BeforeSavingListener; |
... | ... | |
121 | 125 |
|
122 | 126 |
private List<AfterSavingListener> afterSavingListeners = new ArrayList<AfterSavingListener>(); |
123 | 127 |
|
128 |
@Override |
|
124 | 129 |
public void initialize() { |
125 | 130 |
initializeDocumentActionsExtensionPoint(); |
126 | 131 |
registerDocuments(); |
127 | 132 |
registerIcons(); |
128 | 133 |
|
134 |
PropertiesPageManager propertiesManager = ToolsUtilLocator.getPropertiesPageManager(); |
|
135 |
propertiesManager.registerFactory(new ProjectDocumentsPanelPageFactory()); |
|
136 |
|
|
129 | 137 |
File projectFile = getProjectFileFromArguments(); |
130 | 138 |
if( projectFile!=null ) { |
131 | 139 |
// Posponemos la apertura del proyecto ya que en este momento |
... | ... | |
248 | 256 |
t2 = System.currentTimeMillis(); |
249 | 257 |
PluginServices.getLogger().info( |
250 | 258 |
"Project saved. " + (t2 - t1) + " miliseconds"); |
251 |
getProjectFrame().refreshControls();
|
|
259 |
getProjectFrame().setProject(p);
|
|
252 | 260 |
} |
253 | 261 |
return saved; |
254 | 262 |
} |
... | ... | |
289 | 297 |
lastSavePath = filePath.substring(0, |
290 | 298 |
filePath.lastIndexOf(File.separatorChar)); |
291 | 299 |
|
292 |
getProjectFrame().refreshControls();
|
|
300 |
getProjectFrame().setProject(p);
|
|
293 | 301 |
return saved; |
294 | 302 |
} |
295 | 303 |
|
... | ... | |
387 | 395 |
|
388 | 396 |
getProjectFrame().setProject(p); |
389 | 397 |
PluginServices.getMainFrame().setTitle(projectFile.getName()); |
390 |
getProjectFrame().refreshControls(); |
|
398 |
// getProjectFrame().refreshControls();
|
|
391 | 399 |
|
392 | 400 |
// p.restoreWindowProperties(); |
393 | 401 |
|
... | ... | |
416 | 424 |
showProjectWindow(); |
417 | 425 |
} |
418 | 426 |
|
419 |
/** |
|
420 |
* @see com.iver.mdiApp.plugins.IExtension#postInitialize() |
|
421 |
*/ |
|
427 |
@Override |
|
422 | 428 |
public void postInitialize() { |
423 |
try { |
|
424 |
if( !SwingUtilities.isEventDispatchThread() ) { |
|
425 |
SwingUtilities.invokeAndWait(new Runnable() { |
|
429 |
PluginsManager pluginsManager = PluginsLocator.getManager(); |
|
430 |
pluginsManager.addStartupTask( |
|
431 |
"createEmptyProject", |
|
432 |
new Runnable() { |
|
433 |
@Override |
|
426 | 434 |
public void run() { |
427 | 435 |
createEmptyProject(); |
428 | 436 |
} |
429 |
}); |
|
430 |
} else { |
|
431 |
createEmptyProject(); |
|
432 |
} |
|
433 |
} catch (Exception e) { |
|
434 |
LOG.warn("Can't load initial project.",e); |
|
435 |
} |
|
437 |
}, |
|
438 |
true, |
|
439 |
10 |
|
440 |
); |
|
436 | 441 |
} |
437 | 442 |
|
438 | 443 |
|
... | ... | |
472 | 477 |
return false; |
473 | 478 |
} |
474 | 479 |
} |
475 |
FileOutputStream fout=null; |
|
476 |
ZipOutputStream zout=null; |
|
477 | 480 |
LOG.info("Writing project '"+ file.getAbsolutePath()+"'."); |
478 | 481 |
try { |
479 | 482 |
fireBeforeSavingFileEvent(new SaveEvent(this,SaveEvent.BEFORE_SAVING, file)); |
480 |
|
|
481 |
fout = new FileOutputStream(file); |
|
482 |
zout = new ZipOutputStream(fout); |
|
483 |
p.saveState(zout, file.getParentFile()); |
|
484 |
|
|
485 |
zout.putNextEntry(new ZipEntry("preview.jpg")); |
|
486 | 483 |
BufferedImage img = ApplicationLocator.getManager().getUIManager().getImagePreview(); |
487 | 484 |
img = scale(img, 0.40); |
488 |
try { |
|
489 |
ImageIO.write(img, "jpg", zout); |
|
490 |
} catch (IOException ex) { |
|
491 |
LOG.warn("Can't save preview image'.", ex); |
|
492 |
} |
|
493 |
fireAfterSavingFileEvent(new SaveEvent(this, SaveEvent.AFTER_SAVING, file)); |
|
494 |
IOUtils.closeQuietly(zout); |
|
495 |
IOUtils.closeQuietly(fout); |
|
485 |
p.saveState(file,img); |
|
496 | 486 |
|
497 |
if( !isValidZIP(file) ) { |
|
498 |
throw new ZipException("Invalid project file '"+file.getAbsolutePath()+"'"); |
|
499 |
} |
|
500 |
|
|
501 | 487 |
PluginServices.getMainFrame().setTitle(file.getName()); |
502 | 488 |
setPath(file.toString()); |
503 | 489 |
|
... | ... | |
511 | 497 |
); |
512 | 498 |
LOG.warn("Error writing project '"+file.getAbsolutePath()+"'.", e); |
513 | 499 |
return false; |
514 |
} finally { |
|
515 |
IOUtils.closeQuietly(zout); |
|
516 |
IOUtils.closeQuietly(fout); |
|
517 |
} |
|
518 |
|
|
500 |
} |
|
519 | 501 |
LOG.warn("Wrote project '"+file.getAbsolutePath()+"'."); |
520 | 502 |
return true; |
521 | 503 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/ApplicationManager.java | ||
---|---|---|
306 | 306 |
|
307 | 307 |
public String getLocaleLanguage(); |
308 | 308 |
|
309 |
/** |
|
310 |
* sets message in status bar |
|
311 |
* |
|
312 |
* This method is thread safe. |
|
313 |
* |
|
314 |
* @param message |
|
315 |
* @param message_type One of: JOptionPane.ERROR_MESSAGE, |
|
316 |
* JOptionPane.WARNING_MESSAGE, JOptionPane.INFORMATION_MESSAGE |
|
317 |
*/ |
|
318 |
public void message(String message, int message_type); |
|
319 |
|
|
309 |
// /**
|
|
310 |
// * sets message in status bar
|
|
311 |
// *
|
|
312 |
// * This method is thread safe.
|
|
313 |
// *
|
|
314 |
// * @param message
|
|
315 |
// * @param message_type One of: JOptionPane.ERROR_MESSAGE,
|
|
316 |
// * JOptionPane.WARNING_MESSAGE, JOptionPane.INFORMATION_MESSAGE
|
|
317 |
// */
|
|
318 |
// public void message(String message, int message_type);
|
|
319 |
// |
|
320 | 320 |
public String translate(String message, String... args) ; |
321 | 321 |
|
322 | 322 |
public Component getRootComponent(); |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/imp/DefaultApplicationManager.java | ||
---|---|---|
113 | 113 |
|
114 | 114 |
private Version version; |
115 | 115 |
|
116 |
public DefaultApplicationManager() {
|
|
117 |
epManager = ToolsLocator.getExtensionPointManager();
|
|
118 |
epManager.add(EPNAME_PREPARE_OPEN_DATASTORE,
|
|
119 |
"Actions to do when open a DataStore");
|
|
120 |
epManager.add(EPNAME_PREPARE_OPEN_DATASTOREPARAMETERS,
|
|
121 |
"Actions to do before open a DataStore with parameters");
|
|
122 |
epManager.add(EPNAME_PREPARE_OPEN_LAYER,
|
|
123 |
"Actions to do after create a Layer");
|
|
124 |
epManager.add(EPNAME_ADD_TABLE_WIZARD,
|
|
125 |
"Wizards to add new document table");
|
|
116 |
public DefaultApplicationManager() {
|
|
117 |
epManager = ToolsLocator.getExtensionPointManager();
|
|
118 |
epManager.add(EPNAME_PREPARE_OPEN_DATASTORE,
|
|
119 |
"Actions to do when open a DataStore");
|
|
120 |
epManager.add(EPNAME_PREPARE_OPEN_DATASTOREPARAMETERS,
|
|
121 |
"Actions to do before open a DataStore with parameters");
|
|
122 |
epManager.add(EPNAME_PREPARE_OPEN_LAYER,
|
|
123 |
"Actions to do after create a Layer");
|
|
124 |
epManager.add(EPNAME_ADD_TABLE_WIZARD,
|
|
125 |
"Wizards to add new document table");
|
|
126 | 126 |
|
127 |
version = new Version(); |
|
128 |
} |
|
127 |
try { |
|
128 |
version = new Version(); |
|
129 |
} catch(Exception ex) { |
|
130 |
logger.warn("Can't locate application version."); |
|
131 |
} |
|
132 |
} |
|
129 | 133 |
|
130 | 134 |
/* (non-Javadoc) |
131 | 135 |
* @see org.gvsig.appGvSigManager#pepareOpenDataSource(org.gvsig.fmap.dal.DataStore) |
... | ... | |
427 | 431 |
return Launcher.getAndamiConfig().getLocaleLanguage(); |
428 | 432 |
} |
429 | 433 |
|
430 |
public void message(String message, int message_type) { |
|
431 |
MainFrame main = PluginServices.getMainFrame(); |
|
432 |
main.message(message, message_type); |
|
433 |
} |
|
434 |
|
|
435 | 434 |
public void messageDialog(String message, String title, int messageType) { |
436 | 435 |
MainFrame main = PluginServices.getMainFrame(); |
437 | 436 |
main.messageDialog(message, title, messageType); |
... | ... | |
518 | 517 |
public File[] showSaveFileDialog(String title, File initialPath) { |
519 | 518 |
return showChooserDialog(title, JFileChooser.SAVE_DIALOG, JFileChooser.FILES_ONLY, false, initialPath, null, false); |
520 | 519 |
} |
520 |
|
|
521 |
@Override |
|
522 |
public void message(String message, int message_type) { |
|
523 |
MainFrame main = PluginServices.getMainFrame(); |
|
524 |
main.message(message, message_type); |
|
525 |
} |
|
521 | 526 |
|
522 | 527 |
public String translate(String message, String... args) { |
523 | 528 |
return org.gvsig.i18n.Messages.translate(message, args); |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/Project.java | ||
---|---|---|
24 | 24 |
package org.gvsig.app.project; |
25 | 25 |
|
26 | 26 |
import java.awt.Color; |
27 |
import java.awt.image.BufferedImage; |
|
27 | 28 |
import java.beans.PropertyChangeListener; |
28 | 29 |
import java.io.File; |
29 | 30 |
import java.io.InputStream; |
30 | 31 |
import java.io.OutputStream; |
31 |
import java.util.Iterator; |
|
32 | 32 |
import java.util.List; |
33 | 33 |
import java.util.Set; |
34 | 34 |
|
... | ... | |
37 | 37 |
import org.gvsig.app.project.documents.Document; |
38 | 38 |
import org.gvsig.fmap.mapcontext.layers.ExtendedPropertiesSupport; |
39 | 39 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
40 |
import org.gvsig.tools.observer.Observable; |
|
41 | 40 |
import org.gvsig.tools.persistence.Persistent; |
42 | 41 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
43 | 42 |
|
44 |
public interface Project extends DocumentsContainer, Persistent, ExtendedPropertiesSupport {
|
|
43 |
public interface Project extends DocumentsContainer, Persistent, ExtendedPropertiesSupport { |
|
45 | 44 |
|
45 |
public static final String PROJECT_PANEL_PAGE_GROUP = "ProyectPanel"; |
|
46 |
|
|
46 | 47 |
public static final String PROJECT_PROPERTIES_PAGE_GROUP = "Proyect"; |
47 | 48 |
|
48 | 49 |
public static final String FILE_EXTENSION = ".gvsproj"; |
49 | 50 |
|
50 |
public void addPropertyChangeListener(PropertyChangeListener arg0);
|
|
51 |
public void addPropertyChangeListener(PropertyChangeListener listener);
|
|
51 | 52 |
|
52 |
/** |
|
53 |
* Return the creation date of the project |
|
54 |
* |
|
55 |
* @return |
|
56 |
*/ |
|
57 |
public String getCreationDate(); |
|
53 |
public void removePropertyChangeListener(PropertyChangeListener listener); |
|
58 | 54 |
|
59 |
/**
|
|
60 |
* Return the name of the project
|
|
61 |
*
|
|
62 |
* @return
|
|
63 |
*/
|
|
64 |
public String getName();
|
|
55 |
/**
|
|
56 |
* Return the creation date of the project
|
|
57 |
*
|
|
58 |
* @return
|
|
59 |
*/
|
|
60 |
public String getCreationDate();
|
|
65 | 61 |
|
66 |
/**
|
|
67 |
* Set the name of he project.
|
|
68 |
*
|
|
69 |
* @param string
|
|
70 |
*/
|
|
71 |
public void setName(String name);
|
|
62 |
/**
|
|
63 |
* Return the name of the project
|
|
64 |
*
|
|
65 |
* @return
|
|
66 |
*/
|
|
67 |
public String getName();
|
|
72 | 68 |
|
73 |
/**
|
|
74 |
* Return the comments associateds with the project
|
|
75 |
*
|
|
76 |
* @return comments
|
|
77 |
*/
|
|
78 |
public String getComments();
|
|
69 |
/**
|
|
70 |
* Set the name of he project.
|
|
71 |
*
|
|
72 |
* @param name
|
|
73 |
*/
|
|
74 |
public void setName(String name);
|
|
79 | 75 |
|
80 |
/**
|
|
81 |
* Set the comments associateds with the project
|
|
82 |
*
|
|
83 |
* @param comments as string
|
|
84 |
*/
|
|
85 |
public void setComments(String string);
|
|
76 |
/**
|
|
77 |
* Return the comments associateds with the project
|
|
78 |
*
|
|
79 |
* @return comments
|
|
80 |
*/
|
|
81 |
public String getComments();
|
|
86 | 82 |
|
87 |
/**
|
|
88 |
* Retuen the modification date of the project.
|
|
89 |
*
|
|
90 |
* @return modification date as string
|
|
91 |
*/
|
|
92 |
public String getModificationDate();
|
|
83 |
/**
|
|
84 |
* Set the comments associateds with the project
|
|
85 |
*
|
|
86 |
* @param comments as string
|
|
87 |
*/
|
|
88 |
public void setComments(String comments);
|
|
93 | 89 |
|
94 |
/**
|
|
95 |
* Return the author of the project,
|
|
96 |
*
|
|
97 |
* @return author as string
|
|
98 |
*/
|
|
99 |
public String getOwner();
|
|
90 |
/**
|
|
91 |
* Retuen the modification date of the project.
|
|
92 |
*
|
|
93 |
* @return modification date as string
|
|
94 |
*/
|
|
95 |
public String getModificationDate();
|
|
100 | 96 |
|
101 |
/**
|
|
102 |
* Sets the author of the project
|
|
103 |
*
|
|
104 |
* @param author name as string
|
|
105 |
*/
|
|
106 |
public void setOwner(String owner);
|
|
97 |
/**
|
|
98 |
* Return the author of the project,
|
|
99 |
*
|
|
100 |
* @return author as string
|
|
101 |
*/
|
|
102 |
public String getOwner();
|
|
107 | 103 |
|
108 |
/**
|
|
109 |
* Obtiene el color de selecci�n que se usar� en el proyecto
|
|
110 |
*
|
|
111 |
* @return
|
|
112 |
*/
|
|
113 |
public Color getSelectionColor();
|
|
104 |
/**
|
|
105 |
* Sets the author of the project
|
|
106 |
*
|
|
107 |
* @param owner
|
|
108 |
*/
|
|
109 |
public void setOwner(String owner);
|
|
114 | 110 |
|
115 |
/**
|
|
116 |
* Sets the selecction color
|
|
117 |
*
|
|
118 |
* @param selection color as string
|
|
119 |
*/
|
|
120 |
public void setSelectionColor(String selectionColor);
|
|
111 |
/**
|
|
112 |
* Obtiene el color de selecci�n que se usar� en el proyecto
|
|
113 |
*
|
|
114 |
* @return
|
|
115 |
*/
|
|
116 |
public Color getSelectionColor();
|
|
121 | 117 |
|
122 |
/**
|
|
123 |
* Sets the selecction color
|
|
124 |
*
|
|
125 |
* @param selection color as Color
|
|
126 |
*/
|
|
127 |
public void setSelectionColor(Color selectionColor);
|
|
118 |
/**
|
|
119 |
* Sets the selecction color
|
|
120 |
*
|
|
121 |
* @param selectionColor
|
|
122 |
*/
|
|
123 |
public void setSelectionColor(String selectionColor);
|
|
128 | 124 |
|
129 |
public IProjection getProjection(); |
|
125 |
/** |
|
126 |
* Sets the selecction color |
|
127 |
* |
|
128 |
* @param selectionColor |
|
129 |
*/ |
|
130 |
public void setSelectionColor(Color selectionColor); |
|
130 | 131 |
|
131 |
public void setProjection(IProjection projection);
|
|
132 |
public IProjection getProjection();
|
|
132 | 133 |
|
133 |
/** |
|
134 |
* Sets the modified state of project. |
|
135 |
* |
|
136 |
* Can't set to not modified. |
|
137 |
* |
|
138 |
* @param modified as boolean |
|
139 |
*/ |
|
140 |
public void setModified(boolean modified); |
|
134 |
public void setProjection(IProjection projection); |
|
141 | 135 |
|
142 |
public boolean hasChanged(); |
|
136 |
/** |
|
137 |
* Sets the modified state of project. |
|
138 |
* |
|
139 |
* Can't set to not modified. |
|
140 |
* |
|
141 |
* @param modified as boolean |
|
142 |
*/ |
|
143 |
public void setModified(boolean modified); |
|
143 | 144 |
|
145 |
public boolean hasChanged(); |
|
144 | 146 |
|
145 |
/**
|
|
146 |
* Adds a document to the project
|
|
147 |
*
|
|
148 |
* @param document as IProjectDocument
|
|
149 |
* @deprecated use addDocument
|
|
150 |
*/
|
|
151 |
public void add(Document document);
|
|
147 |
/**
|
|
148 |
* Adds a document to the project
|
|
149 |
*
|
|
150 |
* @param document as IProjectDocument
|
|
151 |
* @deprecated use addDocument |
|
152 |
*/
|
|
153 |
public void add(Document document);
|
|
152 | 154 |
|
153 |
/**
|
|
154 |
* Remove a document of the project
|
|
155 |
*
|
|
156 |
* @param document as Document
|
|
157 |
* @deprecated use removeDocument
|
|
158 |
*/
|
|
159 |
public void remove(Document document);
|
|
155 |
/**
|
|
156 |
* Remove a document of the project
|
|
157 |
*
|
|
158 |
* @param document as Document
|
|
159 |
* @deprecated use removeDocument |
|
160 |
*/
|
|
161 |
public void remove(Document document);
|
|
160 | 162 |
|
161 |
/** |
|
162 |
* Return the view that contains the especified layer. |
|
163 |
* |
|
164 |
* @param layer |
|
165 |
* |
|
166 |
* @return name of the view that contains the layer |
|
167 |
* |
|
168 |
* @throws RuntimeException |
|
169 |
* Si la capa que se pasa como par�metro no se encuentra en |
|
170 |
* ninguna vista |
|
171 |
*/ |
|
172 |
public String getViewName(FLayer layer); |
|
163 |
/** |
|
164 |
* Return the view that contains the especified layer. |
|
165 |
* |
|
166 |
* @param layer |
|
167 |
* |
|
168 |
* @return name of the view that contains the layer |
|
169 |
* |
|
170 |
* @throws RuntimeException Si la capa que se pasa como par�metro no se |
|
171 |
* encuentra en ninguna vista |
|
172 |
*/ |
|
173 |
public String getViewName(FLayer layer); |
|
173 | 174 |
|
174 |
public void addExtent(ProjectExtent arg1);
|
|
175 |
public void addExtent(ProjectExtent arg1);
|
|
175 | 176 |
|
176 |
public ProjectExtent removeExtent(int arg0);
|
|
177 |
public ProjectExtent removeExtent(int arg0);
|
|
177 | 178 |
|
178 |
public ProjectExtent[] getExtents();
|
|
179 |
public ProjectExtent[] getExtents();
|
|
179 | 180 |
|
180 |
public void saveState(File out) throws PersistenceException;
|
|
181 |
public void saveState(File out, BufferedImage preview);
|
|
181 | 182 |
|
182 |
public void saveState(OutputStream out) throws PersistenceException; |
|
183 |
|
|
184 |
public void saveState(OutputStream out, File rootFolder) throws PersistenceException; |
|
183 |
@Deprecated |
|
184 |
public void saveState(File out) throws PersistenceException; |
|
185 | 185 |
|
186 |
public void loadState(InputStream in); |
|
186 |
@Deprecated |
|
187 |
public void saveState(OutputStream out) throws PersistenceException; |
|
187 | 188 |
|
188 |
public void loadState(File in); |
|
189 |
@Deprecated |
|
190 |
public void saveState(OutputStream out, File rootFolder) throws PersistenceException; |
|
189 | 191 |
|
190 |
public String exportDocumentsAsText(List<Document> documents); |
|
192 |
@Deprecated |
|
193 |
public void loadState(InputStream in); |
|
191 | 194 |
|
192 |
public void importDocuments(String data, String doctype);
|
|
195 |
public void loadState(File in);
|
|
193 | 196 |
|
194 |
public boolean canImportDocuments(String data, String doctype);
|
|
197 |
public String exportDocumentsAsText(List<Document> documents);
|
|
195 | 198 |
|
199 |
public void importDocuments(String data, String doctype); |
|
200 |
|
|
201 |
public boolean canImportDocuments(String data, String doctype); |
|
202 |
|
|
196 | 203 |
public File getFile(); |
197 | 204 |
|
198 | 205 |
public Set<String> getUnloadedObjects(); |
199 | 206 |
|
200 | 207 |
public List<Exception> getLoadErrors(); |
201 |
} |
|
208 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/DefaultProject.java | ||
---|---|---|
23 | 23 |
package org.gvsig.app.project; |
24 | 24 |
|
25 | 25 |
import java.awt.Color; |
26 |
import java.awt.Image; |
|
27 |
import java.awt.geom.AffineTransform; |
|
28 |
import java.awt.image.AffineTransformOp; |
|
29 |
import java.awt.image.BufferedImage; |
|
26 | 30 |
import java.beans.PropertyChangeEvent; |
27 | 31 |
import java.beans.PropertyChangeListener; |
28 | 32 |
import java.beans.PropertyChangeSupport; |
... | ... | |
45 | 49 |
import java.util.List; |
46 | 50 |
import java.util.Map; |
47 | 51 |
import java.util.Set; |
52 |
import java.util.logging.Level; |
|
53 |
import java.util.zip.ZipEntry; |
|
48 | 54 |
import java.util.zip.ZipException; |
49 | 55 |
import java.util.zip.ZipFile; |
56 |
import java.util.zip.ZipOutputStream; |
|
57 |
import javax.imageio.ImageIO; |
|
58 |
import org.apache.commons.io.IOUtils; |
|
50 | 59 |
|
51 | 60 |
import org.cresques.cts.IProjection; |
52 | 61 |
|
... | ... | |
60 | 69 |
import org.gvsig.app.extension.ProjectExtension; |
61 | 70 |
import org.gvsig.app.extension.Version; |
62 | 71 |
import org.gvsig.app.project.ProjectManager.NewProjectEvent; |
63 |
import org.gvsig.app.project.ProjectManager.ProjectLoadedEvent; |
|
64 | 72 |
import org.gvsig.app.project.documents.AbstractDocument; |
65 | 73 |
import org.gvsig.app.project.documents.Document; |
66 | 74 |
import org.gvsig.app.project.documents.exceptions.SaveException; |
... | ... | |
82 | 90 |
import org.gvsig.tools.persistence.PersistentState; |
83 | 91 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
84 | 92 |
import org.gvsig.utils.StringUtilities; |
93 |
import org.gvsig.utils.save.SaveEvent; |
|
85 | 94 |
|
86 | 95 |
import org.slf4j.Logger; |
87 | 96 |
import org.slf4j.LoggerFactory; |
... | ... | |
181 | 190 |
change.firePropertyChange(evt); |
182 | 191 |
} |
183 | 192 |
|
193 |
@Override |
|
184 | 194 |
public synchronized void addPropertyChangeListener( |
185 | 195 |
PropertyChangeListener arg0) { |
186 | 196 |
change.addPropertyChangeListener(arg0); |
187 | 197 |
} |
188 | 198 |
|
199 |
@Override |
|
200 |
public void removePropertyChangeListener(PropertyChangeListener listener) { |
|
201 |
change.removePropertyChangeListener(listener); |
|
202 |
} |
|
203 |
|
|
189 | 204 |
/** |
190 | 205 |
* Return the creation date of the project |
191 | 206 |
* |
... | ... | |
577 | 592 |
} |
578 | 593 |
} |
579 | 594 |
|
595 |
@Override |
|
580 | 596 |
public File getFile() { |
581 | 597 |
return this.fname; |
582 | 598 |
} |
583 | 599 |
|
600 |
@Deprecated |
|
601 |
@Override |
|
584 | 602 |
public void saveState(OutputStream out) throws PersistenceException { |
585 | 603 |
saveState(out, null); |
586 | 604 |
} |
605 |
|
|
606 |
@Override |
|
607 |
public void saveState(File file, BufferedImage preview) { |
|
608 |
FileOutputStream fout=null; |
|
609 |
ZipOutputStream zout=null; |
|
610 |
try { |
|
611 |
fout = new FileOutputStream(file); |
|
612 |
zout = new ZipOutputStream(fout); |
|
613 |
this.saveState(zout, file.getParentFile()); |
|
587 | 614 |
|
615 |
zout.putNextEntry(new ZipEntry("preview.jpg")); |
|
616 |
try { |
|
617 |
ImageIO.write(preview, "jpg", zout); |
|
618 |
} catch (IOException ex) { |
|
619 |
LOG.warn("Can't save preview image'.", ex); |
|
620 |
} |
|
621 |
IOUtils.closeQuietly(zout); |
|
622 |
IOUtils.closeQuietly(fout); |
|
623 |
|
|
624 |
if( !isValidZIP(file) ) { |
|
625 |
throw new ZipException("Invalid project file '"+file.getAbsolutePath()+"'"); |
|
626 |
} |
|
627 |
this.fname = file; |
|
628 |
} catch (Exception ex) { |
|
629 |
throw new RuntimeException("Can't write project in '"+file.getAbsolutePath()+".",ex); |
|
630 |
} finally { |
|
631 |
IOUtils.closeQuietly(zout); |
|
632 |
IOUtils.closeQuietly(fout); |
|
633 |
} |
|
634 |
} |
|
635 |
|
|
636 |
@Override |
|
588 | 637 |
public void saveState(OutputStream out, File rootFolder) |
589 | 638 |
throws PersistenceException { |
590 |
if (notifyObservers(ProjectNotification.BEFORE_SAVE_TO_STREAM).isProcessCanceled()) { |
|
639 |
if (notifyObservers(ProjectNotification.BEFORE_SAVE_TO_STREAM, rootFolder).isProcessCanceled()) {
|
|
591 | 640 |
return; |
592 | 641 |
} |
593 | 642 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
... | ... | |
605 | 654 |
throw state.getContext().getErrors(); |
606 | 655 |
} |
607 | 656 |
this.fname = null; |
608 |
notifyObservers(ProjectNotification.AFTER_SAVE_TO_STREAM); |
|
657 |
notifyObservers(ProjectNotification.AFTER_SAVE_TO_STREAM, rootFolder);
|
|
609 | 658 |
} |
610 | 659 |
|
660 |
@Deprecated |
|
611 | 661 |
public void loadState(InputStream in) { |
612 | 662 |
loadState(in, null); |
613 | 663 |
} |
614 | 664 |
|
615 | 665 |
public void loadState(InputStream in, File rootFolder) { |
616 |
if (notifyObservers(ProjectNotification.BEFORE_LOAD_FROM_STREAM).isProcessCanceled()) { |
|
666 |
if (notifyObservers(ProjectNotification.BEFORE_LOAD_FROM_STREAM, rootFolder).isProcessCanceled()) {
|
|
617 | 667 |
return; |
618 | 668 |
} |
619 | 669 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
... | ... | |
631 | 681 |
this.loadFromState(state); |
632 | 682 |
this.unloadedObjects = getUnloadedObjects(state.getContext()); |
633 | 683 |
this.loadErrors = state.getContext().getErrors(); |
634 |
ProjectManager.getInstance().notifyProjectEvent(new ProjectLoadedEvent() { |
|
635 |
@Override |
|
636 |
public Project getProject() { |
|
637 |
return DefaultProject.this; |
|
638 |
} |
|
639 |
}); |
|
640 | 684 |
|
641 | 685 |
} catch (PersistenceException e) { |
642 | 686 |
LOG.info("Can't load project to stream", e); |
643 | 687 |
} |
644 | 688 |
this.fname = null; |
645 |
notifyObservers(ProjectNotification.AFTER_LOAD_FROM_STREAM); |
|
689 |
notifyObservers(ProjectNotification.AFTER_LOAD_FROM_STREAM, rootFolder);
|
|
646 | 690 |
|
647 | 691 |
} |
648 | 692 |
|
... | ... | |
704 | 748 |
notifyObservers(ProjectNotification.AFTER_LOAD_FROM_FILE, in); |
705 | 749 |
} |
706 | 750 |
|
707 |
@SuppressWarnings("unchecked") |
|
751 |
//@SuppressWarnings("unchecked") |
|
752 |
@Override |
|
708 | 753 |
public void loadFromState(PersistentState state) |
709 | 754 |
throws PersistenceException { |
710 | 755 |
this.clean(); |
756 |
notifyObservers(ProjectNotification.BEFORE_LOAD_FROM_STATE, state); |
|
711 | 757 |
|
712 | 758 |
this.setComments(state.getString("comments")); |
713 | 759 |
this.setCreationDate(state.getString("creationDate")); |
... | ... | |
728 | 774 |
List<AbstractDocument> documents = (List<AbstractDocument>) state |
729 | 775 |
.get("documents"); |
730 | 776 |
for (int i = 0; i < documents.size(); i++) { |
731 |
this.add(documents.get(i)); |
|
777 |
AbstractDocument doc = documents.get(i); |
|
778 |
if( doc != null ) { |
|
779 |
this.add(doc); |
|
780 |
} |
|
732 | 781 |
} |
733 | 782 |
|
734 | 783 |
List<DocumentWindowInfo> persistentWindows = (List<DocumentWindowInfo>) state.get("documentWindowsInformation"); |
... | ... | |
751 | 800 |
pe.setProject(this); |
752 | 801 |
pe.showProjectWindow(projectWindowInfo); |
753 | 802 |
} |
754 |
|
|
803 |
notifyObservers(ProjectNotification.AFTER_LOAD_FROM_STATE, state); |
|
755 | 804 |
} |
756 | 805 |
|
757 | 806 |
public void saveToState(PersistentState state) throws PersistenceException { |
... | ... | |
1169 | 1218 |
observableHelper.deleteObservers(); |
1170 | 1219 |
} |
1171 | 1220 |
|
1172 |
// private void notifyObservers(ProjectNotifycation notifycation) { |
|
1173 |
// observableHelper.notifyObservers(this, notifycation); |
|
1174 |
// } |
|
1175 | 1221 |
private ProjectNotification notifyObservers(int type) { |
1176 |
DefaultProjectNotification notifycation |
|
1177 |
= new DefaultProjectNotification(type, null, null); |
|
1178 |
try { |
|
1179 |
observableHelper.notifyObservers(this, notifycation); |
|
1180 |
} catch (Exception ex) { |
|
1181 |
LOG.info("Can't notify observers", ex); |
|
1182 |
} |
|
1183 |
return notifycation; |
|
1222 |
return notifyObservers(new DefaultProjectNotification(type)); |
|
1184 | 1223 |
} |
1185 | 1224 |
|
1186 | 1225 |
private ProjectNotification notifyObservers(int type, Document document) { |
1187 |
DefaultProjectNotification notifycation |
|
1188 |
= new DefaultProjectNotification(type, document, null); |
|
1189 |
try { |
|
1190 |
observableHelper.notifyObservers(this, notifycation); |
|
1191 |
} catch (Exception ex) { |
|
1192 |
LOG.info("Can't notify observers", ex); |
|
1193 |
} |
|
1194 |
return notifycation; |
|
1226 |
return notifyObservers(new DefaultProjectNotification(type, document)); |
|
1195 | 1227 |
} |
1228 |
|
|
1229 |
private ProjectNotification notifyObservers(int type, PersistentState state) { |
|
1230 |
return notifyObservers(new DefaultProjectNotification(type, state)); |
|
1231 |
} |
|
1196 | 1232 |
|
1197 | 1233 |
private ProjectNotification notifyObservers(int type, File file) { |
1198 |
DefaultProjectNotification notifycation |
|
1199 |
= new DefaultProjectNotification(type, null, file); |
|
1234 |
return notifyObservers(new DefaultProjectNotification(type, file)); |
|
1235 |
} |
|
1236 |
|
|
1237 |
private ProjectNotification notifyObservers(ProjectNotification notifycation) { |
|
1200 | 1238 |
try { |
1201 | 1239 |
observableHelper.notifyObservers(this, notifycation); |
1202 | 1240 |
} catch (Exception ex) { |
... | ... | |
1204 | 1242 |
} |
1205 | 1243 |
return notifycation; |
1206 | 1244 |
} |
1207 |
|
|
1245 |
|
|
1208 | 1246 |
class DefaultProjectNotification implements ProjectNotification { |
1209 | 1247 |
|
1210 | 1248 |
private int type; |
1211 | 1249 |
private Document document; |
1212 | 1250 |
private File file; |
1213 | 1251 |
private boolean processCanceled = false; |
1252 |
private PersistentState state = null; |
|
1214 | 1253 |
|
1215 |
DefaultProjectNotification(int type, Document document, File file) {
|
|
1254 |
DefaultProjectNotification(int type) { |
|
1216 | 1255 |
this.type = type; |
1256 |
} |
|
1257 |
|
|
1258 |
DefaultProjectNotification(int type, Document document) { |
|
1259 |
this(type); |
|
1217 | 1260 |
this.document = document; |
1261 |
} |
|
1262 |
|
|
1263 |
DefaultProjectNotification(int type, File file) { |
|
1264 |
this(type); |
|
1218 | 1265 |
this.file = file; |
1219 | 1266 |
} |
1220 | 1267 |
|
1268 |
DefaultProjectNotification(int type, PersistentState state) { |
|
1269 |
this(type); |
|
1270 |
this.state = state; |
|
1271 |
} |
|
1272 |
|
|
1273 |
@Override |
|
1221 | 1274 |
public int getNotificationType() { |
1222 | 1275 |
return type; |
1223 | 1276 |
} |
1224 | 1277 |
|
1278 |
@Override |
|
1225 | 1279 |
public Document getDocument() { |
1226 | 1280 |
return document; |
1227 | 1281 |
} |
1228 | 1282 |
|
1283 |
@Override |
|
1229 | 1284 |
public void cancelProcess() { |
1230 | 1285 |
processCanceled = true; |
1231 | 1286 |
} |
1232 | 1287 |
|
1288 |
@Override |
|
1233 | 1289 |
public boolean isProcessCanceled() { |
1234 | 1290 |
return processCanceled; |
1235 | 1291 |
} |
1236 | 1292 |
|
1293 |
@Override |
|
1237 | 1294 |
public File getFile() { |
1238 | 1295 |
return file; |
1239 | 1296 |
} |
1240 | 1297 |
|
1298 |
@Override |
|
1299 |
public PersistentState getState() { |
|
1300 |
return this.state; |
|
1301 |
} |
|
1302 |
|
|
1303 |
@Override |
|
1304 |
public Project getProject() { |
|
1305 |
return DefaultProject.this; |
|
1306 |
} |
|
1241 | 1307 |
} |
1242 | 1308 |
|
1243 | 1309 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/ProjectNotification.java | ||
---|---|---|
24 | 24 |
package org.gvsig.app.project; |
25 | 25 |
|
26 | 26 |
import java.io.File; |
27 |
import org.gvsig.tools.persistence.PersistentState; |
|
27 | 28 |
|
28 | 29 |
|
29 | 30 |
public interface ProjectNotification extends DocumentsContainerNotification { |
... | ... | |
40 | 41 |
public static final int BEFORE_LOAD_FROM_STREAM = 15; |
41 | 42 |
public static final int AFTER_LOAD_FROM_STREAM = 16; |
42 | 43 |
|
44 |
public static final int BEFORE_LOAD_FROM_STATE = 17; |
|
45 |
public static final int AFTER_LOAD_FROM_STATE = 18; |
|
46 |
|
|
47 |
public static final int BEFORE_SAVE_TO_STATE = 19; |
|
48 |
public static final int AFTER_SAVE_TO_STATE = 20; |
|
49 |
|
|
43 | 50 |
public File getFile(); |
51 |
|
|
52 |
public PersistentState getState(); |
|
53 |
|
|
54 |
public Project getProject(); |
|
44 | 55 |
|
45 | 56 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/ProjectManager.java | ||
---|---|---|
77 | 77 |
|
78 | 78 |
} |
79 | 79 |
|
80 |
public interface ProjectLoadedEvent extends ProjectEvent { |
|
81 |
|
|
82 |
} |
|
83 |
|
|
84 | 80 |
public static ProjectManager getInstance() { |
85 | 81 |
if (factory == null) { |
86 | 82 |
factory = new ProjectManager(); |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/AbstractDocument.java | ||
---|---|---|
32 | 32 |
import java.util.Date; |
33 | 33 |
import java.util.List; |
34 | 34 |
import javax.swing.JComponent; |
35 |
import org.apache.commons.lang3.StringUtils; |
|
35 | 36 |
|
36 | 37 |
import org.gvsig.andami.PluginServices; |
37 | 38 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
... | ... | |
130 | 131 |
if (isLocked()) { |
131 | 132 |
throw new RuntimeException("this document is locked"); |
132 | 133 |
} |
133 |
if( name.length()==0) {
|
|
134 |
if( StringUtils.isEmpty(name) ) {
|
|
134 | 135 |
name = null; |
135 | 136 |
} |
136 | 137 |
if( project != null ) { |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/gui/ProjectGeneralPropertiesPageFactory.java | ||
---|---|---|
21 | 21 |
return true; |
22 | 22 |
} |
23 | 23 |
|
24 |
public PropertiesPage create(Object obj) {
|
|
25 |
return new ProjectGeneralPropertiesPage((Project)obj);
|
|
24 |
public PropertiesPage create(Object container, Object data) {
|
|
25 |
return new ProjectGeneralPropertiesPage((Project)data);
|
|
26 | 26 |
} |
27 | 27 |
|
28 | 28 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/gui/projectpanel/ProjectDocumentsPanelPage.java | ||
---|---|---|
1 |
package org.gvsig.app.project.documents.gui.projectpanel; |
|
2 |
|
|
3 |
import java.awt.BorderLayout; |
|
4 |
import org.gvsig.app.project.documents.gui.*; |
|
5 |
import java.awt.Dimension; |
|
6 |
import java.awt.FlowLayout; |
|
7 |
import java.awt.event.ActionEvent; |
|
8 |
import java.awt.event.ActionListener; |
|
9 |
import java.awt.event.ComponentAdapter; |
|
10 |
import java.awt.event.ComponentEvent; |
|
11 |
import java.beans.PropertyChangeEvent; |
|
12 |
import java.beans.PropertyChangeListener; |
|
13 |
import java.io.File; |
|
14 |
import java.util.Collections; |
|
15 |
import java.util.Comparator; |
|
16 |
import java.util.Iterator; |
|
17 |
import java.util.List; |
|
18 |
import javax.swing.ButtonGroup; |
|
19 |
import javax.swing.JComponent; |
|
20 |
import javax.swing.JOptionPane; |
|
21 |
import javax.swing.JPanel; |
|
22 |
import javax.swing.JRadioButton; |
|
23 |
import javax.swing.JScrollPane; |
|
24 |
import javax.swing.ScrollPaneConstants; |
|
25 |
import javax.swing.SwingUtilities; |
|
26 |
import javax.swing.event.ListSelectionEvent; |
|
27 |
import javax.swing.event.ListSelectionListener; |
|
28 |
import org.apache.commons.lang3.StringUtils; |
|
29 |
import org.gvsig.andami.PluginServices; |
|
30 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
31 |
import org.gvsig.andami.ui.mdiManager.MDIManager; |
|
32 |
import org.gvsig.app.ApplicationLocator; |
|
33 |
import org.gvsig.app.ApplicationManager; |
|
34 |
import org.gvsig.app.project.Project; |
|
35 |
import org.gvsig.app.project.ProjectManager; |
|
36 |
import org.gvsig.app.project.documents.Document; |
|
37 |
import org.gvsig.app.project.documents.DocumentManager; |
|
38 |
import org.gvsig.tools.ToolsLocator; |
|
39 |
import org.gvsig.tools.i18n.I18nManager; |
|
40 |
import org.gvsig.tools.identitymanagement.SimpleIdentityManager; |
|
41 |
import org.gvsig.tools.observer.Observable; |
|
42 |
import org.gvsig.tools.observer.Observer; |
|
43 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
44 |
import org.gvsig.tools.swing.api.ToolsSwingManager; |
|
45 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
46 |
import org.gvsig.utils.DefaultListModel; |
|
47 |
import org.slf4j.Logger; |
|
48 |
import org.slf4j.LoggerFactory; |
|
49 |
|
|
50 |
public class ProjectDocumentsPanelPage |
|
51 |
extends ProjectDocumentsPanelPageView |
|
52 |
implements ProjectPanelPage { |
|
53 |
|
|
54 |
private final Logger LOG = LoggerFactory.getLogger(ProjectGeneralPropertiesPage.class); |
|
55 |
|
|
56 |
private Project project; |
|
57 |
private DocumentManager currentDocumentType; |
|
58 |
private final PropertyChangeListener projectPropertyChangeListener; |
|
59 |
private final Observer projectObserver; |
|
60 |
|
|
61 |
public ProjectDocumentsPanelPage() { |
|
62 |
this.project = null; |
|
63 |
this.projectPropertyChangeListener = new PropertyChangeListener() { |
|
64 |
@Override |
|
65 |
public void propertyChange(PropertyChangeEvent evt) { |
|
66 |
updateProject(); |
|
67 |
} |
|
68 |
}; |
|
69 |
this.projectObserver = new Observer() { |
|
70 |
@Override |
|
71 |
public void update(Observable observable, Object notification) { |
|
72 |
updateProject(); |
|
73 |
} |
|
74 |
}; |
|
75 |
this.initComponents(); |
|
76 |
} |
|
77 |
|
|
78 |
@Override |
|
79 |
public void setData(Object data) { |
|
80 |
} |
|
81 |
|
|
82 |
@Override |
|
83 |
public String getTitle() { |
|
84 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
85 |
return i18n.getTranslation("Documents"); |
|
86 |
} |
|
87 |
|
|
88 |
@Override |
|
89 |
public int getPriority() { |
|
90 |
return 1000; |
|
91 |
} |
|
92 |
|
|
93 |
@Override |
|
94 |
public boolean whenAccept() { |
|
95 |
return true; |
|
96 |
} |
|
97 |
|
|
98 |
@Override |
|
99 |
public boolean whenApply() { |
|
100 |
return true; |
|
101 |
} |
|
102 |
|
|
103 |
@Override |
|
104 |
public boolean whenCancel() { |
|
105 |
return true; |
|
106 |
} |
|
107 |
|
|
108 |
@Override |
|
109 |
public JComponent asJComponent() { |
|
110 |
return this; |
|
111 |
} |
|
112 |
|
|
113 |
private void initComponents() { |
|
114 |
this.initDocumentTypes(); |
|
115 |
this.btnDocumentNew.addActionListener(new ActionListener() { |
|
116 |
@Override |
|
117 |
public void actionPerformed(ActionEvent e) { |
|
118 |
doDocumentNew(); |
|
119 |
} |
|
120 |
}); |
|
121 |
this.btnDocumentOpen.addActionListener(new ActionListener() { |
|
122 |
@Override |
|
123 |
public void actionPerformed(ActionEvent e) { |
|
124 |
doDocumentOpen(); |
|
125 |
} |
|
126 |
}); |
|
127 |
this.btnDocumentRename.addActionListener(new ActionListener() { |
|
128 |
@Override |
|
129 |
public void actionPerformed(ActionEvent e) { |
|
130 |
doDocumentRename(); |
|
131 |
} |
|
132 |
}); |
|
133 |
this.btnDocumentDelete.addActionListener(new ActionListener() { |
|
134 |
@Override |
|
135 |
public void actionPerformed(ActionEvent e) { |
|
136 |
doDocumentDelete(); |
|
137 |
} |
|
138 |
}); |
|
139 |
this.btnDocumentProperties.addActionListener(new ActionListener() { |
|
140 |
@Override |
|
141 |
public void actionPerformed(ActionEvent e) { |
|
142 |
doDocumentProperties(); |
|
143 |
} |
|
144 |
}); |
|
145 |
this.btnProjectProperties.addActionListener(new ActionListener() { |
|
146 |
@Override |
|
147 |
public void actionPerformed(ActionEvent e) { |
|
148 |
doProjectProperties(); |
|
149 |
} |
|
150 |
}); |
|
151 |
this.lstDocuments.addListSelectionListener(new ListSelectionListener() { |
|
152 |
@Override |
|
153 |
public void valueChanged(ListSelectionEvent e) { |
|
154 |
if (e.getValueIsAdjusting()) { |
|
155 |
return; |
|
156 |
} |
|
157 |
doDocumentsSelectionChanged(); |
|
158 |
} |
|
159 |
}); |
|
160 |
this.translate(); |
|
161 |
} |
|
162 |
|
|
163 |
private void translate() { |
|
164 |
ToolsSwingManager manager = ToolsSwingLocator.getToolsSwingManager(); |
|
165 |
manager.translate(this.lblCreationDate); |
|
166 |
manager.translate(this.lblSavedIn); |
|
167 |
manager.translate(this.lblSessionName); |
|
168 |
manager.translate(this.lblDocument); |
|
169 |
manager.translate(this.lblDocumentTypes); |
|
170 |
manager.translate(this.lblSessionProperties); |
|
171 |
manager.translate(this.lblCreationDate); |
|
172 |
manager.translate(this.lblCreationDate); |
|
173 |
manager.translate(this.lblCreationDate); |
Also available in: Unified diff