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 65 resultsPanel = new ResultsPanel(viewListener, voTableResultsView);
66 66 requestPanel = new RequestPanel(viewListener);
67 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 99 /**
100 100 * Build and fill the GUI.
101 101 */
102   - public void buildWindow() {
  102 + private void buildMainView() {
103 103 setLayout(new BorderLayout());
104 104  
105 105 JSplitPane northPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, servicesPanel,
106 106 requestPanel);
107   -
108 107 JSplitPane mainPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, northPanel, resultsPanel);
  108 +
109 109 add(mainPanel, BorderLayout.CENTER);
110 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 109 this.viewListener = viewListener;
110 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 117 setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
  118 +
113 119 setMaximumSize(new Dimension(ParamField.MAX_FIELD_WIDTH, ParamField.FIELD_HEIGHT));
  120 +
114 121 String strLabel = paramName.replaceAll("_", " ").trim();
115 122 JLabel label = new JLabel(strLabel.substring(0, 1).toUpperCase() + strLabel.substring(1));
116 123 label.setPreferredSize(new Dimension(ParamField.LABEL_WIDTH, ParamField.FIELD_HEIGHT));
  124 +
117 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 38 /** A label to display several informations (aka. status bar). */
39 39 private JLabel infoLabel;
40 40  
  41 + private ViewListener viewListener;
  42 +
41 43  
42 44 /**
43 45 * Method constructor for the bottom bar panel.
... ... @@ -45,9 +47,19 @@ public class BottomBarPanel extends JPanel {
45 47 * @param mainView The main view of the application.
46 48 */
47 49 public BottomBarPanel(final ViewListener viewListener) {
  50 + this.viewListener = viewListener;
  51 + buildBottomBarPanel();
  52 + }
  53 +
  54 + private void buildBottomBarPanel() {
48 55 setLayout(new BorderLayout());
  56 +
49 57 infoLabel = new JLabel();
50 58 this.add(infoLabel);
  59 + this.add(buildGetFileButton(), BorderLayout.EAST);
  60 + }
  61 +
  62 + private JButton buildGetFileButton() {
51 63 JButton button = new JButton("Get File");
52 64 button.addActionListener(new ActionListener() {
53 65  
... ... @@ -58,7 +70,7 @@ public class BottomBarPanel extends JPanel {
58 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 69 */
70 70 public RequestPanel(ViewListener viewListener) {
71 71 this.viewListener = viewListener;
  72 + buildRequestPanel();
  73 + }
  74 +
  75 + private void buildRequestPanel() {
72 76 setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
  77 +
73 78 setPreferredSize(new Dimension(GUIDim.RIGHT_PANEL_WIDTH, GUIDim.TOP_PANEL_HEIGHT));
74 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 33 /** The serial version UID. */
34 34 private static final long serialVersionUID = 1L;
35 35  
  36 + ViewListener viewListener;
  37 +
36 38  
37 39 /**
38 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 45 */
44 46 public ResultsPanel(ViewListener viewListener, VOTableView voTableView) {
45 47 super();
  48 + this.viewListener = viewListener;
  49 +
  50 + buildResultPanel(voTableView);
  51 + }
46 52  
  53 + private void buildResultPanel(VOTableView voTableView) {
47 54 setLayout(new BorderLayout());
48   - this.add(voTableView);
49 55  
50 56 setPreferredSize(new Dimension(GUIDim.LEFT_PANEL_WIDTH + GUIDim.RIGHT_PANEL_WIDTH,
51 57 GUIDim.BOTTOM_PANEL_HEIGHT));
52 58 setMinimumSize(new Dimension(GUIDim.LEFT_PANEL_MIN_WIDTH + GUIDim.RIGHT_PANEL_MIN_WIDTH,
53 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 21 import java.awt.event.ActionEvent;
22 22 import java.awt.event.ActionListener;
23 23  
24   -import javax.swing.BorderFactory;
25 24 import javax.swing.JButton;
26 25 import javax.swing.JLabel;
27 26 import javax.swing.JPanel;
... ... @@ -65,23 +64,17 @@ public class ServicesPanel extends JPanel {
65 64 this.viewListener = viewListener;
66 65 this.voTableView = voTableView;
67 66  
  67 + buildServicesPanel(voTableView);
  68 + }
  69 +
  70 + private void buildServicesPanel(final VOTableView voTableView) {
68 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 73 setPreferredSize(new Dimension(GUIDim.LEFT_PANEL_WIDTH, GUIDim.TOP_PANEL_HEIGHT));
81 74 setMinimumSize(new Dimension(GUIDim.LEFT_PANEL_MIN_WIDTH, GUIDim.TOP_PANEL_MIN_HEIGHT));
82 75  
83 76 // TODO: Support multi-selection
84   - this.voTableView.getTable().getSelectionModel()
  77 + voTableView.getTable().getSelectionModel()
85 78 .addListSelectionListener(new ListSelectionListener() {
86 79  
87 80 @Override
... ... @@ -89,10 +82,24 @@ public class ServicesPanel extends JPanel {
89 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 104 private JTextField getTableNameTextField() {
98 105 if (tableNameTextField == null) {
... ... @@ -102,7 +109,7 @@ public class ServicesPanel extends JPanel {
102 109 }
103 110  
104 111 /**
105   - *
  112 + * What ?
106 113 */
107 114 private JTextField getServiceUrlTextField() {
108 115 if (serviceUrlTextField == null) {
... ... @@ -112,6 +119,8 @@ public class ServicesPanel extends JPanel {
112 119 }
113 120  
114 121 /**
  122 + * What ?
  123 + *
115 124 * @return
116 125 */
117 126 private JButton getServiceButton() {
... ...