From: <and...@us...> - 2008-08-12 12:12:40
|
Revision: 475 http://ggc.svn.sourceforge.net/ggc/?rev=475&view=rev Author: andyrozman Date: 2008-08-12 12:12:48 +0000 (Tue, 12 Aug 2008) Log Message: ----------- Added Paths: ----------- trunk/ggc-plugin_base/ trunk/ggc-plugin_base/src/ trunk/ggc-plugin_base/src/ggc/ trunk/ggc-plugin_base/src/ggc/plugin/ trunk/ggc-plugin_base/src/ggc/plugin/list/ trunk/ggc-plugin_base/src/ggc/plugin/list/BaseListAbstractPanel.java trunk/ggc-plugin_base/src/ggc/plugin/list/BaseListBrowserPanel.java trunk/ggc-plugin_base/src/ggc/plugin/list/BaseListDialog.java trunk/ggc-plugin_base/src/ggc/plugin/list/BaseListEntry.java trunk/ggc-plugin_base/src/ggc/plugin/list/BaseListMainPanel.java trunk/ggc-plugin_base/src/ggc/plugin/list/BaseListModel.java trunk/ggc-plugin_base/src/ggc/plugin/list/BaseListRoot.java trunk/ggc-plugin_base/src/ggc/plugin/util/ trunk/ggc-plugin_base/src/ggc/plugin/util/DataAccessPlugInBase.java Added: trunk/ggc-plugin_base/src/ggc/plugin/list/BaseListAbstractPanel.java =================================================================== --- trunk/ggc-plugin_base/src/ggc/plugin/list/BaseListAbstractPanel.java (rev 0) +++ trunk/ggc-plugin_base/src/ggc/plugin/list/BaseListAbstractPanel.java 2008-08-12 12:12:48 UTC (rev 475) @@ -0,0 +1,43 @@ +/* + * GGC - GNU Gluco Control + * + * A pure java app to help you manage your diabetes. + * + * 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: GGCTreeRoot + * Purpose: Used for holding tree information for nutrition and meals + * + * Author: andyrozman + */ + +package ggc.plugin.list; + +import javax.swing.JPanel; + + +public abstract class BaseListAbstractPanel extends JPanel +{ + + /** + * + */ + private static final long serialVersionUID = -419549921018198285L; + + public abstract void setData(Object obj); + +} Added: trunk/ggc-plugin_base/src/ggc/plugin/list/BaseListBrowserPanel.java =================================================================== --- trunk/ggc-plugin_base/src/ggc/plugin/list/BaseListBrowserPanel.java (rev 0) +++ trunk/ggc-plugin_base/src/ggc/plugin/list/BaseListBrowserPanel.java 2008-08-12 12:12:48 UTC (rev 475) @@ -0,0 +1,278 @@ +/* + * GGC - GNU Gluco Control + * + * A pure java app to help you manage your diabetes. + * + * 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: GGCTreeRoot + * Purpose: Used for holding tree information for nutrition and meals + * + * Author: andyrozman + */ + +package ggc.plugin.list; + +import ggc.plugin.util.DataAccessPlugInBase; + +import java.awt.Color; +import java.awt.Font; + +import javax.swing.JButton; +import javax.swing.JEditorPane; +import javax.swing.JLabel; +import javax.swing.JScrollPane; + +import com.atech.graphics.components.web.MiniBrowserPanel; +import com.atech.i18n.I18nControlAbstract; + + + +public class BaseListBrowserPanel extends BaseListAbstractPanel +{ + + static final long serialVersionUID = 0L; + + I18nControlAbstract ic = null; + DataAccessPlugInBase m_da = null; + JEditorPane editor; + + Font font_big, font_normal, font_normal_b; + JLabel label, label_test; + JButton button; + + MiniBrowserPanel mbp; + + BaseListDialog m_dialog = null; + + + + public BaseListBrowserPanel(BaseListDialog dia) + { + + super(); + + m_dialog = dia; + m_da = dia.m_da; + + font_big = m_da.getFont(DataAccessPlugInBase.FONT_BIG_BOLD); + font_normal_b = m_da.getFont(DataAccessPlugInBase.FONT_NORMAL_BOLD); + font_normal = m_da.getFont(DataAccessPlugInBase.FONT_NORMAL); + + //createPanel(); + //init(); + initBrowser(); + + } + + + public void init() + { + + System.out.println("init()"); + this.setBounds(0,0,500,500); + this.setLayout(new java.awt.BorderLayout()); + + this.editor = new JEditorPane(); + + + JScrollPane jScrollPane1 = new JScrollPane(this.editor); + //jScrollPane1.setPreferredSize(new java.awt.Dimension(13, 1200)); + + this.editor.setEditable(false); + this.editor.setContentType("text/html"); + jScrollPane1.setViewportView(this.editor); + this.editor.setText("<html><body><font color=\"#CCCCCC\"><h1>Test</h1></font></body></html>"); + + this.add(jScrollPane1, java.awt.BorderLayout.CENTER); + + this.editor.select(0,0); + + + + } + + + public void initBrowser() + { + + this.setBounds(0,0,582,565); + this.setLayout(null); + + //MiniBrowserPanel mbp; + + this.mbp = new MiniBrowserPanel(); + this.mbp.setBounds(0,0,582,565); + +/* + JScrollPane jScrollPane1 = new JScrollPane(this.editor); + //jScrollPane1.setPreferredSize(new java.awt.Dimension(13, 1200)); + + this.editor.setEditable(false); + this.editor.setContentType("text/html"); + jScrollPane1.setViewportView(this.editor); + this.editor.setText("<html><body><font color=\"#CCCCCC\"><h1>Test</h1></font></body></html>"); + + this.add(jScrollPane1, java.awt.BorderLayout.CENTER); + + this.editor.select(0,0); +*/ + this.add(this.mbp, null); //, java.awt.BorderLayout.CENTER); + + } + + + public void createPanel() + { + + + //this.setLayout(new java.awt.BorderLayout()); + this.setLayout(null); + + editor = new JEditorPane(); + + + JScrollPane jScrollPane1 = new JScrollPane(editor); + jScrollPane1.setBounds(0,0,300,300); + jScrollPane1.setBackground(Color.blue); + + + //jScrollPane1.setPreferredSize(new java.awt.Dimension(13, 1200)); + + editor.setEditable(false); + editor.setContentType("text/html"); + //jScrollPane1.setViewportView(editor); + editor.setText("<html><body><font color=\"#CCCCCC\"><h1>Test</h1></font></body></html>"); + + this.add(jScrollPane1, null); + + //editor.select(0,0); + + + + /* + + this.setSize(460, 520); + this.setLayout(new BorderLayout()); + + this.editor = new JEditorPane(); + this.editor.setContentType("html"); + this.editor.s + + + JScrollPane scroll = new JScrollPane(); + */ + + /* + + Font fnt_18 = new Font("Times New Roman", Font.PLAIN, 14); + + //String nut_db = nutrition_db[this.m_dialog.getType()]; + + String nut_db = "SSS"; + + label = new JLabel(ic.getMessage(nut_db)); + label.setBounds(0, 35, 520, 40); + label.setFont(font_big); + label.setHorizontalAlignment(SwingConstants.CENTER); + this.add(label, null); + + + label = new JLabel(ic.getMessage(nut_db + "_DESC")); + label.setBounds(40, 120, 400, 250); + label.setVerticalAlignment(JLabel.TOP); + label.setFont(fnt_18); + this.add(label, null); + + + label_test = new JLabel(ic.getMessage("ADD_DIOCESE_DESC")); + label_test.setBounds(40, 330, 300, 60); + label_test.setFont(font_normal); + this.add(label_test, null); + + + + label = new JLabel(ic.getMessage("EDIT_VIEW")); + label.setBounds(40, 280, 300, 30); + label.setFont(fnt_18); +// this.add(label, null); + + label = new JLabel(ic.getMessage("EDIT_VIEW_DESC")); + label.setBounds(40, 310, 300, 60); + //label.setFont(font_normal); +// this.add(label, null); +*/ + + return; + } + + + public void loadFile(String name) + { + String res = m_da.metersUrl.get(name); + + String web = "http://localhost:88/meters/" + res; + + System.out.println(web); + + + this.mbp.setPage(web); + + /* + //abbott_diabetes_care.html + try + { + URL url = new URL("http://localhost:88/meters/" + res); //this.getClass().getResource("/html/abbott_diabetes_care.html"); + InputStreamReader ins = new InputStreamReader(url.openStream()); + BufferedReader br = new BufferedReader( ins ); + String line; + StringBuffer sb = new StringBuffer(); + + while ((line = br.readLine())!=null) + { + sb.append(line); + } + + //System.out.println("Sb: " + sb); + + this.editor.setText(sb.toString()); + //this.jEditorPane1.setText(sb.toString()); + } + catch(Exception ex) + { + System.out.println("PumpListCompanyPanel::error reading. Ex: " + ex); + ex.printStackTrace(); + } + */ + } + + + public void setData(Object obj) + { + //System.out.println((String)obj); + + //editor.setText("<html><body><font color=\"#CCCCCC\"><h1>" + (String)obj + "</h1></font></body></html>"); + //editor.setText("<html><body><h1>" + (String)obj + "</h1></body></html>"); + + loadFile((String)obj); + } + + + + + +} Added: trunk/ggc-plugin_base/src/ggc/plugin/list/BaseListDialog.java =================================================================== --- trunk/ggc-plugin_base/src/ggc/plugin/list/BaseListDialog.java (rev 0) +++ trunk/ggc-plugin_base/src/ggc/plugin/list/BaseListDialog.java 2008-08-12 12:12:48 UTC (rev 475) @@ -0,0 +1,434 @@ +/* + * GGC - GNU Gluco Control + * + * A pure java app to help you manage your diabetes. + * + * 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: NutritionTreeDialog + * Purpose: Main class for displaying nutrition information. + * + * Author: andyrozman + */ + +package ggc.plugin.list; + +import ggc.plugin.util.DataAccessPlugInBase; + +import java.awt.Dimension; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTree; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.TreeSelectionModel; + +import com.atech.i18n.I18nControlAbstract; + + + +public class BaseListDialog extends JDialog implements TreeSelectionListener, ActionListener +{ + static final long serialVersionUID = 0L; + + + private JPanel mainPane; + private JTree tree; + + public DataAccessPlugInBase m_da = null; + + +// private static boolean playWithLineStyle = false; +// private static String lineStyle = "Horizontal"; + +// private static boolean useSystemLookAndFeel = false; + + + private I18nControlAbstract ic = null; + public BaseListAbstractPanel panels[] = null; +// x private int selectedPanel = 0; + +// addMouseListener(this); +// add(pop); + + BaseListRoot m_root = null; + + + public BaseListDialog(DataAccessPlugInBase da) + { + + super(new JFrame(), "", true); + //super((JDialog)null, "", true); + + m_da = da; + ic = m_da.m_i18n; + + m_root = new BaseListRoot(m_da); + + //this.setResizable(false); + this.setBounds(80, 50, 800, 600); + setTitle(); + + JPanel panel = new JPanel(); + panel.setLayout(new GridLayout(1,0)); + + //this.pop.s + //add(pop); + + + //Create a tree that allows one selection at a time. + tree = new JTree(); + tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); + this.setTreeModel(tree); + //tree.setModel(new NutritionTreeModel(m_da.m_nutrition_treeroot)); + tree.addTreeSelectionListener(this); + //tree.addMouseListener(this); + + + JScrollPane treeView = new JScrollPane(tree); + + mainPane = new JPanel(); + mainPane.setLayout(null); + + //Add the scroll panes to a split pane. + JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT/*.VERTICAL_SPLIT*/); + splitPane.setTopComponent(treeView); + splitPane.setBottomComponent(mainPane); + + Dimension minimumSize = new Dimension(100, 50); + mainPane.setMinimumSize(minimumSize); + treeView.setMinimumSize(minimumSize); + splitPane.setDividerLocation(200); //XXX: ignored in some releases + //of Swing. bug 4101306 + splitPane.setPreferredSize(new Dimension(500, 300)); + + panel.add(splitPane); + + createPanels(); + this.add(panel); + makePanelVisible(0); + + this.setVisible(true); + + } + + + + public void setTitle() + { + this.setTitle(m_da.getWebListerTitle()); + } + + public void setTreeModel(JTree tree) + { + tree.setModel(new BaseListModel(this.m_root)); + } + + + public void createPanels() + { + panels = new BaseListAbstractPanel[2]; + + panels[0] = new BaseListMainPanel(this); + panels[1] = new BaseListBrowserPanel(this); + + for(int i = 0; i < panels.length ; i++) + { + mainPane.add(panels[i]); + } + + makePanelVisible(0); + + } + + public static final int PANEL_MAIN = 0; + public static final int PANEL_BROWSER = 1; + + + + /** + * Makes selected panel visible + */ + public void makePanelVisible(int num) + { +//x selectedPanel = num; + + for(int i = 0; i < panels.length; i++) + if(i == num) + panels[i].setVisible(true); + else + panels[i].setVisible(false); + } + + + Object selected_last_path = null; + + /** Required by TreeSelectionListener interface. */ + public void valueChanged(TreeSelectionEvent e) + { + + this.selected_last_path = tree.getLastSelectedPathComponent(); + + //this.displayPanel(1); + + if (this.selected_last_path instanceof BaseListRoot) + { + makePanelVisible(BaseListDialog.PANEL_MAIN); + } + else if (this.selected_last_path instanceof String) + { + makePanelVisible(BaseListDialog.PANEL_BROWSER); + this.panels[BaseListDialog.PANEL_BROWSER].setData(this.selected_last_path); + } + + + /* + if (tree.getLastSelectedPathComponent() instanceof GGCTreeRoot) + { + makePanelVisible(NutritionTreeDialog.PANEL_MAIN); + //System.out.println("NutritionTreeDialog::valueChanged:: NOT IMPLEMENTED"); + //Diocese dio = (Diocese)tree.getLastSelectedPathComponent(); + //((ViewDiocesePanel)panels[DioceseCfgDialog.PANEL_VIEW_DIOCESE]).setData((DioceseH)dio); //node2.getObject()); + } + else if (tree.getLastSelectedPathComponent() instanceof FoodGroup) + { + makePanelVisible(NutritionTreeDialog.PANEL_FOODGROUP); + this.panels[NutritionTreeDialog.PANEL_FOODGROUP].setData(tree.getLastSelectedPathComponent()); + } + else if (tree.getLastSelectedPathComponent() instanceof FoodDescription) + { + makePanelVisible(NutritionTreeDialog.PANEL_FOOD); + this.panels[NutritionTreeDialog.PANEL_FOOD].setData(tree.getLastSelectedPathComponent()); + } +*/ + +/* + if (panels[selectedPanel] instanceof EditablePanel) + { + EditablePanel p = (EditablePanel)panels[selectedPanel]; + if (p.hasDataChanged()) + { + if (!p.saveData()) + return; + } + } + + + if (tree.getLastSelectedPathComponent() instanceof Diocese) + { + makePanelVisible(DioceseCfgDialog.PANEL_VIEW_DIOCESE); + Diocese dio = (Diocese)tree.getLastSelectedPathComponent(); + ((ViewDiocesePanel)panels[DioceseCfgDialog.PANEL_VIEW_DIOCESE]).setData((DioceseH)dio); //node2.getObject()); + } + else if (tree.getLastSelectedPathComponent() instanceof Parish) + { + makePanelVisible(DioceseCfgDialog.PANEL_VIEW_PARISH); + Parish pi = (Parish)tree.getLastSelectedPathComponent(); + ((ViewParishPanel)panels[DioceseCfgDialog.PANEL_VIEW_PARISH]).setData((ParishH)pi); + } + else if (tree.getLastSelectedPathComponent() instanceof ParishPerson) + { + ParishPerson pp = (ParishPerson)tree.getLastSelectedPathComponent(); + makePanelVisible(DioceseCfgDialog.PANEL_VIEW_PARISH_PERSONAL); + ((ViewParishPersonalPanel)panels[DioceseCfgDialog.PANEL_VIEW_PARISH_PERSONAL]).setData((ParishH)pp.getParish()); + } + else if (tree.getLastSelectedPathComponent() instanceof DiocesePerson) + { + DiocesePerson pp = (DiocesePerson)tree.getLastSelectedPathComponent(); + makePanelVisible(DioceseCfgDialog.PANEL_VIEW_DIOCESE_PERSONAL); + ((ViewDiocesePanel)panels[DioceseCfgDialog.PANEL_VIEW_DIOCESE_PERSONAL]).setData((DioceseH)pp.getDiocese()); + } + else + { + System.out.println("DioceseCfgDialog::valueChanged::UnknownAction"); + } +*/ + } + + public static int PANEL_VIEW = 0; + public static int PANEL_EDIT = 1; + public static int PANEL_ADD = 2; + public static int PANEL_ADD_ITEM = 3; + + + + private void displayPanel(int special_action) + { + + /* + //System.out.println() + + if (this.selected_last_path instanceof GGCTreeRoot) + { + makePanelVisible(NutritionTreeDialog.PANEL_MAIN); + } + else if (this.selected_last_path instanceof FoodGroup) + { + if (special_action == NutritionTreeDialog.PANEL_VIEW) + { + makePanelVisible(NutritionTreeDialog.PANEL_FOODGROUP); + this.panels[NutritionTreeDialog.PANEL_FOODGROUP].setData(this.selected_last_path); + } + else if (special_action == NutritionTreeDialog.PANEL_EDIT) + { + makePanelVisible(NutritionTreeDialog.PANEL_FOODGROUP_EDIT); + this.panels[NutritionTreeDialog.PANEL_FOODGROUP_EDIT].setData(this.selected_last_path); + + //System.out.println("FoodGroup Edit failed"); + } + else if (special_action == NutritionTreeDialog.PANEL_ADD) + { + //System.out.println("FoodGroup Add Group failed"); + makePanelVisible(NutritionTreeDialog.PANEL_FOODGROUP_EDIT); + this.panels[NutritionTreeDialog.PANEL_FOODGROUP_EDIT].setParent(this.selected_last_path); + } + else + { + //System.out.println("FoodGroup Add Item failed"); + makePanelVisible(NutritionTreeDialog.PANEL_FOOD_EDIT); + this.panels[NutritionTreeDialog.PANEL_FOOD_EDIT].setParent(this.selected_last_path); + } + } + else if (this.selected_last_path instanceof FoodDescription) + { + if (special_action == NutritionTreeDialog.PANEL_VIEW) + { + makePanelVisible(NutritionTreeDialog.PANEL_FOOD); + this.panels[NutritionTreeDialog.PANEL_FOOD].setData(this.selected_last_path); + } + else if (special_action == NutritionTreeDialog.PANEL_EDIT) + { + System.out.println("FoodDescription Edit failed"); + } + else + { + System.out.println("FoodDescription Add failed"); + } + + } + */ + } + + + + + + + + boolean made = false; + int menu_prev_type = 0; + + + + public int getTreeItemType() + { +/* + if (this.mouse_selected_object instanceof GGCTreeRoot) + { + return 1; + } + else + { + if (this.m_tree_type==2) + { + if (this.mouse_selected_object instanceof FoodGroup) + return 2; + else + return 3; + } + else if (this.m_tree_type==3) + { + if (this.mouse_selected_object instanceof MealGroup) + return 2; + else + return 3; + + } + else + { + System.out.println("Error on mouse click: Wrong type:" + this.mouse_selected_object); + return -1; + } + + } + //else + */ + + return 0; + + } + + + /* + public static void main(String args[]) + { + DataAccessPlugInBase da = DataAccessPump.getInstance(); + + + + new PumpListDialog(da); + + } +*/ + + public void actionPerformed(ActionEvent ae) + { + /* + // TODO Auto-generated method stub + //System.out.println("Action performed, NOT handled"); + + String command = ae.getActionCommand(); + + if (command.equals("close")) + { + } + else if (command.equals("view")) + { + this.selected_last_path = this.mouse_selected_object; + this.displayPanel(NutritionTreeDialog.PANEL_VIEW); + } + else if (command.equals("add_item")) + { + this.selected_last_path = this.mouse_selected_object; + this.displayPanel(NutritionTreeDialog.PANEL_ADD_ITEM); + } + else if (command.equals("add_group")) + { + this.selected_last_path = this.mouse_selected_object; + this.displayPanel(NutritionTreeDialog.PANEL_ADD); + } + else if ((command.equals("edit_item")) || + (command.equals("edit_group"))) + { + this.selected_last_path = this.mouse_selected_object; + this.displayPanel(NutritionTreeDialog.PANEL_EDIT); + } + + */ + + } + + + +} Added: trunk/ggc-plugin_base/src/ggc/plugin/list/BaseListEntry.java =================================================================== --- trunk/ggc-plugin_base/src/ggc/plugin/list/BaseListEntry.java (rev 0) +++ trunk/ggc-plugin_base/src/ggc/plugin/list/BaseListEntry.java 2008-08-12 12:12:48 UTC (rev 475) @@ -0,0 +1,61 @@ +/* + * GGC - GNU Gluco Control + * + * A pure java app to help you manage your diabetes. + * + * 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: GGCTreeRoot + * Purpose: Used for holding tree information for nutrition and meals + * + * Author: andyrozman + */ + +package ggc.plugin.list; + + + + +public class BaseListEntry +{ + + public static final int STATUS_NONE = 0; + public static final int STATUS_DONE = 1; + public static final int STATUS_PLANNED = 2; + public static final int STATUS_NOTPLANNED = 3; + + + public String name; + public String page; + public int status; + + + public BaseListEntry() + { + } + + + public BaseListEntry(String name, String page, int status) + { + this.name = name; + this.page = page; + this.status = status; + } + + + +} Added: trunk/ggc-plugin_base/src/ggc/plugin/list/BaseListMainPanel.java =================================================================== --- trunk/ggc-plugin_base/src/ggc/plugin/list/BaseListMainPanel.java (rev 0) +++ trunk/ggc-plugin_base/src/ggc/plugin/list/BaseListMainPanel.java 2008-08-12 12:12:48 UTC (rev 475) @@ -0,0 +1,88 @@ +package ggc.plugin.list; + +//package ggc.gui.nutrition.panels; + +//import ggc.gui.nutrition.NutritionTreeDialog; +import ggc.plugin.util.DataAccessPlugInBase; + +import java.awt.Font; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.SwingConstants; + +import com.atech.i18n.I18nControlAbstract; + + +// WORK IN PROGRESS, PLEASE DO NOT TOUCH +// andyrozman + + +public class BaseListMainPanel extends BaseListAbstractPanel //JPanel +{ + static final long serialVersionUID = 0L; + + + I18nControlAbstract m_ic = null; + DataAccessPlugInBase m_da = null; + + Font font_big, font_normal, font_normal_b; + JLabel label; + JButton button; + + BaseListDialog m_dialog = null; + + + + public BaseListMainPanel(BaseListDialog dia) + { + + super(); + + m_dialog = dia; + m_da = dia.m_da; + m_ic = m_da.getI18nControlInstance(); + + font_big = m_da.getFont(DataAccessPlugInBase.FONT_BIG_BOLD); + font_normal_b = m_da.getFont(DataAccessPlugInBase.FONT_NORMAL_BOLD); + font_normal = m_da.getFont(DataAccessPlugInBase.FONT_NORMAL); + + createPanel(); + + } + + + public void createPanel() + { + + this.setSize(460, 520); + this.setLayout(null); + + Font fnt_18 = new Font("Times New Roman", Font.PLAIN, 14); + + label = new JLabel(m_da.getWebListerTitle()); + label.setBounds(0, 35, 520, 40); + label.setFont(font_big); + label.setHorizontalAlignment(SwingConstants.CENTER); + this.add(label, null); + + + label = new JLabel(m_da.getWebListerDescription()); + label.setBounds(40, 120, 400, 250); + label.setVerticalAlignment(JLabel.TOP); + label.setFont(fnt_18); + this.add(label, null); + + return; + } + + + public void setData(Object obj) + { + } + + +} + + + Added: trunk/ggc-plugin_base/src/ggc/plugin/list/BaseListModel.java =================================================================== --- trunk/ggc-plugin_base/src/ggc/plugin/list/BaseListModel.java (rev 0) +++ trunk/ggc-plugin_base/src/ggc/plugin/list/BaseListModel.java 2008-08-12 12:12:48 UTC (rev 475) @@ -0,0 +1,177 @@ +/* + * GGC - GNU Gluco Control + * + * A pure java app to help you manage your diabetes. + * + * 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: NutritionTreeModel + * Purpose: This is tree model for displaying nutrition information. + * + * Author: andyrozman + */ + + +package ggc.plugin.list; + + +import java.util.Vector; + +import javax.swing.event.TreeModelEvent; +import javax.swing.event.TreeModelListener; +import javax.swing.tree.TreeModel; +import javax.swing.tree.TreePath; + +public class BaseListModel implements TreeModel +{ + + private boolean m_debug = false; + private Vector<TreeModelListener> treeModelListeners = new Vector<TreeModelListener>(); + private BaseListRoot rootObj = null; + + + public BaseListModel(BaseListRoot rt) + { + rootObj = rt; + } + + + public void debug(String deb) + { + if (m_debug) + System.out.println(deb); + } + + + + //////////////// Fire events ////////////////////////////////////////////// + + /** + * The only event raised by this model is TreeStructureChanged with the + * root as path, i.e. the whole tree has changed. + */ + protected void fireTreeStructureChanged(BaseListRoot oldRoot) + { + int len = treeModelListeners.size(); + TreeModelEvent e = new TreeModelEvent(this, + new Object[] {oldRoot}); + for (int i = 0; i < len; i++) + { + (treeModelListeners.elementAt(i)).treeStructureChanged(e); + } + } + + + //////////////// TreeModel interface implementation /////////////////////// + + /** + * Adds a listener for the TreeModelEvent posted after the tree changes. + */ + public void addTreeModelListener(TreeModelListener l) + { + treeModelListeners.addElement(l); + } + + + /** + * Returns the child of parent at index index in the parent's child array. + */ + public Object getChild(Object parent, int index) + { + + debug("getChild: " + index); + + if (parent instanceof BaseListRoot) + { + return rootObj.children.get(index); + } + else if (parent instanceof String) + { + return null; + } + else + return null; + + } + + /** + * Returns the number of children of parent. + */ + public int getChildCount(Object parent) + { + debug("Parent (getChildCount()): " + parent); + + if (parent instanceof BaseListRoot) + { + return rootObj.children.size(); + } + else + return 0; + + } + + /** + * Returns the index of child in parent. + */ + public int getIndexOfChild(Object parent, Object child) + { + debug("getIndexofChild: "); + + if (parent instanceof BaseListRoot) + { + return rootObj.children.indexOf(child); + } + else + return -1; + + } + + /** + * Returns the root of the tree. + */ + public Object getRoot() + { + return rootObj; + } + + /** + * Returns true if node is a leaf. + */ + public boolean isLeaf(Object node) + { + return (getChildCount(node)==0); + } + + + /** + * Removes a listener previously added with addTreeModelListener(). + */ + public void removeTreeModelListener(TreeModelListener l) + { + treeModelListeners.removeElement(l); + } + + /** + * Messaged when the user has altered the value for the item + * identified by path to newValue. Not used by this model. + */ + public void valueForPathChanged(TreePath path, Object newValue) + { + System.out.println("*** valueForPathChanged : " + path + " --> " + newValue); + } + +} Added: trunk/ggc-plugin_base/src/ggc/plugin/list/BaseListRoot.java =================================================================== --- trunk/ggc-plugin_base/src/ggc/plugin/list/BaseListRoot.java (rev 0) +++ trunk/ggc-plugin_base/src/ggc/plugin/list/BaseListRoot.java 2008-08-12 12:12:48 UTC (rev 475) @@ -0,0 +1,55 @@ +/* + * GGC - GNU Gluco Control + * + * A pure java app to help you manage your diabetes. + * + * 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: GGCTreeRoot + * Purpose: Used for holding tree information for nutrition and meals + * + * Author: andyrozman + */ + +package ggc.plugin.list; + +import ggc.plugin.util.DataAccessPlugInBase; + +import java.util.ArrayList; + +public class BaseListRoot +{ + + public ArrayList<String> children = null; + DataAccessPlugInBase m_da; + + + public BaseListRoot(DataAccessPlugInBase da) + { + m_da = da; + this.children = m_da.getWebListerItemsTitles(); + } + + + @Override + public String toString() + { + return m_da.getWebListerTitle(); + } + + +} Added: trunk/ggc-plugin_base/src/ggc/plugin/util/DataAccessPlugInBase.java =================================================================== --- trunk/ggc-plugin_base/src/ggc/plugin/util/DataAccessPlugInBase.java (rev 0) +++ trunk/ggc-plugin_base/src/ggc/plugin/util/DataAccessPlugInBase.java 2008-08-12 12:12:48 UTC (rev 475) @@ -0,0 +1,1096 @@ +/* + * GGC - GNU Gluco Control + * + * A pure java app to help you manage your diabetes. + * + * 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: DataAccessMeter + * Purpose: Used for utility works and static data handling (this is singelton + * class which holds all our definitions, so that we don't need to create them + * again for each class. + * + * Author: andyrozman + */ + +package ggc.plugin.util; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Font; +import java.awt.Image; +import java.io.ByteArrayOutputStream; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.math.BigDecimal; +import java.math.MathContext; +import java.math.RoundingMode; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.Enumeration; +import java.util.GregorianCalendar; +import java.util.Hashtable; +import java.util.Properties; +import java.util.Vector; + +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JLabel; + +import com.atech.i18n.I18nControlAbstract; +import com.atech.utils.ATDataAccessAbstract; + + +public abstract class DataAccessPlugInBase extends ATDataAccessAbstract +{ + + + public static final String pathPrefix = "."; + + //public I18nControl m_i18n = null; + +// private static DataAccessMeter s_da = null; // This is handle to unique + + + public Font fonts[] = null; + + + +//xa private GGCProperties m_settings = null; + + //private DbToolApplicationGGC m_configFile = null; +// private ConfigurationManager m_cfgMgr = null; + + + public static DecimalFormat MmolDecimalFormat = new DecimalFormat("#0.0"); + + /** + * Which BG unit is used: BG_MGDL = mg/dl, BG_MMOL = mmol/l + */ + public int m_BG_unit = BG_MGDL; + + public String[] availableLanguages = { "English", "Deutsch", "Slovenski", }; + + public String[] avLangPostfix = { "en", "de", "si", }; + + public String[] bg_units = { "mg/dl", "mmol/l" }; + + public Hashtable<String,String> timeZones; + + public Vector<String> time_zones_vector; + +// public static DecimalFormat MmolDecimalFormat = new DecimalFormat("#0.0"); + + public ImageIcon config_icons[] = null; +/* + { + new ImageIcon("/icons/cfg_general.png"), + new ImageIcon("/icons/cfg_medical.png"), + new ImageIcon("icons/cfg_colors.png"), + new ImageIcon("icons/cfg_render.png"), + new ImageIcon("icons/cfg_meter.png"), + new ImageIcon("icons/cfg_print.png") + }; +*/ +/* public ImageIcon config_icons[] = { + new ImageIcon("images/cfg_db.gif"), + new ImageIcon("images/cfg_look.gif"), + new ImageIcon("images/cfg_myparish.gif"), + new ImageIcon("images/cfg_masses.gif"), + new ImageIcon("images/cfg_users.gif"), + new ImageIcon("images/cfg_lang.gif"), + new ImageIcon("images/cfg_web.gif"), + null + }; + + public String config_types[] = { + m_ic.getMessage("GENERAL"), + m_ic.getMessage("MEDICAL_DATA"), + m_ic.getMessage("COLORS_AND_FONTS"), + m_ic.getMessage("RENDERING_QUALITY"), + m_ic.getMessage("METER_CONFIGURATION"), + m_ic.getMessage("PRINTING") + }; + +*/ + public String[] options_yes_no = null; + + + JFrame m_main = null; + + + public Hashtable<String,String> metersUrl; + public ArrayList<String> metersNames; + + + + // ******************************************************** + // ****** Constructors and Access methods ***** + // ******************************************************** + + // Constructor: DataAccessMeter + /** + * + * This is DataAccessMeter constructor; Since classes use Singleton Pattern, + * constructor is protected and can be accessed only with getInstance() + * method.<br><br> + * + */ + public DataAccessPlugInBase(I18nControlAbstract i18n) + { + super(i18n); //I18nControl.getInstance()); + + this.loadTimeZones(); + + loadMetersTable(); + loadConfigIcons(); + + checkPrerequisites(); + + } + + // FIXME should be abstract + public void initSpecial() + { + } + + + // Method: getInstance + // Author: Andy + /** + * + * This method returns reference to OmniI18nControl object created, or if no + * object was created yet, it creates one.<br><br> + * + * @return Reference to OmniI18nControl object + * + */ +/* public static DataAccessMeter getInstance() + { + if (s_da == null) + s_da = new DataAccessMeter(null); + return s_da; + } + + public static DataAccessMeter createInstance(JFrame main) + { + if (s_da == null) + { + //GGCDb db = new GGCDb(); + s_da = new DataAccessMeter(main); +//x s_da.setParent(main); + } + + return s_da; + } +*/ + + + + public void loadConfigIcons() + { + config_icons = new ImageIcon[5]; + config_icons[0] = new ImageIcon(getImage("/icons/cfg_general.png", m_main)); + config_icons[1] = new ImageIcon(getImage("/icons/cfg_medical.png", m_main)); + config_icons[2] = new ImageIcon(getImage("/icons/cfg_print.png", m_main)); + config_icons[3] = new ImageIcon(getImage("/icons/cfg_meter.png", m_main)); + config_icons[4] = new ImageIcon(getImage("/icons/cfg_general.png", m_main)); + + } + + + + + /* + static public DataAccessMeter getInstance() + { + return m_da; + } + */ + + // Method: deleteInstance + /** + * This method sets handle to DataAccessMeter to null and deletes the instance. <br><br> + */ + public void deleteInstance() + { + m_i18n = null; + } + + + public void loadMetersTable() + { + + metersUrl = new Hashtable<String,String>(); + metersNames = new ArrayList<String>(); + + + + metersNames.add("Abbott Diabetes Care"); + metersUrl.put("Abbott Diabetes Care", "abbott.html"); + metersNames.add("Bayer Diagnostics"); + metersUrl.put("Bayer Diagnostics", "bayer.html"); + metersNames.add("Diabetic Supply of Suncoast"); + metersUrl.put("Diabetic Supply of Suncoast", "suncoast.html"); + metersNames.add("Diagnostic Devices"); + metersUrl.put("Diagnostic Devices", "prodigy.html"); + metersNames.add("Arkray USA (formerly Hypoguard)"); + metersUrl.put("Arkray USA (formerly Hypoguard)", "arkray.html"); + metersNames.add("HealthPia America"); + metersUrl.put("HealthPia America", "healthpia.html"); + metersNames.add("Home Diagnostics"); + metersUrl.put("Home Diagnostics", "home_diganostics.html"); + metersNames.add("Lifescan"); + metersUrl.put("Lifescan", "lifescan.html"); + metersNames.add("Nova Biomedical"); + metersUrl.put("Nova Biomedical", "nova_biomedical.html"); + metersNames.add("Roche Diagnostics"); + metersUrl.put("Roche Diagnostics", "roche.html"); + metersNames.add("Sanvita"); + metersUrl.put("Sanvita", "sanvita.html"); + metersNames.add("U.S. Diagnostics"); + metersUrl.put("U.S. Diagnostics", "us_diagnostics.html"); + metersNames.add("WaveSense"); + metersUrl.put("WaveSense", "wavesense.html"); + + } + + + + /* + public void startDb(StatusBarL bar2) + { + GGCDbLoader loader = new GGCDbLoader(this, bar2); + loader.start(); + } */ +/* + public GGCDb getDb() + { + return m_db; + } +*/ + + + public String weblister_title; + + + public abstract void createWebListerItems(); + + + public String getWebListerTitle() + { + return this.weblister_title; + } + + + public String getWebListerDescription() + { + // return this.weblister_title; + return null; + } + + + public ArrayList<String> getWebListerItemsTitles() + { + return null; + } + + public ArrayList<String> getWebListerItemsStatuses() + { + return null; + } + + + + + // ******************************************************** + // ****** Abstract Methods ***** + // ******************************************************** + + + + public String getApplicationName() + { + return "GGC_MeterTool"; + } + + + + public void checkPrerequisites() + { + } + + + public String getImagesRoot() + { + return "/icons/"; + } + + + public void loadBackupRestoreCollection() + { + } + + + + + + // ******************************************************** + // ****** Fonts ***** + // ******************************************************** + + public static final int FONT_BIG_BOLD = 0; + + public static final int FONT_NORMAL = 1; + + public static final int FONT_NORMAL_BOLD = 2; + + public void loadFonts() + { + fonts = new Font[3]; + fonts[0] = new Font("SansSerif", Font.BOLD, 22); + fonts[1] = new Font("SansSerif", Font.PLAIN, 12); + fonts[2] = new Font("SansSerif", Font.BOLD, 12); + } + + public Font getFont(int font_id) + { + return fonts[font_id]; + } + + + + // ******************************************************** + // ****** Icons ***** + // ******************************************************** + + + + + // ******************************************************** + // ****** Db ***** + // ******************************************************** + + + + // ******************************************************** + // ****** Meters ***** + // ******************************************************** + + + // ******************************************************** + // ****** Meters ***** + // ******************************************************** + + public void loadTimeZones() + { + this.timeZones = new Hashtable<String,String>(); + + // Posible needed enchancment. We should probably list all ID's as values. On windows default ID can be different + // as in this table. We should add this names, if we encounter problems. + + addTimeZoneEntry("(GMT+13:00) Nuku'alofa", "Pacific/Tongatapu"); + addTimeZoneEntry("(GMT+12:00) Fiji, Kamchatka, Marshall Is.", "Pacific/Fiji"); + addTimeZoneEntry("(GMT+12:00) Auckland, Wellington", "Pacific/Auckland"); + addTimeZoneEntry("(GMT+11:00) Magadan, Solomon Is., New Caledonia", "Asia/Magadan"); + addTimeZoneEntry("(GMT+10:00) Vladivostok", "Asia/Vladivostok"); + addTimeZoneEntry("(GMT+10:00) Hobart", "Australia/Hobart"); + addTimeZoneEntry("(GMT+10:00) Guam, Port Moresby", "Pacific/Guam"); + addTimeZoneEntry("(GMT+10:00) Canberra, Melbourne, Sydney", "Australia/Sydney"); + addTimeZoneEntry("(GMT+10:00) Brisbane", "Australia/Brisbane"); + addTimeZoneEntry("(GMT+09:30) Adelaide", "Australia/Adelaide"); + addTimeZoneEntry("(GMT+09:00) Yakutsk", "Asia/Yakutsk"); + addTimeZoneEntry("(GMT+09:00) Seoul", "Asia/Seoul"); + addTimeZoneEntry("(GMT+09:00) Osaka, Sapporo, Tokyo", "Asia/Tokyo"); + addTimeZoneEntry("(GMT+08:00) Taipei", "Asia/Taipei"); + addTimeZoneEntry("(GMT+08:00) Perth", "Australia/Perth"); + addTimeZoneEntry("(GMT+08:00) Kuala Lumpur, Singapore", "Asia/Kuala_Lumpur"); + addTimeZoneEntry("(GMT+08:00) Irkutsk, Ulaan Bataar", "Asia/Irkutsk"); + addTimeZoneEntry("(GMT+08:00) Beijing, Chongqing, Hong Kong, Urumqi", "Asia/Hong_Kong"); + addTimeZoneEntry("(GMT+07:00) Krasnoyarsk", "Asia/Krasnoyarsk"); + addTimeZoneEntry("(GMT+07:00) Bangkok, Hanoi, Jakarta", "Asia/Bangkok"); + addTimeZoneEntry("(GMT+06:30) Rangoon", "Asia/Rangoon"); + addTimeZoneEntry("(GMT+06:00) Sri Jayawardenepura", "Asia/Colombo"); + addTimeZoneEntry("(GMT+06:00) Astana, Dhaka", "Asia/Dhaka"); + addTimeZoneEntry("(GMT+06:00) Almaty, Novosibirsk", "Asia/Almaty"); + addTimeZoneEntry("(GMT+05:45) Kathmandu", "Asia/Katmandu"); + addTimeZoneEntry("(GMT+05:30) Chennai, Kolkata, Mumbai, New Delhi", "Asia/Calcutta"); + addTimeZoneEntry("(GMT+05:00) Islamabad, Karachi, Tashkent", "Asia/Karachi"); + addTimeZoneEntry("(GMT+05:00) Ekaterinburg", "Asia/Yekaterinburg"); + addTimeZoneEntry("(GMT+04:30) Kabul", "Asia/Kabul"); + addTimeZoneEntry("(GMT+04:00) Baku, Tbilisi, Yerevan", "Asia/Baku"); + addTimeZoneEntry("(GMT+04:00) Abu Dhabi, Muscat", "Asia/Dubai"); + addTimeZoneEntry("(GMT+03:30) Tehran", "Asia/Tehran"); + addTimeZoneEntry("(GMT+03:00) Nairobi", "Africa/Nairobi"); + addTimeZoneEntry("(GMT+03:00) Moscow, St. Petersburg, Volgograd", "Europe/Moscow"); + addTimeZoneEntry("(GMT+03:00) Kuwait, Riyadh", "Asia/Kuwait"); + addTimeZoneEntry("(GMT+03:00) Baghdad", "Asia/Baghdad"); + addTimeZoneEntry("(GMT+02:00) Jerusalem", "Asia/Jerusalem"); + addTimeZoneEntry("(GMT+02:00) Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius", "Europe/Helsinki"); + addTimeZoneEntry("(GMT+02:00) Harare, Pretoria", "Africa/Harare"); + addTimeZoneEntry("(GMT+02:00) Cairo", "Africa/Cairo"); + addTimeZoneEntry("(GMT+02:00) Bucharest", "Europe/Bucharest"); + addTimeZoneEntry("(GMT+02:00) Athens, Istanbul, Minsk", "Europe/Athens"); + addTimeZoneEntry("(GMT+01:00) West Central Africa", "Africa/Lagos"); + addTimeZoneEntry("(GMT+01:00) Sarajevo, Skopje, Warsaw, Zagreb", "Europe/Warsaw"); + addTimeZoneEntry("(GMT+01:00) Brussels, Copenhagen, Madrid, Paris", "Europe/Brussels"); + addTimeZoneEntry("(GMT+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague", "Europe/Prague,Europe/Belgrade"); + addTimeZoneEntry("(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna", "Europe/Amsterdam"); + addTimeZoneEntry("(GMT) Casablanca, Monrovia", "Africa/Casablanca"); + addTimeZoneEntry("(GMT) Greenwich Mean Time : Dublin, Edinburgh, Lisbon, London", "Europe/Dublin"); + addTimeZoneEntry("(GMT-01:00) Azores", "Atlantic/Azores"); + addTimeZoneEntry("(GMT-01:00) Cape Verde Is.", "Atlantic/Cape_Verde"); + addTimeZoneEntry("(GMT-02:00) Mid-Atlantic", "Atlantic/South_Georgia"); + addTimeZoneEntry("(GMT-03:00) Brasilia", "America/Sao_Paulo"); + addTimeZoneEntry("(GMT-03:00) Buenos Aires, Georgetown", "America/Buenos_Aires"); + addTimeZoneEntry("(GMT-03:00) Greenland", "America/Thule"); + addTimeZoneEntry("(GMT-03:30) Newfoundland", "America/St_Johns"); + addTimeZoneEntry("(GMT-04:00) Atlantic Time (Canada)", "America/Halifax"); + addTimeZoneEntry("(GMT-04:00) Caracas, La Paz", "America/Caracas"); + addTimeZoneEntry("(GMT-04:00) Santiago", "America/Santiago"); + addTimeZoneEntry("(GMT-05:00) Bogota, Lima, Quito", "America/Bogota"); + addTimeZoneEntry("(GMT-05:00) Eastern Time (US & Canada)", " America/New_York"); + addTimeZoneEntry("(GMT-05:00) Indiana (East)", "America/Indianapolis"); + addTimeZoneEntry("(GMT-06:00) Central America", "America/Costa_Rica"); + addTimeZoneEntry("(GMT-06:00) Central Time (US & Canada)", "America/Chicago"); + addTimeZoneEntry("(GMT-06:00) Guadalajara, Mexico City, Monterrey", "America/Mexico_City"); + addTimeZoneEntry("(GMT-06:00) Saskatchewan", "America/Winnipeg"); + addTimeZoneEntry("(GMT-07:00) Arizona", "America/Phoenix"); + addTimeZoneEntry("(GMT-07:00) Chihuahua, La Paz, Mazatlan", "America/Tegucigalpa"); + addTimeZoneEntry("(GMT-07:00) Mountain Time (US & Canada)", "America/Denver"); + addTimeZoneEntry("(GMT-08:00) Pacific Time (US & Canada); Tijuana", "America/Los_Angeles"); + addTimeZoneEntry("(GMT-09:00) Alaska", "America/Anchorage"); + addTimeZoneEntry("(GMT-10:00) Hawaii", "Pacific/Honolulu"); + addTimeZoneEntry("(GMT-11:00) Midway Island, Samoa", "Pacific/Apia"); + addTimeZoneEntry("(GMT-12:00) International Date Line West", "MIT"); + + + this.time_zones_vector = new Vector<String>(); + + for(Enumeration<String> en= this.timeZones.keys(); en.hasMoreElements(); ) + { + this.time_zones_vector.add(en.nextElement()); + } + + + } + + + public void addTimeZoneEntry(String long_desc, String keycode) + { + //SimpleConfigurationTZDialog.time_zones.put(long_desc, keycode); + //SimpleConfigurationTZDialog.time_zones_vector.add(long_desc); + } + + + + + // ******************************************************** + // ****** Settings ***** + // ******************************************************** +/* + public GGCProperties getSettings() + { + return this.m_settings; + } + + public void loadSettingsFromDb() + { + this.m_settings.load(); + } +*/ + public Color getColor(int color) + { + return new Color(color); + } +/* + public ConfigurationManager getConfigurationManager() + { + return this.m_cfgMgr; + } +*/ + + // ******************************************************** + // ****** BG Measurement Type ***** + // ******************************************************** + + public static final int BG_MGDL = 1; + + public static final int BG_MMOL = 2; + + public int getBGMeasurmentType() + { + return this.m_BG_unit; + } + + public void setBGMeasurmentType(int type) + { + this.m_BG_unit = type; + } + + private static final float MGDL_TO_MMOL_FACTOR = 0.0555f; + + private static final float MMOL_TO_MGDL_FACTOR = 18.016f; + + /** + * Depending on the return value of <code>getBGMeasurmentType()</code>, either + * return the mg/dl or the mmol/l value of the database's value. Default is mg/dl. + * @param dbValue - The database's value (in float) + * @return the BG in either mg/dl or mmol/l + */ + public float getDisplayedBG(float dbValue) + { + switch (this.m_BG_unit) + { + case BG_MMOL: + // this POS should return a float rounded to 3 decimal places, + // if I understand the docu correctly + return (new BigDecimal(dbValue * MGDL_TO_MMOL_FACTOR, + new MathContext(3, RoundingMode.HALF_UP)).floatValue()); + case BG_MGDL: + default: + return dbValue; + } + } + + public float getBGValue(float bg_value) + { + switch (this.m_BG_unit) + { + case BG_MMOL: + return (bg_value * MGDL_TO_MMOL_FACTOR); + case BG_MGDL: + default: + return bg_value; + } + } + + + public float getBGValueByType(int type, float bg_value) + { + switch (type) + { + case BG_MMOL: + return (bg_value * MGDL_TO_MMOL_FACTOR); + case BG_MGDL: + default: + return bg_value; + } + } + + + public float getBGValueByType(int input_type, int output_type, float bg_value) + { + + if (input_type==output_type) + return bg_value; + else + { + if (output_type==DataAccessPlugInBase.BG_MGDL) + { + return bg_value * DataAccessPlugInBase.MGDL_TO_MMOL_FACTOR; + } + else + { + return bg_value * DataAccessPlugInBase.MMOL_TO_MGDL_FACTOR; + } + } + + } + + + public float getBGValueDifferent(int type, float bg_value) + { + + if (type==DataAccessPlugInBase.BG_MGDL) + { + return bg_value * DataAccessPlugInBase.MGDL_TO_MMOL_FACTOR; + } + else + { + return bg_value * DataAccessPlugInBase.MMOL_TO_MGDL_FACTOR; + } + } + + + + // ******************************************************** + // ****** Parent handling (for UIs) ***** + // ******************************************************** + + + + /** + * Utils + */ + + + public Image getImage(String filename, Component cmp) + { + Image img; + + InputStream is = this.getClass().getResourceAsStream(filename); + + if (is==null) + System.out.println("Error reading image: "+filename); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try + { + int c; + while ((c = is.read()) >=0) + baos.write(c); + + + //JDialog.getT + //JFrame.getToolkit(); + + if (cmp==null) + cmp = new JLabel(); + + img = cmp.getToolkit().createImage(baos.toByteArray()); + } + catch (IOException ex) + { + ex.printStackTrace(); + return null; + } + return img; + } + + + + // ******************************************************** + // ****** Look and Feel ***** + // ******************************************************** + + + public static String[] getLFData() + { + String out[] = new String[2]; + + try + { + Properties props = new Properties(); + + FileInputStream in = new FileInputStream("../data/GGC_Config.properties"); + props.load(in); + + out[0] = (String)props.get("LF_CLASS"); + out[1] = (String)props.get("SKINLF_SELECTED"); + + return out; + + } + catch(Exception ex) + { + System.out.println("DataAccessMeter::getLFData::Exception> " + ex); + return null; + } + } + + + + + // ******************************************************** + // ****** Dates and Times Handling ***** + // ******************************************************** + + public String getCurrentDateString() + { + GregorianCalendar gc = new GregorianCalendar(); + return gc.get(Calendar.DAY_OF_MONTH) + "." + + (gc.get(Calendar.MONTH) + 1) + "." + gc.get(Calendar.YEAR); + } + + public String[] getMonthsArray() + { + String arr[] = new String[12]; + + arr[0] = m_i18n.getMessage("JANUARY"); + arr[1] = m_i18n.getMessage("FEBRUARY"); + arr[2] = m_i18n.getMessage("MARCH"); + arr[3] = m_i18n.getMessage("APRIL"); + arr[4] = m_i18n.getMessage("MAY"); + arr[5] = m_i18n.getMessage("JUNE"); + arr[6] = m_i18n.getMessage("JULY"); + arr[7] = m_i18n.getMessage("AUGUST"); + arr[8] = m_i18n.getMessage("SEPTEMBER"); + arr[9] = m_i18n.getMessage("OCTOBER"); + arr[10] = m_i18n.getMessage("NOVEMBER"); + arr[11] = m_i18n.getMessage("DECEMBER"); + + return arr; + + } + + public String getDateString(int date) + { + // 20051012 + + int year = date / 10000; + int months = date - (year * 10000); + + months = months / 100; + + int days = date - (year * 10000) - (months * 100); + + if (year == 0) + return getLeadingZero(days, 2) + "/" + getLeadingZero(months, 2); + else + return getLeadingZero(days, 2) + "/" + getLeadingZero(months, 2) + + "/" + year; + } + + public String getTimeString(int time) + { + int hours = time / 100; + int min = time - hours * 100; + + return getLeadingZero(hours, 2) + ":" + getLeadingZero(min, 2); + } + + public String getDateTimeString(long date) + { + return getDateTimeString(date, 1); + } + + public String getDateTimeAsDateString(long date) + { + return getDateTimeString(date, 2); + } + + public String getDateTimeAsTimeString(long date) + { + return getDateTimeString(date, 3); + } + + // ret_type = 1 (Date and time) + // ret_type = 2 (Date) + // ret_type = 3 (Time) + + public static final int DT_DATETIME = 1; + + public static final int DT_DATE = 2; + + public static final int DT_TIME = 3; + + public String getDateTimeString(long dt, int ret_type) + { + + int y = (int) (dt / 100000000L); + dt -= y * 100000000L; + + int m = (int) (dt / 1000000L); + dt -= m * 1000000L; + + int d = (int) (dt / 10000L); + dt -= d * 10000L; + + int h = (int) (dt / 100L); + dt -= h * 100L; + + int min = (i... [truncated message content] |