Revision 1756
trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/LayoutExtension.java | ||
---|---|---|
116 | 116 |
} |
117 | 117 |
} |
118 | 118 |
|
119 |
public static class AccesoryPanelForTemplates extends JPanel { |
|
120 |
|
|
121 |
@SuppressWarnings("OverridableMethodCallInConstructor") |
|
122 |
public AccesoryPanelForTemplates(File projectfile, FileDialogChooser fc) { |
|
123 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
124 |
ApplicationManager application = ApplicationLocator.getApplicationManager(); |
|
125 |
PreferencesNode prefs = application.getPreferences("gvsig.foldering"); |
|
126 |
String prefsPath = prefs.get(TEMPLATES_FOLDER_PROPERTY_NAME, null); |
|
127 |
|
|
128 |
BoxLayout l = new BoxLayout(this, BoxLayout.PAGE_AXIS); |
|
129 |
this.setLayout(l); |
|
130 |
ImageIcon projectIcon = ToolsSwingLocator.getIconThemeManager().getActive().get("application-project-gotofolder"); |
|
131 |
JButton goToProjectButton = new JButton(projectIcon); |
|
132 |
|
|
133 |
goToProjectButton.setToolTipText(i18n.getTranslation("_Go_to_folder_project")); |
|
134 |
this.add(goToProjectButton); |
|
135 |
if(projectfile != null) { |
|
136 |
goToProjectButton.addActionListener((ActionEvent e) -> { |
|
137 |
fc.setCurrentDirectory(projectfile.getParentFile()); |
|
138 |
}); |
|
139 |
goToProjectButton.setEnabled(true); |
|
140 |
} else { |
|
141 |
goToProjectButton.setEnabled(false); |
|
142 |
} |
|
143 |
ImageIcon templatesIcon = ToolsSwingLocator.getIconThemeManager().getActive().get("application-layout-gotodefaulttemplatesfolder"); |
|
144 |
JButton goToTemplatesButton = new JButton(templatesIcon); |
|
145 |
|
|
146 |
goToTemplatesButton.setToolTipText(i18n.getTranslation("_Go_to_default_templates_folder")); |
|
147 |
this.add(goToTemplatesButton); |
|
148 |
goToTemplatesButton.addActionListener((ActionEvent e) -> { |
|
149 |
File prefsFile = new File(prefsPath); |
|
150 |
if (prefsFile.exists()) { |
|
151 |
fc.setCurrentDirectory(prefsFile); |
|
152 |
} |
|
153 |
}); |
|
154 |
goToTemplatesButton.setEnabled(StringUtils.isNotBlank(prefsPath)); |
|
155 |
|
|
156 |
} |
|
157 |
|
|
158 |
} |
|
159 |
|
|
119 | 160 |
private void saveLayout() { |
120 | 161 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
121 | 162 |
layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow(); |
... | ... | |
131 | 172 |
ApplicationManager application = ApplicationLocator.getApplicationManager(); |
132 | 173 |
PreferencesNode prefs = application.getPreferences("gvsig.foldering"); |
133 | 174 |
|
134 |
String prefsPath = prefs.get(TEMPLATES_FOLDER_PROPERTY_NAME, null); |
|
135 | 175 |
File projectfile = application.getCurrentProject().getFile(); |
136 |
JPanel accesory = null; |
|
137 |
if(projectfile != null || prefsPath != null) { |
|
138 |
accesory = new JPanel(); |
|
139 |
BoxLayout l = new BoxLayout(accesory, BoxLayout.PAGE_AXIS); |
|
140 |
accesory.setLayout(l); |
|
141 |
} |
|
142 |
if(projectfile != null) { |
|
143 |
ImageIcon icon = ToolsSwingLocator.getIconThemeManager().getActive().get("application-project-gotofolder"); |
|
144 |
JButton goToProjectButton = new JButton(icon); |
|
145 |
|
|
146 |
goToProjectButton.setToolTipText(i18n.getTranslation("_Go_to_folder_project")); |
|
147 |
accesory.add(goToProjectButton); |
|
148 |
goToProjectButton.addActionListener((ActionEvent e) -> { |
|
149 |
fc.setCurrentDirectory(projectfile.getParentFile()); |
|
150 |
}); |
|
151 |
} |
|
152 |
if(prefsPath != null) { |
|
153 |
ImageIcon icon = ToolsSwingLocator.getIconThemeManager().getActive().get("application-layout-gotodefaulttemplatesfolder"); |
|
154 |
JButton goToTemplatesButton = new JButton(icon); |
|
155 |
|
|
156 |
goToTemplatesButton.setToolTipText(i18n.getTranslation("_Go_to_default_templates_folder")); |
|
157 |
accesory.add(goToTemplatesButton); |
|
158 |
goToTemplatesButton.addActionListener((ActionEvent e) -> { |
|
159 |
File prefsFile = new File(prefsPath); |
|
160 |
if(prefsFile.exists()){ |
|
161 |
fc.setCurrentDirectory(prefsFile); |
|
162 |
} |
|
163 |
}); |
|
164 |
} |
|
165 |
if(accesory != null){ |
|
166 |
fc.setAccessory(accesory); |
|
167 |
} |
|
168 | 176 |
|
169 |
File folder = null; |
|
170 |
folder = manager.getLastPath("_Last_layout_template_folder", new File("")); |
|
177 |
JPanel accesory = new AccesoryPanelForTemplates(projectfile, fc); |
|
178 |
fc.setAccessory(accesory); |
|
179 |
|
|
180 |
File folder = manager.getLastPath("_Last_layout_template_folder", new File("")); |
|
171 | 181 |
if(folder == null || StringUtils.isBlank(folder.getPath())) { |
172 | 182 |
if(projectfile != null){ |
173 | 183 |
folder = projectfile.getParentFile(); |
trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/LayoutMainExtension.java | ||
---|---|---|
27 | 27 |
import java.io.FileInputStream; |
28 | 28 |
import java.io.IOException; |
29 | 29 |
import java.util.Iterator; |
30 |
import java.util.prefs.Preferences; |
|
31 | 30 |
import javax.swing.JOptionPane; |
31 |
import javax.swing.JPanel; |
|
32 | 32 |
import org.gvsig.andami.IconThemeHelper; |
33 | 33 |
import org.gvsig.andami.PluginServices; |
34 | 34 |
import org.gvsig.andami.plugins.Extension; |
... | ... | |
92 | 92 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameTextDialog; |
93 | 93 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameViewDialog; |
94 | 94 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
95 |
import org.gvsig.filedialogchooser.FileDialogChooser; |
|
96 |
import org.gvsig.filedialogchooser.FileDialogChooserManager; |
|
95 | 97 |
import org.gvsig.gui.beans.swing.JFileChooser; |
96 | 98 |
import org.gvsig.i18n.Messages; |
97 | 99 |
import org.gvsig.layout.mapbox.MapBoxUtils; |
... | ... | |
111 | 113 |
import org.gvsig.tools.persistence.PersistenceManager; |
112 | 114 |
import org.gvsig.tools.persistence.PersistentState; |
113 | 115 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
116 |
import org.gvsig.tools.util.ToolsUtilLocator; |
|
114 | 117 |
import org.gvsig.utils.GenericFileFilter; |
115 | 118 |
import org.slf4j.Logger; |
116 | 119 |
import org.slf4j.LoggerFactory; |
... | ... | |
205 | 208 |
private void openLayout() { |
206 | 209 |
LayoutPanel layout = null; |
207 | 210 |
|
208 |
if (templatesPath == null) { |
|
209 |
Preferences prefs = Preferences.userRoot().node("gvsig.foldering"); |
|
210 |
templatesPath = prefs.get("TemplatesFolder", null); |
|
211 |
} |
|
211 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
212 |
FileDialogChooserManager manager = ToolsUtilLocator.getFileDialogChooserManager(); |
|
213 |
FileDialogChooser fc = manager.create("_Last_layout_template_folder"); |
|
214 |
GenericFileFilter layoutMainFilter = new GenericFileFilter( |
|
215 |
LayoutManager.TEMPLATE_FILE_POINTEXT, |
|
216 |
i18n.getTranslation("_Layout_template") + " (*" |
|
217 |
+ LayoutManager.TEMPLATE_FILE_POINTEXT + ")"); |
|
212 | 218 |
|
213 |
JFileChooser jfc = new JFileChooser(LAYOUT_TEMPLATE_FILECHOOSER_ID, |
|
214 |
templatesPath); |
|
215 |
GenericFileFilter layoutMainExtensionFilter = new GenericFileFilter( |
|
216 |
LayoutManager.TEMPLATE_FILE_POINTEXT, |
|
217 |
Messages.getText("_Layout_template") + " (*" |
|
218 |
+ LayoutManager.TEMPLATE_FILE_POINTEXT + ")"); |
|
219 |
jfc.addChoosableFileFilter(layoutMainExtensionFilter); |
|
220 |
jfc.setFileFilter(layoutMainExtensionFilter); |
|
219 |
fc.addChoosableFileFilter(layoutMainFilter); |
|
220 |
fc.setFileFilter(layoutMainFilter); |
|
221 |
ApplicationManager application = ApplicationLocator.getApplicationManager(); |
|
222 |
|
|
223 |
File projectfile = application.getCurrentProject().getFile(); |
|
221 | 224 |
|
222 |
if (jfc.showOpenDialog((Component) PluginServices.getMainFrame()) == JFileChooser.APPROVE_OPTION) { |
|
223 |
File file = jfc.getSelectedFile(); |
|
225 |
JPanel accesory = new LayoutExtension.AccesoryPanelForTemplates(projectfile, fc); |
|
226 |
fc.setAccessory(accesory); |
|
227 |
|
|
228 |
if (fc.showOpenDialog((Component) PluginServices.getMainFrame()) == JFileChooser.APPROVE_OPTION) { |
|
229 |
File file = fc.getSelectedFile(); |
|
224 | 230 |
try { |
225 | 231 |
if (!file.exists()) { |
226 | 232 |
/* |
Also available in: Unified diff