Revision 6838 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/toc/FPopupMenu.java
FPopupMenu.java | ||
---|---|---|
93 | 93 |
* Realiza el cambio de color si se pulsa OK |
94 | 94 |
* @author Luis W. Sevilla (sevilla_lui@gva.es) |
95 | 95 |
*/ |
96 |
class FSymbolChangeColorTocMenuEntry extends AbstractTocContextMenuAction {
|
|
97 |
public String getGroup() {
|
|
98 |
return "group1"; //FIXME
|
|
96 |
class FSymbolChangeColorTocMenuEntry extends AbstractTocContextMenuAction { |
|
97 |
public String getGroup() { |
|
98 |
return "group1"; //FIXME |
|
99 | 99 |
} |
100 | 100 |
|
101 |
public int getGroupOrder() {
|
|
101 |
public int getGroupOrder() { |
|
102 | 102 |
return 10; |
103 | 103 |
} |
104 | 104 |
|
... | ... | |
109 | 109 |
public String getText() { |
110 | 110 |
return PluginServices.getText(this, "Cambio_Color"); |
111 | 111 |
} |
112 |
|
|
112 |
|
|
113 | 113 |
public boolean isEnabled(ITocItem item, FLayer[] selectedItems) { |
114 | 114 |
return true; |
115 | 115 |
} |
... | ... | |
132 | 132 |
return bShow; |
133 | 133 |
} |
134 | 134 |
|
135 |
public void execute(ITocItem item, FLayer[] selectedItems) {
|
|
135 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
|
136 | 136 |
|
137 | 137 |
boolean showDialog=false; |
138 | 138 |
if (isTocItemBranch(item)) { |
... | ... | |
195 | 195 |
* @author Vicente Caballero Navarro |
196 | 196 |
*/ |
197 | 197 |
class ChangeNameTocMenuEntry extends AbstractTocContextMenuAction { |
198 |
public String getGroup() {
|
|
199 |
return "group1"; //FIXME
|
|
198 |
public String getGroup() { |
|
199 |
return "group1"; //FIXME |
|
200 | 200 |
} |
201 | 201 |
|
202 |
public int getGroupOrder() {
|
|
202 |
public int getGroupOrder() { |
|
203 | 203 |
return 10; |
204 | 204 |
} |
205 | 205 |
|
... | ... | |
219 | 219 |
return isTocItemBranch(item); |
220 | 220 |
} |
221 | 221 |
|
222 |
|
|
222 |
|
|
223 | 223 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
224 | 224 |
FLayer lyr = getNodeLayer(item); |
225 | 225 |
if (!lyr.isAvailable()) return; |
... | ... | |
236 | 236 |
|
237 | 237 |
|
238 | 238 |
class FLyrVectEditPropertiesTocMenuEntry extends AbstractTocContextMenuAction { |
239 |
public String getGroup() {
|
|
240 |
return "group2"; //FIXME
|
|
239 |
public String getGroup() { |
|
240 |
return "group2"; //FIXME |
|
241 | 241 |
} |
242 | 242 |
|
243 |
public int getGroupOrder() {
|
|
243 |
public int getGroupOrder() { |
|
244 | 244 |
return 20; |
245 | 245 |
} |
246 | 246 |
|
... | ... | |
257 | 257 |
} |
258 | 258 |
|
259 | 259 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
260 |
if (isTocItemBranch(item)) {
|
|
260 |
if (isTocItemBranch(item)) { |
|
261 | 261 |
FLayer lyr = getNodeLayer(item); |
262 | 262 |
if ((lyr instanceof ClassifiableVectorial)) { |
263 | 263 |
if (!((lyr instanceof FLyrVect) && |
264 | 264 |
!((FLyrVect)lyr).isPropertiesMenuVisible())){ |
265 | 265 |
return true; |
266 | 266 |
} |
267 |
|
|
267 |
|
|
268 | 268 |
} |
269 | 269 |
} |
270 | 270 |
return false; |
271 |
|
|
271 |
|
|
272 | 272 |
} |
273 | 273 |
|
274 |
|
|
274 |
|
|
275 | 275 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
276 | 276 |
FLayer[] actives = selectedItems; |
277 | 277 |
FThemeManagerWindow fThemeManagerWindow; |
... | ... | |
313 | 313 |
} |
314 | 314 |
} |
315 | 315 |
} |
316 |
}
|
|
316 |
} |
|
317 | 317 |
} |
318 |
|
|
318 |
|
|
319 | 319 |
} |
320 | 320 |
|
321 | 321 |
class FLyrRasterAdjustTransparencyTocMenuEntry extends TocMenuEntry { |
... | ... | |
350 | 350 |
} |
351 | 351 |
|
352 | 352 |
class ZoomAlTemaTocMenuEntry extends AbstractTocContextMenuAction { |
353 |
public String getGroup() {
|
|
354 |
return "group2"; //FIXME
|
|
353 |
public String getGroup() { |
|
354 |
return "group2"; //FIXME |
|
355 | 355 |
} |
356 | 356 |
|
357 |
public int getGroupOrder() {
|
|
357 |
public int getGroupOrder() { |
|
358 | 358 |
return 20; |
359 | 359 |
} |
360 | 360 |
|
... | ... | |
371 | 371 |
} |
372 | 372 |
|
373 | 373 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
374 |
if (isTocItemBranch(item)) {
|
|
374 |
if (isTocItemBranch(item) && ! (selectedItems == null || selectedItems.length <= 0)) {
|
|
375 | 375 |
return true; |
376 | 376 |
} |
377 | 377 |
return false; |
378 |
|
|
378 |
|
|
379 | 379 |
} |
380 | 380 |
|
381 |
|
|
381 |
|
|
382 | 382 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
383 |
|
|
383 |
|
|
384 |
|
|
384 | 385 |
// 050209, jmorell: Para que haga un zoom a un grupo de capas seleccionadas. |
385 |
FLayer[] actives = selectedItems; |
|
386 |
if (actives.length==1) {
|
|
386 |
|
|
387 |
if (selectedItems.length==1) {
|
|
387 | 388 |
try { |
388 |
if (!actives[0].isAvailable()) return;
|
|
389 |
getMapContext().getViewPort().setExtent(actives[0].getFullExtent());
|
|
389 |
if (!selectedItems[0].isAvailable()) return;
|
|
390 |
getMapContext().getViewPort().setExtent(selectedItems[0].getFullExtent());
|
|
390 | 391 |
} catch (com.iver.cit.gvsig.fmap.DriverException e1) { |
391 | 392 |
e1.printStackTrace(); |
392 | 393 |
} |
393 | 394 |
} else { |
394 | 395 |
try { |
395 |
Rectangle2D maxExtent = setMaxExtent(actives);
|
|
396 |
getMapContext().getViewPort().setExtent(maxExtent);
|
|
396 |
Rectangle2D maxExtent = setMaxExtent(selectedItems);
|
|
397 |
getMapContext().getViewPort().setExtent(maxExtent);
|
|
397 | 398 |
} catch (com.iver.cit.gvsig.fmap.DriverException e1) { |
398 | 399 |
e1.printStackTrace(); |
399 | 400 |
} |
... | ... | |
424 | 425 |
} |
425 | 426 |
} |
426 | 427 |
|
427 |
class EliminarCapaTocMenuEntry extends AbstractTocContextMenuAction {
|
|
428 |
public String getGroup() {
|
|
429 |
return "group3"; //FIXME
|
|
428 |
class EliminarCapaTocMenuEntry extends AbstractTocContextMenuAction { |
|
429 |
public String getGroup() { |
|
430 |
return "group3"; //FIXME |
|
430 | 431 |
} |
431 | 432 |
|
432 |
public int getGroupOrder() {
|
|
433 |
public int getGroupOrder() { |
|
433 | 434 |
return 30; |
434 | 435 |
} |
435 | 436 |
|
... | ... | |
446 | 447 |
} |
447 | 448 |
|
448 | 449 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
449 |
if (isTocItemBranch(item)) {
|
|
450 |
if (isTocItemBranch(item)) { |
|
450 | 451 |
return true; |
451 | 452 |
} |
452 | 453 |
return false; |
453 |
|
|
454 |
|
|
454 | 455 |
} |
455 | 456 |
|
456 |
|
|
457 |
|
|
457 | 458 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
458 | 459 |
// 050209, jmorell: Para poder borrar todas las capas seleccionadas desde el FPopUpMenu. |
459 | 460 |
// Es necesario pulsar May?sculas a la vez que el bot?n derecho. |
460 |
|
|
461 |
|
|
461 | 462 |
FLayer[] actives = selectedItems; |
462 | 463 |
int option=-1; |
463 | 464 |
if (actives.length>0) { |
... | ... | |
510 | 511 |
* @author Vicente Caballero Navarro |
511 | 512 |
*/ |
512 | 513 |
class LayersGroupTocMenuEntry extends AbstractTocContextMenuAction { |
513 |
public String getGroup() {
|
|
514 |
return "group4"; //FIXME
|
|
514 |
public String getGroup() { |
|
515 |
return "group4"; //FIXME |
|
515 | 516 |
} |
516 | 517 |
|
517 |
public int getGroupOrder() {
|
|
518 |
public int getGroupOrder() { |
|
518 | 519 |
return 40; |
519 | 520 |
} |
520 | 521 |
|
... | ... | |
531 | 532 |
} |
532 | 533 |
|
533 | 534 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
534 |
if (isTocItemBranch(item)) {
|
|
535 |
if (isTocItemBranch(item)) { |
|
535 | 536 |
return true; |
536 | 537 |
} |
537 | 538 |
return false; |
538 |
|
|
539 |
|
|
539 | 540 |
} |
540 | 541 |
|
541 |
|
|
542 |
public void execute(ITocItem item, FLayer[] selectedItems) {
|
|
542 |
|
|
543 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
|
543 | 544 |
//ITocItem tocItem = (ITocItem) getNodeUserObject(); |
544 | 545 |
ChangeName changename=new ChangeName(null); |
545 | 546 |
PluginServices.getMDIManager().addView(changename); |
546 | 547 |
String nombre=changename.getName(); |
547 |
|
|
548 |
|
|
548 | 549 |
if (nombre != null){ |
549 | 550 |
if (isTocItemBranch(item)){ |
550 | 551 |
FLayer[] actives = selectedItems; |
... | ... | |
554 | 555 |
layers[i]=allLayers.getLayer(i); |
555 | 556 |
} |
556 | 557 |
if (actives.length>1) { |
557 |
|
|
558 |
|
|
558 | 559 |
FLayers layerGroup=new FLayers(getMapContext(),getNodeLayer(item).getParentLayer()); |
559 | 560 |
boolean first=true; |
560 | 561 |
for (int i=0;i<layers.length;i++) { |
... | ... | |
567 | 568 |
} |
568 | 569 |
if(layer instanceof FLyrRaster) |
569 | 570 |
((FLyrRaster)layer).setRemoveRasterFlag(false); |
570 |
|
|
571 |
|
|
571 | 572 |
layer.getParentLayer().removeLayer(layer); |
572 | 573 |
layerGroup.addLayer(layer); |
573 | 574 |
} |
574 | 575 |
} |
575 | 576 |
layerGroup.setName(nombre); |
576 |
|
|
577 |
|
|
577 |
|
|
578 |
|
|
578 | 579 |
} |
579 |
|
|
580 |
|
|
580 | 581 |
} |
581 | 582 |
// TRUCO PARA REFRESCAR. |
582 | 583 |
getMapContext().invalidate(); |
... | ... | |
589 | 590 |
* |
590 | 591 |
* @author Vicente Caballero Navarro |
591 | 592 |
*/ |
592 |
class LayersUngroupTocMenuEntry extends AbstractTocContextMenuAction {
|
|
593 |
public String getGroup() {
|
|
594 |
return "group4"; //FIXME
|
|
593 |
class LayersUngroupTocMenuEntry extends AbstractTocContextMenuAction { |
|
594 |
public String getGroup() { |
|
595 |
return "group4"; //FIXME |
|
595 | 596 |
} |
596 | 597 |
|
597 |
public int getGroupOrder() {
|
|
598 |
public int getGroupOrder() { |
|
598 | 599 |
return 40; |
599 | 600 |
} |
600 | 601 |
|
... | ... | |
610 | 611 |
return true; |
611 | 612 |
} |
612 | 613 |
|
613 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) {
|
|
614 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
|
614 | 615 |
if (isTocItemBranch(item)){ |
615 | 616 |
FLayer lyr = getNodeLayer(item); |
616 | 617 |
if (!(lyr instanceof FLayers)){ |
... | ... | |
618 | 619 |
} |
619 | 620 |
} |
620 | 621 |
return true; |
621 |
|
|
622 |
|
|
622 | 623 |
} |
623 | 624 |
|
624 |
|
|
625 |
|
|
625 | 626 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
626 | 627 |
if (isTocItemBranch(item)){ |
627 | 628 |
FLayers agrupa = (FLayers)getNodeLayer(item); |
... | ... | |
649 | 650 |
* @author Vicente Caballero Navarro |
650 | 651 |
*/ |
651 | 652 |
class FirstLayerTocMenuEntry extends AbstractTocContextMenuAction { |
652 |
public String getGroup() {
|
|
653 |
return "group4"; //FIXME
|
|
653 |
public String getGroup() { |
|
654 |
return "group4"; //FIXME |
|
654 | 655 |
} |
655 | 656 |
|
656 |
public int getGroupOrder() {
|
|
657 |
public int getGroupOrder() { |
|
657 | 658 |
return 40; |
658 | 659 |
} |
659 | 660 |
|
... | ... | |
669 | 670 |
return true; |
670 | 671 |
} |
671 | 672 |
|
672 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) {
|
|
673 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
|
673 | 674 |
if (isTocItemBranch(item)){ |
674 | 675 |
return true; |
675 | 676 |
} |
676 | 677 |
return false; |
677 |
|
|
678 |
|
|
678 | 679 |
} |
679 | 680 |
|
680 |
|
|
681 |
public void execute(ITocItem item, FLayer[] selectedItems) {
|
|
681 |
|
|
682 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
|
682 | 683 |
if (isTocItemBranch(item)){ |
683 | 684 |
if (getMapContext().getLayers().getActives().length == 1) { |
684 | 685 |
FLayer layer=((TocItemBranch)item).getLayer(); |
... | ... | |
718 | 719 |
private JMenuItem properties; |
719 | 720 |
FLayer lyr = null; |
720 | 721 |
public int zoomType = ZOOM_TO_VIEW_CENTER; |
721 |
|
|
722 | 722 |
|
723 |
|
|
723 | 724 |
public void initialize(FPopupMenu m) { |
724 | 725 |
super.initialize(m); |
725 | 726 |
|
... | ... | |
818 | 819 |
public static final int ZOOM_TO_VIEW_CENTER = 0x2; |
819 | 820 |
FLayer lyr = null; |
820 | 821 |
public int zoomType = ZOOM_TO_VIEW_CENTER; |
821 |
|
|
822 |
public String getGroup() {
|
|
823 |
return "group2"; //FIXME
|
|
822 |
|
|
823 |
public String getGroup() { |
|
824 |
return "group2"; //FIXME |
|
824 | 825 |
} |
825 | 826 |
|
826 |
public int getGroupOrder() {
|
|
827 |
public int getGroupOrder() { |
|
827 | 828 |
return 20; |
828 | 829 |
} |
829 | 830 |
|
... | ... | |
840 | 841 |
} |
841 | 842 |
|
842 | 843 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
843 |
if (isTocItemBranch(item)) {
|
|
844 |
if (isTocItemBranch(item)) { |
|
844 | 845 |
return getNodeLayer(item) instanceof FLyrRaster; |
845 | 846 |
} |
846 | 847 |
return false; |
847 |
|
|
848 |
|
|
848 | 849 |
} |
849 | 850 |
|
850 |
|
|
851 |
public void execute(ITocItem item, FLayer[] selectedItems) {
|
|
851 |
|
|
852 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
|
852 | 853 |
if (selectedItems.length==1) { |
853 | 854 |
lyr = getNodeLayer(item); |
854 | 855 |
View vista = (View) PluginServices.getMDIManager().getActiveView(); |
... | ... | |
903 | 904 |
* Entrada de men? para recargar una capa. |
904 | 905 |
*/ |
905 | 906 |
class ReloadLayerTocMenuEntry extends AbstractTocContextMenuAction{ |
906 |
public String getGroup() {
|
|
907 |
return "group3"; //FIXME
|
|
907 |
public String getGroup() { |
|
908 |
return "group3"; //FIXME |
|
908 | 909 |
} |
909 | 910 |
|
910 |
public int getGroupOrder() {
|
|
911 |
public int getGroupOrder() { |
|
911 | 912 |
return 30; |
912 | 913 |
} |
913 | 914 |
|
... | ... | |
924 | 925 |
} |
925 | 926 |
|
926 | 927 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
927 |
if (isTocItemBranch(item)) {
|
|
928 |
if (isTocItemBranch(item)) { |
|
928 | 929 |
return true; |
929 | 930 |
} |
930 | 931 |
return false; |
931 |
|
|
932 |
|
|
932 | 933 |
} |
933 | 934 |
|
934 |
|
|
935 |
|
|
935 | 936 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
936 | 937 |
try { |
937 | 938 |
getNodeLayer(item).reload(); |
... | ... | |
943 | 944 |
|
944 | 945 |
|
945 | 946 |
|
946 |
class OldTocContextMenuAction extends AbstractTocContextMenuAction {
|
|
947 |
class OldTocContextMenuAction extends AbstractTocContextMenuAction { |
|
947 | 948 |
private TocMenuEntry entry; |
948 | 949 |
|
949 | 950 |
public int getGroupOrder() { |
950 | 951 |
return 999; |
951 | 952 |
} |
952 |
|
|
953 |
|
|
953 | 954 |
public String getGroup() { |
954 | 955 |
return "zzzOldMenus"; |
955 | 956 |
} |
956 |
|
|
957 |
|
|
957 | 958 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
958 | 959 |
return; //No se llega a ejecutar nunca |
959 | 960 |
} |
960 |
|
|
961 |
|
|
961 | 962 |
public String getText() { |
962 | 963 |
return null; //No se llega a ejecutar nunca |
963 | 964 |
} |
964 |
|
|
965 |
|
|
965 | 966 |
public void initializeElement(FPopupMenu menu) { |
966 | 967 |
this.entry.initialize(menu); |
967 | 968 |
} |
968 |
|
|
969 |
|
|
969 | 970 |
public void setEntry(TocMenuEntry entry) { |
970 | 971 |
this.entry = entry; |
971 | 972 |
} |
972 |
|
|
973 |
|
|
973 | 974 |
public TocMenuEntry getEntry() { |
974 | 975 |
return this.entry; |
975 | 976 |
} |
... | ... | |
1011 | 1012 |
extensionPoints.add("View_TocActions","LayersGroup",new LayersGroupTocMenuEntry()); |
1012 | 1013 |
extensionPoints.add("View_TocActions","LayersUngroup",new LayersUngroupTocMenuEntry()); |
1013 | 1014 |
extensionPoints.add("View_TocActions","FirstLayer",new FirstLayerTocMenuEntry()); |
1014 |
|
|
1015 |
|
|
1015 |
|
|
1016 |
|
|
1016 | 1017 |
} |
1017 | 1018 |
static { |
1018 | 1019 |
/* Cambiados |
... | ... | |
1024 | 1025 |
FPopupMenu.addEntry(new ZoomAlTemaTocMenuEntry()); |
1025 | 1026 |
FPopupMenu.addEntry(new ZoomPixelCursorTocMenuEntry()); |
1026 | 1027 |
|
1027 |
|
|
1028 |
|
|
1028 | 1029 |
FPopupMenu.addEntry(new EliminarCapaTocMenuEntry()); |
1029 | 1030 |
FPopupMenu.addEntry(new ReloadLayerTocMenuEntry()); |
1030 | 1031 |
|
1031 | 1032 |
FPopupMenu.addEntry(new LayersGroupTocMenuEntry()); |
1032 | 1033 |
FPopupMenu.addEntry(new LayersUngroupTocMenuEntry()); |
1033 | 1034 |
|
1034 |
|
|
1035 |
|
|
1035 | 1036 |
FPopupMenu.addEntry(new FirstLayerTocMenuEntry()); |
1036 | 1037 |
*/ |
1037 | 1038 |
FPopupMenu.addEntry(new FLyrRasterAdjustPropertiesTocMenuEntry()); |
... | ... | |
1042 | 1043 |
* @deprecated |
1043 | 1044 |
*/ |
1044 | 1045 |
public static void addEntry(TocMenuEntry entry) { |
1045 |
|
|
1046 |
|
|
1046 | 1047 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
1047 |
|
|
1048 |
|
|
1048 | 1049 |
OldTocContextMenuAction action = new OldTocContextMenuAction(); |
1049 | 1050 |
action.setEntry(entry); |
1050 | 1051 |
String name =entry.getClass().getName(); |
1051 | 1052 |
name = name.substring(name.lastIndexOf(".")+1); |
1052 | 1053 |
extensionPoints.add("View_TocActions",name,action); |
1053 |
|
|
1054 |
|
|
1054 | 1055 |
} |
1055 | 1056 |
|
1056 | 1057 |
/** |
... | ... | |
1087 | 1088 |
super(); |
1088 | 1089 |
this.initialize(mc,node); |
1089 | 1090 |
} |
1090 |
|
|
1091 |
|
|
1091 | 1092 |
private void initialize(FMap mc, DefaultMutableTreeNode node) { |
1092 | 1093 |
this.mapContext = mc; |
1093 | 1094 |
this.nodo = node; |
... | ... | |
1095 | 1096 |
//salir = new MenuItem("Salir"); |
1096 | 1097 |
this.extensionPoint = (ExtensionPoint)ExtensionPointsSingleton.getInstance().get("View_TocActions"); |
1097 | 1098 |
this.selecteds = this.mapContext.getLayers().getActives(); |
1098 |
|
|
1099 |
|
|
1099 | 1100 |
IContextMenuAction[] actions = this.getActionList(); |
1100 |
|
|
1101 |
|
|
1101 | 1102 |
this.createMenuElements(actions); |
1102 |
|
|
1103 |
|
|
1103 | 1104 |
this.loadOldStileOptions(); |
1104 |
|
|
1105 | 1105 |
|
1106 |
|
|
1106 | 1107 |
} |
1107 | 1108 |
|
1108 | 1109 |
public FMap getMapContext() { return mapContext; } |
... | ... | |
1111 | 1112 |
if (nodo == null) return null; |
1112 | 1113 |
return (ITocItem)nodo.getUserObject(); |
1113 | 1114 |
} |
1114 |
|
|
1115 |
|
|
1115 | 1116 |
public DefaultMutableTreeNode getNode() { |
1116 | 1117 |
return this.nodo; |
1117 | 1118 |
} |
1118 |
|
|
1119 |
|
|
1119 | 1120 |
private IContextMenuAction[] getActionList() { |
1120 | 1121 |
ArrayList actionArrayList = new ArrayList(); |
1121 | 1122 |
Iterator iter = this.extensionPoint.keySet().iterator(); |
... | ... | |
1137 | 1138 |
actionArrayList.add(action); |
1138 | 1139 |
} |
1139 | 1140 |
} |
1140 |
|
|
1141 |
|
|
1141 | 1142 |
} |
1142 |
IContextMenuAction[] result = (IContextMenuAction[])Array.newInstance(IContextMenuAction.class,actionArrayList.size());
|
|
1143 |
IContextMenuAction[] result = (IContextMenuAction[])Array.newInstance(IContextMenuAction.class,actionArrayList.size()); |
|
1143 | 1144 |
System.arraycopy(actionArrayList.toArray(),0,result,0,actionArrayList.size()); |
1144 | 1145 |
Arrays.sort(result,new CompareAction()); |
1145 |
|
|
1146 |
|
|
1146 | 1147 |
return result; |
1147 | 1148 |
} |
1148 |
|
|
1149 |
|
|
1149 | 1150 |
public class CompareAction implements Comparator{ |
1150 | 1151 |
public int compare(Object o1, Object o2) { |
1151 | 1152 |
return this.compare((IContextMenuAction)o1,(IContextMenuAction)o2); |
1152 | 1153 |
} |
1153 |
|
|
1154 |
|
|
1154 | 1155 |
public int compare(IContextMenuAction o1, IContextMenuAction o2) { |
1155 | 1156 |
//FIXME: flata formatear los enteros!!!! |
1156 | 1157 |
NumberFormat formater = NumberFormat.getInstance(); |
... | ... | |
1160 | 1161 |
return key1.compareTo(key2); |
1161 | 1162 |
} |
1162 | 1163 |
} |
1163 |
|
|
1164 |
|
|
1164 | 1165 |
private void createMenuElements(IContextMenuAction[] actions) { |
1165 | 1166 |
String group = null; |
1166 | 1167 |
for (int i=0;i < actions.length;i++) { |
1167 | 1168 |
IContextMenuAction action = actions[i]; |
1168 | 1169 |
MenuItem item = new MenuItem(action.getText(),action); |
1169 | 1170 |
item.setFont(theFont); |
1170 |
item.setEnabled(action.isEnabled(this.getNodeUserObject(),this.selecteds));
|
|
1171 |
item.setEnabled(action.isEnabled(this.getNodeUserObject(),this.selecteds)); |
|
1171 | 1172 |
if (!action.getGroup().equals(group)) { |
1172 | 1173 |
if (group != null) this.addSeparator(); |
1173 |
group = action.getGroup();
|
|
1174 |
}
|
|
1175 |
this.add(item);
|
|
1174 |
group = action.getGroup(); |
|
1175 |
} |
|
1176 |
this.add(item); |
|
1176 | 1177 |
} |
1177 |
|
|
1178 |
|
|
1178 | 1179 |
} |
1179 | 1180 |
|
1180 |
|
|
1181 |
|
|
1181 | 1182 |
public class MenuItem extends JMenuItem implements ActionListener{ |
1182 | 1183 |
private IContextMenuAction action; |
1183 | 1184 |
public MenuItem(String text,IContextMenuAction documentAction) { |
... | ... | |
1189 | 1190 |
} |
1190 | 1191 |
this.addActionListener(this); |
1191 | 1192 |
} |
1192 |
|
|
1193 |
|
|
1193 | 1194 |
public void actionPerformed(ActionEvent e) { |
1194 | 1195 |
this.action.execute(FPopupMenu.this.getNodeUserObject(), FPopupMenu.this.selecteds); |
1195 | 1196 |
} |
1196 | 1197 |
} |
1197 |
|
|
1198 |
|
|
1198 | 1199 |
private void loadOldStileOptions() { |
1199 | 1200 |
boolean first = true; |
1200 | 1201 |
Iterator iter = this.extensionPoint.keySet().iterator(); |
... | ... | |
1224 | 1225 |
//Si lo es lo eliminamos |
1225 | 1226 |
this.remove(this.getComponentCount()-1); |
1226 | 1227 |
} |
1227 |
|
|
1228 |
|
|
1228 |
|
|
1229 |
|
|
1229 | 1230 |
} |
1230 |
|
|
1231 | 1231 |
|
1232 |
|
|
1232 | 1233 |
} |
Also available in: Unified diff