├── TableUtil ├── nbproject │ ├── .cvsignore │ ├── genfiles.properties │ ├── project.xml │ └── project.properties ├── build.xml └── src │ └── resultsettablemodel │ ├── ResultSetTableModelFactory.java │ └── ResultSetTableModel.java ├── CropPlanning ├── nbproject │ ├── .cvsignore │ ├── configs │ │ └── debug.properties │ ├── genfiles.properties │ └── project.xml ├── manifest.mf ├── cps-icon.icns ├── cps-icon-nobkg.icns ├── cps-icon-nobkg.ico ├── buildnumber.properties ├── cps-icon-nobkg-old.icns ├── wheelhoe-for-twinkle.png ├── src │ └── CPS │ │ ├── Module │ │ ├── CPSModuleMediator.java │ │ ├── CPSUITranslator.java │ │ ├── CPSUIChangeListener.java │ │ ├── CPSUI.java │ │ ├── CPSDisplayable.java │ │ ├── CPSModuleSettings.java │ │ ├── CPSDataUser.java │ │ ├── Extension │ │ │ ├── CPSExtensionUIElement.java │ │ │ ├── CPSExtensible.java │ │ │ ├── CPSExtensionElement.java │ │ │ ├── CPSExtensionPoint.java │ │ │ ├── CPSExtensionDataElement.java │ │ │ └── CPSExtension.java │ │ ├── CPSDataModelSQL.java │ │ ├── CPSDisplayableDataUserModule.java │ │ ├── CPSImportable.java │ │ ├── CPSExportable.java │ │ ├── CPSDataModelUser.java │ │ ├── CPSImporter.java │ │ ├── CPSDataUserModule.java │ │ ├── CPSConfigurable.java │ │ ├── CPSExporter.java │ │ ├── CPSWizardPage.java │ │ └── CPSModule.java │ │ ├── UI │ │ ├── Swing │ │ │ ├── CPSTextComponent.java │ │ │ ├── CPSButtonComponent.java │ │ │ ├── CPSNumberFormatErrorDialog.java │ │ │ ├── CPSHeaderPanel.java │ │ │ ├── CPSErrorDialog.java │ │ │ ├── CPSDocumentChangeListener.java │ │ │ ├── CPSButtonGroup.java │ │ │ ├── CPSComponent.java │ │ │ ├── CPSInfoDialog.java │ │ │ ├── CPSComboBox.java │ │ │ ├── CPSConfirmDialog.java │ │ │ ├── autocomplete │ │ │ │ ├── TextComponentAdaptor.java │ │ │ │ ├── ComboBoxAdaptor.java │ │ │ │ ├── ListAdaptor.java │ │ │ │ ├── ObjectToStringConverter.java │ │ │ │ ├── AutoCompleteComboBoxEditor.java │ │ │ │ └── AbstractAutoCompleteAdaptor.java │ │ │ ├── CPSRadioButton.java │ │ │ ├── CPSCheckBox.java │ │ │ ├── CPSTextArea.java │ │ │ ├── CPSCardPanel.java │ │ │ ├── CPSTextField.java │ │ │ └── CPSDialog.java │ │ └── Modules │ │ │ ├── CPSAdvancedTableFormat.java │ │ │ ├── CPSComparator.java │ │ │ └── CPSMasterDetailModule.java │ │ ├── Core │ │ ├── TODOLists │ │ │ ├── AvailabilityTableFormat.java │ │ │ ├── GHSeedingTableFormat.java │ │ │ ├── DSFieldPlantingTableFormat.java │ │ │ ├── TPFieldPlantingTableFormat.java │ │ │ ├── GoogleCalLoginDialog.java │ │ │ ├── AllPlantingsTableFormat.java │ │ │ └── GoogleCaptchaDialog.java │ │ ├── CropDB │ │ │ ├── CropDBFilterator.java │ │ │ └── CropDB.java │ │ ├── DB │ │ │ ├── CreateRecordsWizardPage.java │ │ │ ├── HSQLDBPopulator.java │ │ │ └── HSQLSettings.java │ │ ├── CropPlans │ │ │ ├── CropPlans.java │ │ │ └── CropPlanFilterator.java │ │ └── UI │ │ │ ├── FrameManager.java │ │ │ ├── SettingsDialog.java │ │ │ └── FirstRunDialog.java │ │ ├── Data │ │ ├── CPSBoolean.java │ │ ├── CPSTextFilter.java │ │ ├── CPSComparators.java │ │ └── CPSPlantingComparator.java │ │ └── CSV │ │ └── CSVTableModel.java ├── appinfo.properties ├── log4j.properties ├── scripts │ └── mkdmg.sh ├── appcast.xml └── Release Notes.txt ├── .gitignore └── .github └── ISSUE_TEMPLATE └── bug_report.md /TableUtil/nbproject/.cvsignore: -------------------------------------------------------------------------------- 1 | private 2 | -------------------------------------------------------------------------------- /CropPlanning/nbproject/.cvsignore: -------------------------------------------------------------------------------- 1 | private 2 | -------------------------------------------------------------------------------- /CropPlanning/nbproject/configs/debug.properties: -------------------------------------------------------------------------------- 1 | run.jvmargs=-Xms256m -Xmx256m 2 | -------------------------------------------------------------------------------- /CropPlanning/manifest.mf: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | X-COMMENT: Main-Class will be added automatically by build 3 | -------------------------------------------------------------------------------- /CropPlanning/cps-icon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/claytonrcarter/cropplanning/HEAD/CropPlanning/cps-icon.icns -------------------------------------------------------------------------------- /CropPlanning/cps-icon-nobkg.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/claytonrcarter/cropplanning/HEAD/CropPlanning/cps-icon-nobkg.icns -------------------------------------------------------------------------------- /CropPlanning/cps-icon-nobkg.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/claytonrcarter/cropplanning/HEAD/CropPlanning/cps-icon-nobkg.ico -------------------------------------------------------------------------------- /CropPlanning/buildnumber.properties: -------------------------------------------------------------------------------- 1 | #Build Number for ANT. Do not edit! 2 | #Mon Feb 08 16:39:34 EST 2016 3 | build.number=158 4 | -------------------------------------------------------------------------------- /CropPlanning/cps-icon-nobkg-old.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/claytonrcarter/cropplanning/HEAD/CropPlanning/cps-icon-nobkg-old.icns -------------------------------------------------------------------------------- /CropPlanning/wheelhoe-for-twinkle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/claytonrcarter/cropplanning/HEAD/CropPlanning/wheelhoe-for-twinkle.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /CropPlanning/nbproject/private/ 2 | .DS_Store 3 | /CropPlanning/build/ 4 | /TableUtil/dist/ 5 | /TableUtil/build/ 6 | /CropPlanning/dist/ 7 | /TableUtil/nbproject/private/ 8 | CropPlanning/appcast-item.xml 9 | CropPlanning/twinkle.properties 10 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Module/CPSModuleMediator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | 6 | package CPS.Module; 7 | 8 | /** 9 | * 10 | */ 11 | public interface CPSModuleMediator { 12 | 13 | public String getCropPlan(); 14 | public String getPlantingCropName(); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 13 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Module/CPSUITranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CPSUITranslator.java 3 | * 4 | * Created on March 15, 2007, 12:52 PM by Clayton 5 | * 6 | * Class to translate between raw data classes (from the DataModel) and 7 | * the UI. 8 | */ 9 | 10 | package CPS.Module; 11 | 12 | import CPS.Data.*; 13 | 14 | public abstract class CPSUITranslator { 15 | 16 | public abstract T convertCrop( CPSCrop c ); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/UI/Swing/CPSTextComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | 6 | package CPS.UI.Swing; 7 | 8 | import CPS.Data.CPSDatum.CPSDatumState; 9 | 10 | /** 11 | * 12 | * @author crcarter 13 | */ 14 | public interface CPSTextComponent extends CPSComponent { 15 | 16 | public void setInitialText( String s ); 17 | public void setInitialText( String s, CPSDatumState c ); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/UI/Swing/CPSButtonComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | 6 | package CPS.UI.Swing; 7 | 8 | import CPS.Data.CPSDatum.CPSDatumState; 9 | 10 | /** 11 | * 12 | * @author crcarter 13 | */ 14 | public interface CPSButtonComponent extends CPSComponent { 15 | 16 | public void setInitialState ( boolean b ); 17 | public void setInitialState ( boolean b, CPSDatumState c ); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /CropPlanning/appinfo.properties: -------------------------------------------------------------------------------- 1 | #Everything can be manually updated except buildnum and builddate. 2 | #Mon, 08 Feb 2016 16:39:34 -0500 3 | #Wed Feb 17 22:10:07 EST 2010 4 | program.PROGNAME=CPS.CropPlanning 5 | program.BUILDNUM=157 6 | program.AUTHOR=Clayton Carter 7 | program.BUILDDATE=20160239163934 8 | program.DESCRIPTION=Crop Planning Software 9 | program.COPYRIGHT=2013 10 | program.VERSION=0.7.0 11 | program.COMPANY= 12 | program.WEBSITE=http\://code.google.com/p/cropplanning/ 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /CropPlanning/nbproject/genfiles.properties: -------------------------------------------------------------------------------- 1 | build.xml.data.CRC32=7fb3f7b5 2 | build.xml.script.CRC32=ddf9ff9c 3 | build.xml.stylesheet.CRC32=958a1d3e 4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. 5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. 6 | nbproject/build-impl.xml.data.CRC32=0d4963bd 7 | nbproject/build-impl.xml.script.CRC32=f5de892a 8 | nbproject/build-impl.xml.stylesheet.CRC32=05530350@1.79.1.48 9 | -------------------------------------------------------------------------------- /TableUtil/nbproject/genfiles.properties: -------------------------------------------------------------------------------- 1 | build.xml.data.CRC32=bf766dae 2 | build.xml.script.CRC32=b6966887 3 | build.xml.stylesheet.CRC32=8064a381@1.68.1.46 4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. 5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. 6 | nbproject/build-impl.xml.data.CRC32=bf766dae 7 | nbproject/build-impl.xml.script.CRC32=73809570 8 | nbproject/build-impl.xml.stylesheet.CRC32=05530350@1.79.1.48 9 | -------------------------------------------------------------------------------- /CropPlanning/log4j.properties: -------------------------------------------------------------------------------- 1 | 2 | #define the console appender 3 | log4j.appender.consoleAppender = org.apache.log4j.ConsoleAppender 4 | 5 | # now define the layout for the appender 6 | log4j.appender.consoleAppender.layout = org.apache.log4j.PatternLayout 7 | log4j.appender.consoleAppender.layout.ConversionPattern=%-5p %c %x - %m%n 8 | 9 | # now map our console appender as a root logger, means all log messages will go to this appender 10 | log4j.rootLogger = DEBUG, consoleAppender 11 | 12 | log4j.logger.persist.engine=INFO 13 | log4j.logger.persist.parameters=INFO 14 | log4j.logger.persist.results=INFO 15 | log4j.logger.persist.profiling=INFO 16 | -------------------------------------------------------------------------------- /TableUtil/nbproject/project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.netbeans.modules.java.j2seproject 4 | 5 | 6 | TableUtil 7 | 1.6.5 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Module/CPSUIChangeListener.java: -------------------------------------------------------------------------------- 1 | /* Copyright (C) Jan 18, 2008 Clayton Carter */ 2 | 3 | 4 | package CPS.Module; 5 | 6 | /** 7 | * a CPSUIChangeListener is an object that wishes to be notified of changes which might affect 8 | * the layout of the UI 9 | * 10 | * @author Clayton Carter 11 | */ 12 | public interface CPSUIChangeListener { 13 | 14 | /** 15 | * This is called whenever a CPSDisplayableModule (to which this object has been added via 16 | * the CPSDisplayableModule.addUIChangeListener() method) has affect the UI in such a way 17 | * that it might need to be laidout again. 18 | * @deprecated 19 | */ 20 | public void uiChanged(); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Module/CPSUI.java: -------------------------------------------------------------------------------- 1 | package CPS.Module; 2 | 3 | import javax.swing.JPanel; 4 | 5 | public abstract class CPSUI extends CPSModule implements CPSUIChangeListener { 6 | 7 | // methods 8 | public abstract void showUI (); 9 | public abstract String showFirstRunDialog( String defaultDir ); 10 | public abstract boolean showFirstRunPreInitWizard( CPSGlobalSettings globSet ); 11 | public abstract void addModule ( CPSDisplayableDataUserModule mod ); 12 | public abstract void addModule ( String name, JPanel content ); 13 | 14 | public abstract void addModuleConfiguration( CPSConfigurable config ); 15 | public abstract void addExporter( CPSExporter ex ); 16 | public abstract void addImporter( CPSImporter im ); 17 | 18 | public abstract boolean showFirstRunPostInitWizard ( CPSGlobalSettings globSet ); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Module/CPSDisplayable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | */ 4 | 5 | package CPS.Module; 6 | 7 | import java.awt.Dimension; 8 | import javax.swing.JPanel; 9 | 10 | /** 11 | * 12 | * @author Clayton 13 | */ 14 | public interface CPSDisplayable { 15 | 16 | public abstract JPanel display(); 17 | public abstract Dimension getSize(); 18 | 19 | /** 20 | * Add a CPSUIChangeListener to the list of of modules that wish to be notified when this 21 | * module has updated it's UI. 22 | * @param ucl The CPSUIChangeListener to be added (and subsequently notified) 23 | */ 24 | public void addUIChangeListener( CPSUIChangeListener ucl ); 25 | /** 26 | * this should be protected; FOR INTERNAL USE ONLY 27 | * This method is called whenever there is a change or update in this modules UI. It notifies 28 | * all UI change listeners that the UI has been updated and that they should lay out their UI 29 | * again. 30 | */ 31 | public void signalUIChanged(); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Module/CPSModuleSettings.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | 6 | package CPS.Module; 7 | 8 | import java.util.prefs.Preferences; 9 | import javax.swing.BorderFactory; 10 | import javax.swing.JPanel; 11 | import net.miginfocom.swing.MigLayout; 12 | 13 | 14 | public abstract class CPSModuleSettings { 15 | 16 | protected Preferences prefs = null; 17 | protected JPanel configPanel = null; 18 | 19 | public CPSModuleSettings() { 20 | // prefs = Preferences.userNodeForPackage( this.getClass() ); 21 | } 22 | 23 | public CPSModuleSettings( Class c ) { 24 | prefs = Preferences.userNodeForPackage( c ); 25 | } 26 | 27 | public Preferences getModulePreferences() { 28 | return prefs; 29 | } 30 | 31 | protected void initConfigPanel() { 32 | configPanel = new JPanel( new MigLayout( "", "[align right][]" ) ); 33 | configPanel.setBorder( BorderFactory.createEtchedBorder() ); 34 | } 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Module/CPSDataUser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | */ 4 | 5 | package CPS.Module; 6 | 7 | /** 8 | * 9 | * @author Clayton 10 | */ 11 | public interface CPSDataUser { 12 | 13 | /** 14 | * Register the data source for this module and signal that the data is ready to be used. 15 | * @param dm a CPSDataModel to use as the data source for this module 16 | */ 17 | public void setDataSource( CPSDataModel dm ); 18 | /** this should be protected; FOR INTERNAL USE ONLY */ 19 | public CPSDataModel getDataSource(); 20 | 21 | /** this should be protected; FOR INTERNAL USE ONLY */ 22 | public boolean isDataAvailable(); 23 | /** this should be protected; FOR INTERNAL USE ONLY */ 24 | public void setDataAvailable( boolean b ); 25 | /** this should be protected; FOR INTERNAL USE ONLY */ 26 | public void setDataAvailable(); 27 | 28 | /** 29 | * This method is called by the DataSource whenever the data has been updated 30 | * and the DataListeners are updated. Every CPSDataModelUser should use this 31 | * method to update and/or refresh the data they are currently using. 32 | */ 33 | public abstract void dataUpdated(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Module/Extension/CPSExtensionUIElement.java: -------------------------------------------------------------------------------- 1 | /* CPSExtensionUIElement - created: Dec 30, 2008 2 | * Copyright (C) 2008 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | * 22 | */ 23 | 24 | package CPS.Module.Extension; 25 | 26 | /** 27 | * 28 | */ 29 | public interface CPSExtensionUIElement extends CPSExtensionElement { 30 | 31 | } 32 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Module/Extension/CPSExtensible.java: -------------------------------------------------------------------------------- 1 | /* CPSExtensible.java - created: Dec 29, 2008 2 | * Copyright (C) 2008 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | * 22 | */ 23 | 24 | package CPS.Module.Extension; 25 | 26 | /** 27 | * An interface to define how and where a module can be extended. 28 | */ 29 | public interface CPSExtensible { 30 | 31 | } 32 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Module/Extension/CPSExtensionElement.java: -------------------------------------------------------------------------------- 1 | /* CPSExtensionElement.java - created: Dec 30, 2008 2 | * Copyright (C) 2008 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | * 22 | */ 23 | 24 | package CPS.Module.Extension; 25 | 26 | /** 27 | * The base interface from which all other Extension Elements are derived. 28 | */ 29 | public interface CPSExtensionElement { 30 | 31 | } 32 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Module/CPSDataModelSQL.java: -------------------------------------------------------------------------------- 1 | /* CPSDataModelSQL.java - created: Dec 19, 2008 2 | * Copyright (C) 2008 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | * 22 | */ 23 | 24 | package CPS.Module; 25 | 26 | import java.sql.Connection; 27 | 28 | public abstract class CPSDataModelSQL extends CPSDataModel { 29 | 30 | public CPSDataModelSQL() { super(); } 31 | 32 | // public abstract Connection getConnection(); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Module/CPSDisplayableDataUserModule.java: -------------------------------------------------------------------------------- 1 | package CPS.Module; 2 | 3 | import java.util.ArrayList; 4 | 5 | public abstract class CPSDisplayableDataUserModule extends CPSDataUserModule 6 | implements CPSDisplayable { 7 | 8 | /** An ArrayList of CPSUIChangeListeners which will be notified when this module has changed or 9 | * updated its UI in such a way that the overall program might to be laid out again. 10 | */ 11 | protected ArrayList changeListeners = new ArrayList(); 12 | /** 13 | * Add a CPSUIChangeListener to the list of of modules that wish to be notified when this 14 | * module has updated it's UI. 15 | * @param ucl The CPSUIChangeListener to be added (and subsequently notified) 16 | */ 17 | public void addUIChangeListener( CPSUIChangeListener ucl ) { changeListeners.add( ucl ); } 18 | /** 19 | * This method is called whenever there is a change or update in this modules UI. It notifies 20 | * all UI change listeners that the UI has been updated and that they should lay out their UI 21 | * again. 22 | */ 23 | public void signalUIChanged() { 24 | for ( CPSUIChangeListener ucl : changeListeners ) 25 | ucl.uiChanged(); 26 | } 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Module/CPSImportable.java: -------------------------------------------------------------------------------- 1 | /* CPSImportable.java - created: Apr 3, 2008 2 | * Copyright (C) 2008 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | * 22 | */ 23 | 24 | package CPS.Module; 25 | 26 | /** 27 | * A simple interface by which modules can "expose" themselves to importable data. 28 | * @author Clayton Carter 29 | */ 30 | public interface CPSImportable { 31 | 32 | public String getImportName(); 33 | public void importData( CPSImporter im ); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Module/Extension/CPSExtensionPoint.java: -------------------------------------------------------------------------------- 1 | /* CPSExtensionPoint.java - created: Dec 30, 2008 2 | * Copyright (C) 2008 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | * 22 | */ 23 | 24 | package CPS.Module.Extension; 25 | 26 | /** 27 | * Extension points are the pieces of an Extensible module to which ExtensionElements can attach. Every CPSExtensible 28 | * object is really made up of a number of CPSExtensionPoints. 29 | */ 30 | public interface CPSExtensionPoint { 31 | 32 | } 33 | -------------------------------------------------------------------------------- /CropPlanning/nbproject/project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.netbeans.modules.java.j2seproject 4 | 5 | 6 | CropPlanning 7 | 1.6.5 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | Persist 16 | jar 17 | 18 | jar 19 | clean 20 | jar 21 | 22 | 23 | Twinkle 24 | jar 25 | 26 | jar 27 | clean 28 | jar 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Module/CPSExportable.java: -------------------------------------------------------------------------------- 1 | /* CPSExportable.java - created: Feb 5, 2008 2 | * Copyright (C) 2008 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | * 22 | */ 23 | 24 | package CPS.Module; 25 | 26 | /** 27 | * A simple interface to define a way by this modules (or anything, for that matter) 28 | * may reveal themselves as having data to export and then to actually export 29 | * said data. 30 | */ 31 | public interface CPSExportable { 32 | 33 | public String getExportName(); 34 | public void exportData(); 35 | public void exportData( CPSExporter ex ); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /CropPlanning/scripts/mkdmg.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # This script taken verbatim from the JarBundler ANT task package. Some comments added. 5 | # 12/10/08 6 | # 7 | 8 | # base location of the project of the SRC and DEST folders 9 | BASE="$1" 10 | # location of the directory to be turned into a disk image 11 | SRC="$2" 12 | # location of the directory where the files will be prepped and worked on 13 | DEST="$3" 14 | # base name of the created image (without extension) 15 | VOLUME="$4" 16 | 17 | echo Base Directory: `pwd`/$1 18 | echo Source Dir: $2 19 | echo Destination Dir: $3 20 | echo Volume Name: $4 21 | 22 | TEMP="TEMPORARY" 23 | 24 | cd $BASE 25 | 26 | if [[ -e $DEST/$VOLUME.dmg ]]; 27 | then 28 | echo Removing old disk image: $DEST/$VOLUME.dmg 29 | rm $DEST/$VOLUME.dmg 30 | fi 31 | 32 | # create 10MB image 33 | hdiutil create -megabytes 25 $DEST/$TEMP.dmg -layout NONE 34 | MY_DISK=`hdid -nomount $DEST/$TEMP.dmg` 35 | 36 | # mount and unmount the image 37 | newfs_hfs -v $VOLUME $MY_DISK 38 | hdiutil eject $MY_DISK 39 | 40 | # remount the image 41 | hdid $DEST/$TEMP.dmg 42 | 43 | # change file permissions of source files and copy source files onto image 44 | # chflags -R nouchg,noschg "$SRC" 45 | ditto -rsrc -v "$SRC" "/Volumes/$VOLUME" 46 | # ditto -rsrcFork -v "./background/" "/Volumes/$VOLUME" 47 | 48 | # eject volume convert and change settings of the image 49 | hdiutil eject $MY_DISK 50 | hdiutil convert -format UDCO $DEST/$TEMP.dmg -o $DEST/$VOLUME.dmg 51 | hdiutil internet-enable -yes $DEST/$VOLUME.dmg 52 | 53 | # clean up temp file 54 | rm $DEST/$TEMP.dmg -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Module/CPSDataModelUser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CPSDataModelUser.java 3 | * 4 | * Created on March 14, 2007, 1:16 PM 5 | * 6 | * 7 | */ 8 | 9 | package CPS.Module; 10 | 11 | /** 12 | * 13 | * @author Clayton 14 | */ 15 | public abstract class CPSDataModelUser implements CPSDataUser { 16 | 17 | protected boolean dataAvail = false; 18 | private CPSDataModel dataModel = null; 19 | 20 | /** 21 | * Register the data source for this module and signal that the data is ready to be used. 22 | * @param dm a CPSDataModel to use as the data source for this module 23 | */ 24 | public void setDataSource( CPSDataModel dm ) { 25 | if ( dm != null ) { 26 | dataModel = dm; 27 | setDataAvailable(); 28 | getDataSource().addDataListener( this ); 29 | } 30 | } 31 | public CPSDataModel getDataSource() { return dataModel; } 32 | 33 | public boolean isDataAvailable() { return dataAvail; } 34 | public void setDataAvailable( boolean b ) { dataAvail = b; } 35 | public void setDataAvailable() { setDataAvailable(true); } 36 | 37 | /** 38 | * This method is called by the DataSource whenever the data has been updated 39 | * and the DataListeners are updated. Every CPSDataModelUser should use this 40 | * method to update and/or refresh the data they are currently using. 41 | */ 42 | public abstract void dataUpdated(); 43 | 44 | 45 | protected void debug( String message ) { 46 | CPSModule.debug( this.getClass().getName(), message ); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /CropPlanning/appcast.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Crop Planning Software's Changelog 5 | http://cropplanning.googlecode.com/files/appcast.xml 6 | Most recent changes with links to updates. 7 | en 8 | 9 | Crop Planning Software Version 0.5.5 10 | 02/15/2013 11 | http://www.failbetterfarm.com/cps/ReleaseNotes0.5.5.html 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Module/Extension/CPSExtensionDataElement.java: -------------------------------------------------------------------------------- 1 | /* CPSExtensionElement.java - created: Dec 30, 2008 2 | * Copyright (C) 2008 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | * 22 | */ 23 | 24 | package CPS.Module.Extension; 25 | 26 | import CPS.Module.CPSDataModel; 27 | 28 | /** 29 | * An interface for the pieces or elements that make up an extension. These elements are what actually attach 30 | * to the extension points of extensible modules. 31 | */ 32 | public interface CPSExtensionDataElement extends CPSExtensionElement { 33 | 34 | public void recieveDataModel( CPSDataModel dm ); 35 | 36 | public void newDataFor( int id ); 37 | public void loadDataFor( int id ); 38 | public void saveDataFor( int id ); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/UI/Swing/CPSNumberFormatErrorDialog.java: -------------------------------------------------------------------------------- 1 | /* CPSNumberFormatErrorDialog.java - created: Feb 13, 2014 2 | /* 3 | * This file is part of the project "Crop Planning Software". For more 4 | * information: 5 | * website: https://github.com/claytonrcarter/cropplanning 6 | * email: cropplanning@gmail.com 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | package CPS.UI.Swing; 23 | 24 | import javax.swing.JPanel; 25 | 26 | /** 27 | * 28 | * @author crcarter 29 | */ 30 | public class CPSNumberFormatErrorDialog extends CPSErrorDialog { 31 | 32 | public CPSNumberFormatErrorDialog( JPanel parent ) { 33 | super( parent, 34 | "Cannot Save Changes", 35 | "
Couldn't understand one of the numbers
" + 36 | "you entered. Numbers should be entered
" + 37 | "without units. (eg 12 instead of 12in or 12\")
" + 38 | "No changes are being saved." ); 39 | } 40 | 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/UI/Swing/CPSHeaderPanel.java: -------------------------------------------------------------------------------- 1 | /* CPSHeaderPanel.java - created: Mar 7, 2008 2 | * Copyright (C) 2008 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | * 22 | */ 23 | 24 | package CPS.UI.Swing; 25 | 26 | import java.awt.Dimension; 27 | import org.jdesktop.swingx.JXHeader; 28 | 29 | public class CPSHeaderPanel extends JXHeader { 30 | 31 | int width = -1; 32 | 33 | protected void setWidth( int i ) { 34 | width = i; 35 | } 36 | 37 | @Override 38 | public Dimension getPreferredScrollableViewportSize() { 39 | if ( width == -1 ) 40 | return super.getPreferredScrollableViewportSize(); 41 | else 42 | return new Dimension( width, 43 | super.getPreferredScrollableViewportSize().height ); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/UI/Modules/CPSAdvancedTableFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CPSAdvancedTableFormat.java - created: Dec 9, 2009 3 | * Copyright (c) **YEAR** Expected hash. user evaluated instead to freemarker.template.SimpleScalar on line 5, column 43 in Templates/Licenses/preamble.txt. 4 | * 5 | /* 6 | * To change this template, choose Tools | Templates 7 | * and open the template in the editor. 8 | */ 9 | 10 | package CPS.UI.Modules; 11 | 12 | import CPS.Data.CPSRecord; 13 | import ca.odell.glazedlists.gui.AdvancedTableFormat; 14 | import java.util.Comparator; 15 | 16 | public abstract class CPSAdvancedTableFormat implements AdvancedTableFormat { 17 | 18 | /** @return true is the column at index colNum should be displayed by default, false otherwise */ 19 | public abstract boolean isDefaultColumn( int colNum ); 20 | 21 | /** @return the column number which is the default column to sort on */ 22 | public abstract int getDefaultSortColumn(); 23 | 24 | /** @return the property number for the data displayed in column at index colNum */ 25 | public abstract int getPropNumForColumn( int colNum ); 26 | 27 | public abstract T getBlankRecord(); 28 | 29 | public String getColumnName( int colNum ) { 30 | 31 | return ((CPSRecord) getBlankRecord()).getDatum( getPropNumForColumn( colNum ) ).getName(); 32 | 33 | } 34 | 35 | public Class getColumnClass( int colNum ) { 36 | 37 | return getColumnValue( getBlankRecord(), colNum ).getClass(); 38 | 39 | } 40 | 41 | public Comparator getColumnComparator( int colNum ) { 42 | 43 | // return GlazedLists.comparableComparator(); 44 | return new CPSComparator( getPropNumForColumn( colNum ) ); 45 | 46 | } 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/UI/Swing/CPSErrorDialog.java: -------------------------------------------------------------------------------- 1 | /* CPSCpnfirmDialog.java 2 | * Copyright (C) 2013 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | */ 22 | package CPS.UI.Swing; 23 | 24 | import java.awt.Component; 25 | import javax.swing.JLabel; 26 | 27 | public class CPSErrorDialog extends CPSInfoDialog { 28 | 29 | 30 | public CPSErrorDialog( Component parent, String problem ) { 31 | this( parent, "Error", problem ); 32 | } 33 | 34 | public CPSErrorDialog( Component parent, String header, String problem ) { 35 | super( parent, header, 36 | "Sorry, but we encountered a problem" + 37 | ( problem.equals( "" ) ? "." : ":
" + problem )); 38 | } 39 | 40 | public static void main(String[] args) { 41 | new CPSErrorDialog( new JLabel(), "fart").setVisible(true); 42 | System.exit(0); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Module/CPSImporter.java: -------------------------------------------------------------------------------- 1 | /* CPSImporter.java - Created: Mar 29, 2008 2 | * Copyright (C) 2008 sm_zl_kimi 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | * 22 | */ 23 | 24 | package CPS.Module; 25 | 26 | import CPS.Data.CPSCrop; 27 | import CPS.Data.CPSPlanting; 28 | import java.util.ArrayList; 29 | /** 30 | * A simple interface for classes that provide the capabilty to import 31 | * data to the file system. 32 | */ 33 | public interface CPSImporter { 34 | 35 | public ArrayList importCropsAndVarieties( String filename ); 36 | 37 | public ArrayList importCropPlan( String filename ); 38 | /** 39 | * Returns the default file extension used by this importer. 40 | * @return the default file extension WITHOUT a leading period (".") 41 | */ 42 | public String getImportFileDefaultExtension(); 43 | 44 | } 45 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Module/CPSDataUserModule.java: -------------------------------------------------------------------------------- 1 | /* Copyright (C) Jan 18, 2008 Clayton Carter */ 2 | 3 | 4 | package CPS.Module; 5 | 6 | /** 7 | * The code in this file should mirror, more or less, that in CPSDataModelUser.java 8 | * 9 | * @author Clayton Carter 10 | */ 11 | public abstract class CPSDataUserModule extends CPSModule implements CPSDataUser { 12 | 13 | protected boolean dataAvail = false; 14 | private CPSDataModel dataModel = null; 15 | private CPSModuleMediator modmed = null; 16 | 17 | /** 18 | * Register the data source for this module and signal that the data is ready to be used. 19 | * @param dm a CPSDataModel to use as the data source for this module 20 | */ 21 | public void setDataSource( CPSDataModel dm ) { 22 | if ( dm != null ) { 23 | dataModel = dm; 24 | setDataAvailable(); 25 | getDataSource().addDataListener( this ); 26 | } 27 | } 28 | public CPSDataModel getDataSource() { return dataModel; } 29 | 30 | public boolean isDataAvailable() { return dataAvail; } 31 | public void setDataAvailable( boolean b ) { dataAvail = b; } 32 | public void setDataAvailable() { setDataAvailable(true); } 33 | 34 | /** 35 | * This method is called by the DataSource whenever the data has been updated 36 | * and the DataListeners are updated. Every CPSDataModelUser should use this 37 | * method to update and/or refresh the data they are currently using. 38 | */ 39 | public abstract void dataUpdated(); 40 | 41 | public void setMediator( CPSModuleMediator modmed ) { 42 | this.modmed = modmed; 43 | } 44 | 45 | protected CPSModuleMediator getMediator() { 46 | return modmed; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Module/CPSConfigurable.java: -------------------------------------------------------------------------------- 1 | /* CPSConfigurable.java - created: Feb 12, 2008 2 | * Copyright (C) 2008 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | * 22 | */ 23 | 24 | package CPS.Module; 25 | 26 | import javax.swing.JPanel; 27 | import org.netbeans.spi.wizard.WizardPage; 28 | 29 | /** 30 | * An interface for working with modules which have or provide "settings" 31 | * or confguration "options". 32 | */ 33 | public interface CPSConfigurable { 34 | 35 | public String getModuleName(); 36 | public JPanel getConfigurationDisplay(); 37 | public CPSWizardPage[] getConfigurationWizardPages(); 38 | // public void receiveGlobalSettings( CPSGlobalSettings globalSettings ); 39 | 40 | public void saveConfiguration(); 41 | public void resetConfiguration(); 42 | public void resetConfigurationToDefaults(); 43 | 44 | } 45 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Core/TODOLists/AvailabilityTableFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package CPS.Core.TODOLists; 6 | 7 | import CPS.Data.CPSPlanting; 8 | import CPS.UI.Modules.CPSAdvancedTableFormat; 9 | 10 | /** 11 | * 12 | * @author crcarter 13 | */ 14 | public class AvailabilityTableFormat extends CPSAdvancedTableFormat { 15 | 16 | public int getColumnCount() { return 4; } 17 | 18 | public String getColumnName(int column) { 19 | 20 | CPSPlanting p = new CPSPlanting(); 21 | 22 | switch ( column ) { 23 | case 0: return p.getDatum( CPSPlanting.PROP_CROP_NAME ).getName(); 24 | case 1: return p.getDatum( CPSPlanting.PROP_VAR_NAME ).getName(); 25 | case 2: return "Plantings"; 26 | case 3: return "Harvest Dates"; 27 | default: return ""; 28 | } 29 | 30 | } 31 | 32 | public Object getColumnValue( CPSPlanting p, int column) { 33 | 34 | switch ( column ) { 35 | case 0: return p.getCropName(); 36 | case 1: return p.getVarietyName(); 37 | case 2: return p.getMaturityDays(); 38 | case 3: return p.getCustomField1(); 39 | default: return ""; 40 | } 41 | 42 | } 43 | 44 | @Override 45 | public boolean isDefaultColumn(int colNum) { return true; } 46 | 47 | @Override 48 | public int getDefaultSortColumn() { return 0; } 49 | 50 | @Override 51 | public int getPropNumForColumn(int colNum) { 52 | switch ( colNum ) { 53 | case 0: return CPSPlanting.PROP_CROP_NAME; 54 | case 1: return CPSPlanting.PROP_VAR_NAME; 55 | case 2: return CPSPlanting.PROP_MAT_ADJUST; 56 | case 3: return CPSPlanting.PROP_CUSTOM1; 57 | default: return CPSPlanting.PROP_ID; 58 | } 59 | } 60 | 61 | @Override 62 | public CPSPlanting getBlankRecord() { return new CPSPlanting(); } 63 | 64 | 65 | 66 | } 67 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/UI/Swing/CPSDocumentChangeListener.java: -------------------------------------------------------------------------------- 1 | /* CPSDocumentChangeListener.java 2 | * Copyright (C) 2007, 2008 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | */ 22 | 23 | package CPS.UI.Swing; 24 | 25 | import javax.swing.event.DocumentEvent; 26 | import javax.swing.event.DocumentListener; 27 | 28 | /** 29 | * CPSDocumentListener - a document listener that simply records when a text 30 | * component has changed from it's ititial state 31 | */ 32 | public class CPSDocumentChangeListener implements DocumentListener { 33 | 34 | CPSComponent comp; 35 | 36 | public CPSDocumentChangeListener( CPSComponent c ) { 37 | comp = c; 38 | } 39 | 40 | private void updateComponentChanged() { 41 | comp.setHasChanged(true); 42 | comp.setBackgroundChanged(); 43 | } 44 | 45 | public void insertUpdate(DocumentEvent e) { updateComponentChanged(); } 46 | public void removeUpdate(DocumentEvent e) { updateComponentChanged(); } 47 | public void changedUpdate(DocumentEvent e) {} 48 | 49 | } 50 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/UI/Swing/CPSButtonGroup.java: -------------------------------------------------------------------------------- 1 | /* CPSButtonGroup.java - created: Mar 9, 2008 2 | * Copyright (C) 2008 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | * 22 | */ 23 | 24 | package CPS.UI.Swing; 25 | 26 | import CPS.Data.CPSDatum.CPSDatumState; 27 | import java.util.List; 28 | import javax.swing.AbstractButton; 29 | 30 | public class CPSButtonGroup extends JButtonGroup { 31 | 32 | public CPSButtonGroup( AbstractButton[] ab ) { 33 | super(ab); 34 | } 35 | 36 | public void setInitialSelection( AbstractButton button, boolean selected, CPSDatumState cds ) { 37 | 38 | unselectAll(); 39 | lastSelectedButton = null; 40 | 41 | List bs = getButtonsList(); 42 | bs.remove(button); 43 | for ( AbstractButton b : bs ) { 44 | if ( b instanceof CPSRadioButton ) 45 | ((CPSRadioButton) b).resetState(); 46 | } 47 | 48 | if ( button instanceof CPSRadioButton ) 49 | ( (CPSRadioButton) button ).doInitialClick( cds ); 50 | 51 | } 52 | 53 | 54 | 55 | } 56 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Module/CPSExporter.java: -------------------------------------------------------------------------------- 1 | /* CPSExporter.java - Created: Feb 5, 2008 2 | * Copyright (C) 2008 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | * 22 | */ 23 | 24 | package CPS.Module; 25 | 26 | import CPS.Data.CPSCrop; 27 | import CPS.Data.CPSPlanting; 28 | import java.util.List; 29 | import javax.swing.JTable; 30 | 31 | /** 32 | * A simple interface for classes that provide the capabilty to export 33 | * data to the file system. 34 | */ 35 | public interface CPSExporter { 36 | 37 | public void exportCropsAndVarieties( String filename, 38 | List crops ); 39 | public void exportCropPlan( String filename, 40 | String planName, 41 | List plantings ); 42 | 43 | public void exportJTable( String filename, String title, JTable table ); 44 | 45 | /** 46 | * Returns the default file extension used by this exporter. 47 | * @return the default file extension WITHOUT a leading period (".") 48 | */ 49 | public String getExportFileDefaultExtension(); 50 | 51 | } 52 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Data/CPSBoolean.java: -------------------------------------------------------------------------------- 1 | /* CPSBoolean.java - created: Mar 8, 2008 2 | * Copyright (C) 2008 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | * 22 | */ 23 | 24 | package CPS.Data; 25 | 26 | public class CPSBoolean { 27 | 28 | private Boolean value; 29 | 30 | public CPSBoolean( Boolean b ) { 31 | value = b; 32 | } 33 | 34 | public CPSBoolean( boolean b ) { 35 | this( new Boolean(b) ); 36 | } 37 | 38 | 39 | public CPSBoolean not() { 40 | if ( isNull() ) 41 | return new CPSBoolean( null ); 42 | else 43 | return new CPSBoolean( ! booleanValue() ); 44 | } 45 | 46 | 47 | public boolean isNull() { 48 | return value == null; 49 | } 50 | 51 | 52 | 53 | public boolean booleanValue() { 54 | if ( isNull() ) 55 | return false; 56 | else 57 | return value.booleanValue(); 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | if ( isNull() ) 63 | return "null"; 64 | else 65 | return value.toString(); 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/UI/Swing/CPSComponent.java: -------------------------------------------------------------------------------- 1 | /* CPSComponent.java 2 | * Copyright (C) 2007, 2008 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | */ 22 | 23 | package CPS.UI.Swing; 24 | 25 | import java.awt.Color; 26 | 27 | /** 28 | * CPSComponent - a simple interface to allow our custom Swing components to 29 | * record and retrieve whether they have been altered. 30 | */ 31 | public interface CPSComponent { 32 | 33 | Color SKY_BLUE = new Color( 135, 206, 235 ); 34 | Color LIGHT_BLUE = new Color( 173, 216, 230 ); /* same color as text selection */ 35 | Color LIGHT_GREEN = new Color( 152, 251, 152 ); 36 | Color LIGHT_RED = new Color( 255, 192, 203 ); 37 | Color COLOR_INHERITED = SKY_BLUE; 38 | Color COLOR_CALCULATED = LIGHT_GREEN; 39 | Color COLOR_CHANGED = LIGHT_RED; 40 | Color COLOR_NORMAL = Color.WHITE; 41 | 42 | public boolean hasChanged(); 43 | public void setHasChanged( boolean b ); 44 | public void setBackgroundInherited(); 45 | public void setBackgroundCalculated(); 46 | public void setBackgroundChanged(); 47 | public void setBackgroundNormal(); 48 | 49 | } 50 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Core/TODOLists/GHSeedingTableFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | 6 | package CPS.Core.TODOLists; 7 | 8 | import CPS.Data.CPSPlanting; 9 | import CPS.UI.Modules.CPSAdvancedTableFormat; 10 | 11 | /** 12 | * 13 | * @author kendra 14 | */ 15 | public class GHSeedingTableFormat extends CPSAdvancedTableFormat { 16 | 17 | public int getColumnCount() { return 9; } 18 | 19 | public Object getColumnValue( CPSPlanting p, int arg1 ) { 20 | 21 | switch ( arg1 ) { 22 | case 0: return p.getDateToPlant(); 23 | case 1: return p.getCropName(); 24 | case 2: return p.getVarietyName(); 25 | case 3: return p.getPlantsNeeded(); 26 | case 4: return p.getPlantsToStart(); 27 | case 5: return p.getFlatSize(); 28 | case 6: return p.getSeedsPer(); 29 | case 7: return p.getFlatsNeeded(); 30 | case 8: return p.getPlantingNotesInherited(); 31 | default: return ""; 32 | } 33 | } 34 | 35 | @Override 36 | public CPSPlanting getBlankRecord() { 37 | return new CPSPlanting(); 38 | } 39 | 40 | @Override 41 | public int getDefaultSortColumn() { 42 | return 0; 43 | } 44 | 45 | @Override 46 | public int getPropNumForColumn(int colNum) { 47 | 48 | switch ( colNum ) { 49 | case 0: return CPSPlanting.PROP_DATE_PLANT; 50 | case 1: return CPSPlanting.PROP_CROP_NAME; 51 | case 2: return CPSPlanting.PROP_VAR_NAME; 52 | case 3: return CPSPlanting.PROP_PLANTS_NEEDED; 53 | case 4: return CPSPlanting.PROP_PLANTS_START; 54 | case 5: return CPSPlanting.PROP_FLAT_SIZE; 55 | case 6: return CPSPlanting.PROP_SEEDS_PER_TP; 56 | case 7: return CPSPlanting.PROP_FLATS_NEEDED; 57 | case 8: return CPSPlanting.PROP_PLANTING_NOTES; 58 | default: return CPSPlanting.PROP_ID; 59 | } 60 | } 61 | 62 | @Override 63 | public boolean isDefaultColumn(int colNum) { 64 | return true; 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Core/CropDB/CropDBFilterator.java: -------------------------------------------------------------------------------- 1 | /* CropDBFilterator.java - Created: Nov 9, 2009 2 | * Copyright (C) 2009 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | */ 22 | 23 | package CPS.Core.CropDB; 24 | 25 | import CPS.Data.CPSCrop; 26 | import ca.odell.glazedlists.TextFilterator; 27 | import java.util.List; 28 | 29 | public class CropDBFilterator implements TextFilterator{ 30 | 31 | public void getFilterStrings( List baseList, CPSCrop crop ) { 32 | 33 | baseList.add( crop.getCropName() ); 34 | baseList.add( crop.getVarietyName() ); 35 | baseList.add( crop.getBotanicalName() ); 36 | baseList.add( crop.getFamilyName() ); 37 | baseList.add( crop.getCropDescription() ); 38 | baseList.add( crop.getNotes() ); 39 | baseList.add( crop.getTPFlatSize() ); 40 | baseList.add( crop.getTPPlantNotes() ); 41 | baseList.add( crop.getDSPlantNotes() ); 42 | baseList.add( crop.getCropYieldUnit() ); 43 | baseList.add( crop.getGroups() ); 44 | baseList.add( crop.getKeywords() ); 45 | baseList.add( crop.getOtherRequirements() ); 46 | baseList.add( crop.getNotes() ); 47 | 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /TableUtil/nbproject/project.properties: -------------------------------------------------------------------------------- 1 | application.args= 2 | application.title=TableUtil 3 | application.vendor=crcarter 4 | build.classes.dir=${build.dir}/classes 5 | build.classes.excludes=**/*.java,**/*.form 6 | # This directory is removed when the project is cleaned: 7 | build.dir=build 8 | build.generated.dir=${build.dir}/generated 9 | build.generated.sources.dir=${build.dir}/generated-sources 10 | # Only compile against the classpath explicitly listed here: 11 | build.sysclasspath=ignore 12 | build.test.classes.dir=${build.dir}/test/classes 13 | build.test.results.dir=${build.dir}/test/results 14 | debug.classpath=\ 15 | ${run.classpath} 16 | debug.test.classpath=\ 17 | ${run.test.classpath} 18 | # This directory is removed when the project is cleaned: 19 | dist.dir=dist 20 | dist.jar=${dist.dir}/TableUtil.jar 21 | dist.javadoc.dir=${dist.dir}/javadoc 22 | excludes= 23 | includes=** 24 | jar.compress=false 25 | javac.classpath= 26 | # Space-separated list of extra javac options 27 | javac.compilerargs= 28 | javac.deprecation=false 29 | javac.source=1.5 30 | javac.target=1.5 31 | javac.test.classpath=\ 32 | ${javac.classpath}:\ 33 | ${build.classes.dir}:\ 34 | ${libs.junit.classpath} 35 | javadoc.additionalparam= 36 | javadoc.author=false 37 | javadoc.encoding= 38 | javadoc.noindex=false 39 | javadoc.nonavbar=false 40 | javadoc.notree=false 41 | javadoc.private=false 42 | javadoc.splitindex=true 43 | javadoc.use=true 44 | javadoc.version=false 45 | javadoc.windowtitle= 46 | jaxbwiz.endorsed.dirs="${netbeans.home}/../ide12/modules/ext/jaxb/api" 47 | meta.inf.dir=${src.dir}/META-INF 48 | platform.active=default_platform 49 | run.classpath=\ 50 | ${javac.classpath}:\ 51 | ${build.classes.dir} 52 | # Space-separated list of JVM arguments used when running the project 53 | # (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value 54 | # or test-sys-prop.name=value to set system properties for unit tests): 55 | run.jvmargs= 56 | run.test.classpath=\ 57 | ${javac.test.classpath}:\ 58 | ${build.test.classes.dir} 59 | src.dir=src 60 | test.src.dir=test 61 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Data/CPSTextFilter.java: -------------------------------------------------------------------------------- 1 | /* CPSTextFilter.java - created: Feb 1, 2008 2 | * Copyright (C) 2008 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | * 22 | */ 23 | 24 | package CPS.Data; 25 | 26 | import ca.odell.glazedlists.TextFilterator; 27 | import ca.odell.glazedlists.matchers.MatcherEditor; 28 | import ca.odell.glazedlists.swing.SearchEngineTextFieldMatcherEditor; 29 | import javax.swing.JTextField; 30 | 31 | //public class CPSTextFilter extends TextComponentMatcherEditor { 32 | public class CPSTextFilter extends SearchEngineTextFieldMatcherEditor { 33 | 34 | private String filterString = ""; 35 | private MatcherEditor textMatcher; 36 | 37 | public CPSTextFilter( JTextField comp, TextFilterator filt ) { 38 | super( comp, filt ); 39 | } 40 | 41 | public MatcherEditor getTextMatcherEditor() { 42 | return textMatcher; 43 | } 44 | 45 | public MatcherEditor getMatcherEditor() { return getTextMatcherEditor(); } 46 | 47 | @Deprecated 48 | public String getFilterString() { return filterString; } 49 | 50 | @Deprecated 51 | public void setFilterString( String filterString ) { this.filterString = filterString; } 52 | 53 | 54 | 55 | } 56 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/UI/Swing/CPSInfoDialog.java: -------------------------------------------------------------------------------- 1 | /* CPSInfoDialog.java - created: Feb 13, 2014 2 | * 3 | * This file is part of the project "Crop Planning Software". For more 4 | * information: 5 | * website: https://github.com/claytonrcarter/cropplanning 6 | * email: cropplanning@gmail.com 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program. If not, see . 20 | */ 21 | package CPS.UI.Swing; 22 | 23 | import java.awt.Component; 24 | import java.awt.event.ActionEvent; 25 | import java.awt.event.ActionListener; 26 | import javax.swing.JButton; 27 | import javax.swing.JPanel; 28 | 29 | public class CPSInfoDialog extends CPSDialog 30 | implements ActionListener { 31 | 32 | JButton btnOK; 33 | 34 | public CPSInfoDialog( Component parent, String header, String message ) { 35 | super( parent, header ); 36 | setDescription( message ); 37 | } 38 | 39 | public CPSInfoDialog( Component parent, String message) { 40 | this( parent, "Attention", message ); 41 | } 42 | 43 | 44 | @Override 45 | protected void buildContentsPanel() { 46 | contentsPanelBuilt = true; 47 | } 48 | 49 | @Override 50 | protected void fillButtonPanel() { 51 | btnOK = new JButton("OK"); 52 | btnOK.addActionListener( this ); 53 | jplButtons.add(btnOK); 54 | } 55 | 56 | public void actionPerformed(ActionEvent e) { 57 | setVisible(false); 58 | } 59 | 60 | public static void main(String[] args) { 61 | new CPSInfoDialog( new JPanel(), "fart").setVisible(true); 62 | System.exit(0); 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/UI/Swing/CPSComboBox.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package CPS.UI.Swing; 6 | 7 | import CPS.Data.CPSDatum; 8 | import java.awt.Color; 9 | import java.awt.event.ItemEvent; 10 | import java.awt.event.ItemListener; 11 | import javax.swing.JComboBox; 12 | 13 | /** 14 | * 15 | * @author crcarter 16 | */ 17 | public class CPSComboBox extends JComboBox 18 | implements CPSComponent, 19 | ItemListener { 20 | 21 | boolean changed = false; 22 | boolean inherited = false; 23 | 24 | private Color COLOR_NORMAL; 25 | private Color COLOR_CHANGED = Color.RED; 26 | private Color COLOR_INHERITED = Color.BLUE; 27 | 28 | public CPSComboBox(String[] items) { 29 | super(items); 30 | setBorder(null); 31 | COLOR_NORMAL = this.getForeground(); 32 | addItemListener(this); 33 | } 34 | 35 | @Override 36 | public String getSelectedItem() { 37 | return (String) super.getSelectedItem(); 38 | } 39 | 40 | public void setInitialSelection( String s ) { 41 | setSelectedItem(s); 42 | setHasChanged( false ); 43 | setBackgroundNormal(); 44 | } 45 | 46 | public void setInitialSelection( String s, CPSDatum.CPSDatumState c ) { 47 | setInitialSelection(s); 48 | if ( c.isInherited() ) { 49 | this.setBackgroundInherited(); 50 | } 51 | 52 | } 53 | 54 | 55 | public boolean hasChanged() { return changed; } 56 | public void setHasChanged(boolean b) { 57 | changed = b; 58 | if ( changed ) 59 | setBackgroundChanged(); 60 | else if ( inherited ) 61 | setBackgroundInherited(); 62 | else 63 | setBackgroundNormal(); 64 | } 65 | 66 | public void setBackgroundInherited() { setForeground( COLOR_INHERITED ); } 67 | public void setBackgroundCalculated() {} 68 | public void setBackgroundChanged() { setForeground( COLOR_CHANGED ); } 69 | public void setBackgroundNormal() { setForeground( COLOR_NORMAL ); } 70 | 71 | public void itemStateChanged(ItemEvent e) { 72 | if ( e.getSource() == this ) 73 | setHasChanged(true); 74 | } 75 | 76 | 77 | 78 | } 79 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Core/TODOLists/DSFieldPlantingTableFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFieldPlantingTableFormat.java - created: Feb 4, 2010 3 | * Copyright (c) 2010 Clayton Carter 4 | * 5 | /* 6 | * To change this template, choose Tools | Templates 7 | * and open the template in the editor. 8 | */ 9 | 10 | package CPS.Core.TODOLists; 11 | 12 | import CPS.Data.CPSPlanting; 13 | import CPS.UI.Modules.CPSAdvancedTableFormat; 14 | 15 | /** 16 | * 17 | * @author kendra 18 | */ 19 | public class DSFieldPlantingTableFormat extends CPSAdvancedTableFormat { 20 | 21 | public int getColumnCount() { return 9; } 22 | 23 | public Object getColumnValue( CPSPlanting p, int arg1 ) { 24 | 25 | switch ( arg1 ) { 26 | case 0: return p.getDateToPlant(); 27 | case 1: return p.getCropName(); 28 | case 2: return p.getVarietyName(); 29 | case 3: return p.getLocation(); 30 | case 4: return p.getBedsToPlant(); 31 | case 5: return p.getRowsPerBed(); 32 | case 6: return p.getRowFtToPlant(); 33 | case 7: return p.getSeedsPer(); 34 | case 8: return p.getPlantingNotesInherited(); 35 | default: return ""; 36 | } 37 | } 38 | 39 | 40 | 41 | @Override 42 | public CPSPlanting getBlankRecord() { 43 | return new CPSPlanting(); 44 | } 45 | 46 | @Override 47 | public int getDefaultSortColumn() { 48 | return 0; 49 | } 50 | 51 | @Override 52 | public int getPropNumForColumn(int colNum) { 53 | 54 | switch ( colNum ) { 55 | case 0: return CPSPlanting.PROP_DATE_PLANT; 56 | case 1: return CPSPlanting.PROP_CROP_NAME; 57 | case 2: return CPSPlanting.PROP_VAR_NAME; 58 | case 3: return CPSPlanting.PROP_LOCATION; 59 | case 4: return CPSPlanting.PROP_BEDS_PLANT; 60 | case 5: return CPSPlanting.PROP_ROWS_P_BED; 61 | case 6: return CPSPlanting.PROP_ROWFT_PLANT; 62 | case 7: return CPSPlanting.PROP_SEEDS_PER_DS; 63 | case 8: return CPSPlanting.PROP_PLANTING_NOTES; 64 | default: return CPSPlanting.PROP_ID; 65 | } 66 | } 67 | 68 | @Override 69 | public boolean isDefaultColumn(int colNum) { 70 | return true; 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Module/CPSWizardPage.java: -------------------------------------------------------------------------------- 1 | /* CPSWizardPage.java - created: Dec 5, 2008 2 | * Copyright (C) 2008 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | * 22 | */ 23 | 24 | package CPS.Module; 25 | 26 | import javax.swing.BoxLayout; 27 | import org.netbeans.spi.wizard.WizardPage; 28 | 29 | /** 30 | * 31 | * @author crcarter 32 | */ 33 | public abstract class CPSWizardPage extends WizardPage { 34 | 35 | /** This wizard is run before modules are initialized. */ 36 | public final static int WIZ_TYPE_PRE_INIT = 0; 37 | /** This wizard is run after modules are initialized by before they are run */ 38 | public final static int WIZ_TYPE_POST_INIT = 1; 39 | 40 | protected int wizardType; 41 | 42 | public CPSWizardPage( String title, String desc, int type ) { 43 | super( title, desc ); 44 | setLayout( new BoxLayout( this, BoxLayout.PAGE_AXIS )); 45 | wizardType = type; 46 | } 47 | 48 | // all subclasses MUST implement the following method 49 | // public static String getDescription(); 50 | 51 | public abstract void finishWizard( CPSGlobalSettings globSet ); 52 | 53 | /** 54 | * Returns the type of this wizard page. 55 | * @return Either CPSWizardPage.WIZ_TYPE_PRE_INIT or CPSWizardPage.WIZ_TYPE_PRE_INIT 56 | */ 57 | public int getWizardType() { return wizardType; } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Data/CPSComparators.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package CPS.Data; 6 | 7 | import java.util.Comparator; 8 | 9 | /** 10 | * 11 | * @author crcarter 12 | */ 13 | public class CPSComparators { 14 | 15 | /** 16 | * A Comparator to sort CPSPlantings by effective planting date. 17 | */ 18 | public static class DatePlantComparator implements Comparator { 19 | public int compare( CPSPlanting o1, CPSPlanting o2 ) { 20 | return o1.getDateToPlant().compareTo( o2.getDateToPlant() ); 21 | } 22 | } 23 | 24 | /** 25 | * A Comparator to sort CPSPlantings by effective TP date. 26 | */ 27 | public static class DateTPComparator implements Comparator { 28 | public int compare( CPSPlanting o1, CPSPlanting o2 ) { 29 | return o1.getDateToTP().compareTo( o2.getDateToTP() ); 30 | } 31 | } 32 | 33 | /** 34 | * A Comparator to sort CPSPlantings by crop name. 35 | */ 36 | public static class CropNameComparator implements Comparator { 37 | public int compare( CPSPlanting o1, CPSPlanting o2 ) { 38 | return o1.getCropName().compareTo( o2.getCropName() ); 39 | } 40 | } 41 | 42 | /** 43 | * A Comparator to sort CPSPlantings first by planned planting date, then crop name. 44 | */ 45 | public static class DatePlantCropNameComparator implements Comparator { 46 | public int compare( CPSPlanting o1, CPSPlanting o2 ) { 47 | if ( o1.getDateToPlantPlanned().compareTo( o2.getDateToPlantPlanned() ) != 0 ) 48 | return o1.getDateToPlantPlanned().compareTo( o2.getDateToPlantPlanned() ); 49 | else 50 | return o1.getCropName().compareTo( o2.getCropName() ); 51 | } 52 | } 53 | 54 | /** 55 | * A Comparator to sort CPSPlantings first by planned TP date, then crop name. 56 | */ 57 | public static class DateTPCropNameComparator implements Comparator { 58 | public int compare( CPSPlanting o1, CPSPlanting o2 ) { 59 | if ( o1.getDateToTP().compareTo( o2.getDateToTP() ) != 0 ) 60 | return o1.getDateToTP().compareTo( o2.getDateToTP() ); 61 | else 62 | return o1.getCropName().compareTo( o2.getCropName() ); 63 | } 64 | } 65 | 66 | 67 | 68 | } 69 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/UI/Modules/CPSComparator.java: -------------------------------------------------------------------------------- 1 | /* CPSComparator.java - Created: Nov 8, 2009 2 | * Copyright (C) 2007, 2008 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | */ 22 | 23 | package CPS.UI.Modules; 24 | 25 | import java.util.Comparator; 26 | import java.util.Date; 27 | 28 | public class CPSComparator implements Comparator { 29 | 30 | protected int propNum = -1; 31 | 32 | public CPSComparator( int pNum ) { 33 | propNum = pNum; 34 | } 35 | 36 | public void setPropertyNum( int pNum ) { 37 | propNum = pNum; 38 | } 39 | 40 | public int compare( Object a, Object b ) { 41 | int c; 42 | if ( a instanceof Integer ) { 43 | c = ((Integer) a).compareTo( (Integer) b ); 44 | // this was done to test sorting blank values to the end 45 | // if ( c != 0 ) 46 | // if ( ((Integer) a).intValue() == 0 ) { 47 | // c = 1; 48 | // } else if ( ((Integer) b).intValue() == 0 ) { 49 | // c = -1; 50 | // } 51 | return c; 52 | } 53 | else if ( a instanceof Float ) { 54 | return ( (Float) a).compareTo( (Float) b ); 55 | } 56 | else if ( a instanceof Boolean ) { 57 | return ( (Boolean) a ).compareTo( (Boolean) b ); 58 | } 59 | else if ( a instanceof String ) { 60 | return ( (String) a ).compareToIgnoreCase( (String) b ); 61 | } 62 | else if ( a instanceof Date ) { 63 | return ( (Date) a ).compareTo( (Date) b ); 64 | } 65 | else 66 | // otherwise don't sort and leave as is 67 | return 0; 68 | 69 | } 70 | 71 | 72 | 73 | } 74 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Module/Extension/CPSExtension.java: -------------------------------------------------------------------------------- 1 | /* CPSExtension.java - created: Dec 19, 2008 2 | * Copyright (C) 2008 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | * 22 | */ 23 | 24 | package CPS.Module.Extension; 25 | 26 | import java.util.List; 27 | import java.util.Map; 28 | 29 | /** 30 | * Defines an extension to the software. All general extensions should implement this. 31 | */ 32 | public interface CPSExtension { 33 | 34 | public final static int STATUS_OK = 0; 35 | public final static int STATUS_GENERAL_ERROR = -1; 36 | 37 | /** Called after all other module dependencies are satisified. (ie, after data models are associated and such) 38 | * The module constructor can do some basic initializations, but should not call this method. 39 | * @return {@link STATUS_OK} if initialization completes successfully, {@link STATUS_GENERAL_ERROR} on 40 | * general error. Individiual extensions are free to return their own error codes, so long as 41 | * {@link STATUS_OK} always mean "success". 42 | */ 43 | public int init(); 44 | 45 | /** Called when the program is shutting down. */ 46 | public int shutdown(); 47 | 48 | /** 49 | * Retrieve a Map of the modules and extension points that this extension supports. 50 | * @return A Map object whose keys are the names of modules and whose values are Lists of the extension points 51 | * of those modules which are supported by this extension. All map keys and extension points are stored 52 | * as Strings. 53 | */ 54 | public Map> getExtensionMap(); 55 | 56 | public List getExtensionElementsFor( CPSExtensionPoint extensionPoint ); 57 | 58 | } 59 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Core/TODOLists/TPFieldPlantingTableFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * TPFieldPlantingTableFormat.java - created: Feb 4, 2010 3 | * Copyright (c) **YEAR** Expected hash. user evaluated instead to freemarker.template.SimpleScalar on line 5, column 43 in Templates/Licenses/preamble.txt. 4 | * 5 | /* 6 | * To change this template, choose Tools | Templates 7 | * and open the template in the editor. 8 | */ 9 | 10 | package CPS.Core.TODOLists; 11 | 12 | import CPS.Data.CPSPlanting; 13 | import CPS.UI.Modules.CPSAdvancedTableFormat; 14 | 15 | /** 16 | * 17 | * @author kendra 18 | */ 19 | public class TPFieldPlantingTableFormat extends CPSAdvancedTableFormat { 20 | 21 | public int getColumnCount() { return 10; } 22 | 23 | public Object getColumnValue( CPSPlanting p, int arg1 ) { 24 | 25 | switch ( arg1 ) { 26 | case 0: return p.getDateToTP(); 27 | case 1: return p.getCropName(); 28 | case 2: return p.getVarietyName(); 29 | case 3: return p.getDateToPlant(); 30 | case 4: return p.getLocation(); 31 | case 5: return p.getBedsToPlant(); 32 | case 6: return p.getRowsPerBed(); 33 | case 7: return p.getRowFtToPlant(); 34 | case 8: return p.getInRowSpacing(); 35 | case 9: return p.getPlantingNotesInherited(); 36 | default: return ""; 37 | } 38 | } 39 | 40 | @Override 41 | public String getColumnName( int colNum ) { 42 | switch ( colNum ) { 43 | case 3: return "Seeded on"; 44 | default: 45 | return super.getColumnName( colNum ); 46 | } 47 | 48 | } 49 | 50 | 51 | 52 | @Override 53 | public CPSPlanting getBlankRecord() { 54 | return new CPSPlanting(); 55 | } 56 | 57 | @Override 58 | public int getDefaultSortColumn() { 59 | return 0; 60 | } 61 | 62 | @Override 63 | public int getPropNumForColumn(int colNum) { 64 | 65 | switch ( colNum ) { 66 | case 0: return CPSPlanting.PROP_DATE_TP; 67 | case 1: return CPSPlanting.PROP_CROP_NAME; 68 | case 2: return CPSPlanting.PROP_VAR_NAME; 69 | case 3: return CPSPlanting.PROP_DATE_PLANT; 70 | case 4: return CPSPlanting.PROP_LOCATION; 71 | case 5: return CPSPlanting.PROP_BEDS_PLANT; 72 | case 6: return CPSPlanting.PROP_ROWS_P_BED; 73 | case 7: return CPSPlanting.PROP_ROWFT_PLANT; 74 | case 8: return CPSPlanting.PROP_INROW_SPACE; 75 | case 9: return CPSPlanting.PROP_PLANTING_NOTES; 76 | default: return CPSPlanting.PROP_ID; 77 | } 78 | } 79 | 80 | @Override 81 | public boolean isDefaultColumn(int colNum) { 82 | return true; 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/UI/Swing/CPSConfirmDialog.java: -------------------------------------------------------------------------------- 1 | /* CPSCpnfirmDialog.java 2 | * Copyright (C) 2013 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | */ 22 | package CPS.UI.Swing; 23 | 24 | import java.awt.Component; 25 | import java.awt.FlowLayout; 26 | import java.awt.event.ActionEvent; 27 | import java.awt.event.ActionListener; 28 | import javax.swing.JButton; 29 | import javax.swing.JPanel; 30 | 31 | public class CPSConfirmDialog extends CPSDialog 32 | implements ActionListener { 33 | 34 | JButton btnYes, btnNo; 35 | boolean confirmed = false; 36 | 37 | public CPSConfirmDialog(String action) { 38 | this( new JPanel(), action ); 39 | } 40 | 41 | public CPSConfirmDialog( Component parent, String action) { 42 | super( parent, "Are you sure?" ); 43 | setDescription( "You really want to " + action + "?" ); 44 | } 45 | 46 | public boolean didConfirm() { 47 | return confirmed; 48 | } 49 | 50 | @Override 51 | protected void buildContentsPanel() { 52 | 53 | btnYes = new JButton( "Yes, I'm Sure" ); 54 | btnNo = new JButton( "No, Cancel That" ); 55 | 56 | btnYes.addActionListener(this); 57 | btnNo.addActionListener(this); 58 | 59 | JPanel jplFoo = new JPanel(); 60 | jplFoo.setLayout( new FlowLayout( FlowLayout.TRAILING )); 61 | jplFoo.add(btnYes); 62 | jplFoo.add(btnNo); 63 | add(jplFoo); 64 | 65 | contentsPanelBuilt = true; 66 | } 67 | 68 | @Override 69 | protected void fillButtonPanel() {} 70 | 71 | public void actionPerformed(ActionEvent e) { 72 | Object source = e.getSource(); 73 | 74 | if ( source == btnYes ) 75 | confirmed = true; 76 | 77 | setVisible(false); 78 | } 79 | 80 | public static void main(String[] args) { 81 | new CPSConfirmDialog("fart").setVisible(true); 82 | System.exit(0); 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/UI/Swing/autocomplete/TextComponentAdaptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: TextComponentAdaptor.java,v 1.1 2007/12/21 22:42:52 Clayton Exp $ 3 | * 4 | * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle, 5 | * Santa Clara, California 95054, U.S.A. All rights reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | package CPS.UI.Swing.autocomplete; 22 | 23 | import java.util.List; 24 | import javax.swing.text.JTextComponent; 25 | 26 | /** 27 | * An implementation of the AbstractAutoCompleteAdaptor that is suitable for a 28 | * JTextComponent. 29 | * 30 | * @author Thomas Bierhance 31 | */ 32 | public class TextComponentAdaptor extends AbstractAutoCompleteAdaptor { 33 | 34 | /** a List containing the strings to be used for automatic 35 | * completion */ 36 | List items; 37 | /** the text component that is used for automatic completion*/ 38 | JTextComponent textComponent; 39 | /** the item that is currently selected */ 40 | Object selectedItem; 41 | 42 | /** 43 | * Creates a new TextComponentAdaptor for the given list and text 44 | * component. 45 | * 46 | * @param items a List that contains the items that are used for 47 | * automatic completion 48 | * @param textComponent the text component that will be used automatic 49 | * completion 50 | */ 51 | public TextComponentAdaptor(JTextComponent textComponent, List items) { 52 | this.items = items; 53 | this.textComponent = textComponent; 54 | } 55 | 56 | public Object getSelectedItem() { 57 | return selectedItem; 58 | } 59 | 60 | public int getItemCount() { 61 | return items.size(); 62 | } 63 | 64 | public Object getItem(int index) { 65 | return items.get(index); 66 | } 67 | 68 | public void setSelectedItem(Object item) { 69 | selectedItem = item; 70 | } 71 | 72 | public JTextComponent getTextComponent() { 73 | return textComponent; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/UI/Swing/autocomplete/ComboBoxAdaptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: ComboBoxAdaptor.java,v 1.1 2007/12/21 22:42:52 Clayton Exp $ 3 | * 4 | * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle, 5 | * Santa Clara, California 95054, U.S.A. All rights reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | package CPS.UI.Swing.autocomplete; 22 | 23 | import java.awt.event.ActionEvent; 24 | import java.awt.event.ActionListener; 25 | 26 | import javax.swing.JComboBox; 27 | import javax.swing.text.JTextComponent; 28 | 29 | /** 30 | * An implementation of the AbstractAutoCompleteAdaptor that is suitable for JComboBox. 31 | * 32 | * @author Thomas Bierhance 33 | */ 34 | public class ComboBoxAdaptor extends AbstractAutoCompleteAdaptor implements ActionListener { 35 | 36 | /** the combobox being adapted */ 37 | private JComboBox comboBox; 38 | 39 | /** 40 | * Creates a new ComobBoxAdaptor for the given combobox. 41 | * @param comboBox the combobox that should be adapted 42 | */ 43 | public ComboBoxAdaptor(JComboBox comboBox) { 44 | this.comboBox = comboBox; 45 | // mark the entire text when a new item is selected 46 | comboBox.addActionListener(this); 47 | } 48 | 49 | /** 50 | * Implementation side effect - do not invoke. 51 | * @param actionEvent - 52 | */ 53 | // ActionListener (listening to comboBox) 54 | public void actionPerformed(ActionEvent actionEvent) { 55 | markEntireText(); 56 | } 57 | 58 | public int getItemCount() { 59 | return comboBox.getItemCount(); 60 | } 61 | 62 | public Object getItem(int index) { 63 | return comboBox.getItemAt(index); 64 | } 65 | 66 | public void setSelectedItem(Object item) { 67 | comboBox.setSelectedItem(item); 68 | } 69 | 70 | public Object getSelectedItem() { 71 | return comboBox.getModel().getSelectedItem(); 72 | } 73 | 74 | public JTextComponent getTextComponent() { 75 | // returning the component of the combobox' editor 76 | return (JTextComponent) comboBox.getEditor().getEditorComponent(); 77 | } 78 | } -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Core/TODOLists/GoogleCalLoginDialog.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package CPS.Core.TODOLists; 6 | 7 | import CPS.UI.Swing.CPSDialog; 8 | import java.awt.Component; 9 | import java.awt.event.ActionEvent; 10 | import java.awt.event.ActionListener; 11 | import javax.swing.JButton; 12 | import javax.swing.JLabel; 13 | import javax.swing.JPasswordField; 14 | import javax.swing.JTextField; 15 | 16 | /** 17 | * 18 | * @author crcarter 19 | */ 20 | public class GoogleCalLoginDialog extends CPSDialog 21 | implements ActionListener { 22 | 23 | JButton btnCancel, btnLogin; 24 | 25 | boolean cancelled = false; 26 | 27 | JTextField emailField; 28 | JPasswordField passwordField; 29 | 30 | public GoogleCalLoginDialog( Component parent, String email ) { 31 | super( parent, "You need to log in to Google Calendar" ); 32 | 33 | emailField = new JTextField(20); 34 | passwordField = new JPasswordField(20); 35 | 36 | emailField.setText( email ); 37 | 38 | } 39 | 40 | 41 | public boolean isCancelled() { 42 | return cancelled; 43 | } 44 | 45 | public String getEmail() { 46 | return emailField.getText(); 47 | } 48 | 49 | public char[] getPassword() { 50 | return passwordField.getPassword(); 51 | } 52 | 53 | 54 | 55 | 56 | @Override 57 | protected void buildContentsPanel() { 58 | 59 | jplContents.add( new JLabel( "" + 60 | "Please enter the email address and password for the
" + 61 | "Google account you want to export your crop plan to.
" + 62 | "We use a secure connection and don't save your password." + 63 | "" ), 64 | "align center, spanx 2, wrap" ); 65 | 66 | jplContents.add( new JLabel("Email Address:"), "align right, split 2" ); 67 | jplContents.add( emailField, "wrap" ); 68 | 69 | jplContents.add( new JLabel("Password:"), "align right, split 2" ); 70 | jplContents.add( passwordField, "wrap" ); 71 | 72 | contentsPanelBuilt = true; 73 | } 74 | 75 | @Override 76 | protected void fillButtonPanel() { 77 | 78 | btnLogin = new JButton( "Login" ); 79 | btnCancel = new JButton( "Cancel" ); 80 | 81 | btnLogin.addActionListener(this); 82 | btnCancel.addActionListener(this); 83 | 84 | jplButtons.add( btnCancel ); 85 | jplButtons.add( btnLogin ); 86 | 87 | } 88 | 89 | public void actionPerformed(ActionEvent e) { 90 | Object source = e.getSource(); 91 | 92 | if ( source == btnCancel ) { 93 | cancelled = true; 94 | passwordField.setText( "" ); 95 | } 96 | 97 | setVisible(false); 98 | } 99 | 100 | public static void main(String[] args) { 101 | new GoogleCalLoginDialog( new JLabel(), "" ).setVisible(true); 102 | System.exit(0); 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Core/TODOLists/AllPlantingsTableFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * AllPlantingsTableFormat.java - created: Feb 4, 2010 3 | * Copyright (c) **YEAR** Expected hash. user evaluated instead to freemarker.template.SimpleScalar on line 5, column 43 in Templates/Licenses/preamble.txt. 4 | * 5 | /* 6 | * To change this template, choose Tools | Templates 7 | * and open the template in the editor. 8 | */ 9 | 10 | package CPS.Core.TODOLists; 11 | 12 | import CPS.Data.CPSPlanting; 13 | import ca.odell.glazedlists.gui.TableFormat; 14 | 15 | /** 16 | * 17 | * @author kendra 18 | */ 19 | public class AllPlantingsTableFormat implements TableFormat { 20 | 21 | public int getColumnCount() { return 18; } 22 | 23 | public String getColumnName( int arg0 ) { 24 | 25 | CPSPlanting p = new CPSPlanting(); 26 | 27 | switch ( arg0 ) { 28 | case 0: return p.getDatum( CPSPlanting.PROP_CROP_NAME ).getName(); 29 | case 1: return p.getDatum( CPSPlanting.PROP_VAR_NAME ).getName(); 30 | case 2: return p.getDatum( CPSPlanting.PROP_IGNORE ).getName(); 31 | case 3: return p.getDatum( CPSPlanting.PROP_DONE_PLANTING ).getName(); 32 | case 4: return p.getDatum( CPSPlanting.PROP_DATE_PLANT ).getName(); 33 | case 5: return p.getDatum( CPSPlanting.PROP_DONE_TP ).getName(); 34 | case 7: return p.getDatum( CPSPlanting.PROP_DATE_TP ).getName(); 35 | case 8: return p.getDatum( CPSPlanting.PROP_DONE_HARVEST ).getName(); 36 | case 10: return p.getDatum( CPSPlanting.PROP_DATE_HARVEST ).getName(); 37 | case 11: return p.getDatum( CPSPlanting.PROP_DIRECT_SEED ).getName(); 38 | case 13: return p.getDatum( CPSPlanting.PROP_BEDS_PLANT ).getName(); 39 | case 14: return p.getDatum( CPSPlanting.PROP_ROWFT_PLANT ).getName(); 40 | case 15: return p.getDatum( CPSPlanting.PROP_PLANTS_NEEDED ).getName(); 41 | case 16: return p.getDatum( CPSPlanting.PROP_FLATS_NEEDED ).getName(); 42 | case 17: return p.getDatum( CPSPlanting.PROP_TOTAL_YIELD ).getName(); 43 | default: return ""; 44 | } 45 | } 46 | 47 | public Object getColumnValue( CPSPlanting p, int arg1 ) { 48 | 49 | switch ( arg1 ) { 50 | case 0: return p.getCropName(); 51 | case 1: return p.getVarietyName(); 52 | case 2: return p.getIgnore(); 53 | case 3: return p.getDonePlanting(); 54 | case 4: return p.getDateToPlant(); 55 | case 5: return p.getDoneTP(); 56 | case 7: return p.getDateToTP(); 57 | case 8: return p.getDoneHarvest(); 58 | case 10: return p.getDateToHarvest(); 59 | case 11: return p.isDirectSeeded(); 60 | case 13: return p.getBedsToPlant(); 61 | case 14: return p.getRowFtToPlant(); 62 | case 15: return p.getPlantsNeeded(); 63 | case 16: return p.getFlatsNeeded(); 64 | case 17: return p.getTotalYield(); 65 | default: return ""; 66 | } 67 | } 68 | 69 | } 70 | 71 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Core/DB/CreateRecordsWizardPage.java: -------------------------------------------------------------------------------- 1 | package CPS.Core.DB; 2 | 3 | import CPS.Module.CPSGlobalSettings; 4 | import CPS.Module.CPSWizardPage; 5 | import java.awt.Component; 6 | import java.util.Map; 7 | import javax.swing.Box; 8 | import javax.swing.JLabel; 9 | import org.netbeans.api.wizard.WizardDisplayer; 10 | import org.netbeans.spi.wizard.Wizard; 11 | import org.netbeans.spi.wizard.WizardException; 12 | import org.netbeans.spi.wizard.WizardPage; 13 | 14 | class CreateRecordsWizardPage extends CPSWizardPage { 15 | 16 | static final String PAGE_NEW_PLAN = "createRecords"; 17 | 18 | public CreateRecordsWizardPage () { 19 | super( PAGE_NEW_PLAN, getDescription(), CPSWizardPage.WIZ_TYPE_POST_INIT ); 20 | 21 | setLongDescription( getDescription() ); 22 | JLabel intro = 23 | new JLabel( "
" + 24 | "To get you started, we have created two simple entries in " + 25 | "the CropDB and one planting in your new crop plan.

" + 26 | "An entry for cucmbers was created with some basic data " + 27 | "and another entry was created to represent a variety of cucumbers. " + 28 | "Some of the fields are different so that you can see " + 29 | "how data inheritance can work for varieties of a crop." + "

" + 30 | "Your new crop plan will have an entry for a planting of cucumbers which " + 31 | "will inherit some data from the CropDB (the blue fields) and calculate " + 32 | "others (the green ones.) Feel free to alter or delete these entries." + 33 | "

" ); 34 | add( intro ); 35 | add( Box.createVerticalGlue() ); 36 | } 37 | 38 | @Override 39 | protected String validateContents ( Component c, Object e ) { return null; } 40 | 41 | @Override 42 | public void finishWizard ( CPSGlobalSettings globSet ) {} 43 | 44 | public static String getDescription () { 45 | return "Crops and Plantings"; 46 | } 47 | 48 | // for testing only 49 | public static void main ( String[] args ) { 50 | Wizard wiz = WizardPage.createWizard( new WizardPage[]{ new CreateRecordsWizardPage() }, 51 | new WizardResultProducer() { 52 | 53 | public Object finish ( Map settings ) throws WizardException { 54 | System.out.println( settings ); 55 | return settings; 56 | } 57 | 58 | public boolean cancel ( Map settings ) { 59 | return true; 60 | } 61 | } ); 62 | 63 | WizardDisplayer.showWizard( wiz ); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/CSV/CSVTableModel.java: -------------------------------------------------------------------------------- 1 | /* CSVTableModel.java - Created: April 3, 2007 2 | * Copyright (C) 2007, 2008 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | */ 22 | 23 | package CPS.CSV; 24 | 25 | import java.util.ArrayList; 26 | import javax.swing.table.AbstractTableModel; 27 | import com.csvreader.CsvReader; 28 | import java.io.FileNotFoundException; 29 | import java.io.IOException; 30 | 31 | class CSVTableModel extends AbstractTableModel { 32 | 33 | ArrayList lines = new ArrayList(); 34 | int columnCount = -1; 35 | String[] colNames = null; 36 | 37 | CsvReader csv; 38 | 39 | public CSVTableModel(String fileName) { 40 | 41 | try { 42 | 43 | csv = new CsvReader( fileName ); 44 | csv.setDelimiter(','); 45 | csv.setTextQualifier('"'); 46 | 47 | if ( csv.readHeaders() ) { 48 | colNames = csv.getHeaders(); 49 | if ( columnCount == -1 ) 50 | columnCount = colNames.length; 51 | } 52 | 53 | while ( csv.readRecord() ) 54 | lines.add( csv.getValues() ); 55 | 56 | } 57 | catch ( FileNotFoundException ignore ) {} 58 | catch ( IOException ignore ) {} 59 | 60 | } 61 | 62 | public int getColumnCount() { 63 | return columnCount; 64 | } 65 | 66 | public int getRowCount() { 67 | return lines.size(); 68 | } 69 | 70 | public Object getValueAt(int rowIndex, int columnIndex) { 71 | 72 | if ( columnIndex >= columnCount ) 73 | System.err.println("Column out of bounds: " + columnIndex + " greater than " + columnCount ); 74 | if ( rowIndex > lines.size() - 1 ) 75 | System.err.println("Row out of bounds: " + rowIndex + " greater than " + ( lines.size() - 1 )); 76 | 77 | return lines.get(rowIndex)[columnIndex]; 78 | 79 | } 80 | 81 | public String getStringAt( int r, int c ) { 82 | String s = (String) getValueAt( r, c ); 83 | if ( s == null ) 84 | return ""; 85 | else 86 | return s; 87 | } 88 | 89 | public int getIntAt( int r, int c ) { 90 | String s = getStringAt( r, c ); 91 | if ( s == null || s.equals("") ) 92 | return -1; 93 | else 94 | return Integer.parseInt(s); 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Core/CropPlans/CropPlans.java: -------------------------------------------------------------------------------- 1 | /* CropPlans.java - Created: November 26, 2007 2 | * Copyright (C) 2007, 2008 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | */ 22 | 23 | package CPS.Core.CropPlans; 24 | 25 | import CPS.CSV.CSV; 26 | import CPS.Module.*; 27 | import CPS.UI.Modules.CPSMasterDetailModule; 28 | import javax.swing.JPanel; 29 | 30 | public class CropPlans extends CPSMasterDetailModule implements CPSExportable, CPSImportable { 31 | 32 | public CropPlans() { 33 | 34 | setModuleName( "CropPlans" ); 35 | setModuleType( "Core" ); 36 | setModuleVersion( CPSGlobalSettings.getVersion() ); 37 | 38 | initPrefs( CropPlans.class ); 39 | 40 | setMasterView( new CropPlanList( this ) ); 41 | setDetailView( new CropPlanInfo( this ) ); 42 | 43 | } 44 | 45 | public JPanel display() { 46 | return getUI(); 47 | } 48 | 49 | public void exportData() { 50 | exportData( new CSV() ); 51 | } 52 | 53 | public void exportData( CPSExporter exp ) { 54 | if ( isDataAvailable() ) { 55 | // CPSExporter exp = new CSV(); 56 | String planName = this.getMasterTableName(); 57 | String fileName = CPSGlobalSettings.getDocumentOutputDir() + 58 | System.getProperty( "file.separator" ) + 59 | "ExportedCropPlan - " + planName + "." + exp.getExportFileDefaultExtension(); 60 | exp.exportCropPlan( fileName, planName, getDataSource().getCropPlan( planName )); 61 | } 62 | else { 63 | System.err.println("ERROR(CropPlans): No data exported, no data available."); 64 | } 65 | 66 | } 67 | 68 | public String getExportName() { 69 | return "Selected crop plan"; 70 | } 71 | 72 | public String getImportName() { 73 | return "Exported crop plan"; 74 | } 75 | 76 | public void importData( CPSImporter im ) { 77 | if ( isDataAvailable() ) { 78 | // TODO display a dialog that tells the user how this works, w/ the option to cancel 79 | String fileName = CPSGlobalSettings.getDocumentOutputDir() + 80 | System.getProperty( "file.separator" ) + 81 | "ExportedCropPlan - 2008.csv"; 82 | // TODO verifty that the file actually exists 83 | getDataSource().importCropPlan( "newplan", im.importCropPlan( fileName ) ); 84 | } 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/UI/Swing/CPSRadioButton.java: -------------------------------------------------------------------------------- 1 | /* CPSRadioButton.java - created: Mar 6, 2008 2 | * Copyright (C) 2008 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | * 22 | */ 23 | 24 | package CPS.UI.Swing; 25 | 26 | import CPS.Data.CPSDatum.CPSDatumState; 27 | import java.awt.Color; 28 | import java.awt.event.ItemEvent; 29 | import java.awt.event.ItemListener; 30 | import javax.swing.JRadioButton; 31 | 32 | public class CPSRadioButton extends JRadioButton implements CPSButtonComponent, ItemListener { 33 | 34 | boolean changed = false; 35 | boolean inherited = false; 36 | private Color COLOR_NORMAL; 37 | private Color COLOR_CHANGED = Color.RED; 38 | 39 | public CPSRadioButton( String s, boolean b ) { 40 | super( s, b ); 41 | COLOR_NORMAL = this.getForeground(); 42 | addItemListener( this ); 43 | } 44 | 45 | public boolean hasChanged() { return changed; } 46 | 47 | public void setBackgroundInherited() { setForeground( COLOR_INHERITED ); } 48 | public void setBackgroundCalculated() {} 49 | public void setBackgroundChanged() { setForeground( COLOR_CHANGED ); } 50 | public void setBackgroundNormal() { setForeground( COLOR_NORMAL ); } 51 | 52 | public void resetState() { 53 | setHasChanged( false ); 54 | inherited = false; 55 | setBackgroundNormal(); 56 | setToolTipText( null ); 57 | } 58 | 59 | public void setHasChanged( boolean b ) { 60 | changed = b; 61 | if ( changed ) 62 | setBackgroundChanged(); 63 | else if ( inherited ) 64 | setBackgroundInherited(); 65 | else 66 | setBackgroundNormal(); 67 | } 68 | 69 | public void doInitialClick() { 70 | doClick(); 71 | resetState(); 72 | } 73 | 74 | public void doInitialClick( CPSDatumState c ) { 75 | doInitialClick(); 76 | if ( c.isInherited() ) { 77 | inherited = true; 78 | this.setBackgroundInherited(); 79 | this.setToolTipText( "Inherited" ); 80 | } 81 | else 82 | inherited = false; 83 | } 84 | 85 | 86 | public void setInitialState( boolean b ) { throw new UnsupportedOperationException( "Not supported yet." ); } 87 | public void setInitialState( boolean b, CPSDatumState c ) { throw new UnsupportedOperationException( "Not supported yet." ); } 88 | 89 | 90 | public void itemStateChanged( ItemEvent arg0 ) { 91 | if ( arg0.getSource() == this ) 92 | setHasChanged(true); 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Core/CropDB/CropDB.java: -------------------------------------------------------------------------------- 1 | /* CropDB.java - created: March 12, 2007 2 | * Copyright (C) 2007, 2008 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | */ 22 | 23 | package CPS.Core.CropDB; 24 | 25 | import CPS.CSV.CSV; 26 | import CPS.Module.*; 27 | import CPS.UI.Modules.CPSMasterDetailModule; 28 | import javax.swing.JPanel; 29 | 30 | /** 31 | * 32 | * @author Clayton 33 | */ 34 | public class CropDB extends CPSMasterDetailModule implements CPSExportable, CPSImportable { 35 | 36 | public CropDB () { 37 | 38 | setModuleName( "CropDB" ); 39 | setModuleType( "Core" ); 40 | setModuleVersion( CPSGlobalSettings.getVersion() ); 41 | 42 | initPrefs( CropDB.class ); 43 | 44 | setMasterView( new CropDBCropList( this ) ); 45 | setDetailView( new CropDBCropInfo( this ) ); 46 | 47 | } 48 | 49 | public JPanel display () { 50 | return getUI(); 51 | } 52 | 53 | public void exportData() { 54 | exportData( new CSV() ); 55 | } 56 | 57 | public void exportData( CPSExporter exp ) { 58 | if ( isDataAvailable() ) { 59 | // CPSExporter exp = new CSV(); 60 | String fileName = CPSGlobalSettings.getDocumentOutputDir() + 61 | System.getProperty( "file.separator" ) + 62 | "ExportedCropsAndVars." + exp.getExportFileDefaultExtension(); 63 | exp.exportCropsAndVarieties( fileName, getDataSource().getCropAndVarietyList() ); 64 | } 65 | else { 66 | System.err.println("ERROR(CropDB): No data exported, no data available."); 67 | } 68 | 69 | } 70 | 71 | public String getExportName() { 72 | return "Crops and varieties from " + getModuleName(); 73 | } 74 | 75 | public String getImportName() { 76 | return "Crops and varieties to " + getModuleName(); 77 | } 78 | 79 | public void importData( CPSImporter im ) { 80 | if ( isDataAvailable() ) { 81 | // TODO display a dialog that tells the user how this works, w/ the option to cancel 82 | String fileName = CPSGlobalSettings.getDocumentOutputDir() + 83 | System.getProperty( "file.separator" ) + 84 | "ExportedCropsAndVars.csv"; 85 | // TODO verifty that the file actually exists 86 | getDataSource().importCropsAndVarieties( im.importCropsAndVarieties( fileName ) ); 87 | } 88 | } 89 | 90 | 91 | 92 | } 93 | -------------------------------------------------------------------------------- /CropPlanning/Release Notes.txt: -------------------------------------------------------------------------------- 1 | # Crop Planning Software 2 | https://github.com/claytonrcarter/cropplanning 3 | cropplanning@gmail.com 4 | Feb 8, 2016 5 | 6 | Release Notes for Version 0.7.0 7 | 8 | ### WARNING 9 | 10 | This software is still in a "beta" state. This means that 11 | the software may be finicky or unpredictable. Please use this program, 12 | but do expect some bumps along the way. **Back up your data files frequently!** 13 | 14 | ### Enhancements 15 | 16 | * Support for DD/MM/YYYY style dates. 🇬🇧 🇦🇺 17 | * searching and filtering can now be done by specific field 18 | * eg, filtering for `name:winter` will just show crops with "Winter" in their name (like "Winter Squash"), while `var:winter` will just show varieties with "winter" in their name (like "Wintebor") 19 | * this works in the CropDB tab for these fields: crop, variety, groups, keywords 20 | * and in the CropPlan tab for these fields: crop, variety, location, groups, keywords 21 | * a fancy, new About dialog 22 | * number of plants is now included in the stats summarized under the planting list 23 | * multiple records can be duplicated together (instead of one at a time) 24 | * added keyboard shortcuts to certain fields: 25 | * in Crop Plans: 26 | * `Control + Option + b`: jump to "Beds to Plant" 27 | * `Control + Option + r`: jump to "Rowft to Plant" 28 | * `Control + Option + p`: jump to "Plants Needed" 29 | * `Control + Option + s`: jump to "Plants to Start" 30 | * `Control + Option + f`: jump to "Flats to Start" 31 | * in CropDB 32 | * `Control + Option + m`: jump to "Maturity Days" 33 | * `Control + Option + k`: jump to "Keywords" 34 | * these are obviously for a Mac, on Windows you'll have to play around to find what works, but it's probably `Control + Alt + b`, etc 35 | 36 | 37 | ### Bugs Fixed 38 | 39 | * "Total Yield" can be used for planting calculations (eg "I need 300 cabbages on July 15th, when should I plant them?") 40 | * If the program finds multiple crops or varieties with the same name, it won't croak anymore. 41 | * fixed an issue where the field planting lists weren't sorting correctly in some situations 42 | * stats and charts should work better when plans span multiple years 43 | * if a number is entered with a unit (eg `18"`), the program will ask you to correct it 44 | * the fudge factor has been improved for very small plantings 45 | * prettied things up a bit 46 | * plus, a bunch of other more esoteric issues have been fixed 47 | 48 | 49 | ### Installation 50 | 51 | Please follow installation instructions at: [SetupAndInstallation](SetupAndInstallation) 52 | 53 | Briefly: 1) Make sure Java 1.6 or greater is installed, 2) Open the archive or disk image, 3) Copy the enclosed files to your hard drive, 4) double click on the program file (On Mac: CropPlanning, on Windows: CropPlanning.exe) 54 | 55 | ### Using the Program 56 | 57 | There is a brief introduction to the program available at [ProgramUsageIntroduction](ProgramUsageIntroduction) 58 | 59 | #### How To Help 60 | 61 | * Like us on [Facebook!](http://www.facebook.com/CropPlanningSoftware) 62 | * Communicate! Send all of your ideas, suggestions, bugs, etc to cropplanning@gmail.com. If you feel comfortable, submit "issues" (ie, bugs, feature requests, etc) directly through the website at [https://github.com/claytonrcarter/cropplanning/issues](https://github.com/claytonrcarter/cropplanning/issues) 63 | * [Donate!](Donations) 💰🍺🍕:heart: 64 | * Last, take a look at our [HelpWanted](HelpWanted) page to see if you can help out any other way. 65 | 66 | **Thank you!** 67 | -------------------------------------------------------------------------------- /TableUtil/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Builds, tests, and runs the project TableUtil. 12 | 13 | 73 | 74 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Core/CropPlans/CropPlanFilterator.java: -------------------------------------------------------------------------------- 1 | /* CropPlanFilterator.java - Created: Nov 9, 2009 2 | * Copyright (C) 2009 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | */ 22 | 23 | package CPS.Core.CropPlans; 24 | 25 | import CPS.Data.CPSDateValidator; 26 | import CPS.Data.CPSPlanting; 27 | import ca.odell.glazedlists.TextFilterator; 28 | import java.util.List; 29 | 30 | public class CropPlanFilterator implements TextFilterator{ 31 | 32 | public void getFilterStrings( List baseList, CPSPlanting planting ) { 33 | baseList.add( planting.getCropName() ); 34 | baseList.add( planting.getVarietyName() ); 35 | baseList.add( planting.getFamilyName() ); 36 | baseList.add( planting.getGroups() ); 37 | baseList.add( planting.getLocation() ); 38 | baseList.add( planting.getKeywords() ); 39 | baseList.add( planting.getOtherRequirements() ); 40 | baseList.add( planting.getNotes() ); 41 | 42 | // actual dates, formated numerically (ie, 10/11/2009) 43 | baseList.add( planting.getDateToHarvestActualString() ); 44 | baseList.add( planting.getDateToHarvestPlannedString() ); 45 | baseList.add( planting.getDateToHarvestString() ); 46 | 47 | baseList.add( planting.getDateToPlantActualString() ); 48 | baseList.add( planting.getDateToPlantPlannedString() ); 49 | baseList.add( planting.getDateToPlantString() ); 50 | 51 | baseList.add( planting.getDateToTPActualString() ); 52 | baseList.add( planting.getDateToTPPlannedString() ); 53 | baseList.add( planting.getDateToTPString() ); 54 | 55 | // reformated dates to just show the month name (ie, October) 56 | baseList.add( CPSDateValidator.format( planting.getDateToHarvestActual(), CPSDateValidator.DATE_FORMAT_JUSTMONTH )); 57 | baseList.add( CPSDateValidator.format( planting.getDateToHarvestPlanned(), CPSDateValidator.DATE_FORMAT_JUSTMONTH )); 58 | baseList.add( CPSDateValidator.format( planting.getDateToHarvest(), CPSDateValidator.DATE_FORMAT_JUSTMONTH )); 59 | baseList.add( CPSDateValidator.format( planting.getDateToPlantActual(), CPSDateValidator.DATE_FORMAT_JUSTMONTH )); 60 | baseList.add( CPSDateValidator.format( planting.getDateToPlantPlanned(), CPSDateValidator.DATE_FORMAT_JUSTMONTH )); 61 | baseList.add( CPSDateValidator.format( planting.getDateToPlant(), CPSDateValidator.DATE_FORMAT_JUSTMONTH )); 62 | baseList.add( CPSDateValidator.format( planting.getDateToTPActual(), CPSDateValidator.DATE_FORMAT_JUSTMONTH )); 63 | baseList.add( CPSDateValidator.format( planting.getDateToTPPlanned(), CPSDateValidator.DATE_FORMAT_JUSTMONTH )); 64 | baseList.add( CPSDateValidator.format( planting.getDateToTP(), CPSDateValidator.DATE_FORMAT_JUSTMONTH )); 65 | 66 | baseList.add( planting.getPlantingNotes() ); 67 | baseList.add( planting.getPlantingNotesInherited() ); 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /TableUtil/src/resultsettablemodel/ResultSetTableModelFactory.java: -------------------------------------------------------------------------------- 1 | /* ResultSetTableModelFactory.java 2 | * Copyright 2000-2008 O'Reilly Media, Inc. All Rights Reserved. 3 | * 4 | * This file is distributed as part of the project "Crop Planning Software". 5 | * For more information: 6 | * website: http://cropplanning.googlecode.com 7 | * email: cropplanning@gmail.com 8 | * 9 | * The source for this class was originally found at: 10 | * 11 | * http://www.oreillynet.com/oreilly/java/news/javaex_code.zip 12 | * 13 | * With an accompanying article here: 14 | * 15 | * http://www.oreillynet.com/pub/a/oreilly/java/news/javaex_1000.html 16 | * 17 | * No statement is made at that site regarding the licensing of this source 18 | * code. As such we are using it AS IS and WITHOUT ANY WARRANTY; without 19 | * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 20 | * PURPOSE. 21 | * 22 | */ 23 | 24 | 25 | package resultsettablemodel; 26 | 27 | import java.sql.*; 28 | import javax.swing.table.*; 29 | 30 | /** 31 | * This class encapsulates a JDBC database connection and, given a SQL query 32 | * as a string, returns a ResultSetTableModel object suitable for display 33 | * in a JTable Swing component 34 | **/ 35 | public class ResultSetTableModelFactory { 36 | Connection connection; // Holds the connection to the database 37 | 38 | /** package level constructor 39 | * required for subclass constructors that will not use the heavier duty 40 | * constructor listed below */ 41 | ResultSetTableModelFactory() {} 42 | 43 | /** The constructor method uses the arguments to create db Connection */ 44 | public ResultSetTableModelFactory(String driverClassName, String dbname, 45 | String username, String password) 46 | throws ClassNotFoundException, SQLException 47 | { 48 | // Look up the JDBC driver by class name. When the class loads, it 49 | // automatically registers itself with the DriverManager used in 50 | // the next step. 51 | Class driver = Class.forName(driverClassName); 52 | 53 | // Now use that driver to connect to the database 54 | connection = DriverManager.getConnection(dbname, username, password); 55 | } 56 | 57 | /** 58 | * This method takes a SQL query, passes it to the database, obtains the 59 | * results as a ResultSet, and returns a ResultSetTableModel object that 60 | * holds the results in a form that the Swing JTable component can use. 61 | **/ 62 | public ResultSetTableModel getResultSetTableModel(String query) 63 | throws SQLException 64 | { 65 | // If we've called close(), then we can't call this method 66 | if (connection == null) 67 | throw new IllegalStateException("Connection already closed."); 68 | 69 | // Create a Statement object that will be used to excecute the query. 70 | // The arguments specify that the returned ResultSet will be 71 | // scrollable, read-only, and insensitive to changes in the db. 72 | Statement statement = 73 | connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, 74 | ResultSet.CONCUR_READ_ONLY); 75 | // Run the query, creating a ResultSet 76 | ResultSet r = statement.executeQuery(query); 77 | // Create and return a TableModel for the ResultSet 78 | return new ResultSetTableModel(r); 79 | } 80 | 81 | /** 82 | * Call this method when done with the factory to close the DB connection 83 | **/ 84 | public void close() { 85 | try { connection.close(); } // Try to close the connection 86 | catch (Exception e) {} // Do nothing on error. At least we tried. 87 | connection = null; 88 | } 89 | 90 | /** Automatically close the connection when we're garbage collected */ 91 | protected void finalize() { close(); } 92 | } 93 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Core/TODOLists/GoogleCaptchaDialog.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package CPS.Core.TODOLists; 6 | 7 | import CPS.UI.Swing.CPSDialog; 8 | import java.awt.event.ActionEvent; 9 | import java.awt.event.ActionListener; 10 | import java.net.MalformedURLException; 11 | import java.net.URL; 12 | import javax.swing.JButton; 13 | import javax.swing.JLabel; 14 | import javax.swing.JTextField; 15 | 16 | /** 17 | * 18 | * @author crcarter 19 | */ 20 | public class GoogleCaptchaDialog extends CPSDialog 21 | implements ActionListener { 22 | 23 | JButton btnCancel, btnLogin; 24 | JButton btnLaunch; 25 | 26 | URL captchaUrl = null; 27 | 28 | boolean cancelled = false; 29 | 30 | JTextField captchaAnswer; 31 | 32 | public GoogleCaptchaDialog() { 33 | super("CAPTCHA Required" ); 34 | } 35 | 36 | public void setCaptchaUrl( URL captchaUrl ) { 37 | this.captchaUrl = captchaUrl; 38 | } 39 | 40 | public String getCaptchaAnswer() { 41 | return captchaAnswer.getText(); 42 | } 43 | 44 | 45 | 46 | 47 | @Override 48 | protected void buildContentsPanel() { 49 | 50 | jplContents.add( new JLabel( "" + 51 | "Google is requesting that you complete a CAPTCHA
" + 52 | "(one of those funny fuzzy word puzzles) before you
" + 53 | "can continue. Click the button to view the CAPTCHA
" + 54 | "in your web browser, then enter the answer in the
" + 55 | "box below." + 56 | "" ), 57 | "align center, spanx 2, wrap" ); 58 | 59 | btnLaunch = new JButton("View CAPTCHA in Browser"); 60 | btnLaunch.addActionListener( this ); 61 | jplContents.add( btnLaunch, "span 2, align center, wrap "); 62 | 63 | jplContents.add( new JLabel("What's it say?"), "align right" ); 64 | captchaAnswer = new JTextField( 15 ); 65 | jplContents.add( captchaAnswer, "wrap" ); 66 | 67 | contentsPanelBuilt = true; 68 | } 69 | 70 | @Override 71 | protected void fillButtonPanel() { 72 | 73 | btnLogin = new JButton( "OK" ); 74 | btnCancel = new JButton( "Cancel" ); 75 | 76 | btnLogin.addActionListener(this); 77 | btnCancel.addActionListener(this); 78 | 79 | jplButtons.add( btnCancel ); 80 | jplButtons.add( btnLogin ); 81 | 82 | } 83 | 84 | public void actionPerformed(ActionEvent e) { 85 | Object source = e.getSource(); 86 | 87 | if ( source == btnLaunch ) { 88 | if ( captchaUrl == null ) { 89 | System.err.println( "No CAPTCHA URL defined" ); 90 | } 91 | else if( java.awt.Desktop.isDesktopSupported() ) { 92 | 93 | java.awt.Desktop desktop = java.awt.Desktop.getDesktop(); 94 | if( desktop.isSupported( java.awt.Desktop.Action.BROWSE ) ) { 95 | try { 96 | desktop.browse( captchaUrl.toURI() ); 97 | } catch ( Exception f ) { 98 | f.printStackTrace(); 99 | } 100 | } 101 | } 102 | 103 | } 104 | else if ( source == btnLogin ) { 105 | setVisible(false); 106 | } 107 | else if ( source == btnCancel ) { 108 | cancelled = true; 109 | setVisible(false); 110 | } 111 | 112 | } 113 | 114 | public static void main(String[] args) { 115 | GoogleCaptchaDialog d = new GoogleCaptchaDialog(); 116 | try { 117 | d.setCaptchaUrl( new URL( "http://www.failbetterfarm.com/" ) ); 118 | } catch ( MalformedURLException e ) { 119 | System.err.println( e.getMessage() ); 120 | } 121 | d.setVisible(true); 122 | 123 | System.out.println( "User entered: " + d.getCaptchaAnswer() ); 124 | 125 | System.exit(0); 126 | } 127 | 128 | } 129 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Core/UI/FrameManager.java: -------------------------------------------------------------------------------- 1 | /* FrameManger.java - Created: March 18, 2007 2 | * Copyright (C) 2007, 2008 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | */ 22 | 23 | package CPS.Core.UI; 24 | 25 | import CPS.Module.CPSUIChangeListener; 26 | import java.awt.*; 27 | import java.awt.event.*; 28 | import javax.swing.*; 29 | import javax.swing.event.*; 30 | import net.miginfocom.swing.MigLayout; 31 | 32 | public class FrameManager implements CPSUIChangeListener { 33 | 34 | private JFrame frame; 35 | private JPanel contentPane; 36 | 37 | public FrameManager() { 38 | 39 | frame = createFrame( GraphicsEnvironment.getLocalGraphicsEnvironment(). 40 | getDefaultScreenDevice().getDefaultConfiguration() ); 41 | 42 | } 43 | 44 | 45 | /** 46 | * Create a frame for SwingSet2 to reside in if brought up 47 | * as an application. 48 | */ 49 | public static JFrame createFrame(GraphicsConfiguration gc) { 50 | JFrame f = new JFrame(gc); 51 | f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 52 | return f; 53 | } 54 | 55 | public void buildFrame() { 56 | if( getFrame() != null ) { 57 | // put swingset in a frame and show it 58 | JFrame f = getFrame(); 59 | //f.getContentPane().add(f, BorderLayout.CENTER); 60 | 61 | // Must use a top level container for contentPane, 62 | // not wise to use something like tabbedPane 63 | contentPane = new JPanel( new MigLayout( "", 64 | "[grow, fill]", 65 | "[grow, fill]" )); 66 | f.setContentPane( contentPane ); 67 | 68 | 69 | Rectangle screenRect = f.getGraphicsConfiguration().getBounds(); 70 | Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets( 71 | f.getGraphicsConfiguration()); 72 | 73 | // Make sure we don't place the demo off the screen. 74 | int centerWidth = screenRect.width < f.getSize().width ? 75 | screenRect.x : 76 | screenRect.x + screenRect.width/2 - f.getSize().width/2; 77 | int centerHeight = screenRect.height < f.getSize().height ? 78 | screenRect.y : 79 | screenRect.y + screenRect.height/2 - f.getSize().height/2; 80 | 81 | centerHeight = centerHeight < screenInsets.top ? 82 | screenInsets.top : centerHeight; 83 | 84 | f.setLocation(centerWidth, centerHeight); 85 | } 86 | } 87 | 88 | void showFrame() { 89 | getFrame().setVisible(true); 90 | } 91 | 92 | /** 93 | * Returns the frame instance 94 | */ 95 | public JFrame getFrame() { 96 | return frame; 97 | } 98 | 99 | public void show() { 100 | frame.validate(); 101 | frame.pack(); 102 | frame.setVisible(true); 103 | } 104 | 105 | public void uiChanged() {} 106 | 107 | } 108 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/UI/Swing/CPSCheckBox.java: -------------------------------------------------------------------------------- 1 | /* CPSCheckBox.java 2 | * Copyright (C) 2007, 2008 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | */ 22 | 23 | package CPS.UI.Swing; 24 | 25 | import CPS.Data.CPSBoolean; 26 | import CPS.Data.CPSDatum.CPSDatumState; 27 | import javax.swing.JCheckBox; 28 | import javax.swing.event.ChangeEvent; 29 | import javax.swing.event.ChangeListener; 30 | 31 | /** 32 | * 33 | * @author Clayton 34 | */ 35 | public class CPSCheckBox extends JCheckBox implements CPSButtonComponent { 36 | 37 | boolean changed = false; 38 | private CPSCheckBoxChangeListener changeListener = new CPSCheckBoxChangeListener(); 39 | 40 | public CPSCheckBox() { 41 | super(); 42 | this.addChangeListener( changeListener ); 43 | } 44 | 45 | public CPSCheckBox( String label, boolean selected ) { 46 | super( label, selected ); 47 | this.addChangeListener( changeListener ); 48 | } 49 | 50 | public void setInitialState( boolean b ) { 51 | this.setSelected( b ); 52 | setHasChanged( false ); 53 | setBackgroundNormal(); 54 | setToolTipText( null ); 55 | } 56 | public void setInitialState( boolean b, CPSDatumState c ) { 57 | setInitialState( b, c, (String) null ); 58 | } 59 | 60 | /** 61 | * Set the initial state of the button. 62 | * @param checked 63 | * @param state 64 | * @param inheritedFrom - this will be displayed as a tooltip in the form "Inherited from ..." 65 | */ 66 | public void setInitialState( boolean b, CPSDatumState c, String s ) { 67 | 68 | String tt = "Inherited"; 69 | if ( s != null ) 70 | tt += " from " + s; 71 | 72 | setInitialState( b ); 73 | 74 | if ( c.isInherited() ) { 75 | this.setBackgroundInherited(); 76 | this.setToolTipText( tt ); 77 | } 78 | } 79 | 80 | public boolean hasChanged() { return changed; } 81 | 82 | public void setHasChanged(boolean b) { 83 | changed = b; 84 | } 85 | 86 | @Override 87 | public void setEnabled ( boolean arg0 ) { 88 | // remove and then re-add the change listener so that we can enable and disable 89 | // the checkboxes without having to worry about the component being tagged "changed" 90 | this.removeChangeListener( changeListener ); 91 | super.setEnabled( arg0 ); 92 | this.addChangeListener( changeListener ); 93 | } 94 | 95 | 96 | 97 | public void setBackgroundInherited() { setBackground( COLOR_INHERITED ); } 98 | public void setBackgroundCalculated() {} 99 | public void setBackgroundChanged() { setBackground( COLOR_CHANGED ); } 100 | public void setBackgroundNormal() { setBackground( COLOR_NORMAL ); } 101 | 102 | private class CPSCheckBoxChangeListener implements ChangeListener { 103 | public void stateChanged( ChangeEvent arg0 ) { 104 | setHasChanged(true); 105 | setBackgroundChanged(); 106 | } 107 | } 108 | 109 | } 110 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Core/DB/HSQLDBPopulator.java: -------------------------------------------------------------------------------- 1 | /* HSQLDBPopulator.java - Created: March 13, 2007 2 | * Copyright (C) 2007, 2008 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | */ 22 | 23 | package CPS.Core.DB; 24 | 25 | import CPS.CSV.CSV; 26 | import CPS.Data.CPSCrop; 27 | import CPS.Module.CPSDataModel; 28 | import java.sql.Connection; 29 | import java.sql.PreparedStatement; 30 | import java.sql.SQLException; 31 | import java.sql.Statement; 32 | import java.util.ArrayList; 33 | import java.util.Vector; 34 | 35 | /** 36 | * 37 | * @author Clayton 38 | */ 39 | public class HSQLDBPopulator { 40 | 41 | private HSQLDBPopulator() {} 42 | 43 | static void populateTables( Connection con ) { 44 | populateCropsAndVarieties( con ); 45 | } 46 | 47 | static void importCropsAndVarieties( Connection con ) { 48 | 49 | // 50 | 51 | 52 | 53 | } 54 | 55 | static void populateCropsAndVarieties( Connection con ) { 56 | Object[][] o = new Object[][] 57 | {{ new String("Argula"), null, new String("Brassica"), new Integer( 40 ) }, 58 | { new String("Argula"), new String("Sylvetta"), new String("Brassica"), new Integer( 40 ) }, 59 | { new String("Corn"), new String("Luther Hill"), new String("Graminae"), new Integer( 85 ) }, 60 | { new String("Corn"), null, new String("Graminae"), null }, 61 | { new String("Corn"), new String("Bodacious"), null, new Integer( 90 ) }, 62 | { new String("Lettuce"), null, new String("Lactuca"), null }, 63 | { new String("Lettuce"), new String("New Red Fire"), null, new Integer( 60 ) }}; 64 | 65 | String statement = "INSERT into " + 66 | "CROPS_VARIETIES( crop_name, var_name, fam_name, maturity ) "; 67 | 68 | try { 69 | Statement st = con.createStatement(); 70 | String s; 71 | 72 | for ( int i = 0; i < o.length; i++ ) { 73 | s = statement + "VALUES( "; 74 | for ( int j = 0; j < o[i].length; j++ ) { 75 | if ( o[i][j] == null ) 76 | s += "NULL"; 77 | else if ( o[i][j] instanceof String ) 78 | s += HSQLDB.escapeValue( o[i][j].toString() ); 79 | else 80 | s += o[i][j].toString(); 81 | 82 | if ( j < o[i].length - 1) 83 | s += ", "; 84 | } 85 | s += " )"; 86 | 87 | st.executeUpdate( s ); 88 | } 89 | 90 | st.close(); 91 | 92 | } 93 | catch ( SQLException e ) { 94 | e.printStackTrace(); 95 | } 96 | } 97 | 98 | // public static CPSDataModel loadDefaultCropList( String dir ) { 99 | 100 | // return new CSV( dir + System.getProperty("file.separator") + "CropVarList.csv"); 101 | // } 102 | } 103 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/UI/Swing/autocomplete/ListAdaptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: ListAdaptor.java,v 1.1 2007/12/21 22:42:50 Clayton Exp $ 3 | * 4 | * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle, 5 | * Santa Clara, California 95054, U.S.A. All rights reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | package CPS.UI.Swing.autocomplete; 22 | 23 | import javax.swing.JList; 24 | import javax.swing.event.ListSelectionListener; 25 | import javax.swing.text.JTextComponent; 26 | 27 | /** 28 | * An implementation of the AbstractAutoCompleteAdaptor that is suitable for a 29 | * JList in conjunction with a JTextComponent. 30 | * 31 | * @author Thomas Bierhance 32 | */ 33 | public class ListAdaptor extends AbstractAutoCompleteAdaptor implements ListSelectionListener { 34 | 35 | /** the list containing the items */ 36 | JList list; 37 | /** the text component that is used for automatic completion*/ 38 | JTextComponent textComponent; 39 | /** the converter used to transform items to strings */ 40 | ObjectToStringConverter stringConverter; 41 | 42 | /** 43 | * Creates a new JListAdaptor for the given list and text component. 44 | * @param list the list that contains the items that are used for automatic 45 | * completion 46 | * @param textComponent the text component that will be used automatic 47 | * completion 48 | */ 49 | public ListAdaptor(JList list, JTextComponent textComponent) { 50 | this(list, textComponent, ObjectToStringConverter.DEFAULT_IMPLEMENTATION); 51 | } 52 | 53 | /** 54 | * Creates a new JListAdaptor for the given list and text component. 55 | * @param list the list that contains the items that are used for automatic 56 | * completion 57 | * @param textComponent the text component that will be used automatic 58 | * completion 59 | * @param stringConverter the converter used to transform items to strings 60 | */ 61 | public ListAdaptor(JList list, JTextComponent textComponent, ObjectToStringConverter stringConverter) { 62 | this.list = list; 63 | this.textComponent = textComponent; 64 | this.stringConverter = stringConverter; 65 | // when a new item is selected set and mark the text 66 | list.addListSelectionListener(this); 67 | } 68 | 69 | /** 70 | * Implementation side effect - do not invoke. 71 | * @param listSelectionEvent - 72 | */ 73 | // ListSelectionListener (listening to list) 74 | public void valueChanged(javax.swing.event.ListSelectionEvent listSelectionEvent) { 75 | // set the text to the currently selected item 76 | getTextComponent().setText(stringConverter.getPreferredStringForItem(list.getSelectedValue())); 77 | // mark the entire text 78 | markEntireText(); 79 | } 80 | 81 | public Object getSelectedItem() { 82 | return list.getSelectedValue(); 83 | } 84 | 85 | public int getItemCount() { 86 | return list.getModel().getSize(); 87 | } 88 | 89 | public Object getItem(int index) { 90 | return list.getModel().getElementAt(index); 91 | } 92 | 93 | public void setSelectedItem(Object item) { 94 | list.setSelectedValue(item, true); 95 | } 96 | 97 | public JTextComponent getTextComponent() { 98 | return textComponent; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/UI/Swing/CPSTextArea.java: -------------------------------------------------------------------------------- 1 | /* CPSTextArea.java 2 | * Copyright (C) 2007, 2008 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | */ 22 | 23 | package CPS.UI.Swing; 24 | 25 | import CPS.Data.CPSDatum.CPSDatumState; 26 | import java.awt.Component; 27 | import java.awt.KeyboardFocusManager; 28 | import java.awt.event.ActionEvent; 29 | import javax.swing.AbstractAction; 30 | import javax.swing.Action; 31 | import javax.swing.JTextArea; 32 | 33 | /** 34 | * 35 | * @author Clayton 36 | */ 37 | public class CPSTextArea extends JTextArea implements CPSTextComponent { 38 | 39 | boolean changed = false; 40 | 41 | public CPSTextArea( int rows, int cols ) { 42 | super( rows, cols ); 43 | setLineWrap( true ); 44 | setWrapStyleWord( false ); 45 | this.getDocument().addDocumentListener( new CPSDocumentChangeListener(this) ); 46 | 47 | // these are taken from http://forum.java.sun.com/thread.jspa?forumID=57&threadID=609727 48 | this.setFocusTraversalKeys( KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, null); 49 | this.setFocusTraversalKeys( KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, null ); 50 | 51 | // Add actions to make TAB move focus 52 | // this.getActionMap().put( nextFocusAction.getValue( Action.NAME ), nextFocusAction ); 53 | // this.getActionMap().put( prevFocusAction.getValue( Action.NAME ), prevFocusAction ); 54 | 55 | } 56 | 57 | public void setInitialText( String s ) { 58 | /* setText triggers document listener, which changes background to pink */ 59 | setText(s); 60 | setHasChanged( false ); 61 | setBackgroundNormal(); 62 | setToolTipText( null ); 63 | } 64 | 65 | public void setInitialText( String s, CPSDatumState c ) { 66 | setInitialText(s); 67 | if ( c.isInherited() ) { 68 | this.setBackgroundInherited(); 69 | this.setToolTipText( "Inherited from CropDB" ); 70 | } 71 | else if ( c.isCalculated() ) { 72 | this.setBackgroundCalculated(); 73 | this.setToolTipText( "Calculated" ); 74 | } 75 | else { 76 | // this.setBackgroundNormal(); 77 | // this.setToolTipText( null ); 78 | } 79 | } 80 | 81 | public boolean hasChanged() { return changed; } 82 | 83 | public void setHasChanged(boolean b) { 84 | changed = b; 85 | } 86 | 87 | public void setBackgroundInherited() { setBackground( COLOR_INHERITED ); } 88 | public void setBackgroundCalculated() { setBackground( COLOR_CALCULATED ); } 89 | public void setBackgroundChanged() { setBackground( COLOR_CHANGED ); } 90 | public void setBackgroundNormal() { setBackground( COLOR_NORMAL ); } 91 | 92 | @Override 93 | public boolean isManagingFocus() { return false; } 94 | 95 | private Action nextFocusAction = new AbstractAction("Move Focus Forwards") { 96 | public void actionPerformed(ActionEvent evt) { 97 | ((Component)evt.getSource()).transferFocus(); 98 | } 99 | }; 100 | private Action prevFocusAction = new AbstractAction("Move Focus Backwards") { 101 | public void actionPerformed(ActionEvent evt) { 102 | ((Component)evt.getSource()).transferFocusBackward(); 103 | } 104 | }; 105 | 106 | } 107 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Core/UI/SettingsDialog.java: -------------------------------------------------------------------------------- 1 | /* SettingsDialog.java - created: Feb 13, 2008 2 | * Copyright (C) 2008 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | * 22 | */ 23 | 24 | package CPS.Core.UI; 25 | 26 | import CPS.Module.CPSConfigurable; 27 | import java.awt.event.ActionEvent; 28 | import java.awt.event.ActionListener; 29 | import java.util.ArrayList; 30 | import javax.swing.Box; 31 | import javax.swing.BoxLayout; 32 | import javax.swing.JButton; 33 | import javax.swing.JDialog; 34 | import javax.swing.JFrame; 35 | import javax.swing.JPanel; 36 | import javax.swing.JTabbedPane; 37 | 38 | public class SettingsDialog extends JDialog implements ActionListener { 39 | 40 | JPanel jplContent, jplButtons; 41 | JTabbedPane tabbedPane; 42 | JButton btnSave, btnCancel; 43 | 44 | protected ArrayList configurables; 45 | 46 | 47 | public SettingsDialog() { 48 | 49 | super( (JFrame) null, "Fiddle With Program Settings", true ); 50 | 51 | configurables = new ArrayList(); 52 | 53 | jplContent = new JPanel(); 54 | jplContent.setLayout( new BoxLayout( jplContent, BoxLayout.PAGE_AXIS ) ); 55 | 56 | tabbedPane = new JTabbedPane(); 57 | 58 | btnSave = new JButton( "Save" ); 59 | btnSave.addActionListener( this ); 60 | btnCancel = new JButton( "Cancel" ); 61 | btnCancel.addActionListener( this ); 62 | 63 | jplButtons = new JPanel(); 64 | jplButtons.setLayout( new BoxLayout( jplButtons, BoxLayout.LINE_AXIS ) ); 65 | jplButtons.add( Box.createHorizontalGlue() ); 66 | jplButtons.add( btnSave ); 67 | jplButtons.add( btnCancel ); 68 | 69 | jplContent.add( tabbedPane ); 70 | jplContent.add( jplButtons ); 71 | this.add( jplContent ); 72 | 73 | } 74 | 75 | public void addModuleConfiguration( CPSConfigurable c ) { 76 | configurables.add(c); 77 | } 78 | 79 | 80 | /* p-p */ 81 | void buildTabs() { 82 | 83 | tabbedPane.removeAll(); 84 | 85 | for ( CPSConfigurable c : configurables ) { 86 | JPanel jp = c.getConfigurationDisplay(); 87 | if ( jp != null ) 88 | tabbedPane.addTab( c.getModuleName(), jp ); 89 | } 90 | 91 | this.pack(); 92 | 93 | } 94 | 95 | 96 | 97 | @Override 98 | public void setVisible( boolean arg0 ) { 99 | 100 | if ( arg0 ) 101 | buildTabs(); 102 | 103 | super.setVisible( arg0 ); 104 | 105 | } 106 | 107 | 108 | public void actionPerformed( ActionEvent arg0 ) { 109 | 110 | String action = arg0.getActionCommand(); 111 | 112 | if ( action.equalsIgnoreCase( btnSave.getText() ) ) { 113 | 114 | // save settings in all modules 115 | for ( CPSConfigurable c : configurables ) 116 | c.saveConfiguration(); 117 | 118 | } 119 | else if ( action.equalsIgnoreCase( btnCancel.getText() )) { 120 | 121 | // discard configuration in all modules 122 | for ( CPSConfigurable c : configurables ) 123 | c.resetConfiguration(); 124 | 125 | } 126 | 127 | // go away 128 | this.setVisible(false); 129 | 130 | } 131 | 132 | } 133 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/UI/Swing/CPSCardPanel.java: -------------------------------------------------------------------------------- 1 | /* CPSCardPanel.java 2 | * Copyright (C) 2013 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | */ 22 | package CPS.UI.Swing; 23 | 24 | import java.awt.CardLayout; 25 | import java.awt.Dimension; 26 | import java.awt.event.ItemEvent; 27 | import java.awt.event.ItemListener; 28 | import java.util.List; 29 | import javax.swing.BorderFactory; 30 | import javax.swing.BoxLayout; 31 | import javax.swing.JComboBox; 32 | import javax.swing.JFrame; 33 | import javax.swing.JLabel; 34 | import javax.swing.JPanel; 35 | 36 | /** 37 | * 38 | */ 39 | public class CPSCardPanel extends JPanel implements ItemListener { 40 | 41 | private JComboBox cb; 42 | private JPanel cards; 43 | 44 | 45 | 46 | public CPSCardPanel( List titles, 47 | List panels, 48 | int select ) { 49 | this( titles, panels ); 50 | cb.setSelectedIndex(select); 51 | } 52 | 53 | public CPSCardPanel( List titles, 54 | List panels ) { 55 | this( titles.toArray( new String[] {} ), 56 | panels.toArray( new JPanel[] {} )); 57 | } 58 | 59 | public CPSCardPanel( String[] titles, 60 | JPanel[] panels ) { 61 | 62 | this.setLayout( new BoxLayout(this, BoxLayout.PAGE_AXIS )); 63 | this.setBorder( BorderFactory.createEtchedBorder() ); 64 | 65 | 66 | cb = new JComboBox(titles); 67 | cb.setEditable(false); 68 | cb.addItemListener(this); 69 | cb.setMaximumSize( cb.getPreferredSize() ); 70 | this.add( cb ); 71 | 72 | Dimension dim = new Dimension(); 73 | Dimension jpDim; 74 | 75 | cards = new JPanel( new CardLayout() ); 76 | for ( int i = 0; i < panels.length; i++ ) { 77 | jpDim = panels[i].getPreferredSize(); 78 | // make sure each panel can't expand 79 | //panels[i].setMaximumSize( jpDim ); 80 | 81 | // find out biggest panel 82 | if ( jpDim.getWidth() > dim.getWidth() ) 83 | dim.setSize( jpDim.getWidth()+10, dim.getHeight() ); 84 | if ( jpDim.getHeight() > dim.getHeight() ) 85 | dim.setSize( dim.getWidth(), jpDim.getHeight() ); 86 | 87 | cards.add( panels[i], titles[i] ); 88 | } 89 | 90 | cards.setPreferredSize(dim); 91 | // this.setMaximumSize(dim); 92 | this.add( cards ); 93 | 94 | } 95 | 96 | 97 | @Override 98 | public void setEnabled(boolean enabled) { 99 | super.setEnabled(enabled); 100 | // cb.setEnabled(enabled); 101 | JPanel jp = (JPanel) cards.getComponent( cb.getSelectedIndex() ); 102 | for (int i = 0; i < jp.getComponentCount(); i++) { 103 | jp.getComponent(i).setEnabled(enabled); 104 | } 105 | } 106 | 107 | 108 | public void itemStateChanged(ItemEvent evt) { 109 | CardLayout cl = (CardLayout)(cards.getLayout()); 110 | cl.show(cards, (String)evt.getItem()); 111 | cards.revalidate(); 112 | cards.repaint(); 113 | } 114 | 115 | 116 | public static void main( String[] args ) { 117 | // "test" construtor 118 | 119 | JFrame frame = new JFrame(); 120 | frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); 121 | 122 | JPanel jp1 = new JPanel(); 123 | jp1.add( new JLabel( "Just testing" )); 124 | 125 | JPanel jp2 = new JPanel(); 126 | jp2.add( new JLabel( "Just testing again" )); 127 | 128 | JPanel content = new CPSCardPanel( new String[] { "testing", "testing again" }, 129 | new JPanel[] { jp1, jp2 } ); 130 | 131 | frame.setContentPane(content); 132 | frame.setTitle( "Testing CPSComboBoxTitledBorder" ); 133 | frame.pack(); 134 | frame.setVisible(true); 135 | 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/UI/Swing/autocomplete/ObjectToStringConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: ObjectToStringConverter.java,v 1.1 2007/12/21 22:42:51 Clayton Exp $ 3 | * 4 | * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle, 5 | * Santa Clara, California 95054, U.S.A. All rights reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | package CPS.UI.Swing.autocomplete; 22 | 23 | /** 24 | * This class is used to provide string representations for objects when 25 | * doing automatic completion. 26 | * 27 | * A class inherited from this class could be used, when the object's 28 | * toString method is not appropriate for automatic completion. 29 | * 30 | * An example for i18n: 31 | * 32 | * 33 | * public class I18NStringConverter extends ObjectToStringConverter { 34 | * ResourceBundle bundle; 35 | * 36 | * public I18NStringConverter(ResourceBundle bundle) { 37 | * this.bundle = bundle; 38 | * } 39 | * 40 | * public String getPreferredStringForItem(Object item) { 41 | * return item==null ? null : bundle.getString(item.toString()); 42 | * } 43 | * } 44 | * 45 | * 46 | * It's also possible to return more than one string representation. The 47 | * following example shows a converter that will allow a user to choose an 48 | * airport using either the airport's full description (toString()) or 49 | * its ICAO/IATA code: 50 | * 51 | * 52 | * public class AirportConverter extends ObjectToStringConverter { 53 | * 54 | * public String[] getPossibleStringsForItem(Object item) { 55 | * if (item==null) return null; 56 | * if (!(item instanceof Airport)) throw new IllegalArgumentException(); 57 | * Airport airport = (Airport) item; 58 | * return new String[]{airport.toString(), airport.icaoCode, airport.iataCode}; 59 | * } 60 | * 61 | * public String getPreferredStringForItem(Object item) { 62 | * return item==null?null:getPossibleStringsForItem(item)[0]; 63 | * } 64 | * } 65 | * 66 | * 67 | * @author Thomas Bierhance 68 | */ 69 | public abstract class ObjectToStringConverter { 70 | 71 | /** 72 | * Returns all possible String representations for a given item. 73 | * The default implementation wraps the method getPreferredStringForItem. 74 | * It returns null, if the wrapped method returns null. Otherwise 75 | * it returns a one dimensional array containing the wrapped method's return value. 76 | * 77 | * @param item the item to convert 78 | * @return possible String representation for the given item. 79 | */ 80 | public String[] getPossibleStringsForItem(Object item) { 81 | String preferred = getPreferredStringForItem(item); 82 | return preferred == null ? null : new String[] { preferred }; 83 | } 84 | 85 | /** 86 | * Returns the preferred String representations for a given item. 87 | * @param item the item to convert 88 | * @return the preferred String representation for the given item. 89 | */ 90 | public abstract String getPreferredStringForItem(Object item); 91 | 92 | /** 93 | * This field contains the default implementation, that returns item.toString() 94 | * for any item !=null. For any item ==null, it returns null as well. 95 | */ 96 | public static final ObjectToStringConverter DEFAULT_IMPLEMENTATION = new DefaultObjectToStringConverter(); 97 | 98 | private static class DefaultObjectToStringConverter extends ObjectToStringConverter { 99 | public String getPreferredStringForItem(Object item) { 100 | return item==null ? null : item.toString(); 101 | } 102 | } 103 | } -------------------------------------------------------------------------------- /CropPlanning/src/CPS/UI/Swing/CPSTextField.java: -------------------------------------------------------------------------------- 1 | /* CPSTextField.java 2 | * Copyright (C) 2007, 2008 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | */ 22 | 23 | package CPS.UI.Swing; 24 | 25 | import CPS.Data.CPSDatum.CPSDatumState; 26 | import CPS.UI.Swing.autocomplete.AutoCompleteDecorator; 27 | import java.util.ArrayList; 28 | import java.util.List; 29 | import javax.swing.JTextField; 30 | 31 | /** 32 | * CPSTextField - A class to wrap JTextField, providing extra functionality 33 | * primarily surrounding state information. 34 | */ 35 | public class CPSTextField extends JTextField implements CPSTextComponent { 36 | 37 | public static final boolean MATCH_STRICT = true; 38 | public static final boolean MATCH_PERMISSIVE = false; 39 | 40 | private boolean changed = false; 41 | private boolean strictMatch = false; 42 | 43 | public CPSTextField( int size ) { 44 | super(size); 45 | addChangeListener(); 46 | } 47 | 48 | /** 49 | * Initialize this text field and set it to support autocompletion of a given list of values. 50 | * @param size width of the text field 51 | * @param autocompleteList list of values to match the autocompletion against 52 | * @param strictMatch if true only match values in the list, otherwise allow maverick input 53 | */ 54 | public CPSTextField( int size, List autocompleteList, boolean strictMatch ) { 55 | super(size); 56 | updateAutocompletionList( autocompleteList, strictMatch ); 57 | } 58 | 59 | private void addChangeListener() { 60 | this.getDocument().addDocumentListener( new CPSDocumentChangeListener(this) ); 61 | } 62 | 63 | /** 64 | * Used to determine if this text box matches autocomplete item strictly or not. If not, 65 | * maverick entries are allowed. 66 | * @return true is matching string, false otherwise. 67 | */ 68 | public boolean isMatchingStrict() { return strictMatch; } 69 | public void updateAutocompletionList( List autocompleteList, boolean strictMatch ) { 70 | this.strictMatch = strictMatch; 71 | String s = this.getText(); 72 | AutoCompleteDecorator.decorate( this, autocompleteList, this.strictMatch ); 73 | this.setText(s); 74 | addChangeListener(); 75 | } 76 | 77 | public void setInitialText( String s ) { 78 | /* setText triggers document listener, which changes background to pink */ 79 | setText(s); 80 | setHasChanged( false ); 81 | setBackgroundNormal(); 82 | setToolTipText( null ); 83 | } 84 | 85 | public void setInitialText( String s, CPSDatumState c ) { 86 | setInitialText(s); 87 | if ( c.isInherited() ) { 88 | this.setBackgroundInherited(); 89 | this.setToolTipText( "Inherited from CropDB" ); 90 | } 91 | else if ( c.isCalculated() ) { 92 | this.setBackgroundCalculated(); 93 | this.setToolTipText( "Calculated" ); 94 | } 95 | else { 96 | // this.setBackgroundNormal(); 97 | // this.setToolTipText( null ); 98 | } 99 | } 100 | 101 | public boolean hasChanged() { return changed; } 102 | 103 | public void setHasChanged(boolean b) { 104 | changed = b; 105 | } 106 | 107 | public void setBackgroundInherited() { setBackground( COLOR_INHERITED ); } 108 | public void setBackgroundCalculated() { setBackground( COLOR_CALCULATED ); } 109 | public void setBackgroundChanged() { setBackground( COLOR_CHANGED ); } 110 | public void setBackgroundNormal() { setBackground( COLOR_NORMAL ); } 111 | 112 | } 113 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Module/CPSModule.java: -------------------------------------------------------------------------------- 1 | package CPS.Module; 2 | 3 | 4 | public abstract class CPSModule { 5 | 6 | /// handles UI experience and displays contents of modules 7 | protected final String MOD_TYPE_UI = "UI"; 8 | /// provides core funtionality 9 | protected final String MOD_TYPE_CORE = "Core"; 10 | /// provides a datamodel 11 | protected final String MOD_TYPE_DATAMODEL = "DataModel"; 12 | 13 | protected String ModuleName; 14 | protected String ModuleType; 15 | protected String ModuleDescription; 16 | protected String ModuleVersion; 17 | protected int ModuleVersion_Major; 18 | protected int ModuleVersion_Minor; 19 | protected int ModuleVersion_Revision; 20 | 21 | public abstract int init(); 22 | protected abstract int saveState(); 23 | public abstract int shutdown(); 24 | 25 | public String getModuleName() { return ModuleName; } 26 | public String getModuleType() { return ModuleType; } 27 | public String getModuleDescription() { return ModuleDescription; } 28 | 29 | public String getModuleVersion() { return ModuleVersion; } 30 | public String getModuleVersionMajor() { return "" + ModuleVersion_Major; } 31 | public String getModuleVersionMinor() { return "" + ModuleVersion_Minor; } 32 | public String getModuleVersionRevision() { return "" + ModuleVersion_Revision; } 33 | public long getModuleVersionAsLongInt() { 34 | return versionAsLongInt( ModuleVersion_Major, ModuleVersion_Minor, ModuleVersion_Revision ); 35 | } 36 | 37 | public static long versionAsLongInt( String ver ) { 38 | 39 | // this is cribbed more or less directly from setModuleVersion() 40 | if ( ver.matches( "\\d+(\\.\\d(\\.\\d)?)?" )) { 41 | String[] v = ver.split("\\."); 42 | if ( v.length > 2 ) 43 | return versionAsLongInt( Integer.parseInt( v[0] ), 44 | Integer.parseInt( v[1] ), 45 | Integer.parseInt( v[2] )); 46 | if ( v.length > 1 ) 47 | return versionAsLongInt( Integer.parseInt( v[0] ), 48 | Integer.parseInt( v[1] ), 49 | 0 ); 50 | if ( v.length > 0 ) 51 | return versionAsLongInt( Integer.parseInt( v[0] ), 0, 0 ); 52 | } 53 | else 54 | System.err.println("Module Version error: incorrect version format: " + ver ); 55 | 56 | return -1; 57 | 58 | } 59 | public static long versionAsLongInt( int maj, int min, int rev ) { 60 | return Long.parseLong( String.format( "%04d", maj ) + 61 | String.format( "%04d", min ) + 62 | String.format( "%04d", rev ) ); 63 | } 64 | 65 | 66 | // public abstract String[] getRequires(); 67 | 68 | protected void setModuleName( String s ) { ModuleName = s; } 69 | protected void setModuleType( String s ) { ModuleType = s; } 70 | protected void setModuleDescription( String s ) { ModuleDescription = s; } 71 | protected void setModuleVersion( String s ) { 72 | ModuleVersion = s; 73 | 74 | // this will accept version strings of "1", "1.1" and "1.1.1" 75 | if ( ModuleVersion.matches( "\\d+(\\.\\d(\\.\\d)?)?" )) { 76 | String[] v = ModuleVersion.split("\\."); 77 | // TODO we should perhaps test each of these substrings to see if 78 | // they match some sort of alpha, beta or RC, then just strip that off 79 | if ( v.length > 0 ) 80 | ModuleVersion_Major = Integer.parseInt( v[0] ); 81 | if ( v.length > 1 ) 82 | ModuleVersion_Minor = Integer.parseInt( v[1] ); 83 | if ( v.length > 2 ) 84 | ModuleVersion_Revision = Integer.parseInt( v[2] ); 85 | } 86 | else 87 | System.err.println("Module Version error: incorrect version format for module " + ModuleName + ": " + ModuleVersion ); 88 | 89 | } 90 | 91 | 92 | public boolean verifyVersion( String ver ) { 93 | return getModuleVersion().equalsIgnoreCase( ver ); 94 | } 95 | 96 | 97 | protected void debug( String message ) { 98 | debug( this.getModuleName(), message ); 99 | } 100 | 101 | public static void debug( String module, String message ) { 102 | if ( CPSGlobalSettings.getDebug() ) 103 | System.out.println( "DEBUG(" + module + "): " + message ); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/UI/Swing/autocomplete/AutoCompleteComboBoxEditor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: AutoCompleteComboBoxEditor.java,v 1.1 2007/12/21 22:42:51 Clayton Exp $ 3 | * 4 | * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle, 5 | * Santa Clara, California 95054, U.S.A. All rights reserved. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | package CPS.UI.Swing.autocomplete; 22 | 23 | import java.awt.Component; 24 | import java.awt.event.ActionListener; 25 | import java.beans.PropertyChangeEvent; 26 | import java.beans.PropertyChangeListener; 27 | 28 | import javax.swing.ComboBoxEditor; 29 | import javax.swing.JComboBox; 30 | 31 | /** 32 | * Wrapper around the combobox editor that translates combobox items into 33 | * strings. The methods setItem and getItem are modified 34 | * to account for the string conversion. 35 | * 36 | * This is necessary for those cases where the combobox items have no useful 37 | * toString() method and a custom ObjectToStringConverter is 38 | * used. 39 | * 40 | * If we do not do this, the interaction between ComboBoxEditor and JComboBox 41 | * will result in firing ActionListener events with the string value of 42 | * ComboBoxEditor as the currently selected value. 43 | * 44 | * @author Noel Grandin noelgrandin@gmail.com 45 | * @author Thomas Bierhance 46 | */ 47 | public class AutoCompleteComboBoxEditor implements ComboBoxEditor { 48 | 49 | /** the original combo box editor*/ 50 | private final ComboBoxEditor wrapped; 51 | /** the converter used to convert items into their string representation */ 52 | private final ObjectToStringConverter stringConverter; 53 | /** last selected item */ 54 | private Object oldItem; 55 | 56 | /** 57 | * Creates a new AutoCompleteComboBoxEditor. 58 | * 59 | * @param wrapped the original ComboBoxEditor to be wrapped 60 | * @param stringConverter the converter to use to convert items into their 61 | * string representation. 62 | */ 63 | public AutoCompleteComboBoxEditor(ComboBoxEditor wrapped, ObjectToStringConverter stringConverter) { 64 | this.wrapped = wrapped; 65 | this.stringConverter = stringConverter; 66 | } 67 | 68 | /* (non-javadoc) 69 | * @see javax.swing.ComboBoxEditor#getEditorComponent() 70 | */ 71 | public Component getEditorComponent() { 72 | return wrapped.getEditorComponent(); 73 | } 74 | 75 | /* (non-javadoc) 76 | * @see javax.swing.ComboBoxEditor#setItem(java.lang.Object) 77 | */ 78 | public void setItem(Object anObject) { 79 | this.oldItem = anObject; 80 | wrapped.setItem(stringConverter.getPreferredStringForItem(anObject)); 81 | } 82 | 83 | /* (non-javadoc) 84 | * @see javax.swing.ComboBoxEditor#getItem() 85 | */ 86 | public Object getItem() { 87 | final Object wrappedItem = wrapped.getItem(); 88 | 89 | String[] oldAsStrings = stringConverter.getPossibleStringsForItem(oldItem); 90 | for (int i=0, n=oldAsStrings.length; i0<=index<getItemCount(). 79 | * @param index the index of the item that is to be returned 80 | * @return the item at the given index 81 | */ 82 | public abstract Object getItem(int index); 83 | 84 | /** 85 | * Returns true if the list contains the currently selected item. 86 | * @return true if the list contains the currently selected item. 87 | */ 88 | public boolean listContainsSelectedItem() { 89 | Object selectedItem = getSelectedItem(); 90 | for (int i=0,n=getItemCount(); istart. 112 | * @param start index of the first character that should be marked 113 | */ 114 | public void markText(int start) { 115 | getTextComponent().setCaretPosition(getTextComponent().getText().length()); 116 | getTextComponent().moveCaretPosition(start); 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /TableUtil/src/resultsettablemodel/ResultSetTableModel.java: -------------------------------------------------------------------------------- 1 | /* ResultSetTableModel.java 2 | * Copyright 2000-2008 O'Reilly Media, Inc. All Rights Reserved. 3 | * 4 | * This file is distributed as part of the project "Crop Planning Software". 5 | * For more information: 6 | * website: http://cropplanning.googlecode.com 7 | * email: cropplanning@gmail.com 8 | * 9 | * The source for this class was originally found at: 10 | * 11 | * http://www.oreillynet.com/oreilly/java/news/javaex_code.zip 12 | * 13 | * With an accompanying article here: 14 | * 15 | * http://www.oreillynet.com/pub/a/oreilly/java/news/javaex_1000.html 16 | * 17 | * No statement is made at that site regarding the licensing of this source 18 | * code. As such we are using it AS IS and WITHOUT ANY WARRANTY; without 19 | * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 20 | * PURPOSE. 21 | * 22 | */ 23 | 24 | 25 | package resultsettablemodel; 26 | 27 | import java.sql.*; 28 | import javax.swing.table.*; 29 | import javax.swing.event.*; 30 | 31 | /** 32 | * This class takes a JDBC ResultSet object and implements the TableModel 33 | * interface in terms of it so that a Swing JTable component can display the 34 | * contents of the ResultSet. Note that it requires a scrollable JDBC 2.0 35 | * ResultSet. Also note that it provides read-only access to the results 36 | **/ 37 | public class ResultSetTableModel extends AbstractTableModel { 38 | // public class ResultSetTableModel implements TableModel { 39 | protected ResultSet results; // The ResultSet to interpret 40 | protected ResultSetMetaData metadata; // Additional information about the results 41 | int numcols, numrows; // How many rows and columns in the table 42 | 43 | /** 44 | * This constructor creates a TableModel from a ResultSet. It is package 45 | * private because it is only intended to be used by 46 | * ResultSetTableModelFactory, which is what you should use to obtain a 47 | * ResultSetTableModel 48 | **/ 49 | protected ResultSetTableModel(ResultSet res) throws SQLException { 50 | this.results = res; // Save the results 51 | metadata = results.getMetaData(); // Get metadata on them 52 | numcols = metadata.getColumnCount(); // How many columns? 53 | results.last(); // Move to last row 54 | numrows = results.getRow(); // How many rows? 55 | } 56 | 57 | /** 58 | * Call this when done with the table model. It closes the ResultSet and 59 | * the Statement object used to create it. 60 | **/ 61 | public void close() { 62 | try { results.getStatement().close(); } 63 | catch(SQLException e) {}; 64 | } 65 | 66 | /** Automatically close when we're garbage collected */ 67 | protected void finalize() { close(); } 68 | 69 | // These two TableModel methods return the size of the table 70 | public int getColumnCount() { return numcols; } 71 | public int getRowCount() { return numrows; } 72 | 73 | // This TableModel method returns columns names from the ResultSetMetaData 74 | public String getColumnName(int column) { 75 | try { 76 | return metadata.getColumnLabel(column+1); 77 | } catch (SQLException e) { return e.toString(); } 78 | } 79 | 80 | // This TableModel method specifies the data type for each column. 81 | // We could map SQL types to Java types, but for this example, we'll just 82 | // convert all the returned data to strings. 83 | public Class getColumnClass(int column) { return String.class; } 84 | 85 | /** 86 | * This is the key method of TableModel: it returns the value at each cell 87 | * of the table. We use strings in this case. If anything goes wrong, we 88 | * return the exception as a string, so it will be displayed in the table. 89 | * Note that SQL row and column numbers start at 1, but TableModel column 90 | * numbers start at 0. 91 | **/ 92 | public Object getValueAt(int row, int column) { 93 | try { 94 | results.absolute(row+1); // Go to the specified row 95 | Object o = results.getObject(column+1); // Get value of the column 96 | if (o == null) return null; 97 | else return o.toString(); // Convert it to a string 98 | } catch (SQLException e) { return e.toString(); } 99 | } 100 | 101 | // Our table isn't editable 102 | public boolean isCellEditable(int row, int column) { return false; } 103 | 104 | // Since its not editable, we don't need to implement these methods 105 | // commented out 4/3/07 so that we can override this class to be editable 106 | // public void setValueAt(Object value, int row, int column) {} 107 | // public void addTableModelListener(TableModelListener l) {} 108 | // public void removeTableModelListener(TableModelListener l) {} 109 | } 110 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/UI/Swing/CPSDialog.java: -------------------------------------------------------------------------------- 1 | /* CPSDialog.java - created: Mar 7, 2008 2 | * Copyright (C) 2008 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | * 22 | */ 23 | 24 | package CPS.UI.Swing; 25 | 26 | import java.awt.Component; 27 | import javax.swing.BorderFactory; 28 | import javax.swing.JDialog; 29 | import javax.swing.JFrame; 30 | import javax.swing.JLabel; 31 | import javax.swing.JPanel; 32 | import javax.swing.JSeparator; 33 | import javax.swing.SwingUtilities; 34 | import net.miginfocom.swing.MigLayout; 35 | import org.jdesktop.swingx.JXTitledPanel; 36 | 37 | public abstract class CPSDialog extends JDialog { 38 | 39 | protected JXTitledPanel header; 40 | private JPanel jplMain; 41 | protected JPanel jplContents; 42 | protected JPanel jplButtons; 43 | 44 | private Component parent; 45 | // private JFrame parentFrame; 46 | 47 | protected boolean contentsPanelBuilt = false; 48 | 49 | public CPSDialog ( String title ) { 50 | this( new JPanel(), title ); 51 | } 52 | 53 | public CPSDialog ( Component parent, String title ) { 54 | 55 | super( (JFrame) SwingUtilities.getWindowAncestor(parent), true ); 56 | 57 | this.parent = parent; 58 | 59 | header = new JXTitledPanel(); 60 | header.setBorder(BorderFactory.createEmptyBorder()); 61 | setTitle( title ); 62 | 63 | initContentsPanel(); 64 | 65 | initButtonPanel(); 66 | fillButtonPanel(); 67 | 68 | buildMainPanel(); 69 | 70 | super.add( jplMain ); 71 | 72 | } 73 | 74 | 75 | @Override 76 | public Component add( Component arg0 ) { 77 | if ( ! ( arg0 instanceof JPanel )) { 78 | JPanel jp = new JPanel( new MigLayout("wrap 1, align left, gapy 0px!, insets 2px") ); 79 | jp.setBorder( BorderFactory.createEmptyBorder(0, 10, 0, 10)); 80 | jp.add( arg0 ); 81 | return jplContents.add( jp ); 82 | } 83 | else 84 | return jplContents.add( arg0 ); 85 | } 86 | 87 | @Override public void setVisible( boolean show ) { 88 | if ( ! contentsPanelBuilt ) 89 | buildContentsPanel(); 90 | 91 | if ( show ) { 92 | pack(); 93 | setResizable(false); 94 | // should we be setting position relative to parent component or 95 | // parent frame? 96 | setLocationRelativeTo( parent ); 97 | } 98 | super.setVisible( show ); 99 | } 100 | 101 | @Override 102 | public void setTitle( String s ) { 103 | super.setTitle(s); 104 | setHeaderTitle( s ); 105 | } 106 | 107 | public void setHeaderTitle( String s ) { 108 | header.setTitle(s); 109 | } 110 | 111 | /** 112 | * @param s Text to be displayed. This will be treated as HTML. 113 | */ 114 | public void setDescription( String s ) { 115 | JPanel jpl = new JPanel( new MigLayout( "insets n n 0px n, fillx") ); 116 | jpl.add( new JLabel( "" + s + "" ), "wrap" ); 117 | jpl.add( new JSeparator( JSeparator.HORIZONTAL ), "growx, wrap" ); 118 | header.setContentContainer(jpl); 119 | } 120 | 121 | protected void buildMainPanel() { 122 | 123 | jplMain = new JPanel( new MigLayout("wrap 1, gapy 0px!, insets 2px") ); 124 | jplMain.add( header, "growx" ); 125 | jplMain.add( jplContents, "align center" ); 126 | jplMain.add( jplButtons, "align right" ); 127 | 128 | } 129 | 130 | protected void initContentsPanel() { 131 | 132 | jplContents = new JPanel(new MigLayout("gapy 0px!, insets 2px, wrap 1")); 133 | 134 | } 135 | protected abstract void buildContentsPanel(); 136 | 137 | protected void initButtonPanel() { 138 | 139 | jplButtons = new JPanel(new MigLayout("gapy 0px!, insets 2px", "align right")); 140 | jplButtons.setBorder( BorderFactory.createEmptyBorder(0, 10, 5, 10)); 141 | 142 | } 143 | 144 | protected abstract void fillButtonPanel(); 145 | protected void addButton( Component comp ) { 146 | jplButtons.add( comp ); 147 | } 148 | 149 | } 150 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Core/UI/FirstRunDialog.java: -------------------------------------------------------------------------------- 1 | /* FirstRunDialog.java - created: Feb 13, 2008 2 | * Copyright (C) 2008 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | * 22 | */ 23 | 24 | package CPS.Core.UI; 25 | 26 | import CPS.UI.Swing.CPSDialog; 27 | import java.awt.Component; 28 | import java.awt.event.ActionEvent; 29 | import java.awt.event.ActionListener; 30 | import java.io.File; 31 | import javax.swing.BorderFactory; 32 | import javax.swing.BoxLayout; 33 | import javax.swing.JButton; 34 | import javax.swing.JFileChooser; 35 | import javax.swing.JFrame; 36 | import javax.swing.JLabel; 37 | import javax.swing.JPanel; 38 | 39 | public class FirstRunDialog extends CPSDialog implements ActionListener { 40 | 41 | String defaultDirectory; 42 | JPanel jplContents; 43 | JLabel lblOutDir; 44 | JFileChooser flchOutDir; 45 | JButton btnChoose, btnDone; 46 | 47 | public FirstRunDialog( String title, String defaultDir ) { 48 | 49 | super( title ); 50 | setTitle( "Welcome to Crop Planning Software" ); 51 | 52 | setDescription( "It appears that this is your first time running
" + 53 | "this program. Please select the folder or directory
" + 54 | "where you would like this program to store it's
" + 55 | "data. (You can change this later.) If this is
" + 56 | "not the first time you've run this program, then
" + 57 | "it seems that your settings (but not necessarily
" + 58 | "your data) have been lost. Just choose the folder
" + 59 | "or directory you where your data files are stored.
" + 60 | "(The data files have names that start with \"CPSdb\".)" ); 61 | 62 | defaultDirectory = defaultDir; 63 | // flchOutDir.setSelectedFile( new File( defaultDirectory )); 64 | // lblOutDir.setText( flchOutDir.getSelectedFile().getAbsolutePath() ); 65 | 66 | 67 | } 68 | 69 | protected void buildContentsPanel() { 70 | 71 | jplContents = new JPanel(); 72 | jplContents.setLayout( new BoxLayout( jplContents, BoxLayout.PAGE_AXIS ) ); 73 | jplContents.setBorder( BorderFactory.createEmptyBorder( 0, 10, 0, 10 ) ); 74 | 75 | JLabel lblOutDisp = new JLabel( "Output directory:" ); 76 | lblOutDisp.setAlignmentX( Component.RIGHT_ALIGNMENT ); 77 | jplContents.add( lblOutDisp ); 78 | 79 | flchOutDir = new JFileChooser(); 80 | flchOutDir.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY ); 81 | flchOutDir.setSelectedFile( new File( defaultDirectory )); 82 | 83 | lblOutDir = new JLabel( flchOutDir.getSelectedFile().getAbsolutePath() ); 84 | lblOutDir.setAlignmentX( Component.CENTER_ALIGNMENT ); 85 | jplContents.add( lblOutDir ); 86 | 87 | if ( ! lblOutDir.getText().equals("") ) 88 | btnDone.setEnabled(true); 89 | 90 | add( jplContents ); 91 | 92 | } 93 | 94 | protected void fillButtonPanel() { 95 | 96 | btnChoose = new JButton( "Choose Output Directory" ); 97 | btnDone = new JButton( "Done" ); 98 | btnDone.setEnabled(false); 99 | 100 | btnChoose.addActionListener( this ); 101 | btnDone.addActionListener( this ); 102 | 103 | addButton( btnChoose ); 104 | addButton( btnDone ); 105 | 106 | } 107 | 108 | public String getOutputDir() { 109 | return lblOutDir.getText(); 110 | } 111 | 112 | public void actionPerformed( ActionEvent arg0 ) { 113 | String action = arg0.getActionCommand(); 114 | 115 | if ( action.equalsIgnoreCase( btnChoose.getText() ) ) { 116 | flchOutDir.setVisible(true); 117 | int status = flchOutDir.showDialog( jplContents, "Accept" ); 118 | if ( status == JFileChooser.APPROVE_OPTION ) { 119 | lblOutDir.setText( flchOutDir.getSelectedFile().getPath() ); 120 | btnDone.setEnabled(true); 121 | } 122 | } 123 | else if ( action.equalsIgnoreCase( btnDone.getText() )) { 124 | this.setVisible(false); 125 | } 126 | } 127 | 128 | // For testing 129 | public static void main(String[] args) { 130 | new FirstRunDialog( "Title", "." ).setVisible(true); 131 | System.exit(0); 132 | } 133 | 134 | } 135 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Data/CPSPlantingComparator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package CPS.Data; 6 | 7 | import CPS.UI.Modules.CPSComparator; 8 | 9 | /** 10 | * This currently doesn't do anything. 11 | * @deprecated 12 | */ 13 | public class CPSPlantingComparator extends CPSComparator { 14 | 15 | public CPSPlantingComparator(int pNum) { 16 | super(pNum); 17 | } 18 | 19 | @Override 20 | public int compare( Object a, Object b ) { 21 | 22 | CPSPlanting c = (CPSPlanting) a; 23 | CPSPlanting d = (CPSPlanting) b; 24 | 25 | 26 | switch ( propNum ) { 27 | 28 | case CPSPlanting.PROP_CROP_NAME: return super.compare( c.getCropName(), d.getCropName() ); 29 | case CPSPlanting.PROP_VAR_NAME: return super.compare( c.getVarietyName(), d.getVarietyName() ); 30 | case CPSPlanting.PROP_MATURITY: return super.compare( c.getMaturityDays(), d.getMaturityDays() ); 31 | case CPSPlanting.PROP_LOCATION: return super.compare( c.getLocation(), d.getLocation() ); 32 | 33 | // Dates 34 | // "effective" dates 35 | case CPSPlanting.PROP_DATE_PLANT: return super.compare( c.getDateToPlant(), d.getDateToPlant() ); 36 | case CPSPlanting.PROP_DATE_TP: return super.compare( c.getDateToTP(), d.getDateToTP() ); 37 | case CPSPlanting.PROP_DATE_HARVEST: return super.compare( c.getDateToHarvest(), d.getDateToHarvest() ); 38 | // planned dates 39 | case CPSPlanting.PROP_DATE_PLANT_PLAN: return super.compare( c.getDateToPlantPlanned(), d.getDateToPlantPlanned() ); 40 | case CPSPlanting.PROP_DATE_TP_PLAN: return super.compare( c.getDateToTPPlanned(), d.getDateToTPPlanned() ); 41 | case CPSPlanting.PROP_DATE_HARVEST_PLAN: return super.compare( c.getDateToHarvestPlanned(), d.getDateToHarvestPlanned() ); 42 | // actual dates 43 | case CPSPlanting.PROP_DATE_PLANT_ACTUAL: return super.compare( c.getDateToPlantActual(), d.getDateToPlantActual() ); 44 | case CPSPlanting.PROP_DATE_TP_ACTUAL: return super.compare( c.getDateToTPActual(), d.getDateToTPActual() ); 45 | case CPSPlanting.PROP_DATE_HARVEST_ACTUAL: return super.compare( c.getDateToHarvestActual(), d.getDateToHarvestActual() ); 46 | 47 | // Status Booleans 48 | case CPSPlanting.PROP_DONE_PLANTING: return super.compare( c.getDonePlanting(), d.getDonePlanting() ); 49 | case CPSPlanting.PROP_DONE_TP: return super.compare( c.getDoneTP(), d.getDoneTP() ); 50 | case CPSPlanting.PROP_DONE_HARVEST: return super.compare( c.getDoneHarvest(), d.getDoneHarvest() ); 51 | case CPSPlanting.PROP_IGNORE: return super.compare( c.getIgnore(), d.getIgnore() ); 52 | 53 | // Static Data 54 | // inheritable 55 | case CPSPlanting.PROP_MAT_ADJUST: return super.compare( c.getMatAdjust(), d.getMatAdjust() ); 56 | case CPSPlanting.PROP_ROWS_P_BED: return super.compare( c.getRowsPerBed(), d.getRowsPerBed() ); 57 | case CPSPlanting.PROP_ROW_SPACE: return super.compare( c.getRowSpacing(), d.getRowSpacing() ); 58 | // case CPSPlanting.PROP_CROP_NOTES: return super.compare( c.get, d.get ); 59 | 60 | case CPSPlanting.PROP_TIME_TO_TP: return super.compare( c.getTimeToTP(), d.getTimeToTP() ); 61 | case CPSPlanting.PROP_INROW_SPACE: return super.compare( c.getInRowSpacing(), d.getInRowSpacing() ); 62 | case CPSPlanting.PROP_FLAT_SIZE: return super.compare( c.getFlatSize(), d.getFlatSize() ); 63 | case CPSPlanting.PROP_PLANTING_NOTES: return super.compare( c.getPlantingNotes(), d.getPlantingNotes() ); 64 | 65 | // Calculated Data 66 | case CPSPlanting.PROP_BEDS_PLANT: return super.compare( c.getBedsToPlant(), d.getBedsToPlant() ); 67 | case CPSPlanting.PROP_PLANTS_NEEDED: return super.compare( c.getPlantsNeeded(), d.getPlantsNeeded() ); 68 | // case CPSPlanting.PROP_ROWFT_PLANT: return super.compare( c.get, d.get ); 69 | // case CPSPlanting.PROP_PLANTS_START: return super.compare( c.get, d.get ); 70 | // case CPSPlanting.PROP_FLATS_NEEDED: return super.compare( c.get, d.get ); 71 | // 72 | // // Yield 73 | // // static 74 | // case CPSPlanting.PROP_YIELD_P_FOOT: return super.compare( c.get, d.get ); 75 | // case CPSPlanting.PROP_YIELD_NUM_WEEKS: return super.compare( c.get, d.get ); 76 | // case CPSPlanting.PROP_YIELD_P_WEEK: return super.compare( c.get, d.get ); 77 | // case CPSPlanting.PROP_CROP_UNIT: return super.compare( c.get, d.get ); 78 | // case CPSPlanting.PROP_CROP_UNIT_VALUE: return super.compare( c.get, d.get ); 79 | // // calculated 80 | // case CPSPlanting.PROP_TOTAL_YIELD: return super.compare( c.get, d.get ); 81 | // 82 | // // Misc Metadata 83 | // // bools 84 | // case CPSPlanting.PROP_DIRECT_SEED: return super.compare( c.get, d.get ); 85 | // case CPSPlanting.PROP_FROST_HARDY: return super.compare( c.get, d.get ); 86 | // // Strings 87 | // case CPSPlanting.PROP_GROUPS: return super.compare( c.get, d.get ); 88 | // case CPSPlanting.PROP_KEYWORDS: return super.compare( c.get, d.get ); 89 | // case CPSPlanting.PROP_OTHER_REQ: return super.compare( c.get, d.get ); 90 | // case CPSPlanting.PROP_NOTES: return super.compare( c.get, d.get ); 91 | // 92 | // case CPSPlanting.PROP_CUSTOM1: return super.compare( c.get, d.get ); 93 | // case CPSPlanting.PROP_CUSTOM2: return super.compare( c.get, d.get ); 94 | // case CPSPlanting.PROP_CUSTOM3: return super.compare( c.get, d.get ); 95 | // case CPSPlanting.PROP_CUSTOM4: return super.compare( c.get, d.get ); 96 | // case CPSPlanting.PROP_CUSTOM5: return super.compare( c.get, d.get ); 97 | 98 | default: return 0; 99 | 100 | } 101 | 102 | } 103 | 104 | 105 | 106 | } 107 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/UI/Modules/CPSMasterDetailModule.java: -------------------------------------------------------------------------------- 1 | /* CPSDetailView.java 2 | * Copyright (C) 2007, 2008 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | */ 22 | 23 | package CPS.UI.Modules; 24 | 25 | import CPS.Data.CPSRecord; 26 | import CPS.Module.CPSDisplayableDataUserModule; 27 | import CPS.Module.CPSDataModel; 28 | import CPS.Module.CPSUI; 29 | import java.awt.Dimension; 30 | import java.util.List; 31 | import java.util.prefs.Preferences; 32 | import javax.swing.JPanel; 33 | import javax.swing.JSplitPane; 34 | import net.miginfocom.swing.MigLayout; 35 | 36 | /** 37 | * 38 | * @author Clayton 39 | */ 40 | public abstract class CPSMasterDetailModule extends CPSDisplayableDataUserModule { 41 | 42 | public final static String STATUS_NO_SELECTION = "No records selected. Select item from table above to display detailed information."; 43 | public final static String STATUS_IGNORED = "This record is set as IGNORED and cannot be editted. Uncheck \"Ignore\" to edit."; 44 | public final static String STATUS_BLANK = ""; 45 | public final static String STATUS_SAVED = "Changes saved."; 46 | 47 | 48 | private JPanel mainPanel = null; 49 | private JSplitPane splitPane; 50 | private CPSDetailView detail; 51 | private CPSMasterView master; 52 | 53 | protected Preferences modulePrefs; 54 | 55 | private CPSUI mainUI; 56 | 57 | public String getMasterTableName() { 58 | return master.getDisplayedTableName(); 59 | } 60 | 61 | protected void setMasterView( CPSMasterView mv ) { master = mv; } 62 | protected void setDetailView( CPSDetailView dv ) { detail = dv; } 63 | 64 | // TODO possibly remove this call an just replace it with 65 | // with a method to pass a record ID instead of a whole record 66 | protected void displayDetail( CPSRecord r ) { 67 | detail.displayRecord(r); 68 | } 69 | protected CPSRecord getDetailsForID( int id ) { 70 | return master.getDetailsForID( id ); 71 | } 72 | 73 | protected void clearDetailDisplay() { 74 | detail.clearDisplay(); 75 | } 76 | protected void setDetailViewForEditting() { 77 | detail.setForEditting(); 78 | } 79 | protected void selectRecordsInMasterView( List ids ) { 80 | master.selectRecords( ids ); 81 | } 82 | protected void updateRecordInMasterView( CPSRecord r ) { 83 | master.updateRecord( r ); 84 | } 85 | 86 | 87 | public JPanel getUI() { 88 | if ( mainPanel == null ) 89 | buildUI(); 90 | return mainPanel; 91 | } 92 | protected void initUI() { 93 | mainPanel = new JPanel( new MigLayout( "insets 2px", 94 | "[grow, fill]", 95 | "[grow, fill]" )); 96 | } 97 | protected void buildUI() { 98 | splitPane = new JSplitPane( JSplitPane.VERTICAL_SPLIT, 99 | master.getJPanel(), 100 | detail.getJPanel() ); 101 | splitPane.setDividerSize(5); 102 | splitPane.setDividerLocation(0.5); 103 | splitPane.setResizeWeight(1.0); // top get's more space 104 | splitPane.setOneTouchExpandable(false); 105 | splitPane.setContinuousLayout(true); 106 | initUI(); 107 | mainPanel.add(splitPane); 108 | } 109 | 110 | protected void setStatus( String s ) { 111 | detail.setStatus(s); 112 | } 113 | 114 | @Override 115 | public void setDataSource(CPSDataModel dm) { 116 | // set the data source for this object 117 | super.setDataSource(dm); 118 | 119 | // set the data source for these panels 120 | master.setDataSource(dm); 121 | detail.setDataSource(dm); 122 | } 123 | 124 | protected void initPrefs( Class c ) { 125 | modulePrefs = Preferences.userNodeForPackage(c); 126 | } 127 | 128 | protected Preferences getPrefs() { 129 | return modulePrefs; 130 | } 131 | 132 | public Dimension getSize() { 133 | return splitPane.getPreferredSize(); 134 | } 135 | 136 | @Override 137 | public void dataUpdated() { 138 | master.dataUpdated(); 139 | detail.dataUpdated(); 140 | } 141 | 142 | @Override 143 | public int init() { 144 | throw new UnsupportedOperationException( "Not supported yet." ); 145 | } 146 | 147 | @Override 148 | protected int saveState() { 149 | master.saveState(); 150 | detail.saveState(); 151 | return 0; 152 | } 153 | 154 | @Override 155 | public int shutdown() { 156 | master.shutdown(); 157 | detail.shutdown(); 158 | return 0; 159 | } 160 | 161 | } 162 | -------------------------------------------------------------------------------- /CropPlanning/src/CPS/Core/DB/HSQLSettings.java: -------------------------------------------------------------------------------- 1 | /* HSQLSettings.java - created: Feb 13, 2008 2 | * Copyright (C) 2008 Clayton Carter 3 | * 4 | * This file is part of the project "Crop Planning Software". For more 5 | * information: 6 | * website: https://github.com/claytonrcarter/cropplanning 7 | * email: cropplanning@gmail.com 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | * 22 | */ 23 | 24 | package CPS.Core.DB; 25 | 26 | import CPS.Module.CPSModule; 27 | import CPS.Module.CPSModuleSettings; 28 | import java.awt.event.ActionEvent; 29 | import java.awt.event.ActionListener; 30 | import java.awt.event.ItemEvent; 31 | import java.awt.event.ItemListener; 32 | import javax.swing.ButtonGroup; 33 | import javax.swing.JButton; 34 | import javax.swing.JFileChooser; 35 | import javax.swing.JLabel; 36 | import javax.swing.JPanel; 37 | import javax.swing.JRadioButton; 38 | 39 | public class HSQLSettings extends CPSModuleSettings implements ActionListener, 40 | ItemListener { 41 | 42 | public static final String KEY_USEGLOBALDIR = "USE_GLOBAL"; 43 | public static final String KEY_CUSTOMOUTDIR = "CUSTOM_DIR"; 44 | 45 | protected JRadioButton rdoUseGlobalDir, rdoUseCustomDir; 46 | protected boolean prefUseGlobalDirDefault = true; 47 | protected JLabel lblCustomOutDir; 48 | protected JFileChooser flchCustomDir; 49 | protected JButton btnCustomDir; 50 | 51 | 52 | public HSQLSettings() { 53 | super( HSQLDB.class ); 54 | CPSModule.debug( "HSQLSettings", "using pref node:" + HSQLDB.class.toString() ); 55 | 56 | rdoUseGlobalDir = new JRadioButton( "Use global output directory", false ); 57 | rdoUseGlobalDir.addItemListener(this); 58 | rdoUseCustomDir = new JRadioButton( "Use other directory:", false ); 59 | rdoUseCustomDir.addItemListener(this); 60 | ButtonGroup bg = new ButtonGroup(); 61 | bg.add( rdoUseCustomDir ); 62 | bg.add( rdoUseGlobalDir ); 63 | 64 | lblCustomOutDir = new JLabel(); 65 | 66 | flchCustomDir = new JFileChooser(); 67 | flchCustomDir.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY ); 68 | 69 | btnCustomDir = new JButton( "Choose Output Directory" ); 70 | btnCustomDir.addActionListener(this); 71 | 72 | buildConfigPanel(); 73 | rdoUseGlobalDir.doClick(); 74 | 75 | } 76 | 77 | public boolean getUseGlobalDir() { 78 | return getModulePreferences().getBoolean( KEY_USEGLOBALDIR, prefUseGlobalDirDefault ); 79 | } 80 | 81 | public String getCustomOutDir() { 82 | // TODO if we were really suave, this would default to the global output directory 83 | // for now, though, this should be fine 84 | return getModulePreferences().get( KEY_CUSTOMOUTDIR, 85 | flchCustomDir.getFileSystemView().getDefaultDirectory().getAbsolutePath() ); 86 | } 87 | 88 | 89 | private void buildConfigPanel() { 90 | 91 | initConfigPanel(); 92 | 93 | configPanel.add( new JLabel("Database output directory:"), "align left, wrap" ); 94 | 95 | configPanel.add( rdoUseGlobalDir, "wrap" ); 96 | configPanel.add( rdoUseCustomDir, "wrap" ); 97 | 98 | configPanel.add( lblCustomOutDir, "span 2, align center, wrap" ); 99 | 100 | configPanel.add( btnCustomDir, "align right, wrap" ); 101 | 102 | } 103 | 104 | public JPanel getConfigurationDisplay() { 105 | resetConfiguration(); 106 | return configPanel; 107 | } 108 | 109 | public void resetConfiguration() { 110 | if ( getUseGlobalDir() ) 111 | rdoUseGlobalDir.doClick(); 112 | else 113 | rdoUseCustomDir.doClick(); 114 | 115 | lblCustomOutDir.setText( getCustomOutDir() ); 116 | } 117 | 118 | public void resetConfigurationToDefaults() { 119 | rdoUseGlobalDir.doClick(); 120 | lblCustomOutDir.setText( flchCustomDir.getFileSystemView().getDefaultDirectory().getAbsolutePath() ); 121 | } 122 | 123 | public void saveConfiguration() { 124 | getModulePreferences().putBoolean( KEY_USEGLOBALDIR, rdoUseGlobalDir.isSelected() ); 125 | getModulePreferences().put( KEY_CUSTOMOUTDIR, lblCustomOutDir.getText() ); 126 | } 127 | 128 | public void itemStateChanged( ItemEvent arg0 ) { 129 | Object source = arg0.getSource(); 130 | 131 | if ( source == rdoUseGlobalDir ) { 132 | btnCustomDir.setEnabled(false); 133 | } 134 | else if ( source == rdoUseCustomDir ) { 135 | btnCustomDir.setEnabled(true); 136 | } 137 | 138 | } 139 | 140 | 141 | 142 | public void actionPerformed( ActionEvent arg0 ) { 143 | String action = arg0.getActionCommand(); 144 | 145 | if ( action.equalsIgnoreCase( btnCustomDir.getText() ) ) { 146 | flchCustomDir.setVisible(true); 147 | int status = flchCustomDir.showDialog( configPanel, "Accept" ); 148 | if ( status == JFileChooser.APPROVE_OPTION ) { 149 | lblCustomOutDir.setText( flchCustomDir.getSelectedFile().getPath() ); 150 | } 151 | } 152 | 153 | } 154 | 155 | } 156 | --------------------------------------------------------------------------------