Commit a6dc855e6d94a7cebce9d1d0bff8a19400e05145
1 parent
d470f971
Exists in
master
Add tabs (draft)
Showing
3 changed files
with
82 additions
and
24 deletions
Show diff stats
src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelCtrl.java
@@ -17,6 +17,7 @@ | @@ -17,6 +17,7 @@ | ||
17 | package eu.omp.irap.vespa.epntapclient.gui.mainpanel; | 17 | package eu.omp.irap.vespa.epntapclient.gui.mainpanel; |
18 | 18 | ||
19 | import java.awt.Cursor; | 19 | import java.awt.Cursor; |
20 | +import java.io.File; | ||
20 | import java.util.logging.Level; | 21 | import java.util.logging.Level; |
21 | import java.util.logging.Logger; | 22 | import java.util.logging.Logger; |
22 | 23 | ||
@@ -177,7 +178,8 @@ public class MainPanelCtrl extends EpnTapController implements MainPanelListener | @@ -177,7 +178,8 @@ public class MainPanelCtrl extends EpnTapController implements MainPanelListener | ||
177 | @Override | 178 | @Override |
178 | protected void done() { | 179 | protected void done() { |
179 | if (!isCancelled()) { | 180 | if (!isCancelled()) { |
180 | - resultsPanelCtrl.getView().fillTable(resultsPanelCtrl.getVOTableData()); | 181 | + String fName = new File(resultsPanelCtrl.getVOTablePath()).getName(); |
182 | + resultsPanelCtrl.getView().addTable(fName, resultsPanelCtrl.getVOTableData()); | ||
181 | } | 183 | } |
182 | view.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); | 184 | view.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
183 | } | 185 | } |
src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelCtrl.java
@@ -52,6 +52,17 @@ public class ResultPanelCtrl extends VOTableCtrl implements ResultPanelListener | @@ -52,6 +52,17 @@ public class ResultPanelCtrl extends VOTableCtrl implements ResultPanelListener | ||
52 | view = new ResultPanelView(this); | 52 | view = new ResultPanelView(this); |
53 | } | 53 | } |
54 | 54 | ||
55 | + /** Download and parse a VOTable, then add the result to the current tab in the result panel. */ | ||
56 | + @Override | ||
57 | + public void appendVOTable(String newTargetURL, String newQuery) { | ||
58 | + try { | ||
59 | + super.appendVOTable(newTargetURL, newQuery); | ||
60 | + } catch (VOTableException e) { | ||
61 | + listener.displayError("Can not update the VOTable.", e); | ||
62 | + } | ||
63 | + view.updateTable(voTableData); | ||
64 | + } | ||
65 | + | ||
55 | @Override | 66 | @Override |
56 | public void displayInfo(String shortMessage, String detailledMessage) { | 67 | public void displayInfo(String shortMessage, String detailledMessage) { |
57 | super.displayInfo(shortMessage, detailledMessage); | 68 | super.displayInfo(shortMessage, detailledMessage); |
@@ -78,14 +89,4 @@ public class ResultPanelCtrl extends VOTableCtrl implements ResultPanelListener | @@ -78,14 +89,4 @@ public class ResultPanelCtrl extends VOTableCtrl implements ResultPanelListener | ||
78 | public void onRowsSelected() { | 89 | public void onRowsSelected() { |
79 | LOGGER.info("Selected row: " + StringJoiner.join(view.getSelectedRows())); | 90 | LOGGER.info("Selected row: " + StringJoiner.join(view.getSelectedRows())); |
80 | } | 91 | } |
81 | - | ||
82 | - @Override | ||
83 | - public void appendVOTable(String newTargetURL, String newQuery) { | ||
84 | - try { | ||
85 | - super.appendVOTable(newTargetURL, newQuery); | ||
86 | - } catch (VOTableException e) { | ||
87 | - listener.displayError("Can not update the VOTable.", e); | ||
88 | - } | ||
89 | - view.fillTable(voTableData); | ||
90 | - } | ||
91 | } | 92 | } |
src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelView.java
@@ -19,34 +19,43 @@ package eu.omp.irap.vespa.epntapclient.gui.resultpanel; | @@ -19,34 +19,43 @@ package eu.omp.irap.vespa.epntapclient.gui.resultpanel; | ||
19 | import java.awt.BorderLayout; | 19 | import java.awt.BorderLayout; |
20 | import java.awt.event.ActionEvent; | 20 | import java.awt.event.ActionEvent; |
21 | import java.awt.event.ActionListener; | 21 | import java.awt.event.ActionListener; |
22 | +import java.util.ArrayList; | ||
23 | +import java.util.List; | ||
22 | 24 | ||
23 | import javax.swing.JButton; | 25 | import javax.swing.JButton; |
24 | import javax.swing.JFileChooser; | 26 | import javax.swing.JFileChooser; |
25 | import javax.swing.JLabel; | 27 | import javax.swing.JLabel; |
26 | import javax.swing.JPanel; | 28 | import javax.swing.JPanel; |
29 | +import javax.swing.JTabbedPane; | ||
27 | 30 | ||
31 | +import eu.omp.irap.vespa.votable.gui.VOTablePanelListener; | ||
28 | import eu.omp.irap.vespa.votable.gui.VOTablePanelView; | 32 | import eu.omp.irap.vespa.votable.gui.VOTablePanelView; |
33 | +import eu.omp.irap.vespa.votable.votabledata.VOTableData; | ||
29 | 34 | ||
30 | /** | 35 | /** |
31 | * @author N. Jourdane | 36 | * @author N. Jourdane |
32 | */ | 37 | */ |
33 | -public class ResultPanelView extends VOTablePanelView { | 38 | +public class ResultPanelView extends JPanel implements VOTablePanelListener { |
34 | 39 | ||
35 | /** The serial version UID. */ | 40 | /** The serial version UID. */ |
36 | private static final long serialVersionUID = 1L; | 41 | private static final long serialVersionUID = 1L; |
37 | 42 | ||
43 | + /** The JPanel containing the buttons. */ | ||
44 | + private JPanel buttonsPanel; | ||
45 | + | ||
38 | /** The GUI element of the button to save the result of the query. */ | 46 | /** The GUI element of the button to save the result of the query. */ |
39 | private JButton fileButton; | 47 | private JButton fileButton; |
40 | 48 | ||
41 | /** A status bar, to display several informative messages. */ | 49 | /** A status bar, to display several informative messages. */ |
42 | private JLabel statusBar; | 50 | private JLabel statusBar; |
43 | 51 | ||
52 | + private JTabbedPane tabbedPane; | ||
53 | + | ||
54 | + private List<VOTablePanelView> tablePanels; | ||
55 | + | ||
44 | /** The listener of the result panel. */ | 56 | /** The listener of the result panel. */ |
45 | ResultPanelListener listener; | 57 | ResultPanelListener listener; |
46 | 58 | ||
47 | - /** The JPanel containing the buttons. */ | ||
48 | - private JPanel buttonsPanel; | ||
49 | - | ||
50 | 59 | ||
51 | /** | 60 | /** |
52 | * Method constructor which customize the result panel, but don't build it from scratch since | 61 | * Method constructor which customize the result panel, but don't build it from scratch since |
@@ -55,24 +64,55 @@ public class ResultPanelView extends VOTablePanelView { | @@ -55,24 +64,55 @@ public class ResultPanelView extends VOTablePanelView { | ||
55 | * @param listener The listener of the result view. | 64 | * @param listener The listener of the result view. |
56 | */ | 65 | */ |
57 | public ResultPanelView(ResultPanelListener listener) { | 66 | public ResultPanelView(ResultPanelListener listener) { |
58 | - super(listener); | ||
59 | this.listener = listener; | 67 | this.listener = listener; |
68 | + tablePanels = new ArrayList<>(); | ||
60 | buildResultPanel(); | 69 | buildResultPanel(); |
61 | } | 70 | } |
62 | 71 | ||
63 | /** | 72 | /** |
73 | + * Create a new tab and add a new VOTable into it. | ||
74 | + * | ||
75 | + * @param voTableData The VOTable data to add in a new tab. | ||
76 | + */ | ||
77 | + public void addTable(String title, VOTableData voTableData) { | ||
78 | + VOTablePanelView voTablePanel = new VOTablePanelView(this); | ||
79 | + voTablePanel.fillTable(voTableData); | ||
80 | + tablePanels.add(voTablePanel); | ||
81 | + tabbedPane.add(title, voTablePanel); | ||
82 | + } | ||
83 | + | ||
84 | + /** | ||
64 | * Build the panel and add graphical elements to it. | 85 | * Build the panel and add graphical elements to it. |
65 | */ | 86 | */ |
66 | public void buildResultPanel() { | 87 | public void buildResultPanel() { |
88 | + tabbedPane = new JTabbedPane(); | ||
67 | JPanel bottomBar = new JPanel(); | 89 | JPanel bottomBar = new JPanel(); |
68 | bottomBar.setLayout(new BorderLayout()); | 90 | bottomBar.setLayout(new BorderLayout()); |
69 | bottomBar.add(getStatusBar(), BorderLayout.CENTER); | 91 | bottomBar.add(getStatusBar(), BorderLayout.CENTER); |
70 | bottomBar.add(getButtonsPanel(), BorderLayout.EAST); | 92 | bottomBar.add(getButtonsPanel(), BorderLayout.EAST); |
71 | 93 | ||
94 | + add(tabbedPane, BorderLayout.CENTER); | ||
72 | add(bottomBar, BorderLayout.SOUTH); | 95 | add(bottomBar, BorderLayout.SOUTH); |
73 | } | 96 | } |
74 | 97 | ||
75 | /** | 98 | /** |
99 | + * Create if necessary the buttons panel, then return it. | ||
100 | + * | ||
101 | + * @return the buttons panel. | ||
102 | + */ | ||
103 | + public JPanel getButtonsPanel() { | ||
104 | + if (buttonsPanel == null) { | ||
105 | + buttonsPanel = new JPanel(); | ||
106 | + buttonsPanel.add(getFileButton()); | ||
107 | + } | ||
108 | + return buttonsPanel; | ||
109 | + } | ||
110 | + | ||
111 | + public VOTablePanelView getCurrentTablePanel() { | ||
112 | + return tablePanels.get(getSelectedTab()); | ||
113 | + } | ||
114 | + | ||
115 | + /** | ||
76 | * Returns the button to save the VOTable, create it if doesn't exist. | 116 | * Returns the button to save the VOTable, create it if doesn't exist. |
77 | * | 117 | * |
78 | * @return The button to save the VOTable. | 118 | * @return The button to save the VOTable. |
@@ -94,6 +134,20 @@ public class ResultPanelView extends VOTablePanelView { | @@ -94,6 +134,20 @@ public class ResultPanelView extends VOTablePanelView { | ||
94 | } | 134 | } |
95 | 135 | ||
96 | /** | 136 | /** |
137 | + * @return The index of the selected tab. | ||
138 | + */ | ||
139 | + public List<Integer> getSelectedRows() { | ||
140 | + return getCurrentTablePanel().getSelectedRows(); | ||
141 | + } | ||
142 | + | ||
143 | + /** | ||
144 | + * @return The index of the selected tab. | ||
145 | + */ | ||
146 | + public int getSelectedTab() { | ||
147 | + return tabbedPane.getSelectedIndex(); | ||
148 | + } | ||
149 | + | ||
150 | + /** | ||
97 | * Returns the status bar, create it if doesn't exist. | 151 | * Returns the status bar, create it if doesn't exist. |
98 | * | 152 | * |
99 | * @return The status bar. | 153 | * @return The status bar. |
@@ -105,6 +159,11 @@ public class ResultPanelView extends VOTablePanelView { | @@ -105,6 +159,11 @@ public class ResultPanelView extends VOTablePanelView { | ||
105 | return statusBar; | 159 | return statusBar; |
106 | } | 160 | } |
107 | 161 | ||
162 | + @Override | ||
163 | + public void onRowsSelected() { | ||
164 | + // Do nothing yet when a row is selected. | ||
165 | + } | ||
166 | + | ||
108 | /** | 167 | /** |
109 | * @param infoText The text to display in the status-bar, which will override the old one. | 168 | * @param infoText The text to display in the status-bar, which will override the old one. |
110 | */ | 169 | */ |
@@ -113,15 +172,11 @@ public class ResultPanelView extends VOTablePanelView { | @@ -113,15 +172,11 @@ public class ResultPanelView extends VOTablePanelView { | ||
113 | } | 172 | } |
114 | 173 | ||
115 | /** | 174 | /** |
116 | - * Create if necessary the buttons panel, then return it. | 175 | + * Append data to the current tab. |
117 | * | 176 | * |
118 | - * @return the buttons panel. | 177 | + * @param voTableData The VOTable data to add in the current tab. |
119 | */ | 178 | */ |
120 | - public JPanel getButtonsPanel() { | ||
121 | - if (buttonsPanel == null) { | ||
122 | - buttonsPanel = new JPanel(); | ||
123 | - buttonsPanel.add(getFileButton()); | ||
124 | - } | ||
125 | - return buttonsPanel; | 179 | + public void updateTable(VOTableData voTableData) { |
180 | + getCurrentTablePanel().fillTable(voTableData); | ||
126 | } | 181 | } |
127 | } | 182 | } |