Revision 41081 trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/ViewManager.java
ViewManager.java | ||
---|---|---|
23 | 23 |
*/ |
24 | 24 |
package org.gvsig.app.project.documents.view; |
25 | 25 |
|
26 |
import java.util.Map; |
|
27 |
|
|
26 | 28 |
import javax.swing.ImageIcon; |
27 | 29 |
|
28 | 30 |
import org.gvsig.andami.IconThemeHelper; |
29 | 31 |
import org.gvsig.andami.PluginServices; |
32 |
import org.gvsig.andami.PluginsLocator; |
|
33 |
import org.gvsig.andami.actioninfo.ActionInfo; |
|
34 |
import org.gvsig.andami.actioninfo.ActionInfoManager; |
|
30 | 35 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
31 | 36 |
import org.gvsig.app.project.ProjectManager; |
32 | 37 |
import org.gvsig.app.project.documents.AbstractDocument; |
... | ... | |
44 | 49 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
45 | 50 |
import org.gvsig.tools.ToolsLocator; |
46 | 51 |
import org.gvsig.tools.dynobject.DynStruct; |
52 |
import org.gvsig.tools.extensionpoint.ExtensionBuilder; |
|
53 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
|
47 | 54 |
import org.gvsig.tools.persistence.PersistenceManager; |
48 | 55 |
import org.slf4j.Logger; |
49 | 56 |
import org.slf4j.LoggerFactory; |
... | ... | |
115 | 122 |
return new ViewProperties((DefaultViewDocument) doc); |
116 | 123 |
} |
117 | 124 |
|
125 |
public void addTOCContextAction(String theAction) { |
|
126 |
ActionInfoManager actionManager = PluginsLocator.getActionInfoManager(); |
|
127 |
ActionInfo action = actionManager.getAction(theAction); |
|
128 |
if( action==null ) { |
|
129 |
String errmsg = "Action '"+theAction+"' not found"; |
|
130 |
logger.info(errmsg); |
|
131 |
throw new RuntimeException(errmsg); |
|
132 |
} |
|
133 |
this.addTOCContextAction(action); |
|
134 |
} |
|
135 |
|
|
136 |
public void addTOCContextAction(ActionInfo action) { |
|
137 |
this.addTOCContextAction(action.getName(), new ActionInfoAdapterToContextMenuAction(action)); |
|
138 |
} |
|
139 |
|
|
140 |
class ActionInfoAdapterToContextMenuAction implements IContextMenuAction { |
|
141 |
ActionInfo action = null; |
|
142 |
ActionInfoAdapterToContextMenuAction(ActionInfo action) { |
|
143 |
this.action = action; |
|
144 |
} |
|
145 |
public boolean isVisible(Object item, Object[] selectedItems) { |
|
146 |
return this.action.isVisible(); |
|
147 |
} |
|
148 |
public boolean isEnabled(Object item, Object[] selectedItems) { |
|
149 |
return this.action.isEnabled(); |
|
150 |
} |
|
151 |
public void execute(Object item, Object[] selectedItems) { |
|
152 |
this.action.execute(selectedItems); |
|
153 |
} |
|
154 |
public String getGroup() { |
|
155 |
return null; |
|
156 |
} |
|
157 |
public int getGroupOrder() { |
|
158 |
return 0; |
|
159 |
} |
|
160 |
public int getOrder() { |
|
161 |
return (int) this.action.getPosition(); |
|
162 |
} |
|
163 |
public String getText() { |
|
164 |
return this.action.getLabel(); |
|
165 |
} |
|
166 |
public String getDescription() { |
|
167 |
return this.action.getTooltip(); |
|
168 |
} |
|
169 |
} |
|
170 |
|
|
171 |
public void addTOCContextAction(String id, IContextMenuAction action) { |
|
172 |
ExtensionPoint exPoint = ToolsLocator.getExtensionPointManager().add( |
|
173 |
"View_TocActions", ""); |
|
174 |
if( action instanceof ExtensionBuilder ) { |
|
175 |
exPoint.append(id, "", (ExtensionBuilder)action); |
|
176 |
return; |
|
177 |
} |
|
178 |
exPoint.append(id, "", new ContextMenuActionAdapterToExtensionBuilder(action)); |
|
179 |
} |
|
180 |
|
|
181 |
class ContextMenuActionAdapterToExtensionBuilder implements ExtensionBuilder { |
|
182 |
IContextMenuAction menuAction = null; |
|
183 |
ContextMenuActionAdapterToExtensionBuilder(IContextMenuAction menuAction) { |
|
184 |
this.menuAction = menuAction; |
|
185 |
} |
|
186 |
public Object create() { |
|
187 |
return this.menuAction; |
|
188 |
} |
|
189 |
public Object create(Object[] args) { |
|
190 |
return this.menuAction; |
|
191 |
} |
|
192 |
public Object create(Map args) { |
|
193 |
return this.menuAction; |
|
194 |
} |
|
195 |
} |
|
196 |
|
|
118 | 197 |
/** |
119 | 198 |
* Registers in the points of extension the Factory with alias. |
120 | 199 |
* |
Also available in: Unified diff