gvsig-3d / 2.1 / trunk / org.gvsig.view3d / org.gvsig.view3d.app / org.gvsig.view3d.app.common / src / main / java / org / gvsig / view3d / app / mainplugin / FullScreenView3DExtension.java @ 530
History | View | Annotate | Download (2.08 KB)
1 |
package org.gvsig.view3d.app.mainplugin; |
---|---|
2 |
|
3 |
import javax.swing.JComponent; |
4 |
|
5 |
import org.gvsig.andami.IconThemeHelper; |
6 |
import org.gvsig.andami.plugins.Extension; |
7 |
import org.gvsig.andami.ui.ToolsWindowManager.Window; |
8 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
9 |
import org.gvsig.app.ApplicationLocator; |
10 |
import org.gvsig.app.ApplicationManager; |
11 |
import org.gvsig.app.project.documents.view.ViewDocument; |
12 |
import org.gvsig.app.project.documents.view.gui.IView; |
13 |
import org.gvsig.view3d.swing.api.View3DPanel; |
14 |
|
15 |
|
16 |
public class FullScreenView3DExtension extends Extension { |
17 |
|
18 |
public void execute(String actionCommand) { |
19 |
|
20 |
if ("full-screen-view-3d".equals(actionCommand)) { |
21 |
View3DPanel view3dPanel = getActiveView3DPanel(); |
22 |
if(view3dPanel != null){ |
23 |
view3dPanel.fullScreen(); |
24 |
} |
25 |
} |
26 |
} |
27 |
|
28 |
private void registerIcons() { |
29 |
IconThemeHelper.registerIcon("view3d", "full-screen-view-3d", this); |
30 |
} |
31 |
|
32 |
public void initialize() { |
33 |
registerIcons(); |
34 |
|
35 |
} |
36 |
|
37 |
public boolean isEnabled() { |
38 |
|
39 |
View3DPanel view3DPanel = getActiveView3DPanel(); |
40 |
|
41 |
if(view3DPanel != null){ |
42 |
return true; |
43 |
} |
44 |
|
45 |
return false; |
46 |
} |
47 |
|
48 |
private View3DPanel getActiveView3DPanel() {
|
49 |
ApplicationManager appManager = ApplicationLocator.getManager(); |
50 |
IWindow activeWindow = appManager.getActiveWindow(); |
51 |
|
52 |
if(activeWindow instanceof Window){ |
53 |
Window aWindow = (Window) activeWindow; |
54 |
JComponent contents = aWindow.getContents();
|
55 |
if( contents instanceof View3DPanel){ |
56 |
return (View3DPanel) contents;
|
57 |
} |
58 |
} |
59 |
return null; |
60 |
} |
61 |
|
62 |
public boolean isVisible() { |
63 |
IView view = getActiveView(); |
64 |
if (view != null) { |
65 |
return true; |
66 |
} |
67 |
return false; |
68 |
} |
69 |
|
70 |
private IView getActiveView() {
|
71 |
ApplicationManager application = ApplicationLocator.getManager(); |
72 |
IView view = (IView) application.getActiveComponent(ViewDocument.class); |
73 |
return view;
|
74 |
} |
75 |
|
76 |
} |