|
From: <and...@us...> - 2017-06-28 19:09:40
|
Revision: 1463
http://sourceforge.net/p/ggc/code/1463
Author: andyrozman
Date: 2017-06-28 19:09:37 +0000 (Wed, 28 Jun 2017)
Log Message:
-----------
0.3.1 [26.6.2017]
- created new project under maven
- moved files from desktop module
- refactoring a little
Modified Paths:
--------------
trunk/ggc-desktop-app/ggc-desktop-little/pom.xml
trunk/ggc-desktop-app/ggc-desktop-little/src/main/java/ggc/gui/little/GGCLittle.java
trunk/ggc-desktop-app/ggc-desktop-little/src/main/java/ggc/gui/little/StatusBarL.java
trunk/ggc-desktop-app/ggc-desktop-little/src/main/java/ggc/gui/little/panels/DailyStatsControlsL.java
trunk/ggc-desktop-app/ggc-desktop-little/src/main/java/ggc/gui/little/panels/DailyStatsPanelL.java
trunk/ggc-desktop-app/ggc-desktop-little/src/main/java/ggc/gui/little/panels/GeneralInfoPanelL.java
trunk/ggc-desktop-app/ggc-desktop-little/src/main/java/ggc/gui/little/panels/MainLittlePanel.java
trunk/ggc-desktop-app/ggc-desktop-little/src/main/java/ggc/gui/little/panels/PlugInMeterPanelL.java
trunk/ggc-desktop-app/ggc-desktop-little/src/main/java/ggc/gui/little/panels/PlugInPumpPanelL.java
trunk/ggc-desktop-app/ggc-desktop-little/src/main/java/ggc/gui/little/panels/ScheduleInfoPanelL.java
trunk/ggc-desktop-app/ggc-desktop-little/src/main/java/ggc/gui/little/panels/StocksInfoPanelL.java
Added Paths:
-----------
trunk/ggc-desktop-app/ggc-desktop-little/docs/Changelog
trunk/ggc-desktop-app/ggc-desktop-little/src/main/java/ggc/
trunk/ggc-desktop-app/ggc-desktop-little/src/main/java/ggc/gui/
trunk/ggc-desktop-app/ggc-desktop-little/src/main/java/ggc/gui/little/
trunk/ggc-desktop-app/ggc-desktop-little/src/main/java/ggc/gui/little/data/
trunk/ggc-desktop-app/ggc-desktop-little/src/main/java/ggc/gui/little/data/DailyStatsTableLittleModel.java
trunk/ggc-desktop-app/ggc-desktop-little/src/main/java/ggc/gui/little/panels/DailyStatsListPanelL.java
trunk/ggc-desktop-app/ggc-desktop-little/src/main/templates/
trunk/ggc-desktop-app/ggc-desktop-little/src/main/templates/Version.java.template
Removed Paths:
-------------
trunk/ggc-desktop-app/ggc-desktop/src/main/java/ggc/gui/little/
Added: trunk/ggc-desktop-app/ggc-desktop-little/docs/Changelog
===================================================================
--- trunk/ggc-desktop-app/ggc-desktop-little/docs/Changelog (rev 0)
+++ trunk/ggc-desktop-app/ggc-desktop-little/docs/Changelog 2017-06-28 19:09:37 UTC (rev 1463)
@@ -0,0 +1,12 @@
+
+Changes for Desktop Little
+===========================
+
+0.3.1 [26.6.2017]
+- created new project under maven
+- moved files from desktop module
+- refactoring a little
+
+
+0.3.0
+- before changes
\ No newline at end of file
Modified: trunk/ggc-desktop-app/ggc-desktop-little/pom.xml
===================================================================
--- trunk/ggc-desktop-app/ggc-desktop-little/pom.xml 2017-06-28 19:00:28 UTC (rev 1462)
+++ trunk/ggc-desktop-app/ggc-desktop-little/pom.xml 2017-06-28 19:09:37 UTC (rev 1463)
@@ -11,34 +11,39 @@
<name>GGC Desktop - Little</name>
<description>GGC Little (Version of GGC that could always run in background)</description>
<artifactId>ggc-desktop-little</artifactId>
- <version>0.1-SNAPSHOT</version>
+ <version>${ggc-desktop-little.version}</version>
+
+
<build>
- <directory>target</directory>
- <outputDirectory>target/classes</outputDirectory>
- <finalName>${project.artifactId}-${project.version}</finalName>
- <testOutputDirectory>target/test-classes</testOutputDirectory>
- <sourceDirectory>src/main/java</sourceDirectory>
- <!-- <scriptSourceDirectory>src/main/scripts</scriptSourceDirectory> -->
+ <plugins>
+ <plugin>
+ <groupId>com.google.code.maven-replacer-plugin</groupId>
+ <artifactId>maven-replacer-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${project.build.directory}/generated-sources/ggc/gui/little/data/</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
- <testSourceDirectory>src/test/java</testSourceDirectory>
- <resources>
- <resource>
- <directory>src</directory>
- <filtering>true</filtering>
- <excludes>
- <exclude>**/*.java</exclude>
- </excludes>
- </resource>
- </resources>
- <testResources>
- <testResource>
- <directory>src/test/resources</directory>
- </testResource>
- </testResources>
+ </plugins>
</build>
+
<dependencies>
<dependency>
<groupId>net.sf.ggc</groupId>
@@ -72,10 +77,9 @@
</dependencies>
<properties>
-
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
-
+ <version.file>
+ ${project.build.directory}/generated-sources/ggc/gui/little/data/Version.java
+ </version.file>
</properties>
</project>
Modified: trunk/ggc-desktop-app/ggc-desktop-little/src/main/java/ggc/gui/little/GGCLittle.java
===================================================================
--- trunk/ggc-desktop-app/ggc-desktop/src/main/java/ggc/gui/little/GGCLittle.java 2016-12-26 14:02:38 UTC (rev 1456)
+++ trunk/ggc-desktop-app/ggc-desktop-little/src/main/java/ggc/gui/little/GGCLittle.java 2017-06-28 19:09:37 UTC (rev 1463)
@@ -1,34 +1,35 @@
package ggc.gui.little;
import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
+import java.awt.event.*;
import java.text.SimpleDateFormat;
import java.util.GregorianCalendar;
import java.util.Hashtable;
+import java.util.Map;
+import java.util.Observable;
-import javax.help.CSH;
-import javax.help.HelpBroker;
-import javax.help.HelpSet;
-import javax.help.HelpSetException;
import javax.swing.*;
-import com.atech.help.HelpContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.atech.graphics.observe.EventObserverInterface;
import com.atech.i18n.I18nControlAbstract;
import com.atech.utils.ATSwingUtils;
-import com.l2fprod.gui.plaf.skin.SkinLookAndFeel;
+import com.atech.utils.java.VersionResolver;
import ggc.core.data.DailyValuesRow;
+import ggc.core.data.defs.DatabaseStatusType;
+import ggc.core.data.defs.GGCObservableType;
+import ggc.core.data.defs.RefreshInfoType;
import ggc.core.db.GGCDb;
+import ggc.core.gui.GGCGuiHelper;
+import ggc.core.plugins.GGCPluginType;
import ggc.core.util.DataAccess;
import ggc.gui.dialogs.AboutGGCDialog;
-import ggc.gui.little.panels.DailyStatsPanelL;
+import ggc.gui.little.panels.DailyStatsListPanelL;
import ggc.gui.little.panels.MainLittlePanel;
+import ggc.gui.main.StatusBar;
import ggc.gui.pen.DailyRowDialog;
/**
@@ -58,22 +59,26 @@
* Author: andyrozman {an...@at...}
*/
-public class GGCLittle extends JFrame implements WindowListener, ActionListener
+public class GGCLittle extends JFrame implements ActionListener, EventObserverInterface
{
private static final long serialVersionUID = -7744922647111948669L;
- private I18nControlAbstract m_ic = null; // I18nControl.getInstance();
- private DataAccess m_da = null;
+ private static Logger LOG = LoggerFactory.getLogger(GGCLittle.class);
+
+ private GGCGuiHelper guiHelper; // = new GGCGuiHelper(LOG);
+
+ private I18nControlAbstract i18nControl = null; // I18nControl.getInstance();
+ private DataAccess dataAccess = null;
private GGCDb m_db = null;
- private static SkinLookAndFeel s_skinlf;
- private static final String skinLFdir = "../data/skinlf_themes/";
- private Hashtable<String, GGCAction> actions = null;
+ // private static SkinLookAndFeel s_skinlf;
+ // private static final String skinLFdir = "../data/skinlf_themes/";
+ private Map<String, JMenuItem> actions = null;
// GUI
private MainLittlePanel informationPanel = null;
- private StatusBarL statusPanel;
- private DailyStatsPanelL dailyStats = null;
+ private StatusBar statusPanel;
+ private DailyStatsListPanelL dailyStats = null;
// fields
private JToolBar toolBar = new JToolBar();
@@ -87,56 +92,18 @@
String ggc_little_version = "v0.2.3";
-
/**
* Static definitions (Look and Feel)
*/
static
{
- GGCLittle.setLookAndFeel(); // Win (not so bad) ???
+ GGCGuiHelper.setLog(LOG);
+ GGCGuiHelper.setLookAndFeel();
+ DataAccess.getSkinManager().setSkinLfOverrides(GGCGuiHelper.getSkinLfOverrides());
}
/**
- * Set Look And Feel
- */
- public static void setLookAndFeel()
- {
-
- try
- {
-
- String data[] = DataAccess.getLFData();
-
- if (data == null)
- return;
- else
- {
- if (data[0].equals("com.l2fprod.gui.plaf.skin.SkinLookAndFeel"))
- {
- SkinLookAndFeel.setSkin(SkinLookAndFeel.loadThemePack(skinLFdir + data[1]));
-
- s_skinlf = new com.l2fprod.gui.plaf.skin.SkinLookAndFeel();
- UIManager.setLookAndFeel(s_skinlf);
- }
- else
- {
- UIManager.setLookAndFeel(data[0]);
- }
-
- JFrame.setDefaultLookAndFeelDecorated(true);
- JDialog.setDefaultLookAndFeelDecorated(true);
- }
- }
- catch (Exception ex)
- {
- System.err.println("Error loading L&F: " + ex);
- }
-
- }
-
-
- /**
* Constructor
*
* @param developer_version
@@ -143,21 +110,35 @@
*/
public GGCLittle(boolean developer_version)
{
- m_da = DataAccess.createInstance(this);
- m_ic = m_da.getI18nControlInstance();
- m_db = m_da.getDb();
+ dataAccess = DataAccess.createInstance(this);
+ i18nControl = dataAccess.getI18nControlInstance();
+ m_db = dataAccess.getDb();
- this.actions = new Hashtable<String, GGCAction>();
+ guiHelper = new GGCGuiHelper();
+ guiHelper.setDataAccess(dataAccess);
- statusPanel = new StatusBarL(this);
+ this.actions = new Hashtable<String, JMenuItem>();
- String title = m_ic.getMessage("GGC_LITTLE_TITLE");
+ statusPanel = new StatusBar();
+ String title = i18nControl.getMessage("GGC_LITTLE_TITLE");
+
+ ggc_little_version = "v"
+ + VersionResolver.getVersion("ggc.gui.little.data.Version", this.getClass().getSimpleName());
+
setTitle(title + " (" + ggc_little_version + ")");
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
- addWindowListener(this);
+ addWindowListener(new WindowAdapter()
+ {
+ @Override
+ public void windowClosing(WindowEvent e)
+ {
+ close();
+ }
+ });
+
createToolbar();
createSystemTrayInstance();
@@ -170,13 +151,19 @@
getContentPane().add(toolBar, BorderLayout.NORTH);
getContentPane().add(statusPanel, BorderLayout.SOUTH);
- helpInit();
+ guiHelper.helpInit();
+ guiHelper.setApplicationIcon(this);
+ dataAccess.getObserverManager().addObserver(GGCObservableType.Status, this);
+ dataAccess.getObserverManager().addObserver(GGCObservableType.Database, this);
+
// dataAccess.addObserver(observable_id, inst)
- m_da.startDb(); // statusPanel);
+ dataAccess.getObserverManager().startToObserve();
+
+ dataAccess.startDb(); // statusPanel);
setDbActions(false);
- statusPanel.setStatusMessage(m_ic.getMessage("INIT"));
+ statusPanel.setStatusMessage(i18nControl.getMessage("INIT"));
// dayData = DataAccess.getInstance().getDayStats(new
// GregorianCalendar());
@@ -187,12 +174,37 @@
dailyStats = informationPanel.dailyStats;
getContentPane().add(informationPanel, BorderLayout.CENTER);
- setSize(640, 480);
- this.setResizable(false);
+ this.setBounds(100, 100, 800, 600);
+
+ this.getRootPane().addComponentListener(new ComponentAdapter()
+ {
+
+ public void componentResized(ComponentEvent e)
+ {
+ // This is only called when the user releases the mouse button.
+ resizeEvent();
+ }
+ });
+
+ // this.setResizable(false);
this.setVisible(true);
}
+ private void resizeEvent()
+ {
+ double x = this.getBounds().getWidth() - 360;
+
+ emptyLabelBeforeHelp.setSize((int) x, 30);
+ emptyLabelBeforeHelp.setPreferredSize(new Dimension((int) x, 30));
+
+ // emptyLabelBeforeHelp.getWidth()
+ System.out.println("componentResized [" + this.getBounds().getWidth());
+ }
+
+ JLabel emptyLabelBeforeHelp;
+
+
private void createToolbar()
{
@@ -202,19 +214,19 @@
JLabel label_empty = new JLabel("");
label_empty.setPreferredSize(new Dimension(40, 20));
- this.toolBar.add(getEmptyLabel(10, 20));
+ this.toolBar.add(guiHelper.getEmptyLabel(10, 20));
- createToolbarAction("MN_QUIT", "MN_QUIT_LT_DESC", "quit", "exit.png");
+ createToolbarButton("MN_QUIT", "MN_QUIT_LT_DESC", "quit", "exit.png");
- this.toolBar.add(getEmptyLabel(30, 20));
+ this.toolBar.add(guiHelper.getEmptyLabel(30, 20));
- createToolbarAction("TB_ADD_ROW", "TB_ADD_ROW_DESC", "add_entry", "table_add.png");
- createToolbarAction("TB_EDIT_ROW", "TB_EDIT_ROW_DESC", "edit_entry", "table_edit.png");
- createToolbarAction("TB_DELETE_ROW", "TB_DELETE_ROW_DESC", "delete_entry", "table_delete.png");
+ createToolbarButton("TB_ADD_ROW", "TB_ADD_ROW_DESC", "add_entry", "table_add.png");
+ createToolbarButton("TB_EDIT_ROW", "TB_EDIT_ROW_DESC", "edit_entry", "table_edit.png");
+ createToolbarButton("TB_DELETE_ROW", "TB_DELETE_ROW_DESC", "delete_entry", "table_delete.png");
- this.toolBar.add(getEmptyLabel(30, 20));
+ this.toolBar.add(guiHelper.getEmptyLabel(30, 20));
- createToolbarAction("TB_SHOW_GRAPH", "TB_SHOW_GRAPH_DESC", "show_graph", "line-chart.png");
+ createToolbarButton("TB_SHOW_GRAPH", "TB_SHOW_GRAPH_DESC", "show_graph", "line-chart.png");
// this.toolBar.add(getEmptyLabel(30,20));
@@ -221,9 +233,10 @@
// createToolbarAction("MN_FROM_METER", "TB_READ_METER_LT_DESC",
// "read_meter", "readmeter.gif");
- this.toolBar.add(getEmptyLabel(360, 20));
+ this.toolBar.add(emptyLabelBeforeHelp = guiHelper.getEmptyLabel(430, 20));
- createToolbarAction("MN_ABOUT", "TB_ABOUT_DESC", "hlp_about", "about.png");
+ createToolbarButton("MN_HELP", "TB_HELP_DESC", "hlp_help", "help.png");
+ createToolbarButton("MN_ABOUT", "TB_ABOUT_DESC", "hlp_about", "about.png");
// this.actions.get("read_meter").setEnabled(false);
@@ -268,7 +281,6 @@
}
-
/*
* private JMenuItem createItem(String name, String desc, String action) {
* JMenuItem item = new JMenuItem(i18nControl.getMessage(name));
@@ -279,15 +291,15 @@
* return item; }
*/
- /**
- * Get Status Panel
- *
- * @return
- */
- public StatusBarL getStatusPanel()
- {
- return this.statusPanel;
- }
+ // /**
+ // * Get Status Panel
+ // *
+ // * @return
+ // */
+ // public StatusBarL getStatusPanel()
+ // {
+ // return this.statusPanel;
+ // }
/**
@@ -301,30 +313,43 @@
}
- private JLabel getEmptyLabel(int width, int height)
+ private void createToolbarButton(String name, String toolTip, String actionCommand, String iconSmall
+ /* , GGCToolbarType toolbarType */)
{
- JLabel label_empty = new JLabel("");
- label_empty.setPreferredSize(new Dimension(width, height));
- return label_empty;
+ JButton button = new JButton();
+ button.setName(i18nControl.getMessageWithoutMnemonic(name));
- }
+ if (toolTip != null)
+ {
+ button.setToolTipText(i18nControl.getMessage(toolTip));
+ }
+ if (actionCommand != null)
+ {
+ button.setActionCommand(actionCommand);
+ }
- private void createToolbarAction(String name, String tip, String action_command, String icon_small)
- {
- GGCAction action = new GGCAction(name, tip, action_command);
-
- if (icon_small != null)
+ if (iconSmall != null)
{
- action.putValue(Action.SMALL_ICON, ATSwingUtils.getImageIcon(icon_small, 24, 24, this, m_da));
+ button.setIcon(ATSwingUtils.getImageIcon(iconSmall, 28, 28, this, dataAccess));
}
- // this.toolBar.add(action);
- this.actions.put(action_command, action);
+ button.addActionListener(this);
- addToolBarButton(action);
+ // this.toolbarItems.get(toolbarType).put(actionCommand, button);
+ // this.toolbars.get(toolbarType).add(button);
+ toolBar.add(button);
+
+ button.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
+ button.setFocusPainted(false);
+ button.setPreferredSize(new Dimension(32, 32));
+
+ // this.toolbars.get(toolbarType).add(button);
+
+ // this.actions.put(action_command, action);
+
}
@@ -354,7 +379,7 @@
{
// write to prefs to file on close.
// props.write();
- m_da.getDb().closeDb();
+ dataAccess.getDb().closeDb();
// s_dbH.disconnectDb();
dispose();
System.exit(0);
@@ -361,425 +386,233 @@
}
- /*
- * private JMenuItem addMenuItem(JMenu menu, Action action) { JMenuItem item
- * = menu.add(action);
- * KeyStroke keystroke = (KeyStroke)action.getCode(Action.ACCELERATOR_KEY);
- * if (keystroke != null) item.setAccelerator(keystroke); return item; }
- */
- /*
- * private void addToolBarSpacer() { toolBar.addSeparator(); }
- */
-
- private JButton addToolBarButton(Action action)
+ private boolean checkDateSame()
{
- final JButton button = toolBar.add(action);
+ if (m_db == null)
+ {
+ this.m_db = dataAccess.getDb();
+ }
- button.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
- button.setFocusPainted(false);
+ if (!dataAccess.isSameDay(this.gc_current, new GregorianCalendar()))
+ {
+ // not same date
+ JOptionPane.showMessageDialog(getMyParent(), i18nControl.getMessage("CURRENT_DATE_HAS_CHANGED"),
+ i18nControl.getMessage("ERROR"), JOptionPane.ERROR_MESSAGE);
- button.setPreferredSize(new Dimension(28, 28));
+ this.dailyStats.refreshInfo();
- // button.setIcon((ImageIcon)action.getCode(Action.SMALL_ICON));
- /*
- * button.addMouseListener(new MouseListener() { public void
- * mouseEntered(MouseEvent e) { if (button.isEnabled()) {
- * button.setBorder(BorderFactory.createLineBorder(new Color(8, 36,
- * 106), 1)); button.setBackground(new Color(180, 190, 213)); }
- * }
- * public void mouseExited(MouseEvent e) {
- * button.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
- * button.setBackground(new Color(213, 210, 205)); }
- * public void mouseClicked(MouseEvent e) { }
- * public void mousePressed(MouseEvent e) { }
- * public void mouseReleased(MouseEvent e) { }
- * });
- */
+ return false;
+ }
+ else
+ return true;
- // button.setRolloverIcon(new ImageIcon("ggc/icons/connect.png"));
- // button.setRolloverEnabled(true);
- return button;
}
- class GGCAction extends AbstractAction
+
+ /**
+ * actionPerformed
+ */
+ public void actionPerformed(ActionEvent e)
{
- // private String command = null;
- /**
- *
- */
- private static final long serialVersionUID = 5381628629001707536L;
+ // FIXME add/edit/delete for both types
+ String actionCommand = e.getActionCommand();
- GGCAction(String name, String command)
+ if (actionCommand.equals("show_app"))
{
- super();
- setName(m_ic.getMessageWithoutMnemonic(name));
-
- putValue(Action.NAME, m_ic.getMessageWithoutMnemonic(name));
-
- char ch = m_ic.getMnemonic(name);
-
- if (ch != '0')
+ if (is_visible)
{
- putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(ch, Event.CTRL_MASK));
+ this.toFront();
}
-
- if (command != null)
+ else
{
- putValue(ACTION_COMMAND_KEY, command);
+ this.setVisible(true);
}
+ }
+ else if (actionCommand.equals("hide_app"))
+ {
+ is_visible = false;
+ this.setVisible(false);
- command = name;
}
-
-
- /*
- * GGCAction(String name, KeyStroke keystroke) { this();
- * setName(i18nControl.getMessageWithoutMnemonic(name)); if (keystroke
- * != null)
- * putValue(ACCELERATOR_KEY, keystroke); }
- */
- GGCAction(String name, String tooltip, String command)
+ else if (actionCommand.equals("exit_app"))
{
- super();
- setName(m_ic.getMessageWithoutMnemonic(name));
+ close();
+ }
+ else if (actionCommand.equals("quit"))
+ {
+ close();
+ }
+ else if (actionCommand.equals("add_entry"))
+ {
+ if (checkIfPumpAndDisplayError("Adding entry"))
+ {
+ return;
+ }
- putValue(Action.NAME, m_ic.getMessageWithoutMnemonic(name));
+ checkDateSame();
- char ch = m_ic.getMnemonic(name);
+ SimpleDateFormat sf = new SimpleDateFormat("dd.MM.yyyy");
- if (ch != '0')
- {
- putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(ch, Event.CTRL_MASK));
- }
+ DailyRowDialog aRF = new DailyRowDialog(dailyStats.getDayData(), sf.format(gc_current.getTime()),
+ getMyParent());
- if (tooltip != null)
+ if (aRF.actionSuccessful())
{
- putValue(SHORT_DESCRIPTION, m_ic.getMessage(tooltip));
- }
+ System.out.println("m_db:" + m_db);
+ System.out.println("dailyStats.dayData:" + dailyStats.getDayData());
- if (command != null)
- {
- putValue(ACTION_COMMAND_KEY, command);
+ m_db.saveDayStats(dailyStats.getDayData());
+ dailyStats.getTableModel().fireTableChanged(null);
+ // this.model.fireTableChanged(null);
}
- }
+ // DailyValues dv = getDayData();
+ //
+ // DailyRowDialog aRF = new DailyRowDialog(dv,
+ // dataAccess.getCurrentDateString(), getFrame());
+ //
+ // if (aRF.actionSuccessful())
+ // {
+ // dataAccess.getDb().saveDayStats(dv);
+ // reloadTable();
+ // }
- /*
- * GGCAction(String name, KeyStroke keystroke, String tooltip) {
- * this(name, keystroke); if (tooltip != null)
- * putValue(SHORT_DESCRIPTION, tooltip); }
- */
-
- public void actionPerformed(ActionEvent e)
+ }
+ else if (actionCommand.equals("edit_entry"))
{
- String command = e.getActionCommand();
-
- if (command.equals("quit"))
+ if (checkIfPumpAndDisplayError("Edit entry"))
{
- close();
+ return;
}
- else if (command.equals("add_entry"))
- {
- checkDateSame();
- SimpleDateFormat sf = new SimpleDateFormat("dd.MM.yyyy");
+ checkDateSame();
- DailyRowDialog aRF = new DailyRowDialog(dailyStats.getDayData(), sf.format(gc_current.getTime()),
- getMyParent());
-
- if (aRF.actionSuccessful())
- {
- System.out.println("m_db:" + m_db);
- System.out.println("dailyStats.dayData:" + dailyStats.getDayData());
-
- m_db.saveDayStats(dailyStats.getDayData());
- dailyStats.getTableModel().fireTableChanged(null);
- // this.model.fireTableChanged(null);
- }
- }
- else if (command.equals("edit_entry"))
+ if (dailyStats.getTable().getSelectedRow() == -1)
{
- checkDateSame();
-
- if (dailyStats.getTable().getSelectedRow() == -1)
- {
- JOptionPane.showMessageDialog(getMyParent(), m_ic.getMessage("SELECT_ROW_FIRST"),
- m_ic.getMessage("ERROR"), JOptionPane.ERROR_MESSAGE);
- return;
- }
-
- DailyValuesRow dvr = dailyStats.getDayData().getRow(dailyStats.getTable().getSelectedRow());
-
- DailyRowDialog aRF = new DailyRowDialog(dvr, getMyParent());
-
- if (aRF.actionSuccessful())
- {
- m_db.saveDayStats(dailyStats.getDayData());
- dailyStats.getTableModel().fireTableChanged(null);
- }
-
+ JOptionPane.showMessageDialog(getMyParent(), i18nControl.getMessage("SELECT_ROW_FIRST"),
+ i18nControl.getMessage("ERROR"), JOptionPane.ERROR_MESSAGE);
+ return;
}
- else if (command.equals("delete_entry"))
- {
- checkDateSame();
- if (dailyStats.getTable().getSelectedRow() == -1)
- {
- JOptionPane.showMessageDialog(getMyParent(), m_ic.getMessage("SELECT_ROW_FIRST"),
- m_ic.getMessage("ERROR"), JOptionPane.ERROR_MESSAGE);
- return;
- }
+ DailyValuesRow dvr = dailyStats.getDayData().getRow(dailyStats.getTable().getSelectedRow());
- int option_selected = JOptionPane.showOptionDialog(getMyParent(),
- m_ic.getMessage("ARE_YOU_SURE_DELETE_ROW"), m_ic.getMessage("QUESTION"), JOptionPane.YES_NO_OPTION,
- JOptionPane.QUESTION_MESSAGE, null, m_da.options_yes_no, JOptionPane.YES_OPTION);
+ DailyRowDialog aRF = new DailyRowDialog(dvr, getMyParent());
- if (option_selected == JOptionPane.NO_OPTION)
- return;
-
- try
- {
- dailyStats.getDayData().deleteRow(dailyStats.getTable().getSelectedRow());
- dailyStats.getTableModel().fireTableChanged(null);
- m_db.saveDayStats(dailyStats.getDayData());
- }
- catch (Exception ex)
- {
- System.out.println("DailyStatsDialog:Action:Delete Row: " + ex);
- // log.error("Action::Delete Row::Exception: " + ex, ex);
- }
- }
- else if (command.equals("show_graph"))
+ if (aRF.actionSuccessful())
{
- // DailyGraphDialog dgd = new DailyGraphDialog(getMyParent(),
- // dailyStats.getDayData());
- // dgd.setDailyValues(dailyStats.getDayData());
+ m_db.saveDayStats(dailyStats.getDayData());
+ dailyStats.getTableModel().fireTableChanged(null);
}
- else if (command.equals("read_meter"))
- {
- // ReadMeterDialog.showMe(MainFrame.this);
- }
- else if (command.equals("hlp_about"))
- {
- // FIX This
- new AboutGGCDialog(getMyParent());
- // JOptionPane.showMessageDialog(null,
- // "GNU Gluco Control v0.0.1", "About GGC",
- // JOptionPane.INFORMATION_MESSAGE);
- }
- else
- {
- System.out.println("GGCLittle:Unknown Command: " + command);
- }
}
- }
-
-
- /**
- * Help Init
- */
- public void helpInit()
- {
- // TODO fix this
- HelpContext hc = new HelpContext("../data/help/GGC.hs");
-
- m_da.setHelpContext(hc);
-
- JMenuItem helpItem = new JMenuItem(m_ic.getMessage("HELP") + "...");
- helpItem.setIcon(new ImageIcon(getClass().getResource("/icons/help.gif")));
-
- hc.setHelpItem(helpItem);
-
- String mainHelpSetName = "../data/help/GGC.hs";
- mainHelpSetName = mainHelpSetName.replace("/", File.separator);
-
- hc.setMainHelpSetName(mainHelpSetName);
-
- // try to find the helpset and create a HelpBroker object
- if (hc.getMainHelpBroker() == null)
+ else if (actionCommand.equals("delete_entry"))
{
+ if (checkIfPumpAndDisplayError("Delete entry"))
+ {
+ return;
+ }
- // System.out.println("Help init broker");
+ checkDateSame();
- HelpSet main_help_set = null;
- // HelpContext.mainHelpSet = null;
+ if (dailyStats.getTable().getSelectedRow() == -1)
+ {
+ JOptionPane.showMessageDialog(getMyParent(), i18nControl.getMessage("SELECT_ROW_FIRST"),
+ i18nControl.getMessage("ERROR"), JOptionPane.ERROR_MESSAGE);
+ return;
+ }
- // ClassLoader cl = MainFrame.class.getClassLoader();
- // String help_url = "jar:file:pis_lang-0.1.jar!/help/PIS.hs";
+ int option_selected = JOptionPane.showOptionDialog(getMyParent(),
+ i18nControl.getMessage("ARE_YOU_SURE_DELETE_ROW"), i18nControl.getMessage("QUESTION"),
+ JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, dataAccess.options_yes_no,
+ JOptionPane.YES_OPTION);
- String help_url = "jar:file:ggc_help-0.1.jar!/help/en/GGC.hs";
+ if (option_selected == JOptionPane.NO_OPTION)
+ return;
try
{
- URL hsURL = new URL(help_url);
-
- /*
- * if (hsURL == null)
- * System.out.println("HelpSet " + help_url /*
- * PISMain.mainHelpSetName
- */// + " not found.");
- // else */
- main_help_set = new HelpSet(null, hsURL);
+ dailyStats.getDayData().deleteRow(dailyStats.getTable().getSelectedRow());
+ dailyStats.getTableModel().fireTableChanged(null);
+ m_db.saveDayStats(dailyStats.getDayData());
}
- catch (HelpSetException ee)
+ catch (Exception ex)
{
- System.out.println("HelpSet " + help_url + " could not be opened.");
- System.out.println(ee.getMessage());
+ System.out.println("DailyStatsDialog:Action:Delete Row: " + ex);
+ // log.error("Action::Delete Row::Exception: " + ex, ex);
}
- catch (MalformedURLException ee)
+ }
+ else if (actionCommand.equals("show_graph"))
+ {
+ showFunctionalityNotAvailableYet("Show daily graph");
+ // DailyGraphDialog dgd = new DailyGraphDialog(getMyParent(),
+ // dailyStats.getDayData());
+ // dgd.setDailyValues(dailyStats.getDayData());
+ }
+ else if (actionCommand.equals("read_meter"))
+ {
+ executePluginAction(GGCPluginType.MeterToolPlugin, e, "meters_read");
+ }
+ else if (actionCommand.equals("read_pump"))
+ {
+ if (dataAccess.isPluginAvailable(GGCPluginType.MeterToolPlugin))
{
- System.out.println("Problem with HelpSet path: " + help_url + "\n" + ee);
+ dataAccess.getPlugIn(GGCPluginType.MeterToolPlugin)
+ .actionPerformed(new ActionEvent(this, e.getID() + 1, "meters_read"));
}
- HelpBroker main_help_broker = null;
-
- if (main_help_set != null)
- {
- // System.out.println("Help: Main Help Set present, creating
- // broker");
- main_help_broker = main_help_set.createHelpBroker();
- }
-
- CSH.DisplayHelpFromSource csh = null;
-
- if (main_help_broker != null)
- {
- // CSH.DisplayHelpFromSource is a convenience class to display
- // the helpset
- csh = new CSH.DisplayHelpFromSource(main_help_broker);
-
- if (csh != null)
- {
- // listen to ActionEvents from the helpItem
- hc.getHelpItem().addActionListener(csh);
- }
- }
-
- hc.setDisplayHelpFromSourceInstance(csh);
- hc.setMainHelpBroker(main_help_broker);
- hc.setMainHelpSet(main_help_set);
-
- CSH.trackCSEvents();
-
+ showFunctionalityNotAvailableYet("Read Pump");
+ // ReadMeterDialog.showMe(MainFrame.this);
}
-
- }
-
-
- private boolean checkDateSame()
- {
- if (m_db == null)
+ else if (actionCommand.equals("read_cgms"))
{
- this.m_db = m_da.getDb();
+ showFunctionalityNotAvailableYet("Read CGMS");
+ // ReadMeterDialog.showMe(MainFrame.this);
}
-
- if (!m_da.isSameDay(this.gc_current, new GregorianCalendar()))
+ else if (actionCommand.equals("hlp_about"))
{
- // not same date
- JOptionPane.showMessageDialog(getMyParent(), m_ic.getMessage("CURRENT_DATE_HAS_CHANGED"),
- m_ic.getMessage("ERROR"), JOptionPane.ERROR_MESSAGE);
-
- this.dailyStats.refreshInfo();
-
- return false;
+ // FIX This
+ new AboutGGCDialog(getMyParent());
+ // JOptionPane.showMessageDialog(null,
+ // "GNU Gluco Control v0.0.1", "About GGC",
+ // JOptionPane.INFORMATION_MESSAGE);
}
else
- return true;
+ {
+ System.out.println("GGCLittle:Unknown Command: " + actionCommand);
+ }
}
- // Window Listener
-
- /**
- */
- public void windowDeactivated(WindowEvent e)
+ private void executePluginAction(GGCPluginType pluginType, ActionEvent e, String actionCommand)
{
- }
+ if (dataAccess.isPluginAvailable(pluginType))
+ {
+ dataAccess.getPlugIn(pluginType).actionPerformed(new ActionEvent(this, e.getID(), actionCommand));
+ }
-
- /**
- */
- public void windowActivated(java.awt.event.WindowEvent e)
- {
}
- /**
- */
- public void windowDeiconified(java.awt.event.WindowEvent e)
+ private void showFunctionalityNotAvailableYet(String functionality)
{
+ dataAccess.showMessageDialog(this, ATSwingUtils.DialogType.Error,
+ functionality + " is not working in this application yet. Please use full version of GGC instead.");
}
- /**
- */
- public void windowIconified(java.awt.event.WindowEvent e)
+ private boolean checkIfPumpAndDisplayError(String errorDescriptionTarget)
{
- }
-
-
- /**
- */
- public void windowClosed(java.awt.event.WindowEvent e)
- {
- }
-
-
- /**
- */
- public void windowOpened(java.awt.event.WindowEvent e)
- {
- }
-
-
- /**
- * Window Closing Event
- * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)
- */
- public void windowClosing(WindowEvent e)
- {
- close();
- }
-
-
- /**
- * actionPerformed
- */
- public void actionPerformed(ActionEvent e)
- {
-
- String action = e.getActionCommand();
-
- if (action.equals("show_app"))
+ if (dataAccess.isPumpMode())
{
- if (is_visible)
- {
- this.toFront();
- }
- else
- {
- this.setVisible(true);
- }
+ dataAccess.showMessageDialog(this, ATSwingUtils.DialogType.Error,
+ errorDescriptionTarget + " for Pump is not working in this application yet. Please use GGC instead.");
+ return true;
}
- else if (action.equals("hide_app"))
- {
- is_visible = false;
- this.setVisible(false);
- }
- else if (action.equals("exit_app"))
- {
- close();
- }
- else
- {
- System.out.println("Action: " + action);
- }
-
+ return false;
}
@@ -803,4 +636,59 @@
}
+
+ public void update(Observable obj, Object arg)
+ {
+ // System.out.println("!!!! update app: " +
+ // this.getClass().getSimpleName() + " - " + arg);
+
+ if (arg instanceof RefreshInfoType)
+ {
+ RefreshInfoType refreshInfoType = (RefreshInfoType) arg;
+
+ // if (!title_set)
+ // {
+ // if (refreshInfoType.getCode() >=
+ // RefreshInfoType.GeneralInfo.getCode())
+ // {
+ // title_set = true;
+ // this.setSoftwareMode();
+ // }
+ // }
+
+ // Integer i = (Integer)arg;
+
+ // this.setSoftwareMode();
+ // this.setTitle();
+
+ }
+ else if (arg instanceof DatabaseStatusType)
+ {
+ // DatabaseStatusType databaseStatusType = (DatabaseStatusType) arg;
+ //
+ // setMenusByDbLoad(databaseStatusType.getCode());
+ //
+ // if (databaseStatusType == DatabaseStatusType.Loaded)
+ // {
+ // refreshMenus();
+ // }
+ }
+ else if (arg instanceof Exception)
+ {
+ Exception ex = (Exception) arg;
+ LOG.error("Error connecting to Database: " + ex.getMessage(), ex);
+
+ dataAccess.createErrorDialog("Main", "Opening Db", ex, guiHelper.getDbSettingsAndCause(false), //
+ guiHelper.getDbSettingsAndCause(true), //
+ i18nControl.getMessage("DB_PROBLEM_NOT_CONNECTED_SOLUTION"), //
+ i18nControl.getMessage("DB_PROBLEM_NOT_CONNECTED_SOLUTION_TOOLTIP"));
+
+ System.exit(1);
+ }
+ else
+ {
+ LOG.error("Unallowed update type ({}) - {}.", arg.getClass().getSimpleName(), arg);
+ }
+
+ }
}
Modified: trunk/ggc-desktop-app/ggc-desktop-little/src/main/java/ggc/gui/little/StatusBarL.java
===================================================================
--- trunk/ggc-desktop-app/ggc-desktop/src/main/java/ggc/gui/little/StatusBarL.java 2016-12-26 14:02:38 UTC (rev 1456)
+++ trunk/ggc-desktop-app/ggc-desktop-little/src/main/java/ggc/gui/little/StatusBarL.java 2017-06-28 19:09:37 UTC (rev 1463)
@@ -5,9 +5,12 @@
import javax.swing.*;
+import com.atech.graphics.observe.EventObserverInterface;
import com.atech.i18n.I18nControlAbstract;
-import com.atech.misc.refresh.EventObserverInterface;
import com.atech.utils.ATSwingUtils;
+
+import ggc.core.data.defs.DatabaseStatusType;
+import ggc.core.data.defs.GGCObservableType;
import ggc.core.util.DataAccess;
/**
@@ -96,7 +99,7 @@
add(lblMessage, BorderLayout.WEST);
add(pan, BorderLayout.EAST);
- da.addObserver(DataAccess.OBSERVABLE_STATUS, this);
+ da.getObserverManager().addObserver(GGCObservableType.Status, this);
}
@@ -156,10 +159,14 @@
*/
public void update(Observable obj, Object arg)
{
- if (arg instanceof Integer)
+ System.out.println("!!!! update Status: " + this.getClass().getSimpleName() + " - " + arg);
+
+ System.out.println("Status update: " + arg);
+
+ if (arg instanceof DatabaseStatusType)
{
- Integer i = (Integer) arg;
- this.setDbStatus(i.intValue());
+ DatabaseStatusType databaseStatusType = (DatabaseStatusType) arg;
+ this.setDbStatus(databaseStatusType.getCode());
}
else
{
Copied: trunk/ggc-desktop-app/ggc-desktop-little/src/main/java/ggc/gui/little/data/DailyStatsTableLittleModel.java (from rev 1456, trunk/ggc-core-app/ggc-core/src/main/java/ggc/core/data/DailyStatsTableModel.java)
===================================================================
--- trunk/ggc-desktop-app/ggc-desktop-little/src/main/java/ggc/gui/little/data/DailyStatsTableLittleModel.java (rev 0)
+++ trunk/ggc-desktop-app/ggc-desktop-little/src/main/java/ggc/gui/little/data/DailyStatsTableLittleModel.java 2017-06-28 19:09:37 UTC (rev 1463)
@@ -0,0 +1,112 @@
+package ggc.gui.little.data;
+
+import javax.swing.table.AbstractTableModel;
+
+import ggc.core.data.DailyValues;
+import ggc.core.data.DataValuesInterface;
+
+/**
+ * Application: GGC - GNU Gluco Control
+ *
+ * See AUTHORS for copyright information.
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Filename: DailyStatsTableModel
+ * Description: A TableModel for the DailyStats-Table. It is the bridge between
+ * the table and the data behind it in the DailyValues Class.
+ *
+ * Author: schultd
+ * Andy {an...@at...}
+ */
+
+public class DailyStatsTableLittleModel extends AbstractTableModel
+{
+
+ private static final long serialVersionUID = -8281136305573121781L;
+
+ DailyValues dayDataPen;
+
+ DataValuesInterface data;
+
+
+ public DailyStatsTableLittleModel()
+ {
+ }
+
+
+ // public DailyValues getDailyValuesPen()
+ // {
+ // return this.dayDataPen;
+ // }
+
+ public void setDataValues(DataValuesInterface dayData)
+ {
+ this.data = dayData;
+ fireTableChanged(null);
+ }
+
+
+ public int getColumnCount()
+ {
+ if (data == null)
+ return 0;
+
+ return data.getColumnCount();
+ }
+
+
+ public int getRowCount()
+ {
+ if (data == null)
+ return 0;
+
+ return data.getRowCount();
+ }
+
+
+ public Object getValueAt(int row, int column)
+ {
+ if (data == null)
+ return null;
+
+ return data.getValueAt(row, column);
+ }
+
+
+ @Override
+ public String getColumnName(int column)
+ {
+ if (data == null)
+ return null;
+
+ return data.getColumnName(column);
+ }
+
+
+ @Override
+ public Class<?> getColumnClass(int c)
+ {
+ return String.class;
+ }
+
+
+ @Override
+ public boolean isCellEditable(int row, int col)
+ {
+ return false;
+ }
+
+}
Modified: trunk/ggc-desktop-app/ggc-desktop-little/src/main/java/ggc/gui/little/panels/DailyStatsControlsL.java
===================================================================
--- trunk/ggc-desktop-app/ggc-desktop/src/main/java/ggc/gui/little/panels/DailyStatsControlsL.java 2016-12-26 14:02:38 UTC (rev 1456)
+++ trunk/ggc-desktop-app/ggc-desktop-little/src/main/java/ggc/gui/little/panels/DailyStatsControlsL.java 2017-06-28 19:09:37 UTC (rev 1463)
@@ -3,7 +3,8 @@
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.Map;
import javax.swing.*;
@@ -12,7 +13,7 @@
import ggc.gui.little.GGCLittle;
import ggc.gui.main.panels.AbstractInfoPanel;
import ggc.gui.main.panels.InfoPanelType;
-import ggc.gui.pen.DailyRowDialog;
+import info.clearthought.layout.TableLayout;
/**
* Application: GGC - GNU Gluco Control
@@ -45,8 +46,9 @@
private static final long serialVersionUID = -3682024667811580299L;
GGCLittle m_little = null;
JButton[] buttons = new JButton[4];
- MainLittlePanel m_mlp;
- GregorianCalendar m_gc = null;
+ // MainLittlePanel m_mlp;
+ // GregorianCalendar m_gc = null;
+ Map<String, JButton> buttonMap = new HashMap<String, JButton>();
// private I18nControlAbstract i18nControl =
@@ -60,8 +62,8 @@
public DailyStatsControlsL(MainLittlePanel mlp)
{
super("");
- m_mlp = mlp;
- m_gc = new GregorianCalendar();
+ m_little = mlp.getApplication();
+ // m_gc = new GregorianCalendar();
init();
}
@@ -69,14 +71,33 @@
private void init()
{
- this.setLayout(new GridLayout(2, 2));
+ double sizes[][] = { { 0.50, 0.50 }, { 0.25, 0.25, 0.25, 0.25 }, };
+
+ setLayout(new TableLayout(sizes));
+
+ // add(new JLabel(i18nControl.getMessage(i18nKey) + ":"), "1, " +
+ // currentLine);
+
+ addButton("ADD_ROW", "add_entry", "0,0");
+ addButton("EDIT_ROW", "edit_entry", "1,0");
+ addButton("DELETE_ROW", "delete_entry", "0,1");
+ addButton("SHOW_DAILY_GRAPH", "show_graph", "1,1");
+ addButton("READ_METER", "read_meter", "0,2");
+ addButton("READ_PUMP", "read_pump", "1,2");
+ addButton("READ_CGMS", "read_cgms", "0,3");
+ addButton("MN_HELP", "hlp_help", "1,3");
+
+ if (true)
+ return;
+
+ this.setLayout(new GridLayout(4, 2));
setBorder(BorderFactory.createTitledBorder(
DataAccess.getInstance().getI18nControlInstance().getMessage("DAILY_CONTROL") + ":"));
- Dimension dim = new Dimension(120, 20);
+ // Dimension dim = new Dimension(120, 20);
- JButton button = new JButton(m_ic.getMessage("SHOW_DAILY_GRAPH"));
- button.setPreferredSize(dim);
+ JButton button = new JButton(i18nControl.getMessage("SHOW_DAILY_GRAPH"));
+ // button.setPreferredSize(dim);
button.setActionCommand("show_daily_graph");
button.addActionListener(this);
button.setEnabled(false);
@@ -83,8 +104,8 @@
buttons[0] = button;
this.add(button);
- button = new JButton(m_ic.getMessage("ADD_ROW"));
- button.setPreferredSize(dim);
+ button = new JButton(i18nControl.getMessage("ADD_ROW"));
+ // button.setPreferredSize(dim);
button.setActionCommand("add_row");
button.addActionListener(this);
button.setEnabled(false);
@@ -91,8 +112,8 @@
buttons[1] = button;
this.add(button);
- button = new JButton(m_ic.getMessage("EDIT_ROW"));
- button.setPreferredSize(dim);
+ button = new JButton(i18nControl.getMessage("EDIT_ROW"));
+ // button.setPreferredSize(dim);
button.setActionCommand("edit_row");
button.addActionListener(this);
button.setEnabled(false);
@@ -99,8 +120,8 @@
buttons[2] = button;
this.add(button);
- button = new JButton(m_ic.getMessage("DELETE_ROW"));
- button.setPreferredSize(dim);
+ button = new JButton(i18nControl.getMessage("DELETE_ROW"));
+ // button.setPreferredSize(dim);
button.setActionCommand("delete_row");
button.addActionListener(this);
button.setEnabled(false);
@@ -111,6 +132,21 @@
}
+ private void addButton(String key, String actionCommand, String position)
+ {
+ JButton button = new JButton(i18nControl.getMessage(key));
+ // button.setPreferredSize(dim);
+ button.setActionCommand(actionCommand);
+ button.addActionListener(this.m_little);
+ button.setEnabled(false);
+ // buttons[3] = button;
+
+ buttonMap.put(actionCommand, button);
+
+ add(button, position);
+ }
+
+
/**
* Refresh Information
*/
@@ -117,8 +153,10 @@
@Override
public void refreshInfo()
{
- boolean start = m_da.getDb().isDbStarted();
+ System.out.println("!!!!!!!!!!!!!!!!!!!!!!! refreshInfo: DailyStats");
+ boolean start = dataAccess.getDb().isDbStarted();
+
for (JButton button : this.buttons)
{
button.setEnabled(start);
@@ -133,17 +171,16 @@
}
- /**
- * Get Table
- *
- * @return
- */
- public JTable getTable()
- {
- return this.m_mlp.dailyStats.getTable();
- }
+ // /**
+ // * Get Table
+ // *
+ // * @return
+ // */
+ // public JTable getTable()
+ // {
+ // return this.m_mlp.dailyStats.getTable();
+ // }
-
/**
* Get Day Data
*
@@ -151,32 +188,32 @@
*/
public DailyValues getDayData()
{
- return this.m_mlp.dailyStats.getTableModel().getDailyValues();
+ // FIXME
+ return null;
+ // return this.m_mlp.dailyStats.getTableModel().getDailyValues();
}
+ // /**
+ // * Reload Table
+ // */
+ // public void reloadTable()
+ // {
+ // // dataAccess.getDayStats(new GregorianCalendar());
+ // dataAccess.loadDailySettingsLittle(m_gc, true);
+ // this.m_mlp.dailyStats.getTableModel().setDataValues(dataAccess.getDayStats(m_gc));
+ // }
- /**
- * Reload Table
- */
- public void reloadTable()
- {
- // dataAccess.getDayStats(new GregorianCalendar());
- m_da.loadDailySettingsLittle(m_gc, true);
- this.m_mlp.dailyStats.getTableModel().setDailyValues(m_da.getDayStats(m_gc));
- }
+ // /**
+ // * Get Frame
+ // * @return
+ // */
+ // public JFrame getFrame()
+ // {
+ // return this.m_mlp.m_little;
+ // }
/**
- * Get Frame
- * @return
- */
- public JFrame getFrame()
- {
- return this.m_mlp.m_little;
- }
-
-
- /**
* Action Performed
*
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
@@ -184,76 +221,79 @@
public void actionPerformed(ActionEvent e)
{
- String command = e.getActionCommand();
-
- if (command.equals("add_row"))
- {
- DailyValues dv = getDayData();
-
- DailyRowDialog aRF = new DailyRowDialog(dv, m_da.getCurrentDateString(), getFrame());
-
- if (aRF.actionSuccessful())
- {
- m_da.getDb().saveDayStats(dv);
- reloadTable();
- }
- }
- else if (command.equals("edit_row"))
- {
- int srow = getTable().getSelectedRow();
-
- if (srow == -1)
- {
- JOptionPane.showMessageDialog(this, m_ic.getMessage("SELECT_ROW_FIRST"), m_ic.getMessage("ERROR"),
- JOptionPane.ERROR_MESSAGE);
- return;
- }
-
- DailyValues dv = getDayData();
-
- DailyRowDialog aRF = new DailyRowDialog(dv.getRow(srow), getFrame());
-
- if (aRF.actionSuccessful())
- {
- m_da.getDb().saveDayStats(dv);
- reloadTable();
- }
-
- }
- else if (command.equals("delete_row"))
- {
- int srow = getTable().getSelectedRow();
-
- if (srow == -1)
- {
- JOptionPane.showMessageDialog(this, m_ic.getMessage("SELECT_ROW_FIRST"), m_ic.getMessage("ERROR"),
- JOptionPane.ERROR_MESSAGE);
- return;
- }
-
- try
- {
- DailyValues dv = getDayData();
-
- dv.deleteRow(srow);
-
- m_da.getDb().saveDayStats(dv);
- reloadTable();
- }
- catch (Exception ex)
- {
- System.out.println("DailyStatsDialog:Action:Delete Row: " + ex);
- }
- }
- else if (command.equals("show_daily_graph"))
- {
- // DailyGraphDialog dgd = new DailyGraphDialog(m_mlp.m_little);
- // dgd.setDailyValues(getDayData());
- }
- else
- {
- System.out.println("DailyStatsDialog:Unknown Action: " + command);
- }
+ // String command = e.getActionCommand();
+ //
+ // if (command.equals("add_row"))
+ // {
+ // DailyValues dv = getDayData();
+ //
+ // DailyRowDialog aRF = new DailyRowDialog(dv,
+ // dataAccess.getCurrentDateString(), getFrame());
+ //
+ // if (aRF.actionSuccessful())
+ // {
+ // dataAccess.getDb().saveDayStats(dv);
+ // reloadTable();
+ // }
+ // }
+ // else if (command.equals("edit_row"))
+ // {
+ // int srow = getTable().getSelectedRow();
+ //
+ // if (srow == -1)
+ // {
+ // JOptionPane.showMessageDialog(this,
+ // i18nControl.getMessage("SELECT_ROW_FIRST"),
+ // i18nControl.getMessage("ERROR"), JOptionPane.ERROR_MESSAGE);
+ // return;
+ // }
+ //
+ // DailyValues dv = getDayData();
+ //
+ // DailyRowDialog aRF = new DailyRowDialog(dv.getRow(srow), getFrame());
+ //
+ // if (aRF.actionSuccessful())
+ // {
+ // dataAccess.getDb().saveDayStats(dv);
+ // reloadTable();
+ // }
+ //
+ // }
+ // else if (command.equals("delete_row"))
+ // {
+ // int srow = getTable().getSelectedRow();
+ //
+ // if (srow == -1)
+ // {
+ // JOptionPane.showMessageDialog(this,
+ // i18nControl.getMessage("SELECT_ROW_FIRST"),
+ // i18nControl.getMessage("ERROR"), JOptionPane.ERROR_MESSAGE);
+ // return;
+ // }
+ //
+ // try
+ // {
+ // DailyValues dv = getDayData();
+ //
+ // dv.deleteRow(srow);
+ //
+ // dataAccess.getDb().saveDayStats(dv);
+ // reloadTable();
+ // }
+ // catch (Exception ex)
+ // {
+ // System.out.println("DailyStatsDialog:Action:Delete Row: " + ex);
+ // }
+ // }
+ // else if (command.equals("show_daily_graph"))
+ // {
+ // // DailyGraphDialog dgd = new DailyGraphDialog(m_mlp.m_little);
+ // // dgd.setDailyValues(getDayData());
+ // }
+ // else
+ // {
+ // System.out.println("DailyStatsDialog:Unknown Action: " + command);
+ // }
}
/*
@@ -285,6 +325,13 @@
@Override
public void doRefresh()
{
+ System.out.println("!!!!!!!!!!!!!!!!!!!!!!! doRefresh: DailyStats");
+
+ for (JButton button : buttonMap.values())
+ {
+ button.setEnabled(true);
+ }
+
}
}
Copied: trunk/ggc-desktop-app/ggc-desktop-little/src/main/java/ggc/gui/little/panels/DailyStatsListPanelL.java (from rev 1456, trunk/ggc-desktop-app/ggc-desktop/src/main/java/ggc/gui/little/panels/DailyStatsPanelL.java)
===================================================================
--- trunk/ggc-desktop-app/ggc-desktop-little/src/main/java/ggc/gui/little/panels/DailyStatsListPanelL.java (rev 0)
+++ trunk/ggc-desktop-app/ggc-desktop-little/src/main/java/ggc/gui/little/panels/DailyStatsListPanelL.java 2017-06-28 19:09:37 UTC (rev 1463)
@@ -0,0 +1,174 @@
+package ggc.gui.little.panels;
+
+import java.awt.*;
+import java.util.GregorianCalendar;
+
+import javax.swing.*;
+import javax.swing.border.TitledBorder;
+
+import ggc.core.data.DailyValues;
+import ggc.gui.little.data.DailyStatsTableLittleModel;
+import ggc.gui.main.panels.AbstractInfoPanel;
+import ggc.gui.main.panels.InfoPanelType;
+
+/**
+ * Application: GGC - GNU Gluco Control
+ *
+ * See AUTHORS for copyright information.
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Filename: DailyStatsPanelL
+ * Description: Panel for Daily Stats
+ *
+ * Author: andyrozman {an...@at...}
+ */
+
+public class DailyStatsListPanelL extends AbstractInfoPanel
+{
+
+ private static final long serialVersionUID = 3519092324025060409L;
+ private DailyStatsTableLittleModel model = null;
+ JScrollPane resultsPane;
+ private JTable table;
+ private DailyValues dayData;
+
+
+ /**
+ * Constructor
+ */
+ public DailyStatsListPanelL()
+ {
+ super(null);
+
+ setTitle(i18nControl.getMessage("DAILY_VALUES") + ": (" + dataAccess.getCurrentDateString() + ")");
+ init();
+ }
+
+
+ public void setTitle(String title)
+ {
+ TitledBorder titledBorder = (TitledBorder) this.getBorder();
+ titledBorder.setTitle(title);
+ }
+
+
+ /**
+ * Get Table Model
+ *
+ * @return
+ */
+ public DailyStatsTableLittleModel getTableModel()
+ {
+ return model;
+ }
+
+
+ /**
+ * Refresh Information
+ */
+ @Override
+ public void refreshInfo()
+ {
+ refreshDayData();
+ }
+
+
+ @Override
+ public InfoPanelType getPanelType()
+ {
+ return InfoPanelType.DailyValuesList;
+ }
+
+
+ /**
+ * Get Table
+ *
+ * @return
+ */
+ public JTable getTable()
+ {
+ return this.table;
+ }
+
+
+ /**
+ * Get Day Data
+ *
+ * @return
+ */
+ public DailyValues getDayData()
+ {
+ return this.dayData;
+ }
+
+
+ private void refreshDayData()
+ {
+ DailyValues dv = dataAccess.getDayStats(new GregorianCalendar());
+
+ if (dv != null)
+ {
+ dayData = dv;
+ model.setDataValues(dayData);
+ this.model.fireTableChanged(null);
+ }
+ }
+
+
+ private void init()
+ {
+ this.setLayout(new GridLayout(1, 1));
+
+ dayData = dataAccess.getDayStats(new GregorianCalendar());
+
+ // if (dayData==null)
+ // dayData = DataAccess.getInstance().getDayStats(new
+ // GregorianCalendar());
+ // refreshDayData();
+
+ System.out.println("DailyStatPa...
[truncated message content] |