├── .gitignore ├── contractmanager ├── .gitignore ├── src │ ├── main │ │ ├── resources │ │ │ ├── img │ │ │ │ ├── chart.png │ │ │ │ ├── chart.xcf │ │ │ │ ├── cm-folder.png │ │ │ │ ├── edit-copy.png │ │ │ │ ├── edit-undo.png │ │ │ │ ├── address-book-new.png │ │ │ │ ├── cm-folder-open.png │ │ │ │ ├── edit-undo_green.png │ │ │ │ ├── office-calendar.png │ │ │ │ ├── contractmanager-icon-64x64.png │ │ │ │ └── images.txt │ │ │ ├── templates │ │ │ │ ├── extension.odt │ │ │ │ ├── cancellation.odt │ │ │ │ └── skip_dynamics.odt │ │ │ ├── lang │ │ │ │ ├── contractmanager_messages_en_GB.properties │ │ │ │ └── contractmanager_messages_de_DE.properties │ │ │ ├── help │ │ │ │ ├── de_de │ │ │ │ │ ├── de.janrieke.contractmanager.gui.view.SettingsView.txt │ │ │ │ │ ├── de.janrieke.contractmanager.gui.view.WelcomeView.txt │ │ │ │ │ ├── de.janrieke.contractmanager.gui.view.AddressDetailView.txt │ │ │ │ │ ├── de.janrieke.contractmanager.gui.view.AddressListView.txt │ │ │ │ │ ├── de.janrieke.contractmanager.gui.view.ContractListView.txt │ │ │ │ │ ├── de.janrieke.contractmanager.gui.view.ContractDetailView.txt │ │ │ │ │ ├── de.janrieke.contractmanager.gui.view.ExpensesAnalysisView.txt │ │ │ │ │ └── de.janrieke.contractmanager.gui.view.IncomeExpensesAnalysisView.txt │ │ │ │ └── en_gb │ │ │ │ │ └── de.janrieke.contractmanager.gui.view.WelcomeView.txt │ │ │ └── sql │ │ │ │ ├── h2-create.sql │ │ │ │ └── mysql-create.sql │ │ └── java │ │ │ └── de │ │ │ └── janrieke │ │ │ └── contractmanager │ │ │ ├── gui │ │ │ ├── chart │ │ │ │ ├── BarChart.java │ │ │ │ ├── IncomeExpensesBarChart.java │ │ │ │ ├── Chart.java │ │ │ │ └── ChartData.java │ │ │ ├── button │ │ │ │ └── RestoreButton.java │ │ │ ├── parts │ │ │ │ ├── CostsListTablePart.java │ │ │ │ ├── OnlyForContractsWithRemindersContextMenuItem.java │ │ │ │ ├── SizeableTablePart.java │ │ │ │ └── ContractListTablePart.java │ │ │ ├── dialog │ │ │ │ ├── ContractDetailViewSettingsDialog.java │ │ │ │ ├── DebugDialog.java │ │ │ │ └── AboutDialog.java │ │ │ ├── input │ │ │ │ ├── CheckboxInput.java │ │ │ │ ├── PositiveIntegerInput.java │ │ │ │ └── ICSFileInput.java │ │ │ ├── action │ │ │ │ ├── RestoreAction.java │ │ │ │ ├── ShowSettingsView.java │ │ │ │ ├── ShowWelcomeView.java │ │ │ │ ├── ShowAddressListView.java │ │ │ │ ├── ShowContractListView.java │ │ │ │ ├── ShowExpensesAnalysisView.java │ │ │ │ ├── ShowTransactionDetailsView.java │ │ │ │ ├── ShowIncomeExpensesAnalysisView.java │ │ │ │ ├── ShowJameicaSettings.java │ │ │ │ ├── ShowAboutDialog.java │ │ │ │ ├── ShowDocumentStorage.java │ │ │ │ ├── ShowHibiscusSettings.java │ │ │ │ ├── ShowLicenseInfoView.java │ │ │ │ ├── ShowAddressDetailView.java │ │ │ │ ├── CreateNewCostEntry.java │ │ │ │ ├── DismissNextReminder.java │ │ │ │ ├── RemovePaydayFromCostEntry.java │ │ │ │ ├── ShowContractDetailView.java │ │ │ │ ├── DeleteCostEntry.java │ │ │ │ ├── DeleteContract.java │ │ │ │ └── DeleteAddress.java │ │ │ ├── menu │ │ │ │ ├── CostsListMenu.java │ │ │ │ ├── AddressListMenu.java │ │ │ │ └── ContractListMenu.java │ │ │ ├── view │ │ │ │ ├── AddressListView.java │ │ │ │ ├── LicenseInfoView.java │ │ │ │ ├── WelcomeView.java │ │ │ │ ├── ContractListView.java │ │ │ │ ├── IncomeExpensesAnalysisView.java │ │ │ │ └── ExpensesAnalysisView.java │ │ │ └── control │ │ │ │ ├── ExpensesAnalysisControl.java │ │ │ │ └── IncomeExpensesAnalysisControl.java │ │ │ ├── server │ │ │ ├── DBSupportMySqlImpl.java │ │ │ ├── VersionUtil.java │ │ │ ├── TransactionImpl.java │ │ │ └── SettingImpl.java │ │ │ ├── ext │ │ │ └── hibiscus │ │ │ │ ├── UmsatzImportWorker.java │ │ │ │ ├── UmsatzRemoveWorker.java │ │ │ │ ├── ContractDetailViewHibiscusCategories.java │ │ │ │ ├── TransactionUtils.java │ │ │ │ ├── ActiveWhenAssignedContextMenuItem.java │ │ │ │ └── NewTransactionsListener.java │ │ │ ├── util │ │ │ ├── CalendarBuilder.java │ │ │ ├── ValidRuntimes.java │ │ │ ├── ListMap.java │ │ │ └── DateUtils.java │ │ │ ├── models │ │ │ └── MonthlyCosts.java │ │ │ └── rmi │ │ │ ├── Transaction.java │ │ │ ├── Costs.java │ │ │ ├── Storage.java │ │ │ ├── Setting.java │ │ │ ├── IntervalType.java │ │ │ ├── Address.java │ │ │ ├── Version.java │ │ │ ├── ContractDBService.java │ │ │ └── DBSupport.java │ ├── updates │ │ └── java │ │ │ ├── update0024.java │ │ │ ├── update0023.java │ │ │ ├── AbstractUpdate.java │ │ │ ├── update0022.java │ │ │ ├── update0019.java │ │ │ ├── update0018.java │ │ │ ├── update0017.java │ │ │ ├── update0016.java │ │ │ ├── update0020.java │ │ │ └── update0021.java │ └── assembly │ │ └── assembly.xml ├── lib │ ├── org.odftoolkit.odfdom_0.8.9.jar │ ├── org.swtchart_0.10.0.v20160212.jar │ ├── org.swtchart.ext_0.10.0.v20160212.jar │ ├── images_info.xml │ ├── swtchart_info.xml │ ├── odfdom_info.xml │ └── odfdom_dependencies_info.xml ├── TEST_DB_UPDATES.txt ├── updatesite │ ├── repository.xml │ └── jameica-repository-1.0.xsd ├── README ├── .project ├── .classpath ├── VERSION_HISTORY.txt ├── BuildRelease.txt └── plugin.xml └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | /de_willuhn_ds.jar 2 | /de_willuhn_util.jar 3 | /hibiscus.jar 4 | /jameica.jar 5 | -------------------------------------------------------------------------------- /contractmanager/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | /.settings/ 3 | /target/ 4 | /repo/ 5 | /.pydevproject 6 | /dependency-reduced-pom.xml 7 | /updates/ 8 | -------------------------------------------------------------------------------- /contractmanager/src/main/resources/img/chart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janrieke/contractmanager/HEAD/contractmanager/src/main/resources/img/chart.png -------------------------------------------------------------------------------- /contractmanager/src/main/resources/img/chart.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janrieke/contractmanager/HEAD/contractmanager/src/main/resources/img/chart.xcf -------------------------------------------------------------------------------- /contractmanager/lib/org.odftoolkit.odfdom_0.8.9.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janrieke/contractmanager/HEAD/contractmanager/lib/org.odftoolkit.odfdom_0.8.9.jar -------------------------------------------------------------------------------- /contractmanager/lib/org.swtchart_0.10.0.v20160212.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janrieke/contractmanager/HEAD/contractmanager/lib/org.swtchart_0.10.0.v20160212.jar -------------------------------------------------------------------------------- /contractmanager/src/main/resources/img/cm-folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janrieke/contractmanager/HEAD/contractmanager/src/main/resources/img/cm-folder.png -------------------------------------------------------------------------------- /contractmanager/src/main/resources/img/edit-copy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janrieke/contractmanager/HEAD/contractmanager/src/main/resources/img/edit-copy.png -------------------------------------------------------------------------------- /contractmanager/src/main/resources/img/edit-undo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janrieke/contractmanager/HEAD/contractmanager/src/main/resources/img/edit-undo.png -------------------------------------------------------------------------------- /contractmanager/lib/org.swtchart.ext_0.10.0.v20160212.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janrieke/contractmanager/HEAD/contractmanager/lib/org.swtchart.ext_0.10.0.v20160212.jar -------------------------------------------------------------------------------- /contractmanager/src/main/resources/img/address-book-new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janrieke/contractmanager/HEAD/contractmanager/src/main/resources/img/address-book-new.png -------------------------------------------------------------------------------- /contractmanager/src/main/resources/img/cm-folder-open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janrieke/contractmanager/HEAD/contractmanager/src/main/resources/img/cm-folder-open.png -------------------------------------------------------------------------------- /contractmanager/src/main/resources/img/edit-undo_green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janrieke/contractmanager/HEAD/contractmanager/src/main/resources/img/edit-undo_green.png -------------------------------------------------------------------------------- /contractmanager/src/main/resources/img/office-calendar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janrieke/contractmanager/HEAD/contractmanager/src/main/resources/img/office-calendar.png -------------------------------------------------------------------------------- /contractmanager/src/main/resources/templates/extension.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janrieke/contractmanager/HEAD/contractmanager/src/main/resources/templates/extension.odt -------------------------------------------------------------------------------- /contractmanager/src/main/resources/templates/cancellation.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janrieke/contractmanager/HEAD/contractmanager/src/main/resources/templates/cancellation.odt -------------------------------------------------------------------------------- /contractmanager/src/main/resources/templates/skip_dynamics.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janrieke/contractmanager/HEAD/contractmanager/src/main/resources/templates/skip_dynamics.odt -------------------------------------------------------------------------------- /contractmanager/src/main/resources/img/contractmanager-icon-64x64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janrieke/contractmanager/HEAD/contractmanager/src/main/resources/img/contractmanager-icon-64x64.png -------------------------------------------------------------------------------- /contractmanager/src/main/resources/lang/contractmanager_messages_en_GB.properties: -------------------------------------------------------------------------------- 1 | # this file does not need to have any content 2 | # because English is the primary language 3 | # of this plugin -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/chart/BarChart.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janrieke/contractmanager/HEAD/contractmanager/src/main/java/de/janrieke/contractmanager/gui/chart/BarChart.java -------------------------------------------------------------------------------- /contractmanager/src/main/resources/lang/contractmanager_messages_de_DE.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janrieke/contractmanager/HEAD/contractmanager/src/main/resources/lang/contractmanager_messages_de_DE.properties -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/button/RestoreButton.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janrieke/contractmanager/HEAD/contractmanager/src/main/java/de/janrieke/contractmanager/gui/button/RestoreButton.java -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/server/DBSupportMySqlImpl.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janrieke/contractmanager/HEAD/contractmanager/src/main/java/de/janrieke/contractmanager/server/DBSupportMySqlImpl.java -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/parts/CostsListTablePart.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janrieke/contractmanager/HEAD/contractmanager/src/main/java/de/janrieke/contractmanager/gui/parts/CostsListTablePart.java -------------------------------------------------------------------------------- /contractmanager/src/main/resources/img/images.txt: -------------------------------------------------------------------------------- 1 | Tango Desktop Project (PD, http://tango.freedesktop.org/): 2 | edit-copy.png 3 | office-calendar.png 4 | edit-undo.png 5 | address-book-new.png 6 | 7 | Own work (PD): 8 | chart.png -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/ext/hibiscus/UmsatzImportWorker.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janrieke/contractmanager/HEAD/contractmanager/src/main/java/de/janrieke/contractmanager/ext/hibiscus/UmsatzImportWorker.java -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/ext/hibiscus/UmsatzRemoveWorker.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janrieke/contractmanager/HEAD/contractmanager/src/main/java/de/janrieke/contractmanager/ext/hibiscus/UmsatzRemoveWorker.java -------------------------------------------------------------------------------- /contractmanager/TEST_DB_UPDATES.txt: -------------------------------------------------------------------------------- 1 | In order to test database updates (located at src/updates/java/), execute "mvn validate". 2 | This will copy the compiled update*.class files to the "updates" folder, where the update 3 | will find and execute them. -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/chart/IncomeExpensesBarChart.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janrieke/contractmanager/HEAD/contractmanager/src/main/java/de/janrieke/contractmanager/gui/chart/IncomeExpensesBarChart.java -------------------------------------------------------------------------------- /contractmanager/lib/images_info.xml: -------------------------------------------------------------------------------- 1 | 2 | Tango Desktop Project 0.8.90 3 | Free images and icons library 4 | http://tango.freedesktop.org/ 5 | Public Domain 6 | -------------------------------------------------------------------------------- /contractmanager/src/main/resources/help/de_de/de.janrieke.contractmanager.gui.view.SettingsView.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janrieke/contractmanager/HEAD/contractmanager/src/main/resources/help/de_de/de.janrieke.contractmanager.gui.view.SettingsView.txt -------------------------------------------------------------------------------- /contractmanager/src/main/resources/help/de_de/de.janrieke.contractmanager.gui.view.WelcomeView.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janrieke/contractmanager/HEAD/contractmanager/src/main/resources/help/de_de/de.janrieke.contractmanager.gui.view.WelcomeView.txt -------------------------------------------------------------------------------- /contractmanager/src/main/resources/help/de_de/de.janrieke.contractmanager.gui.view.AddressDetailView.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janrieke/contractmanager/HEAD/contractmanager/src/main/resources/help/de_de/de.janrieke.contractmanager.gui.view.AddressDetailView.txt -------------------------------------------------------------------------------- /contractmanager/src/main/resources/help/de_de/de.janrieke.contractmanager.gui.view.AddressListView.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janrieke/contractmanager/HEAD/contractmanager/src/main/resources/help/de_de/de.janrieke.contractmanager.gui.view.AddressListView.txt -------------------------------------------------------------------------------- /contractmanager/src/main/resources/help/de_de/de.janrieke.contractmanager.gui.view.ContractListView.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janrieke/contractmanager/HEAD/contractmanager/src/main/resources/help/de_de/de.janrieke.contractmanager.gui.view.ContractListView.txt -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/dialog/ContractDetailViewSettingsDialog.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janrieke/contractmanager/HEAD/contractmanager/src/main/java/de/janrieke/contractmanager/gui/dialog/ContractDetailViewSettingsDialog.java -------------------------------------------------------------------------------- /contractmanager/src/main/resources/help/de_de/de.janrieke.contractmanager.gui.view.ContractDetailView.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janrieke/contractmanager/HEAD/contractmanager/src/main/resources/help/de_de/de.janrieke.contractmanager.gui.view.ContractDetailView.txt -------------------------------------------------------------------------------- /contractmanager/src/main/resources/help/de_de/de.janrieke.contractmanager.gui.view.ExpensesAnalysisView.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janrieke/contractmanager/HEAD/contractmanager/src/main/resources/help/de_de/de.janrieke.contractmanager.gui.view.ExpensesAnalysisView.txt -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/ext/hibiscus/ContractDetailViewHibiscusCategories.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janrieke/contractmanager/HEAD/contractmanager/src/main/java/de/janrieke/contractmanager/ext/hibiscus/ContractDetailViewHibiscusCategories.java -------------------------------------------------------------------------------- /contractmanager/src/main/resources/help/de_de/de.janrieke.contractmanager.gui.view.IncomeExpensesAnalysisView.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janrieke/contractmanager/HEAD/contractmanager/src/main/resources/help/de_de/de.janrieke.contractmanager.gui.view.IncomeExpensesAnalysisView.txt -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/parts/OnlyForContractsWithRemindersContextMenuItem.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janrieke/contractmanager/HEAD/contractmanager/src/main/java/de/janrieke/contractmanager/gui/parts/OnlyForContractsWithRemindersContextMenuItem.java -------------------------------------------------------------------------------- /contractmanager/lib/swtchart_info.xml: -------------------------------------------------------------------------------- 1 | 2 | SWTChart 0.10.0 3 | SWTChart is a chart drawing component. 4 | http://www.swtchart.org 5 | Eclipse Public License v1.0 - http://www.eclipse.org/legal/epl-v10.html 6 | -------------------------------------------------------------------------------- /contractmanager/src/main/resources/help/en_gb/de.janrieke.contractmanager.gui.view.WelcomeView.txt: -------------------------------------------------------------------------------- 1 |
2 |

3 | Welcome 4 |

5 | 6 |

7 | Welcome to ContractManager, the contract management software for Jameica. 8 |

9 |
-------------------------------------------------------------------------------- /contractmanager/lib/odfdom_info.xml: -------------------------------------------------------------------------------- 1 | 2 | ODFDOM - the OpenDocument API 0.8.9-incubating 3 | A free OpenDocument Format (ODF) library 4 | https://incubator.apache.org/odftoolkit/odfdom/index.html 5 | Apache License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt 6 | -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/util/CalendarBuilder.java: -------------------------------------------------------------------------------- 1 | package de.janrieke.contractmanager.util; 2 | 3 | import java.util.Calendar; 4 | 5 | /** 6 | * A simple builder class for calenders. Can be mocked for testing purposes. 7 | */ 8 | public class CalendarBuilder { 9 | public Calendar getInstance() { 10 | return Calendar.getInstance(); 11 | } 12 | } -------------------------------------------------------------------------------- /contractmanager/lib/odfdom_dependencies_info.xml: -------------------------------------------------------------------------------- 1 | 2 | ODFDOM dependencies 3 | commons-validator 1.4.0; org.apache.clerezza (rdf.rdfa) 0.1-incubating; org.apache.jena (jena-arq) 2.9.4; xerces (xercesImpl) 2.9.1 4 | https://incubator.apache.org/odftoolkit/mvn-site/0.8.9-incubating/odfdom-java/dependencies.html 5 | diverse 6 | -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/util/ValidRuntimes.java: -------------------------------------------------------------------------------- 1 | package de.janrieke.contractmanager.util; 2 | 3 | import de.janrieke.contractmanager.rmi.IntervalType; 4 | 5 | /** 6 | * Instances of this class shall only be returned if all fields are 7 | * set and valid. 8 | */ 9 | public class ValidRuntimes { 10 | public IntervalType firstMinRuntimeType; 11 | public Integer firstMinRuntimeCount; 12 | public IntervalType followingMinRuntimeType; 13 | public Integer followingMinRuntimeCount; 14 | public Boolean fixedTerms = false; 15 | } -------------------------------------------------------------------------------- /contractmanager/updatesite/repository.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /contractmanager/src/updates/java/update0024.java: -------------------------------------------------------------------------------- 1 | import de.janrieke.contractmanager.server.DBSupportH2Impl; 2 | 3 | /** 4 | * New flag to snap period ends to end of selected period, e.g., MONTHs. 5 | */ 6 | public class update0024 extends AbstractUpdate { 7 | /** 8 | * Default constructor 9 | */ 10 | public update0024() { 11 | // Update for H2 12 | statements.put(DBSupportH2Impl.class.getName(), 13 | "ALTER TABLE costs ADD COLUMN payday date;\n"); 14 | } 15 | 16 | /** 17 | * @see de.willuhn.sql.version.Update#getName() 18 | */ 19 | @Override 20 | public String getName() { 21 | return "Database update v23 to v24 (add payday for costs)"; 22 | } 23 | } -------------------------------------------------------------------------------- /contractmanager/src/updates/java/update0023.java: -------------------------------------------------------------------------------- 1 | import de.janrieke.contractmanager.server.DBSupportH2Impl; 2 | 3 | /** 4 | * New flag to snap period ends to end of selected period, e.g., MONTHs. 5 | */ 6 | public class update0023 extends AbstractUpdate { 7 | /** 8 | * Default constructor 9 | */ 10 | public update0023() { 11 | // Update for H2 12 | statements.put(DBSupportH2Impl.class.getName(), 13 | "ALTER TABLE contract ADD COLUMN runtime_snap_to_end int(1);\n"); 14 | } 15 | 16 | /** 17 | * @see de.willuhn.sql.version.Update#getName() 18 | */ 19 | @Override 20 | public String getName() { 21 | return "Database update v22 to v23 (add snap to end of period flag)"; 22 | } 23 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ContractManager 2 | 3 | ContractManager is a contract management software for the Jameica platform (http://willuhn.de/products/jameica/). It allows you to enter details of your contracts, e.g., financial information, runtime, or cancellation deadlines. It notifies you about upcoming cancellation deadlines. 4 | 5 | For installation instruction, see http://janrieke.de/contractmanager/. 6 | 7 | [ContractManager Web Site](http://janrieke.de/contractmanager/) 8 | 9 | ## Features 10 | * Management of contractual details, e.g., financial information, addresses, terms, documents 11 | * Reminders for cancellation deadlines 12 | * Export reminders to iCalendar file 13 | * Generation of letters of cancellation 14 | -------------------------------------------------------------------------------- /contractmanager/README: -------------------------------------------------------------------------------- 1 | ContractManager for Jameica 2 | Copyright (C) 2010-2019 Jan Rieke 3 | 4 | ContractManager is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | ContractManager is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | 17 | 18 | 19 | Contact the author at: it (AT) janrieke (DOT) de -------------------------------------------------------------------------------- /contractmanager/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | contractmanager 4 | 5 | 6 | 7 | 8 | 9 | org.python.pydev.PyDevBuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.jdt.core.javabuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.m2e.core.maven2Builder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.m2e.core.maven2Nature 26 | org.eclipse.jdt.core.javanature 27 | org.python.pydev.pythonNature 28 | 29 | 30 | -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/input/CheckboxInput.java: -------------------------------------------------------------------------------- 1 | package de.janrieke.contractmanager.gui.input; 2 | 3 | import org.eclipse.swt.widgets.Control; 4 | import org.eclipse.swt.widgets.Label; 5 | 6 | /** 7 | * Extends the {@link de.willuhn.jameica.gui.input.CheckboxInput} class with 8 | * tooltips. 9 | */ 10 | public class CheckboxInput extends de.willuhn.jameica.gui.input.CheckboxInput { 11 | 12 | private String tooltip; 13 | private Control control; 14 | 15 | public CheckboxInput(boolean value) { 16 | super(value); 17 | } 18 | 19 | @Override 20 | public Control getControl() { 21 | if (control != null) { 22 | return control; 23 | } 24 | control = super.getControl(); 25 | if (tooltip != null) { 26 | control.setToolTipText(tooltip); 27 | setTooltipForLabel(tooltip); 28 | } 29 | return control; 30 | } 31 | 32 | public void setTooltip(String tooltip) { 33 | this.tooltip = tooltip; 34 | if (control != null) { 35 | control.setToolTipText(tooltip); 36 | setTooltipForLabel(tooltip); 37 | } 38 | } 39 | 40 | private void setTooltipForLabel(String tooltip) { 41 | Object label = getData("jameica.label"); 42 | if (label instanceof Label) { 43 | ((Label) label).setToolTipText(tooltip); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/models/MonthlyCosts.java: -------------------------------------------------------------------------------- 1 | package de.janrieke.contractmanager.models; 2 | 3 | import de.janrieke.contractmanager.rmi.IntervalType; 4 | 5 | /** 6 | * Helper class to provide a model for drawing monthly costs statistics. 7 | */ 8 | public class MonthlyCosts { 9 | private final String description; 10 | private final double money; 11 | 12 | public MonthlyCosts(String description, double money) { 13 | super(); 14 | this.description = description; 15 | this.money = money; 16 | } 17 | 18 | public static double averageToMonthly(double money, IntervalType interval) { 19 | switch (interval) { 20 | case DAYS: 21 | return money * 30; 22 | case WEEKS: 23 | return money * (52d/12); 24 | case MONTHS: 25 | return money; 26 | case QUARTER_YEARS: 27 | return money / 3; 28 | case HALF_YEARS: 29 | return money / 6; 30 | case YEARS: 31 | return money / 12; 32 | 33 | default: 34 | return 0.0f; 35 | } 36 | } 37 | 38 | public static MonthlyCosts averageToMonthlyCosts(String description, double money, IntervalType interval) { 39 | return new MonthlyCosts(description, averageToMonthly(money, interval)); 40 | } 41 | 42 | public String getDescription() { 43 | return description; 44 | } 45 | 46 | public double getMoney() { 47 | return money; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/action/RestoreAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.gui.action; 19 | 20 | import de.willuhn.jameica.gui.AbstractView; 21 | import de.willuhn.jameica.gui.Action; 22 | import de.willuhn.jameica.gui.GUI; 23 | import de.willuhn.util.ApplicationException; 24 | 25 | public class RestoreAction implements Action { 26 | 27 | private AbstractView view; 28 | 29 | public RestoreAction(AbstractView view) { 30 | this.view = view; 31 | } 32 | 33 | @Override 34 | public void handleAction(Object context) throws ApplicationException { 35 | GUI.startView(view, context); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/action/ShowSettingsView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.gui.action; 19 | 20 | import de.willuhn.jameica.gui.Action; 21 | import de.willuhn.jameica.gui.GUI; 22 | import de.willuhn.util.ApplicationException; 23 | 24 | /** 25 | * Action to open the project list. 26 | */ 27 | public class ShowSettingsView implements Action { 28 | 29 | /** 30 | * @see de.willuhn.jameica.gui.Action#handleAction(java.lang.Object) 31 | */ 32 | public void handleAction(Object context) throws ApplicationException { 33 | GUI.startView(de.janrieke.contractmanager.gui.view.SettingsView.class 34 | .getName(), null); 35 | } 36 | 37 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/action/ShowWelcomeView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.gui.action; 19 | 20 | import de.willuhn.jameica.gui.Action; 21 | import de.willuhn.jameica.gui.GUI; 22 | import de.willuhn.util.ApplicationException; 23 | 24 | /** 25 | * Action for the welcome screen. 26 | */ 27 | public class ShowWelcomeView implements Action { 28 | 29 | /** 30 | * @see de.willuhn.jameica.gui.Action#handleAction(java.lang.Object) 31 | */ 32 | public void handleAction(Object context) throws ApplicationException { 33 | GUI.startView( 34 | de.janrieke.contractmanager.gui.view.WelcomeView.class.getName(), 35 | null); 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/action/ShowAddressListView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.gui.action; 19 | 20 | import de.willuhn.jameica.gui.Action; 21 | import de.willuhn.jameica.gui.GUI; 22 | import de.willuhn.util.ApplicationException; 23 | 24 | /** 25 | * Action to open the project list. 26 | */ 27 | public class ShowAddressListView implements Action { 28 | 29 | /** 30 | * @see de.willuhn.jameica.gui.Action#handleAction(java.lang.Object) 31 | */ 32 | public void handleAction(Object context) throws ApplicationException { 33 | GUI.startView(de.janrieke.contractmanager.gui.view.AddressListView.class 34 | .getName(), null); 35 | } 36 | 37 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/action/ShowContractListView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.gui.action; 19 | 20 | import de.willuhn.jameica.gui.Action; 21 | import de.willuhn.jameica.gui.GUI; 22 | import de.willuhn.util.ApplicationException; 23 | 24 | /** 25 | * Action to open the project list. 26 | */ 27 | public class ShowContractListView implements Action { 28 | 29 | /** 30 | * @see de.willuhn.jameica.gui.Action#handleAction(java.lang.Object) 31 | */ 32 | public void handleAction(Object context) throws ApplicationException { 33 | GUI.startView(de.janrieke.contractmanager.gui.view.ContractListView.class 34 | .getName(), null); 35 | } 36 | 37 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/action/ShowExpensesAnalysisView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.gui.action; 19 | 20 | import de.willuhn.jameica.gui.Action; 21 | import de.willuhn.jameica.gui.GUI; 22 | import de.willuhn.util.ApplicationException; 23 | 24 | /** 25 | * Action to open the project list. 26 | */ 27 | public class ShowExpensesAnalysisView implements Action { 28 | 29 | /** 30 | * @see de.willuhn.jameica.gui.Action#handleAction(java.lang.Object) 31 | */ 32 | public void handleAction(Object context) throws ApplicationException { 33 | GUI.startView(de.janrieke.contractmanager.gui.view.ExpensesAnalysisView.class 34 | .getName(), null); 35 | } 36 | 37 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/action/ShowTransactionDetailsView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.gui.action; 19 | 20 | import de.willuhn.jameica.gui.Action; 21 | import de.willuhn.jameica.gui.GUI; 22 | import de.willuhn.util.ApplicationException; 23 | 24 | /** 25 | * Action to open the project list. 26 | */ 27 | public class ShowTransactionDetailsView implements Action { 28 | 29 | /** 30 | * @see de.willuhn.jameica.gui.Action#handleAction(java.lang.Object) 31 | */ 32 | public void handleAction(Object context) throws ApplicationException { 33 | GUI.startView(de.janrieke.contractmanager.gui.view.ContractListView.class 34 | .getName(), null); 35 | } 36 | 37 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/rmi/Transaction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.rmi; 19 | 20 | import java.rmi.RemoteException; 21 | 22 | import de.willuhn.datasource.rmi.DBObject; 23 | 24 | /* 25 | * CREATE TABLE umsaetze ( 26 | * umsatz_id int(4), 27 | * contract_id int(4), 28 | * UNIQUE (umsatz_id), 29 | * PRIMARY KEY (umsatz_id) 30 | * ); 31 | */ 32 | public interface Transaction extends DBObject { 33 | public void setTransactionID(Integer id) throws RemoteException; 34 | public Integer getTransactionID() throws RemoteException; 35 | public Contract getContract() throws RemoteException; 36 | public void setContract(Contract contract) throws RemoteException; 37 | } 38 | -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/action/ShowIncomeExpensesAnalysisView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.gui.action; 19 | 20 | import de.willuhn.jameica.gui.Action; 21 | import de.willuhn.jameica.gui.GUI; 22 | import de.willuhn.util.ApplicationException; 23 | 24 | /** 25 | * Action to open the project list. 26 | */ 27 | public class ShowIncomeExpensesAnalysisView implements Action { 28 | 29 | /** 30 | * @see de.willuhn.jameica.gui.Action#handleAction(java.lang.Object) 31 | */ 32 | public void handleAction(Object context) throws ApplicationException { 33 | GUI.startView(de.janrieke.contractmanager.gui.view.IncomeExpensesAnalysisView.class 34 | .getName(), null); 35 | } 36 | 37 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/action/ShowJameicaSettings.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.gui.action; 19 | 20 | import de.willuhn.jameica.gui.Action; 21 | import de.willuhn.jameica.gui.GUI; 22 | import de.willuhn.jameica.gui.internal.views.Settings; 23 | import de.willuhn.util.ApplicationException; 24 | 25 | public class ShowJameicaSettings implements Action { 26 | 27 | private String tab; 28 | 29 | public ShowJameicaSettings(String tab) { 30 | this.tab = tab; 31 | } 32 | 33 | /** 34 | * @see de.willuhn.jameica.gui.Action#handleAction(java.lang.Object) 35 | */ 36 | public void handleAction(Object context) throws ApplicationException { 37 | GUI.startView(Settings.class, tab); 38 | } 39 | } -------------------------------------------------------------------------------- /contractmanager/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/ext/hibiscus/TransactionUtils.java: -------------------------------------------------------------------------------- 1 | package de.janrieke.contractmanager.ext.hibiscus; 2 | 3 | import java.rmi.RemoteException; 4 | import java.util.Optional; 5 | 6 | import de.janrieke.contractmanager.Settings; 7 | import de.janrieke.contractmanager.rmi.Contract; 8 | import de.janrieke.contractmanager.rmi.Transaction; 9 | import de.willuhn.datasource.rmi.DBIterator; 10 | import de.willuhn.datasource.rmi.DBService; 11 | import de.willuhn.jameica.hbci.rmi.Umsatz; 12 | 13 | public class TransactionUtils { 14 | private TransactionUtils() { 15 | throw new AssertionError("no instantiation"); 16 | } 17 | 18 | /** 19 | * Prueft, ob der Umsatz bereits einem Vertrag zugeordnet ist. 20 | * @param u der zu pruefende Umsatz. 21 | * @return true, wenn es bereits einen Vertrag gibt. 22 | * @throws Exception 23 | */ 24 | public static boolean isAssigned(Umsatz u) throws RemoteException { 25 | return getTransactionsFor(u).hasNext(); 26 | } 27 | 28 | public static Optional getContractFor(Umsatz u) throws RemoteException { 29 | DBIterator transactions = getTransactionsFor(u); 30 | if (transactions.hasNext()) { 31 | return Optional.of(transactions.next().getContract()); 32 | } 33 | return Optional.empty(); 34 | } 35 | 36 | private static DBIterator getTransactionsFor(Umsatz u) throws RemoteException { 37 | DBService service = Settings.getDBService(); 38 | DBIterator transactions = service.createList(Transaction.class); 39 | transactions.addFilter("transaction_id = ?",new Object[]{u.getID()}); 40 | return transactions; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/input/PositiveIntegerInput.java: -------------------------------------------------------------------------------- 1 | package de.janrieke.contractmanager.gui.input; 2 | 3 | import org.eclipse.swt.SWT; 4 | import org.eclipse.swt.widgets.Control; 5 | import org.eclipse.swt.widgets.Event; 6 | import org.eclipse.swt.widgets.Listener; 7 | 8 | import de.willuhn.jameica.gui.input.IntegerInput; 9 | 10 | public class PositiveIntegerInput extends IntegerInput { 11 | public PositiveIntegerInput() { 12 | super(); 13 | } 14 | 15 | public PositiveIntegerInput(int value) { 16 | super(value < 0 ? 0 : value); 17 | } 18 | 19 | /** 20 | * @see de.willuhn.jameica.gui.input.Input#getControl() 21 | */ 22 | public Control getControl() { 23 | final Control c = super.getControl(); 24 | if (c != text) 25 | return c; //this should not happen 26 | if ((Integer)getValue() == 0) 27 | text.setText(""); 28 | text.addListener(SWT.FocusOut, new Listener() { 29 | public void handleEvent(Event event) { 30 | Object value = getValue(); 31 | if (value == null || value.toString().length() == 0) 32 | return; 33 | try { 34 | Integer intVal = new Integer(value.toString()); 35 | if (intVal <= 0) { 36 | setValue(0); 37 | text.setText(""); 38 | } else 39 | setValue(intVal); // normalize 40 | } catch (NumberFormatException e) { 41 | setValue(0); 42 | text.setText(""); 43 | } 44 | } 45 | }); 46 | return c; 47 | } 48 | 49 | @Override 50 | public Object getValue() { 51 | Object value = super.getValue(); 52 | if (value == null || !(value instanceof Integer) || (Integer) value < 0) 53 | return 0; 54 | else 55 | return value; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/action/ShowAboutDialog.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.gui.action; 19 | 20 | import de.janrieke.contractmanager.Settings; 21 | import de.willuhn.jameica.gui.Action; 22 | import de.willuhn.jameica.gui.dialogs.AbstractDialog; 23 | import de.willuhn.logging.Logger; 24 | import de.willuhn.util.ApplicationException; 25 | 26 | public class ShowAboutDialog implements Action { 27 | 28 | /** 29 | * @see de.willuhn.jameica.gui.Action#handleAction(java.lang.Object) 30 | */ 31 | public void handleAction(Object context) throws ApplicationException { 32 | try { 33 | new de.janrieke.contractmanager.gui.dialog.AboutDialog( 34 | AbstractDialog.POSITION_CENTER).open(); 35 | } catch (Exception e) { 36 | Logger.error("error while opening about dialog", e); 37 | throw new ApplicationException(Settings.i18n().tr( 38 | "Error while opening the About dialog")); 39 | } 40 | } 41 | 42 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/action/ShowDocumentStorage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.gui.action; 19 | 20 | import de.janrieke.contractmanager.Settings; 21 | import de.janrieke.contractmanager.rmi.Contract; 22 | import de.willuhn.jameica.gui.Action; 23 | import de.willuhn.logging.Logger; 24 | import de.willuhn.util.ApplicationException; 25 | 26 | public class ShowDocumentStorage implements Action { 27 | 28 | /** 29 | * @see de.willuhn.jameica.gui.Action#handleAction(java.lang.Object) 30 | */ 31 | public void handleAction(Object context) throws ApplicationException { 32 | try { 33 | new de.janrieke.contractmanager.gui.dialog.DocumentStorageDialog((Contract) context).open(); 34 | } catch (Exception e) { 35 | Logger.error("error while opening file storage dialog", e); 36 | throw new ApplicationException(Settings.i18n().tr( 37 | "Error while opening the storage dialog")); 38 | } 39 | } 40 | 41 | } -------------------------------------------------------------------------------- /contractmanager/src/assembly/assembly.xml: -------------------------------------------------------------------------------- 1 | 5 | bin 6 | 7 | zip 8 | 9 | contractmanager 10 | 11 | 12 | ${project.basedir} 13 | 14 | 15 | README 16 | VERSION_HISTORY.txt 17 | LICENSE 18 | plugin.xml 19 | 20 | 21 | 22 | ${project.build.directory}/classes 23 | updates/ 24 | 25 | *.class 26 | 27 | 28 | 29 | ${project.basedir}/lib 30 | lib/ 31 | 32 | *.xml 33 | epl-v10.html 34 | org.odftoolkit.odfdom_0.8.9.jar 35 | 36 | 37 | 38 | ${project.basedir}/src/main/resources/sql 39 | sql/ 40 | 41 | 42 | ${project.basedir}/src/main/resources/templates 43 | templates/ 44 | 45 | 46 | 47 | 48 | ${project.build.directory}/${project.build.finalName}.jar 49 | contractmanager.jar 50 | 51 | 52 | -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/input/ICSFileInput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.gui.input; 19 | 20 | import org.eclipse.swt.widgets.FileDialog; 21 | 22 | import de.janrieke.contractmanager.Settings; 23 | import de.willuhn.jameica.gui.input.FileInput; 24 | 25 | /** 26 | * FileInput with customized dialog for ICS file selection. 27 | */ 28 | public class ICSFileInput extends FileInput { 29 | 30 | private boolean save; 31 | 32 | public ICSFileInput(String file, boolean save) { 33 | super(file, save); 34 | this.save = save; 35 | } 36 | 37 | @Override 38 | protected void customize(FileDialog fd) { 39 | String[] names = { 40 | Settings.i18n().tr("iCalendar file" + " (*.ics)"), 41 | Settings.i18n().tr("All files") + " (*.*)" }; 42 | String[] filters = { "*.ics", "*.*" }; 43 | fd.setFilterExtensions(filters); 44 | fd.setFilterNames(names); 45 | if (save) 46 | fd.setOverwrite(true); 47 | fd.setFileName(value); 48 | super.customize(fd); 49 | } 50 | } -------------------------------------------------------------------------------- /contractmanager/VERSION_HISTORY.txt: -------------------------------------------------------------------------------- 1 | VERSION HISTORY: 2 | 3 | 0.1: 4 | - Basic contract management 5 | - Cancellation Reminder 6 | - Generation of letters of cancellation 7 | - Export reminders to iCal 8 | 9 | 0.2: 10 | - Reload iCal file instead of overwriting (do not re-remind of already checked cancellation) 11 | - Better address management 12 | 13 | 0.3: 14 | - Include payments from Hibiscus 15 | 16 | 0.3.1: 17 | - Moving iCal import/export to Jameica's calander + jameica.ical 18 | 19 | 0.4: 20 | - Analysis diagrams 21 | 22 | 0.4.1: 23 | - Bugfixes 24 | 25 | 0.4.2: 26 | - Bugfixes 27 | 28 | 0.5: 29 | - Document storage 30 | - SEPA-Mandatsreferenz und -Gl�ubiger-ID 31 | - Improved import dialog (intelligent pre-selection of contract) 32 | - Auto-import of new Hibiscus transactions 33 | - Added quarterly/semiannually as payment interval 34 | - update libs (ODFDOM 0.8.9-incubating) 35 | 36 | 0.5.1: 37 | - "Remind me next term" function 38 | - Dialog with database login data 39 | - Import/Export 40 | 41 | 0.5.2: 42 | - Hide inactive contracts from contract list 43 | - More templates for document generation 44 | - Improved assignment of Hibiscus transactions 45 | - "Snap to end" feature to fix the end date of a contract to, e.g., the end of month 46 | - Preparations for MySQL support (thx Harald) 47 | 48 | 0.5.3: 49 | - Payment dates 50 | - MySQL/MariaDB support 51 | 52 | 0.5.4: 53 | - Fixed exception in contract list 54 | 55 | 0.5.5: 56 | - Shortcut for "New Contract" is now ALT+N (avoid collision on Mac). 57 | - Re-saving a contract no longer unsets the Hibiscus category. 58 | - Jameica 2.8+ is now required. 59 | 60 | 61 | ROADMAP: 62 | 63 | 0.6: 64 | - Grouping of contracs 65 | 66 | 1.0: 67 | - Contract detection based on Hibiscus transactions 68 | - Analyses based on "real" Hibiscus transaction -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/action/ShowHibiscusSettings.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.gui.action; 19 | 20 | import de.janrieke.contractmanager.Settings; 21 | import de.willuhn.jameica.gui.Action; 22 | import de.willuhn.jameica.gui.dialogs.AbstractDialog; 23 | import de.willuhn.jameica.system.OperationCanceledException; 24 | import de.willuhn.logging.Logger; 25 | import de.willuhn.util.ApplicationException; 26 | 27 | public class ShowHibiscusSettings implements Action { 28 | 29 | /** 30 | * @see de.willuhn.jameica.gui.Action#handleAction(java.lang.Object) 31 | */ 32 | public void handleAction(Object context) throws ApplicationException { 33 | try { 34 | new de.janrieke.contractmanager.gui.dialog.ContractDetailViewSettingsDialog( 35 | AbstractDialog.POSITION_CENTER).open(); 36 | } catch (OperationCanceledException e) { 37 | } catch (Exception e) { 38 | Logger.error("error while opening about dialog", e); 39 | throw new ApplicationException(Settings.i18n().tr( 40 | "Error while opening the About dialog")); 41 | } 42 | } 43 | 44 | } -------------------------------------------------------------------------------- /contractmanager/src/updates/java/AbstractUpdate.java: -------------------------------------------------------------------------------- 1 | import java.io.StringReader; 2 | import java.util.HashMap; 3 | import java.util.Map; 4 | 5 | import de.janrieke.contractmanager.rmi.ContractDBService; 6 | import de.janrieke.contractmanager.server.ContractDBUpdateProvider; 7 | import de.janrieke.contractmanager.server.DBSupportH2Impl; 8 | import de.willuhn.logging.Logger; 9 | import de.willuhn.sql.ScriptExecutor; 10 | import de.willuhn.sql.version.Update; 11 | import de.willuhn.sql.version.UpdateProvider; 12 | import de.willuhn.util.ApplicationException; 13 | import de.willuhn.util.I18N; 14 | 15 | public abstract class AbstractUpdate implements Update { 16 | 17 | protected Map statements = new HashMap<>(); 18 | 19 | public AbstractUpdate() { 20 | super(); 21 | } 22 | 23 | /** 24 | * @see de.willuhn.sql.version.Update#execute(de.willuhn.sql.version.UpdateProvider) 25 | */ 26 | @Override 27 | public void execute(UpdateProvider provider) throws ApplicationException { 28 | ContractDBUpdateProvider myProvider = (ContractDBUpdateProvider) provider; 29 | I18N i18n = myProvider.getResources().getI18N(); 30 | 31 | // Get the SQL dialect 32 | String driver = ContractDBService.SETTINGS.getString("database.driver", 33 | DBSupportH2Impl.class.getName()); 34 | String sql = statements.get(driver); 35 | if (sql == null) { 36 | throw new ApplicationException(i18n.tr( 37 | "Database {0} not supported", driver)); 38 | } 39 | 40 | try { 41 | ScriptExecutor 42 | .execute(new StringReader(sql), myProvider.getConnection(), 43 | myProvider.getProgressMonitor()); 44 | myProvider.getProgressMonitor().log(i18n.tr("Database updated.")); 45 | } catch (ApplicationException ae) { 46 | throw ae; 47 | } catch (Exception e) { 48 | Logger.error("unable to execute update", e); 49 | throw new ApplicationException( 50 | i18n.tr("Error during database update"), e); 51 | } 52 | } 53 | 54 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/action/ShowLicenseInfoView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | /********************************************************************** 19 | * Copied from Jameica 20 | * 21 | * $Source: /cvsroot/jameica/jameica/src/de/willuhn/jameica/gui/internal/action/License.java,v $ 22 | * $Revision: 1.4 $ 23 | * $Date: 2005-01-19 00:15:49 $ 24 | * $Author: willuhn $ 25 | * $Locker: $ 26 | * $State: Exp $ 27 | * 28 | * Copyright (c) by willuhn.webdesign 29 | * All rights reserved 30 | * 31 | **********************************************************************/ 32 | 33 | package de.janrieke.contractmanager.gui.action; 34 | 35 | import de.willuhn.jameica.gui.Action; 36 | import de.willuhn.jameica.gui.GUI; 37 | import de.willuhn.util.ApplicationException; 38 | 39 | /** 40 | * @author willuhn 41 | */ 42 | public class ShowLicenseInfoView implements Action 43 | { 44 | 45 | /** 46 | * @see de.willuhn.jameica.gui.Action#handleAction(java.lang.Object) 47 | */ 48 | public void handleAction(Object context) throws ApplicationException 49 | { 50 | GUI.startView(de.janrieke.contractmanager.gui.view.LicenseInfoView.class,null); 51 | } 52 | 53 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/chart/Chart.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* 20 | * Partially copied from Hibiscus/Syntax, (c) by willuhn.webdesign 21 | */ 22 | package de.janrieke.contractmanager.gui.chart; 23 | 24 | import java.rmi.RemoteException; 25 | 26 | import de.willuhn.jameica.gui.Part; 27 | 28 | /** 29 | * Basis-Interface fuer ein Chart. 30 | * @param der Typ der Chartdaten. 31 | */ 32 | public interface Chart extends Part 33 | { 34 | /** 35 | * Speichert den Titel des Charts. 36 | * @param title Titel. 37 | */ 38 | public void setTitle(String title); 39 | 40 | /** 41 | * Liefert den Titel des Charts. 42 | * @return Titel. 43 | */ 44 | public String getTitle(); 45 | 46 | /** 47 | * Fuegt dem Chart eine Datenreihe hinzu, 48 | * @param data 49 | */ 50 | public void addData(T data); 51 | 52 | /** 53 | * Entfernt eine Datenreihe aus dem Chart. 54 | * @param data 55 | */ 56 | public void removeData(T data); 57 | 58 | /** 59 | * Entfernt alle Datenreihen. 60 | */ 61 | public void removeAllData(); 62 | 63 | /** 64 | * Zeichnet das Chart neu. 65 | * Ist eigentlich nur noetig, wenn sich die Daten tatsaechlich geaendert haben. 66 | * @throws RemoteException 67 | */ 68 | public void redraw() throws RemoteException; 69 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/action/ShowAddressDetailView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.gui.action; 19 | 20 | import java.rmi.RemoteException; 21 | 22 | import de.janrieke.contractmanager.Settings; 23 | import de.janrieke.contractmanager.rmi.Address; 24 | import de.willuhn.jameica.gui.Action; 25 | import de.willuhn.jameica.gui.GUI; 26 | import de.willuhn.util.ApplicationException; 27 | 28 | /** 29 | * Action for "show contract details" or "create new contract". 30 | */ 31 | public class ShowAddressDetailView implements Action { 32 | 33 | /** 34 | * @see de.willuhn.jameica.gui.Action#handleAction(java.lang.Object) 35 | */ 36 | public void handleAction(Object context) throws ApplicationException { 37 | 38 | Address p = null; 39 | 40 | // check if the context is a contract 41 | if (context != null && (context instanceof Address)) 42 | p = (Address) context; 43 | else { 44 | try { 45 | p = (Address) Settings.getDBService().createObject( 46 | Address.class, null); 47 | } catch (RemoteException e) { 48 | throw new ApplicationException(Settings.i18n().tr( 49 | "Error while creating new contract"), e); 50 | } 51 | } 52 | 53 | // ok, lets start the dialog 54 | GUI.startView(de.janrieke.contractmanager.gui.view.AddressDetailView.class 55 | .getName(), p); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/menu/CostsListMenu.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.gui.menu; 19 | 20 | import de.janrieke.contractmanager.Settings; 21 | import de.janrieke.contractmanager.gui.action.CreateNewCostEntry; 22 | import de.janrieke.contractmanager.gui.action.DeleteCostEntry; 23 | import de.janrieke.contractmanager.gui.action.RemovePaydayFromCostEntry; 24 | import de.janrieke.contractmanager.gui.control.ContractControl; 25 | import de.willuhn.jameica.gui.parts.CheckedContextMenuItem; 26 | import de.willuhn.jameica.gui.parts.ContextMenu; 27 | import de.willuhn.jameica.gui.parts.ContextMenuItem; 28 | 29 | public class CostsListMenu extends ContextMenu { 30 | 31 | public CostsListMenu(ContractControl contractControl) { 32 | // CheckedContextMenuItems will be disabled, if the user clicks into an 33 | // empty space of the table 34 | addItem(new ContextMenuItem(Settings.i18n().tr( 35 | "Create a new cost entry"), new CreateNewCostEntry(contractControl), 36 | "document-new.png")); 37 | 38 | addItem(ContextMenuItem.SEPARATOR); 39 | addItem(new CheckedContextMenuItem(Settings.i18n().tr( 40 | "Remove payday..."), new RemovePaydayFromCostEntry(contractControl), null)); 41 | addItem(new CheckedContextMenuItem(Settings.i18n().tr( 42 | "Delete cost entry..."), new DeleteCostEntry(contractControl), "window-close.png")); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/view/AddressListView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.gui.view; 19 | 20 | import de.janrieke.contractmanager.Settings; 21 | import de.janrieke.contractmanager.gui.action.ShowAddressDetailView; 22 | import de.janrieke.contractmanager.gui.control.AddressControl; 23 | import de.willuhn.jameica.gui.AbstractView; 24 | import de.willuhn.jameica.gui.GUI; 25 | import de.willuhn.jameica.gui.util.ButtonArea; 26 | import de.willuhn.util.ApplicationException; 27 | 28 | /** 29 | * View to show the list of existing contracts. 30 | */ 31 | public class AddressListView extends AbstractView { 32 | 33 | /** 34 | * @see de.willuhn.jameica.gui.AbstractView#bind() 35 | */ 36 | public void bind() throws Exception { 37 | 38 | GUI.getView().setTitle(Settings.i18n().tr("Existing addresses")); 39 | 40 | AddressControl control = new AddressControl(this); 41 | 42 | control.getAddressesTable().paint(this.getParent()); 43 | 44 | ButtonArea buttons = new ButtonArea(this.getParent(), 3); 45 | //buttons.addButton(new Back(false)); 46 | 47 | buttons.addButton(Settings.i18n().tr("Create new address..."), 48 | new ShowAddressDetailView(), null, true, "document-new.png"); 49 | } 50 | 51 | /** 52 | * @see de.willuhn.jameica.gui.AbstractView#unbind() 53 | */ 54 | public void unbind() throws ApplicationException { 55 | } 56 | 57 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/rmi/Costs.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.rmi; 19 | 20 | import java.rmi.RemoteException; 21 | import java.util.Date; 22 | 23 | import de.willuhn.datasource.rmi.DBObject; 24 | /* 25 | * CREATE TABLE costs ( 26 | * id IDENTITY, 27 | * contract_id int(5), 28 | * description varchar(255), 29 | * money double, 30 | * period int(1), 31 | * payday date, 32 | * UNIQUE (id), 33 | * PRIMARY KEY (id) 34 | * ); 35 | */ 36 | public interface Costs extends DBObject { 37 | public Contract getContract() throws RemoteException; 38 | public void setContract(Contract contract) throws RemoteException; 39 | 40 | public String getDescription() throws RemoteException; 41 | public void setDescription(String description) throws RemoteException; 42 | 43 | public double getMoney() throws RemoteException; 44 | public void setMoney(double money) throws RemoteException; 45 | 46 | public IntervalType getPeriod() throws RemoteException; 47 | public void setPeriod(IntervalType period) throws RemoteException; 48 | 49 | public Date getPayday() throws RemoteException; 50 | public void setPayday(Date payday) throws RemoteException; 51 | 52 | public static final String NEXT_PAYDAY = "next_payday"; 53 | public Date getNextPayday() throws RemoteException; 54 | public Date getNextPayday(Date after) throws RemoteException; 55 | 56 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/chart/ChartData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* 20 | * Partially copied from Hibiscus/Syntax, (c) by willuhn.webdesign 21 | */ 22 | package de.janrieke.contractmanager.gui.chart; 23 | 24 | import java.rmi.RemoteException; 25 | import java.util.List; 26 | 27 | /** 28 | * Basis-Interface, welches die zu zeichnenden Datenreihen enthaelt. 29 | */ 30 | public interface ChartData 31 | { 32 | /** 33 | * Liefert die zu zeichnende Datenreihe. 34 | * @return Datenreihe. 35 | * @throws RemoteException 36 | */ 37 | public List getData() throws RemoteException; 38 | 39 | /** 40 | * Liefert das Label der Datenreihe. 41 | * @return Label der Datenreihe. 42 | * @throws RemoteException 43 | */ 44 | public String getLabel() throws RemoteException; 45 | 46 | /** 47 | * Liefert den Namen des Attributs, welches fuer die Werte 48 | * verwendet werden soll. Der Wert des Attributes muss vom Typ java.lang.Number sein. 49 | * @return Name des Werte-Attributs. 50 | * @throws RemoteException 51 | */ 52 | public String getDataAttribute() throws RemoteException; 53 | 54 | /** 55 | * Liefert den Namen des Attributs fuer die Beschriftung. 56 | * @return Name des Attributs fuer die Beschriftung. 57 | * Der Wert des Attributes muss vom Typ java.lang.Date sein. 58 | * @throws RemoteException 59 | */ 60 | public String getLabelAttribute() throws RemoteException; 61 | } -------------------------------------------------------------------------------- /contractmanager/src/updates/java/update0022.java: -------------------------------------------------------------------------------- 1 | import java.io.StringReader; 2 | import java.util.HashMap; 3 | import java.util.Map; 4 | 5 | import de.janrieke.contractmanager.rmi.ContractDBService; 6 | import de.janrieke.contractmanager.server.ContractDBUpdateProvider; 7 | import de.janrieke.contractmanager.server.DBSupportH2Impl; 8 | import de.willuhn.logging.Logger; 9 | import de.willuhn.sql.ScriptExecutor; 10 | import de.willuhn.sql.version.Update; 11 | import de.willuhn.sql.version.UpdateProvider; 12 | import de.willuhn.util.ApplicationException; 13 | import de.willuhn.util.I18N; 14 | 15 | /** 16 | * MySQL support preparations 17 | */ 18 | public class update0022 implements Update { 19 | private Map statements = new HashMap<>(); 20 | 21 | /** 22 | * Default constructor 23 | */ 24 | public update0022() { 25 | // Update for H2 26 | statements.put(DBSupportH2Impl.class.getName(), 27 | "ALTER TABLE settings ALTER COLUMN key RENAME TO mkey;\n"); 28 | } 29 | 30 | /** 31 | * @see de.willuhn.sql.version.Update#execute(de.willuhn.sql.version.UpdateProvider) 32 | */ 33 | @Override 34 | public void execute(UpdateProvider provider) throws ApplicationException { 35 | ContractDBUpdateProvider myProvider = (ContractDBUpdateProvider) provider; 36 | I18N i18n = myProvider.getResources().getI18N(); 37 | 38 | // Get the SQL dialect 39 | String driver = ContractDBService.SETTINGS.getString("database.driver", 40 | DBSupportH2Impl.class.getName()); 41 | String sql = statements.get(driver); 42 | if (sql == null) { 43 | throw new ApplicationException(i18n.tr( 44 | "Database {0} not supported", driver)); 45 | } 46 | 47 | try { 48 | ScriptExecutor 49 | .execute(new StringReader(sql), myProvider.getConnection(), 50 | myProvider.getProgressMonitor()); 51 | myProvider.getProgressMonitor().log(i18n.tr("Database updated.")); 52 | } catch (ApplicationException ae) { 53 | throw ae; 54 | } catch (Exception e) { 55 | Logger.error("unable to execute update", e); 56 | throw new ApplicationException( 57 | i18n.tr("Error during database update"), e); 58 | } 59 | } 60 | 61 | /** 62 | * @see de.willuhn.sql.version.Update#getName() 63 | */ 64 | @Override 65 | public String getName() { 66 | return "Database update v21 to v22 (add support for mysql)"; 67 | } 68 | 69 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/action/CreateNewCostEntry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.gui.action; 19 | 20 | import java.rmi.RemoteException; 21 | 22 | import de.janrieke.contractmanager.Settings; 23 | import de.janrieke.contractmanager.gui.control.ContractControl; 24 | import de.janrieke.contractmanager.rmi.Contract; 25 | import de.janrieke.contractmanager.rmi.Costs; 26 | import de.janrieke.contractmanager.rmi.IntervalType; 27 | import de.willuhn.jameica.gui.Action; 28 | import de.willuhn.util.ApplicationException; 29 | 30 | /** 31 | * Action for "delete contract". 32 | */ 33 | public class CreateNewCostEntry implements Action { 34 | 35 | private ContractControl contract; 36 | 37 | public CreateNewCostEntry(ContractControl contract) { 38 | this.contract = contract; 39 | } 40 | 41 | /** 42 | * @see de.willuhn.jameica.gui.Action#handleAction(java.lang.Object) 43 | */ 44 | public void handleAction(Object context) throws ApplicationException { 45 | try { 46 | Costs c = (Costs) Settings.getDBService().createObject( 47 | Costs.class, null); 48 | c.setContract((Contract) contract.getCurrentObject()); 49 | c.setDescription(""); 50 | c.setMoney(0); 51 | c.setPeriod(IntervalType.YEARS); 52 | contract.addTemporaryCostEntry(c); 53 | } catch (RemoteException e) { 54 | throw new ApplicationException(Settings.i18n().tr( 55 | "Error while creating new cost entry"), e); 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/rmi/Storage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.rmi; 19 | 20 | import java.io.InputStream; 21 | import java.rmi.RemoteException; 22 | 23 | import de.willuhn.datasource.rmi.DBObject; 24 | 25 | /* 26 | * CREATE TABLE storage ( 27 | * id IDENTITY, 28 | * contract_id int(5), 29 | * description varchar(255), 30 | * path varchar(65535), 31 | * file BLOB, 32 | * UNIQUE (id), 33 | * PRIMARY KEY (id), 34 | * CONSTRAINT fk_storage_contract FOREIGN KEY (contract_id) REFERENCES contract (id) ON DELETE CASCADE ON UPDATE CASCADE 35 | * ); 36 | */ 37 | public interface Storage extends DBObject { 38 | public Contract getContract() throws RemoteException; 39 | public void setContract(Contract contract) throws RemoteException; 40 | public String getDescription() throws RemoteException; 41 | public void setDescription(String desc) throws RemoteException; 42 | public String getPath() throws RemoteException; 43 | public void setPath(String path) throws RemoteException; 44 | 45 | /** 46 | * Returns a stream for reading the binary contents stored in the "file" field. 47 | * Note: All data must be read before calling any other database operation. 48 | * Any other DB operation will implicitly close the stream. 49 | * @return a stream with the file contents 50 | * @throws RemoteException 51 | */ 52 | public InputStream getFile() throws RemoteException; 53 | //saving is only implemented via prepared statements 54 | } 55 | -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/rmi/Setting.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.rmi; 19 | 20 | import java.rmi.RemoteException; 21 | 22 | import de.willuhn.datasource.rmi.DBObject; 23 | 24 | /** 25 | * Interface of the business object for settings. According to the SQL table, we 26 | * define some getters and setters here. 27 | * 28 | *
29 | CREATE TABLE settings (
30 |   key varchar(255) NOT NULL,
31 |   value varchar(255),
32 |   UNIQUE (key),
33 |   PRIMARY KEY (key)
34 | );
35 |  * 
36 | * 37 | *
38 | * Getters and setters for the primary key (id) are not needed. Every one of the 39 | * following methods has to throw a RemoteException.
40 | * 41 | * ############################################################################# 42 | * # IMPORTANT: # # All business objects are RMI objects. So you have to run the 43 | * # # rmi compiler (rmic) to create the needed stubs. # # Without that you will 44 | * get a # # java.lang.reflect.InvocationTargetException # # (caused by 45 | * java.rmi.StubNotFoundException) # 46 | * ############################################################################# 47 | * 48 | * @author jrieke 49 | */ 50 | public interface Setting extends DBObject { 51 | 52 | public String getKey() throws RemoteException; 53 | public void setKey(String key) throws RemoteException; 54 | 55 | public String getValue() throws RemoteException; 56 | public void setValue(String value) throws RemoteException; 57 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/action/DismissNextReminder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.gui.action; 19 | 20 | import java.rmi.RemoteException; 21 | 22 | import de.janrieke.contractmanager.Settings; 23 | import de.janrieke.contractmanager.rmi.Contract; 24 | import de.willuhn.jameica.gui.Action; 25 | import de.willuhn.jameica.gui.parts.TablePart; 26 | import de.willuhn.logging.Logger; 27 | import de.willuhn.util.ApplicationException; 28 | 29 | /** 30 | * Action for "delete contract". 31 | */ 32 | public class DismissNextReminder implements Action { 33 | 34 | private TablePart tablePart; 35 | 36 | public DismissNextReminder(TablePart tablePart) { 37 | this.tablePart = tablePart; 38 | } 39 | 40 | /** 41 | * @see de.willuhn.jameica.gui.Action#handleAction(java.lang.Object) 42 | */ 43 | public void handleAction(Object context) throws ApplicationException { 44 | 45 | // check if the context is a contract 46 | if (context == null || !(context instanceof Contract)) 47 | throw new ApplicationException(Settings.i18n().tr( 48 | "Please choose a contract.")); 49 | 50 | Contract c = (Contract) context; 51 | 52 | try { 53 | c.doNotRemindAboutNextCancellation(); 54 | c.store(); 55 | tablePart.updateItem(c, c); 56 | } catch (RemoteException e) { 57 | Logger.error("error while dismissing reminder", e); 58 | throw new ApplicationException(Settings.i18n().tr( 59 | "Error while dismissing reminder"), e); 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /contractmanager/BuildRelease.txt: -------------------------------------------------------------------------------- 1 | Release instructions, exemplary for version 0.5.2 2 | 3 | Assume that currently version 0.5.2-SNAPSHOT is in development. Then perform a release as follows: 4 | 5 | 1. Change plugin.xml: 6 | - 7 | - http://janrieke.de/products/jameica/updates/contractmanager/release/0.5.2/contractmanager.zip 8 | (Note the "/release/" instead of "/snapshot/" in the URL!) 9 | 10 | 2. Change pom.xml: 11 | - 0.5.2 12 | 13 | 3. If not already done, describe the changes since the last release in VERSION_HISTORY. 14 | 15 | 4. Set the year in LICENSE, README, and src/main/java/de/janrieke/contractmanager/gui/dialog/AboutDialog.java to the current year. 16 | 17 | 5. Execute "mvn clean package" 18 | 19 | 6. If successful, there will be a "contractmanager-0.5.2-bin.zip" in the target folder. This is the complete release. Copy this file to "ContractManager Releases/0.5.2/contractmanager.zip". 20 | 21 | 7. Verify that the release works (check both for updates and fresh installations)! 22 | - Use .jameica-installation-test und then a real installation for this. 23 | - Create a backup in .jameica-installation-test after the installation so that we can go back to the state of this release later. 24 | 25 | 8. git commit, git push. 26 | 27 | 9. Upload contractmanager.zip to http://janrieke.de/products/jameica/updates/contractmanager/release/0.5.2/contractmanager.zip. 28 | 29 | 10. Upload plugin.xml to both http://janrieke.de/products/jameica/updates/contractmanager/release/ and http://janrieke.de/products/jameica/updates/contractmanager/release/0.5.2/. 30 | 31 | Now, the release is live. 32 | 33 | 11. Verify that an update via the updatesite works (again use ".jameica-installation-test"). 34 | 35 | 12. Close the ".jameica-installation-test" Jameica instance. Use the last backup of ".jameica-installation-test" and copy it to "ContractManager Releases". 36 | 37 | Now, we finally have to set the new development version: 38 | 39 | 13. Change plugin.xml: 40 | - 41 | - http://janrieke.de/products/jameica/updates/contractmanager/snapshot/0.5.3-SNAPSHOT/contractmanager.zip 42 | (Note the "/snapshot/" instead of "/release/" in the URL!) 43 | 44 | 14. Change pom.xml: 45 | - 0.5.3-SNAPSHOT 46 | -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/action/RemovePaydayFromCostEntry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.gui.action; 19 | 20 | import java.rmi.RemoteException; 21 | 22 | import de.janrieke.contractmanager.Settings; 23 | import de.janrieke.contractmanager.gui.control.ContractControl; 24 | import de.janrieke.contractmanager.rmi.Costs; 25 | import de.willuhn.jameica.gui.Action; 26 | import de.willuhn.logging.Logger; 27 | import de.willuhn.util.ApplicationException; 28 | 29 | /** 30 | * Action for "remove cost payday". 31 | */ 32 | public class RemovePaydayFromCostEntry implements Action { 33 | 34 | private ContractControl contractControl; 35 | 36 | public RemovePaydayFromCostEntry(ContractControl contract) { 37 | this.contractControl = contract; 38 | } 39 | 40 | /** 41 | * @see de.willuhn.jameica.gui.Action#handleAction(java.lang.Object) 42 | */ 43 | @Override 44 | public void handleAction(Object context) throws ApplicationException { 45 | 46 | // check if the context is a contract 47 | if (context == null || !(context instanceof Costs)) { 48 | throw new ApplicationException(Settings.i18n().tr( 49 | "Please choose a cost entry.")); 50 | } 51 | 52 | Costs c = (Costs) context; 53 | 54 | try { 55 | c.setPayday(null); 56 | contractControl.getCostsList().updateItem(c, c); 57 | } catch (RemoteException e) { 58 | Logger.error("error while removing payday from cost entry", e); 59 | throw new ApplicationException(Settings.i18n().tr( 60 | "Error while removing payday from cost entry")); 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/rmi/IntervalType.java: -------------------------------------------------------------------------------- 1 | package de.janrieke.contractmanager.rmi; 2 | 3 | import de.janrieke.contractmanager.Settings; 4 | 5 | /** 6 | * Enumeration of different intervals that define contract runtimes, 7 | * cancellation deadlines or cost paydays. 8 | */ 9 | public enum IntervalType { 10 | //Will be sorted by order 11 | ONCE (0, "undefined", "once"), 12 | DAYS (1, "Days", "daily"), 13 | WEEKS (2, "Weeks", "weekly"), 14 | MONTHS (3, "Months", "monthly"), 15 | QUARTER_YEARS (5, "Quarter Years","quarterly"), 16 | HALF_YEARS (6, "Half Years", "semiannually"), 17 | YEARS (4, "Years", "annually"); 18 | 19 | private final int value; //used for DB storage 20 | private final String name; 21 | private final String adjective; 22 | 23 | private IntervalType(int value, String name, String adjective) { 24 | this.value = value; 25 | this.name = name; 26 | this.adjective = adjective; 27 | } 28 | 29 | public int getValue() { 30 | return value; 31 | } 32 | 33 | public String getName() { 34 | return Settings.i18n().tr(name); 35 | } 36 | 37 | @Override 38 | public String toString() { 39 | return getName(); 40 | } 41 | 42 | public String getAdjective() { 43 | return Settings.i18n().tr(adjective); 44 | } 45 | 46 | public static IntervalType valueOfAdjective(String adjective) { 47 | for (IntervalType interval : IntervalType.values()) { 48 | if (interval.adjective.equals(adjective) || Settings.i18n().tr(interval.adjective).equals(adjective)) { 49 | return interval; 50 | } 51 | } 52 | return ONCE; 53 | } 54 | 55 | public static IntervalType valueOfName(String name) { 56 | for (IntervalType interval : IntervalType.values()) { 57 | if (interval.name.equals(name) || Settings.i18n().tr(interval.name).equals(name)) { 58 | return interval; 59 | } 60 | } 61 | return ONCE; 62 | } 63 | 64 | public static IntervalType valueOf(int value) { 65 | for (IntervalType interval : IntervalType.values()) { 66 | if (interval.value == value) { 67 | return interval; 68 | } 69 | } 70 | return ONCE; 71 | } 72 | 73 | public static String[] getAdjectives() { 74 | String[] res = new String[IntervalType.values().length]; 75 | for (IntervalType interval : IntervalType.values()) { 76 | res[interval.ordinal()] = interval.getAdjective(); 77 | } 78 | return res; 79 | } 80 | 81 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/action/ShowContractDetailView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.gui.action; 19 | 20 | import java.rmi.RemoteException; 21 | 22 | import de.janrieke.contractmanager.Settings; 23 | import de.janrieke.contractmanager.rmi.Contract; 24 | import de.janrieke.contractmanager.rmi.IntervalType; 25 | import de.willuhn.jameica.gui.Action; 26 | import de.willuhn.jameica.gui.GUI; 27 | import de.willuhn.util.ApplicationException; 28 | 29 | /** 30 | * Action for "show contract details" or "create new contract". 31 | */ 32 | public class ShowContractDetailView implements Action { 33 | 34 | /** 35 | * @see de.willuhn.jameica.gui.Action#handleAction(java.lang.Object) 36 | */ 37 | public void handleAction(Object context) throws ApplicationException { 38 | 39 | Contract p = null; 40 | 41 | // check if the context is a contract 42 | if (context != null && (context instanceof Contract)) 43 | p = (Contract) context; 44 | else { 45 | try { 46 | p = (Contract) Settings.getDBService().createObject( 47 | Contract.class, null); 48 | p.setCancelationPeriodType(IntervalType.MONTHS); 49 | p.setFirstMinRuntimeType(IntervalType.MONTHS); 50 | p.setFollowingMinRuntimeType(IntervalType.MONTHS); 51 | } catch (RemoteException e) { 52 | throw new ApplicationException(Settings.i18n().tr( 53 | "Error while creating new contract"), e); 54 | } 55 | } 56 | 57 | // ok, lets start the dialog 58 | GUI.startView(de.janrieke.contractmanager.gui.view.ContractDetailView.class 59 | .getName(), p); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /contractmanager/src/main/resources/sql/h2-create.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE address ( 2 | id IDENTITY, 3 | name varchar(255) NOT NULL, 4 | street varchar(255), 5 | number varchar(16), 6 | extra varchar(255), 7 | zipcode varchar(5), 8 | city varchar(255), 9 | state varchar(255), 10 | country varchar(255), 11 | UNIQUE (id), 12 | PRIMARY KEY (id) 13 | ); 14 | 15 | CREATE TABLE contract ( 16 | id IDENTITY, 17 | name varchar(255) NOT NULL, 18 | contract_no varchar(255), 19 | customer_no varchar(255), 20 | address_id int(5), 21 | comment varchar(10000), 22 | startdate date, 23 | enddate date, 24 | cancelation_period_count int(4), 25 | cancelation_period_type int(4), 26 | first_min_runtime_count int(4), 27 | first_min_runtime_type int(4), 28 | next_min_runtime_count int(4), 29 | next_min_runtime_type int(4), 30 | uri varchar(4096), 31 | hibiscus_category varchar(255) NULL, 32 | ignore_cancellations int(1) NOT NULL, 33 | do_not_remind_before date, 34 | sepa_creditor varchar(35), 35 | sepa_customer varchar(35), 36 | runtime_snap_to_end int(1), 37 | UNIQUE (id), 38 | PRIMARY KEY (id), 39 | CONSTRAINT fk_address FOREIGN KEY (address_id) REFERENCES address (id) 40 | ); 41 | 42 | CREATE TABLE costs ( 43 | id IDENTITY, 44 | contract_id int(5), 45 | description varchar(255), 46 | money double, 47 | period int(1), 48 | payday date, 49 | UNIQUE (id), 50 | PRIMARY KEY (id), 51 | CONSTRAINT fk_costs_contract FOREIGN KEY (contract_id) REFERENCES contract (id) ON DELETE CASCADE ON UPDATE CASCADE 52 | ); 53 | 54 | CREATE TABLE transactions ( 55 | transaction_id int(5), 56 | contract_id int(5), 57 | UNIQUE (transaction_id), 58 | PRIMARY KEY (transaction_id), 59 | CONSTRAINT fk_transactions_contract FOREIGN KEY (contract_id) REFERENCES contract (id) ON DELETE CASCADE ON UPDATE CASCADE 60 | ); 61 | 62 | CREATE TABLE storage ( 63 | id IDENTITY, 64 | contract_id int(5), 65 | description varchar(255), 66 | path varchar(65535), 67 | file BLOB, 68 | UNIQUE (id), 69 | PRIMARY KEY (id), 70 | CONSTRAINT fk_storage_contract FOREIGN KEY (contract_id) REFERENCES contract (id) ON DELETE CASCADE ON UPDATE CASCADE 71 | ); 72 | 73 | CREATE TABLE settings ( 74 | mkey varchar(255) NOT NULL, 75 | value varchar(255), 76 | UNIQUE (mkey), 77 | PRIMARY KEY (mkey) 78 | ); 79 | 80 | CREATE TABLE version ( 81 | id IDENTITY, 82 | name varchar(255) NOT NULL, 83 | version int(5) NOT NULL, 84 | UNIQUE (id), 85 | PRIMARY KEY (id) 86 | ); 87 | 88 | INSERT INTO version (name,version) values ('contract_db',24); 89 | -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/ext/hibiscus/ActiveWhenAssignedContextMenuItem.java: -------------------------------------------------------------------------------- 1 | package de.janrieke.contractmanager.ext.hibiscus; 2 | 3 | import de.willuhn.jameica.gui.Action; 4 | import de.willuhn.jameica.gui.parts.CheckedContextMenuItem; 5 | import de.willuhn.jameica.hbci.rmi.Umsatz; 6 | import de.willuhn.jameica.messaging.StatusBarMessage; 7 | import de.willuhn.jameica.system.Application; 8 | import de.willuhn.logging.Logger; 9 | 10 | /** 11 | * Helper class to deactivate the menu item if the transaction is already assigned. 12 | */ 13 | class ActiveWhenAssignedContextMenuItem extends CheckedContextMenuItem 14 | { 15 | private boolean activeWhenAssigned; 16 | private boolean allowMultiple; 17 | 18 | /** 19 | * ct. 20 | * 21 | * @param text 22 | * @param a 23 | * @param activeWhenAssigned 24 | * if true, the item will only be active when the 25 | * transaction is assigned to a constract; if false, 26 | * the item will only be active if the transaction is not 27 | * assigned. 28 | */ 29 | public ActiveWhenAssignedContextMenuItem(String text, Action a, boolean activeWhenAssigned, 30 | boolean allowMultiple) 31 | { 32 | super(text, a); 33 | this.activeWhenAssigned = activeWhenAssigned; 34 | this.allowMultiple = allowMultiple; 35 | } 36 | 37 | /** 38 | * @see de.willuhn.jameica.gui.parts.CheckedContextMenuItem#isEnabledFor(java.lang.Object) 39 | */ 40 | @Override 41 | public boolean isEnabledFor(Object o) 42 | { 43 | if (o == null) { 44 | return false; 45 | } 46 | 47 | if (o instanceof Umsatz[]) { 48 | if (allowMultiple) { 49 | // Wenn wir eine ganze Liste von Buchungen haben, pruefen 50 | // wir nicht jede einzeln, ob sie schon in ContractManager vorhanden 51 | // ist. Die werden dann beim Import (weiter unten) einfach ausgesiebt. 52 | return super.isEnabledFor(o); 53 | } else { 54 | return false; 55 | } 56 | } 57 | 58 | if (!(o instanceof Umsatz)) { 59 | return false; 60 | } 61 | 62 | try { 63 | return (activeWhenAssigned ^ !TransactionUtils.isAssigned((Umsatz) o)) && super.isEnabledFor(o); 64 | } catch (Exception e) { 65 | Logger.error("unable to detect if buchung is already assigned",e); 66 | Application.getMessagingFactory().sendMessage(new StatusBarMessage(UmsatzListMenuHibiscusExtension.i18n.tr("Error while checking for assigned contracts in ContractManager"), StatusBarMessage.TYPE_ERROR)); 67 | } 68 | return false; 69 | } 70 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/view/LicenseInfoView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | /********************************************************************** 19 | * Copied from Jameica 20 | * 21 | * $Source: /cvsroot/jameica/jameica/src/de/willuhn/jameica/gui/internal/views/License.java,v $ 22 | * $Revision: 1.5 $ 23 | * $Date: 2009-01-20 10:51:51 $ 24 | * $Author: willuhn $ 25 | * $Locker: $ 26 | * $State: Exp $ 27 | * 28 | * Copyright (c) by willuhn.webdesign 29 | * All rights reserved 30 | * 31 | **********************************************************************/ 32 | package de.janrieke.contractmanager.gui.view; 33 | 34 | import de.janrieke.contractmanager.gui.control.LicenseControl; 35 | import de.willuhn.jameica.gui.AbstractView; 36 | import de.willuhn.jameica.gui.GUI; 37 | import de.willuhn.jameica.gui.Part; 38 | import de.willuhn.jameica.system.Application; 39 | import de.willuhn.util.ApplicationException; 40 | import de.willuhn.util.I18N; 41 | 42 | /** 43 | * View fuer die Lizenz-Informationen 44 | */ 45 | public class LicenseInfoView extends AbstractView { 46 | 47 | /** 48 | * @see de.willuhn.jameica.gui.AbstractView#bind() 49 | */ 50 | public void bind() throws Exception 51 | { 52 | I18N i18n = Application.getI18n(); 53 | GUI.getView().setTitle(i18n.tr("Licence Information")); 54 | 55 | LicenseControl control = new LicenseControl(this); 56 | 57 | Part libs = control.getLibList(); 58 | libs.paint(getParent()); 59 | 60 | //ButtonArea buttons = new ButtonArea(getParent(), 1); 61 | //buttons.addButton(new Back(true)); 62 | } 63 | 64 | /** 65 | * @see de.willuhn.jameica.gui.AbstractView#unbind() 66 | */ 67 | public void unbind() throws ApplicationException { 68 | } 69 | 70 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/menu/AddressListMenu.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.gui.menu; 19 | 20 | import de.janrieke.contractmanager.Settings; 21 | import de.janrieke.contractmanager.gui.action.DeleteAddress; 22 | import de.janrieke.contractmanager.gui.action.ShowAddressDetailView; 23 | import de.willuhn.jameica.gui.Action; 24 | import de.willuhn.jameica.gui.parts.CheckedContextMenuItem; 25 | import de.willuhn.jameica.gui.parts.ContextMenu; 26 | import de.willuhn.jameica.gui.parts.ContextMenuItem; 27 | import de.willuhn.util.ApplicationException; 28 | 29 | /** 30 | * Prepared context menu for project tables. 31 | */ 32 | public class AddressListMenu extends ContextMenu { 33 | /** 34 | * ct. 35 | * 36 | * @param showNew 37 | */ 38 | public AddressListMenu(boolean showNew) { 39 | // CheckedContextMenuItems will be disabled, if the user clicks into an 40 | // empty space of the table 41 | addItem(new CheckedContextMenuItem(Settings.i18n().tr("Open..."), 42 | new ShowAddressDetailView(), "document-open.png")); 43 | 44 | if (showNew) { 45 | // separator 46 | addItem(ContextMenuItem.SEPARATOR); 47 | 48 | addItem(new ContextMenuItem(Settings.i18n().tr( 49 | "Create a New Address..."), new Action() { 50 | public void handleAction(Object context) 51 | throws ApplicationException { 52 | // we force the context to be null to create a new 53 | // project in any case 54 | new ShowAddressDetailView().handleAction(null); 55 | } 56 | }, "document-new.png")); 57 | 58 | addItem(ContextMenuItem.SEPARATOR); 59 | addItem(new CheckedContextMenuItem(Settings.i18n().tr( 60 | "Delete Address..."), new DeleteAddress(), 61 | "window-close.png")); 62 | } 63 | 64 | } 65 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/rmi/Address.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.rmi; 19 | 20 | import java.rmi.RemoteException; 21 | 22 | import de.willuhn.datasource.rmi.DBObject; 23 | /* 24 | * CREATE TABLE address ( 25 | * id NUMERIC default UNIQUEKEY('address'), 26 | * name varchar(255) NOT NULL, 27 | * street varchar(255), 28 | * number int(4), 29 | * extra varchar(255), 30 | * zipcode int(4), 31 | * city varchar(255), 32 | * state varchar(255), 33 | * country varchar(255), 34 | * UNIQUE (id), 35 | * PRIMARY KEY (id) 36 | * ); 37 | */ 38 | public interface Address extends DBObject { 39 | public String getName() throws RemoteException; 40 | public void setName(String name) throws RemoteException; 41 | 42 | public String getStreet() throws RemoteException; 43 | public void setStreet(String street) throws RemoteException; 44 | 45 | public String getNumber() throws RemoteException; 46 | public void setNumber(String number) throws RemoteException; 47 | 48 | public String getExtra() throws RemoteException; 49 | public void setExtra(String extra) throws RemoteException; 50 | 51 | public String getZipcode() throws RemoteException; 52 | public void setZipcode(String zipcode) throws RemoteException; 53 | 54 | public String getCity() throws RemoteException; 55 | public void setCity(String city) throws RemoteException; 56 | 57 | public String getState() throws RemoteException; 58 | public void setState(String state) throws RemoteException; 59 | 60 | public String getCountry() throws RemoteException; 61 | public void setCountry(String country) throws RemoteException; 62 | 63 | //these are derived features 64 | public static final String CONTRACT_COUNT = "contract_count"; 65 | public int getContractCount() throws RemoteException; 66 | } -------------------------------------------------------------------------------- /contractmanager/src/main/resources/sql/mysql-create.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE address ( 2 | id int(10) AUTO_INCREMENT, 3 | name varchar(255) NOT NULL, 4 | street varchar(255), 5 | number varchar(16), 6 | extra varchar(255), 7 | zipcode varchar(5), 8 | city varchar(255), 9 | state varchar(255), 10 | country varchar(255), 11 | UNIQUE (id), 12 | PRIMARY KEY (id) 13 | ) ENGINE=InnoDB; 14 | 15 | CREATE TABLE contract ( 16 | id int(10) AUTO_INCREMENT, 17 | name varchar(255) NOT NULL, 18 | contract_no varchar(255), 19 | customer_no varchar(255), 20 | address_id int(5), 21 | comment varchar(10000), 22 | startdate date, 23 | enddate date, 24 | cancelation_period_count int(4), 25 | cancelation_period_type int(4), 26 | first_min_runtime_count int(4), 27 | first_min_runtime_type int(4), 28 | next_min_runtime_count int(4), 29 | next_min_runtime_type int(4), 30 | uri text(4096), 31 | hibiscus_category varchar(255) NULL, 32 | ignore_cancellations int(1) NOT NULL, 33 | do_not_remind_before date, 34 | sepa_creditor varchar(35), 35 | sepa_customer varchar(35), 36 | runtime_snap_to_end int(1), 37 | UNIQUE (id), 38 | PRIMARY KEY (id), 39 | CONSTRAINT fk_address FOREIGN KEY (address_id) REFERENCES address (id) 40 | ) ENGINE=InnoDB; 41 | 42 | CREATE TABLE costs ( 43 | id int(10) AUTO_INCREMENT, 44 | contract_id int(5), 45 | description varchar(255), 46 | money double, 47 | period int(1), 48 | payday date, 49 | UNIQUE (id), 50 | PRIMARY KEY (id), 51 | CONSTRAINT fk_costs_contract FOREIGN KEY (contract_id) REFERENCES contract (id) ON DELETE CASCADE ON UPDATE CASCADE 52 | ) ENGINE=InnoDB; 53 | 54 | CREATE TABLE transactions ( 55 | transaction_id int(5), 56 | contract_id int(5), 57 | UNIQUE (transaction_id), 58 | PRIMARY KEY (transaction_id), 59 | CONSTRAINT fk_transactions_contract FOREIGN KEY (contract_id) REFERENCES contract (id) ON DELETE CASCADE ON UPDATE CASCADE 60 | ) ENGINE=InnoDB; 61 | 62 | CREATE TABLE storage ( 63 | id int(10) AUTO_INCREMENT, 64 | contract_id int(5), 65 | description varchar(255), 66 | path text(65535), 67 | file BLOB, 68 | UNIQUE (id), 69 | PRIMARY KEY (id), 70 | CONSTRAINT fk_storage_contract FOREIGN KEY (contract_id) REFERENCES contract (id) ON DELETE CASCADE ON UPDATE CASCADE 71 | ) ENGINE=InnoDB; 72 | 73 | CREATE TABLE settings ( 74 | mkey varchar(255) NOT NULL, 75 | value varchar(255), 76 | UNIQUE (mkey), 77 | PRIMARY KEY (mkey) 78 | ) ENGINE=InnoDB; 79 | 80 | CREATE TABLE version ( 81 | id int(10) AUTO_INCREMENT, 82 | name varchar(255) NOT NULL, 83 | version int(5) NOT NULL, 84 | UNIQUE (id), 85 | PRIMARY KEY (id) 86 | ) ENGINE=InnoDB; 87 | 88 | INSERT INTO version (name,version) values ('contract_db',24); 89 | -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/action/DeleteCostEntry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.gui.action; 19 | 20 | import de.janrieke.contractmanager.Settings; 21 | import de.janrieke.contractmanager.gui.control.ContractControl; 22 | import de.janrieke.contractmanager.rmi.Costs; 23 | import de.willuhn.jameica.gui.Action; 24 | import de.willuhn.logging.Logger; 25 | import de.willuhn.util.ApplicationException; 26 | 27 | /** 28 | * Action for "delete contract". 29 | */ 30 | public class DeleteCostEntry implements Action { 31 | 32 | private ContractControl contract; 33 | 34 | public DeleteCostEntry(ContractControl contract) { 35 | this.contract = contract; 36 | } 37 | 38 | /** 39 | * @see de.willuhn.jameica.gui.Action#handleAction(java.lang.Object) 40 | */ 41 | public void handleAction(Object context) throws ApplicationException { 42 | 43 | // check if the context is a contract 44 | if (context == null || !(context instanceof Costs)) 45 | throw new ApplicationException(Settings.i18n().tr( 46 | "Please choose a cost entry.")); 47 | 48 | Costs c = (Costs) context; 49 | 50 | try { 51 | //YesNoDialog d = new YesNoDialog(YesNoDialog.POSITION_CENTER); 52 | //d.setTitle(Settings.i18n().tr("Are you sure?")); 53 | //d.setText(Settings.i18n().tr( 54 | // "Do you really want to delete these cost entry?")); 55 | 56 | //Boolean choice = (Boolean) d.open(); 57 | //if (!choice.booleanValue()) 58 | // return; 59 | 60 | contract.removeCostEntry(c); 61 | //c.delete(); 62 | //GUI.getStatusBar().setSuccessText( 63 | // Settings.i18n().tr("Cost entry deleted successfully")); 64 | } catch (Exception e) { 65 | Logger.error("error while deleting costs", e); 66 | throw new ApplicationException(Settings.i18n().tr( 67 | "Error while deleting cost entry")); 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/action/DeleteContract.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.gui.action; 19 | 20 | import de.janrieke.contractmanager.Settings; 21 | import de.janrieke.contractmanager.gui.view.ContractDetailView; 22 | import de.janrieke.contractmanager.rmi.Contract; 23 | import de.willuhn.jameica.gui.Action; 24 | import de.willuhn.jameica.gui.GUI; 25 | import de.willuhn.jameica.gui.dialogs.YesNoDialog; 26 | import de.willuhn.logging.Logger; 27 | import de.willuhn.util.ApplicationException; 28 | 29 | /** 30 | * Action for "delete contract". 31 | */ 32 | public class DeleteContract implements Action { 33 | 34 | /** 35 | * @see de.willuhn.jameica.gui.Action#handleAction(java.lang.Object) 36 | */ 37 | public void handleAction(Object context) throws ApplicationException { 38 | 39 | // check if the context is a contract 40 | if (context == null || !(context instanceof Contract)) 41 | throw new ApplicationException(Settings.i18n().tr( 42 | "Please choose a contract.")); 43 | 44 | Contract c = (Contract) context; 45 | 46 | try { 47 | 48 | // before deleting the contract, we show up a confirm dialog ;) 49 | 50 | YesNoDialog d = new YesNoDialog(YesNoDialog.POSITION_CENTER); 51 | d.setTitle(Settings.i18n().tr("Are you sure?")); 52 | d.setText(Settings.i18n().tr( 53 | "Do you really want to delete this contract?")); 54 | 55 | Boolean choice = (Boolean) d.open(); 56 | if (!choice.booleanValue()) 57 | return; 58 | 59 | c.delete(); 60 | GUI.getStatusBar().setSuccessText( 61 | Settings.i18n().tr("Contract deleted successfully")); 62 | } catch (Exception e) { 63 | Logger.error("error while deleting contract", e); 64 | throw new ApplicationException(Settings.i18n().tr( 65 | "Error while deleting contract")); 66 | } 67 | 68 | if (GUI.getCurrentView() instanceof ContractDetailView) 69 | GUI.startPreviousView(); 70 | } 71 | 72 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/rmi/Version.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | /********************************************************************** 19 | * Kopie aus Hibiscus 20 | * 21 | * $Source: /cvsroot/hibiscus/hibiscus/src/de/willuhn/jameica/hbci/rmi/Version.java,v $ 22 | * $Revision: 1.1 $ 23 | * $Date: 2007-12-06 17:57:21 $ 24 | * $Author: willuhn $ 25 | * $Locker: $ 26 | * $State: Exp $ 27 | * 28 | * Copyright (c) by willuhn software & services 29 | * All rights reserved 30 | * 31 | **********************************************************************/ 32 | 33 | package de.janrieke.contractmanager.rmi; 34 | 35 | import java.rmi.RemoteException; 36 | 37 | import de.willuhn.datasource.rmi.DBObject; 38 | 39 | /** 40 | * Interface fuer einen Datensatz in der Versionstabelle. 41 | */ 42 | public interface Version extends DBObject 43 | { 44 | 45 | /** 46 | * Liefert den Namen der Version. 47 | * @return Name der Version. 48 | * @throws RemoteException 49 | */ 50 | public String getName() throws RemoteException; 51 | 52 | /** 53 | * Speichert den Namen der Version. 54 | * @param name Name der Version. 55 | * @throws RemoteException 56 | */ 57 | public void setName(String name) throws RemoteException; 58 | 59 | /** 60 | * Liefert den aktuellen Stand der Version. 61 | * @return Stand der Version. 62 | * @throws RemoteException 63 | */ 64 | public int getVersion() throws RemoteException; 65 | 66 | /** 67 | * Legt die neue Versionsnummer fest. 68 | * @param newVersion die neue Versionsnummer. 69 | * @throws RemoteException 70 | */ 71 | public void setVersion(int newVersion) throws RemoteException; 72 | 73 | } 74 | 75 | 76 | /********************************************************************* 77 | * $Log: Version.java,v $ 78 | * Revision 1.1 2007-12-06 17:57:21 willuhn 79 | * @N Erster Code fuer das neue Versionierungs-System 80 | * 81 | **********************************************************************/ -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/view/WelcomeView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.gui.view; 19 | 20 | import de.janrieke.contractmanager.ContractManagerPlugin; 21 | import de.janrieke.contractmanager.Settings; 22 | import de.willuhn.jameica.gui.AbstractView; 23 | import de.willuhn.jameica.gui.GUI; 24 | import de.willuhn.jameica.gui.util.Color; 25 | import de.willuhn.jameica.gui.util.LabelGroup; 26 | import de.willuhn.jameica.plugin.AbstractPlugin; 27 | import de.willuhn.jameica.system.Application; 28 | import de.willuhn.util.ApplicationException; 29 | 30 | /** 31 | * Welcome screen of this example plugin. 32 | * 33 | * @author willuhn 34 | */ 35 | public class WelcomeView extends AbstractView { 36 | 37 | /** 38 | * this method will be invoked when starting the view. 39 | * 40 | * @see de.willuhn.jameica.gui.AbstractView#bind() 41 | */ 42 | public void bind() throws Exception { 43 | AbstractPlugin p = Application.getPluginLoader().getPlugin( 44 | ContractManagerPlugin.class); 45 | GUI.getView().setTitle(Settings.i18n().tr("ContractManager")+" (v" + p.getManifest().getVersion() + ")"); 46 | 47 | LabelGroup group = new LabelGroup(this.getParent(), Settings.i18n().tr( 48 | "Welcome")); 49 | 50 | group.addText(Settings.i18n().tr("Welcome to ContractManager"), true); 51 | 52 | group.addText(Settings.i18n().tr("Be careful: This is software in beta testing. It may still contain bugs and errors."), true, Color.ERROR); 53 | 54 | group = new LabelGroup(this.getParent(), Settings.i18n().tr( 55 | "Contract Cancellation Reminder")); 56 | group.addPart(new CancellationReminderBox()); 57 | } 58 | 59 | /** 60 | * this method will be executed when exiting the view. You don't need to 61 | * dispose your widgets, the GUI controller will do this in a recursive way 62 | * for you. 63 | * 64 | * @see de.willuhn.jameica.gui.AbstractView#unbind() 65 | */ 66 | public void unbind() throws ApplicationException { 67 | // We've nothing to do here ;) 68 | } 69 | 70 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/parts/SizeableTablePart.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.gui.parts; 19 | 20 | import java.rmi.RemoteException; 21 | import java.util.List; 22 | 23 | import org.eclipse.swt.layout.GridData; 24 | import org.eclipse.swt.widgets.Composite; 25 | 26 | import de.willuhn.datasource.GenericIterator; 27 | import de.willuhn.jameica.gui.Action; 28 | import de.willuhn.jameica.gui.parts.TablePart; 29 | import de.willuhn.jameica.gui.util.SimpleContainer; 30 | 31 | public class SizeableTablePart extends TablePart { 32 | 33 | private int heightHint = -1; 34 | private int orderByIndex = -1; 35 | private String orderByColName = null; 36 | 37 | @Override 38 | public synchronized void paint(Composite parent) throws RemoteException { 39 | if (heightHint != -1) { 40 | SimpleContainer container = new SimpleContainer(parent, true); //give the table a minimum height 41 | GridData gd = new GridData(GridData.FILL_VERTICAL | GridData.FILL_HORIZONTAL); 42 | gd.heightHint = heightHint; 43 | container.getComposite().setLayoutData(gd); 44 | super.paint(container.getComposite()); 45 | } else { 46 | super.paint(parent); 47 | } 48 | if (orderByIndex != -1) { 49 | super.orderBy(orderByIndex); 50 | } 51 | if (orderByColName != null) { 52 | super.orderBy(orderByColName); 53 | } 54 | } 55 | 56 | public SizeableTablePart(GenericIterator list, Action action) { 57 | super(list, action); 58 | } 59 | 60 | public SizeableTablePart(List list, Action action) 61 | { 62 | super(list, action); 63 | } 64 | 65 | public synchronized void setHeightHint(int heightHint) { 66 | this.heightHint = heightHint; 67 | } 68 | 69 | @Override 70 | public synchronized void orderBy(int index) { 71 | // make method public 72 | this.orderByIndex = index; 73 | super.orderBy(index); 74 | } 75 | 76 | @Override 77 | public synchronized void orderBy(String colName) { 78 | // make method public 79 | this.orderByColName = colName; 80 | super.orderBy(colName); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/util/ListMap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2014 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.util; 19 | 20 | import java.util.ArrayList; 21 | import java.util.HashMap; 22 | import java.util.List; 23 | import java.util.Map; 24 | 25 | public class ListMap extends HashMap> { 26 | /** 27 | * The UID. 28 | */ 29 | private static final long serialVersionUID = 8323975575855457935L; 30 | 31 | /** 32 | * Adds the given value to the list of key. 33 | * Will create the list if it does not exist yet. 34 | * 35 | * @param key The key to whose list the value will be added 36 | * @param value The value to add to the list 37 | */ 38 | public void addToList(K key, V value) { 39 | if (this.containsKey(key)) { 40 | this.get(key).add(value); 41 | } else { 42 | List list = new ArrayList(); 43 | list.add(value); 44 | this.put(key, list); 45 | } 46 | } 47 | 48 | /** 49 | * Gets the list that corresponds to the given key. 50 | * If create is true, a new list will be created and added 51 | * to the map. If false, an empty list is returned. 52 | * 53 | * @param key The key for which the list will be returned 54 | * @param create Whether to add a new list for the given key if 55 | * non exists 56 | * @return The list. Can never be null. 57 | */ 58 | public List getList(K key, boolean create) { 59 | if (this.containsKey(key)) { 60 | return this.get(key); 61 | } else { 62 | List list = new ArrayList(); 63 | if (create) { 64 | this.put(key, list); 65 | } 66 | return list; 67 | } 68 | } 69 | 70 | /** 71 | * Computes a list of keys in whose lists the given value is. 72 | * 73 | * @param value the value to search for 74 | * @return a list of all keys whose lists contain the value 75 | */ 76 | public List getKeyFromListEntries(V value) { 77 | List result = new ArrayList(); 78 | for (Map.Entry> entry : this.entrySet()) { 79 | if (entry.getValue().contains(value)) 80 | result.add(entry.getKey()); 81 | } 82 | return result; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/ext/hibiscus/NewTransactionsListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2014 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* 20 | * Partially copied from Hibiscus/Syntax, (c) by willuhn.webdesign 21 | */ 22 | 23 | package de.janrieke.contractmanager.ext.hibiscus; 24 | 25 | import de.janrieke.contractmanager.Settings; 26 | import de.willuhn.datasource.GenericObject; 27 | import de.willuhn.jameica.hbci.HBCI; 28 | import de.willuhn.jameica.hbci.messaging.ImportMessage; 29 | import de.willuhn.jameica.hbci.rmi.Umsatz; 30 | import de.willuhn.jameica.messaging.Message; 31 | import de.willuhn.jameica.messaging.MessageConsumer; 32 | import de.willuhn.jameica.system.Application; 33 | 34 | /** 35 | * Automatically import incoming Hibiscus transactions. 36 | */ 37 | public class NewTransactionsListener implements MessageConsumer { 38 | /** 39 | * @see de.willuhn.jameica.messaging.MessageConsumer#autoRegister() 40 | */ 41 | @Override 42 | public boolean autoRegister() { 43 | return Application.getPluginLoader().isInstalled(HBCI.class.getName()); 44 | } 45 | 46 | /** 47 | * @see de.willuhn.jameica.messaging.MessageConsumer#getExpectedMessageTypes() 48 | */ 49 | @Override 50 | @SuppressWarnings("rawtypes") 51 | public Class[] getExpectedMessageTypes() { 52 | return new Class[] { ImportMessage.class }; 53 | } 54 | 55 | /** 56 | * @see de.willuhn.jameica.messaging.MessageConsumer#handleMessage(de.willuhn.jameica.messaging.Message) 57 | */ 58 | @Override 59 | public void handleMessage(Message message) throws Exception { 60 | if (!Settings.getHibiscusAutoImportNewTransactions()) { 61 | return; 62 | } 63 | 64 | // Ignore non-import messages 65 | if (message == null || !(message instanceof ImportMessage)) { 66 | return; 67 | } 68 | 69 | GenericObject o = ((ImportMessage) message).getObject(); 70 | 71 | if (o == null || !(o instanceof Umsatz) || o.getID() == null) { 72 | return; // no ID means: not stored in DB 73 | } 74 | 75 | if (((Umsatz) o).hasFlag(Umsatz.FLAG_NOTBOOKED)) { 76 | return; // ignore transactions that have not been booked, yet 77 | } 78 | 79 | Umsatz[] u = { (Umsatz) o }; 80 | UmsatzImportWorker worker = new UmsatzImportWorker(u, true); 81 | worker.run(null); 82 | } 83 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/server/VersionUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | /********************************************************************** 19 | * Kopie aus Hibiscus 20 | * 21 | * $Source: /cvsroot/hibiscus/hibiscus/src/de/willuhn/jameica/hbci/server/VersionUtil.java,v $ 22 | * $Revision: 1.3 $ 23 | * $Date: 2008-05-30 14:23:48 $ 24 | * $Author: willuhn $ 25 | * $Locker: $ 26 | * $State: Exp $ 27 | * 28 | * Copyright (c) by willuhn software & services 29 | * All rights reserved 30 | * 31 | **********************************************************************/ 32 | 33 | package de.janrieke.contractmanager.server; 34 | 35 | import java.rmi.RemoteException; 36 | 37 | import de.janrieke.contractmanager.ContractManagerPlugin; 38 | import de.janrieke.contractmanager.rmi.Version; 39 | import de.willuhn.datasource.rmi.DBIterator; 40 | import de.willuhn.datasource.rmi.DBService; 41 | import de.willuhn.jameica.system.Application; 42 | import de.willuhn.util.ApplicationException; 43 | import de.willuhn.util.I18N; 44 | 45 | /** 46 | * Statische Hilfsklasse zum Auslesen von Versionsnummern. 47 | */ 48 | public class VersionUtil 49 | { 50 | /** 51 | * Liefert die Version zum angegebenen Namen. 52 | * Wenn das Versions-Objekt noch nicht existiert, wird es automatisch erstellt. 53 | * @param service der Datenbank-Service. 54 | * @param name Name der Version. 55 | * @return die Version. 56 | * @throws RemoteException 57 | * @throws ApplicationException 58 | */ 59 | public static Version getVersion(DBService service, String name) throws RemoteException, ApplicationException 60 | { 61 | if (name == null || name.length() == 0) 62 | { 63 | I18N i18n = Application.getPluginLoader().getPlugin(ContractManagerPlugin.class).getResources().getI18N(); 64 | throw new ApplicationException(i18n.tr("No name for version")); 65 | } 66 | DBIterator list = service.createList(Version.class); 67 | list.addFilter("name = ?", name); 68 | if (list.hasNext()) { 69 | return list.next(); 70 | } 71 | 72 | // Neue Version erstellen 73 | Version v = service.createObject(Version.class,null); 74 | v.setName(name); 75 | v.store(); 76 | return v; 77 | } 78 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/view/ContractListView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.gui.view; 19 | 20 | import org.eclipse.swt.SWT; 21 | import org.eclipse.swt.layout.GridData; 22 | import org.eclipse.swt.widgets.TabFolder; 23 | 24 | import de.janrieke.contractmanager.Settings; 25 | import de.janrieke.contractmanager.gui.action.ShowContractDetailView; 26 | import de.janrieke.contractmanager.gui.control.ContractControl; 27 | import de.willuhn.jameica.gui.AbstractView; 28 | import de.willuhn.jameica.gui.GUI; 29 | import de.willuhn.jameica.gui.util.ButtonArea; 30 | import de.willuhn.jameica.gui.util.ColumnLayout; 31 | import de.willuhn.jameica.gui.util.Container; 32 | import de.willuhn.jameica.gui.util.SimpleContainer; 33 | import de.willuhn.jameica.gui.util.TabGroup; 34 | import de.willuhn.util.ApplicationException; 35 | 36 | /** 37 | * View to show the list of existing contracts. 38 | */ 39 | public class ContractListView extends AbstractView { 40 | 41 | /** 42 | * @see de.willuhn.jameica.gui.AbstractView#bind() 43 | */ 44 | public void bind() throws Exception { 45 | GUI.getView().setTitle(Settings.i18n().tr("Existing contracts")); 46 | 47 | ContractControl control = new ContractControl(this); 48 | 49 | TabFolder folder = new TabFolder(this.getParent(), SWT.NONE); 50 | folder.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 51 | TabGroup tab = new TabGroup(folder,Settings.i18n().tr("Filter view")); 52 | 53 | ColumnLayout cols = new ColumnLayout(tab.getComposite(),2); 54 | 55 | Container left = new SimpleContainer(cols.getComposite()); 56 | left.addCheckbox(control.getActiveFilterSwitch(), Settings.i18n().tr("Only show currently active contracts")); 57 | 58 | control.getContractsTable().paint(this.getParent()); 59 | 60 | ButtonArea buttons = new ButtonArea(this.getParent(), 3); 61 | //buttons.addButton(new Back(false)); 62 | 63 | buttons.addButton(Settings.i18n().tr("Create new contract..."), 64 | new ShowContractDetailView(), null, true, "document-new.png"); 65 | } 66 | 67 | /** 68 | * @see de.willuhn.jameica.gui.AbstractView#unbind() 69 | */ 70 | public void unbind() throws ApplicationException { 71 | } 72 | 73 | } -------------------------------------------------------------------------------- /contractmanager/src/updates/java/update0019.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | import java.io.StringReader; 20 | import java.util.HashMap; 21 | import java.util.Map; 22 | 23 | import de.janrieke.contractmanager.rmi.ContractDBService; 24 | import de.janrieke.contractmanager.server.DBSupportH2Impl; 25 | import de.janrieke.contractmanager.server.ContractDBUpdateProvider; 26 | import de.willuhn.logging.Logger; 27 | import de.willuhn.sql.ScriptExecutor; 28 | import de.willuhn.sql.version.Update; 29 | import de.willuhn.sql.version.UpdateProvider; 30 | import de.willuhn.util.ApplicationException; 31 | import de.willuhn.util.I18N; 32 | 33 | /** 34 | * Increasing street number field size. 35 | */ 36 | public class update0019 implements Update { 37 | private Map statements = new HashMap(); 38 | 39 | /** 40 | * Default constructor 41 | */ 42 | public update0019() { 43 | // Update for H2 44 | statements.put(DBSupportH2Impl.class.getName(), 45 | "ALTER TABLE address ALTER COLUMN number VARCHAR(16) NOT NULL;\n"); 46 | } 47 | 48 | /** 49 | * @see de.willuhn.sql.version.Update#execute(de.willuhn.sql.version.UpdateProvider) 50 | */ 51 | public void execute(UpdateProvider provider) throws ApplicationException { 52 | ContractDBUpdateProvider myProvider = (ContractDBUpdateProvider) provider; 53 | I18N i18n = myProvider.getResources().getI18N(); 54 | 55 | // Get the SQL dialect 56 | String driver = ContractDBService.SETTINGS.getString("database.driver", 57 | DBSupportH2Impl.class.getName()); 58 | String sql = (String) statements.get(driver); 59 | if (sql == null) 60 | throw new ApplicationException(i18n.tr( 61 | "Database {0} not supported", driver)); 62 | 63 | try { 64 | ScriptExecutor 65 | .execute(new StringReader(sql), myProvider.getConnection(), 66 | myProvider.getProgressMonitor()); 67 | myProvider.getProgressMonitor().log(i18n.tr("Database updated.")); 68 | } catch (ApplicationException ae) { 69 | throw ae; 70 | } catch (Exception e) { 71 | Logger.error("unable to execute update", e); 72 | throw new ApplicationException( 73 | i18n.tr("Error during database update"), e); 74 | } 75 | } 76 | 77 | /** 78 | * @see de.willuhn.sql.version.Update#getName() 79 | */ 80 | public String getName() { 81 | return "Database update v18 to v19 (increasing street number field size)"; 82 | } 83 | 84 | } -------------------------------------------------------------------------------- /contractmanager/src/updates/java/update0018.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | import java.io.StringReader; 20 | import java.util.HashMap; 21 | import java.util.Map; 22 | 23 | import de.janrieke.contractmanager.rmi.ContractDBService; 24 | import de.janrieke.contractmanager.server.DBSupportH2Impl; 25 | import de.janrieke.contractmanager.server.ContractDBUpdateProvider; 26 | import de.willuhn.logging.Logger; 27 | import de.willuhn.sql.ScriptExecutor; 28 | import de.willuhn.sql.version.Update; 29 | import de.willuhn.sql.version.UpdateProvider; 30 | import de.willuhn.util.ApplicationException; 31 | import de.willuhn.util.I18N; 32 | 33 | /** 34 | * Removes table icaluids. 35 | */ 36 | public class update0018 implements Update { 37 | private Map statements = new HashMap(); 38 | 39 | /** 40 | * Default constructor 41 | */ 42 | public update0018() { 43 | // Update for H2 44 | statements.put(DBSupportH2Impl.class.getName(), 45 | "ALTER TABLE contract ADD COLUMN ignore_cancellations int(1);\n" 46 | + "DROP TABLE icaluids\n"); 47 | } 48 | 49 | /** 50 | * @see de.willuhn.sql.version.Update#execute(de.willuhn.sql.version.UpdateProvider) 51 | */ 52 | public void execute(UpdateProvider provider) throws ApplicationException { 53 | ContractDBUpdateProvider myProvider = (ContractDBUpdateProvider) provider; 54 | I18N i18n = myProvider.getResources().getI18N(); 55 | 56 | // Get the SQL dialect 57 | String driver = ContractDBService.SETTINGS.getString("database.driver", 58 | DBSupportH2Impl.class.getName()); 59 | String sql = (String) statements.get(driver); 60 | if (sql == null) 61 | throw new ApplicationException(i18n.tr( 62 | "Database {0} not supported", driver)); 63 | 64 | try { 65 | ScriptExecutor 66 | .execute(new StringReader(sql), myProvider.getConnection(), 67 | myProvider.getProgressMonitor()); 68 | myProvider.getProgressMonitor().log(i18n.tr("Database updated.")); 69 | } catch (ApplicationException ae) { 70 | throw ae; 71 | } catch (Exception e) { 72 | Logger.error("unable to execute update", e); 73 | throw new ApplicationException( 74 | i18n.tr("Error during database update"), e); 75 | } 76 | } 77 | 78 | /** 79 | * @see de.willuhn.sql.version.Update#getName() 80 | */ 81 | public String getName() { 82 | return "Database update v17 to v18 (adding column for ignoring cancellation warnings)"; 83 | } 84 | 85 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/menu/ContractListMenu.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.gui.menu; 19 | 20 | import de.janrieke.contractmanager.Settings; 21 | import de.janrieke.contractmanager.gui.action.DeleteContract; 22 | import de.janrieke.contractmanager.gui.action.DismissNextReminder; 23 | import de.janrieke.contractmanager.gui.action.GenerateOdfDocument; 24 | import de.janrieke.contractmanager.gui.action.ShowContractDetailView; 25 | import de.janrieke.contractmanager.gui.parts.OnlyForContractsWithRemindersContextMenuItem; 26 | import de.willuhn.jameica.gui.Action; 27 | import de.willuhn.jameica.gui.parts.CheckedContextMenuItem; 28 | import de.willuhn.jameica.gui.parts.ContextMenu; 29 | import de.willuhn.jameica.gui.parts.ContextMenuItem; 30 | import de.willuhn.jameica.gui.parts.TablePart; 31 | import de.willuhn.util.ApplicationException; 32 | 33 | /** 34 | * Prepared context menu for project tables. 35 | */ 36 | public class ContractListMenu extends ContextMenu { 37 | /** 38 | * ct. 39 | * 40 | * @param showNew 41 | */ 42 | public ContractListMenu(TablePart tablePart, boolean showNew) { 43 | // CheckedContextMenuItems will be disabled, if the user clicks into an 44 | // empty space of the table 45 | addItem(new CheckedContextMenuItem(Settings.i18n().tr("Open..."), 46 | new ShowContractDetailView(), "document-open.png")); 47 | 48 | addItem(new CheckedContextMenuItem(Settings.i18n().tr( 49 | "Generate Letter..."), new GenerateOdfDocument(), 50 | "document-print.png")); 51 | 52 | addItem(new OnlyForContractsWithRemindersContextMenuItem(Settings.i18n().tr( 53 | "Dismiss Reminder For Next Deadline"), new DismissNextReminder(tablePart))); 54 | 55 | if (showNew) { 56 | // separator 57 | addItem(ContextMenuItem.SEPARATOR); 58 | 59 | addItem(new ContextMenuItem(Settings.i18n().tr( 60 | "Create a new contract..."), new Action() { 61 | public void handleAction(Object context) 62 | throws ApplicationException { 63 | // we force the context to be null to create a new 64 | // project in any case 65 | new ShowContractDetailView().handleAction(null); 66 | } 67 | }, "document-new.png")); 68 | 69 | addItem(ContextMenuItem.SEPARATOR); 70 | addItem(new CheckedContextMenuItem(Settings.i18n().tr( 71 | "Delete contract..."), new DeleteContract(), 72 | "window-close.png")); 73 | } 74 | 75 | } 76 | } -------------------------------------------------------------------------------- /contractmanager/src/updates/java/update0017.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | import java.io.StringReader; 20 | import java.util.HashMap; 21 | import java.util.Map; 22 | 23 | import de.janrieke.contractmanager.rmi.ContractDBService; 24 | import de.janrieke.contractmanager.server.DBSupportH2Impl; 25 | import de.janrieke.contractmanager.server.ContractDBUpdateProvider; 26 | import de.willuhn.logging.Logger; 27 | import de.willuhn.sql.ScriptExecutor; 28 | import de.willuhn.sql.version.Update; 29 | import de.willuhn.sql.version.UpdateProvider; 30 | import de.willuhn.util.ApplicationException; 31 | import de.willuhn.util.I18N; 32 | 33 | 34 | /** 35 | * Adds a new column "hibiscus_category" to contract table. 36 | */ 37 | public class update0017 implements Update 38 | { 39 | private Map statements = new HashMap(); 40 | 41 | /** 42 | * Default constructor 43 | */ 44 | public update0017() 45 | { 46 | // Update for H2 47 | statements.put(DBSupportH2Impl.class.getName(), 48 | "ALTER TABLE contract ADD COLUMN hibiscus_category varchar(255) NULL\n"); 49 | } 50 | 51 | /** 52 | * @see de.willuhn.sql.version.Update#execute(de.willuhn.sql.version.UpdateProvider) 53 | */ 54 | public void execute(UpdateProvider provider) throws ApplicationException 55 | { 56 | ContractDBUpdateProvider myProvider = (ContractDBUpdateProvider) provider; 57 | I18N i18n = myProvider.getResources().getI18N(); 58 | 59 | // Get the SQL dialect 60 | String driver = ContractDBService.SETTINGS.getString("database.driver",DBSupportH2Impl.class.getName()); 61 | String sql = (String) statements.get(driver); 62 | if (sql == null) 63 | throw new ApplicationException(i18n.tr("Database {0} not supported",driver)); 64 | 65 | try 66 | { 67 | ScriptExecutor.execute(new StringReader(sql),myProvider.getConnection(),myProvider.getProgressMonitor()); 68 | myProvider.getProgressMonitor().log(i18n.tr("Database updated.")); 69 | } 70 | catch (ApplicationException ae) 71 | { 72 | throw ae; 73 | } 74 | catch (Exception e) 75 | { 76 | Logger.error("unable to execute update",e); 77 | throw new ApplicationException(i18n.tr("Error during database update"),e); 78 | } 79 | } 80 | 81 | /** 82 | * @see de.willuhn.sql.version.Update#getName() 83 | */ 84 | public String getName() 85 | { 86 | return "Database update v16 to v17 (adding column for hibiscus categories)"; 87 | } 88 | 89 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/server/TransactionImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.server; 19 | 20 | import java.rmi.RemoteException; 21 | 22 | import de.janrieke.contractmanager.rmi.Contract; 23 | import de.janrieke.contractmanager.rmi.Transaction; 24 | import de.willuhn.datasource.db.AbstractDBObject; 25 | import de.willuhn.datasource.rmi.ObjectNotFoundException; 26 | 27 | /** 28 | * CREATE TABLE transactions ( transaction_id int(5), contract_id int(5), UNIQUE 29 | * (transaction_id), PRIMARY KEY (transaction_id) ); 30 | * 31 | * @author Jan Rieke 32 | * 33 | */ 34 | public class TransactionImpl extends AbstractDBObject implements Transaction { 35 | 36 | public TransactionImpl() throws RemoteException { 37 | super(); 38 | } 39 | 40 | /** 41 | * The UID. 42 | */ 43 | private static final long serialVersionUID = 6231715594674008961L; 44 | 45 | @Override 46 | protected String getTableName() { 47 | return "transactions"; 48 | } 49 | 50 | /** 51 | * @see de.willuhn.datasource.db.AbstractDBObject#getForeignObject(java.lang.String) 52 | */ 53 | @Override 54 | protected Class getForeignObject(String field) throws RemoteException { 55 | if ("contract_id".equals(field)) 56 | return Contract.class; 57 | return null; 58 | } 59 | 60 | 61 | @Override 62 | public Contract getContract() throws RemoteException { 63 | Contract result; 64 | try { 65 | result = (Contract) getAttribute("contract_id"); 66 | } catch (ObjectNotFoundException e) { 67 | result = null; 68 | } 69 | return result; 70 | } 71 | 72 | @Override 73 | public void setContract(Contract contract) throws RemoteException { 74 | setAttribute("contract_id", contract); 75 | } 76 | 77 | @Override 78 | public String getPrimaryAttribute() throws RemoteException { 79 | return "transaction_id"; 80 | } 81 | 82 | @Override 83 | public void setTransactionID(Integer id) throws RemoteException { 84 | setAttribute("transaction_id", id.toString()); 85 | } 86 | 87 | @Override 88 | public Integer getTransactionID() throws RemoteException { 89 | return Integer.valueOf((String) getAttribute("transaction_id")); 90 | } 91 | 92 | @Override 93 | protected String getIDField() { 94 | return Boolean.getBoolean(getService().getClass().getName() + ".uppercase") ? "TRANSACTION_ID" : "transaction_id"; 95 | } 96 | 97 | 98 | 99 | } 100 | -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/rmi/ContractDBService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | /***************************************************************************** 19 | * Kopie aus Hibiscus 20 | * 21 | * $Source: /cvsroot/hibiscus/hibiscus/src/de/willuhn/jameica/hbci/rmi/HBCIDBService.java,v $ 22 | * $Revision: 1.8 $ 23 | * $Date: 2010-11-02 12:02:20 $ 24 | * $Author: willuhn $ 25 | * $Locker: $ 26 | * $State: Exp $ 27 | * 28 | ****************************************************************************/ 29 | package de.janrieke.contractmanager.rmi; 30 | 31 | import java.rmi.RemoteException; 32 | import java.sql.Connection; 33 | 34 | import de.willuhn.datasource.rmi.DBService; 35 | import de.willuhn.jameica.system.Settings; 36 | import de.willuhn.util.ApplicationException; 37 | 38 | /** 39 | * Interface fuer den Datenbank-Service von Hibiscus. 40 | * @author willuhn 41 | */ 42 | public interface ContractDBService extends DBService 43 | { 44 | /** 45 | * Einstellungen fuer die DB-Services. 46 | */ 47 | public final static Settings SETTINGS = new Settings(ContractDBService.class); 48 | 49 | /** 50 | * Initialisiert/erzeugt die Datenbank. 51 | * @throws RemoteException Wenn beim Initialisieren ein Fehler auftrat. 52 | */ 53 | public void install() throws RemoteException; 54 | 55 | /** 56 | * Checkt die Konsistenz der Datenbank und fuehrt bei Bedarf Updates durch. 57 | * @throws RemoteException Wenn es beim Pruefen der Datenbank-Konsistenz zu einem Fehler kam. 58 | * @throws ApplicationException wenn die Datenbank-Konsistenz nicht gewaehrleistet ist. 59 | */ 60 | public void checkConsistency() throws RemoteException, ApplicationException; 61 | 62 | /** 63 | * Liefert den verwendeten Treiber. 64 | * @return der Treiber. 65 | * @throws RemoteException 66 | */ 67 | public DBSupport getDriver() throws RemoteException; 68 | 69 | /** 70 | * Liefert den Namen der SQL-Funktion, mit der die Datenbank aus einem DATE-Feld einen UNIX-Timestamp macht. 71 | * Bei MySQL ist das z.Bsp. "UNIX_TIMESTAMP". 72 | * @param content der Feld-Name. 73 | * @return Name der SQL-Funktion samt Parameter. Also zum Beispiel "TONUMBER(datum)". 74 | * @throws RemoteException 75 | */ 76 | public String getSQLTimestamp(String content) throws RemoteException; 77 | 78 | /** 79 | * Returns the current connection. 80 | * @return connection 81 | * @throws RemoteException 82 | */ 83 | public Connection getConnection() throws RemoteException; 84 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/parts/ContractListTablePart.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2014 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.gui.parts; 19 | 20 | import java.rmi.RemoteException; 21 | import java.util.List; 22 | 23 | import org.eclipse.swt.SWT; 24 | import org.eclipse.swt.widgets.Button; 25 | import org.eclipse.swt.widgets.Control; 26 | import org.eclipse.swt.widgets.TableItem; 27 | 28 | import de.janrieke.contractmanager.Settings; 29 | import de.janrieke.contractmanager.rmi.Contract; 30 | import de.willuhn.jameica.gui.Action; 31 | import de.willuhn.jameica.gui.GUI; 32 | import de.willuhn.jameica.gui.parts.TableChangeListener; 33 | import de.willuhn.jameica.gui.parts.TablePart; 34 | import de.willuhn.logging.Logger; 35 | import de.willuhn.util.ApplicationException; 36 | 37 | public class ContractListTablePart extends TablePart { 38 | 39 | private double sum; 40 | 41 | public ContractListTablePart(List list, Action action) { 42 | super(list, action); 43 | setRememberColWidths(true); 44 | this.addChangeListener(new TableChangeListener() { 45 | 46 | @Override 47 | public void itemChanged(Object object, String attribute, String newValue) 48 | throws ApplicationException { 49 | assert object instanceof Contract; 50 | try { 51 | ((Contract)object).setDoNotRemind(!"\u2611".equals(newValue)); 52 | ((Contract)object).store(); 53 | } catch (RemoteException e) { 54 | Logger.error("error while storing contract", e); 55 | GUI.getStatusBar().setErrorText( 56 | Settings.i18n().tr("Error while storing contract")); 57 | } 58 | } 59 | }); 60 | } 61 | 62 | @Override 63 | protected String getControlValue(Control control) { 64 | if (control instanceof Button) { 65 | return ((Button) control).getSelection()?"\u2611":"\u2610"; 66 | } else { 67 | return super.getControlValue(control); 68 | } 69 | } 70 | 71 | @Override 72 | protected Control getEditorControl(int row, TableItem item, String oldValue) { 73 | if (item.getData() instanceof Contract && row == 7) { 74 | Button newButton = new Button(item.getParent(), SWT.CHECK); 75 | newButton.setSelection("\u2611".equals(oldValue)); 76 | newButton.setFocus(); 77 | return newButton; 78 | } else { 79 | return super.getEditorControl(row, item, oldValue); 80 | } 81 | } 82 | 83 | public void setSum(double sum) { 84 | this.sum = sum; 85 | } 86 | 87 | @Override 88 | protected String getSummary() { 89 | return Settings.i18n().tr("Total in this month") + ": " + Settings.DECIMALFORMAT.format(Math.round(sum*100d)/100d) + " EUR"; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /contractmanager/src/updates/java/update0016.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | import java.io.StringReader; 20 | import java.util.HashMap; 21 | import java.util.Map; 22 | 23 | import de.janrieke.contractmanager.rmi.ContractDBService; 24 | import de.janrieke.contractmanager.server.DBSupportH2Impl; 25 | import de.janrieke.contractmanager.server.ContractDBUpdateProvider; 26 | import de.willuhn.logging.Logger; 27 | import de.willuhn.sql.ScriptExecutor; 28 | import de.willuhn.sql.version.Update; 29 | import de.willuhn.sql.version.UpdateProvider; 30 | import de.willuhn.util.ApplicationException; 31 | import de.willuhn.util.I18N; 32 | 33 | 34 | /** 35 | * Adds a new table "icaluids" that holds uids of exported ical entries. 36 | */ 37 | public class update0016 implements Update 38 | { 39 | private Map statements = new HashMap(); 40 | 41 | /** 42 | * Default constructor 43 | */ 44 | public update0016() 45 | { 46 | // Update for H2 47 | statements.put(DBSupportH2Impl.class.getName(), 48 | "CREATE TABLE icaluids (" + 49 | "uid varchar(255) NOT NULL, " + 50 | "contract_id int(5), " + 51 | "UNIQUE (uid), " + 52 | "PRIMARY KEY (uid));\n" + 53 | "ALTER TABLE icaluids ADD CONSTRAINT fk_icaluids_contract FOREIGN KEY (contract_id) REFERENCES contract (id) DEFERRABLE;\n"); 54 | } 55 | 56 | /** 57 | * @see de.willuhn.sql.version.Update#execute(de.willuhn.sql.version.UpdateProvider) 58 | */ 59 | public void execute(UpdateProvider provider) throws ApplicationException 60 | { 61 | ContractDBUpdateProvider myProvider = (ContractDBUpdateProvider) provider; 62 | I18N i18n = myProvider.getResources().getI18N(); 63 | 64 | // Get the SQL dialect 65 | String driver = ContractDBService.SETTINGS.getString("database.driver",DBSupportH2Impl.class.getName()); 66 | String sql = (String) statements.get(driver); 67 | if (sql == null) 68 | throw new ApplicationException(i18n.tr("Database {0} not supported",driver)); 69 | 70 | try 71 | { 72 | ScriptExecutor.execute(new StringReader(sql),myProvider.getConnection(),myProvider.getProgressMonitor()); 73 | myProvider.getProgressMonitor().log(i18n.tr("Database updated.")); 74 | } 75 | catch (ApplicationException ae) 76 | { 77 | throw ae; 78 | } 79 | catch (Exception e) 80 | { 81 | Logger.error("unable to execute update",e); 82 | throw new ApplicationException(i18n.tr("Error during database update"),e); 83 | } 84 | } 85 | 86 | /** 87 | * @see de.willuhn.sql.version.Update#getName() 88 | */ 89 | public String getName() 90 | { 91 | return "Database update v15 to v16 (adding table icaluids)"; 92 | } 93 | 94 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/util/DateUtils.java: -------------------------------------------------------------------------------- 1 | package de.janrieke.contractmanager.util; 2 | 3 | import java.util.Calendar; 4 | import java.util.Date; 5 | 6 | import de.janrieke.contractmanager.rmi.IntervalType; 7 | import de.willuhn.jameica.util.DateUtil; 8 | 9 | public class DateUtils { 10 | 11 | /** 12 | * 13 | * @param calendar 14 | * the calender to modify 15 | * @param interval 16 | * @param count 17 | * @return true if the operation was performed, false if it was impossible 18 | * due to invalid interval type. 19 | */ 20 | public static final boolean addToCalendar(Calendar calendar, IntervalType interval, int count) { 21 | // if the period is invalid, assume there is none 22 | if (interval != null) { 23 | switch (interval) { 24 | case DAYS: 25 | calendar.add(Calendar.DAY_OF_YEAR, count); 26 | return true; 27 | case WEEKS: 28 | calendar.add(Calendar.WEEK_OF_YEAR, count); 29 | return true; 30 | case MONTHS: 31 | calendar.add(Calendar.MONTH, count); 32 | return true; 33 | case QUARTER_YEARS: 34 | calendar.add(Calendar.MONTH, count * 3); 35 | return true; 36 | case HALF_YEARS: 37 | calendar.add(Calendar.MONTH, count * 6); 38 | return true; 39 | case YEARS: 40 | calendar.add(Calendar.YEAR, count); 41 | return true; 42 | case ONCE: 43 | return false; 44 | default: 45 | return false; 46 | } 47 | } 48 | return false; 49 | } 50 | 51 | /** 52 | * Calculates the next contractual term's end after the given date. 53 | * 54 | * @param after 55 | * @param excludeFirstTerm If true, never return the start of the first term. 56 | * @return The end of the term, or null if no end could be calculated. 57 | */ 58 | public static Date calculateNextTermBeginAfter(Date after, Date startDate, boolean excludeFirstTerm, ValidRuntimes runtimes) { 59 | if (after == null) { 60 | return null; 61 | } 62 | if (startDate == null) { 63 | return null; 64 | } 65 | if (runtimes == null) { 66 | return null; 67 | } 68 | 69 | Calendar afterCal = Calendar.getInstance(); 70 | afterCal.setTime(DateUtil.endOfDay(after)); 71 | 72 | Calendar calendar = Calendar.getInstance(); 73 | calendar.setTime(startDate); 74 | 75 | // If fixed terms is true, virtually delay the start of the contract to the next period. 76 | if (runtimes.fixedTerms) { 77 | switch (runtimes.firstMinRuntimeType) { 78 | case WEEKS: 79 | calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); 80 | calendar.add(Calendar.WEEK_OF_YEAR, 1); 81 | break; 82 | case MONTHS: 83 | calendar.set(Calendar.DAY_OF_MONTH, 1); 84 | calendar.add(Calendar.MONTH, 1); 85 | break; 86 | case YEARS: 87 | calendar.set(Calendar.DAY_OF_YEAR, 1); 88 | calendar.add(Calendar.YEAR, 1); 89 | break; 90 | default: 91 | } 92 | 93 | } 94 | 95 | boolean first = true; 96 | boolean validResult = true; 97 | 98 | while (validResult && (!calendar.after(afterCal) || (first && excludeFirstTerm))) { 99 | if (first) { 100 | validResult = addToCalendar(calendar, runtimes.firstMinRuntimeType, runtimes.firstMinRuntimeCount); 101 | first = false; 102 | } else { 103 | validResult = addToCalendar(calendar, runtimes.followingMinRuntimeType, runtimes.followingMinRuntimeCount); 104 | } 105 | } 106 | 107 | return validResult ? calendar.getTime() : null; 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /contractmanager/src/updates/java/update0020.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | import java.io.StringReader; 20 | import java.util.HashMap; 21 | import java.util.Map; 22 | 23 | import de.janrieke.contractmanager.rmi.ContractDBService; 24 | import de.janrieke.contractmanager.server.DBSupportH2Impl; 25 | import de.janrieke.contractmanager.server.ContractDBUpdateProvider; 26 | import de.willuhn.logging.Logger; 27 | import de.willuhn.sql.ScriptExecutor; 28 | import de.willuhn.sql.version.Update; 29 | import de.willuhn.sql.version.UpdateProvider; 30 | import de.willuhn.util.ApplicationException; 31 | import de.willuhn.util.I18N; 32 | 33 | /** 34 | * Remind me later function 35 | */ 36 | public class update0020 implements Update { 37 | private Map statements = new HashMap(); 38 | 39 | /** 40 | * Default constructor 41 | */ 42 | public update0020() { 43 | // Update for H2 44 | statements.put(DBSupportH2Impl.class.getName(), 45 | "ALTER TABLE contract ADD COLUMN do_not_remind_before date;\n" + 46 | "ALTER TABLE transactions DROP CONSTRAINT fk_contract;\n" + 47 | "ALTER TABLE transactions ADD CONSTRAINT fk_transactions_contract FOREIGN KEY (contract_id) REFERENCES contract (id) ON DELETE CASCADE ON UPDATE CASCADE;\n" + 48 | "DELETE FROM costs WHERE contract_id NOT IN (SELECT id from contract);\n" + //in case some unassigned costs got lost in the DB 49 | "ALTER TABLE costs ADD CONSTRAINT fk_costs_contract FOREIGN KEY (contract_id) REFERENCES contract (id) ON DELETE CASCADE ON UPDATE CASCADE;\n"); 50 | } 51 | 52 | /** 53 | * @see de.willuhn.sql.version.Update#execute(de.willuhn.sql.version.UpdateProvider) 54 | */ 55 | public void execute(UpdateProvider provider) throws ApplicationException { 56 | ContractDBUpdateProvider myProvider = (ContractDBUpdateProvider) provider; 57 | I18N i18n = myProvider.getResources().getI18N(); 58 | 59 | // Get the SQL dialect 60 | String driver = ContractDBService.SETTINGS.getString("database.driver", 61 | DBSupportH2Impl.class.getName()); 62 | String sql = (String) statements.get(driver); 63 | if (sql == null) 64 | throw new ApplicationException(i18n.tr( 65 | "Database {0} not supported", driver)); 66 | 67 | try { 68 | ScriptExecutor 69 | .execute(new StringReader(sql), myProvider.getConnection(), 70 | myProvider.getProgressMonitor()); 71 | myProvider.getProgressMonitor().log(i18n.tr("Database updated.")); 72 | } catch (ApplicationException ae) { 73 | throw ae; 74 | } catch (Exception e) { 75 | Logger.error("unable to execute update", e); 76 | throw new ApplicationException( 77 | i18n.tr("Error during database update"), e); 78 | } 79 | } 80 | 81 | /** 82 | * @see de.willuhn.sql.version.Update#getName() 83 | */ 84 | public String getName() { 85 | return "Database update v19 to v20 (remind me later function, DB cleanup)"; 86 | } 87 | 88 | } -------------------------------------------------------------------------------- /contractmanager/src/updates/java/update0021.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | import java.io.StringReader; 20 | import java.util.HashMap; 21 | import java.util.Map; 22 | 23 | import de.janrieke.contractmanager.rmi.ContractDBService; 24 | import de.janrieke.contractmanager.server.ContractDBUpdateProvider; 25 | import de.janrieke.contractmanager.server.DBSupportH2Impl; 26 | import de.willuhn.logging.Logger; 27 | import de.willuhn.sql.ScriptExecutor; 28 | import de.willuhn.sql.version.Update; 29 | import de.willuhn.sql.version.UpdateProvider; 30 | import de.willuhn.util.ApplicationException; 31 | import de.willuhn.util.I18N; 32 | 33 | /** 34 | * Document storage; SEPA information 35 | */ 36 | public class update0021 implements Update { 37 | private Map statements = new HashMap<>(); 38 | 39 | /** 40 | * Default constructor 41 | */ 42 | public update0021() { 43 | // Update for H2 44 | statements.put(DBSupportH2Impl.class.getName(), 45 | "ALTER TABLE contract ADD COLUMN sepa_creditor varchar(35);\n" + 46 | "ALTER TABLE contract ADD COLUMN sepa_customer varchar(35);\n" + 47 | "CREATE TABLE storage (\n" + 48 | " id IDENTITY,\n" + 49 | " contract_id int(5),\n" + 50 | " description varchar(255),\n" + 51 | " path varchar(65535),\n" + 52 | " file BLOB,\n" + 53 | " UNIQUE (id),\n" + 54 | " PRIMARY KEY (id),\n" + 55 | " CONSTRAINT fk_storage_contract FOREIGN KEY (contract_id) REFERENCES contract (id) ON DELETE CASCADE ON UPDATE CASCADE\n" + 56 | ");\n"); 57 | } 58 | 59 | /** 60 | * @see de.willuhn.sql.version.Update#execute(de.willuhn.sql.version.UpdateProvider) 61 | */ 62 | @Override 63 | public void execute(UpdateProvider provider) throws ApplicationException { 64 | ContractDBUpdateProvider myProvider = (ContractDBUpdateProvider) provider; 65 | I18N i18n = myProvider.getResources().getI18N(); 66 | 67 | // Get the SQL dialect 68 | String driver = ContractDBService.SETTINGS.getString("database.driver", 69 | DBSupportH2Impl.class.getName()); 70 | String sql = statements.get(driver); 71 | if (sql == null) { 72 | throw new ApplicationException(i18n.tr( 73 | "Database {0} not supported", driver)); 74 | } 75 | 76 | try { 77 | ScriptExecutor 78 | .execute(new StringReader(sql), myProvider.getConnection(), 79 | myProvider.getProgressMonitor()); 80 | myProvider.getProgressMonitor().log(i18n.tr("Database updated.")); 81 | } catch (ApplicationException ae) { 82 | throw ae; 83 | } catch (Exception e) { 84 | Logger.error("unable to execute update", e); 85 | throw new ApplicationException( 86 | i18n.tr("Error during database update"), e); 87 | } 88 | } 89 | 90 | /** 91 | * @see de.willuhn.sql.version.Update#getName() 92 | */ 93 | @Override 94 | public String getName() { 95 | return "Database update v20 to v21 (SEPA fields, document storage)"; 96 | } 97 | 98 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/server/SettingImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | /********************************************************************** 19 | * $Source: /cvsroot/hibiscus/hibiscus/src/de/willuhn/jameica/hbci/server/DBPropertyImpl.java,v $ 20 | * $Revision: 1.1 $ 21 | * $Date: 2008-05-30 14:23:48 $ 22 | * $Author: willuhn $ 23 | * $Locker: $ 24 | * $State: Exp $ 25 | * 26 | * Copyright (c) by willuhn software & services 27 | * All rights reserved 28 | * 29 | **********************************************************************/ 30 | 31 | package de.janrieke.contractmanager.server; 32 | 33 | import java.rmi.RemoteException; 34 | import java.sql.SQLException; 35 | 36 | import de.janrieke.contractmanager.rmi.Setting; 37 | import de.willuhn.datasource.db.AbstractDBObject; 38 | 39 | /** 40 | * Speichert ein einzelnes Property in der Datenbank. 41 | */ 42 | public class SettingImpl extends AbstractDBObject implements Setting { 43 | 44 | /** 45 | * The UID. 46 | */ 47 | private static final long serialVersionUID = 2994333719211540630L; 48 | 49 | private boolean upper; 50 | 51 | /** 52 | * ct 53 | * 54 | * @throws RemoteException 55 | */ 56 | public SettingImpl() throws RemoteException { 57 | super(); 58 | } 59 | 60 | @Override 61 | protected void init() throws SQLException { 62 | super.init(); 63 | upper = Boolean.getBoolean(getService().getClass().getName() + ".uppercase"); 64 | } 65 | 66 | /** 67 | * @see de.willuhn.datasource.db.AbstractDBObject#getPrimaryAttribute() 68 | */ 69 | @Override 70 | public String getPrimaryAttribute() throws RemoteException { 71 | return "mkey"; 72 | } 73 | 74 | @Override 75 | protected String getIDField() { 76 | return upper ? "MKEY" : "mkey"; 77 | } 78 | 79 | /** 80 | * @see de.willuhn.datasource.db.AbstractDBObject#getTableName() 81 | */ 82 | @Override 83 | protected String getTableName() { 84 | return "settings"; 85 | } 86 | 87 | /** 88 | * @see de.willuhn.jameica.hbci.rmi.DBProperty#getName() 89 | */ 90 | @Override 91 | public String getKey() throws RemoteException { 92 | return (String) getAttribute("mkey"); 93 | } 94 | 95 | /** 96 | * @see de.willuhn.jameica.hbci.rmi.DBProperty#setValue(java.lang.String) 97 | */ 98 | @Override 99 | public void setKey(String key) throws RemoteException { 100 | setAttribute("mkey", key); 101 | } 102 | 103 | /** 104 | * @see de.willuhn.jameica.hbci.rmi.DBProperty#getValue() 105 | */ 106 | @Override 107 | public String getValue() throws RemoteException { 108 | return (String) getAttribute("value"); 109 | } 110 | 111 | /** 112 | * @see de.willuhn.jameica.hbci.rmi.DBProperty#setValue(java.lang.String) 113 | */ 114 | @Override 115 | public void setValue(String value) throws RemoteException { 116 | setAttribute("value", value); 117 | } 118 | 119 | } -------------------------------------------------------------------------------- /contractmanager/updatesite/jameica-repository-1.0.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 26 | 27 | 31 | 32 | 33 | 34 | XML-Spezifikation des XML-Formats fuer die "repository.xml" 35 | von Update-Sites fuer Jameica. 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | Root-Element einer repository.xml 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | Bezeichnung des Repositories. 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | Definition der Liste von Plugins in diesem Repository. 65 | 66 | 67 | 68 | 69 | Definition eines einzelnen Updates 70 | 71 | 72 | 73 | 74 | 75 | URL des Repository 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | Optionale Angabe eines Namens fuer die Gruppe von Plugins. 86 | 87 | 88 | 89 | 90 | 91 | 92 | Optionale Angabe der URL eines PEM/DER-codierten Aussteller-Zertifikates der Plugins. 93 | 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/view/IncomeExpensesAnalysisView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.gui.view; 19 | 20 | import org.eclipse.swt.widgets.Event; 21 | 22 | import de.janrieke.contractmanager.Settings; 23 | import de.janrieke.contractmanager.gui.control.IncomeExpensesAnalysisControl; 24 | import de.willuhn.jameica.gui.AbstractView; 25 | import de.willuhn.jameica.gui.GUI; 26 | import de.willuhn.jameica.gui.parts.Button; 27 | import de.willuhn.jameica.gui.util.ColumnLayout; 28 | import de.willuhn.jameica.gui.util.Container; 29 | import de.willuhn.jameica.gui.util.SimpleContainer; 30 | 31 | /** 32 | * this is the dialog for the contract details. 33 | */ 34 | public class IncomeExpensesAnalysisView extends AbstractView { 35 | 36 | private IncomeExpensesAnalysisControl control; 37 | 38 | private int selectedYear = -1; 39 | private int selectedMonth = -1; 40 | private boolean selectedUsePaydays = false; 41 | 42 | /** 43 | * @see de.willuhn.jameica.gui.AbstractView#bind() 44 | */ 45 | @Override 46 | public void bind() throws Exception { 47 | // draw the title 48 | GUI.getView().setTitle(Settings.i18n().tr("Income/Expenses Comparison")); 49 | 50 | control = new IncomeExpensesAnalysisControl(this); 51 | 52 | // register listeners (must happen before adding the control) 53 | control.getPayDayCheckbox().addListener(this::handleReload); 54 | control.getYearSelector().addListener(this::handleReload); 55 | control.getMonthSelector().addListener(this::handleReload); 56 | 57 | SimpleContainer container = new SimpleContainer(getParent(), true); 58 | 59 | ColumnLayout top = new ColumnLayout(container.getComposite(), 4); 60 | Container col1 = new SimpleContainer(top.getComposite()); 61 | Container col2 = new SimpleContainer(top.getComposite()); 62 | Container col3 = new SimpleContainer(top.getComposite()); 63 | 64 | col1.addCheckbox(control.getPayDayCheckbox(), Settings.i18n().tr("Use paydays")); 65 | col2.addLabelPair(Settings.i18n().tr("Month:"), control.getMonthSelector()); 66 | col3.addLabelPair(Settings.i18n().tr("Year:"), control.getYearSelector()); 67 | top.add(new Button(Settings.i18n().tr("Current Month"), this::toCurrentMonth)); 68 | 69 | container.addPart(control.getChartPart()); 70 | } 71 | 72 | private synchronized void handleReload(Event event) { 73 | if (inputsChanged()) { 74 | control.redrawChart(); 75 | } 76 | } 77 | 78 | private boolean inputsChanged() { 79 | boolean newUsePaydays = (Boolean) control.getPayDayCheckbox().getValue(); 80 | int newMonth = control.getMonthNumber((String) control.getMonthSelector().getValue()); 81 | int newYear = (Integer) control.getYearSelector().getValue(); 82 | if (selectedUsePaydays != newUsePaydays 83 | || selectedMonth != newMonth 84 | || selectedYear != newYear) { 85 | selectedUsePaydays = newUsePaydays; 86 | selectedMonth = newMonth; 87 | selectedYear = newYear; 88 | return true; 89 | } 90 | return false; 91 | } 92 | 93 | private void toCurrentMonth(Object context) { 94 | control.resetToCurrentMonth(); 95 | handleReload(null); 96 | } 97 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/action/DeleteAddress.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.gui.action; 19 | 20 | import java.rmi.RemoteException; 21 | 22 | import de.janrieke.contractmanager.Settings; 23 | import de.janrieke.contractmanager.gui.view.AddressDetailView; 24 | import de.janrieke.contractmanager.rmi.Address; 25 | import de.janrieke.contractmanager.rmi.Contract; 26 | import de.willuhn.datasource.rmi.DBIterator; 27 | import de.willuhn.datasource.rmi.DBService; 28 | import de.willuhn.jameica.gui.Action; 29 | import de.willuhn.jameica.gui.GUI; 30 | import de.willuhn.jameica.gui.dialogs.YesNoDialog; 31 | import de.willuhn.logging.Logger; 32 | import de.willuhn.util.ApplicationException; 33 | 34 | /** 35 | * Action for "delete contract". 36 | */ 37 | public class DeleteAddress implements Action { 38 | 39 | /** 40 | * @see de.willuhn.jameica.gui.Action#handleAction(java.lang.Object) 41 | */ 42 | @Override 43 | public void handleAction(Object context) throws ApplicationException { 44 | 45 | // check if the context is a address 46 | if (context == null || !(context instanceof Address)) { 47 | throw new ApplicationException(Settings.i18n().tr( 48 | "Please choose a address.")); 49 | } 50 | 51 | Address p = (Address) context; 52 | 53 | // first check that there is no contract associated with that address 54 | try { 55 | // 1) Get the Database Service. 56 | DBService service = Settings.getDBService(); 57 | 58 | // 2) We create the contract list using createList(Class) 59 | DBIterator contracts = service.createList(Contract.class); 60 | 61 | // 3) we add a filter to only query for tasks with our address id 62 | contracts.addFilter("address_id = " + p.getID()); 63 | 64 | if (contracts.size()>0) { 65 | GUI.getView().setErrorText(Settings.i18n().tr("Address was not deleted because it is still in use.")); 66 | GUI.getStatusBar().setErrorText(Settings.i18n().tr("Address was not deleted because it is still in use.")); 67 | return; 68 | } 69 | } catch (RemoteException e) { 70 | throw new ApplicationException("unable to load contract list", e); 71 | } 72 | 73 | try { 74 | // before deleting the address, we show up a confirm dialog ;) 75 | 76 | YesNoDialog d = new YesNoDialog(YesNoDialog.POSITION_CENTER); 77 | d.setTitle(Settings.i18n().tr("Are you sure?")); 78 | d.setText(Settings.i18n().tr( 79 | "Do you really want to delete this address?")); 80 | 81 | Boolean choice = (Boolean) d.open(); 82 | if (!choice.booleanValue()) { 83 | return; 84 | } 85 | 86 | p.delete(); 87 | GUI.getStatusBar().setSuccessText( 88 | Settings.i18n().tr("Address deleted successfully")); 89 | } catch (Exception e) { 90 | Logger.error("error while deleting address", e); 91 | throw new ApplicationException(Settings.i18n().tr( 92 | "Error while deleting address")); 93 | } 94 | 95 | if (GUI.getCurrentView() instanceof AddressDetailView) { 96 | GUI.startPreviousView(); 97 | } 98 | } 99 | 100 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/view/ExpensesAnalysisView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.gui.view; 19 | 20 | import org.eclipse.swt.widgets.Event; 21 | 22 | import de.janrieke.contractmanager.Settings; 23 | import de.janrieke.contractmanager.gui.control.ExpensesAnalysisControl; 24 | import de.willuhn.jameica.gui.AbstractView; 25 | import de.willuhn.jameica.gui.GUI; 26 | import de.willuhn.jameica.gui.parts.Button; 27 | import de.willuhn.jameica.gui.util.ColumnLayout; 28 | import de.willuhn.jameica.gui.util.Container; 29 | import de.willuhn.jameica.gui.util.SimpleContainer; 30 | 31 | /** 32 | * this is the dialog for the contract details. 33 | */ 34 | public class ExpensesAnalysisView extends AbstractView { 35 | 36 | private ExpensesAnalysisControl control; 37 | 38 | private int selectedYear = -1; 39 | private int selectedMonth = -1; 40 | private boolean selectedUsePaydays = false; 41 | 42 | /** 43 | * @see de.willuhn.jameica.gui.AbstractView#bind() 44 | */ 45 | @Override 46 | public void bind() throws Exception { 47 | // draw the title 48 | GUI.getView().setTitle(Settings.i18n().tr("Income/Expenses Comparison")); 49 | 50 | // instanciate controller 51 | control = new ExpensesAnalysisControl(this); 52 | 53 | // register listeners (must happen before adding the control) 54 | control.getPayDayCheckbox().addListener(this::handleReload); 55 | control.getYearSelector().addListener(this::handleReload); 56 | control.getMonthSelector().addListener(this::handleReload); 57 | 58 | SimpleContainer container = new SimpleContainer(getParent(), true); 59 | 60 | ColumnLayout top = new ColumnLayout(container.getComposite(), 4); 61 | Container col1 = new SimpleContainer(top.getComposite()); 62 | Container col2 = new SimpleContainer(top.getComposite()); 63 | Container col3 = new SimpleContainer(top.getComposite()); 64 | 65 | col1.addCheckbox(control.getPayDayCheckbox(), Settings.i18n().tr("Use paydays")); 66 | col2.addLabelPair(Settings.i18n().tr("Month:"), control.getMonthSelector()); 67 | col3.addLabelPair(Settings.i18n().tr("Year:"), control.getYearSelector()); 68 | top.add(new Button(Settings.i18n().tr("Current Month"), this::toCurrentMonth)); 69 | 70 | container.addPart(control.getChartPart()); 71 | } 72 | private synchronized void handleReload(Event event) { 73 | if (inputsChanged()) { 74 | control.redrawChart(); 75 | } 76 | } 77 | 78 | private boolean inputsChanged() { 79 | boolean newUsePaydays = (Boolean) control.getPayDayCheckbox().getValue(); 80 | int newMonth = control.getMonthNumber((String) control.getMonthSelector().getValue()); 81 | int newYear = (Integer) control.getYearSelector().getValue(); 82 | if (selectedUsePaydays != newUsePaydays 83 | || selectedMonth != newMonth 84 | || selectedYear != newYear) { 85 | selectedUsePaydays = newUsePaydays; 86 | selectedMonth = newMonth; 87 | selectedYear = newYear; 88 | return true; 89 | } 90 | return false; 91 | } 92 | 93 | private void toCurrentMonth(Object context) { 94 | control.resetToCurrentMonth(); 95 | handleReload(null); 96 | } 97 | } -------------------------------------------------------------------------------- /contractmanager/plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | ContractManager for Jameica 9 | http://janrieke.de/products/jameica/updates/contractmanager/snapshot/0.5.6-SNAPSHOT/contractmanager.zip 10 | http://janrieke.de/products/contractmanager 11 | GPL 3.0 - http://www.gnu.org/licenses/gpl-3.0.txt 12 | contractmanager-icon-64x64.png 13 | 14 | 15 | 16 | 17 | 18 | 19 | contractmanager\.jar 20 | .*\.class 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/control/ExpensesAnalysisControl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* 20 | * Partially copied from Hibiscus/Syntax, (c) by willuhn.webdesign 21 | */ 22 | package de.janrieke.contractmanager.gui.control; 23 | 24 | import java.util.ArrayList; 25 | import java.util.Calendar; 26 | import java.util.List; 27 | import java.util.Locale; 28 | import java.util.Map; 29 | import java.util.Map.Entry; 30 | 31 | import de.janrieke.contractmanager.gui.parts.ExpensesAnalysisChartPart; 32 | import de.willuhn.jameica.gui.AbstractControl; 33 | import de.willuhn.jameica.gui.AbstractView; 34 | import de.willuhn.jameica.gui.Part; 35 | import de.willuhn.jameica.gui.input.CheckboxInput; 36 | import de.willuhn.jameica.gui.input.SelectInput; 37 | import de.willuhn.jameica.gui.input.SpinnerInput; 38 | 39 | /** 40 | * Controller fuer den Dialog Lizenzinformationen. 41 | */ 42 | public class ExpensesAnalysisControl extends AbstractControl { 43 | 44 | private Map monthNames; 45 | private SelectInput monthSelector; 46 | private SpinnerInput yearSelector; 47 | private ExpensesAnalysisChartPart chart = null; 48 | private CheckboxInput usePayDayCheckbox; 49 | 50 | /** 51 | * ct. 52 | * 53 | * @param view 54 | */ 55 | public ExpensesAnalysisControl(AbstractView view) { 56 | super(view); 57 | Calendar cal = Calendar.getInstance(); 58 | monthNames = cal.getDisplayNames(Calendar.MONTH, Calendar.LONG, Locale.getDefault()); 59 | } 60 | 61 | public Part getChartPart() { 62 | if (chart == null) { 63 | chart = new ExpensesAnalysisChartPart(this); 64 | } 65 | return chart; 66 | } 67 | 68 | public int getMonthNumber (String name) { 69 | return monthNames.get(name); 70 | } 71 | public void redrawChart() { 72 | if (chart == null) { 73 | getChartPart(); 74 | } 75 | chart.redraw(); 76 | } 77 | 78 | public SelectInput getMonthSelector() { 79 | if (monthSelector == null) { 80 | int curMonth = Calendar.getInstance().get(Calendar.MONTH); 81 | String curMonthName = null; 82 | List list = new ArrayList<>(); 83 | for (int i = 0; i<12; i++) { 84 | outer: 85 | for (Map.Entry entry : monthNames.entrySet()) { 86 | if (entry.getValue().equals(i)) { 87 | if (curMonth == i) { 88 | curMonthName = entry.getKey(); 89 | } 90 | list.add(entry.getKey()); 91 | continue outer; 92 | } 93 | } 94 | } 95 | monthSelector = new SelectInput(list, curMonthName); 96 | } 97 | return monthSelector; 98 | } 99 | 100 | public SpinnerInput getYearSelector() { 101 | if (yearSelector == null) { 102 | yearSelector = new SpinnerInput(1900, 3000, Calendar.getInstance().get(Calendar.YEAR)); 103 | } 104 | return yearSelector; 105 | } 106 | 107 | public CheckboxInput getPayDayCheckbox() { 108 | if (usePayDayCheckbox == null) { 109 | usePayDayCheckbox = new CheckboxInput(true); 110 | } 111 | return usePayDayCheckbox; 112 | } 113 | 114 | public void resetToCurrentMonth() { 115 | int curMonth = Calendar.getInstance().get(Calendar.MONTH); 116 | String currentMonth = monthNames.entrySet().stream() 117 | .filter(e -> e.getValue().equals(curMonth)) 118 | .map(Entry::getKey) 119 | .findFirst().orElseGet(monthNames.keySet().iterator()::next); 120 | getMonthSelector().setValue(currentMonth); 121 | 122 | getYearSelector().setValue(Calendar.getInstance().get(Calendar.YEAR)); 123 | } 124 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/control/IncomeExpensesAnalysisControl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* 20 | * Partially copied from Hibiscus/Syntax, (c) by willuhn.webdesign 21 | */ 22 | package de.janrieke.contractmanager.gui.control; 23 | 24 | import java.util.ArrayList; 25 | import java.util.Calendar; 26 | import java.util.List; 27 | import java.util.Locale; 28 | import java.util.Map; 29 | import java.util.Map.Entry; 30 | 31 | import de.janrieke.contractmanager.gui.input.CheckboxInput; 32 | import de.janrieke.contractmanager.gui.parts.IncomeExpensesAnalysisChartPart; 33 | import de.willuhn.jameica.gui.AbstractControl; 34 | import de.willuhn.jameica.gui.AbstractView; 35 | import de.willuhn.jameica.gui.Part; 36 | import de.willuhn.jameica.gui.input.SelectInput; 37 | import de.willuhn.jameica.gui.input.SpinnerInput; 38 | 39 | /** 40 | * Controller fuer den Dialog Lizenzinformationen. 41 | */ 42 | public class IncomeExpensesAnalysisControl extends AbstractControl { 43 | 44 | Map monthNames; 45 | /** 46 | * ct. 47 | * 48 | * @param view 49 | */ 50 | public IncomeExpensesAnalysisControl(AbstractView view) { 51 | super(view); 52 | Calendar cal = Calendar.getInstance(); 53 | monthNames = cal.getDisplayNames(Calendar.MONTH, Calendar.LONG, Locale.getDefault()); 54 | } 55 | 56 | public int getMonthNumber (String name) { 57 | return monthNames.get(name); 58 | } 59 | 60 | private IncomeExpensesAnalysisChartPart chart = null; 61 | private SelectInput monthSelector; 62 | private SpinnerInput yearSelector; 63 | private CheckboxInput usePayDayCheckbox; 64 | 65 | public Part getChartPart() { 66 | if (chart == null) { 67 | chart = new IncomeExpensesAnalysisChartPart(this); 68 | } 69 | return chart; 70 | } 71 | 72 | public void redrawChart() { 73 | if (chart == null) { 74 | getChartPart(); 75 | } 76 | chart.redraw(); 77 | } 78 | 79 | public SelectInput getMonthSelector() { 80 | if (monthSelector == null) { 81 | int curMonth = Calendar.getInstance().get(Calendar.MONTH); 82 | String curMonthName = null; 83 | List list = new ArrayList<>(); 84 | for (int i = 0; i<12; i++) { 85 | outer: 86 | for (Map.Entry entry : monthNames.entrySet()) { 87 | if (entry.getValue().equals(i)) { 88 | if (curMonth == i) { 89 | curMonthName = entry.getKey(); 90 | } 91 | list.add(entry.getKey()); 92 | continue outer; 93 | } 94 | } 95 | } 96 | monthSelector = new SelectInput(list, curMonthName); 97 | } 98 | return monthSelector; 99 | } 100 | 101 | public void resetToCurrentMonth() { 102 | int curMonth = Calendar.getInstance().get(Calendar.MONTH); 103 | String currentMonth = monthNames.entrySet().stream() 104 | .filter(e -> e.getValue().equals(curMonth)) 105 | .map(Entry::getKey) 106 | .findFirst().orElseGet(monthNames.keySet().iterator()::next); 107 | getMonthSelector().setValue(currentMonth); 108 | 109 | getYearSelector().setValue(Calendar.getInstance().get(Calendar.YEAR)); 110 | } 111 | 112 | public SpinnerInput getYearSelector() { 113 | if (yearSelector == null) { 114 | yearSelector = new SpinnerInput(1900, 3000, Calendar.getInstance().get(Calendar.YEAR)); 115 | } 116 | return yearSelector; 117 | } 118 | 119 | public CheckboxInput getPayDayCheckbox() { 120 | if (usePayDayCheckbox == null) { 121 | usePayDayCheckbox = new CheckboxInput(true); 122 | } 123 | return usePayDayCheckbox; 124 | } 125 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/dialog/DebugDialog.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2014 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | /* 19 | * Copy from Hibiscus 20 | * Copyright (c) by willuhn software & services 21 | * All rights reserved 22 | */ 23 | 24 | package de.janrieke.contractmanager.gui.dialog; 25 | 26 | import org.eclipse.swt.widgets.Composite; 27 | 28 | import de.janrieke.contractmanager.ContractManagerPlugin; 29 | import de.janrieke.contractmanager.rmi.ContractDBService; 30 | import de.willuhn.jameica.gui.Action; 31 | import de.willuhn.jameica.gui.dialogs.AbstractDialog; 32 | import de.willuhn.jameica.gui.input.TextAreaInput; 33 | import de.willuhn.jameica.gui.parts.ButtonArea; 34 | import de.willuhn.jameica.gui.util.Container; 35 | import de.willuhn.jameica.gui.util.SimpleContainer; 36 | import de.willuhn.jameica.system.Application; 37 | import de.willuhn.util.ApplicationException; 38 | import de.willuhn.util.I18N; 39 | 40 | /** 41 | * Ein Dialog, der Debug-Informationen - unter anderem ueber die Datenbank 42 | * anzeigt. 43 | */ 44 | public class DebugDialog extends AbstractDialog { 45 | private final static int WINDOW_WIDTH = 550; 46 | private final static int WINDOW_HEIGHT = 200; 47 | private final static I18N i18n = Application.getPluginLoader() 48 | .getPlugin(ContractManagerPlugin.class).getResources().getI18N(); 49 | 50 | /** 51 | * ct 52 | * 53 | * @param position 54 | */ 55 | public DebugDialog(int position) { 56 | super(position); 57 | this.setTitle(i18n.tr("Database Information")); 58 | setSize(WINDOW_WIDTH, WINDOW_HEIGHT); 59 | } 60 | 61 | /** 62 | * @see de.willuhn.jameica.gui.dialogs.AbstractDialog#getData() 63 | */ 64 | protected Object getData() throws Exception { 65 | return null; 66 | } 67 | 68 | /** 69 | * @see de.willuhn.jameica.gui.dialogs.AbstractDialog#paint(org.eclipse.swt.widgets.Composite) 70 | */ 71 | protected void paint(Composite parent) throws Exception { 72 | ContractDBService service = (ContractDBService) Application 73 | .getServiceFactory().lookup(ContractManagerPlugin.class, 74 | "contract_db"); 75 | de.janrieke.contractmanager.rmi.DBSupport driver = service.getDriver(); 76 | 77 | StringBuffer sb = new StringBuffer(); 78 | sb.append(i18n.tr("JDBC Driver: {0}\n", driver.getJdbcDriver())); 79 | sb.append(i18n.tr("JDBC URL: {0}\n", driver.getJdbcUrl())); 80 | sb.append(i18n.tr("JDBC Username: {0}\n", driver.getJdbcUsername())); 81 | sb.append(i18n.tr("JDBC Password: {0}\n", driver.getJdbcPassword())); 82 | 83 | Container container = new SimpleContainer(parent); 84 | container.addHeadline(i18n.tr("Database Settings")); 85 | TextAreaInput text = new TextAreaInput(sb.toString()); 86 | text.setHeight(90); 87 | container.addPart(text); 88 | 89 | ButtonArea buttons = new ButtonArea(); 90 | buttons.addButton(i18n.tr("Close"), new Action() { 91 | public void handleAction(Object context) 92 | throws ApplicationException { 93 | close(); 94 | } 95 | }, null, true, "window-close.png"); 96 | container.addButtonArea(buttons); 97 | 98 | getShell().setMinimumSize( 99 | getShell().computeSize(WINDOW_WIDTH, WINDOW_HEIGHT)); 100 | } 101 | 102 | } 103 | 104 | /********************************************************************* 105 | * $Log: DebugDialog.java,v $ Revision 1.2 2011/03/30 08:19:37 willuhn 106 | * 107 | * @C Code-Cleanup 108 | * 109 | * Revision 1.1 2008/05/06 10:10:56 willuhn 110 | * @N Diagnose-Dialog, mit dem man die JDBC-Verbindungsdaten (u.a. auch das 111 | * JDBC-Passwort) ausgeben kann 112 | * 113 | **********************************************************************/ 114 | -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/rmi/DBSupport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2011 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | /********************************************************************** 19 | * Kopie aus Hibiscus 20 | * 21 | * $Source: /cvsroot/hibiscus/hibiscus/src/de/willuhn/jameica/hbci/rmi/DBSupport.java,v $ 22 | * $Revision: 1.9 $ 23 | * $Date: 2010-11-02 12:02:20 $ 24 | * $Author: willuhn $ 25 | * $Locker: $ 26 | * $State: Exp $ 27 | * 28 | * Copyright (c) by willuhn software & services 29 | * All rights reserved 30 | * 31 | **********************************************************************/ 32 | 33 | package de.janrieke.contractmanager.rmi; 34 | 35 | import java.io.File; 36 | import java.io.Serializable; 37 | import java.rmi.RemoteException; 38 | import java.sql.Connection; 39 | 40 | /** 41 | * Interface fuer eine unterstuetzte Datenbank. 42 | * Fuer den Suppoert einer neuen Datenbank (z.Bsp. MySQL) 43 | * in Hibiscus muss dieses Interface implementiert werden. 44 | */ 45 | public interface DBSupport extends Serializable 46 | { 47 | /** 48 | * Liefert die JDBC-URL. 49 | * @return die JDBC-URL. 50 | */ 51 | public String getJdbcUrl(); 52 | 53 | /** 54 | * Liefert den Klassennamen des JDBC-Treibers. 55 | * @return der JDBC-Treiber. 56 | */ 57 | public String getJdbcDriver(); 58 | 59 | /** 60 | * Liefert den Usernamen des Datenbank-Users. 61 | * @return Username. 62 | */ 63 | public String getJdbcUsername(); 64 | 65 | /** 66 | * Liefert das Passwort des Datenbank-Users. 67 | * @return das Passwort. 68 | */ 69 | public String getJdbcPassword(); 70 | 71 | /** 72 | * Prueft die Datenbankverbindung. 73 | * @param conn die Datenbank-Connection. 74 | * @throws RemoteException Wenn die Verbindung defekt ist und vom DB-Service neu erzeugt werden muss. 75 | */ 76 | public void checkConnection(Connection conn) throws RemoteException; 77 | 78 | /** 79 | * Richtet ggf. die Datenbank ein. 80 | * @throws RemoteException 81 | */ 82 | public void install() throws RemoteException; 83 | 84 | /** 85 | * Fuehrt ein SQL-Update-Script auf der Datenbank aus. 86 | * @param conn die Datenbank-Connection. 87 | * @param sqlScript das SQL-Script. 88 | * @throws RemoteException 89 | */ 90 | public void execute(Connection conn, File sqlScript) throws RemoteException; 91 | 92 | /** 93 | * Liefert einen Dateinamens-Prefix, der SQL-Scripts vorangestellt werden soll. 94 | * @return Dateinamens-Prefix. 95 | * @throws RemoteException 96 | */ 97 | public String getScriptPrefix() throws RemoteException; 98 | 99 | /** 100 | * Liefert den Namen der SQL-Funktion, mit der die Datenbank aus einem DATE-Feld einen UNIX-Timestamp macht. 101 | * Bei MySQL ist das z.Bsp. "UNIX_TIMESTAMP". 102 | * @param content der Feld-Name. 103 | * @return Name der SQL-Funktion samt Parameter. Also zum Beispiel "TONUMBER(datum)". 104 | * @throws RemoteException 105 | */ 106 | public String getSQLTimestamp(String content) throws RemoteException; 107 | 108 | /** 109 | * Legt fest, ob SQL-Insert-Queries mit oder ohne ID erzeugt werden sollen. 110 | * @return true, wenn die Insert-Queries mit ID erzeugt werden. 111 | * @throws RemoteException 112 | * Siehe auch: de.willuhn.datasource.db.DBServiceImpl#getInsertWithID() 113 | */ 114 | public boolean getInsertWithID() throws RemoteException; 115 | 116 | /** 117 | * Liefert das Transaction-Isolation-Level. 118 | * @return das Transaction-Isolation-Level. 119 | * @throws RemoteException 120 | */ 121 | public int getTransactionIsolationLevel() throws RemoteException; 122 | 123 | } -------------------------------------------------------------------------------- /contractmanager/src/main/java/de/janrieke/contractmanager/gui/dialog/AboutDialog.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ContractManager for Jameica. 3 | * Copyright (C) 2010-2018 Jan Rieke 4 | * 5 | * ContractManager is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ContractManager is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package de.janrieke.contractmanager.gui.dialog; 19 | 20 | import org.eclipse.swt.widgets.Composite; 21 | 22 | import de.janrieke.contractmanager.ContractManagerPlugin; 23 | import de.janrieke.contractmanager.Settings; 24 | import de.willuhn.jameica.gui.dialogs.AbstractDialog; 25 | import de.willuhn.jameica.gui.input.LabelInput; 26 | import de.willuhn.jameica.gui.parts.ButtonArea; 27 | import de.willuhn.jameica.gui.parts.FormTextPart; 28 | import de.willuhn.jameica.gui.util.LabelGroup; 29 | import de.willuhn.jameica.messaging.StatusBarMessage; 30 | import de.willuhn.jameica.plugin.AbstractPlugin; 31 | import de.willuhn.jameica.plugin.Manifest; 32 | import de.willuhn.jameica.system.Application; 33 | import de.willuhn.jameica.system.OperationCanceledException; 34 | import de.willuhn.logging.Logger; 35 | 36 | /** 37 | * Our "About..." dialog. 38 | */ 39 | public class AboutDialog extends AbstractDialog { 40 | 41 | int WINDOW_WIDTH = 550; 42 | int WINDOW_HEIGHT = 350; 43 | 44 | /** 45 | * ct. 46 | * 47 | * @param position 48 | */ 49 | public AboutDialog(int position) { 50 | super(position); 51 | this.setTitle(Settings.i18n().tr("About...")); 52 | setSize(WINDOW_WIDTH, WINDOW_HEIGHT); 53 | } 54 | 55 | /** 56 | * @see de.willuhn.jameica.gui.dialogs.AbstractDialog#paint(org.eclipse.swt.widgets.Composite) 57 | */ 58 | @Override 59 | protected void paint(Composite parent) throws Exception { 60 | Manifest manifest = Application.getPluginLoader().getManifest(ContractManagerPlugin.class); 61 | 62 | FormTextPart text = new FormTextPart(); 63 | text.setText("
" + "

" + manifest.getDescription() + "

" 64 | + "
Licence: GPL 3.0 (http://www.gnu.org/licenses/gpl-3.0.txt)" 65 | + "

Copyright by Jan Rieke [it@janrieke.de] 2010-2019

" + "

" 66 | + manifest.getHomepage() + "

" 67 | + "

Contains code from Jameica, Jameica Example Plugin, Hibiscus, and Syntax; copyright by Olaf Willuhn [info@jameica.org], GPL

" 68 | + "

http://www.jameica.org

" + "
"); 69 | 70 | text.paint(parent); 71 | 72 | LabelGroup group = new LabelGroup(parent, " Information "); 73 | 74 | AbstractPlugin p = Application.getPluginLoader().getPlugin(ContractManagerPlugin.class); 75 | 76 | group.addLabelPair(Settings.i18n().tr("Version"), 77 | new LabelInput("" + manifest.getVersion())); 78 | group.addLabelPair(Settings.i18n().tr("Working directory"), 79 | new LabelInput("" + p.getResources().getWorkPath())); 80 | 81 | ButtonArea buttons = new ButtonArea(); 82 | buttons.addButton(Settings.i18n().tr("Database Information"), context -> { 83 | try { 84 | new DebugDialog(DebugDialog.POSITION_CENTER).open(); 85 | } catch (OperationCanceledException oce) { 86 | Logger.info(oce.getMessage()); 87 | return; 88 | } catch (Exception e) { 89 | Logger.error("unable to display debug dialog", e); 90 | Application.getMessagingFactory() 91 | .sendMessage(new StatusBarMessage( 92 | Settings.i18n().tr("Error while showing database information"), 93 | StatusBarMessage.TYPE_ERROR)); 94 | } 95 | }, null, false, "dialog-information.png"); 96 | buttons.addButton(Settings.i18n().tr("Close"), context -> close(), null, true, 97 | "window-close.png"); 98 | group.addButtonArea(buttons); 99 | } 100 | 101 | /** 102 | * @see de.willuhn.jameica.gui.dialogs.AbstractDialog#getData() 103 | */ 104 | @Override 105 | protected Object getData() throws Exception { 106 | return null; 107 | } 108 | 109 | @Override 110 | protected void onEscape() { 111 | // Avoid exception on ESC 112 | close(); 113 | } 114 | } 115 | --------------------------------------------------------------------------------