forked from jverein/jverein
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Import und Export von Formularen (#555)
* Import und Export von Formularen * Dokulink * Import von Menue zu Button verschoben. Vereinsdaten in Allgemeine Map
- Loading branch information
Showing
10 changed files
with
519 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/de/jost_net/JVerein/gui/action/FormularExportAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/********************************************************************** | ||
* Copyright (c) by Heiner Jostkleigrewe | ||
* This program is free software: you can redistribute it and/or modify it under the terms of the | ||
* GNU General Public License as published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without | ||
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See | ||
* the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with this program. If not, | ||
* see <http://www.gnu.org/licenses/>. | ||
* | ||
* [email protected] | ||
* www.jverein.de | ||
**********************************************************************/ | ||
package de.jost_net.JVerein.gui.action; | ||
|
||
import de.jost_net.JVerein.gui.dialogs.ExportDialog; | ||
import de.jost_net.JVerein.gui.view.DokumentationUtil; | ||
import de.jost_net.JVerein.rmi.Formular; | ||
import de.willuhn.jameica.gui.Action; | ||
import de.willuhn.jameica.gui.GUI; | ||
import de.willuhn.jameica.system.OperationCanceledException; | ||
import de.willuhn.logging.Logger; | ||
import de.willuhn.util.ApplicationException; | ||
|
||
public class FormularExportAction implements Action | ||
{ | ||
|
||
/** | ||
* @see de.willuhn.jameica.gui.Action#handleAction(java.lang.Object) | ||
*/ | ||
@Override | ||
public void handleAction(Object context) throws ApplicationException | ||
{ | ||
try | ||
{ | ||
ExportDialog d = new ExportDialog(new Object[] { context }, | ||
Formular.class, DokumentationUtil.FORMULARE); | ||
d.open(); | ||
} | ||
catch (OperationCanceledException oce) | ||
{ | ||
Logger.info(oce.getMessage()); | ||
return; | ||
} | ||
catch (ApplicationException ae) | ||
{ | ||
throw ae; | ||
} | ||
catch (Exception e) | ||
{ | ||
Logger.error("Fehler", e); | ||
GUI.getStatusBar() | ||
.setErrorText("Fehler beim exportieren des Formulars"); | ||
} | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
src/de/jost_net/JVerein/gui/action/FormularImportAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/********************************************************************** | ||
* Copyright (c) by Heiner Jostkleigrewe | ||
* This program is free software: you can redistribute it and/or modify it under the terms of the | ||
* GNU General Public License as published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without | ||
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See | ||
* the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with this program. If not, | ||
* see <http://www.gnu.org/licenses/>. | ||
* | ||
* [email protected] | ||
* www.jverein.de | ||
**********************************************************************/ | ||
package de.jost_net.JVerein.gui.action; | ||
|
||
import de.jost_net.JVerein.gui.dialogs.ImportDialog; | ||
import de.jost_net.JVerein.gui.view.DokumentationUtil; | ||
import de.jost_net.JVerein.rmi.Formular; | ||
import de.willuhn.datasource.GenericObject; | ||
import de.willuhn.jameica.gui.Action; | ||
import de.willuhn.jameica.gui.GUI; | ||
import de.willuhn.jameica.system.OperationCanceledException; | ||
import de.willuhn.logging.Logger; | ||
import de.willuhn.util.ApplicationException; | ||
|
||
public class FormularImportAction implements Action | ||
{ | ||
|
||
/** | ||
* @see de.willuhn.jameica.gui.Action#handleAction(java.lang.Object) | ||
*/ | ||
@Override | ||
public void handleAction(Object context) throws ApplicationException | ||
{ | ||
try | ||
{ | ||
ImportDialog d = new ImportDialog((GenericObject) context, | ||
Formular.class, true, DokumentationUtil.FORMULARE); | ||
d.open(); | ||
} | ||
catch (OperationCanceledException oce) | ||
{ | ||
Logger.info(oce.getMessage()); | ||
return; | ||
} | ||
catch (ApplicationException ae) | ||
{ | ||
throw ae; | ||
} | ||
catch (Exception e) | ||
{ | ||
Logger.error("Fehler", e); | ||
GUI.getStatusBar().setErrorText("Fehler beim importieren des Formulars"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/********************************************************************** | ||
* Copyright (c) by Heiner Jostkleigrewe | ||
* This program is free software: you can redistribute it and/or modify it under the terms of the | ||
* GNU General Public License as published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without | ||
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See | ||
* the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with this program. If not, | ||
* see <http://www.gnu.org/licenses/>. | ||
* | ||
* [email protected] | ||
* www.jverein.de | ||
**********************************************************************/ | ||
|
||
package de.jost_net.JVerein.io; | ||
|
||
|
||
import java.io.BufferedOutputStream; | ||
import java.io.File; | ||
import java.io.FileNotFoundException; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import java.rmi.RemoteException; | ||
|
||
import com.itextpdf.text.DocumentException; | ||
|
||
import de.jost_net.JVerein.Einstellungen; | ||
import de.jost_net.JVerein.rmi.Formular; | ||
import de.jost_net.JVerein.rmi.Formularfeld; | ||
import de.willuhn.datasource.rmi.DBIterator; | ||
import de.willuhn.datasource.rmi.DBObject; | ||
import de.willuhn.datasource.serialize.XmlWriter; | ||
import de.willuhn.util.ApplicationException; | ||
import de.willuhn.util.ProgressMonitor; | ||
|
||
public class FormularExporterXML implements Exporter | ||
{ | ||
@Override | ||
public String getName() | ||
{ | ||
return "Formular XML-Export"; | ||
} | ||
|
||
@Override | ||
public IOFormat[] getIOFormats(Class<?> objectType) | ||
{ | ||
if (objectType != Formular.class) | ||
{ | ||
return null; | ||
} | ||
IOFormat f = new IOFormat() | ||
{ | ||
|
||
@Override | ||
public String getName() | ||
{ | ||
return FormularExporterXML.this.getName(); | ||
} | ||
|
||
/** | ||
* @see de.willuhn.jameica.hbci.io.IOFormat#getFileExtensions() | ||
*/ | ||
@Override | ||
public String[] getFileExtensions() | ||
{ | ||
return new String[] { "*.xml" }; | ||
} | ||
}; | ||
return new IOFormat[] { f }; | ||
} | ||
|
||
@Override | ||
public String getDateiname() | ||
{ | ||
return "formular"; | ||
} | ||
|
||
@Override | ||
public void doExport(Object[] objects, IOFormat format, File file, | ||
ProgressMonitor monitor) throws RemoteException, ApplicationException, | ||
FileNotFoundException, DocumentException, IOException | ||
{ | ||
XmlWriter writer = new XmlWriter( | ||
new BufferedOutputStream(new FileOutputStream(file))); | ||
|
||
int count = 1; | ||
if (objects[0] instanceof DBObject[]) | ||
{ | ||
objects = (Object[]) objects[0]; | ||
} | ||
for (Object o : objects) | ||
{ | ||
DBObject dbObject = (DBObject) o; | ||
writer.write(dbObject); | ||
|
||
DBIterator<Formularfeld> formularfeldIt = Einstellungen.getDBService() | ||
.createList(Formularfeld.class); | ||
formularfeldIt.addFilter("formular = ?", dbObject.getID()); | ||
while (formularfeldIt.hasNext()) | ||
{ | ||
writer.write(formularfeldIt.next()); | ||
} | ||
monitor.setPercentComplete(count * 100 / objects.length); | ||
} | ||
|
||
writer.close(); | ||
} | ||
|
||
} |
Oops, something went wrong.