SuperX-Kernmodul
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

2440 lines
89 KiB

package de.superx.applet;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.Calendar;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.TimeZone;
import java.util.Vector;
import javax.help.CSH;
import javax.help.HelpBroker;
import javax.help.HelpSet;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JEditorPane;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRootPane;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.JToolBar;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import de.memtext.util.ClipboardUtils;
import de.memtext.util.DateUtils;
import de.memtext.util.WindowUtils;
import de.memtext.widgets.HorizontalBox;
import de.memtext.widgets.VerticalBox;
import de.memtext.widgets.WarningMessage;
import de.superx.common.DBServletException;
import de.superx.common.FieldContainer;
import de.superx.common.Sichten;
import de.superx.common.Sichtgruppe;
import de.superx.common.SxResultRow;
import de.superx.common.SxUser;
/**
* SuperX-Hauptmaske, mit dem Buttons für Anmelden, Kopieren, Drucken etc und
* den Registerkarten Themenauswahl, Maske und Ergebnistabelle.
*
* @version 2.0 01-01-02
* @author Rainer Behr, erweitert von Marlies Winterstein, Meikel Bisping
*/
public class SxMask extends JPanel implements ComponentListener {
private static final long serialVersionUID = 1L;
private static final Font SMALL_BOLD_FONT = new Font("SansSerif",
Font.BOLD, 10);
private static final Font NORMAL_BOLD_FONT = new Font("SansSerif",
Font.BOLD, 12);
private static final Font NORMAL_FONT = new Font("SansSerif", Font.PLAIN,
12);
private static final Font SMALL_FONT = new Font("SansSerif", Font.PLAIN, 10);
private SxUser user = new SxUser("default"); //kein Mandantenbetrieb für Applet
private static boolean isApplet = false;
private static boolean isLogin = false;
private boolean helpsetfound = false;
private static int countFrame = 0;
private boolean dummyLogin = false;
private JFrame sxFrame;
private SxMask sxMask; // r.b. 'this'
private SxLogoPanel logo;
private Hashtable sx_map = null;
private Thread activeThread = null;
private boolean isInterrupted = false;
private JTabbedPane tabPane;
private ConnectionDlg connectionDlg;
//Um Erläuterungen zu Masken anzuzeigen
private ExplanationFrame explanationFrame = new ExplanationFrame();
private JButton btnExplanation = new JButton("Erläuterung");
private MaskeninfoElement selectedMaskeninfoElement = new MaskeninfoElement();
private String sxTitle, serverURL, logToKonsole;
private ParameterPanel parameterPanel = new ParameterPanel();
// private Vector V_sachgeb = new Vector();
private Vector V_thema = new Vector(100);
private SxTablePanel sxTablePanel = null;
private Integer lastMaskeID = new Integer(-1);
private JButton dbBtn, openBtn, searchBtn, resetBtn, stopBtn,
themenAuswahlBtn;
private JButton cloneBtn, copyBtn, saveBtn, printBtn, infoBtn, passwdBtn;
private JScrollPane themenwahlscroll;
private JTree themenwahltree;
private GridBagConstraints gbctree = new GridBagConstraints();
private GridBagLayout gbl = new GridBagLayout();
JEditorPane terlaeuterung = new JEditorPane("text/html", "");
private JButton suchAbfrBtn, themenStandBtn, helpBtn;
private SxThemenbaum sxThemenbaum;
private JLabel themenStandLabel, aktuelleNachrichtL;
private SxForm maskeForm;
private JPanel sxSpanel;
private JTextField statusField;
private HelpSet hs;
private HelpBroker hb;
//String helpItemString = "tut.starttoc";
private String helpItemString = "SuperXAnleitung.htm";
class CloneListener implements ActionListener, Runnable {
CloneListener clone_th;
CloneListener() {
};
public void actionPerformed(ActionEvent e) {
if (isLogin == false)
return;
clone_th = new CloneListener();
new Thread(clone_th).start();
}
public void run() {
SxMask cloneM = new SxMask("SuperX", sx_map, isApplet);
cloneM.setUser(user);
}
}
class OpenListener implements ActionListener, Runnable {
OpenListener open_th;
OpenListener() {
};
public void actionPerformed(ActionEvent e) {
//Wint Hilfe entsprechend setzen
if (selectedMaskeninfoElement.getTid() != null) {
helpItemString = "M" + selectedMaskeninfoElement.getTid()
+ ".htm";
//System.out.println("helpItemString: " + helpItemString);
}
//helpItemString = "build.build";
//CSH.setHelpIDString(openBtn,helpItemString);
if (helpsetfound) {
CSH.setHelpIDString(helpBtn, helpItemString);
hb.enableHelpKey(getRootPane(), helpItemString, hs);
}
open_th = new OpenListener();
activeThread = new Thread(open_th);
activeThread.start();
}
public void run() {
// System.err.println ("OpenListener: " + openBtn.getActionCommand
// ());
if (selectedMaskeninfoElement.getTid() == null) {
getToolkit().beep();
statusField.setText("Bitte ein Thema auswählen !");
return;
}
maskeOeffnen();
activeThread = null;
}
}
class ConnectListener implements ActionListener, Runnable {
private ConnectListener connect_th;
private int mode;
ConnectListener(int mode) {
this.mode = mode;
}
public void actionPerformed(ActionEvent e) {
dbBtn.setEnabled(false);
int rc = -1;
if (isLogin && countFrame > 1)
rc = 0;
else
rc = showConnectionDialog();
if (rc < 0 || rc == 2) {
dbBtn.setEnabled(true);
return;
}
DefaultTreeModel model =(DefaultTreeModel) themenwahltree.getModel();
DefaultMutableTreeNode root=(DefaultMutableTreeNode) themenwahltree.getModel().getRoot();
root.removeAllChildren();
model.reload(root);
connect_th = new ConnectListener(rc);
activeThread = new Thread(connect_th);
activeThread.start();
}
public void run() {
//ist ja An/Ummeldung daher
SuperX.isAuthentificationFound = false;
initUser(mode);
}
}
class SearchListener implements ActionListener, Runnable {
SearchListener search_th;
SearchListener() {
};
public void actionPerformed(ActionEvent e) {
//Wint Hilfe entsprechend setzen
if (selectedMaskeninfoElement.getTid() != null) {
helpItemString = "T" + selectedMaskeninfoElement.getTid()
+ ".htm";
//System.out.println("helpItemString: " + helpItemString);
}
//helpItemString = "debug.overview";
if (helpsetfound) {
CSH.setHelpIDString(helpBtn, helpItemString);
hb.enableHelpKey(getRootPane(), helpItemString, hs);
}
search_th = new SearchListener();
activeThread = new Thread(search_th);
activeThread.start();
}
public void run() {
try {
logo.start();
isInterrupted = false;
searchBtn.setEnabled(false);
resetBtn.setEnabled(false);
Integer fixedColumns = new Integer(selectedMaskeninfoElement
.getXilProps().getProperty("fixed_columns", "1"));
sxTablePanel.setFixedColumns(fixedColumns.intValue());
String hinweis = selectedMaskeninfoElement.getHinweis();
if (hinweis != null) {
if (hinweis.startsWith("<<SQL>>")) {
hinweis = hinweis.substring(7, hinweis.length());
try {
//in Generate-sql wird auch Stand von Sichtfeldern
// gesetzt
String sql = SxUtils
.generateSQL(maskeForm, hinweis);
SxSQL.executeQuery(sql);
SxResultRow r=(SxResultRow) SxSQL.getResult().first();
hinweis = (String) r.get(0);
} catch (Exception e) {
hinweis = null;
}
}
//System.out.println("setting Hinweis:"+Hinweis);
}
maskeForm.setHinweis(hinweis);
//throws an exception if something's wrong
maskeForm.checkFields();
// Generate SQL
boolean isTemplate = selectedMaskeninfoElement.getSelectStmt()
.toUpperCase().indexOf("FREEMARKER TEMPLATE") > -1;
String selectString = SxUtils.generateSQL(maskeForm,
selectedMaskeninfoElement.getSelectStmt() + "\n"
+ selectedMaskeninfoElement.getCleanupStmt());
if (isTemplate) {
//Trickmethode!!
HashMap map = maskeForm.getHashMap(selectedMaskeninfoElement.getTid());
selectString = SxSQL.templateProcessor.process("Maske "
+ selectedMaskeninfoElement.getName(),
selectString,
map, (String) SxDefaults.getPropertyValue("SxDB"));
}
statusField.setBackground(Color.yellow);
statusField.setText("Bitte warten ..");
// Default-Values
//Wint, vorübergehend zum Testen der Abfragen, Merken der Werte
// ausschalten
//Gedächtnis!
maskeForm.rememberSelectionsAsDefaults();
// Parameterliste setzen
parameterPanel.setParams(maskeForm.getParamList(user.getName(),
true));
parameterPanel.setStand(selectedMaskeninfoElement
.getStandString());
parameterPanel.setAbfragename(selectedMaskeninfoElement
.getName());
//JLabel F_parameter = (JLabel)
// tabelleForm.getComp("F_parameter");
//F_parameter.setText();
// Parameterliste
stopBtn.setEnabled(true);
SxSQL.executeAll("--Abfrage\n" + selectString);
if (SxSQL.getRowCount() == 0)
lastMaskeID = new Integer(-1);
if (!selectedMaskeninfoElement.isSqlInHeaders()
&& selectedMaskeninfoElement.getTid().equals(
lastMaskeID))
sxTablePanel.setData(SxSQL.getResultVector());
else {
Vector headerVector = selectedMaskeninfoElement
.getHeaderVector();
Vector resultVector = SxSQL.getResultVector();
SxSQLMetaData metaData = SxSQL.getResultSetMetaData();
if (selectedMaskeninfoElement.isSqlInHeaders())
runSqlInTableHeaders(headerVector);
sxTablePanel.setData(resultVector, headerVector,
selectedMaskeninfoElement.getWidthVector(),
//selectedMaskeninfoElement.getSpaltenExplanations(),
metaData);
}
if (SxSQL.getRowCount() > 0)
lastMaskeID = selectedMaskeninfoElement.getTid();
//if (cleanupString.length () > 0)
// SxSQL.execute (cleanupString);
//MB }
String nachr = SxSQL.getAktuelleNachricht();
if (nachr != null && !nachr.equals("")) {
//aktuelleNachrichtL.setText("<html><font
// color=red>"+nachr+"</font></html>");
//aktuelleNachrichtL.setBackground(java.awt.Color.orange);
statusField
.setText("Bei der Abfrage ist ein SQL-Fehler aufgetreten (siehe Java-Konsole)");
System.out.println("SQL-Fehler: " + nachr);
}
//MB vertikal Scrollbar nach oben
JScrollBar vsbar = sxTablePanel.getScrollPane()
.getVerticalScrollBar();
vsbar.setValue(vsbar.getMinimum());
tabPane.setSelectedIndex(2);
sxMask.repaint();
statusField.setBackground(Color.white);
if (nachr == null || nachr.length() < 1)
statusField.setText(sxTablePanel.getTable().getRowCount()
+ " Sätze gefunden");
} catch (SQLException ex) {
String msg = ex.toString();
// System.err.println("msg: " + msg);
ex.printStackTrace();
statusField.setText(msg.substring(msg.lastIndexOf(":") + 1));
ClipboardUtils.setContents(msg, null);
statusField.setBackground(Color.red);
try {
// Bei Fehler neue Verbindung --> temp. Tabellen werden
// geloescht
SxSQL.close();
ImageIcon disconnect_icon = (ImageIcon) sx_map
.get("disconnect");
dbBtn.setIcon(disconnect_icon);
dbBtn.setDisabledIcon(disconnect_icon);
if (countFrame == 1)
passwdBtn.setEnabled(false);
passwdBtn.setVisible(SuperX.remoteUser == null);
openBtn.setEnabled(false);
//TODO logging eintrag über Maskenaufruf
/*
* SxSQL.setUrl(serverURL); SxSQL.setLogMode(logToKonsole);
* SxSQL.check(user);
*/
lastMaskeID = new Integer(-1);
statusField.setBackground(Color.white);
//statusField.setText("DB-Verbindung erneuert");
ImageIcon connect_icon = (ImageIcon) sx_map.get("connect");
dbBtn.setIcon(connect_icon);
dbBtn.setDisabledIcon(connect_icon);
if (countFrame == 1)
passwdBtn.setEnabled(true);
passwdBtn.setVisible(SuperX.remoteUser == null);
openBtn.setEnabled(true);
} catch (Exception ex2) {
String msg2 = ex2.toString();
ex2.printStackTrace();
statusField.setText(msg2
.substring(msg2.lastIndexOf(":") + 1));
ClipboardUtils.setContents(msg2, null);
}
} catch (Exception ex_input) {
String msg = ex_input.toString();
ex_input.printStackTrace();
System.out.println(ex_input.toString());
JOptionPane.showMessageDialog(sxMask, msg.substring(msg
.lastIndexOf(":") + 1), "Eingabefehler",
JOptionPane.ERROR_MESSAGE);
ClipboardUtils.setContents(msg, null);
}
searchBtn.setEnabled(true);
resetBtn.setEnabled(true);
stopBtn.setEnabled(false);
logo.stop();
JRootPane root = sxMask.getRootPane();
root.setDefaultButton(searchBtn); // DefaultButton setzen
sxMask.repaint();
activeThread = null;
}
private void runSqlInTableHeaders(Vector headerVector) {
//selectedMaskeninfoElement.cloneExplanations();
for (int i = 0; i < headerVector.size(); i++) {
String aHeader = headerVector.get(i).toString();
String query;
if (aHeader.trim().startsWith("<<SQL>>")) {
try {
query = SxUtils.generateSQL(maskeForm, aHeader
.substring(7));
SxSQL.executeQuery(query);
Vector row0 = (Vector) SxSQL.getResultVector().get(0);
String newHeader = row0.get(0).toString();
headerVector.remove(i);
headerVector.add(i, newHeader);
selectedMaskeninfoElement.adaptExplanation(i,newHeader);
} catch (SQLException e) {
WarningMessage.show(sxMask,
"Spaltenüberschrift mit dem Ausdruck\n"
+ aHeader
+ "\nkonnte nicht aufgebaut werden",
"SuperX");
ClipboardUtils.setContents(e.toString(), null);
}
}
}
}
}
class StopListener implements ActionListener {
StopListener() {
};
public void actionPerformed(ActionEvent e) {
stopBtn.setEnabled(false);
try {
logo.start();
statusField.setBackground(Color.red);
statusField.setText("Abbrechen ..");
if (activeThread != null) {
activeThread.interrupt();
isInterrupted = true;
SxSQL.cancel(); // Methode not supplied by Informix JDBC
isInterrupted = true;
searchBtn.setEnabled(true);
}
} catch (Exception ex) {
String msg = ex.toString();
// System.err.println("msg: " + msg);
ex.printStackTrace();
statusField.setText(msg.substring(msg.lastIndexOf(":") + 1));
ClipboardUtils.setContents(msg, null);
}
stopBtn.setEnabled(true);
logo.stop();
}
}
class ResetListener implements ActionListener {
ResetListener() {
};
public void actionPerformed(ActionEvent e) {
resetBtn.setEnabled(false);
String fielddefault = new String();
String fieldname = new String();
for (int i = 0; i < selectedMaskeninfoElement.getFelderinfos()
.size(); i++) {
Vector V_field = (Vector) selectedMaskeninfoElement
.getFelderinfos().elementAt(i);
fieldname = (String) V_field.elementAt(1);
if (fieldname != null)
fieldname = fieldname.trim();
fielddefault = (String) V_field.elementAt(14);
if (fielddefault != null)
fielddefault = fielddefault.trim();
SxField field = maskeForm.getField("F_" + fieldname);
if (field!=null&&field.hasSichten())
field.clearSichtSelections();
// Default-Wert aus Tab. 'felderinfo' setzen
if (fielddefault != null) {
if (fielddefault.startsWith("<<SQL>>")) {
try {
String stmt = fielddefault.substring(7);
SxSQL.executeAll(stmt);
Vector V_default = (Vector) SxSQL.getResultVector()
.elementAt(0);
Object key, value;
if (V_default.size() == 2) {
key = V_default.elementAt(0);
field.setKey(key);
value = V_default.elementAt(1);
if (value instanceof java.sql.Date)
value = SxDate
.toString((java.sql.Date) value);
field.setText(value.toString());
}
if (V_default.size() == 1) {
field.setKey(new Integer("-1"));
value = V_default.elementAt(0);
if (value instanceof java.sql.Date)
value = SxDate
.toString((java.sql.Date) value);
field.setText(value.toString());
}
} catch (Exception ex) {
System.err.println(ex.toString());
ClipboardUtils.setContents(ex.toString(), null);
}
} else {
if (field != null)
{field.setText(fielddefault);
field.setKey(new Integer(-1));
}
}
}
}
maskeForm.rememberSelectionsAsDefaults();
resetBtn.setEnabled(true);
logo.stop();
}
}
class CopyListener implements ActionListener, Runnable {
CopyListener copy_th;
CopyListener() {
};
public void actionPerformed(ActionEvent e) {
copy_th = new CopyListener();
new Thread(copy_th).start();
}
public void run() {
if (sxTablePanel == null)
return;
StringBuffer data = new StringBuffer();
data.append(SxDefaults.getPropertyValue("SxTitle"));
data.append("\n\n");
data.append(selectedMaskeninfoElement.getName());
data.append("\n");
data.append(selectedMaskeninfoElement.getStand());
data.append("\n\nEingabeparameter:\n");
data.append(maskeForm.getParamList(user.getName(), false));
data.append("\n\n");
//Wint "\n" in Überschrift streichen
String s1 = SxUtils.replace(sxTablePanel.getText(), "\\n", "");
s1 = SxUtils.replace(s1, "\"", "'"); //wg. Problemen mit Excel
data.append(s1);
ClipboardUtils.setContents(data, null);
}
}
class SaveDlgListener implements ActionListener {
SaveDlgListener() {
};
public void actionPerformed(ActionEvent e) {
try {
JFileChooser file_dlg = new JFileChooser();
file_dlg.setDialogType(JFileChooser.SAVE_DIALOG);
SaveListener savel = new SaveListener(file_dlg);
file_dlg.addActionListener(savel);
file_dlg.showDialog(sxMask, "Sichern ..");
} catch (Exception ex) {
ClipboardUtils.setContents(ex.toString(), null);
JOptionPane.showMessageDialog(sxMask, ex.toString(), "Fehler",
JOptionPane.ERROR_MESSAGE);
}
}
}
class SaveListener implements ActionListener, Runnable {
SaveListener save_th;
JFileChooser file_dlg;
SaveListener(JFileChooser aFile_dlg) {
file_dlg = aFile_dlg;
};
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("CancelSelection"))
return;
save_th = new SaveListener(file_dlg);
new Thread(save_th).start();
}
public void run() {
File out_file = file_dlg.getSelectedFile();
//if (out_file != null)
// sxTablePanel.saveTable(out_file, sxMask);
}
}
class PrintListener implements ActionListener, Runnable {
PrintListener print_th;
PrintListener() {
};
public void actionPerformed(ActionEvent e) {
print_th = new PrintListener();
new Thread(print_th).start();
}
public void run() {
try {
printBtn.setEnabled(false);
sxTablePanel.printTable(sxMask);
} catch (Exception ex) {
String msg = ex.toString();
ClipboardUtils.setContents(msg, null);
statusField.setText(msg.substring(msg.lastIndexOf(":") + 1));
}
printBtn.setEnabled(true);
}
}
/*
* //Wint class HelpListener implements ActionListener, Runnable {
* HelpListener help_th;
*
* HelpListener(HelpBroker mainhb) { new CSH.DisplayHelpFromSource(mainhb); };
*
* public void actionPerformed(ActionEvent e) { help_th = new
* HelpListener(hb);
*
* new Thread(help_th).start(); }
*
* public void run() { try { helpBtn.setEnabled(false);
* //helpBtn.addActionListener(new CSH.DisplayHelpFromSource(hb)); String
* p_maske = SxMask.this.getName(); if (activeMaskeID != null)
* System.out.println("ID: " + activeMaskeID.toString().toString());
* System.out.println(p_maske); CSH.setHelpIDString(getRootPane(),
* "edit.editsource"); //helpBtn.addActionListener(new
* CSH.DisplayHelpAfterTracking(hb)); helpBtn.addActionListener(new
* CSH.DisplayHelpFromSource(hb)); } catch (Exception ex) { String msg =
* ex.toString(); statusField.setText(msg.substring(msg.lastIndexOf(":") +
* 1)); }
*
* helpBtn.setEnabled(true); } }
*/
class PwdListener implements ActionListener {
JFrame frame;
PwdListener(JFrame frame) {
this.frame = frame;
};
public void actionPerformed(ActionEvent e) {
int rc = -1;
//Hilfe für Paßwortänderung
if (helpsetfound) {
helpItemString = "Anmelden.htm";
CSH.setHelpIDString(passwdBtn, helpItemString);
hb.enableHelpKey(passwdBtn, helpItemString, hs);
hb.enableHelp(passwdBtn, helpItemString, hs);
//CSH.setHelpIDString(helpBtn,helpItemString);
}
SxPasswdChangeDlg passwdChangeDlg = new SxPasswdChangeDlg(frame, "Passwort ändern");
passwdChangeDlg.setNewPasswordChecker(SxSQL.newPasswordChecker);
// if (SxSQL.isAdmin()) {
// passwdChangeDlg.setUsernameFieldEnabled(true);
// passwdChangeDlg.setCheckOldPasswdWanted(false);
// } else {
passwdChangeDlg.setUsername(user.getName());
passwdChangeDlg.setUsernameFieldEnabled(false);
passwdChangeDlg.setCheckOldPasswdWanted(true);
// }
passwdChangeDlg.show();
if (!passwdChangeDlg.wasOkSelected())
return;
try {
WindowUtils.setWaitCursor(statusField, true);
//admin könnte auch von anderen Usern dass Passwort
//ändern, darum wird nicht direkt user genommen,
//sondern userToBeChanged
SxUser userToBeChanged = null;
if (user.getName().equals(passwdChangeDlg.getUsername()))
userToBeChanged = user;
else
userToBeChanged = new SxUser("default",
passwdChangeDlg.getUsername(), passwdChangeDlg.getOldPasswd());
SxSQL.storePwd(userToBeChanged, passwdChangeDlg.getNewPasswd(),
true); //kein Mandantenbetrieb bei Applet
statusField.setBackground(Color.white);
statusField.setText("Kennwort geändert");
passwdChangeDlg.clear();
} catch (Exception ex) {
ex.printStackTrace();
String msg = ex.toString();
ClipboardUtils.setContents(msg, null);
msg = msg.substring(msg.lastIndexOf(":") + 1);
statusField.setBackground(Color.red);
statusField.setText(msg);
JOptionPane.showMessageDialog(sxMask, msg, "Fehler",
JOptionPane.ERROR_MESSAGE);
statusField.setBackground(Color.white);
statusField.setText("");
}
finally
{
WindowUtils.setWaitCursor(statusField, false);
}
}
}
class SuchAbfrListener implements ActionListener, Runnable {
SuchAbfrListener SuchAbfr_th;
JTree tree;
SuchAbfrListener(JTree ltree) {
tree = ltree;
};
public void actionPerformed(ActionEvent e) {
SuchAbfr_th = new SuchAbfrListener(tree);
new Thread(SuchAbfr_th).start();
}
public void run() {
// AbfrageSuchen();
JTree tree = themenwahltree;
String such = JOptionPane.showInputDialog(null,
"Suche nach Abfragen:", "SuperX",
JOptionPane.QUESTION_MESSAGE);
if (such.length() < 1)
return;
such = such.toLowerCase();
String teststring;
TreePath tp;
boolean gefunden = false;
DefaultMutableTreeNode root, test, ausgesucht;
ausgesucht = null;
Vector treffer = new Vector();
Vector treffernodes = new Vector();
//alle Knoten durchlaufen
root = (DefaultMutableTreeNode) tree.getModel().getRoot();
Enumeration en = root.breadthFirstEnumeration();
while (en.hasMoreElements()) {
test = (DefaultMutableTreeNode) en.nextElement();
teststring = test.toString().toLowerCase();
if (teststring.indexOf(such) > -1) {
//wenn suchString im aktuellen Knoten vorhanden
//K
treffer.addElement(test.toString());
treffernodes.addElement(test);
}
}
if (treffer.size() > 0) {
if (treffer.size() > 1) {
//mehr als ein Treffer -> Auswahldialog
String[] trefferstring = new String[treffer.size()];
treffer.copyInto(trefferstring);
String selectedValue = (String) showBigChoiceDialog(null,
"Mehrere Treffer- bitte auswählen...", "SuperX",
JOptionPane.INFORMATION_MESSAGE, null,
trefferstring, trefferstring[0]);
if (selectedValue == null)
return;
gefunden = false;
//gewählten Knoten nach Name in Treffernodes-Vektor suchen
en = treffernodes.elements();
while (en.hasMoreElements() && gefunden == false) {
test = (DefaultMutableTreeNode) en.nextElement();
if (test.toString().equals(selectedValue)) {
ausgesucht = test;
gefunden = true;
}
}
}
if (ausgesucht == null) //bei treffer.size=1
ausgesucht = (DefaultMutableTreeNode) treffernodes
.elementAt(0);
// collapse all brances + Selection anwählen
tree.clearSelection();
en = root.depthFirstEnumeration();
while (en.hasMoreElements()) {
test = (DefaultMutableTreeNode) en.nextElement();
tp = new TreePath(test.getPath());
if (tree.isExpanded(tp))
tree.collapsePath(tp);
}
tp = new TreePath(ausgesucht.getPath());
tree.clearSelection();
tree.setSelectionPath(tp);
tree.scrollPathToVisible(tp);
// tree.makeVisible(tp);
//tree.validate();
//tree.repaint();
} else
JOptionPane.showMessageDialog(null, "Keine Treffer!", "SuperX",
1);
}
private Object showBigChoiceDialog(Component parentComponent,
Object message, String title, int messageType, Icon icon,
Object[] selectionValues, Object initialSelectionValue) {
JOptionPane pane = new JOptionPane(message, messageType,
JOptionPane.OK_CANCEL_OPTION, icon, null, null);
pane.setWantsInput(true);
pane.setSelectionValues(selectionValues);
pane.setInitialSelectionValue(initialSelectionValue);
JDialog dialog = pane.createDialog(parentComponent, title);
dialog.setSize(400, 200);
pane.selectInitialValue();
dialog.show();
Object value = pane.getInputValue();
if (value == JOptionPane.UNINITIALIZED_VALUE)
return null;
return value;
}
}
class ThemenStandListener implements ActionListener {
ThemenStandListener() {
};
public void actionPerformed(ActionEvent e) {
DateFormat df;
String neuerStand = JOptionPane.showInputDialog(null,
"Neues Datum eingeben:", "SuperX",
JOptionPane.QUESTION_MESSAGE);
df = DateFormat.getDateInstance(DateFormat.MEDIUM);
// r.b. default Jahr 4-stellig
df.setTimeZone(TimeZone.getDefault());
df.setLenient(false);
String geprueft = null;
try {
if (neuerStand.endsWith("00")) {
switch (neuerStand.charAt(neuerStand.length() - 3)) {
case '-':
case '.':
case '/':
neuerStand = neuerStand.substring(0, neuerStand
.length() - 2)
+ "2000";
break;
}
}
java.util.Date date = df.parse(neuerStand);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
int year = calendar.get(Calendar.YEAR);
if (year >= 0 && year < 30)
calendar.add(Calendar.YEAR, 2000);
if (year >= 30 && year < 100)
calendar.add(Calendar.YEAR, 1900);
java.sql.Date adate = new java.sql.Date(calendar.getTime()
.getTime());
//wenn Format nicht OK bleibt geprueft null
geprueft = df.format((java.util.Date) adate);
} catch (ParseException e_parse) {
// System.err.println ("SxDate: ERROR: parse: Date != " +
// value);
} catch (IllegalArgumentException e_arg) {
// System.err.println ("SxDate: ERROR: arg: Date != " + value);
}
if (geprueft != null) // Form Ok
{
sxMask.setCursor(new Cursor(Cursor.WAIT_CURSOR));
themenStandLabel.setText(neuerStand);
try {
installThemenbaum(neuerStand);
} catch (SQLException e1) {
ClipboardUtils.setContents(e1.toString(), null);
WarningMessage.show(sxMask, e1.toString(), "Fehler");
}
sxMask.validate();
sxMask.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
} else
JOptionPane.showMessageDialog(null, "Ungültige Eingabe!",
"SuperX", JOptionPane.ERROR_MESSAGE);
}
}
class ThemenwahlPanel extends JPanel {
ThemenwahlPanel() {
super(new BorderLayout());
JPanel centerp = new JPanel();
GridBagConstraints gbc = new GridBagConstraints();
centerp.setLayout(gbl);
themenStandLabel = new JLabel(DateUtils.getTodayString());
themenStandLabel.setFont(SMALL_FONT);
JLabel lerlaueterung = new JLabel("Erläuterung");
lerlaueterung.setBackground(java.awt.Color.orange);
JLabel platzhalterl = new JLabel(" ");
JLabel platzhalterr = new JLabel(" ");
themenStandBtn = new JButton("anderer Stand");
themenStandBtn.setFont(SMALL_FONT);
themenStandBtn.setToolTipText("Zugriff auf alte Abfragen");
ThemenStandListener tsl = new ThemenStandListener();
themenStandBtn.addActionListener(tsl);
gbc.gridx = 0;
gbc.gridy = 0;
gbc.gridwidth = 1;
gbc.gridheight = 1;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.insets = new Insets(10, 2, 2, 0);
gbc.fill = GridBagConstraints.NONE;
gbc.anchor = GridBagConstraints.CENTER;
gbl.setConstraints(platzhalterl, gbc);
centerp.add(platzhalterl);
JPanel pstand = new JPanel();
//Stand des Themenbaum erstmal nicht anzeigen
//pstand.add(ThemenStandLabel);
//pstand.add(ThemenStandBtn);
gbc.gridx = 1;
gbc.gridy = 0;
gbl.setConstraints(pstand, gbc);
centerp.add(pstand);
gbc.gridx = 2;
gbc.gridy = 0;
// gbl.setConstraints(ThemenStandBtn, gbc);
// centerp.add(ThemenStandBtn);
gbc.gridx = 2;
gbc.gridy = 0;
gbl.setConstraints(platzhalterr, gbc);
centerp.add(platzhalterr);
gbc.gridx = 5;
gbc.gridy = 0;
gbl.setConstraints(lerlaueterung, gbc);
centerp.add(lerlaueterung);
//Pseudo initial-Baum anzeigen
DefaultMutableTreeNode dummy = new DefaultMutableTreeNode(
"Abfragen");
dummy.add(new DefaultMutableTreeNode(""));
themenwahltree = new JTree(dummy);
TreePath tp = new TreePath(dummy.getPath());
themenwahltree.collapsePath(tp);
themenwahlscroll = new JScrollPane(themenwahltree);
themenwahlscroll
.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
gbctree.gridx = 0;
gbctree.gridy = 1;
gbctree.gridwidth = 4;
gbctree.gridheight = 4;
gbctree.insets = new Insets(0, 0, 0, 0);
gbctree.weightx = 100;
gbctree.weighty = 100;
gbctree.fill = GridBagConstraints.BOTH;
gbl.setConstraints(themenwahlscroll, gbctree);
centerp.add(themenwahlscroll);
terlaeuterung.setFont(NORMAL_FONT);
terlaeuterung.setEditable(false);
terlaeuterung.setAlignmentX(CENTER_ALIGNMENT);
JScrollPane erlScroll = new JScrollPane(terlaeuterung);
gbc.gridx = 4;
gbc.gridy = 1;
gbc.gridwidth = 2;
gbc.gridheight = 4;
gbc.weightx = 100;
gbc.weighty = 1000;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(0, 0, 0, 0);
gbl.setConstraints(erlScroll, gbc);
centerp.add(erlScroll);
gbc.gridx = 1;
gbc.gridy = 5;
gbc.gridwidth = 1;
gbc.gridheight = 1;
gbc.insets = new Insets(5, 0, 5, 0);
suchAbfrBtn = new JButton("Abfrage suchen");
suchAbfrBtn.setFont(SMALL_FONT);
suchAbfrBtn.setToolTipText("Suchen von Abfragen mittels Stichwort");
SuchAbfrListener sabl = new SuchAbfrListener(themenwahltree);
suchAbfrBtn.addActionListener(sabl);
//psuchAbfr.add(suchAbfrBtn);
gbc.gridx = 2;
gbc.gridy = 5;
gbc.gridwidth = 1;
gbc.gridheight = 1;
gbc.insets = new Insets(5, 0, 5, 0);
gbc.fill = GridBagConstraints.NONE;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.ipadx = 0;
gbl.setConstraints(suchAbfrBtn, gbc);
centerp.add(suchAbfrBtn);
JButton anpassenBtn = new JButton("anpassen");
anpassenBtn.setVisible(false);
anpassenBtn.setFont(SMALL_FONT);
gbc.gridx = 4;
gbc.gridy = 5;
gbc.gridwidth = 1;
gbc.gridheight = 1;
gbc.insets = new Insets(5, 0, 5, 0);
gbc.fill = GridBagConstraints.NONE;
gbc.weightx = 0;
gbc.weighty = 0;
gbl.setConstraints(anpassenBtn, gbc);
centerp.add(anpassenBtn);
aktuelleNachrichtL = new JLabel("");
aktuelleNachrichtL.setBackground(java.awt.Color.orange);
aktuelleNachrichtL.setVisible(true);
aktuelleNachrichtL.setFont(SMALL_FONT);
gbc.gridx = 1;
gbc.gridy = 6;
gbc.gridwidth = 5;
gbc.gridheight = 1;
gbc.insets = new Insets(5, 0, 5, 0);
gbc.fill = GridBagConstraints.NONE;
gbc.weightx = 0;
gbc.weighty = 0;
gbl.setConstraints(aktuelleNachrichtL, gbc);
centerp.add(aktuelleNachrichtL);
JPanel openBtnPanel = new JPanel();
openBtnPanel.setBorder(BorderFactory.createEtchedBorder());
openBtn = new JButton("Öffnen");
openBtn.setMnemonic(KeyEvent.VK_O);
openBtn.addActionListener(new OpenListener());
openBtn.setFont(NORMAL_BOLD_FONT);
openBtn.setEnabled(false);
//Hilfe
//helpItemString = "proj.import";
helpItemString = "Themaauswhlen.htm";
CSH.setHelpIDString(openBtn, helpItemString);
openBtnPanel.add(openBtn);
this.add(centerp, BorderLayout.CENTER);
this.add(openBtnPanel, BorderLayout.SOUTH);
}
}
//der Druckdialog greift direkt auf die JLabels zu
//wegen Font, Größe und Inhalt
class ParameterPanel extends JPanel {
JLabel lblAbfragename, lblEingabeparam, lblParams, lblStand;
ParameterPanel() {
super(new BorderLayout());
VerticalBox topBox = new VerticalBox();
topBox.addStrut(10);
lblAbfragename = new JLabel();
lblAbfragename.setFont(new Font("SansSerif", Font.BOLD, 14));
lblParams = new JLabel();
this.setMaximumSize(new Dimension(200, 1000));
lblEingabeparam = new JLabel("Parameter: ");
topBox.add(lblAbfragename);
topBox.addStrut(5);
topBox.add(lblEingabeparam);
topBox.addStrut(5);
this.add(topBox, BorderLayout.NORTH);
this.add(lblParams, BorderLayout.CENTER);
lblStand = new JLabel();
this.add(lblStand, BorderLayout.SOUTH);
}
public void setAbfragename(String name) {
lblAbfragename.setText(name);
}
public void setParams(String params) {
lblParams.setText(params);
}
public void setStand(String stand) {
lblStand.setText("Stand: " + stand);
}
}
class SxToolbar extends JToolBar {
SxToolbar(JFrame frame) {
// images in sx_map
ImageIcon disconnect_icon = (ImageIcon) sx_map.get("disconnect");
ImageIcon clone_icon = (ImageIcon) sx_map.get("clone");
ImageIcon copy_icon = (ImageIcon) sx_map.get("copy");
ImageIcon save_icon = (ImageIcon) sx_map.get("save");
ImageIcon print_icon = (ImageIcon) sx_map.get("print");
ImageIcon info_icon = (ImageIcon) sx_map.get("info");
ImageIcon passwd_icon = (ImageIcon) sx_map.get("passwd");
ImageIcon help_icon = (ImageIcon) sx_map.get("help");
this.setFloatable(false);
dbBtn = new JButton("Anmelden", disconnect_icon);
dbBtn.setMargin(new Insets(2, 2, 2, 2));
dbBtn.setDisabledIcon(disconnect_icon);
dbBtn.setMnemonic(KeyEvent.VK_D);
dbBtn.setHorizontalTextPosition(JButton.CENTER);
dbBtn.setVerticalTextPosition(JButton.BOTTOM);
dbBtn.setFont(NORMAL_FONT);
ConnectListener conl = new ConnectListener(0);
dbBtn.addActionListener(conl);
this.add(dbBtn);
dbBtn.setVisible(SuperX.remoteUser == null);
passwdBtn = new JButton("Passwort", passwd_icon);
passwdBtn.setMargin(new Insets(2, 2, 2, 2));
passwdBtn.setHorizontalTextPosition(JButton.CENTER);
passwdBtn.setVerticalTextPosition(JButton.BOTTOM);
passwdBtn.setFont(NORMAL_FONT);
PwdListener pwdl = new PwdListener(frame);
passwdBtn.addActionListener(pwdl);
passwdBtn.setEnabled(countFrame == 1 ? true : false);
passwdBtn.setEnabled(false);
this.add(passwdBtn);
passwdBtn.setVisible(SuperX.remoteUser == null);
cloneBtn = new JButton("Clone", clone_icon);
cloneBtn
.setToolTipText("öffnet weiteres SuperX-Fenster! Anschließend Anmelden anklicken!");
cloneBtn.setMargin(new Insets(2, 2, 2, 2));
cloneBtn.setHorizontalTextPosition(JButton.CENTER);
cloneBtn.setVerticalTextPosition(JButton.BOTTOM);
cloneBtn.setFont(NORMAL_FONT);
cloneBtn.setEnabled(false);
CloneListener clonel = new CloneListener();
cloneBtn.addActionListener(clonel);
this.add(cloneBtn);
copyBtn = new JButton("Kopieren", copy_icon);
copyBtn
.setToolTipText("Ergebnisse in Zwischenablage kopieren (als Trennzeichen wird Tabulator benutzt)");
copyBtn.setMargin(new Insets(2, 2, 2, 2));
copyBtn.setHorizontalTextPosition(JButton.CENTER);
copyBtn.setVerticalTextPosition(JButton.BOTTOM);
copyBtn.setFont(NORMAL_FONT);
CopyListener copyl = new CopyListener();
copyBtn.addActionListener(copyl);
this.add(copyBtn);
saveBtn = new JButton("Sichern", save_icon);
saveBtn.setToolTipText("Ergebnisse in Datei speichern");
saveBtn.setMargin(new Insets(2, 2, 2, 2));
saveBtn.setHorizontalTextPosition(JButton.CENTER);
saveBtn.setVerticalTextPosition(JButton.BOTTOM);
saveBtn.setFont(NORMAL_FONT);
SaveDlgListener savedlgl = new SaveDlgListener();
saveBtn.addActionListener(savedlgl);
//Wint 24.7.2001 Button gesperrt, wegen Problemen mit Policy
//da angenommen wird, das er sowieso nicht benutzt wird.
//Die Fehlermeldungen weisen darauf hin, dass FileChoser die ganze
//Platte durchlesen will -- evtl. Vorbehalte bei Usern
//this.add (saveBtn);
printBtn = new JButton("Drucken", print_icon);
printBtn.setMargin(new Insets(2, 2, 2, 2));
printBtn.setHorizontalTextPosition(JButton.CENTER);
printBtn.setVerticalTextPosition(JButton.BOTTOM);
printBtn.setFont(NORMAL_FONT);
PrintListener printl = new PrintListener();
printBtn.addActionListener(printl);
this.add(printBtn);
if (helpsetfound) {
helpBtn = new JButton("Hilfe", help_icon);
helpBtn.setMargin(new Insets(2, 2, 2, 2));
helpBtn.setHorizontalTextPosition(JButton.CENTER);
helpBtn.setVerticalTextPosition(JButton.BOTTOM);
helpBtn.setFont(NORMAL_FONT);
//JMenuItem menu_help = new JMenuItem(" ??");
//HelpListener helpl = new HelpListener(hb);
//helpBtn.addActionListener(helpl);
//helpBtn.addActionListener(new CSH.DisplayHelpFromSource(hb));
helpBtn.addActionListener(new CSH.DisplayHelpAfterTracking(hb));
helpBtn.setEnabled(true);
helpBtn.setToolTipText("Hilfesystem aufrufen");
this.add(helpBtn);
}
//InfoButton MB
infoBtn = new JButton("Info", info_icon);
infoBtn.setMargin(new Insets(2, 5, 2, 5));
infoBtn.setHorizontalTextPosition(JButton.CENTER);
infoBtn.setVerticalTextPosition(JButton.BOTTOM);
infoBtn.setFont(NORMAL_FONT);
infoBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
JOptionPane
.showMessageDialog(
null,
"SuperX Version @version@\nbuild:@sxtimestamp@\n"
+ "Das Data Warehouse für Hochschulen\n"
+ "www.superx-projekt.de\nKontakt: info@superx-projekt.de"
+ "\nMandant: "
+ SxSQL.mandantenID
+ ",public/private key "
+ (SxSQL.dsaHandler == null ? "nicht aktiv"
: "aktiv"), "SuperX", 1);
}
});
this.add(infoBtn);
}
}
public SxMask(String title, Hashtable img_map, boolean ifApplet) {
super();
isApplet = ifApplet;
sxMask = this;
sx_map = img_map;
sxFrame = new JFrame(title);
countFrame++;
init();
sxFrame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
close();
}
});
sxFrame.getContentPane().add(sxMask, BorderLayout.CENTER);
if (countFrame > 1) {
try {
installThemenbaum(DateUtils.getTodayString());
} catch (SQLException e1) {
ClipboardUtils.setContents(e1.toString(), null);
WarningMessage.show(sxMask, e1.toString(), "Fehler");
}
}
sxFrame.pack();
sxFrame.setBounds(100 + countFrame * 50, 100 + countFrame * 50, 600,
500);
sxFrame.setVisible(true);
connectionDlg = new ConnectionDlg(user);
}
private void installThemenbaum(String date) throws SQLException {
sxThemenbaum = new SxThemenbaum(sxMask);
themenwahltree = sxThemenbaum.getTree(date);
themenwahlscroll.setViewportView(themenwahltree);
openBtn.setEnabled(true);
}
void clearThemenbaum() {
themenwahltree.setModel(new DefaultTreeModel(
new DefaultMutableTreeNode("Abfragen")));
}
/**
* Brings up a JDialog using JOptionPane containing the connectionPanel. If
* the user clicks on the 'Connect' button the connection is reset.
*/
public int showConnectionDialog() {
int rc = -999;
if (!dummyLogin) {
rc = connectionDlg.showDlg(this.getFrame());
user.setName(connectionDlg.getUserName());
user.setPasswd(connectionDlg.getPassword());
} else {
rc = JOptionPane.YES_OPTION;
user.setName("admin");
//user.setUsername("testuser");
user.setPasswd("anfang12");
}
//SxNew autologin!
return rc;
}
protected void addMouseListenerToLogo() {
MouseAdapter listMouseListenerToLogo = new MouseAdapter() {
public void mousePressed(MouseEvent e) {
int button1 = e.getModifiers() & InputEvent.BUTTON1_MASK;
if (button1 != 0) {
if (activeThread != null) {
try {
// System.err.println ("interrupt ..");
activeThread.interrupt();
//SxSQL.cancel();
} catch (Exception ex) {
System.err.println(ex.toString());
}
}
}
}
};
logo.addMouseListener(listMouseListenerToLogo);
}
public synchronized void close() {
countFrame--;
if (SxSQL.isActive()) {
try {
SxSQL.close();
} catch (Exception ex) {
System.err.println(ex.toString());
}
}
if (countFrame <= 1) {
connectionDlg.setPassword("");
user.setPasswd("");
}
if (countFrame <= 0) {
isLogin = false;
clearThemenbaum();
//if (!isApplet)
// System.exit(0);
}
}
public void componentHidden(ComponentEvent e) {
}
public void componentMoved(ComponentEvent e) {
}
public void componentResized(ComponentEvent e) {
this.repaint();
}
public void componentShown(ComponentEvent e) {
}
/**
* Creates the connectionPanel, which will contain all the fields for the
* connection information.
*
* @throws SQLException
* @throws DBServletException
*/
protected void createMask() throws SQLException, DBServletException {
// --------------------------------------------------------------------
// r.b.
// direkt abgeleitet aus SuperX C++-Modul 'PlaceFields' in 'sx_win.cxx'
// --------------------------------------------------------------------
int oldx = 20; // orginal: oldx = 50 + 10;
int oldy = 20; // orginal: oldy = 50 + 10;
int leftmargin = 20; // orginal: leftmargin = 50 + 10;
int x_ofs = 20;
int y_ofs = 20;
int oldnw = 0, oldfw = 0;
String fieldname = null;
int fieldnr;
int x;
int y;
int buttonbreite;
int feldbreite;
int zeilenanzahl;
String typ;
int laenge;
int obligatorisch;
int art;
String relation = null;
String attribut = null;
String fielddefault = null;
String sx_db = (String) SxDefaults.getPropertyValue("SxDB");
// Maskenelemente loeschen u. neu anlegen
maskeForm.removeAll(); // "alte" Maskenelemente loeschen
maskeForm.addComp(
// (String) H_thema.get(activeMaskeID),
selectedMaskeninfoElement.getName(), "M_headline", "JLabel", 0,
0, 0, 0);
maskeForm.setPreferredCompWidth("M_headline", 500);
maskeForm.setCompXY("M_headline", 20, 20);
JLabel L_M_headline = (JLabel) maskeForm.getComp("M_headline");
L_M_headline.setFont(new Font("SansSerif", Font.BOLD, 14));
// Tabelle loeschen u. neu anlegen
lastMaskeID = new Integer(-1);
sxTablePanel.setData(new Vector(), new Vector(), new Vector(), null);
// Maskengroesse auslesen
int m_breite = selectedMaskeninfoElement.getBreite().intValue();
// Maskenbreite
int m_hoehe = selectedMaskeninfoElement.getHoehe().intValue();
// Maskenhoehe
// Unsichtbares Feld <<UserID>>
maskeForm.addComp("UserID", "L_UserID", "JLabel", 0, 0, 0, 0);
JLabel L_userid = (JLabel) maskeForm.getComp("L_UserID");
L_userid.setVisible(false);
// s.o. Benutzerautorisierung mit UserID
maskeForm.addComp(SxSQL.getUserID().toString(), "F_UserID", "SxField",
0, SxField.TYPE_INTEGER, 4, 0);
// maskeForm.addComp ("1", "F_UserID", "SxField", 0,
// SxField.TYPE_INTEGER, 4, 0);
SxField F_userid = (SxField) maskeForm.getComp("F_UserID");
F_userid.setVisible(false);
// Einzelfelder einfügen
addIndividualFields(oldy, leftmargin, x_ofs, y_ofs, oldnw, oldfw, sx_db);
// Feld-Angaben in Form speichern
maskeForm.setFieldVector(selectedMaskeninfoElement.getFelderinfos());
// Default-Values (letzte Feld-Eingaben)
maskeForm.restoreValuesFromFormerSelections();
// Default-Button
maskeForm.setDefaultBtn(searchBtn);
// Fenstergroesse anpassen
int diff_height = 0;
maskeForm.revalidate(); //Wint
maskeForm.setPreferredSize(new Dimension(m_breite, m_hoehe));
Rectangle m_rect = new Rectangle(0, 0, m_breite, m_hoehe);
Rectangle f_rect = maskeForm.getBounds();
Container toplevel = maskeForm.getTopLevelAncestor();
Rectangle top_rect = toplevel.getBounds();
if (!f_rect.contains(m_rect)) {
diff_height = m_rect.height - f_rect.height;
f_rect.width += m_rect.width - f_rect.width + 5;
f_rect.height += m_rect.height - f_rect.height;
}
if (!top_rect.contains(f_rect))
top_rect.width += f_rect.width - top_rect.width;
top_rect.height += diff_height;
if (top_rect.height > 600) // Fensterhoehe auf 600 Pixels begrenzen
top_rect.height = 600;
toplevel.setBounds(top_rect);
sxFrame.invalidate();
sxFrame.validate();
sxFrame.repaint();
}
/**
* einzelne Felder auf die Maske packen von CreateMask aufgerufen
*
* @param oldy
* @param leftmargin
* @param x_ofs
* @param y_ofs
* @param oldnw
* @param oldfw
* @param sx_db
* @throws SQLException
* @throws DBServletException
*/
private void addIndividualFields(int oldy, int leftmargin, int x_ofs,
int y_ofs, int oldnw, int oldfw, String sx_db) throws SQLException,
DBServletException {
int oldx;
String fieldname;
int fieldnr;
int x;
int y;
int buttonbreite;
int feldbreite;
int zeilenanzahl;
String typ;
int laenge;
int obligatorisch;
int art;
String relation;
String attribut;
String fielddefault;
SichtApplet defaultsicht = null;
for (int i = 0; i < selectedMaskeninfoElement.getFelderinfos().size(); i++) {
defaultsicht = null;
Vector V_field = (Vector) selectedMaskeninfoElement
.getFelderinfos().elementAt(i);
fieldname = (String) V_field.elementAt(1);
if (fieldname != null)
fieldname = fieldname.trim();
//captions holen
SxSQL.executeQuery("select contents_short, contents_long "
+ " from sx_captions " + " where table_name='felderinfo' "
+ " and field_name='" + fieldname
+ "' and (record_no is null or record_no="
+ V_field.elementAt(0) + ")");
Vector v_captions = SxSQL.getResultVector();
String erläuterung = "";
String fieldCaption = fieldname;
if (v_captions.size() > 0) {
Vector row = (Vector) v_captions.get(0);
String cap = (String) row.get(0);
if (cap != null)
fieldCaption = cap;
erläuterung = (String) row.get(1);
}
fieldnr = ((Integer) V_field.elementAt(2)).intValue();
x = ((Integer) V_field.elementAt(3)).intValue();
if (x == 0)
x += leftmargin;
if (x < 0)
x = 0;
y = ((Integer) V_field.elementAt(4)).intValue();
if (y == 0) {
y = oldy + 25 + y_ofs;
}
if (y == -1) {
x += 2 * x_ofs;
y = oldy;
}
buttonbreite = ((Integer) V_field.elementAt(5)).intValue();
if (buttonbreite == 0)
buttonbreite = oldnw;
else
buttonbreite += x_ofs;
feldbreite = ((Integer) V_field.elementAt(6)).intValue();
if (feldbreite == 0)
feldbreite = oldfw;
zeilenanzahl = ((Integer) V_field.elementAt(7)).intValue();
typ = (String) V_field.elementAt(8);
if (typ != null)
typ = typ.trim();
laenge = ((Integer) V_field.elementAt(9)).intValue();
obligatorisch = ((Integer) V_field.elementAt(10)).intValue();
art = ((Integer) V_field.elementAt(11)).intValue();
//MB XML-Querabhängiges Feldart 16 wird einfach als reguläre 1 umgesetzt
// gar nicht mehr nötig if (art==16) art=1;
relation = (String) V_field.elementAt(12);
if (relation != null)
relation = relation.trim();
attribut = (String) V_field.elementAt(13);
if (attribut != null)
attribut = attribut.trim();
fielddefault = (String) V_field.elementAt(14);
if (fielddefault != null)
fielddefault = fielddefault.trim();
/*
* System.err.println ("Feld : " + fieldname + ", x=" + x + ", y=" +
* y + ", buttonbreite=" + buttonbreite + ", feldbreite=" +
* feldbreite);
*/
//Rückgabewert defaultsicht ist brutale Methode um defaultsicht zu
// merken
if ((art > 0 && art <= 7) || art == 12) {
defaultsicht = addButtonField(fieldname, fieldCaption,
obligatorisch, art, relation, zeilenanzahl,erläuterung, i);
} else {
addLabelField(fieldname, x, y, buttonbreite, obligatorisch);
}
JComponent comp = (JComponent) maskeForm.getComp("L_" + fieldname);
if(art==13||art==15) comp.setVisible(false);
comp.setToolTipText(erläuterung);
FontMetrics font_m = comp.getFontMetrics(comp.getFont());
int label_width = font_m.stringWidth(fieldCaption) + 10;
maskeForm.setPreferredCompWidth("L_" + fieldname, label_width);
maskeForm.setCompXY("L_" + fieldname, x + buttonbreite
- label_width, y);
String field_type = "SxField";
//MB Mehrfachwahlanzeige
if (zeilenanzahl > 1)
field_type = "JComboBox";
if (art == 10)
field_type = "JCheckbox";
if (art == 11)
field_type = "JPasswordField";
//field_type = "JComboView";
if (art != 8&&art!=13&&art!=15)
//wenn es sich nicht um ein reines Label-Feld oder unsichtbare Felder handelt: Eingabefeld
// einfügen
{
if (typ.toLowerCase().equals("integer"))
maskeForm.addComp("", "F_" + fieldname, field_type, 0,
SxField.TYPE_INTEGER, laenge, obligatorisch);
if (typ.toLowerCase().equals("date"))
maskeForm.addComp("", "F_" + fieldname, field_type, 0,
SxField.TYPE_DATE, laenge, obligatorisch);
if (typ.toLowerCase().equals("char"))
maskeForm.addComp("", "F_" + fieldname, field_type, 0,
SxField.TYPE_STRING, laenge, obligatorisch);
if (typ.toLowerCase().equals("decimal"))
maskeForm.addComp("", "F_" + fieldname, field_type, 0,
SxField.TYPE_DOUBLE, laenge, obligatorisch);
if (typ.toLowerCase().equals("sql"))
maskeForm.addComp("", "F_" + fieldname, field_type, 0,
SxField.TYPE_SQL, laenge, obligatorisch);
maskeForm.setPreferredCompWidth("F_" + fieldname, feldbreite);
maskeForm.setCompXY("F_" + fieldname, x_ofs + buttonbreite + x,
y);
SxField valuefield = maskeForm.getField("F_" + fieldname);
if (art == 1 || art == 12) {
valuefield.setEditable(false);
}
//ggfs. eine Default Sicht hinterlegen
//vergl. addButtonField
if (defaultsicht != null) {
valuefield.setSelectedSicht(defaultsicht);
}
// Default-Wert aus Tab. 'felderinfo' setzen
setFieldDefault(sx_db, fieldname, art, fielddefault, valuefield);
}
oldx = x;
oldy = y;
oldnw = buttonbreite;
oldfw = feldbreite;
}
}
/**
* basis Default-werte setzen, später kommt noch Methode, die ggfs. durch
* letzte Eingaben überlagert see createMask
*
* @param sx_db
* @param fieldname
* @param art
* @param fielddefault
* @param field
*/
private void setFieldDefault(String sx_db, String fieldname, int art,
String fielddefault, SxField field) {
if (fielddefault != null) {
String stmt = "";
if (fielddefault.startsWith("<<SQL>>")
|| fielddefault.startsWith("sp_")) {
readFieldDefaultFromDb(sx_db, fieldname, fielddefault, field,
stmt);
} else {
if (field != null)
field.setText(fielddefault);
field.setKey(new Integer(-1));
}
//bei einem Institutionendialog, fielddefault auf null setzen
//siehe Kommentar in SxField.setDefaultValue()
if (art == 4 || art == 6 || art == 7 || art == 12) {
field.setKey("null");
field.setDefaultValue("null");
}
}
}
private void readFieldDefaultFromDb(String sx_db, String fieldname,
String fielddefault, SxField field, String stmt) {
try {
stmt = fielddefault;
if (fielddefault.startsWith("<<SQL>>"))
stmt = fielddefault.substring(7);
stmt = stmt.trim();
if (stmt.startsWith("sp_")) {
if (sx_db.equals("Postgres")) {
stmt = "select " + stmt;
} else {
stmt = "execute procedure " + stmt;
}
}
System.out.println(stmt);
stmt = SxUtils.generateSQL(maskeForm, stmt);
//MB 2/2016 auch Freemarker Parsing
//Trickmethode!!
HashMap map = maskeForm.getHashMap(selectedMaskeninfoElement.getTid());
stmt = SxSQL.templateProcessor.process("Felderdefault "+fieldname
, stmt,
map, (String) SxDefaults.getPropertyValue("SxDB"));
SxSQL.executeAll(stmt);
Vector result = SxSQL.getResultVector();
if (result.size() == 0)
throw new IllegalStateException(
"Defaultwert konnte nicht ermittelt werden, da der select nichts lieferte.");
Vector V_default = (Vector) result.elementAt(0);
Object key, value;
if (V_default.size() == 2) {
key = V_default.elementAt(0);
field.setKey(key);
value = V_default.elementAt(1);
if (value instanceof java.sql.Date)
value = SxDate.toString((java.sql.Date) value);
field.setText(value.toString());
}
if (V_default.size() == 1) {
//field.setKey(new Integer("-1"));
value = V_default.elementAt(0);
key = value;
if (value instanceof java.sql.Date)
value = SxDate.toString((java.sql.Date) value);
field.setText(value.toString());
}
} catch (Exception ex) {
System.out.println("Fehler beim Lesen von Defaultwert für Feld "
+ fieldname + "\n Sql-stmt=" + stmt);
ex.printStackTrace();
}
}
private void addLabelField(String fieldname, int x, int y,
int buttonbreite, int obligatorisch) {
maskeForm.addComp(fieldname, "L_" + fieldname, "JLabel", 0, 0, 0, 0);
maskeForm.setPreferredCompWidth("L_" + fieldname, buttonbreite);
maskeForm.setCompXY("L_" + fieldname, x, y);
JLabel L_fieldname = (JLabel) maskeForm.getComp("L_" + fieldname);
L_fieldname.setHorizontalAlignment(JLabel.RIGHT);
if (obligatorisch != 0)
L_fieldname.setFont(NORMAL_BOLD_FONT);
else
L_fieldname.setFont(NORMAL_FONT);
}
private SichtApplet addButtonField(String fieldname, String fieldCaption,
int obligatorisch, int art, String relation,int zeilenanzahl, String erläuterung,
int i) throws SQLException, DBServletException {
SichtApplet defaultsicht = null;
maskeForm
.addComp(fieldCaption, "L_" + fieldname, "JButton", 0, 0, 0, 0);
JButton btn = (JButton) maskeForm.getComp("L_" + fieldname);
btn.setHorizontalAlignment(JLabel.RIGHT);
if (obligatorisch != 0)
btn.setFont(NORMAL_BOLD_FONT);
else
btn.setFont(NORMAL_FONT);
Sichtgruppe sichtgruppe = null;
if (art == 4 || art == 6 || art == 7 || art == 12) {
Vector sichtentids = new Vector();
try {
//Falls Datenbankzugriff nötig hier schon machen
//vergleichbare Methode im Servlet in Field.initSichtengruppe
if (art == 12 && relation != null
&& relation.startsWith("<<SQL>>")) {
SxSQL.executeQuery(relation.substring(7));
Vector result = SxSQL.getResultVector();
for (Iterator iter = result.iterator(); iter.hasNext();) {
Vector aRow = (Vector) iter.next();
Integer eineSichtTid = (Integer) aRow.get(0);
sichtentids.add(eineSichtTid);
}
}
//MB 1/16 dynamsiche Sichten vom Applet nicht unterstützt
sichtgruppe = user.getSichten().getGruppe(new Hashtable(),new HashMap(),new FieldContainer(), fieldname,art,
sichtentids, relation, zeilenanzahl,maskeForm.getDefaultStand(),SxSQL.mandantenID);
} catch (Exception e) {
String msg = "Konnte Sichten nicht einlesen:" + e.toString();
ClipboardUtils.setContents(msg, null);
WarningMessage.show(sxMask, msg, "SuperX");
e.printStackTrace();
}
}
SxDlgListener dlgl = new SxDlgListener(sxMask, maskeForm, btn,
erläuterung, i, art);
if (sichtgruppe != null) {
defaultsicht = (SichtApplet) sichtgruppe.getSelectedSicht();
dlgl.setSichtgruppe(sichtgruppe);
}
btn.addActionListener(dlgl);
return defaultsicht;
}
void initUser(int mode) {
try {
stopBtn.setEnabled(true);
statusField.setBackground(Color.yellow);
//anmelden
if (mode == 0) {
String sql_stmt;
logo.start();
if (SxSQL.isActive()) {
SxSQL.close();
}
// delete Dialog-Cache
SxDlgManager.clear();
// delete Defaults-Cache
SxDefaults.clear();
SxDefaults.init();
V_thema = null;
user.getSichten().clear();
statusField.setText("Anmelden ..");
passwdBtn.setEnabled(false);
passwdBtn.setVisible(SuperX.remoteUser == null);
SxSQL.setLogMode(logToKonsole);
SxSQL.setUrl(serverURL);
if (!SuperX.isAuthentificationFound)
SxSQL.check(user);
//bei An/ummeldung wird im connectListener
// isAuthenficationFound auf false gesetzt
SxSQL.readFMTemplates();
if (SuperX.remoteUser != null)
passwdBtn.setEnabled(true);
statusField.setText("Lade Standardwerte ..");
//Sichten einlesen
SxSQL.executeQuery(Sichten.getReadingSql(user));
user.getSichten().init(SxSQL.mandantenID, SxSQL.getResult(),
SichtApplet.class);
SxSQL.executeQuery("select distinct tid,type from sichten S where "
+ Sichten.getErlaubteSichtenSql(user));
user.getSichten().setAllowedSichten(SxSQL.getResult(), user.isAdmin());
if (SuperX.isSachgebieteNeeded)
Sachgebiete.init();
installThemenbaum(DateUtils.getTodayString());
terlaeuterung.setText("");
statusField.setBackground(Color.white);
statusField.setText("Anmeldung erfolgreich");
ImageIcon connect_icon = (ImageIcon) sx_map.get("connect");
dbBtn.setIcon(connect_icon);
dbBtn.setDisabledIcon(connect_icon);
if (countFrame == 1)
passwdBtn.setEnabled(true);
openBtn.setEnabled(true);
isLogin = true;
cloneBtn.setEnabled(true);
tabPane.setSelectedIndex(0);
JRootPane root = sxMask.getRootPane();
root.setDefaultButton(openBtn); // DefaultButton setzen
}
if (mode == 1) {
logo.start();
statusField.setText("Abmelden ..");
if (SxSQL.isActive())
SxSQL.close();
// delete Dialog-Cache
SxDlgManager.clear();
// delete Defaults-Cache
SxDefaults.clear();
statusField.setBackground(Color.white);
statusField.setText("Keine DB-Verbindung");
ImageIcon disconnect_icon = (ImageIcon) sx_map
.get("disconnect");
dbBtn.setIcon(disconnect_icon);
dbBtn.setDisabledIcon(disconnect_icon);
if (countFrame == 1)
passwdBtn.setEnabled(false);
openBtn.setEnabled(false);
lastMaskeID = new Integer(-1);
if (countFrame <= 1) {
isLogin = false;
cloneBtn.setEnabled(false);
//sx_map.clear(); //Wint wars nicht!!
}
//Wint:Da bei http-Verbindung kein closeConnection
//möglich ist, wird Applet-Fenster geschlossen
close();
}
} catch (Exception ex) {
String msg = ex.toString();
// System.err.println("msg: " + msg);
ex.printStackTrace();
statusField.setText(msg);
ClipboardUtils.setContents(msg, null);
}
dbBtn.setEnabled(true);
stopBtn.setEnabled(false);
logo.stop();
sxMask.repaint();
activeThread = null;
}
void setUser(SxUser user) {
this.user = user;
}
public Vector getFieldVector() {
return selectedMaskeninfoElement.getFelderinfos();
}
public SxForm getForm() {
return maskeForm;
}
public JFrame getFrame() {
return sxFrame;
}
public SxLogoPanel getLogo() {
return logo;
}
public JTextField getStatusField() {
return statusField;
}
public void init() {
int start_x = 20, start_y = 20;
sxMask.setLayout(new BorderLayout());
JPanel heading = new JPanel();
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints constraints = new GridBagConstraints();
heading.setLayout(gridbag);
constraints.weightx = 1.0;
constraints.weighty = 1.0;
int[] logo_pixels = (int[]) sx_map.get("logo_pixels");
JPanel sxTpanel = new JPanel();
sxTpanel.setLayout(new BoxLayout(sxTpanel, BoxLayout.X_AXIS));
initHelpSystem();
JToolBar toolbar = new SxToolbar(this.getFrame());
sxTpanel.add(toolbar);
constraints.anchor = GridBagConstraints.CENTER;
gridbag.setConstraints(sxTpanel, constraints);
heading.add(sxTpanel);
ImageIcon logo_icon = (ImageIcon) sx_map.get("logo");
logo = new SxLogoPanel(logo_icon, logo_pixels, 20, 50);
addMouseListenerToLogo();
constraints.insets = new Insets(5, 5, 5, 5);
constraints.anchor = GridBagConstraints.EAST;
gridbag.setConstraints(logo, constraints);
heading.add(logo);
sxMask.add(heading, BorderLayout.NORTH);
// Workpanel
JPanel sxWpanel = new JPanel();
sxWpanel.setLayout(new BorderLayout());
sxWpanel.setBorder(BorderFactory.createEtchedBorder());
tabPane = new JTabbedPane();
tabPane.setFont(NORMAL_BOLD_FONT);
// Themenauswahl
ThemenwahlPanel themap = new ThemenwahlPanel();
tabPane.addTab("Themenauswahl", themap);
//Hilfe für Thema
helpItemString = "Themaauswhlen.htm";
CSH.setHelpIDString(themap, helpItemString);
if (helpsetfound) {
hb.enableHelpKey(themap, helpItemString, hs);
hb.enableHelp(themap, helpItemString, hs);
}
// Maske
// ---------------------------------------------------------------------
initMaskeTab();
// Tabelle
// ---------------------------------------------------------------------
initTableTab();
// ---------------------------------------------------------------------
tabPane.setSelectedIndex(0);
sxWpanel.add(tabPane, "Center");
// Statusbar
sxSpanel = new JPanel();
sxSpanel.setLayout(new BorderLayout());
sxSpanel.setBorder(BorderFactory.createEtchedBorder());
statusField = new JTextField("");
statusField.setFont(NORMAL_FONT);
statusField.setMargin(new Insets(5, 5, 5, 5));
statusField.setEditable(false);
sxSpanel.add(statusField, "Center");
sxMask.add(sxWpanel, "Center");
sxMask.add(sxSpanel, "South");
// Default Properties laden
// ---------------------------------------------------------------------
SxDefaults.init();
try {
serverURL = (String) SxDefaults.getPropertyValue("SxServerURL");
//MB 20.6.06 damit schon früher bekannt
SxSQL.setUrl(serverURL);
} catch (Exception ex) {
ClipboardUtils.setContents(ex.toString(), null);
System.err.println(ex);
JOptionPane.showMessageDialog(sxMask, ex.toString(), "Fehler",
JOptionPane.ERROR_MESSAGE);
}
try {
logToKonsole = (String) SxDefaults.getPropertyValue("logToKonsole");
} catch (Exception ex) {
logToKonsole = "none";
}
sxTitle = sxFrame.getTitle();
try {
sxTitle = sxTitle + ", "
+ (String) SxDefaults.getPropertyValue("SxTitle");
sxFrame.setTitle(sxTitle);
} catch (Exception ex) {
sxFrame.setTitle(sxTitle);
}
}
ParameterPanel getParameterPanel() {
return parameterPanel;
}
private void initTableTab() {
JPanel tableTab = new JPanel();
tableTab.setLayout(new BorderLayout());
// Ergebnistabelle fuer Maske
sxTablePanel = new SxTablePanel();
//MB selection Deselektion ermöglichen (dekl. sxTablePanel drüber)
parameterPanel.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
int button1 = e.getModifiers() & InputEvent.BUTTON1_MASK;
if (button1 == 0)
return;
sxTablePanel.table.setColumnSelectionAllowed(false);
sxTablePanel.rowheaderTable.setColumnSelectionAllowed(false);
sxTablePanel.table.setRowSelectionAllowed(true);
sxTablePanel.rowheaderTable.setRowSelectionAllowed(true);
sxTablePanel.table.clearSelection();
sxTablePanel.rowheaderTable.clearSelection();
}
});
HorizontalBox hbox = new HorizontalBox();
hbox.add(parameterPanel);
hbox.addGlue();
tableTab.add(hbox, BorderLayout.NORTH);
//tableTab.add(parameterPanel, BorderLayout.NORTH);
tableTab.add(sxTablePanel, BorderLayout.CENTER);
//Hilfe für Tabelle
//helpItemString = "debug.overview";
if (helpsetfound) {
helpItemString = "Auswertungsmglichkei.htm";
CSH.setHelpIDString(tableTab, helpItemString);
hb.enableHelpKey(tableTab, helpItemString, hs);
hb.enableHelp(tableTab, helpItemString, hs);
//CSH.setHelpIDString(helpBtn,helpItemString);
}
JPanel pSouth = new JPanel();
pSouth.add(btnExplanation);
tableTab.add(pSouth, BorderLayout.SOUTH);
btnExplanation.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
explanationFrame.set(selectedMaskeninfoElement);
explanationFrame.show();
}
});
tabPane.addTab("Tabelle", tableTab);
}
private void initMaskeTab() {
JPanel maskep = new JPanel(new BorderLayout());
// Control-Buttons
JPanel sxCMpanel = new JPanel();
sxCMpanel.setLayout(new FlowLayout());
sxCMpanel.setBorder(BorderFactory.createEtchedBorder());
searchBtn = new JButton("Suchen");
searchBtn.setMnemonic(KeyEvent.VK_S);
SearchListener searchl = new SearchListener();
searchBtn.addActionListener(searchl);
searchBtn.setFont(NORMAL_BOLD_FONT);
searchBtn.setEnabled(false);
//Hilfe
//helpItemString = "proj.paths";
helpItemString = "WeitereThemeneingren.htm";
sxCMpanel.add(searchBtn, 0);
resetBtn = new JButton("Reset");
ResetListener resetl = new ResetListener();
resetBtn.addActionListener(resetl);
resetBtn.setFont(NORMAL_BOLD_FONT);
resetBtn.setEnabled(true);
sxCMpanel.add(resetBtn, 1);
stopBtn = new JButton("Abbrechen");
stopBtn.setMnemonic(KeyEvent.VK_C);
StopListener stopl = new StopListener();
stopBtn.addActionListener(stopl);
stopBtn.setFont(NORMAL_BOLD_FONT);
stopBtn.setEnabled(false);
stopBtn.setVisible(false);
// Abbrechen bringt ConnectionPool durcheinander
sxCMpanel.add(stopBtn, 2);
// SxForm Maske
// ---------------------------------------------------------------------
maskeForm = new SxForm(0, 0, 0, 0);
selectedMaskeninfoElement.setMaskeForm(maskeForm);
maskeForm.setLogo(logo);
maskep.add(new JScrollPane(maskeForm), BorderLayout.CENTER);
maskep.add(sxCMpanel, BorderLayout.SOUTH);
//Hilfe für Maske
//helpItemString = "build.build";
if (helpsetfound) {
helpItemString = "WeitereThemeneingren.htm";
CSH.setHelpIDString(maskep, helpItemString);
hb.enableHelpKey(maskep, helpItemString, hs);
hb.enableHelp(maskep, helpItemString, hs);
//CSH.setHelpIDString(helpBtn,helpItemString);
}
tabPane.addTab("Maske", maskep);
}
private void initHelpSystem() {
ClassLoader loader = this.getClass().getClassLoader();
URL url = null;
try {
url = HelpSet.findHelpSet(loader, "superx_help/superx");
if (url == null) {
url = HelpSet.findHelpSet(loader, "superx_help/superx.hs");
//java.lang.String.debug("codeBase url=" + url);
}
hs = new HelpSet(loader, url);
} catch (NoClassDefFoundError e) {
JOptionPane.showMessageDialog(null,
"Java Hilfesystem nicht gefunden. ", "SuperX",
JOptionPane.WARNING_MESSAGE);
} catch (Exception ee) {
System.out.println("Hilfesystem nicht gefunden!");
}
if (url != null) {
//System.out.println("Hilfesystem gefunden: "+url.toString());
hb = hs.createHelpBroker();
helpsetfound = true;
}
}
//MB Maske Öffnen wird vom OpenListener und Doppelklick in Tree Aufgerufen
public void maskeOeffnen() {
//sxMask.terlaeuterung.setText("");
openBtn.setEnabled(false);
statusField.setText("Bitte warten ..");
SxWaitCursor.set(sxMask, true);
try {
//afterwards selectedMaskeninfoEntry is up to date
readMaskenFelderInfoFromDb();
// Neue Maske aufbauen
sxMask.createMask();
//activeMaskeName = (String) V_id.elementAt(1); //MB name
searchBtn.setEnabled(true);
JRootPane root = sxMask.getRootPane();
root.setDefaultButton(searchBtn); // DefaultButton setzen
tabPane.setSelectedIndex(1);
statusField.setText("");
} catch (Exception ex) {
ex.printStackTrace();
String msg = ex.toString();
ClipboardUtils.setContents(msg, null);
System.out.println(msg);
statusField.setText("Maske konnte nicht aufgebaut werden :"
+ msg.substring(msg.lastIndexOf(":") + 1) + "-"
+ SxSQL.getErrorString());
} finally {
logo.stop();
openBtn.setEnabled(true);
SxWaitCursor.set(sxMask, false);
sxMask.repaint();
}
}
private void readMaskenFelderInfoFromDb() throws SQLException, IOException {
String sql = "select M.tid, M.select_stmt, M.xil_proplist, M.cleanup_stmt, "
+ "M.breite, M.hoehe, S.datum, M.hinweis,M.erlaeuterung "
+ "from maskeninfo M, maske_system_bez B, systeminfo S "
+ "where M.tid = "
+ selectedMaskeninfoElement.getTid()
+ " and M.tid = B.maskeninfo_id"
+ " and S.tid = B.systeminfo_id" + ";";
SxSQL.executeQuery(sql);
Vector vectorMaskeninfoEntries = SxSQL.getResultVector();
if (vectorMaskeninfoEntries.size() == 0) {
throw new SQLException("Keine Daten zu dieser Maske (Nr."
+ selectedMaskeninfoElement.getTid()
+ ") in der Datenbank gefunden");
}
//fieser Trick: es wird als letztes Element noch ein Vector mit
//Spaltenerläuterungen mitgeliefert
selectedMaskeninfoElement.init(vectorMaskeninfoEntries);
sql = "select F.tid, F.name, F.nummer, F.x, F.y, F.buttonbreite, "
+ "F.feldbreite, F.zeilenanzahl, F.typ, F.laenge, "
+ "F.obligatorisch, F.art, F.relation, F.attribut, F.defaultwert "
+ "from felderinfo F, masken_felder_bez B "
+ "where F.art!=999 and B.maskeninfo_id = "
+ selectedMaskeninfoElement.getTid()
+ " and F.tid = B.felderinfo_id " + "order by F.nummer;";
SxSQL.executeQuery(sql);
selectedMaskeninfoElement.setFelderinfos(SxSQL.getResultVector());
//captions_long für die Felder wird in addButtonField geholt
if (SuperX.isSachgebieteNeeded)
selectedMaskeninfoElement.readSachgebiete();
}
void setConnectPwBtnsSVisible(boolean vis) {
dbBtn.setVisible(vis);
passwdBtn.setVisible(vis);
}
public void open() {
sxFrame.setVisible(true);
JRootPane root = sxMask.getRootPane();
if (SuperX.isAuthentificationFound)
root.setDefaultButton(dbBtn); // DefaultButton setzen
if (isLogin == false) {
user.setPasswd("");
connectionDlg.setPassword("");
}
if (!SuperX.isAuthentificationFound && SuperX.remoteUser == null)
dbBtn.doClick();
passwdBtn.setVisible(SuperX.remoteUser == null);
}
public MaskeninfoElement getSelectedMaskeninfoElement() {
return selectedMaskeninfoElement;
}
}