Commit 4ce406a850237ffd1a0745473d9c2e7acd9425e0

Authored by Nathanael Jourdane
1 parent 0f1bce56
Exists in master

Add build() classes in JPanels.

src/main/java/eu/omp/irap/vespa/epntapclient/view/EpnTapMainView.java
@@ -65,7 +65,7 @@ public class EpnTapMainView extends JPanel { @@ -65,7 +65,7 @@ public class EpnTapMainView extends JPanel {
65 resultsPanel = new ResultsPanel(viewListener, voTableResultsView); 65 resultsPanel = new ResultsPanel(viewListener, voTableResultsView);
66 requestPanel = new RequestPanel(viewListener); 66 requestPanel = new RequestPanel(viewListener);
67 bottomBarPanel = new BottomBarPanel(viewListener); 67 bottomBarPanel = new BottomBarPanel(viewListener);
68 - buildWindow(); 68 + buildMainView();
69 } 69 }
70 70
71 /** 71 /**
@@ -99,13 +99,13 @@ public class EpnTapMainView extends JPanel { @@ -99,13 +99,13 @@ public class EpnTapMainView extends JPanel {
99 /** 99 /**
100 * Build and fill the GUI. 100 * Build and fill the GUI.
101 */ 101 */
102 - public void buildWindow() { 102 + private void buildMainView() {
103 setLayout(new BorderLayout()); 103 setLayout(new BorderLayout());
104 104
105 JSplitPane northPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, servicesPanel, 105 JSplitPane northPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, servicesPanel,
106 requestPanel); 106 requestPanel);
107 -  
108 JSplitPane mainPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, northPanel, resultsPanel); 107 JSplitPane mainPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, northPanel, resultsPanel);
  108 +
109 add(mainPanel, BorderLayout.CENTER); 109 add(mainPanel, BorderLayout.CENTER);
110 add(bottomBarPanel, BorderLayout.SOUTH); 110 add(bottomBarPanel, BorderLayout.SOUTH);
111 } 111 }
src/main/java/eu/omp/irap/vespa/epntapclient/view/ParamField.java
@@ -109,13 +109,20 @@ public abstract class ParamField extends JPanel { @@ -109,13 +109,20 @@ public abstract class ParamField extends JPanel {
109 this.viewListener = viewListener; 109 this.viewListener = viewListener;
110 this.paramName = paramName; 110 this.paramName = paramName;
111 111
  112 + buildParamField();
  113 + // TODO: Add tooltip text based on rr.table_column.column_description
  114 + }
  115 +
  116 + private void buildParamField() {
112 setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); 117 setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
  118 +
113 setMaximumSize(new Dimension(ParamField.MAX_FIELD_WIDTH, ParamField.FIELD_HEIGHT)); 119 setMaximumSize(new Dimension(ParamField.MAX_FIELD_WIDTH, ParamField.FIELD_HEIGHT));
  120 +
114 String strLabel = paramName.replaceAll("_", " ").trim(); 121 String strLabel = paramName.replaceAll("_", " ").trim();
115 JLabel label = new JLabel(strLabel.substring(0, 1).toUpperCase() + strLabel.substring(1)); 122 JLabel label = new JLabel(strLabel.substring(0, 1).toUpperCase() + strLabel.substring(1));
116 label.setPreferredSize(new Dimension(ParamField.LABEL_WIDTH, ParamField.FIELD_HEIGHT)); 123 label.setPreferredSize(new Dimension(ParamField.LABEL_WIDTH, ParamField.FIELD_HEIGHT));
  124 +
117 this.add(label); 125 this.add(label);
118 - // TODO: Add tooltip text based on rr.table_column.column_description  
119 } 126 }
120 127
121 128
src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/BottomBarPanel.java
@@ -38,6 +38,8 @@ public class BottomBarPanel extends JPanel { @@ -38,6 +38,8 @@ public class BottomBarPanel extends JPanel {
38 /** A label to display several informations (aka. status bar). */ 38 /** A label to display several informations (aka. status bar). */
39 private JLabel infoLabel; 39 private JLabel infoLabel;
40 40
  41 + private ViewListener viewListener;
  42 +
41 43
42 /** 44 /**
43 * Method constructor for the bottom bar panel. 45 * Method constructor for the bottom bar panel.
@@ -45,9 +47,19 @@ public class BottomBarPanel extends JPanel { @@ -45,9 +47,19 @@ public class BottomBarPanel extends JPanel {
45 * @param mainView The main view of the application. 47 * @param mainView The main view of the application.
46 */ 48 */
47 public BottomBarPanel(final ViewListener viewListener) { 49 public BottomBarPanel(final ViewListener viewListener) {
  50 + this.viewListener = viewListener;
  51 + buildBottomBarPanel();
  52 + }
  53 +
  54 + private void buildBottomBarPanel() {
48 setLayout(new BorderLayout()); 55 setLayout(new BorderLayout());
  56 +
49 infoLabel = new JLabel(); 57 infoLabel = new JLabel();
50 this.add(infoLabel); 58 this.add(infoLabel);
  59 + this.add(buildGetFileButton(), BorderLayout.EAST);
  60 + }
  61 +
  62 + private JButton buildGetFileButton() {
51 JButton button = new JButton("Get File"); 63 JButton button = new JButton("Get File");
52 button.addActionListener(new ActionListener() { 64 button.addActionListener(new ActionListener() {
53 65
@@ -58,7 +70,7 @@ public class BottomBarPanel extends JPanel { @@ -58,7 +70,7 @@ public class BottomBarPanel extends JPanel {
58 viewListener.onDownloadButtonClicked(fc.getSelectedFile()); 70 viewListener.onDownloadButtonClicked(fc.getSelectedFile());
59 } 71 }
60 }); 72 });
61 - this.add(button, BorderLayout.EAST); 73 + return button;
62 } 74 }
63 75
64 /** 76 /**
src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/RequestPanel.java
@@ -69,7 +69,12 @@ public class RequestPanel extends JPanel { @@ -69,7 +69,12 @@ public class RequestPanel extends JPanel {
69 */ 69 */
70 public RequestPanel(ViewListener viewListener) { 70 public RequestPanel(ViewListener viewListener) {
71 this.viewListener = viewListener; 71 this.viewListener = viewListener;
  72 + buildRequestPanel();
  73 + }
  74 +
  75 + private void buildRequestPanel() {
72 setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); 76 setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
  77 +
73 setPreferredSize(new Dimension(GUIDim.RIGHT_PANEL_WIDTH, GUIDim.TOP_PANEL_HEIGHT)); 78 setPreferredSize(new Dimension(GUIDim.RIGHT_PANEL_WIDTH, GUIDim.TOP_PANEL_HEIGHT));
74 setMinimumSize(new Dimension(GUIDim.RIGHT_PANEL_MIN_WIDTH, GUIDim.TOP_PANEL_MIN_HEIGHT)); 79 setMinimumSize(new Dimension(GUIDim.RIGHT_PANEL_MIN_WIDTH, GUIDim.TOP_PANEL_MIN_HEIGHT));
75 80
src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/ResultsPanel.java
@@ -33,6 +33,8 @@ public class ResultsPanel extends JPanel { @@ -33,6 +33,8 @@ public class ResultsPanel extends JPanel {
33 /** The serial version UID. */ 33 /** The serial version UID. */
34 private static final long serialVersionUID = 1L; 34 private static final long serialVersionUID = 1L;
35 35
  36 + ViewListener viewListener;
  37 +
36 38
37 /** 39 /**
38 * Method constructor which customize the result panel, but don't build it from scratch since 40 * Method constructor which customize the result panel, but don't build it from scratch since
@@ -43,13 +45,19 @@ public class ResultsPanel extends JPanel { @@ -43,13 +45,19 @@ public class ResultsPanel extends JPanel {
43 */ 45 */
44 public ResultsPanel(ViewListener viewListener, VOTableView voTableView) { 46 public ResultsPanel(ViewListener viewListener, VOTableView voTableView) {
45 super(); 47 super();
  48 + this.viewListener = viewListener;
  49 +
  50 + buildResultPanel(voTableView);
  51 + }
46 52
  53 + private void buildResultPanel(VOTableView voTableView) {
47 setLayout(new BorderLayout()); 54 setLayout(new BorderLayout());
48 - this.add(voTableView);  
49 55
50 setPreferredSize(new Dimension(GUIDim.LEFT_PANEL_WIDTH + GUIDim.RIGHT_PANEL_WIDTH, 56 setPreferredSize(new Dimension(GUIDim.LEFT_PANEL_WIDTH + GUIDim.RIGHT_PANEL_WIDTH,
51 GUIDim.BOTTOM_PANEL_HEIGHT)); 57 GUIDim.BOTTOM_PANEL_HEIGHT));
52 setMinimumSize(new Dimension(GUIDim.LEFT_PANEL_MIN_WIDTH + GUIDim.RIGHT_PANEL_MIN_WIDTH, 58 setMinimumSize(new Dimension(GUIDim.LEFT_PANEL_MIN_WIDTH + GUIDim.RIGHT_PANEL_MIN_WIDTH,
53 GUIDim.BOTTOM_PANEL_MIN_HEIGHT)); 59 GUIDim.BOTTOM_PANEL_MIN_HEIGHT));
  60 +
  61 + this.add(voTableView);
54 } 62 }
55 } 63 }
src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/ServicesPanel.java
@@ -21,7 +21,6 @@ import java.awt.Dimension; @@ -21,7 +21,6 @@ import java.awt.Dimension;
21 import java.awt.event.ActionEvent; 21 import java.awt.event.ActionEvent;
22 import java.awt.event.ActionListener; 22 import java.awt.event.ActionListener;
23 23
24 -import javax.swing.BorderFactory;  
25 import javax.swing.JButton; 24 import javax.swing.JButton;
26 import javax.swing.JLabel; 25 import javax.swing.JLabel;
27 import javax.swing.JPanel; 26 import javax.swing.JPanel;
@@ -65,23 +64,17 @@ public class ServicesPanel extends JPanel { @@ -65,23 +64,17 @@ public class ServicesPanel extends JPanel {
65 this.viewListener = viewListener; 64 this.viewListener = viewListener;
66 this.voTableView = voTableView; 65 this.voTableView = voTableView;
67 66
  67 + buildServicesPanel(voTableView);
  68 + }
  69 +
  70 + private void buildServicesPanel(final VOTableView voTableView) {
68 setLayout(new BorderLayout()); 71 setLayout(new BorderLayout());
69 - this.add(voTableView, BorderLayout.NORTH);  
70 72
71 - JPanel testServicePenel = new JPanel();  
72 - testServicePenel.setBorder(BorderFactory.createTitledBorder("Test service"));  
73 - JPanel panelTemp = new JPanel();  
74 - panelTemp.add(new JLabel("Service URL"));  
75 - panelTemp.add(getServiceUrlTextField());  
76 - panelTemp.add(new JLabel("Table name"));  
77 - panelTemp.add(getTableNameTextField());  
78 - panelTemp.add(getServiceButton());  
79 - this.add(panelTemp, BorderLayout.CENTER);  
80 setPreferredSize(new Dimension(GUIDim.LEFT_PANEL_WIDTH, GUIDim.TOP_PANEL_HEIGHT)); 73 setPreferredSize(new Dimension(GUIDim.LEFT_PANEL_WIDTH, GUIDim.TOP_PANEL_HEIGHT));
81 setMinimumSize(new Dimension(GUIDim.LEFT_PANEL_MIN_WIDTH, GUIDim.TOP_PANEL_MIN_HEIGHT)); 74 setMinimumSize(new Dimension(GUIDim.LEFT_PANEL_MIN_WIDTH, GUIDim.TOP_PANEL_MIN_HEIGHT));
82 75
83 // TODO: Support multi-selection 76 // TODO: Support multi-selection
84 - this.voTableView.getTable().getSelectionModel() 77 + voTableView.getTable().getSelectionModel()
85 .addListSelectionListener(new ListSelectionListener() { 78 .addListSelectionListener(new ListSelectionListener() {
86 79
87 @Override 80 @Override
@@ -89,10 +82,24 @@ public class ServicesPanel extends JPanel { @@ -89,10 +82,24 @@ public class ServicesPanel extends JPanel {
89 viewListener.onServiceSelected(voTableView.getTable().getSelectedRow()); 82 viewListener.onServiceSelected(voTableView.getTable().getSelectedRow());
90 } 83 }
91 }); 84 });
  85 +
  86 + this.add(buildAddServicePanel(), BorderLayout.CENTER);
  87 + this.add(voTableView, BorderLayout.NORTH);
  88 + }
  89 +
  90 + private JPanel buildAddServicePanel() {
  91 + JPanel panelTemp = new JPanel();
  92 + panelTemp.add(new JLabel("Service URL"));
  93 + panelTemp.add(getServiceUrlTextField());
  94 + panelTemp.add(new JLabel("Table name"));
  95 + panelTemp.add(getTableNameTextField());
  96 + panelTemp.add(getServiceButton());
  97 +
  98 + return panelTemp;
92 } 99 }
93 100
94 /** 101 /**
95 - * 102 + * What ?
96 */ 103 */
97 private JTextField getTableNameTextField() { 104 private JTextField getTableNameTextField() {
98 if (tableNameTextField == null) { 105 if (tableNameTextField == null) {
@@ -102,7 +109,7 @@ public class ServicesPanel extends JPanel { @@ -102,7 +109,7 @@ public class ServicesPanel extends JPanel {
102 } 109 }
103 110
104 /** 111 /**
105 - * 112 + * What ?
106 */ 113 */
107 private JTextField getServiceUrlTextField() { 114 private JTextField getServiceUrlTextField() {
108 if (serviceUrlTextField == null) { 115 if (serviceUrlTextField == null) {
@@ -112,6 +119,8 @@ public class ServicesPanel extends JPanel { @@ -112,6 +119,8 @@ public class ServicesPanel extends JPanel {
112 } 119 }
113 120
114 /** 121 /**
  122 + * What ?
  123 + *
115 * @return 124 * @return
116 */ 125 */
117 private JButton getServiceButton() { 126 private JButton getServiceButton() {