Revision 6644
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/AbstractDocumentAction.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.project; |
|
2 |
|
|
3 |
public abstract class AbstractDocumentAction implements IDocumentAction { |
|
4 |
|
|
5 |
public boolean isVisible(ProjectElement[] selectedItems) { |
|
6 |
return true; |
|
7 |
} |
|
8 |
|
|
9 |
public boolean isEnabled(ProjectElement[] selectedItems) { |
|
10 |
return true; |
|
11 |
} |
|
12 |
|
|
13 |
public String getGroup() { |
|
14 |
return "general"; |
|
15 |
} |
|
16 |
|
|
17 |
public int getGroupOrder() { |
|
18 |
return 50; |
|
19 |
} |
|
20 |
|
|
21 |
public int getOrder() { |
|
22 |
return 0; |
|
23 |
} |
|
24 |
|
|
25 |
public String getDescription() { |
|
26 |
// TODO Auto-generated method stub |
|
27 |
return null; |
|
28 |
} |
|
29 |
|
|
30 |
|
|
31 |
} |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/IDocumentAction.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.project; |
|
2 |
|
|
3 |
|
|
4 |
/** |
|
5 |
* Interface que deben de cumplir una acci?n aplicable a un |
|
6 |
* documento. |
|
7 |
* <br> |
|
8 |
* Las acciones se deben registrar en el punto de extensi?n adecuado * |
|
9 |
* <br><br> |
|
10 |
* Por lo general extender de la clase AbstractDocumentAction |
|
11 |
* |
|
12 |
* |
|
13 |
* |
|
14 |
* @author Jose Manuel Viv? (Chema) |
|
15 |
*/ |
|
16 |
|
|
17 |
public interface IDocumentAction { |
|
18 |
|
|
19 |
/** |
|
20 |
* Dice si la acci?n es visible |
|
21 |
* segun los documentos seleccionados |
|
22 |
*/ |
|
23 |
public boolean isVisible(ProjectElement selectedItems[]); |
|
24 |
|
|
25 |
/** |
|
26 |
* Dice si la acci?n esta habilitada |
|
27 |
* segun los documentos seleccionados |
|
28 |
*/ |
|
29 |
public boolean isEnabled(ProjectElement selectedItems[]); |
|
30 |
|
|
31 |
/** |
|
32 |
* Ejecuta la acci?n sobre los documentos seleccionados |
|
33 |
*/ |
|
34 |
public void execute(ProjectElement selectedItems[]); |
|
35 |
|
|
36 |
/** |
|
37 |
* Nombre del grupo al que pertenece la accion |
|
38 |
*/ |
|
39 |
public String getGroup(); |
|
40 |
|
|
41 |
/** |
|
42 |
* Orden del grupo al que pertenece la acci?n |
|
43 |
*/ |
|
44 |
public int getGroupOrder(); |
|
45 |
|
|
46 |
/** |
|
47 |
* Orden del elemento dentro del grupo |
|
48 |
*/ |
|
49 |
public int getOrder(); |
|
50 |
|
|
51 |
/** |
|
52 |
* Texto del elemento |
|
53 |
*/ |
|
54 |
public String getText(); |
|
55 |
|
|
56 |
/** |
|
57 |
* Descripci?n mas detallada de la acci?n |
|
58 |
*/ |
|
59 |
public String getDescription(); |
|
60 |
|
|
61 |
} |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/AbstractContextMenuAction.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.project; |
|
2 |
|
|
3 |
public abstract class AbstractContextMenuAction implements IContextMenuAction { |
|
4 |
|
|
5 |
public boolean isVisible(ProjectElement[] selectedItems) { |
|
6 |
return true; |
|
7 |
} |
|
8 |
|
|
9 |
public boolean isEnabled(ProjectElement[] selectedItems) { |
|
10 |
return true; |
|
11 |
} |
|
12 |
|
|
13 |
public String getGroup() { |
|
14 |
return "general"; |
|
15 |
} |
|
16 |
|
|
17 |
public int getGroupOrder() { |
|
18 |
return 50; |
|
19 |
} |
|
20 |
|
|
21 |
public int getOrder() { |
|
22 |
return 0; |
|
23 |
} |
|
24 |
|
|
25 |
public String getDescription() { |
|
26 |
// TODO Auto-generated method stub |
|
27 |
return null; |
|
28 |
} |
|
29 |
|
|
30 |
|
|
31 |
} |
|
0 | 32 |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/IContextMenuAction.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.project; |
|
2 |
|
|
3 |
|
|
4 |
/** |
|
5 |
* Interface que deben de cumplir una acci?n aplicable dede un |
|
6 |
* Menu contextual o popup. |
|
7 |
* <br> |
|
8 |
* Las acciones se deben registrar en el punto de extensi?n adecuado * |
|
9 |
* <br><br> |
|
10 |
* Por lo general extender de la clase AbstractDocumentAction |
|
11 |
* |
|
12 |
* |
|
13 |
* |
|
14 |
* @author Jose Manuel Viv? (Chema) |
|
15 |
*/ |
|
16 |
|
|
17 |
public interface IContextMenuAction { |
|
18 |
|
|
19 |
/** |
|
20 |
* Dice si la acci?n es visible |
|
21 |
* segun los documentos seleccionados |
|
22 |
*/ |
|
23 |
public boolean isVisible(ProjectElement selectedItems[]); |
|
24 |
|
|
25 |
/** |
|
26 |
* Dice si la acci?n esta habilitada |
|
27 |
* segun los documentos seleccionados |
|
28 |
*/ |
|
29 |
public boolean isEnabled(ProjectElement selectedItems[]); |
|
30 |
|
|
31 |
/** |
|
32 |
* Ejecuta la acci?n sobre los documentos seleccionados |
|
33 |
*/ |
|
34 |
public void execute(ProjectElement selectedItems[]); |
|
35 |
|
|
36 |
/** |
|
37 |
* Nombre del grupo al que pertenece la accion |
|
38 |
*/ |
|
39 |
public String getGroup(); |
|
40 |
|
|
41 |
/** |
|
42 |
* Orden del grupo al que pertenece la acci?n |
|
43 |
*/ |
|
44 |
public int getGroupOrder(); |
|
45 |
|
|
46 |
/** |
|
47 |
* Orden del elemento dentro del grupo |
|
48 |
*/ |
|
49 |
public int getOrder(); |
|
50 |
|
|
51 |
/** |
|
52 |
* Texto del elemento |
|
53 |
*/ |
|
54 |
public String getText(); |
|
55 |
|
|
56 |
/** |
|
57 |
* Descripci?n mas detallada de la acci?n |
|
58 |
* (se utilizar? como Tooltip) |
|
59 |
*/ |
|
60 |
public String getDescription(); |
|
61 |
|
|
62 |
} |
|
0 | 63 |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/project/DocumentPopupMenu.java | ||
---|---|---|
12 | 12 |
import javax.swing.JMenuItem; |
13 | 13 |
import javax.swing.JPopupMenu; |
14 | 14 |
|
15 |
import com.iver.cit.gvsig.project.IDocumentAction;
|
|
15 |
import com.iver.cit.gvsig.project.IContextMenuAction;
|
|
16 | 16 |
import com.iver.cit.gvsig.project.ProjectElement; |
17 | 17 |
import com.iver.utiles.extensionPoints.ExtensionPoint; |
18 | 18 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
... | ... | |
25 | 25 |
private String option; |
26 | 26 |
private ExtensionPoint extensionPoint; |
27 | 27 |
private ProjectElement[] seleteds; |
28 |
private IDocumentAction[] actions = null;
|
|
28 |
private IContextMenuAction[] actions = null;
|
|
29 | 29 |
|
30 | 30 |
|
31 | 31 |
public DocumentPopupMenu(String option,ProjectElement[] seleteds) { |
... | ... | |
43 | 43 |
} |
44 | 44 |
ArrayList actionArrayList = new ArrayList(); |
45 | 45 |
Iterator iter = this.extensionPoint.keySet().iterator(); |
46 |
IDocumentAction action;
|
|
46 |
IContextMenuAction action;
|
|
47 | 47 |
while (iter.hasNext()) { |
48 | 48 |
action = null; |
49 | 49 |
try { |
50 |
action = (IDocumentAction)this.extensionPoint.create((String)iter.next());
|
|
50 |
action = (IContextMenuAction)this.extensionPoint.create((String)iter.next());
|
|
51 | 51 |
} catch (InstantiationException e) { |
52 | 52 |
// TODO Auto-generated catch block |
53 | 53 |
e.printStackTrace(); |
... | ... | |
62 | 62 |
} |
63 | 63 |
|
64 | 64 |
} |
65 |
this.actions = (IDocumentAction[])Array.newInstance(IDocumentAction.class,actionArrayList.size());
|
|
65 |
this.actions = (IContextMenuAction[])Array.newInstance(IContextMenuAction.class,actionArrayList.size());
|
|
66 | 66 |
System.arraycopy(actionArrayList.toArray(),0,this.actions,0,actionArrayList.size()); |
67 | 67 |
|
68 | 68 |
|
... | ... | |
73 | 73 |
private void createMenuElements() { |
74 | 74 |
String group = null; |
75 | 75 |
for (int i=0;i < actions.length;i++) { |
76 |
IDocumentAction action = this.actions[i];
|
|
76 |
IContextMenuAction action = this.actions[i];
|
|
77 | 77 |
MenuItem item = new MenuItem(action.getText(),action); |
78 | 78 |
item.setEnabled(action.isEnabled(this.seleteds)); |
79 | 79 |
if (!action.getGroup().equals(group)) { |
... | ... | |
94 | 94 |
|
95 | 95 |
public class CompareAction implements Comparator{ |
96 | 96 |
public int compare(Object o1, Object o2) { |
97 |
return this.compare((IDocumentAction)o1,(IDocumentAction)o2);
|
|
97 |
return this.compare((IContextMenuAction)o1,(IContextMenuAction)o2);
|
|
98 | 98 |
} |
99 | 99 |
|
100 |
public int compare(IDocumentAction o1, IDocumentAction o2) {
|
|
100 |
public int compare(IContextMenuAction o1, IContextMenuAction o2) {
|
|
101 | 101 |
//FIXME: flata formatear los enteros!!!! |
102 | 102 |
NumberFormat formater = NumberFormat.getInstance(); |
103 | 103 |
formater.setMinimumIntegerDigits(3); |
... | ... | |
108 | 108 |
} |
109 | 109 |
|
110 | 110 |
public class MenuItem extends JMenuItem implements ActionListener{; |
111 |
private IDocumentAction action;
|
|
112 |
public MenuItem(String text,IDocumentAction documentAction) {
|
|
111 |
private IContextMenuAction action;
|
|
112 |
public MenuItem(String text,IContextMenuAction documentAction) {
|
|
113 | 113 |
super(text); |
114 | 114 |
this.action = documentAction; |
115 | 115 |
String tip = this.action.getDescription(); |
Also available in: Unified diff