root / trunk / applications / appCatalogYNomenclatorClient / src / es / gva / cit / catalogClient / ui / CatalogClientShowResultsPanelButtons.java @ 2047
History | View | Annotate | Download (4.82 KB)
1 |
/*
|
---|---|
2 |
* Created on 10-may-2005
|
3 |
*/
|
4 |
package es.gva.cit.catalogClient.ui; |
5 |
|
6 |
import java.awt.Dimension; |
7 |
import java.awt.event.ActionEvent; |
8 |
import java.awt.event.ActionListener; |
9 |
import java.io.IOException; |
10 |
|
11 |
import javax.swing.BoxLayout; |
12 |
import javax.swing.JButton; |
13 |
import javax.swing.JPanel; |
14 |
|
15 |
import org.w3c.dom.Node; |
16 |
|
17 |
import com.Ostermiller.util.Browser; |
18 |
|
19 |
import es.gva.cit.catalogClient.CatalogClient; |
20 |
import es.gva.cit.catalogClient.metadataXML.XMLTreeNumberOfRecordsAnswer; |
21 |
import es.gva.cit.catalogClient.parsers.Resource; |
22 |
import es.gva.cit.catalogClient.querys.Query; |
23 |
|
24 |
|
25 |
/**
|
26 |
* @author jpiera
|
27 |
*/
|
28 |
public class CatalogClientShowResultsPanelButtons |
29 |
extends JPanel implements ActionListener{ |
30 |
JPanel ppalPanel = null; |
31 |
JPanel imagePanel = null; |
32 |
CatalogClientNextLastPanel numRecordsPanel = null;
|
33 |
Node[] nodes = null; |
34 |
protected CatalogClientShowResultsPanel recordPanel = null; |
35 |
JButton descriptionButton = null; |
36 |
JButton mapButton = null; |
37 |
CatalogClient client = null;
|
38 |
Query query = null; |
39 |
JButton nextButton = null; |
40 |
JButton lastButton = null; |
41 |
int currentRecord = 0; |
42 |
boolean hasImage = false; |
43 |
|
44 |
public CatalogClientShowResultsPanelButtons(Node[] nodes,CatalogClient client,Query query,int currentRecord){ |
45 |
this.nodes = nodes;
|
46 |
this.client = client;
|
47 |
this.query = query;
|
48 |
this.currentRecord = currentRecord;
|
49 |
|
50 |
ppalPanel = new JPanel(); |
51 |
ppalPanel.setLayout(new BoxLayout(ppalPanel, BoxLayout.Y_AXIS)); |
52 |
|
53 |
//Add the numRecordsPanel
|
54 |
numRecordsPanel = new CatalogClientNextLastPanel(XMLTreeNumberOfRecordsAnswer.getNumberOfRecords(nodes[0])); |
55 |
int numRecords = XMLTreeNumberOfRecordsAnswer.getNumberOfRecords(nodes[0]); |
56 |
nextButton = numRecordsPanel.getNextButton(); |
57 |
nextButton.addActionListener(this);
|
58 |
lastButton = numRecordsPanel.getLastButton(); |
59 |
lastButton.addActionListener(this);
|
60 |
ppalPanel.add(numRecordsPanel); |
61 |
|
62 |
recordPanel = new CatalogClientShowResultsPanel(nodes[currentRecord],client.getProtocol());
|
63 |
|
64 |
ppalPanel.add(recordPanel); |
65 |
|
66 |
if (hasImage){
|
67 |
|
68 |
} |
69 |
|
70 |
add(ppalPanel); |
71 |
} |
72 |
|
73 |
public JButton getDescriptionButton() { |
74 |
if (descriptionButton == null) |
75 |
descriptionButton = recordPanel.getDescriptionButton(); |
76 |
return descriptionButton;
|
77 |
} |
78 |
|
79 |
public JButton getMapButton() { |
80 |
if (mapButton == null) |
81 |
mapButton = recordPanel.getMapButton(); |
82 |
return mapButton;
|
83 |
} |
84 |
|
85 |
public void setDefaultButtonListeners() { |
86 |
getDescriptionButton().addActionListener(this);
|
87 |
getMapButton().addActionListener(this);
|
88 |
} |
89 |
|
90 |
|
91 |
public void createNewSearch(){ |
92 |
Node[] nodesRecords = null; |
93 |
|
94 |
nodesRecords = client.getLnkICatalogServerDriver().getRecords(client.getUrl(), |
95 |
query, |
96 |
this.currentRecord);
|
97 |
|
98 |
this.nodes = nodesRecords;
|
99 |
} |
100 |
|
101 |
public int getCurrentNode(){ |
102 |
if ((currentRecord % 10) == 0) |
103 |
return 10; |
104 |
else
|
105 |
return (currentRecord % 10); |
106 |
} |
107 |
|
108 |
public void actionPerformed(ActionEvent e) { |
109 |
if (e.getActionCommand().equals("Siguiente")){ |
110 |
this.currentRecord = this.currentRecord + 1; |
111 |
if (this.currentRecord == XMLTreeNumberOfRecordsAnswer.getNumberOfRecords(nodes[0])) |
112 |
nextButton.setEnabled(false);
|
113 |
else
|
114 |
nextButton.setEnabled(true);
|
115 |
|
116 |
lastButton.setEnabled(true);
|
117 |
|
118 |
if ((this.currentRecord % 10) == 1) |
119 |
createNewSearch(); |
120 |
|
121 |
recordPanel.loadTextNewRecord(nodes[getCurrentNode()],client.getProtocol()); |
122 |
numRecordsPanel.actualizaLabel(currentRecord); |
123 |
} else if (e.getActionCommand().equals("Anterior")){ |
124 |
this.currentRecord = this.currentRecord - 1; |
125 |
if (this.currentRecord == 1) |
126 |
lastButton.setEnabled(false);
|
127 |
else
|
128 |
lastButton.setEnabled(true);
|
129 |
nextButton.setEnabled(true);
|
130 |
|
131 |
if ((this.currentRecord % 10) == 0) |
132 |
createNewSearch(); |
133 |
|
134 |
recordPanel.loadTextNewRecord(nodes[getCurrentNode()],client.getProtocol()); |
135 |
numRecordsPanel.actualizaLabel(currentRecord); |
136 |
} else if (e.getActionCommand().equals("Descripcion")){ |
137 |
descriptionButtonActionPerformed(); |
138 |
} else if (e.getActionCommand().equals("Mapa")){ |
139 |
mapButtonActionPerformed(); |
140 |
} |
141 |
} |
142 |
|
143 |
public void descriptionButtonActionPerformed() { |
144 |
CatalogClientShowResultsPanelTreeButtons frame = new CatalogClientShowResultsPanelTreeButtons(nodes,getCurrentNode());
|
145 |
frame.setSize(new Dimension(800,800)); |
146 |
frame.setTitle("Cliente de Cat?logo");
|
147 |
frame.setVisible(true);
|
148 |
} |
149 |
|
150 |
public void mapButtonActionPerformed() { |
151 |
Resource[] resources = recordPanel.getTags().getResources();
|
152 |
for (int i = 0 ; i < resources.length ; i++){ |
153 |
System.out.println("******************************************"); |
154 |
System.out.println("PROTOCOLO: " + resources[i].getProtocol()); |
155 |
System.out.println("LINK: " + resources[i].getLinkage()); |
156 |
System.out.println("RECURSO: " + resources[i].getName()); |
157 |
|
158 |
if ((resources != null) && (resources[0] != null) && (resources[0].getLinkage() != null)){ |
159 |
Browser.init(); |
160 |
try {
|
161 |
Browser.displayURL(resources[0].getLinkage());
|
162 |
} catch (IOException e1) { |
163 |
e1.printStackTrace(); |
164 |
} |
165 |
} |
166 |
} |
167 |
} |
168 |
} |