Skip to content

Commit

Permalink
All fields from local BDB are selected in Raw data interface
Browse files Browse the repository at this point in the history
  • Loading branch information
akardapolov committed Apr 15, 2016
1 parent eac64b5 commit f9519ef
Show file tree
Hide file tree
Showing 2 changed files with 750 additions and 673 deletions.
145 changes: 72 additions & 73 deletions src/org/ash/gui/ASHrawdata.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.ash.database.ASHDatabase;
import org.ash.history.ASHDatabaseH;
import org.ash.util.ProgressBarUtil;
import org.jdesktop.swingx.JXTable;
import org.jfree.ui.NumberCellRenderer;
import org.joda.time.DateTime;
import org.joda.time.Period;
Expand Down Expand Up @@ -52,8 +53,8 @@ public class ASHrawdata extends JPanel {
/** The database. */
private ASHDatabaseH database;

/** The date format. */
private DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
/** The date format. */
private DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");

/**
* Constructor.
Expand All @@ -71,54 +72,54 @@ public ASHrawdata(JFrame rootFrame0, ASHDatabaseH database0, double begin, doubl

this.main = new JPanel();
this.main.setLayout(new BorderLayout());

this.add(this.main);

// Create empty panel
JPanel ashReport = new JPanel();
ashReport.setLayout(new GridLayout(1, 1, 3, 3));

// The button panel
JToolBar buttonPanel;
buttonPanel = new JToolBar("PanelButton");
buttonPanel.setFloatable(false);
buttonPanel.setBorder(new EtchedBorder());

// get ASH Report button
JButton getASHReportButton = new JButton();
getASHReportButton.setText("Get ASH raw data in table");
getASHReportButton.setPreferredSize(new Dimension(100, 30));
getASHReportButton.setActionCommand("ASHrawdata");

ButtonPlanActionListener buttonListener = new ButtonPlanActionListener(
ashReport, getASHReportButton, database, begin, end);

getASHReportButton.addActionListener(buttonListener);

// Layout of buttons
buttonPanel.add(Box.createRigidArea(new Dimension(10, 0)));
buttonPanel.add(getASHReportButton);
buttonPanel.add(Box.createRigidArea(new Dimension(10, 0)));
buttonPanel.add(new JLabel(dateFormat.format(begin)+
" <<" + getPeriod(begin,end) + ">> "+
dateFormat.format(end)
)
);
" <<" + getPeriod(begin,end) + ">> "+
dateFormat.format(end)
)
);

// Add buttonPanel, main
this.main.add(buttonPanel, BorderLayout.NORTH);
this.main.add(ashReport, BorderLayout.CENTER);
}

private class ButtonPlanActionListener implements ActionListener {
private class ButtonPlanActionListener implements ActionListener {
JPanel panelASHReport;
JButton getASHReportButton;
ASHDatabaseH database;
double begin;
double end;

public ButtonPlanActionListener(final JPanel tabsSQLPlan, final JButton getASHReportButton,
final ASHDatabaseH database, final double begin, final double end) {
public ButtonPlanActionListener(final JPanel tabsSQLPlan, final JButton getASHReportButton,
final ASHDatabaseH database, final double begin, final double end) {
super();
this.panelASHReport = tabsSQLPlan;
this.getASHReportButton = getASHReportButton;
Expand All @@ -133,79 +134,77 @@ public void actionPerformed(final ActionEvent e) {

if (str.equalsIgnoreCase("ASHrawdata")) {
getASHReport();
}
}
}

private void getASHReport() {
//Disable getASHReportButton
//getASHReportButton.setEnabled(false);
// Clear tabbedpane
JPanel panelLoading = createProgressBar("Loading, please wait...");
panelASHReport.removeAll();
panelASHReport.add(panelLoading);
Thread t = new Thread() {
@Override
public void run() {
// delay
try {
Thread.sleep(5L);
} catch (InterruptedException e) {
e.printStackTrace();
}
root.repaint();

//Disable getASHReportButton
//getASHReportButton.setEnabled(false);

// Clear tabbedpane
JPanel panelLoading = createProgressBar("Loading, please wait...");
panelASHReport.removeAll();
panelASHReport.add(panelLoading);

Thread t = new Thread() {
@Override
public void run() {
// delay
try {
Thread.sleep(5L);
} catch (InterruptedException e) {
e.printStackTrace();
}
root.repaint();

/*----------------------*/
JTable table;
DefaultTableModel model;
try {
model = database.getASHRawData(begin, end);
JXTable table;
DefaultTableModel model;
try {
model = database.getASHRawData(begin, end);

table = new JTable(model);
table = new JXTable(model);

TableColumnModel tcm = table.getColumnModel();
//tcm.getColumn(3).setCellRenderer(new NumberCellRenderer());
JPanel p = new JPanel(new BorderLayout());
//JScrollPane scroller = new JScrollPane(table);
table.setColumnControlVisible(true);
table.setHorizontalScrollEnabled(true);

JScrollPane tableRawDataPane = new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
tableRawDataPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE);
JPanel p = new JPanel(new BorderLayout());

tableRawDataPane.setViewportView(table);
tableRawDataPane.setVerticalScrollBar(tableRawDataPane.getVerticalScrollBar());
JScrollPane tableRawDataPane = new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
tableRawDataPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE);

//(JTable)componentList.get(0)
tableRawDataPane.setViewportView(table);
tableRawDataPane.setVerticalScrollBar(tableRawDataPane.getVerticalScrollBar());

p.add(tableRawDataPane);
p.setBorder(BorderFactory.createCompoundBorder(new TitledBorder(
"Selected Items: "), new EmptyBorder(4, 4, 4, 4)));
p.add(tableRawDataPane);
p.setBorder(BorderFactory.createCompoundBorder(new TitledBorder(
"Selected Items: "), new EmptyBorder(4, 4, 4, 4)));

/*----------------------*/

panelASHReport.removeAll();
panelASHReport.add(p);

root.repaint();
panelASHReport.removeAll();
panelASHReport.add(p);

} catch (DatabaseException e) {
e.printStackTrace();
}
root.repaint();


} catch (DatabaseException e) {
e.printStackTrace();
}
};
t.start();
}


}
};
t.start();
}
}

/**
* Creates the progress bar.
*
*
* @param msg the msg
*
*
* @return the j panel
*/
private JPanel createProgressBar(String msg) {
Expand All @@ -215,7 +214,7 @@ private JPanel createProgressBar(String msg) {
panel.add(progress);
return panel;
}

/**
* Get period in mm, dd, hh, ss
* @param begind
Expand All @@ -228,9 +227,9 @@ private String getPeriod(double begind, double endd){
Double endD = endd;
DateTime start = new DateTime(beginD.longValue());
DateTime end = new DateTime(endD.longValue());

Period period = new Period(start, end);

if (period.getMonths() > 0)
out = period.getMonths()+" m. ";
if (period.getDays() > 0)
Expand All @@ -241,7 +240,7 @@ private String getPeriod(double begind, double endd){
out = out + period.getMinutes()+" min. ";
if (period.getSeconds() > 0)
out = out + period.getSeconds()+" sec. ";

return out;
}

Expand Down
Loading

0 comments on commit f9519ef

Please sign in to comment.