Revision 1714 trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/DefaultLayoutManager.java
DefaultLayoutManager.java | ||
---|---|---|
29 | 29 |
import java.util.Comparator; |
30 | 30 |
import java.util.Iterator; |
31 | 31 |
import java.util.List; |
32 |
|
|
33 | 32 |
import javax.swing.ImageIcon; |
34 |
|
|
35 | 33 |
import org.gvsig.andami.PluginServices; |
36 | 34 |
import org.gvsig.andami.PluginsLocator; |
37 | 35 |
import org.gvsig.andami.messages.NotificationManager; |
38 | 36 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
39 |
import org.gvsig.app.ApplicationLocator; |
|
40 | 37 |
import org.gvsig.app.gui.preferencespage.PreferenceKeys; |
41 | 38 |
import org.gvsig.app.project.ProjectManager; |
42 | 39 |
import org.gvsig.app.project.documents.AbstractDocument; |
... | ... | |
49 | 46 |
import org.gvsig.app.project.documents.layout.contextmenu.gui.AbstractLayoutContextMenuAction; |
50 | 47 |
import org.gvsig.app.project.documents.layout.fframes.FrameFactory; |
51 | 48 |
import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
52 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.IFFrameDialog;
|
|
49 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.IFFramePanel;
|
|
53 | 50 |
import org.gvsig.app.project.documents.layout.gui.DefaultLayoutPanel; |
54 | 51 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
55 | 52 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanelImpl; |
56 | 53 |
import org.gvsig.app.project.documents.layout.gui.MapProperties; |
57 |
import org.gvsig.app.project.documents.layout.gui.dialogs.FConfigLayoutDialog; |
|
58 | 54 |
import org.gvsig.app.project.documents.view.IContextMenuAction; |
55 |
import org.gvsig.layout.mapbox.MapBoxUtils; |
|
59 | 56 |
import org.gvsig.tools.ToolsLocator; |
60 | 57 |
import org.gvsig.tools.dynobject.DynStruct; |
61 | 58 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
... | ... | |
101 | 98 |
* |
102 | 99 |
* @return Image button. |
103 | 100 |
*/ |
101 |
@Override |
|
104 | 102 |
public ImageIcon getIcon() { |
105 | 103 |
return ToolsSwingLocator.getIconThemeManager().getCurrent().get("document-map-icon"); |
106 | 104 |
} |
... | ... | |
110 | 108 |
* |
111 | 109 |
* @return Image button. |
112 | 110 |
*/ |
111 |
@Override |
|
113 | 112 |
public ImageIcon getIconSelected() { |
114 | 113 |
return ToolsSwingLocator.getIconThemeManager().getCurrent().get("document-map-icon-sel"); |
115 | 114 |
} |
... | ... | |
119 | 118 |
* |
120 | 119 |
* @return Name of registration |
121 | 120 |
*/ |
121 |
@Override |
|
122 | 122 |
public String getTypeName() { |
123 | 123 |
return TYPENAME; |
124 | 124 |
} |
... | ... | |
128 | 128 |
* |
129 | 129 |
* @return Name of ProjectDocument. |
130 | 130 |
*/ |
131 |
@Override |
|
131 | 132 |
public String getTitle() { |
132 | 133 |
return PluginServices.getText(this, "Mapa"); |
133 | 134 |
} |
134 | 135 |
|
136 |
@Override |
|
135 | 137 |
public AbstractDocument createDocument() { |
136 | 138 |
return new DefaultLayoutDocument(this); |
137 | 139 |
} |
138 | 140 |
|
141 |
@Override |
|
139 | 142 |
public Class getMainWindowClass() { |
140 | 143 |
return LayoutPanelImpl.class; |
141 | 144 |
} |
142 | 145 |
|
146 |
@Override |
|
143 | 147 |
public IWindow getMainWindow(Document doc, WindowLayout layout) { |
144 | 148 |
LayoutPanel layoutPanel = (LayoutPanel) super.getMainWindow(doc, layout); |
145 | 149 |
if (layoutPanel == null) { |
... | ... | |
157 | 161 |
return layoutPanel; |
158 | 162 |
} |
159 | 163 |
|
160 |
public IFFrameDialog createFFrameDialog(IFFrame fframe, |
|
164 |
@Override |
|
165 |
public IFFramePanel createFFrameDialog(IFFrame fframe, |
|
161 | 166 |
LayoutPanel layoutPanel, AffineTransform affineTransform) { |
162 | 167 |
ExtensionPoint ep = extensionPoints.add(KEY_LAYOUT_FFRAMEDIALOG); |
163 | 168 |
|
... | ... | |
167 | 172 |
args[1] = fframe; |
168 | 173 |
Object obj = ep.create(fframe.getName(), args); |
169 | 174 |
if (obj != null) { |
170 |
IFFrameDialog fframedialog = (IFFrameDialog) obj;
|
|
175 |
IFFramePanel fframedialog = (IFFramePanel) obj;
|
|
171 | 176 |
fframedialog.setRectangle(fframe |
172 | 177 |
.getBoundingBox(affineTransform)); |
173 | 178 |
return fframedialog; |
... | ... | |
178 | 183 |
return null; |
179 | 184 |
} |
180 | 185 |
|
181 |
public IFFrameDialog createFFrameDialog(IFFrame fframe, |
|
186 |
@Override |
|
187 |
public IFFramePanel createFFrameDialog(IFFrame fframe, |
|
182 | 188 |
LayoutPanel layoutPanel) { |
183 | 189 |
return createFFrameDialog(fframe, layoutPanel, layoutPanel |
184 | 190 |
.getLayoutControl().getAT()); |
185 | 191 |
} |
186 | 192 |
|
193 |
@Override |
|
187 | 194 |
public void registerFrameFactory(FrameFactory frameFactory, String alias) { |
188 | 195 |
ExtensionPoint ep = |
189 | 196 |
ToolsLocator.getExtensionPointManager().add(KEY_LAYOUT_FFRAME); |
... | ... | |
193 | 200 |
} |
194 | 201 |
} |
195 | 202 |
|
203 |
@Override |
|
196 | 204 |
public void registerFrameFactory(FrameFactory frameFactory) { |
197 | 205 |
registerFrameFactory(frameFactory, null); |
198 | 206 |
} |
199 | 207 |
|
200 | 208 |
@SuppressWarnings("unchecked") |
209 |
@Override |
|
201 | 210 |
public IFFrame createFrame(String frameName) { |
202 | 211 |
|
203 | 212 |
Iterator<Extension> iterator = |
... | ... | |
223 | 232 |
} |
224 | 233 |
|
225 | 234 |
@SuppressWarnings("unchecked") |
235 |
@Override |
|
226 | 236 |
public void registerFFrameDialog(String name, Class clazz) { |
227 |
if (!IFFrameDialog.class.isAssignableFrom(clazz)) {
|
|
237 |
if (!IFFramePanel.class.isAssignableFrom(clazz)) {
|
|
228 | 238 |
throw new IllegalArgumentException(clazz.getName() |
229 | 239 |
+ " must implement the IFFrameDialog interface"); |
230 | 240 |
} |
... | ... | |
272 | 282 |
|
273 | 283 |
DefaultLayoutPanel.registerPersistent(); |
274 | 284 |
DefaultLayoutContext.registerPersistent(); |
285 |
MapBoxUtils.registerPersistence(); |
|
275 | 286 |
} |
276 | 287 |
} |
277 | 288 |
|
289 |
@Override |
|
278 | 290 |
public int getPriority() { |
279 | 291 |
return 2; |
280 | 292 |
} |
... | ... | |
285 | 297 |
* @param showGrid |
286 | 298 |
*/ |
287 | 299 |
public void setDefaultShowGrid(boolean showGrid) { |
288 |
defaultShowGrid = new Boolean(showGrid);
|
|
300 |
defaultShowGrid = showGrid;
|
|
289 | 301 |
} |
290 | 302 |
|
291 | 303 |
/** |
... | ... | |
294 | 306 |
* @param gridEnable |
295 | 307 |
*/ |
296 | 308 |
public void setDefaultAdjustToGrid(boolean gridEnabled) { |
297 |
defaultAdjustToGrid = new Boolean(gridEnabled);
|
|
309 |
defaultAdjustToGrid = gridEnabled;
|
|
298 | 310 |
} |
299 | 311 |
|
300 | 312 |
/** |
... | ... | |
303 | 315 |
* @param showRuler |
304 | 316 |
*/ |
305 | 317 |
public void setDefaultShowRulers(boolean showRules) { |
306 |
defaultShowRulers = new Boolean(showRules);
|
|
318 |
defaultShowRulers = showRules;
|
|
307 | 319 |
} |
308 | 320 |
|
309 | 321 |
/** |
... | ... | |
316 | 328 |
XMLEntity xml = PluginsLocator.getManager().getPlugin(this).getPersistentXML(); |
317 | 329 |
if (xml.contains(PreferenceKeys.DEFAULT_SHOW_LAYOUT_GRID_KEY_NAME)) { |
318 | 330 |
defaultShowGrid = |
319 |
new Boolean(xml.getBooleanProperty(PreferenceKeys.DEFAULT_SHOW_LAYOUT_GRID_KEY_NAME));
|
|
331 |
xml.getBooleanProperty(PreferenceKeys.DEFAULT_SHOW_LAYOUT_GRID_KEY_NAME);
|
|
320 | 332 |
} else { |
321 |
defaultShowGrid = new Boolean(PreferenceKeys.FACTORY_DEFAULT_LAYOUT_GRID_SHOW);
|
|
333 |
defaultShowGrid = PreferenceKeys.FACTORY_DEFAULT_LAYOUT_GRID_SHOW;
|
|
322 | 334 |
} |
323 | 335 |
} |
324 |
return defaultShowGrid.booleanValue();
|
|
336 |
return defaultShowGrid; |
|
325 | 337 |
} |
326 | 338 |
|
327 | 339 |
/** |
... | ... | |
334 | 346 |
XMLEntity xml = PluginsLocator.getManager().getPlugin(this).getPersistentXML(); |
335 | 347 |
if (xml.contains(PreferenceKeys.DEFAULT_ENABLE_LAYOUT_GRID_KEY_NAME)) { |
336 | 348 |
defaultAdjustToGrid = |
337 |
new Boolean( |
|
338 |
xml.getBooleanProperty(PreferenceKeys.DEFAULT_ENABLE_LAYOUT_GRID_KEY_NAME)); |
|
349 |
xml.getBooleanProperty(PreferenceKeys.DEFAULT_ENABLE_LAYOUT_GRID_KEY_NAME); |
|
339 | 350 |
} else { |
340 |
defaultAdjustToGrid = new Boolean(PreferenceKeys.FACTORY_DEFAULT_LAYOUT_GRID_ENABLE);
|
|
351 |
defaultAdjustToGrid = PreferenceKeys.FACTORY_DEFAULT_LAYOUT_GRID_ENABLE;
|
|
341 | 352 |
} |
342 | 353 |
} |
343 |
return defaultAdjustToGrid.booleanValue();
|
|
354 |
return defaultAdjustToGrid; |
|
344 | 355 |
} |
345 | 356 |
|
346 | 357 |
/** |
... | ... | |
353 | 364 |
XMLEntity xml = PluginsLocator.getManager().getPlugin(this).getPersistentXML(); |
354 | 365 |
if (xml.contains(PreferenceKeys.DEFAULT_SHOW_LAYOUT_RULERS_KEY_NAME)) { |
355 | 366 |
defaultShowRulers = |
356 |
new Boolean( |
|
357 |
xml.getBooleanProperty(PreferenceKeys.DEFAULT_SHOW_LAYOUT_RULERS_KEY_NAME)); |
|
367 |
xml.getBooleanProperty(PreferenceKeys.DEFAULT_SHOW_LAYOUT_RULERS_KEY_NAME); |
|
358 | 368 |
} else { |
359 |
defaultShowRulers = new Boolean(PreferenceKeys.FACTORY_DEFAULT_LAYOUT_ENABLE_RULERS);
|
|
369 |
defaultShowRulers = PreferenceKeys.FACTORY_DEFAULT_LAYOUT_ENABLE_RULERS;
|
|
360 | 370 |
} |
361 | 371 |
} |
362 |
return defaultShowRulers.booleanValue();
|
|
372 |
return defaultShowRulers; |
|
363 | 373 |
} |
364 | 374 |
|
365 | 375 |
public boolean getDefaultShowInitialPageConfigDialog() { |
... | ... | |
373 | 383 |
return value; |
374 | 384 |
} |
375 | 385 |
|
386 |
@Override |
|
376 | 387 |
public DynStruct getDefinition(String className) { |
377 | 388 |
|
378 | 389 |
if (this.persistenceDefinition.getName().equalsIgnoreCase(className)) { |
... | ... | |
389 | 400 |
} |
390 | 401 |
|
391 | 402 |
@SuppressWarnings("unchecked") |
403 |
@Override |
|
392 | 404 |
protected Class getDocumentClass() { |
393 | 405 |
return DefaultLayoutDocument.class; |
394 | 406 |
} |
395 | 407 |
|
408 |
@Override |
|
396 | 409 |
public boolean manages(Object object) { |
397 | 410 |
return object instanceof LayoutDocument; |
398 | 411 |
} |
399 | 412 |
|
413 |
@Override |
|
400 | 414 |
public void registerLayoutMenuAction(String name, |
401 | 415 |
Class<? extends IContextMenuAction> clazz) { |
402 | 416 |
ExtensionPoint extensionPoint = |
... | ... | |
404 | 418 |
extensionPoint.append(name, "", clazz); |
405 | 419 |
} |
406 | 420 |
|
421 |
@Override |
|
407 | 422 |
public IContextMenuAction[] createLayoutMenuActions(LayoutPanel layoutPanel) { |
408 | 423 |
List<IContextMenuAction> actionArrayList = |
409 |
new ArrayList<IContextMenuAction>();
|
|
424 |
new ArrayList<>(); |
|
410 | 425 |
@SuppressWarnings("unchecked") |
411 | 426 |
Iterator<ExtensionPoint.Extension> iter = |
412 | 427 |
ToolsLocator.getExtensionPointManager().get(LAYOUT_CONTEXT_MENUS).iterator(); |
... | ... | |
415 | 430 |
action = null; |
416 | 431 |
try { |
417 | 432 |
action = (AbstractLayoutContextMenuAction) iter.next().create(); |
418 |
} catch (InstantiationException e) { |
|
433 |
} catch (InstantiationException | IllegalAccessException e) {
|
|
419 | 434 |
LOG.error("Error creating the context menu", e); |
420 |
} catch (IllegalAccessException e) { |
|
421 |
LOG.error("Error creating the context menu", e); |
|
422 | 435 |
} |
423 | 436 |
if (action != null) { |
424 | 437 |
action.setLayout(layoutPanel); |
... | ... | |
438 | 451 |
|
439 | 452 |
private class CompareAction implements Comparator<IContextMenuAction> { |
440 | 453 |
|
454 |
@Override |
|
441 | 455 |
public int compare(IContextMenuAction o1, IContextMenuAction o2) { |
442 | 456 |
NumberFormat formater = NumberFormat.getInstance(); |
443 | 457 |
formater.setMinimumIntegerDigits(3); |
Also available in: Unified diff