Revision 4473 trunk/extensions/extWMS/src/com/iver/cit/gvsig/gui/wizards/WMSWizard.java
WMSWizard.java | ||
---|---|---|
51 | 51 |
import javax.swing.JLabel; |
52 | 52 |
import javax.swing.JOptionPane; |
53 | 53 |
import javax.swing.JPanel; |
54 |
import javax.swing.tree.DefaultTreeModel; |
|
54 | 55 |
import javax.swing.tree.TreePath; |
55 | 56 |
|
56 | 57 |
import org.apache.log4j.Logger; |
... | ... | |
679 | 680 |
return wmsParamsPanel.getLayerName(); |
680 | 681 |
} |
681 | 682 |
|
682 |
|
|
683 | 683 |
public void initWizard() { |
684 | 684 |
dataSource = new WMSWizardData(); |
685 | 685 |
} |
... | ... | |
706 | 706 |
} |
707 | 707 |
} |
708 | 708 |
|
709 |
// private Object[] getFullPath(String name){ |
|
710 |
// Vector path = new Vector(); |
|
711 |
// WMSLayerNode layerNode; |
|
712 |
// WMSLayerNode parent; |
|
713 |
// for (int i = 0; i <wmsParamsPanel.getLstSelectedLayers().getModel().getSize(); i++) { |
|
714 |
// layerNode = (WMSLayerNode)wmsParamsPanel.getLstSelectedLayers().getModel().getElementAt(i); |
|
715 |
// if(layerNode.getName().compareTo( name ) == 0 ){ |
|
716 |
// path.add(layerNode); |
|
717 |
// parent = (WMSLayerNode)layerNode.getParent().clone(); |
|
718 |
// while ( parent != null){ |
|
719 |
// path.add(parent); |
|
720 |
// parent = (WMSLayerNode)parent.getParent().clone(); |
|
721 |
// } |
|
722 |
// } |
|
723 |
// } |
|
724 |
// return path.toArray(); |
|
725 |
// } |
|
726 |
|
|
709 | 727 |
/** |
710 | 728 |
* If user does not select the chekbox Disagregate layers, will get the layer tree in WMS |
711 | 729 |
* @return |
712 | 730 |
*/ |
713 | 731 |
private FLayer getLayerTree() { |
714 |
//View v = (View) PluginServices.getMDIManager().getActiveView(); |
|
715 |
//FLayers l = new FLayers(v.getMapControl().getMapContext(), null); |
|
716 |
//l.setName("composite"); |
|
717 |
//String[] layerNames = getLayersQuery().split(","); |
|
718 |
LayerTree layerTree = wmsParamsPanel.getLayerStructure(); |
|
719 |
|
|
720 |
TreePath[] selection = layerTree.getSelectionPaths(); |
|
732 |
String[] layerNames = getLayersQuery().split(","); |
|
733 |
LayerTree layerTree = wmsParamsPanel.getLayerStructure(); |
|
734 |
// try{ |
|
735 |
// for (int i = 0; i < layerNames.length; i++) { |
|
736 |
// TreePath path = new TreePath(getFullPath(layerNames[i])); |
|
737 |
// layerTree.addSelectionPath(path); |
|
738 |
// } |
|
739 |
// }catch(Exception e){ |
|
740 |
// e.printStackTrace(); |
|
741 |
// } |
|
742 |
TreePath[] selection = (TreePath[])wmsParamsPanel.getSelectedPaths().toArray(new TreePath[0]);//layerTree.getSelectionPaths(); |
|
721 | 743 |
if (selection!=null){ |
722 |
return getSubTree((WMSLayerNode)layerTree.getModel().getRoot(), selection);
|
|
744 |
return getSubTree((WMSLayerNode)layerTree.getModel().getRoot(), selection); |
|
723 | 745 |
} |
724 | 746 |
return null; |
725 | 747 |
} |
726 | 748 |
|
727 |
private boolean nodeSelected(TreePath[] selection, Object node){ |
|
728 |
|
|
749 |
private boolean nodeSelected(TreePath[] selection, WMSLayerNode node){ |
|
729 | 750 |
for (int i = 0; i < selection.length; i++) { |
730 | 751 |
Object[] components = selection[i].getPath(); |
731 | 752 |
for (int j=0; j < components.length ; j++) |
732 | 753 |
{ |
733 |
if (components[j].equals(node)){ |
|
734 |
return true; |
|
754 |
|
|
755 |
// if (components[j].equals(node)){ |
|
756 |
// return true; |
|
757 |
// } |
|
758 |
if (components[j] instanceof WMSLayerNode){ |
|
759 |
if (((WMSLayerNode)components[j]).getTitle().compareTo(node.getTitle()) == 0){ |
|
760 |
return true; |
|
761 |
} |
|
735 | 762 |
} |
736 |
// if (components[j] instanceof WMSLayerNode){ |
|
737 |
// if (((WMSLayerNode)components[j]).getName().compareTo(name) == 0){ |
|
738 |
// return true; |
|
739 |
// } |
|
740 |
// } |
|
741 | 763 |
// else if (components[j] instanceof String){ |
742 | 764 |
// if (((String)(components[j])).compareTo(name) == 0){ |
743 | 765 |
// return true; |
... | ... | |
754 | 776 |
{ |
755 | 777 |
View v = (View) PluginServices.getMDIManager().getActiveView(); |
756 | 778 |
FLayers l = new FLayers(v.getMapControl().getMapContext(), null); |
757 |
l.setName(node.getName());
|
|
779 |
l.setName(node.getTitle());
|
|
758 | 780 |
for(int i = 0; i < node.getChildren().size(); i++ ){ |
759 | 781 |
if (nodeSelected(selection, (WMSLayerNode)(node.getChildren().get(i)))) |
760 | 782 |
{ |
Also available in: Unified diff