Daniel Quathamer
2 years ago
1609 changed files with 248973 additions and 158430 deletions
@ -1,89 +0,0 @@
@@ -1,89 +0,0 @@
|
||||
package de.superx.applet; |
||||
|
||||
import java.awt.Color; |
||||
import java.awt.Dimension; |
||||
import java.awt.Font; |
||||
import java.awt.Frame; |
||||
import java.awt.GridLayout; |
||||
import java.awt.Insets; |
||||
import java.awt.event.KeyEvent; |
||||
|
||||
import javax.swing.BoxLayout; |
||||
import javax.swing.JLabel; |
||||
import javax.swing.JOptionPane; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JPasswordField; |
||||
import javax.swing.KeyStroke; |
||||
import javax.swing.text.Keymap; |
||||
|
||||
import de.memtext.baseobjects.User; |
||||
|
||||
public class ConnectionDlg extends JPanel { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
private JPasswordField passwordField; |
||||
private JLabel passwordLabel; |
||||
private SxField userNameField; |
||||
private JLabel userNameLabel; |
||||
String[] ConnectOptionNames = { "Anmelden", "Abmelden", "Abbruch" }; |
||||
String ConnectTitle = "Datenbank anmelden"; |
||||
|
||||
public ConnectionDlg(User user) |
||||
{ |
||||
this(user.getName(),""); |
||||
} |
||||
public ConnectionDlg(String userName, String userPass) { |
||||
// Create the labels and text fields.
|
||||
userNameLabel = new JLabel("Benutzername: ", JLabel.RIGHT); |
||||
userNameField = new SxField(userName); |
||||
userNameField.setBackground(Color.white); |
||||
userNameField.setMargin(new Insets(2, 2, 2, 2)); |
||||
|
||||
passwordLabel = new JLabel("Kennwort: ", JLabel.RIGHT); |
||||
passwordField = new JPasswordField(userPass); |
||||
passwordField.setBackground(Color.white); |
||||
passwordField.setMargin(new Insets(2, 2, 2, 2)); |
||||
KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0); |
||||
Keymap map = passwordField.getKeymap(); |
||||
map.removeKeyStrokeBinding(enter); |
||||
passwordField.setKeymap(map); |
||||
|
||||
setFont(new Font("SansSerif", Font.BOLD, 12)); |
||||
setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); |
||||
JPanel namePanel = new JPanel(false); |
||||
namePanel.setLayout(new GridLayout(0, 1)); |
||||
namePanel.setMaximumSize(new Dimension(150, 100)); |
||||
namePanel.add(userNameLabel); |
||||
namePanel.add(passwordLabel); |
||||
add(namePanel); |
||||
JPanel fieldPanel = new JPanel(false); |
||||
fieldPanel.setLayout(new GridLayout(0, 1)); |
||||
fieldPanel.add(userNameField); |
||||
fieldPanel.add(passwordField); |
||||
add(fieldPanel); |
||||
} |
||||
String getUserName() { |
||||
return userNameField.getText(); |
||||
} |
||||
String getPassword() { |
||||
return new String(passwordField.getPassword()); |
||||
} |
||||
public int showDlg(Frame parent) { |
||||
this.passwordField.setText(""); |
||||
return JOptionPane.showOptionDialog( |
||||
parent, |
||||
this, |
||||
ConnectTitle, |
||||
JOptionPane.YES_NO_CANCEL_OPTION, |
||||
JOptionPane.INFORMATION_MESSAGE, |
||||
null, |
||||
ConnectOptionNames, |
||||
ConnectOptionNames[0]); |
||||
} |
||||
public void setPassword(String txt) { |
||||
passwordField.setText(txt); |
||||
} |
||||
|
||||
} |
||||
|
||||
//Created on 15.03.2004 at 13:06:38
|
@ -1,95 +0,0 @@
@@ -1,95 +0,0 @@
|
||||
package de.superx.applet; |
||||
|
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.awt.print.PageFormat; |
||||
import java.awt.print.Paper; |
||||
import java.awt.print.PrinterJob; |
||||
|
||||
import javax.swing.JButton; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JScrollPane; |
||||
|
||||
import de.memtext.icons.MBStandardIcons; |
||||
import de.memtext.util.WindowUtils; |
||||
import de.memtext.widgets.MBFrame; |
||||
import de.memtext.widgets.PrintableEditorPane; |
||||
|
||||
public class ExplanationFrame extends MBFrame implements ActionListener { |
||||
private PrintableEditorPane pane = new PrintableEditorPane("text/html",""); |
||||
|
||||
public ExplanationFrame() { |
||||
super("Erläuterung"); |
||||
pane.setEditable(false); |
||||
//pane.addHyperlinkListener(new Hyperactive(f));
|
||||
setSystemExitOnClose(false); |
||||
setCenter(new JScrollPane(pane)); |
||||
JPanel pSouth=new JPanel(); |
||||
JButton btnPrint=new JButton("Drucken",MBStandardIcons.getPrint()); |
||||
btnPrint.addActionListener(this); |
||||
pSouth.add(btnPrint); |
||||
setSouth(pSouth); |
||||
setSize(400,500); |
||||
WindowUtils.center(this); |
||||
} |
||||
|
||||
public void set(MaskeninfoElement m) { |
||||
this.setTitle("Erläuterung zu " + m.getName()); |
||||
StringBuffer buf=new StringBuffer("<html><h3>Erläuterung zur Abfrage "+m.getName()+"</h3>"); |
||||
buf.append(m.getErlaueterung()+"<br><br>"); |
||||
if (m.hasSpaltenExplanations()) |
||||
{ |
||||
buf.append(m.getSpaltenExplanationText()); |
||||
} |
||||
|
||||
pane.setText(buf.toString()); |
||||
pane.setCaretPosition(0); |
||||
} |
||||
|
||||
public void actionPerformed(ActionEvent ae) { |
||||
print(); |
||||
} |
||||
|
||||
private void print() { |
||||
PrinterJob pj = PrinterJob.getPrinterJob(); |
||||
PageFormat pageFormat = pj.defaultPage(); |
||||
pageFormat.setOrientation(java.awt.print.PageFormat.LANDSCAPE); |
||||
|
||||
// Dialog zur Auswahl des Papierformats
|
||||
pageFormat = pj.pageDialog(pageFormat); |
||||
|
||||
|
||||
|
||||
// A4 festvorgeben.
|
||||
// Papiergroesse DIN A4, Rand: O + U: 1/2 Inch, L + R: 1/2 Inch
|
||||
// alle angaben in 1/72 Inch
|
||||
|
||||
Paper a4 = new Paper(); |
||||
a4.setSize(21 / 2.54 * 72, 29.7 / 2.54 * 72); |
||||
a4.setImageableArea( |
||||
36, |
||||
36, |
||||
(21 / 2.54 * 72) - 72, |
||||
(29.7 / 2.54 * 72) - 72); |
||||
|
||||
pageFormat.setPaper(a4); |
||||
//ggfs_nurMarkierterBereich(pj,pageFormat);
|
||||
|
||||
pj.setPrintable(pane, pageFormat); |
||||
//else
|
||||
// pj.setPrintable(tmp_drucktab, pageFormat);
|
||||
|
||||
if (!pj.printDialog()) |
||||
return; |
||||
try { |
||||
|
||||
pj.print(); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
|
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
//Created on 07.04.2005 at 14:32:57
|
@ -1,360 +0,0 @@
@@ -1,360 +0,0 @@
|
||||
package de.superx.applet; |
||||
|
||||
import java.io.ByteArrayInputStream; |
||||
import java.io.IOException; |
||||
import java.sql.Date; |
||||
import java.sql.SQLException; |
||||
import java.util.HashMap; |
||||
import java.util.Iterator; |
||||
import java.util.Properties; |
||||
import java.util.Vector; |
||||
|
||||
import de.memtext.baseobjects.NamedObject; |
||||
import de.memtext.baseobjects.coll.NamedIdObjectSet; |
||||
import de.superx.common.SxResultRow; |
||||
import de.superx.common.XilParser; |
||||
import freemarker.template.TemplateException; |
||||
|
||||
public class MaskeninfoElement extends NamedObject { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
private Properties xilProps = new Properties(); |
||||
private Vector felderinfos; |
||||
private Integer tid, breite, hoehe; |
||||
private NamedIdObjectSet sachgebiete = new NamedIdObjectSet(); |
||||
private boolean isSqlInHeaders = false; |
||||
private Vector spaltenExplanations; // ,explanationsClone;
|
||||
private String xilPropListString, selectStmt, cleanupStmt, hinweis; |
||||
private Date stand; |
||||
private String erlaueterung; |
||||
private XilParser xilParser = new XilParser(); |
||||
private SxForm maskeForm; |
||||
|
||||
MaskeninfoElement() { |
||||
|
||||
} |
||||
|
||||
public void setMaskeForm(SxForm maskeForm) { |
||||
|
||||
this.maskeForm = maskeForm; |
||||
} |
||||
|
||||
/* |
||||
* MaskeninfoElement(Vector vectorMaskeninfoEntries) throws IOException { |
||||
* init(vectorMaskeninfoEntries); |
||||
* } |
||||
*/ |
||||
/** |
||||
* fieser Trick: es wird als letztes Element noch ein Vector mit |
||||
* Spaltenerläuterungen mitgeliefert |
||||
*/ |
||||
protected void init(Vector vectorMaskeninfoEntries) throws IOException { |
||||
// vector of vector
|
||||
Vector vectorCurrentMask = (Vector) vectorMaskeninfoEntries |
||||
.elementAt(0); |
||||
|
||||
setSelectStmt(vectorCurrentMask.elementAt(1)); |
||||
|
||||
setXilPropListString(vectorCurrentMask.elementAt(2)); |
||||
|
||||
setCleanupStmt(vectorCurrentMask.elementAt(3)); |
||||
setBreite((Integer) vectorCurrentMask.elementAt(4)); |
||||
|
||||
setHoehe((Integer) vectorCurrentMask.elementAt(5)); |
||||
|
||||
stand = new java.sql.Date(1); |
||||
Object tmpDate = vectorCurrentMask.elementAt(6); |
||||
if (tmpDate != null) { |
||||
try { |
||||
// für Informix
|
||||
stand = (java.sql.Date) tmpDate; |
||||
} catch (ClassCastException e) { |
||||
// für Access
|
||||
java.sql.Timestamp mytimestamp = (java.sql.Timestamp) tmpDate; |
||||
long mytimestampwert = mytimestamp.getTime(); |
||||
stand = new java.sql.Date(mytimestampwert); |
||||
} |
||||
|
||||
} |
||||
|
||||
setHinweis(vectorCurrentMask.elementAt(7)); |
||||
setErlaueterung((String) vectorCurrentMask.elementAt(8)); |
||||
// fieser Trick
|
||||
Object expl = vectorCurrentMask.elementAt(9); |
||||
if (!(expl instanceof SxResultRow)) { |
||||
String msg = "Es wurde ein ResultRow mit Erläuterungen erwartet (SuperXDBServlet. addExplanations). statt dessen wurde geliefert: "; |
||||
if (expl == null) |
||||
msg += "null"; |
||||
else |
||||
msg += " ein " + expl.getClass() + " :" + expl; |
||||
throw new IllegalArgumentException(msg); |
||||
} |
||||
spaltenExplanations = new Vector(); |
||||
spaltenExplanations |
||||
.addAll((SxResultRow) vectorCurrentMask.elementAt(9)); |
||||
// cloneExplanations();
|
||||
} |
||||
|
||||
boolean hasSpaltenExplanations() { |
||||
boolean result = false; |
||||
for (Iterator it = spaltenExplanations.iterator(); it.hasNext();) { |
||||
String expl = (String) it.next(); |
||||
if (expl != null && !expl.trim().equals("")) { |
||||
result = true; |
||||
break; |
||||
} |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
StringBuffer getSpaltenExplanationText() { |
||||
StringBuffer buf = new StringBuffer(""); |
||||
for (int i = 0; i < spaltenExplanations.size(); i++) { |
||||
String expl = (String) spaltenExplanations.get(i); |
||||
if (expl != null && !expl.trim().equals("")) |
||||
buf.append(expl + "<br><br>"); |
||||
} |
||||
|
||||
return buf; |
||||
} |
||||
|
||||
public void adaptExplanation(int pos, String neu) { |
||||
if (spaltenExplanations.size() > pos) { |
||||
String expl = (String) spaltenExplanations.get(pos); |
||||
if (expl.indexOf("</b>") > -1) { |
||||
expl = "<b>" + neu |
||||
+ expl.substring(expl.indexOf("</b>"), expl.length()); |
||||
System.out.println("neu:" + expl); |
||||
spaltenExplanations.setElementAt(expl, pos); |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
Integer getBreite() { |
||||
return breite; |
||||
} |
||||
|
||||
String getStandString() { |
||||
String d_str = ""; |
||||
if (getStand() != null) |
||||
d_str = SxDate.toString(getStand()); |
||||
return d_str; |
||||
} |
||||
|
||||
String getCleanupStmt() { |
||||
return cleanupStmt; |
||||
} |
||||
|
||||
String getHinweis() { |
||||
return hinweis; |
||||
} |
||||
|
||||
Integer getHoehe() { |
||||
return hoehe; |
||||
} |
||||
|
||||
String getSelectStmt() { |
||||
return selectStmt; |
||||
} |
||||
|
||||
Date getStand() { |
||||
return stand; |
||||
} |
||||
|
||||
Integer getTid() { |
||||
return tid; |
||||
} |
||||
|
||||
private String getTmpXilPropListString() throws TemplateException, |
||||
IOException, SQLException { |
||||
|
||||
String tmpxil = SxUtils.generateSQL(maskeForm, xilPropListString); |
||||
|
||||
|
||||
tmpxil = SxSQL.templateProcessor.process("XIL-Maske " + getName(), |
||||
tmpxil, |
||||
|
||||
maskeForm.getHashMap(getTid()), (String) SxDefaults.getPropertyValue("SxDB")); |
||||
ByteArrayInputStream bis = new ByteArrayInputStream(tmpxil.getBytes()); |
||||
|
||||
xilProps.load(bis); |
||||
return tmpxil; |
||||
} |
||||
|
||||
void setBreite(Integer integer) { |
||||
breite = integer; |
||||
} |
||||
|
||||
void setCleanupStmt(Object stmt) { |
||||
if (stmt == null) |
||||
stmt = ""; |
||||
cleanupStmt = (String) stmt; |
||||
} |
||||
|
||||
void setHinweis(Object hin) { |
||||
hinweis = null; |
||||
if (hin != null) |
||||
hinweis = hin.toString(); |
||||
} |
||||
|
||||
void setHoehe(Integer integer) { |
||||
hoehe = integer; |
||||
} |
||||
|
||||
void setSelectStmt(Object stmt) { |
||||
if (stmt == null) |
||||
throw new IllegalArgumentException( |
||||
"null ist nicht erlaubt für select stmt"); |
||||
selectStmt = (String) stmt; |
||||
} |
||||
|
||||
private void setStand(Date date) { |
||||
stand = date; |
||||
} |
||||
|
||||
void setTid(Integer integer) { |
||||
tid = integer; |
||||
} |
||||
|
||||
/** |
||||
* Hinterlegt die XIL-Proplist. Derzeit vom Applet nicht unterstützte |
||||
* colspan-Tags \000 werden entfernt |
||||
* |
||||
* @param xil |
||||
*/ |
||||
void setXilPropListString(Object xil) { |
||||
if (xil == null) |
||||
throw new IllegalArgumentException("null ist nicht erlaubt für xil"); |
||||
StringBuffer buf = new StringBuffer(xil.toString()); |
||||
de.memtext.util.StringUtils.replace(buf, "\\000", "\\n"); |
||||
|
||||
xilPropListString = buf.toString(); |
||||
xilParser.setXilString(xilPropListString); |
||||
} |
||||
|
||||
/** |
||||
* wird nur zum Auslesen des Parameters fixed_columns benötigt |
||||
* |
||||
* @return |
||||
*/ |
||||
Properties getXilProps() { |
||||
return xilProps; |
||||
} |
||||
|
||||
Vector getFelderinfos() { |
||||
return felderinfos; |
||||
} |
||||
|
||||
void setFelderinfos(Vector vector) { |
||||
felderinfos = vector; |
||||
} |
||||
|
||||
void clear() { |
||||
felderinfos = null; |
||||
tid = breite = hoehe = null; |
||||
xilPropListString = selectStmt = cleanupStmt = hinweis = null; |
||||
stand = null; |
||||
} |
||||
|
||||
/** |
||||
* not currently needed |
||||
* |
||||
* @throws SQLException |
||||
*/ |
||||
void readSachgebiete() throws SQLException { |
||||
sachgebiete.clear(); |
||||
SxSQL |
||||
.executeQuery("select sachgebiete_id from sachgeb_maske_bez where maskeninfo_id=" |
||||
+ getTid()); |
||||
Sachgebiet sachgeb; |
||||
for (Iterator iter = SxSQL.getResultVector().iterator(); iter.hasNext();) { |
||||
Vector row = (Vector) iter.next(); |
||||
sachgeb = (Sachgebiet) Sachgebiete.getById(row.get(0)); |
||||
sachgebiete.add(sachgeb); |
||||
} |
||||
} |
||||
|
||||
boolean isSqlInHeaders() throws TemplateException, IOException, |
||||
SQLException { |
||||
// sets the boolean properly
|
||||
getHeaderVector(); |
||||
return isSqlInHeaders; |
||||
} |
||||
|
||||
/** |
||||
* Gets a Vector with the column names for the table header. also sets |
||||
* boolean isSqlInHeaders |
||||
* |
||||
* @return |
||||
* @throws SQLException |
||||
* @throws IOException |
||||
* @throws TemplateException |
||||
*/ |
||||
Vector getHeaderVector() throws TemplateException, IOException, |
||||
SQLException { |
||||
Vector header = new Vector(); |
||||
int pos = 0; |
||||
int end_pos = 0; |
||||
int offset = 0; |
||||
String tmpxil = getTmpXilPropListString(); |
||||
int len = tmpxil.length(); |
||||
String search_str = "heading_text=\""; |
||||
String header_str = null; |
||||
int search_len = search_str.length(); |
||||
isSqlInHeaders = false; |
||||
while (offset < len) { |
||||
if ((pos = tmpxil.indexOf(search_str, offset)) != -1) { |
||||
if ((end_pos = tmpxil.indexOf("\"", pos + search_len)) != -1) { |
||||
header_str = tmpxil.substring(pos + search_len, end_pos); |
||||
if (header_str.trim().startsWith("<<SQL>>")) |
||||
isSqlInHeaders = true; |
||||
header.addElement(header_str); |
||||
offset = pos + search_len + header_str.length() + 1; |
||||
} else |
||||
break; |
||||
} else |
||||
break; |
||||
} |
||||
|
||||
return header; |
||||
} |
||||
|
||||
Vector getWidthVector() throws TemplateException, IOException, SQLException { |
||||
xilParser.setXilString(getTmpXilPropListString()); |
||||
return xilParser.getWidths(); |
||||
} |
||||
|
||||
/** |
||||
* @return Returns the erlaueterung. |
||||
*/ |
||||
public String getErlaueterung() { |
||||
return erlaueterung; |
||||
} |
||||
|
||||
/** |
||||
* @param erlaueterung |
||||
* The erlaueterung to set. |
||||
*/ |
||||
public void setErlaueterung(String erlaueterung) { |
||||
this.erlaueterung = erlaueterung; |
||||
} |
||||
|
||||
/* |
||||
* public void cloneExplanations() { explanationsClone=new Vector(); for |
||||
* (Iterator it = spaltenExplanations.iterator(); it.hasNext();) { String |
||||
* element = (String) it.next(); explanationsClone.add(new String(element)); } } |
||||
*/ |
||||
public int getFixedColumns() { |
||||
|
||||
String fx = this.getXilProps().getProperty("fixed_columns", "1"); |
||||
int fc = Integer.parseInt(fx); |
||||
if (fc == 1 |
||||
&& xilPropListString.toLowerCase().indexOf("\"ebene\"") > -1) { |
||||
fc = 2; |
||||
} |
||||
return fc; |
||||
} |
||||
} |
||||
|
||||
// Created on 30.11.2003 at 17:59:08
|
@ -1,16 +0,0 @@
@@ -1,16 +0,0 @@
|
||||
package de.superx.applet; |
||||
import de.memtext.baseobjects.NamedIdObject; |
||||
/** |
||||
* not currently needed |
||||
* see SuperX.isSachgebieteNeeded |
||||
*/ |
||||
public class Sachgebiet extends NamedIdObject { |
||||
|
||||
public Sachgebiet(Object id, String name) { |
||||
super(id, name); |
||||
} |
||||
|
||||
|
||||
} |
||||
|
||||
//Created on 20.11.2003
|
@ -1,53 +0,0 @@
@@ -1,53 +0,0 @@
|
||||
package de.superx.applet; |
||||
|
||||
import java.sql.SQLException; |
||||
import java.util.Iterator; |
||||
|
||||
import de.memtext.baseobjects.NamedIdObjectI; |
||||
import de.memtext.baseobjects.coll.NamedIdObjectSet; |
||||
import de.superx.common.SxResultRow; |
||||
import de.superx.common.SxResultSet; |
||||
/** |
||||
* Not currently needed! |
||||
* see SuperX.isSachgebieteNeeded |
||||
*/ |
||||
public class Sachgebiete { |
||||
|
||||
static NamedIdObjectSet _set = new NamedIdObjectSet(); |
||||
private Sachgebiete() { |
||||
} |
||||
public static void set(NamedIdObjectSet set) { |
||||
_set = set; |
||||
} |
||||
public static NamedIdObjectI getById(Object id) { |
||||
if (_set == null) |
||||
throw new IllegalStateException("list not set"); |
||||
NamedIdObjectI result = null; |
||||
try { |
||||
result = _set.getById(id); |
||||
|
||||
} catch (IllegalArgumentException e) { |
||||
throw new IllegalArgumentException( |
||||
"Es gibt kein Sachgebiet mit der Nummer " + id); |
||||
} |
||||
return result; |
||||
} |
||||
public static NamedIdObjectSet getSet() { |
||||
return _set; |
||||
} |
||||
public static void init() throws SQLException { |
||||
_set.clear(); |
||||
SxSQL.executeQuery("select tid,name from sachgebiete"); |
||||
SxResultSet result = SxSQL.getResult(); |
||||
for (Iterator iter = result.iterator(); iter.hasNext();) { |
||||
SxResultRow row = (SxResultRow) iter.next(); |
||||
_set.add( |
||||
new Sachgebiet( |
||||
(Integer) row.get(0), |
||||
row.get(1).toString())); |
||||
} |
||||
|
||||
} |
||||
} |
||||
|
||||
//Created on 19.11.2003
|
@ -1,231 +0,0 @@
@@ -1,231 +0,0 @@
|
||||
package de.superx.applet; |
||||
|
||||
import java.awt.Component; |
||||
import java.io.IOException; |
||||
import java.sql.SQLException; |
||||
import java.util.Enumeration; |
||||
import java.util.HashMap; |
||||
import java.util.Hashtable; |
||||
import java.util.Vector; |
||||
|
||||
import javax.swing.Icon; |
||||
import javax.swing.JDialog; |
||||
import javax.swing.JOptionPane; |
||||
import javax.swing.JTree; |
||||
import javax.swing.tree.DefaultMutableTreeNode; |
||||
import javax.swing.tree.DefaultTreeCellRenderer; |
||||
import javax.swing.tree.DefaultTreeModel; |
||||
import javax.swing.tree.TreePath; |
||||
|
||||
import de.memtext.tree.HideableNode; |
||||
import de.superx.common.AbstractSicht; |
||||
import de.superx.common.FieldContainer; |
||||
import de.superx.common.SelectableItemTree; |
||||
import de.superx.common.Sichten; |
||||
import de.superx.common.SxResultSet; |
||||
import de.superx.servlet.SxPools; |
||||
import de.superx.util.SqlStringUtils; |
||||
import freemarker.template.TemplateException; |
||||
|
||||
/** |
||||
* Implementierung für den Einsatz im Applet |
||||
*/ |
||||
public class SichtApplet extends AbstractSicht { |
||||
|
||||
private static final long serialVersionUID = 1; |
||||
|
||||
public SichtApplet(Sichten sichten, Object id, String name) { |
||||
super(sichten, id, name); |
||||
setCellRenderer(new SxTreeRenderer()); |
||||
} |
||||
|
||||
/** |
||||
* just for cloning |
||||
* |
||||
* @param id |
||||
* @param name |
||||
* @param model |
||||
*/ |
||||
private SichtApplet(Sichten sichten, Object id, String name, |
||||
DefaultTreeModel model) { |
||||
super(sichten, id, name, model); |
||||
setCellRenderer(new SxTreeRenderer()); |
||||
} |
||||
|
||||
protected SxResultSet readFromDb(String sql) throws SQLException { |
||||
SxSQL.executeAll(sql); |
||||
SxResultSet rohform = SxSQL.getResult(); |
||||
SxSQL.close(); |
||||
return rohform; |
||||
} |
||||
|
||||
public void searchEntries(String such) { |
||||
String teststring; |
||||
TreePath tp; |
||||
boolean gefunden = false; |
||||
DefaultMutableTreeNode test, ausgesucht; |
||||
ausgesucht = null; |
||||
Vector treffer = new Vector(); |
||||
Vector treffernodes = new Vector(); |
||||
|
||||
// alle Knoten durchlaufen
|
||||
|
||||
Enumeration en = getRoot().breadthFirstEnumeration(); |
||||
while (en.hasMoreElements()) { |
||||
test = (DefaultMutableTreeNode) en.nextElement(); |
||||
if (test instanceof HideableNode |
||||
&& ((HideableNode) test).isHidden()) |
||||
continue; |
||||
teststring = test.toString().toLowerCase(); |
||||
|
||||
if (teststring.indexOf(such) > -1) { |
||||
// wenn suchString im aktuellen Knoten vorhanden
|
||||
// K
|
||||
if (test != getRoot()) { |
||||
treffer.addElement(test.toString()); |
||||
treffernodes.addElement(test); |
||||
} |
||||
} |
||||
} |
||||
if (treffer.size() > 0) { |
||||
if (treffer.size() > 1) { |
||||
// mehr als ein Treffer -> Auswahldialog
|
||||
Object[] 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]); |
||||
|
||||
/* |
||||
* String selectedValue = (String) JOptionPane.showInputDialog( |
||||
* 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
|
||||
// if (!tree.isSelectionEmpty()) tree.clearSelection();
|
||||
en = getRoot().depthFirstEnumeration(); |
||||
while (en.hasMoreElements()) { |
||||
test = (DefaultMutableTreeNode) en.nextElement(); |
||||
tp = new TreePath(test.getPath()); |
||||
|
||||
if (test != getRoot() && isExpanded(tp)) |
||||
collapsePath(tp); |
||||
} |
||||
|
||||
tp = new TreePath(ausgesucht.getPath()); |
||||
addSelectionPath(tp); |
||||
scrollPathToVisible(tp); |
||||
|
||||
validate(); |
||||
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; |
||||
} |
||||
|
||||
/** |
||||
* Im Xml-Frontend wird membervariable userid der AbstractSicht benutzt, |
||||
* hier wird getUserId() überschrieben, um Applet-spezifisch UseriD aus |
||||
* SxSQl zu holen |
||||
*/ |
||||
public Integer getUserid() { |
||||
return SxSQL.getUserID(); |
||||
} |
||||
|
||||
protected String getSqlDialect() { |
||||
String result = (String) SxDefaults.getPropertyValue("SxDB"); |
||||
return result; |
||||
|
||||
} |
||||
|
||||
public Object clone() throws CloneNotSupportedException { |
||||
SelectableItemTree st = (SelectableItemTree) super.clone(); |
||||
SichtApplet cl = new SichtApplet(sichten, getId(), getName(), |
||||
(DefaultTreeModel) st.getModel()); |
||||
finishClone(cl); |
||||
return cl; |
||||
} |
||||
|
||||
private class SxTreeRenderer extends DefaultTreeCellRenderer { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
public SxTreeRenderer() { |
||||
} |
||||
|
||||
|
||||
public Component getTreeCellRendererComponent(JTree jtree, Object obj, |
||||
boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { |
||||
|
||||
if (!((DefaultMutableTreeNode)obj).isLeaf()) |
||||
{ |
||||
boolean isAllChildrenHidden=true; |
||||
for(Enumeration en=((DefaultMutableTreeNode)obj).children();en.hasMoreElements();) |
||||
{ |
||||
Object o=en.nextElement(); |
||||
if (!(o instanceof HideableNode)||!((HideableNode)o).isHidden()) |
||||
isAllChildrenHidden=false; |
||||
} |
||||
if (isAllChildrenHidden) {leaf=true;expanded=true;} |
||||
} |
||||
super.getTreeCellRendererComponent(jtree, obj, sel,expanded,leaf,row,hasFocus); |
||||
|
||||
return this; |
||||
} |
||||
} |
||||
/** |
||||
* von Applet nicht unterstützt |
||||
*/ |
||||
public String dynamicSichtGenerateSql(Hashtable formular,String sql) { |
||||
return sql; |
||||
|
||||
} |
||||
/** |
||||
* von Applet nicht unterstützt |
||||
*/ |
||||
public String dynmicSichtFMParsing(HashMap map, |
||||
FieldContainer individualFields, String sql) |
||||
throws TemplateException, IOException, SQLException { |
||||
|
||||
return sql; |
||||
} |
||||
} |
@ -1,314 +0,0 @@
@@ -1,314 +0,0 @@
|
||||
package de.superx.applet; |
||||
|
||||
import java.awt.Image; |
||||
import java.awt.MediaTracker; |
||||
import java.awt.image.ImageObserver; |
||||
import java.awt.image.PixelGrabber; |
||||
import java.util.Hashtable; |
||||
|
||||
import javax.swing.ImageIcon; |
||||
import javax.swing.JApplet; |
||||
import javax.swing.UIManager; |
||||
|
||||
import de.memtext.util.HtmlUtils; |
||||
import de.memtext.widgets.WarningMessage; |
||||
import de.superx.common.SxUser; |
||||
|
||||
/** |
||||
* Hauptklasse von SuperX, mit der SuperX als Applet oder als Applikation |
||||
* aufgerufen werden kann. |
||||
* |
||||
* @version 2.0 01/01/02 |
||||
* @author Rainer Behr, erweitert von Marlies Winterstein, Meikel Bisping |
||||
*/ |
||||
|
||||
public class SuperX extends JApplet { |
||||
static boolean isSachgebieteNeeded = false; |
||||
static boolean isZukünftigerStandErlaubt=true; |
||||
ImageIcon logo_img = new ImageIcon(); |
||||
ImageIcon connect_img = new ImageIcon(); |
||||
ImageIcon disconnect_img = new ImageIcon(); |
||||
ImageIcon passwd_img = new ImageIcon(); |
||||
ImageIcon clone_img = new ImageIcon(); |
||||
ImageIcon copy_img = new ImageIcon(); |
||||
ImageIcon save_img = new ImageIcon(); |
||||
ImageIcon print_img = new ImageIcon(); |
||||
ImageIcon info_img = new ImageIcon(); |
||||
//Wint
|
||||
ImageIcon help_img = new ImageIcon(); |
||||
Hashtable img_map = new Hashtable(); |
||||
|
||||
static boolean isAuthentificationFound = false; |
||||
static String remoteUser=null; |
||||
private SxMask sxMask; |
||||
|
||||
public void destroy() { |
||||
sxMask.close(); |
||||
} |
||||
|
||||
public void init() { |
||||
|
||||
initImages(); |
||||
String docBase = HtmlUtils.getCorretDocBase(this); |
||||
|
||||
String prop_file = docBase + "superx.properties"; |
||||
//System.out.println("prop_file: " + prop_file); //Wint
|
||||
//Stuttgart verwendet http://superx/superx/applet/...
|
||||
int pos = docBase.lastIndexOf("/superx/"); |
||||
String defaultServerUrl = null; |
||||
if (pos > 0) { |
||||
defaultServerUrl = docBase.substring(0, pos) |
||||
+ "/superx/servlet/SuperXDBServlet"; |
||||
//System.out.println("default URL of Servlet: "+defaultServerUrl);
|
||||
} else { |
||||
System.out |
||||
.println("Can't identify SxServerURL automatically, since CodeBase "+docBase+ " doesn't contain /superx/ SxServerURL has to be specified in superx.properties"); |
||||
} |
||||
SxDefaults.setDefaultServerUrl(defaultServerUrl); |
||||
SxDefaults.setPropertyFile(prop_file); |
||||
|
||||
sxMask = new SxMask("SuperX @version@", img_map, true); |
||||
//sxMask = new SxMask("SuperX 2.04", img_map, true);
|
||||
|
||||
} |
||||
|
||||
private void initImages() { |
||||
PixelGrabber pg = null; |
||||
|
||||
try { |
||||
UIManager |
||||
.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); |
||||
} catch (Exception ex) { |
||||
System.err.println("WindowsLookAndFeel nicht verfügbar"); |
||||
} |
||||
|
||||
try { |
||||
Image logo_icon, connect_icon, disconnect_icon, passwd_icon; |
||||
Image clone_icon, copy_icon, save_icon, print_icon, info_icon; |
||||
|
||||
Image help_icon; |
||||
String img_path = "images"; |
||||
// der ClassLoader steht ganz oben also auf gleicher Ebene wie de
|
||||
//und sucht images im Unterverzeichnis /images
|
||||
//de
|
||||
//images
|
||||
ClassLoader cl = getClass().getClassLoader(); |
||||
logo_icon = getImage(cl.getResource(img_path + "/superx.gif")); |
||||
disconnect_icon = getImage(cl.getResource(img_path |
||||
+ "/disconnect.gif")); |
||||
connect_icon = getImage(cl.getResource(img_path + "/connect.gif")); |
||||
passwd_icon = getImage(cl.getResource(img_path + "/passwd.gif")); |
||||
clone_icon = getImage(cl.getResource(img_path + "/clone.gif")); |
||||
copy_icon = getImage(cl.getResource(img_path + "/sx_copy.gif")); |
||||
save_icon = getImage(cl.getResource(img_path + "/sx_save.gif")); |
||||
print_icon = getImage(cl.getResource(img_path + "/sx_print.gif")); |
||||
info_icon = getImage(cl.getResource(img_path + "/info.gif")); |
||||
//Wint
|
||||
help_icon = getImage(cl.getResource(img_path + "/help.gif")); |
||||
MediaTracker tracker = new MediaTracker(this); |
||||
tracker.addImage(logo_icon, 0); |
||||
tracker.addImage(disconnect_icon, 1); |
||||
tracker.addImage(connect_icon, 2); |
||||
tracker.addImage(clone_icon, 3); |
||||
tracker.addImage(copy_icon, 4); |
||||
tracker.addImage(save_icon, 5); |
||||
tracker.addImage(print_icon, 6); |
||||
tracker.addImage(help_icon, 7); |
||||
tracker.addImage(info_icon, 8); |
||||
tracker.addImage(passwd_icon, 9); |
||||
tracker.waitForAll(0); |
||||
if (logo_icon == null) |
||||
System.out.println("superx.gif nicht gefunden"); |
||||
logo_img = new ImageIcon(logo_icon); |
||||
disconnect_img = new ImageIcon(disconnect_icon); |
||||
connect_img = new ImageIcon(connect_icon); |
||||
passwd_img = new ImageIcon(passwd_icon); |
||||
clone_img = new ImageIcon(clone_icon); |
||||
copy_img = new ImageIcon(copy_icon); |
||||
save_img = new ImageIcon(save_icon); |
||||
print_img = new ImageIcon(print_icon); |
||||
info_img = new ImageIcon(info_icon); |
||||
//Wint
|
||||
help_img = new ImageIcon(help_icon); |
||||
|
||||
img_map.put("disconnect", disconnect_img); |
||||
img_map.put("connect", connect_img); |
||||
img_map.put("passwd", passwd_img); |
||||
img_map.put("clone", clone_img); |
||||
img_map.put("copy", copy_img); |
||||
img_map.put("save", save_img); |
||||
img_map.put("print", print_img); |
||||
img_map.put("info", info_img); |
||||
//Wint
|
||||
img_map.put("help", help_img); |
||||
|
||||
int logow, logoh; |
||||
logow = logo_img.getIconWidth(); |
||||
logoh = logo_img.getIconWidth(); |
||||
int[] pixelarray = new int[logow * logoh]; |
||||
|
||||
pg = new PixelGrabber(logo_img.getImage(), 0, 0, logow, logoh, |
||||
pixelarray, 0, logow); |
||||
if (!pg.grabPixels()) |
||||
System.err.println("init: grabPixels() failed"); |
||||
else |
||||
img_map.put("logo_pixels", pixelarray); |
||||
|
||||
img_map.put("logo", logo_img); |
||||
} catch (InterruptedException ex) { |
||||
System.err.println(ex.toString()); |
||||
} |
||||
|
||||
if ((pg.getStatus() & ImageObserver.ABORT) != 0) { |
||||
System.err.println("image fetch aborted or error: " |
||||
+ pg.getStatus()); |
||||
} |
||||
} |
||||
|
||||
public static void main(String s[]) { |
||||
System.out.println("SuperX @version@ (build:@sxtimestamp@)"); |
||||
|
||||
PixelGrabber pg = null; |
||||
final SxMask sxMask; |
||||
final Hashtable img_map = new Hashtable(); |
||||
final ImageIcon logo_img; |
||||
final ImageIcon disconnect_img; |
||||
final ImageIcon connect_img; |
||||
final ImageIcon passwd_img; |
||||
final ImageIcon clone_img; |
||||
final ImageIcon copy_img; |
||||
final ImageIcon save_img; |
||||
final ImageIcon print_img; |
||||
final ImageIcon info_img; |
||||
//Wint
|
||||
final ImageIcon help_img; |
||||
|
||||
try { |
||||
UIManager |
||||
.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); |
||||
//UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
|
||||
//UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
|
||||
|
||||
} catch (Exception ex) { |
||||
// System.err.println ("MacLookAndFeel not available: " +
|
||||
// ex.toString());
|
||||
System.err.println("WindowsLookAndFeel not available: " |
||||
+ ex.toString()); |
||||
} |
||||
|
||||
initImagesWhenApplication(img_map); |
||||
|
||||
SxDefaults |
||||
.setDefaultServerUrl("http://localhost:8080/superx/servlet/SuperXDBServlet"); |
||||
//System.out.println("Hinweis: Wenn kein Eintrag für SxServerUrl in
|
||||
// superx.properties wird mit
|
||||
// http://localhost:8080/superx/servlet/SuperXDBServlet gearbeitet");
|
||||
SxDefaults.setPropertyFile("file:superx.properties"); |
||||
|
||||
sxMask = new SxMask("SuperX @version@", img_map, false); |
||||
|
||||
|
||||
|
||||
sxMask.open(); |
||||
} |
||||
|
||||
private static void initImagesWhenApplication(final Hashtable img_map) { |
||||
PixelGrabber pg; |
||||
final ImageIcon logo_img; |
||||
final ImageIcon disconnect_img; |
||||
final ImageIcon connect_img; |
||||
final ImageIcon passwd_img; |
||||
final ImageIcon clone_img; |
||||
final ImageIcon copy_img; |
||||
final ImageIcon save_img; |
||||
final ImageIcon print_img; |
||||
final ImageIcon info_img; |
||||
final ImageIcon help_img; |
||||
String img_dir = "images"; |
||||
logo_img = new ImageIcon(img_dir + "/superx.gif"); |
||||
disconnect_img = new ImageIcon(img_dir + "/disconnect.gif"); |
||||
connect_img = new ImageIcon(img_dir + "/connect.gif"); |
||||
passwd_img = new ImageIcon(img_dir + "/passwd.gif"); |
||||
clone_img = new ImageIcon(img_dir + "/clone.gif"); |
||||
copy_img = new ImageIcon(img_dir + "/sx_copy.gif"); |
||||
save_img = new ImageIcon(img_dir + "/sx_save.gif"); |
||||
print_img = new ImageIcon(img_dir + "/sx_print.gif"); |
||||
info_img = new ImageIcon(img_dir + "/info.gif"); |
||||
//Wint
|
||||
help_img = new ImageIcon(img_dir + "/help.gif"); |
||||
|
||||
int logow, logoh; |
||||
logow = logo_img.getIconWidth(); |
||||
logoh = logo_img.getIconWidth(); |
||||
int[] pixelarray = new int[logow * logoh]; |
||||
|
||||
try { |
||||
pg = new PixelGrabber(logo_img.getImage(), 0, 0, logow, logoh, |
||||
pixelarray, 0, logow); |
||||
if (!pg.grabPixels()) |
||||
System.err.println("init: grabPixels() failed"); |
||||
else |
||||
img_map.put("logo_pixels", pixelarray); |
||||
} catch (InterruptedException ie) { |
||||
System.err.println(ie); |
||||
} |
||||
|
||||
img_map.put("logo", logo_img); |
||||
img_map.put("disconnect", disconnect_img); |
||||
img_map.put("connect", connect_img); |
||||
img_map.put("passwd", passwd_img); |
||||
img_map.put("clone", clone_img); |
||||
img_map.put("copy", copy_img); |
||||
img_map.put("save", save_img); |
||||
img_map.put("print", print_img); |
||||
img_map.put("info", info_img); |
||||
//Wint
|
||||
img_map.put("help", help_img); |
||||
} |
||||
|
||||
public void start() { |
||||
String zukünftigerStandErlaubt=getParameter("zukünftigerStandErlaubt"); |
||||
if (zukünftigerStandErlaubt!=null&&zukünftigerStandErlaubt.equals("false")) |
||||
isZukünftigerStandErlaubt=false; |
||||
SuperX.isAuthentificationFound=false; |
||||
String jsessionid = getParameter("jsessionid"); |
||||
remoteUser=getParameter("remoteUser"); |
||||
if (remoteUser==null||remoteUser.equals("")||remoteUser.equals("null")) |
||||
remoteUser=null; |
||||
SxDefaults.init(); |
||||
try { |
||||
if (jsessionid != null && !jsessionid.trim().equals("")) { |
||||
// && userid != null && !userid.trim().equals("")) {
|
||||
SuperX.isAuthentificationFound = true; |
||||
SxSQL.jsessionid = jsessionid; |
||||
|
||||
String userstr = SxSQL.getUserFromServlet(); |
||||
if (userstr != null) { |
||||
String userid = userstr.substring(0, userstr.indexOf("|")); |
||||
String kennung = userstr.substring(userstr.indexOf("|") + 1,userstr.indexOf("^")); |
||||
String admin=userstr.substring(userstr.indexOf("^")+1); |
||||
|
||||
SxSQL.setUserID(new Integer(Integer.parseInt(userid))); |
||||
SxUser user=new SxUser("default", kennung, new Integer(Integer |
||||
.parseInt(userid))); // kein Mandantenbetrieb bei Applet
|
||||
if (admin.equals("1")) user.setAdmin(true); |
||||
//sxMask.setUser(new SxUser(getParameter("kennung"), new
|
||||
// Integer(Integer.parseInt(userid))));
|
||||
sxMask.setUser(user); |
||||
// sxMask.setConnectPwBtnsSVisible(false);
|
||||
int mode = 0;//anmelden
|
||||
sxMask.initUser(mode); |
||||
} |
||||
} |
||||
|
||||
SxSQL.initParams(); |
||||
sxMask.open(); |
||||
|
||||
} catch (Exception e) { |
||||
WarningMessage.show(this, "Anmeldung fehlgeschlagen.\n" + e, |
||||
"SuperX"); |
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
} |
||||
} |
@ -1,96 +0,0 @@
@@ -1,96 +0,0 @@
|
||||
package de.superx.applet; |
||||
import java.text.DateFormat; |
||||
import java.text.ParseException; |
||||
import java.util.Calendar; |
||||
import java.util.GregorianCalendar; |
||||
import java.util.TimeZone; |
||||
|
||||
/** |
||||
* Statische Klasse mit Hilfsfunktionen für Datumsobjekte. |
||||
* |
||||
* @version 2.0 01/01/02 |
||||
* @author Rainer Behr, modified by Meikel Bisping |
||||
*/ |
||||
|
||||
public class SxDate { |
||||
static DateFormat df; |
||||
static java.util.Date date; |
||||
static java.sql.Date sql_date; |
||||
static Calendar calendar; |
||||
|
||||
static { |
||||
df = DateFormat.getDateInstance(DateFormat.MEDIUM); |
||||
// r.b. default Jahr 4-stellig
|
||||
df.setTimeZone(TimeZone.getDefault()); |
||||
df.setLenient(false); |
||||
} |
||||
|
||||
/** |
||||
* Wandelt einen String in ein java.sql.Date-Objekt um. |
||||
* @param value umzuformender String |
||||
* @return java.sql.Date-Objekt. Wenn der String nicht in Ordnung ist, wird NULL zurückgeliefert. |
||||
*/ |
||||
public static java.sql.Date getDate(String value) { |
||||
try { |
||||
if (value.endsWith("00")) { |
||||
switch (value.charAt(value.length() - 3)) { |
||||
case '-' : |
||||
case '.' : |
||||
case '/' : |
||||
value = value.substring(0, value.length() - 2) + "2000"; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
date = df.parse(value); |
||||
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); |
||||
|
||||
sql_date = new java.sql.Date(calendar.getTime().getTime()); |
||||
return sql_date; |
||||
} catch (ParseException e_parse) { |
||||
// System.err.println ("SxDate: ERROR: parse: Date != " + value);
|
||||
} catch (IllegalArgumentException e_arg) { |
||||
// System.err.println ("SxDate: ERROR: arg: Date != " + value);
|
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
/** |
||||
* Wandelt ein java.sql.Date-Objekt in einen String um. |
||||
* @param value umzuwandelndes sql.Date-Objekt |
||||
* @return String |
||||
*/ |
||||
|
||||
public static String toString(java.sql.Date aDate) { |
||||
return df.format((java.util.Date) aDate); |
||||
} |
||||
|
||||
|
||||
public static String getNowString() { |
||||
GregorianCalendar cal = new GregorianCalendar(); |
||||
String jetzt = |
||||
cal.get(Calendar.DATE) |
||||
+ "." |
||||
+ (cal.get(Calendar.MONTH) + 1) |
||||
+ "." |
||||
+ cal.get(Calendar.YEAR) |
||||
+ " " |
||||
+ (cal.get(Calendar.HOUR_OF_DAY)) |
||||
+ ":" |
||||
+ cal.get(Calendar.MINUTE) |
||||
+ ":" |
||||
+ cal.get(Calendar.SECOND); |
||||
|
||||
|
||||
return jetzt; |
||||
} |
||||
|
||||
|
||||
} |
@ -1,165 +0,0 @@
@@ -1,165 +0,0 @@
|
||||
package de.superx.applet; |
||||
|
||||
import java.io.IOException; |
||||
import java.io.InputStream; |
||||
import java.net.URL; |
||||
import java.util.Enumeration; |
||||
import java.util.Hashtable; |
||||
import java.util.Properties; |
||||
|
||||
import javax.swing.JOptionPane; |
||||
|
||||
/** |
||||
* Defaultwerte werden aus superx.properties-Datei eingelesen (der wichtigste |
||||
* Wert ist SxServerURL, die URL des Servlets). <br> |
||||
* Weiterhin werden Defaultwerte von Auswahlfeldern (wie Semester oder |
||||
* Hörerstatus) abgelegt und wieder abgerufen.Diese Funktion wird in SxForm |
||||
* genutzt. |
||||
* |
||||
* @version 1.0 23.4.99 |
||||
* @author Rainer Behr |
||||
*/ |
||||
public class SxDefaults { |
||||
static Hashtable defaults_map; |
||||
static String propertyFile; |
||||
static String defaultServerUrl; |
||||
static { |
||||
defaults_map = new Hashtable(); |
||||
propertyFile = null; |
||||
} |
||||
|
||||
public static void setPropertyFile(String file) { |
||||
propertyFile = new String(file); |
||||
} |
||||
|
||||
public static void setDefaultServerUrl(String url) { |
||||
defaultServerUrl = url; |
||||
} |
||||
|
||||
public static void addProperty(String name, Object nkey, Object nvalue) { |
||||
Properties prop = new Properties(); |
||||
prop.put("key", nkey); |
||||
prop.put("value", nvalue); |
||||
|
||||
defaults_map.put(name, prop); |
||||
} |
||||
|
||||
public static Properties getProperty(String name) { |
||||
Properties prop = (Properties) defaults_map.get(name); |
||||
return prop; |
||||
|
||||
} |
||||
|
||||
public static Object getPropertyValue(String name) { |
||||
Properties prop = (Properties) defaults_map.get(name); |
||||
if (prop != null) |
||||
return prop.getProperty("value"); |
||||
else { |
||||
String msg = "Property '" + name |
||||
+ "' in 'superx.properties' nicht gefunden !"; |
||||
throw new NullPointerException(msg); |
||||
} |
||||
} |
||||
|
||||
public static void contents() { |
||||
Enumeration en; |
||||
Properties prop; |
||||
String name; |
||||
Object key; |
||||
Object value; |
||||
|
||||
en = defaults_map.keys(); |
||||
|
||||
while (en.hasMoreElements()) { |
||||
name = (String) en.nextElement(); |
||||
prop = (Properties) SxDefaults.getProperty(name); |
||||
if (prop == null) |
||||
continue; |
||||
key = prop.get("key"); |
||||
value = prop.get("value"); |
||||
//System.out.println (name + ": key=" + key.toString() + ", value="
|
||||
// + value.toString());
|
||||
} |
||||
} |
||||
|
||||
public static void clear() { |
||||
defaults_map.clear(); |
||||
defaults_map = new Hashtable(); |
||||
|
||||
init(); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Setzt auch mandantenID in SxSQL falls angegeben |
||||
* |
||||
*/ |
||||
public static void init() { |
||||
// Default Properties
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
String prop_file; |
||||
Properties props = new Properties(); |
||||
int b_len = 0; |
||||
|
||||
if (propertyFile != null) |
||||
prop_file = propertyFile; |
||||
else |
||||
prop_file = "file:superx.properties"; |
||||
|
||||
try { |
||||
URL props_url = new URL(prop_file); |
||||
InputStream is = props_url.openStream(); |
||||
if (is == null) { |
||||
String msg = "Ressourcedatei '" + prop_file |
||||
+ "' nicht gefunden. "; |
||||
throw new IOException(msg); |
||||
/* Möglichkeit aus System-properties zu lesen, wenn |
||||
* jnlp Datei als Application |
||||
* Versuche aus System-properties zu lesen"; |
||||
System.out.println(msg); |
||||
//MB 2/2016 versuch
|
||||
props.put("logToKonsole",System.getProperty("logToKonsole")); |
||||
props.put("SxTitle",System.getProperty("SxTitle")); |
||||
props.put("SxDB",System.getProperty("SxDB")); |
||||
props.put("SxParamStart",System.getProperty("SxParamStart")); |
||||
props.put("SxParamEnd",System.getProperty("SxParamEnd")); |
||||
props.put("SxParamBoldOn",System.getProperty("SxParamBoldOn")); |
||||
props.put("SxParamBoldOff",System.getProperty("SxParamBoldOff")); |
||||
*/ |
||||
} |
||||
|
||||
props.load(is); |
||||
is.close(); |
||||
|
||||
if (props.getProperty("SxServerURL") == null) |
||||
props.setProperty("SxServerURL", defaultServerUrl); |
||||
// Properties in Class SxDefaults einfuegen
|
||||
String key; |
||||
String value; |
||||
Enumeration en = props.propertyNames(); |
||||
|
||||
//if no special value was speficied for the ServerUrl, use the
|
||||
// default
|
||||
String mandantenID="default"; |
||||
while (en.hasMoreElements()) { |
||||
key = (String) en.nextElement(); |
||||
value = (String) props.getProperty(key); |
||||
if (key.equals("MandantenID")) |
||||
mandantenID=value; |
||||
addProperty(key, key, value); |
||||
} |
||||
//Zuweisung darf erst hier passieren,
|
||||
//sonst Probleme mit statischen Vars in SxSQL
|
||||
SxSQL.mandantenID=mandantenID; |
||||
} catch (IOException ex) { |
||||
System.err.println(ex); |
||||
JOptionPane.showMessageDialog(null, ex.toString(), "Fehler", |
||||
JOptionPane.ERROR_MESSAGE); |
||||
} |
||||
} |
||||
|
||||
public static void removeProperty(String name) { |
||||
defaults_map.remove(name); |
||||
} |
||||
} |
@ -1,49 +0,0 @@
@@ -1,49 +0,0 @@
|
||||
package de.superx.applet; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.util.Vector; |
||||
|
||||
/** |
||||
* |
||||
* Listener für den Löschen-Button bei einer Mehrfachauswahl. |
||||
* @version 1.0 15.09.00 |
||||
* @author Rainer Behr |
||||
* @see SxDlg |
||||
*/ |
||||
|
||||
public class SxDeleteListener implements ActionListener { |
||||
SxTablePanel sxTablePanel; |
||||
|
||||
SxDeleteListener() { |
||||
sxTablePanel = SxDlgManager.getChoiceTable(); |
||||
}; |
||||
|
||||
/** |
||||
* |
||||
* Das markierte Element wird (in der rechten Tabelle) bei einer Mehrfachauswahl gelöscht. |
||||
* |
||||
*/ |
||||
|
||||
public void actionPerformed(ActionEvent e) { |
||||
SxTableSorter model = |
||||
(SxTableSorter) sxTablePanel.getTable().getModel(); |
||||
Vector V_choice = SxDlgManager.getChoiceData(); |
||||
int[] rows = sxTablePanel.getTable().getSelectedRows(); |
||||
int cols = sxTablePanel.getTable().getColumnCount(); |
||||
int[] indexes = model.getIndexes(); |
||||
|
||||
if (rows.length <= 0) |
||||
return; |
||||
|
||||
for (int i = rows.length; i > 0; i--) { |
||||
V_choice.removeElementAt(indexes[rows[i - 1]]); |
||||
} |
||||
|
||||
model.fireTableRowsDeleted(rows[0], rows[rows.length - 1]); |
||||
|
||||
sxTablePanel.setData(V_choice); |
||||
|
||||
model.sortByColumn(cols - 1); |
||||
|
||||
} |
||||
} |
@ -1,50 +0,0 @@
@@ -1,50 +0,0 @@
|
||||
package de.superx.applet; |
||||
|
||||
import java.awt.Frame; |
||||
import java.awt.HeadlessException; |
||||
|
||||
import javax.swing.JComponent; |
||||
|
||||
import de.memtext.baseobjects.DoubleClickMouseListener; |
||||
import de.memtext.dlg.OkCancelClearDlg; |
||||
import de.memtext.util.WindowUtils; |
||||
|
||||
public class SxDlg extends OkCancelClearDlg { |
||||
|
||||
public SxDlg(Frame parent, String title, JComponent comp) |
||||
throws HeadlessException { |
||||
super(parent, title); |
||||
this.setCenter(comp); |
||||
this.pack(); |
||||
WindowUtils.center(this); |
||||
if (comp instanceof SxTablePanel) { |
||||
SxTablePanel sxTablePanel = (SxTablePanel) comp; |
||||
sxTablePanel |
||||
.getTable() |
||||
.addMouseListener(new DoubleClickMouseListener() { |
||||
protected void doubleClickOccured() { |
||||
wasOkSelected = true; |
||||
performOk(); |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
|
||||
protected void performClear() { |
||||
this.hide(); |
||||
|
||||
} |
||||
|
||||
protected void performOk() { |
||||
this.hide(); |
||||
|
||||
} |
||||
|
||||
protected void performCancel() { |
||||
this.hide(); |
||||
|
||||
} |
||||
|
||||
} |
||||
|
||||
//Created on 16.03.2004 at 15:28:54
|
@ -1,164 +0,0 @@
@@ -1,164 +0,0 @@
|
||||
package de.superx.applet; |
||||
|
||||
import java.awt.Component; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.sql.SQLException; |
||||
import java.util.Iterator; |
||||
|
||||
import javax.swing.JButton; |
||||
import javax.swing.JComboBox; |
||||
import javax.swing.JRootPane; |
||||
|
||||
import de.memtext.tree.KeyParentEqualException; |
||||
import de.memtext.tree.NoMainEntryException; |
||||
import de.memtext.widgets.WarningMessage; |
||||
import de.superx.common.DBServletException; |
||||
import de.superx.common.SelectableItem; |
||||
import de.superx.common.Sichtgruppe; |
||||
|
||||
/** |
||||
* Dialoglistener für SxMask und SxDlg.Dabei wird unterschieden,ob es sich um |
||||
* einen Institutionenauswahldialog oder einen anderen Dialog handelt. Bei |
||||
* Ersterem werden entsprechend der Dialogart (Nr. 4/6/7) Einrichtungen aus dem |
||||
* Bereich Lehre angezeigt oder nicht. Aufgerufen von SxMask.addButtonField |
||||
* |
||||
* @version 2.0 01-01-02 |
||||
* @author Rainer Behr, erweitert von Meikel Bisping, Daniel Quathamer |
||||
*/ |
||||
|
||||
public class SxDlgListener implements ActionListener, Runnable { |
||||
SxDlgListener dlg_th; |
||||
SxMask dlgmask; |
||||
private String erläuterung; |
||||
SxForm dlgform; |
||||
JButton dlgBtn; |
||||
SxField sxField; |
||||
String name; |
||||
int fieldnr; |
||||
int dlg_art; |
||||
private Sichtgruppe sichtgruppe; |
||||
|
||||
SxDlgListener(SxMask mask, SxForm form, JButton btn, String erläuterung, |
||||
int n, int art) { |
||||
dlgmask = mask; |
||||
|
||||
dlgform = form; |
||||
dlgBtn = btn; |
||||
fieldnr = n; |
||||
dlg_art = art; |
||||
this.erläuterung = erläuterung; |
||||
// voranstehendes L_ abschneiden
|
||||
name = dlgBtn.getName().substring(2); |
||||
}; |
||||
|
||||
public void actionPerformed(ActionEvent e) { |
||||
dlgBtn.setEnabled(false); |
||||
SxWaitCursor.set(dlgmask, true); |
||||
new Thread(this).start(); |
||||
} |
||||
|
||||
public void run() { |
||||
if (dlg_art == 4 || dlg_art == 6 || dlg_art == 7 || dlg_art == 12) { |
||||
try { |
||||
openTreeDlg(); |
||||
} catch (Exception e) { |
||||
WarningMessage.show(dlgmask, "Konnte Dialog nicht öffnen.\n" |
||||
+ e, "SuperX"); |
||||
e.printStackTrace(); |
||||
} |
||||
} else { |
||||
SxDlgManager.openDlg(dlgmask, dlgform, dlgBtn.getName(), dlgBtn |
||||
.getText(), fieldnr, dlg_art); |
||||
} |
||||
|
||||
dlgBtn.setEnabled(true); |
||||
SxWaitCursor.set(dlgmask, false); |
||||
JRootPane root = dlgform.getRootPane(); |
||||
root.setDefaultButton(dlgform.getDefaultBtn()); |
||||
|
||||
} |
||||
|
||||
public Sichtgruppe getSichtgruppe() { |
||||
return sichtgruppe; |
||||
} |
||||
|
||||
public void setSichtgruppe(Sichtgruppe sichtgruppe) { |
||||
this.sichtgruppe = sichtgruppe; |
||||
} |
||||
|
||||
// dlgform.getDefaults() hier störend da das in OpenDlg passiert!
|
||||
|
||||
private void openTreeDlg() throws SQLException, DBServletException, |
||||
KeyParentEqualException, CloneNotSupportedException, NoMainEntryException { |
||||
|
||||
SxTreeDlg dlg = new SxTreeDlg(dlgmask.getFrame(), dlgBtn.getText(), |
||||
sichtgruppe, erläuterung); |
||||
dlg.setVisible(true); |
||||
// Auf das Schließen des Dialogs warten...
|
||||
|
||||
|
||||
SxField field = dlgform.getField("F_" + name); |
||||
// könnte eigentlich 1x beim Feldinit gemacht werden, klappt aber nicht
|
||||
field.setSichtgruppe(sichtgruppe); |
||||
if (!dlg.wasCancelSelected()) |
||||
{ |
||||
field |
||||
.setSelectedSicht((SichtApplet) sichtgruppe |
||||
.getSelectedSicht()); |
||||
if (dlg.isStandChanged) |
||||
clearRememberedValues(); |
||||
dlgform.setErlaubt(false); |
||||
if (dlg.getSelections().size() == 0) |
||||
throw new IllegalStateException("TreeDialog hätte mindestens 1 Item liefern müssen"); |
||||
if (dlg.getSelections().size() == 1) {//kann auch bei clear -1-Objekt für alles sein
|
||||
if (field.isWithCombo()) { |
||||
JComboBox combo = (JComboBox) dlgform.getComp(field.getName()); |
||||
combo.removeAllItems(); |
||||
} |
||||
SelectableItem gewaehlt = (SelectableItem) dlg.getSelections().get( |
||||
0); |
||||
field.setKey(gewaehlt.getId()); |
||||
field.setText(gewaehlt.getName()); |
||||
// für Institutionenauswahl s. Kommentar in SxUtils.generateSQL()
|
||||
dlgform.setErlaubt(gewaehlt.isAllowed()); |
||||
} |
||||
if (dlg.getSelections().size() > 1) { |
||||
// analog zu SxDlgManager.setField
|
||||
if (field.isWithCombo()) { |
||||
JComboBox combo = (JComboBox) dlgform.getComp(field.getName()); |
||||
combo.removeAllItems(); |
||||
combo.setEditable(false); |
||||
combo.setEnabled(false); |
||||
String[] keys = new String[dlg.getSelections().size()]; |
||||
boolean erlaubt=true; |
||||
for (int i = 0; i < dlg.getSelections().size(); i++) { |
||||
SelectableItem gewaehlt = (SelectableItem) dlg |
||||
.getSelections().get(i); |
||||
if (!gewaehlt.isAllowed()) erlaubt=false; |
||||
keys[i] = gewaehlt.getId().toString(); |
||||
combo.insertItemAt(gewaehlt.getName(), i); |
||||
} |
||||
dlgform.setErlaubt(erlaubt); |
||||
field.setKey(keys); |
||||
field.setText(" < Ihre Auswahl > "); |
||||
|
||||
|
||||
} |
||||
} |
||||
} |
||||
Component err_comp = dlgform.getErrorComp(field.getName()); |
||||
if (err_comp != null) |
||||
dlgform.removeErrorComp(err_comp); |
||||
|
||||
} |
||||
|
||||
private void clearRememberedValues() { |
||||
for (Iterator it = sichtgruppe.iterator(); it.hasNext();) { |
||||
SichtApplet eineSicht = (SichtApplet) it.next(); |
||||
String rm = name + "-Sicht" + eineSicht.getId(); |
||||
SxDefaults.removeProperty(rm); |
||||
} |
||||
} |
||||
|
||||
} |
@ -1,549 +0,0 @@
@@ -1,549 +0,0 @@
|
||||
package de.superx.applet; |
||||
|
||||
import java.awt.Color; |
||||
import java.awt.Component; |
||||
import java.awt.Dimension; |
||||
import java.awt.Frame; |
||||
import java.awt.GridBagConstraints; |
||||
import java.awt.GridBagLayout; |
||||
import java.awt.GridLayout; |
||||
import java.awt.Insets; |
||||
import java.sql.SQLException; |
||||
import java.sql.Types; |
||||
import java.util.HashMap; |
||||
import java.util.Hashtable; |
||||
import java.util.Properties; |
||||
import java.util.Vector; |
||||
|
||||
import javax.swing.JComboBox; |
||||
import javax.swing.JComponent; |
||||
import javax.swing.JLabel; |
||||
import javax.swing.JOptionPane; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JTable; |
||||
import javax.swing.SwingConstants; |
||||
import javax.swing.plaf.basic.BasicArrowButton; |
||||
import javax.swing.table.TableColumnModel; |
||||
import javax.swing.table.TableModel; |
||||
|
||||
/** |
||||
* Darstellung verschiedener Auswahldialoge. |
||||
* |
||||
* @author Rainer Behr, erweitert von Meikel Bisping, Daniel Quathamer |
||||
* |
||||
* |
||||
* |
||||
*/ |
||||
|
||||
public class SxDlgManager { |
||||
private static boolean isSQLstatic; |
||||
static Hashtable dlg_map = null; |
||||
//static String[] DlgOptionNames = { "OK", "Abbruch", "Leeren" };
|
||||
static Component dlg_panel = null; |
||||
static SxTablePanel sxTablePanel = null; |
||||
static SxTablePanel sxTablePanel2 = null; |
||||
static Vector V_header = null; |
||||
static Vector V_sql = null; |
||||
static Vector V_sql2 = null; |
||||
static Vector V_empty = null; |
||||
|
||||
static SxSQLMetaData meta = null; |
||||
|
||||
static { |
||||
dlg_map = new Hashtable(); |
||||
|
||||
V_header = new Vector(); |
||||
V_sql = new Vector(); |
||||
V_sql2 = new Vector(); |
||||
V_empty = new Vector(); |
||||
|
||||
sxTablePanel = new SxTablePanel(); |
||||
|
||||
sxTablePanel.getTable().setAutoResizeMode( |
||||
JTable.AUTO_RESIZE_ALL_COLUMNS); |
||||
|
||||
sxTablePanel2 = new SxTablePanel(); |
||||
|
||||
sxTablePanel2.getTable().setAutoResizeMode( |
||||
JTable.AUTO_RESIZE_ALL_COLUMNS); |
||||
} |
||||
|
||||
static synchronized void openDlg(SxMask mask, SxForm form, String name, |
||||
String caption, int fieldnr, int dlg_art) { |
||||
if (dlg_art != 1 && dlg_art != 2 && dlg_art != 10) |
||||
return; |
||||
|
||||
JComponent dlg_comp; |
||||
Vector v_field = (Vector) form.getFieldVector().elementAt(fieldnr); |
||||
isSQLstatic = true; |
||||
int zeilenanzahl = ((Integer) v_field.elementAt(7)).intValue(); |
||||
// Zeilenanzahl > 1 -> Multi-Dialogauswahl
|
||||
|
||||
SxField field = form.getField("F_" + name.substring(2)); |
||||
|
||||
V_header.removeAllElements(); |
||||
V_sql.removeAllElements(); |
||||
V_sql2.removeAllElements(); |
||||
V_empty.removeAllElements(); |
||||
|
||||
|
||||
String stmt = getReadingSql(dlg_art, form, v_field); |
||||
|
||||
|
||||
try { |
||||
|
||||
|
||||
HashMap map = form.getHashMap(null); |
||||
//map.put("Maskennummer",selectedMaskeninfoElement.getTid());
|
||||
stmt = SxSQL.templateProcessor.process("Feld sql ", stmt, |
||||
//Trickmethode!!
|
||||
map, (String) SxDefaults.getPropertyValue("SxDB")); |
||||
|
||||
|
||||
//
|
||||
Properties dlg_prop = null; |
||||
|
||||
/* |
||||
* An dieser Stelle wird geprüft, ob der Inhalt für das Feld bereits |
||||
* einmal eingelesen wurde, wenn ja, dann aus Arbeitsspeicher, |
||||
* ansonsten bleibt dlg_prop == null und im nächsten Block wird aus |
||||
* der Datenbank gelesen, -> probleme wenn beim erstenmal |
||||
* Prüfungssemester erst ab SS92 danach erscheint nie wieder SS88 |
||||
* immer neu einlesen MB 12.01 |
||||
* |
||||
* if (isSQLstatic) { dlg_prop = getDialogSet(name); if (dlg_prop != |
||||
* null) { V_header = (Vector) ((Vector) |
||||
* dlg_prop.get("header")).clone(); V_sql = (Vector) ((Vector) |
||||
* dlg_prop.get("data")).clone(); meta = (SxSQLMetaData) |
||||
* dlg_prop.get("meta"); } } |
||||
*/ |
||||
|
||||
form.getLogo().start(); |
||||
// System.err.println ("OpenDlg: " + stmt);
|
||||
SxSQL.executeAll(stmt); |
||||
form.getLogo().stop(); |
||||
|
||||
dlg_comp = prepareDlgComp(form, name, caption, zeilenanzahl, field); |
||||
|
||||
SxDlg dlg = new SxDlg((Frame) form.getTopLevelAncestor(), |
||||
//name.substring(2),
|
||||
caption, dlg_comp); |
||||
dlg.show(); |
||||
if (dlg.wasOkSelected()) { |
||||
// if (dlg_art != 10) { alter Institutionendialog mit vier
|
||||
// feldern
|
||||
if (zeilenanzahl == 1) |
||||
setField(field, dlg_art, false); |
||||
if (zeilenanzahl > 1) |
||||
setField(field, dlg_art, true); |
||||
// } else {
|
||||
// setInstFields(SxSQL, field);
|
||||
// }
|
||||
} |
||||
if (dlg.wasClearSelected()) { |
||||
field.setKey(new String("-1")); |
||||
field.setText(""); |
||||
if (field.isWithCombo()) { |
||||
JComboBox combo = (JComboBox) form.getComp("F_" |
||||
+ name.substring(2)); |
||||
if (combo.getItemCount() > 0) |
||||
combo.removeAllItems(); |
||||
} |
||||
} |
||||
|
||||
field.setBackground(Color.white); |
||||
|
||||
field.repaint(); |
||||
} catch (Exception ex) { |
||||
String msg = ex.toString(); |
||||
// System.err.println (ex);
|
||||
// System.err.println ("sql: " + stmt);
|
||||
JOptionPane.showMessageDialog(form, msg.substring(msg |
||||
.lastIndexOf(":") + 1), "SQL-Fehler", |
||||
JOptionPane.ERROR_MESSAGE); |
||||
} |
||||
} |
||||
|
||||
private static JComponent prepareDlgComp(SxForm form, String name, |
||||
String caption, int zeilenanzahl, SxField field) { |
||||
JComponent dlg_comp; |
||||
meta = (SxSQLMetaData) SxSQL.getResultSetMetaData(); |
||||
//Wint,das ist nicht die Stelle, um ID im rechten Fenster auszublenden
|
||||
if (meta.getColumnCount() > 1) |
||||
V_header.addElement("ID"); |
||||
//V_header.addElement(name.substring(2));
|
||||
V_header.addElement(caption); |
||||
V_sql = SxSQL.getResultVector(); |
||||
|
||||
if (isSQLstatic) |
||||
addDialogSet(name, V_header.clone(), V_sql.clone(), meta); |
||||
|
||||
int cols = meta.getColumnCount(); |
||||
|
||||
sxTablePanel.setData(V_sql, V_header, null, meta); |
||||
|
||||
if (zeilenanzahl > 1) { |
||||
Object key = field.getKey(); |
||||
|
||||
if (key instanceof String[]) { |
||||
String[] keys = (String[]) key; |
||||
JComboBox combo = (JComboBox) form.getComp("F_" |
||||
+ name.substring(2)); |
||||
int n = combo.getItemCount(); |
||||
for (int i = 0; i < n; i++) { |
||||
Vector V_row = new Vector(); |
||||
// r.b. 15.09.00
|
||||
// Inhalt von 'keys' in den entsprechenden Datenbanktyp
|
||||
// konvertieren
|
||||
// s. a. Methode tableRepresentation() in SxJDBCAdapter u.
|
||||
// Methode SxInsertListener
|
||||
|
||||
switch (meta.getColumnType(1)) { |
||||
case Types.SMALLINT: |
||||
V_row.addElement(new Short(keys[i])); |
||||
//System.out.println("V_row: smallint");
|
||||
break; |
||||
case Types.INTEGER: |
||||
V_row.addElement(new Integer(keys[i])); |
||||
//System.out.println("V_row: integer");
|
||||
break; |
||||
case Types.DECIMAL: |
||||
case Types.DOUBLE: |
||||
V_row.addElement(new Double(keys[i])); |
||||
//System.out.println("V_row: double");
|
||||
break; |
||||
case Types.DATE: |
||||
V_row.addElement(SxDate.getDate(keys[i])); |
||||
//System.out.println("V_row: date");
|
||||
break; |
||||
default: |
||||
V_row.addElement(keys[i]); |
||||
//System.out.println("V_row: default");
|
||||
break; |
||||
} |
||||
|
||||
V_row.addElement(combo.getItemAt(i)); |
||||
V_sql2.addElement(V_row); |
||||
} |
||||
|
||||
sxTablePanel2.setData(V_sql2, V_header, null, meta); |
||||
} else { |
||||
// Default-Wert aus 'felderinfo'
|
||||
if ((key.toString()).compareTo(new String("-1")) != 0) { |
||||
Vector V_row = new Vector(); |
||||
V_row.addElement(key); |
||||
V_row.addElement(field.getText()); |
||||
V_sql2.addElement(V_row); |
||||
//table2.setData (V_sql2, V_header, meta);
|
||||
sxTablePanel2.setData(V_sql2, V_header, null, meta); |
||||
} else { |
||||
if (cols > 1) |
||||
V_empty.addElement(new Integer(Integer.MIN_VALUE)); |
||||
V_empty.addElement(new String("")); |
||||
|
||||
V_sql2.addElement(V_empty); |
||||
|
||||
//table2.setData (V_sql2, V_header, meta);
|
||||
sxTablePanel2.setData(V_sql2, V_header, null, meta); |
||||
V_sql2.removeAllElements(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
Dimension dim = sxTablePanel.getTable().getPreferredSize(); |
||||
if (dim.height > 300) |
||||
dim.height = 300; |
||||
TableColumnModel cmodel = sxTablePanel.getTable().getColumnModel(); |
||||
//Wint, bewirkte, daß normalerweise ID und Text ausgegeben wurden
|
||||
if (cols > 1 && SxSQL.getRowCount() > 0) |
||||
//&&
|
||||
//(meta.getColumnType(1) == Types.CHAR ||
|
||||
// meta.getColumnType(1) == Types.VARCHAR))
|
||||
{ |
||||
sxTablePanel.getTable().removeColumn(cmodel.getColumn(0)); |
||||
//cols--;
|
||||
//auch für rechte Tabelle nur 1 Feld
|
||||
if (zeilenanzahl > 1) { |
||||
TableColumnModel cmodel2 = sxTablePanel2.getTable() |
||||
.getColumnModel(); |
||||
sxTablePanel2.getTable().removeColumn(cmodel2.getColumn(0)); |
||||
} |
||||
cols--; |
||||
} |
||||
|
||||
if (cols > 1 && SxSQL.getRowCount() > 0) |
||||
cmodel.getColumn(0).setMaxWidth(80); |
||||
dim.width = cmodel.getTotalColumnWidth(); |
||||
if (dim.width < 250) |
||||
dim.width = 250; |
||||
|
||||
int row = sxTablePanel.getTable().getSelectedRow(); |
||||
if (row >= 0) |
||||
sxTablePanel.getTable().setRowSelectionInterval(row, row); |
||||
// why ??
|
||||
//TableColumnModel cmodel2 = sxTablePanel2.getTable().getColumnModel();
|
||||
//cmodel2.getColumn(0).setMaxWidth (80);
|
||||
|
||||
sxTablePanel.getTable().setPreferredScrollableViewportSize(dim); |
||||
sxTablePanel2.getTable().setPreferredScrollableViewportSize(dim); |
||||
sxTablePanel |
||||
.setMinimumSize(new Dimension(dim.width + 5, dim.height + 5)); |
||||
sxTablePanel2.setMinimumSize(new Dimension(dim.width + 5, |
||||
dim.height + 5)); |
||||
|
||||
if (zeilenanzahl > 1) |
||||
dlg_comp = createTwoTablesPanel(); |
||||
else |
||||
dlg_comp = sxTablePanel; |
||||
return dlg_comp; |
||||
} |
||||
|
||||
/** |
||||
* |
||||
* @param dlg_art |
||||
* @param form |
||||
* @param v_field |
||||
* @return |
||||
*/ |
||||
private static String getReadingSql(int dlg_art, SxForm form, Vector v_field) { |
||||
String stmt = null; |
||||
String sx_db = (String) SxDefaults.getPropertyValue("SxDB"); |
||||
String relation = (String) v_field.elementAt(12); |
||||
if (relation != null) |
||||
relation = relation.trim(); |
||||
boolean isTemplate = relation.toUpperCase().indexOf("FREEMARKER TEMPLATE") > -1; |
||||
|
||||
String attribut = (String) v_field.elementAt(13); |
||||
if (attribut != null) |
||||
attribut = attribut.trim(); |
||||
switch (dlg_art) { |
||||
case 1: // Auswahldialog (1-2 Attribute)
|
||||
|
||||
if (relation.startsWith("sp_")) { |
||||
stmt = "execute procedure " + relation; |
||||
if (sx_db.equals("Postgres")) |
||||
stmt = "select " + relation; |
||||
|
||||
break; |
||||
} |
||||
if (relation.startsWith("<<SQL>>")) |
||||
stmt = relation.substring(7); |
||||
else { |
||||
if (attribut.indexOf(',') == -1) |
||||
attribut = "tid, " + attribut; |
||||
stmt = "select " + attribut + " from " + relation |
||||
+ " order by 2"; |
||||
} |
||||
break; |
||||
case 2: // Stored Proc.
|
||||
stmt = "execute procedure " + relation; |
||||
if (sx_db.equals("Postgres")) |
||||
stmt = "select " + relation; |
||||
break; |
||||
case 10: // Aufruf aus Inst.-Dialog s. createInstPanel()
|
||||
if (relation.startsWith("sp_")) { |
||||
stmt = "execute procedure " + relation; |
||||
if (sx_db.equals("Postgres")) |
||||
stmt = "select " + relation; |
||||
break; |
||||
} |
||||
if (relation.startsWith("<<SQL>>")) |
||||
stmt = relation.substring(7); |
||||
else |
||||
stmt = relation; |
||||
break; |
||||
|
||||
} |
||||
|
||||
//<<FELDNAME>> durch Wert ersetzen
|
||||
String prefix = SxUtils.getFieldPrefix(); |
||||
if (stmt.indexOf(prefix) >= 0) { |
||||
isSQLstatic = false; |
||||
stmt = SxUtils.generateSQL(form, stmt); |
||||
//System.out.println("sel-str: " + stmt);
|
||||
int err_start = -1; |
||||
if ((err_start = stmt.indexOf(prefix)) >= 0) { |
||||
String suffix = SxUtils.getFieldSuffix(); |
||||
int err_stop = stmt.indexOf(suffix, err_start); |
||||
err_start += prefix.length(); |
||||
String err_field = stmt.substring(err_start, err_stop); |
||||
String msg = "SQL-Fehler durch '" + err_field + "' !"; |
||||
//System.err.println (msg);
|
||||
JOptionPane.showMessageDialog(form, msg, "Dialogfehler", |
||||
JOptionPane.ERROR_MESSAGE); |
||||
throw new IllegalArgumentException(msg); |
||||
} |
||||
} |
||||
if (isTemplate) stmt="--Freemarker Template\n"+stmt; |
||||
return stmt; |
||||
} |
||||
|
||||
public static void setField(SxField field, int dlg_art, boolean isMultiDlg) |
||||
throws SQLException { |
||||
SxForm form = field.getForm(); |
||||
if (form == null) |
||||
return; |
||||
|
||||
if (!isMultiDlg) { |
||||
SxTableModel tmodel = (SxTableModel) sxTablePanel.getTable().getModel(); |
||||
int row = sxTablePanel.getTable().getSelectedRow(); |
||||
if (row < 0) |
||||
return; |
||||
|
||||
switch (dlg_art) { |
||||
case 1: |
||||
case 2: |
||||
if (meta.getColumnCount() > 1) { |
||||
field.setKey(tmodel.getValueAt2(row, 0)); |
||||
|
||||
field.setText((String) tmodel.getValueAt(row, 1)); |
||||
|
||||
} else { |
||||
field.setKey(new String("-1")); |
||||
field.setText((String) tmodel.getValueAt(row, 0)); |
||||
} |
||||
|
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
} else { |
||||
SxTableModel tmodel = (SxTableModel) sxTablePanel2.getTable().getModel(); |
||||
int rows = tmodel.getRowCount(); |
||||
int cols = tmodel.getColumnCount(); |
||||
|
||||
switch (dlg_art) { |
||||
case 1: |
||||
case 2: |
||||
if (rows < 0) |
||||
break; |
||||
JComboBox combo = null; |
||||
if (field.isWithCombo()) { |
||||
combo = (JComboBox) form.getComp(field.getName()); |
||||
if (combo.getItemCount() > 0) |
||||
combo.removeAllItems(); |
||||
} else |
||||
break; |
||||
|
||||
String[] keys = new String[rows]; |
||||
|
||||
for (int i = 0; i < rows; i++) { |
||||
keys[i] = (String) tmodel.getValueAt(i, 0); |
||||
if (cols == 1) |
||||
combo.insertItemAt(tmodel.getValueAt2(i, 0), i); |
||||
else |
||||
combo.insertItemAt(tmodel.getValueAt(i, 1), i); |
||||
} |
||||
|
||||
field.setKey(keys); |
||||
|
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
|
||||
if (rows > 0) |
||||
field.setText(" < Ihre Auswahl > "); |
||||
else { |
||||
field.setKey(new String("-1")); |
||||
field.setText(""); |
||||
} |
||||
} |
||||
|
||||
// delete Field from Error map
|
||||
Component err_comp = form.getErrorComp(field.getName()); |
||||
if (err_comp != null) |
||||
form.removeErrorComp(err_comp); |
||||
|
||||
} |
||||
|
||||
public static void addDialogSet(String name, Object nheader, Object ndata, |
||||
Object nmeta) { |
||||
Properties prop = new Properties(); |
||||
prop.put("header", nheader); |
||||
prop.put("data", ndata); |
||||
prop.put("meta", nmeta); |
||||
|
||||
dlg_map.put(name, prop); |
||||
} |
||||
|
||||
public static Properties getDialogSet(String name) { |
||||
Properties prop = (Properties) dlg_map.get(name); |
||||
return prop; |
||||
} |
||||
|
||||
public static void clear() { |
||||
dlg_map.clear(); |
||||
dlg_map = new Hashtable(); |
||||
} |
||||
|
||||
public static SxTablePanel getDlgTable() { |
||||
return sxTablePanel; |
||||
} |
||||
|
||||
public static SxTablePanel getChoiceTable() { |
||||
return sxTablePanel2; |
||||
} |
||||
|
||||
public static Vector getDlgData() { |
||||
return V_sql; |
||||
} |
||||
|
||||
public static Vector getChoiceData() { |
||||
return V_sql2; |
||||
} |
||||
|
||||
protected static JComponent createTwoTablesPanel() { |
||||
JPanel dlgPanel = new JPanel(new GridLayout(1, 3)); |
||||
|
||||
GridBagLayout gridbag = new GridBagLayout(); |
||||
GridBagConstraints constraints = new GridBagConstraints(); |
||||
constraints.insets = new Insets(5, 2, 5, 2); |
||||
dlgPanel.setLayout(gridbag); |
||||
|
||||
JPanel btnPanel = new JPanel(new GridLayout(0, 1)); |
||||
|
||||
BasicArrowButton insertBtn = new BasicArrowButton(SwingConstants.EAST); |
||||
insertBtn.setHorizontalAlignment(JLabel.CENTER); |
||||
SxInsertListener insertl = new SxInsertListener(); |
||||
insertBtn.addActionListener(insertl); |
||||
JLabel insertLabel = new JLabel("Einfügen"); |
||||
insertLabel.setHorizontalAlignment(JLabel.CENTER); |
||||
|
||||
BasicArrowButton deleteBtn = new BasicArrowButton(SwingConstants.WEST); |
||||
deleteBtn.setHorizontalAlignment(JLabel.CENTER); |
||||
SxDeleteListener deletel = new SxDeleteListener(); |
||||
deleteBtn.addActionListener(deletel); |
||||
JLabel deleteLabel = new JLabel("Löschen"); |
||||
deleteLabel.setHorizontalAlignment(JLabel.CENTER); |
||||
|
||||
btnPanel.add(insertLabel); |
||||
btnPanel.add(insertBtn); |
||||
btnPanel.add(deleteLabel); |
||||
btnPanel.add(deleteBtn); |
||||
|
||||
constraints.anchor = GridBagConstraints.WEST; |
||||
constraints.fill = GridBagConstraints.HORIZONTAL; |
||||
constraints.weightx = 0.5; |
||||
constraints.weighty = 1.0; |
||||
gridbag.setConstraints(sxTablePanel, constraints); |
||||
dlgPanel.add(sxTablePanel); |
||||
|
||||
constraints.anchor = GridBagConstraints.CENTER; |
||||
constraints.fill = GridBagConstraints.NONE; |
||||
constraints.weightx = 0.25; |
||||
constraints.weighty = 0.25; |
||||
gridbag.setConstraints(btnPanel, constraints); |
||||
dlgPanel.add(btnPanel); |
||||
|
||||
constraints.anchor = GridBagConstraints.EAST; |
||||
constraints.fill = GridBagConstraints.HORIZONTAL; |
||||
constraints.weightx = 0.5; |
||||
constraints.weighty = 1.0; |
||||
gridbag.setConstraints(sxTablePanel2, constraints); |
||||
dlgPanel.add(sxTablePanel2); |
||||
|
||||
return dlgPanel; |
||||
} |
||||
|
||||
} |
@ -1,534 +0,0 @@
@@ -1,534 +0,0 @@
|
||||
package de.superx.applet; |
||||
|
||||
import java.awt.Color; |
||||
import java.awt.Component; |
||||
import java.awt.event.FocusEvent; |
||||
import java.awt.event.FocusListener; |
||||
import java.awt.event.InputEvent; |
||||
import java.awt.event.KeyAdapter; |
||||
import java.awt.event.KeyEvent; |
||||
import java.text.NumberFormat; |
||||
|
||||
import javax.swing.ComboBoxEditor; |
||||
import javax.swing.JButton; |
||||
import javax.swing.JComboBox; |
||||
import javax.swing.JTable; |
||||
import javax.swing.JTextField; |
||||
import javax.swing.table.TableCellEditor; |
||||
|
||||
import de.superx.common.Sichtgruppe; |
||||
|
||||
/** |
||||
* Darstellung eines Feldes auf einer Maske |
||||
* |
||||
* @version 1.0 01/11/99 |
||||
* @author Rainer Behr, Meikel Bisping |
||||
* @see SxForm |
||||
*/ |
||||
|
||||
public class SxField extends JTextField implements ComboBoxEditor, |
||||
FocusListener { |
||||
//
|
||||
// Static Constants
|
||||
//
|
||||
public static final int TYPE_STRING = 0; |
||||
public static final int TYPE_INTEGER = 1; |
||||
public static final int TYPE_DOUBLE = 2; |
||||
public static final int TYPE_DATE = 3; |
||||
public static final int TYPE_SQL = 4; |
||||
|
||||
//
|
||||
// Instants
|
||||
//
|
||||
//protected SxField sxField;
|
||||
private Sichtgruppe sichtgruppe; |
||||
protected int field_type = TYPE_STRING; |
||||
protected int field_length = -1; |
||||
protected boolean isInputNeeded = false; |
||||
protected boolean field_input = false; |
||||
protected boolean field_withCombo = false; |
||||
private String field_value = ""; |
||||
private Object field_key = new Integer(-1); |
||||
|
||||
private SxForm sxForm = null; // Maskenformular
|
||||
private JButton defaultBtn = null; // Default-Button
|
||||
private Object defaultValue = new Integer(-1); |
||||
private SichtApplet selectedSicht; |
||||
JTable tableView = null; |
||||
|
||||
public SxField() { |
||||
super(); |
||||
|
||||
init(); |
||||
} |
||||
|
||||
/** |
||||
* Normalerweise ist der Defaultvalue -1,da aber die Institutionsprozeduren |
||||
* mit char arbeiten und Informix execute procedure mit (,,) nicht klar |
||||
* kommt, wird für Felder die Institutionen betreffen 'null' als defaultwert |
||||
* festgelegt (s. SxMask.createMask()). Wird insbesondere bei isValid() und |
||||
* checkField() benötigt. |
||||
*/ |
||||
public void setDefaultValue(Object defaultValue) { |
||||
this.defaultValue = defaultValue; |
||||
} |
||||
|
||||
public boolean hasSichten() { |
||||
return selectedSicht != null; |
||||
} |
||||
|
||||
public SxField(int type) { |
||||
super(); |
||||
|
||||
field_type = type; |
||||
init(); |
||||
} |
||||
|
||||
public SxField(String text) { |
||||
super(); |
||||
|
||||
setText(text); |
||||
init(); |
||||
} |
||||
|
||||
public SxField(String text, int columns, int type) { |
||||
super(); |
||||
|
||||
field_type = type; |
||||
setText(text); |
||||
setColumns(columns); |
||||
init(); |
||||
} |
||||
|
||||
public SxField(String text, int columns) { |
||||
super(); |
||||
|
||||
setText(text); |
||||
setColumns(columns); |
||||
init(); |
||||
} |
||||
|
||||
public SxField(int type, int length) { |
||||
super(); |
||||
|
||||
field_type = type; |
||||
field_length = length; |
||||
init(); |
||||
} |
||||
|
||||
public SxField(String text, int columns, int type, int length) { |
||||
super(); |
||||
|
||||
field_type = type; |
||||
setText(text); |
||||
setColumns(columns); |
||||
field_length = length; |
||||
init(); |
||||
} |
||||
|
||||
public void setJTable(JTable table) { |
||||
tableView = table; |
||||
} |
||||
|
||||
public void setForm(SxForm form) { |
||||
sxForm = form; |
||||
} |
||||
|
||||
public void setWithCombo(boolean withCombo) { |
||||
field_withCombo = withCombo; |
||||
} |
||||
|
||||
public boolean isWithCombo() { |
||||
return field_withCombo; |
||||
} |
||||
|
||||
public SxForm getForm() { |
||||
return sxForm; |
||||
} |
||||
|
||||
public void setType(int type) { |
||||
field_type = type; |
||||
} |
||||
|
||||
public int getType() { |
||||
return field_type; |
||||
} |
||||
|
||||
public void setKey(Object key) { |
||||
field_key = key; |
||||
} |
||||
|
||||
public Object getKey() { |
||||
Object ret=field_key; |
||||
// if (field_key instanceof Double) ret=field_key.toString().replace(',','.');
|
||||
return ret; |
||||
} |
||||
|
||||
public void setInputNeeded(boolean input) { |
||||
isInputNeeded = input; |
||||
} |
||||
|
||||
public boolean isInputNeeded() { |
||||
return isInputNeeded; |
||||
} |
||||
|
||||
public boolean isValid() { |
||||
if (checkField()) { |
||||
setBackground(Color.white); |
||||
repaint(); |
||||
return true; |
||||
} |
||||
|
||||
setBackground(Color.red); |
||||
repaint(); |
||||
return false; |
||||
} |
||||
|
||||
//
|
||||
// Interface ComboBoxEditor
|
||||
//
|
||||
public Component getEditorComponent() { |
||||
return (Component) this; |
||||
|
||||
} |
||||
|
||||
public Object getItem() { |
||||
return (Object) getText(); |
||||
} |
||||
|
||||
public void setItem(Object anObject) { |
||||
if (anObject == null) |
||||
setText(""); |
||||
else |
||||
setText(anObject.toString()); |
||||
} |
||||
|
||||
// protected methods
|
||||
|
||||
protected void init() { |
||||
final SxField thisField = this; |
||||
KeyAdapter sxFieldKeyListener = new KeyAdapter() { |
||||
|
||||
public void keyPressed(KeyEvent e) { |
||||
Object value; |
||||
|
||||
switch (e.getKeyCode()) { |
||||
case KeyEvent.VK_ENTER: { |
||||
if (tableView != null) { |
||||
SxTableModel model = (SxTableModel) tableView |
||||
.getModel(); |
||||
TableCellEditor editor = tableView.getCellEditor(); |
||||
Component component = tableView.getEditorComponent(); |
||||
int row = tableView.getSelectedRow(); |
||||
int col = tableView.getSelectedColumn(); |
||||
value = model.getObjectAt(row, col); |
||||
if (value instanceof java.lang.Integer) |
||||
field_type = TYPE_INTEGER; |
||||
if (value instanceof java.lang.Double) |
||||
field_type = TYPE_DOUBLE; |
||||
//if (value instanceof java.lang.String)
|
||||
// field_type = TYPE_STRING;
|
||||
if (value instanceof java.sql.Date) |
||||
field_type = TYPE_DATE; |
||||
field_value = ((JTextField) component).getText(); |
||||
} else { |
||||
field_value = getText(); |
||||
setKey(new Integer("-1")); |
||||
} |
||||
|
||||
if (!isValid()) { |
||||
e.consume(); |
||||
getToolkit().beep(); |
||||
} else { |
||||
JButton defaultBtn; |
||||
if (sxForm != null) { |
||||
sxForm.removeErrorComp(thisField); |
||||
|
||||
defaultBtn = sxForm.getDefaultBtn(); |
||||
if (defaultBtn != null) |
||||
defaultBtn.doClick(); // DefaultButton
|
||||
// aktivieren
|
||||
} else { |
||||
defaultBtn = getRootPane().getDefaultButton(); |
||||
if (defaultBtn != null) |
||||
defaultBtn.doClick(); // DefaultButton
|
||||
// aktivieren
|
||||
} |
||||
} |
||||
|
||||
break; |
||||
} |
||||
case KeyEvent.VK_ESCAPE: { |
||||
if (tableView != null) { |
||||
// System.err.println("Editor canceled ..");
|
||||
TableCellEditor editor = tableView.getCellEditor(); |
||||
editor.cancelCellEditing(); |
||||
} |
||||
break; |
||||
} |
||||
default: { |
||||
int metaPressed = e.getModifiers() & InputEvent.META_MASK; |
||||
if (metaPressed != 0) { |
||||
// System.err.println("keyPressed: MetaKey: " +
|
||||
// e.getKeyChar());
|
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
public void keyTyped(KeyEvent e) { |
||||
switch (field_type) { |
||||
case TYPE_INTEGER: |
||||
case TYPE_DOUBLE: { |
||||
switch (e.getKeyChar()) { |
||||
case '1': |
||||
case '2': |
||||
case '3': |
||||
case '4': |
||||
case '5': |
||||
case '6': |
||||
case '7': |
||||
case '8': |
||||
case '9': |
||||
case '0': |
||||
case '-': |
||||
case '.': |
||||
case ',': { |
||||
// r.b. numerische Zeichen erlaubt
|
||||
// System.err.println("Key: " + e.getKeyChar());
|
||||
field_input = true; |
||||
break; |
||||
} |
||||
default: { |
||||
int metaPressed = e.getModifiers() |
||||
& InputEvent.META_MASK; |
||||
if (metaPressed != 0) { |
||||
// System.err.println("keyTyped: MetaKey: " +
|
||||
// e.getKeyChar());
|
||||
break; |
||||
} |
||||
int altPressed = e.getModifiers() & InputEvent.ALT_MASK; |
||||
if (altPressed != 0) |
||||
break; |
||||
// System.err.println("keyTyped: Key: " +
|
||||
// e.getKeyChar());
|
||||
|
||||
if (e.getKeyChar() >= 'A' && e.getKeyChar() <= 'z') { |
||||
getToolkit().beep(); |
||||
e.consume(); |
||||
} |
||||
|
||||
break; |
||||
} |
||||
} |
||||
break; |
||||
} |
||||
case TYPE_DATE: { |
||||
switch (e.getKeyChar()) { |
||||
case '1': |
||||
case '2': |
||||
case '3': |
||||
case '4': |
||||
case '5': |
||||
case '6': |
||||
case '7': |
||||
case '8': |
||||
case '9': |
||||
case '0': |
||||
case '-': |
||||
case '.': |
||||
case '/': { |
||||
// r.b. Datumszeichen erlaubt
|
||||
// System.err.println("Key: " + e.getKeyChar());
|
||||
field_input = true; |
||||
break; |
||||
} |
||||
default: { |
||||
int metaPressed = e.getModifiers() |
||||
& InputEvent.META_MASK; |
||||
if (metaPressed != 0) { |
||||
// System.err.println("keyTyped: MetaKey: " +
|
||||
// e.getKeyChar());
|
||||
break; |
||||
} |
||||
int altPressed = e.getModifiers() & InputEvent.ALT_MASK; |
||||
if (altPressed != 0) |
||||
break; |
||||
// System.err.println("Key: " + e.getKeyChar());
|
||||
if (e.getKeyChar() >= 'A' && e.getKeyChar() <= 'z') { |
||||
getToolkit().beep(); |
||||
e.consume(); |
||||
} |
||||
|
||||
break; |
||||
} |
||||
} |
||||
break; |
||||
} |
||||
case TYPE_STRING: { |
||||
field_input = true; |
||||
break; |
||||
} |
||||
|
||||
default: |
||||
// System.err.println("Key: " + e.getKeyChar());
|
||||
break; |
||||
} |
||||
|
||||
int text_len = getText().length(); |
||||
if (field_length != -1) { |
||||
if (text_len >= field_length && getSelectedText() == null) { |
||||
if (e.getKeyChar() != KeyEvent.VK_ENTER |
||||
&& e.getKeyChar() != KeyEvent.VK_BACK_SPACE) { |
||||
e.consume(); |
||||
getToolkit().beep(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
if (sxForm != null) |
||||
if (isWithCombo()) { |
||||
JComboBox combo = (JComboBox) sxForm.getComp(getName()); |
||||
if (combo.getItemCount() > 0) |
||||
combo.removeAllItems(); |
||||
} |
||||
} |
||||
}; |
||||
|
||||
addKeyListener(sxFieldKeyListener); |
||||
|
||||
addFocusListener(this); |
||||
} |
||||
|
||||
private boolean checkField() { |
||||
boolean error = false; |
||||
|
||||
field_value=""; |
||||
try |
||||
{ |
||||
field_value = getText(); |
||||
} |
||||
catch (NullPointerException e) |
||||
{ |
||||
//komischer Bug in java1.6.11
|
||||
|
||||
} |
||||
if (field_value.equals("")) { |
||||
//setKey (new Integer ("-1"));
|
||||
setKey(defaultValue); //s.Kommentar bei setDefaultValue
|
||||
if (isInputNeeded()) |
||||
return false; |
||||
else |
||||
return true; |
||||
} |
||||
|
||||
field_value = getKey().toString(); |
||||
if (field_value.equals("-1")) |
||||
field_value = getText(); |
||||
|
||||
try { |
||||
switch (field_type) { |
||||
case TYPE_INTEGER: { |
||||
new Integer(field_value); |
||||
//System.out.println ("Fieldtype: integer: " + field_value);
|
||||
break; |
||||
} |
||||
case TYPE_DOUBLE: { |
||||
//NumberFormat nf = NumberFormat.getNumberInstance();
|
||||
//Number new_number = nf.parse(field_value);
|
||||
//setText(nf.format(new Double(new_number.doubleValue())));
|
||||
//dq memo: hier locale reinbringen
|
||||
//setText(nf.format(new Double(new_number.doubleValue())));
|
||||
//System.out.println ("Fieldtype: double: " + field_value);
|
||||
break; |
||||
} |
||||
case TYPE_DATE: { |
||||
if (!de.memtext.util.DateUtils.isValidDate(field_value)) |
||||
throw new Exception("Date error"); |
||||
// java.sql.Date sql_date = SxDate.getDate(field_value);
|
||||
// if (sql_date == null) {
|
||||
//System.err.println ("sxFieldListener: ERROR: arg: Date !=
|
||||
// " + field_value);
|
||||
//throw new Exception("Date error");
|
||||
// }
|
||||
//setText(SxDate.toString(sql_date));
|
||||
//System.out.println ("Fieldtype: date: " + field_value);
|
||||
break; |
||||
} |
||||
default: |
||||
//System.out.println ("Fieldtype: " + field_type + ": " +
|
||||
// field_value);
|
||||
break; |
||||
} |
||||
} |
||||
|
||||
catch (Exception ex) { |
||||
// System.err.println ("checkField(): ERROR: Type: " + field_type +
|
||||
// ": " + field_value);
|
||||
error = true; |
||||
} |
||||
|
||||
if (error) |
||||
return false; |
||||
else |
||||
return true; |
||||
|
||||
} |
||||
|
||||
public void focusGained(FocusEvent e) { |
||||
field_input = false; |
||||
} |
||||
|
||||
public void focusLost(FocusEvent e) { |
||||
if (field_input == true) { |
||||
setKey(new Integer("-1")); |
||||
if (sxForm != null) |
||||
if (isWithCombo()) { |
||||
JComboBox combo = (JComboBox) sxForm.getComp(getName()); |
||||
if (combo.getItemCount() > 0) |
||||
combo.removeAllItems(); |
||||
} |
||||
} |
||||
|
||||
if (!isValid()) { |
||||
if (sxForm != null) |
||||
sxForm.addErrorComp(this); |
||||
} else { |
||||
if (sxForm != null) |
||||
sxForm.removeErrorComp(this); |
||||
} |
||||
} |
||||
|
||||
public SichtApplet getSelectedSicht() { |
||||
return selectedSicht; |
||||
} |
||||
|
||||
public void setSelectedSicht(SichtApplet sicht) { |
||||
this.selectedSicht = sicht; |
||||
} |
||||
public void clearSichtSelections() |
||||
{ |
||||
if (selectedSicht!=null) selectedSicht.clearSelection(); |
||||
if (sichtgruppe!=null) sichtgruppe.clearSelections(); |
||||
} |
||||
public String toString() { |
||||
String result = ""; |
||||
if (getText() != null) |
||||
result += getText(); |
||||
result += " -key:"; |
||||
if (getKey() != null) |
||||
result += getKey(); |
||||
else |
||||
result += " null"; |
||||
|
||||
return result; |
||||
} |
||||
public Sichtgruppe getSichtgruppe() { |
||||
return sichtgruppe; |
||||
} |
||||
public void setSichtgruppe(Sichtgruppe sichtgruppe) { |
||||
this.sichtgruppe = sichtgruppe; |
||||
} |
||||
} |
@ -1,930 +0,0 @@
@@ -1,930 +0,0 @@
|
||||
package de.superx.applet; |
||||
|
||||
import java.awt.Color; |
||||
import java.awt.Component; |
||||
import java.awt.Dimension; |
||||
import java.awt.Font; |
||||
import java.awt.Insets; |
||||
import java.text.NumberFormat; |
||||
import java.util.Enumeration; |
||||
import java.util.HashMap; |
||||
import java.util.Hashtable; |
||||
import java.util.Properties; |
||||
import java.util.Vector; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JButton; |
||||
import javax.swing.JCheckBox; |
||||
import javax.swing.JComboBox; |
||||
import javax.swing.JComponent; |
||||
import javax.swing.JLabel; |
||||
import javax.swing.JOptionPane; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JPasswordField; |
||||
import javax.swing.JRootPane; |
||||
import javax.swing.JScrollPane; |
||||
import javax.swing.JTextArea; |
||||
import javax.swing.JToggleButton; |
||||
|
||||
import de.memtext.util.DateUtils; |
||||
|
||||
/** |
||||
* |
||||
* Stellt ein Maskenformular dar, auf dem sich einzelne Eingabe/Auswahlfelder |
||||
* (vom Typ SxField) <i>wie Semester </i> oder <i>Haushaltsjahr </i> befinden. |
||||
* |
||||
* @version 1.0 01/11/99 |
||||
* @author Rainer Behr |
||||
* @see SxField |
||||
*/ |
||||
|
||||
public class SxForm extends JPanel { |
||||
private SxForm sxForm; // r.b. 'this'
|
||||
private JButton defaultBtn; // Default-Button
|
||||
private SxPosLayout pL; |
||||
private Insets defInsets = new Insets(2, 2, 2, 2); |
||||
private int distX = 20; |
||||
private int distY = 20; |
||||
private int posX = 20; |
||||
private int posY = 20; |
||||
private int diffX = 20; |
||||
private int diffY = 20; |
||||
private HashMap fmMap = new HashMap(); |
||||
private int prefWidth = 200; //400;
|
||||
private int prefHeight = 150; |
||||
private int prefCompHeight = 25; |
||||
|
||||
private SxLogoPanel logo = null; // Logo
|
||||
private Vector fieldVector = null; // Vector for field params
|
||||
private Vector fieldKeys = null; // Vector for field names
|
||||
private Hashtable formMap; // Hashtable for Components
|
||||
private Hashtable errorMap; // Hashtable for Error-Components
|
||||
|
||||
private boolean isErlaubt = false; |
||||
private String hinweis; |
||||
|
||||
private static NumberFormat nf = NumberFormat.getInstance(); |
||||
|
||||
public SxForm() { |
||||
super(); |
||||
|
||||
sxForm = this; |
||||
|
||||
init(); |
||||
} |
||||
|
||||
public SxForm(int dist_x, int dist_y, int diff_x, int diff_y) { |
||||
super(); |
||||
|
||||
sxForm = this; |
||||
|
||||
distX = dist_x; |
||||
distY = dist_y; |
||||
diffX = diff_x; |
||||
diffY = diff_y; |
||||
|
||||
init(); |
||||
} |
||||
|
||||
public void addComp(String value, String comp_name, String class_name, |
||||
int columns, int type, int length, int obligatorisch) { |
||||
Dimension dim = null; |
||||
JButton button; |
||||
JToggleButton toggle; |
||||
JCheckBox checkbox; |
||||
JLabel label; |
||||
SxField field; |
||||
JPasswordField passwordfield; |
||||
JComboBox combo; |
||||
//MBComboView combov;
|
||||
JTextArea t_area; |
||||
|
||||
if (class_name.equals("JButton")) { |
||||
button = new JButton(value); |
||||
button.setName(comp_name); |
||||
button.setMargin(defInsets); |
||||
button.setFont(new Font("SansSerif", Font.BOLD, 12)); |
||||
add(comp_name, button); |
||||
dim = button.getPreferredSize(); |
||||
dim.height = prefCompHeight; |
||||
// dim.width=1000;
|
||||
button.setPreferredSize(dim); |
||||
pL.setPosition(button, posX, posY, dim.width, dim.height); |
||||
formMap.put(comp_name, button); |
||||
} |
||||
|
||||
if (class_name.equals("JToggleButton")) { |
||||
toggle = new JToggleButton(value); |
||||
toggle.setName(comp_name); |
||||
toggle.setMargin(defInsets); |
||||
toggle.setFont(new Font("Arial", Font.BOLD, 12)); |
||||
add(comp_name, toggle); |
||||
dim = toggle.getPreferredSize(); |
||||
dim.height = prefCompHeight; |
||||
toggle.setPreferredSize(dim); |
||||
pL.setPosition(toggle, posX, posY, dim.width, dim.height); |
||||
formMap.put(comp_name, toggle); |
||||
} |
||||
|
||||
if (class_name.equals("JCheckBox")) { |
||||
checkbox = new JCheckBox(value); |
||||
checkbox.setName(comp_name); |
||||
checkbox.setMargin(defInsets); |
||||
checkbox.setFont(new Font("Arial", Font.BOLD, 12)); |
||||
add(comp_name, checkbox); |
||||
dim = checkbox.getPreferredSize(); |
||||
dim.height = prefCompHeight; |
||||
checkbox.setPreferredSize(dim); |
||||
pL.setPosition(checkbox, posX, posY, dim.width, dim.height); |
||||
formMap.put(comp_name, checkbox); |
||||
} |
||||
|
||||
if (class_name.equals("JLabel")) { |
||||
label = new JLabel(value); |
||||
label.setName(comp_name); |
||||
label.setFont(new Font("SansSerif", Font.PLAIN, 12)); |
||||
add(comp_name, label); |
||||
//MB n
|
||||
dim = label.getPreferredSize(); |
||||
if (!comp_name.equals("L_parameter")) { |
||||
|
||||
dim.height = prefCompHeight; |
||||
label.setPreferredSize(dim); |
||||
} |
||||
pL.setPosition(label, posX, posY, dim.width, dim.height); |
||||
formMap.put(comp_name, label); |
||||
} |
||||
|
||||
if (class_name.equals("SxField")) { |
||||
field = new SxField(value, columns, type, length); |
||||
field.setName(comp_name); |
||||
field.setForm(sxForm); |
||||
field.setMargin(defInsets); |
||||
field.setBackground(Color.white); |
||||
if (length > 0) |
||||
field.setEditable(true); |
||||
else |
||||
field.setEditable(false); |
||||
if (obligatorisch != 0) |
||||
field.setInputNeeded(true); |
||||
add(comp_name, field); |
||||
dim = field.getPreferredSize(); |
||||
dim.height = prefCompHeight; |
||||
field.setPreferredSize(dim); |
||||
pL.setPosition(field, posX, posY, dim.width, dim.height); |
||||
formMap.put(comp_name, field); |
||||
} |
||||
if (class_name.equals("JPasswordField")) { |
||||
passwordfield = new JPasswordField(value); |
||||
passwordfield.setName(comp_name); |
||||
passwordfield.setMargin(defInsets); |
||||
passwordfield.setFont(new Font("Arial", Font.BOLD, 12)); |
||||
add(comp_name, passwordfield); |
||||
dim = passwordfield.getPreferredSize(); |
||||
dim.height = prefCompHeight; |
||||
passwordfield.setPreferredSize(dim); |
||||
pL.setPosition(passwordfield, posX, posY, dim.width, dim.height); |
||||
formMap.put(comp_name, passwordfield); |
||||
} |
||||
|
||||
if (class_name.equals("JTextArea")) { |
||||
t_area = new JTextArea(value); |
||||
t_area.setName(comp_name); |
||||
t_area.setMargin(defInsets); |
||||
t_area.setBackground(Color.white); |
||||
if (length > 0) |
||||
t_area.setEditable(true); |
||||
else |
||||
t_area.setEditable(false); |
||||
add(comp_name, t_area); |
||||
dim = t_area.getPreferredSize(); |
||||
dim.height = prefCompHeight; |
||||
t_area.setPreferredSize(dim); |
||||
pL.setPosition(t_area, posX, posY, dim.width, dim.height); |
||||
formMap.put(comp_name, t_area); |
||||
} |
||||
|
||||
if (class_name.equals("JComboBox")) { |
||||
combo = new JComboBox(); |
||||
combo.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
||||
combo.setName(comp_name); |
||||
combo.setBackground(Color.white); |
||||
if (length > 0) { |
||||
field = new SxField(type, length); |
||||
field.setName(comp_name); |
||||
field.setWithCombo(true); |
||||
field.setMargin(defInsets); |
||||
field.setForm(sxForm); |
||||
if (obligatorisch != 0) |
||||
field.setInputNeeded(true); |
||||
combo.setEditor(field); |
||||
combo.setEditable(true); |
||||
} else |
||||
combo.setEditable(false); |
||||
add(comp_name, combo); |
||||
dim = combo.getPreferredSize(); |
||||
dim.height = prefCompHeight; |
||||
combo.setPreferredSize(dim); |
||||
pL.setPosition(combo, posX, posY, dim.width, dim.height); |
||||
formMap.put(comp_name, combo); |
||||
} |
||||
|
||||
/* |
||||
* MB wie ComboBox nur ohne Selektionsmöglichkeit if (class_name.equals |
||||
* ("JComboView")) { combov = new MBComboView(comp_name.substring(2)); |
||||
* //combo.addItem(" <Ihre Auswahl:>");
|
||||
* combov.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
||||
* combov.setName (comp_name); combov.setBackground(Color.white); |
||||
* field=new SxField(); if (length > 0) { field = new SxField (type, |
||||
* length); field.setName (comp_name); field.setWithCombo (true); |
||||
* field.setMargin(defInsets); field.setForm (sxForm); if (input != 0) |
||||
* field.needsInput(true); combov.setEditor (field); |
||||
* combov.setEditable(true); field.setText (" < Ihre Auswahl > "); } |
||||
* |
||||
* combo.addActionListener(new ActionListener(){ public void |
||||
* actionPerformed(ActionEvent e){ combo.setSelectedIndex(1); }} ); |
||||
* JButton help=(JButton)this.getComp("L_"+comp_name.substring(2)); |
||||
* ComboViewAL spezialItemListener=new ComboViewAL(combov,help); |
||||
* combov.addItemListener(spezialItemListener); |
||||
* |
||||
* combov.setRenderer(new ComboViewRenderer()); |
||||
* |
||||
* add (comp_name, combov); |
||||
* |
||||
* dim = combov.getPreferredSize(); dim.height = prefCompHeight; |
||||
* combov.setPreferredSize(dim); pL.setPosition(combov, posX, posY, |
||||
* dim.width, dim.height); formMap.put (comp_name, combov); } |
||||
*/ |
||||
|
||||
fieldKeys.add(comp_name); |
||||
|
||||
if (diffX + dim.width + posX < prefWidth) { |
||||
posX += diffX + dim.width; |
||||
} else { |
||||
posX = distX; |
||||
posY += diffY + dim.height; |
||||
} |
||||
} |
||||
|
||||
public void addErrorComp(Component comp) { |
||||
String err_name = comp.getName(); |
||||
if (err_name != null) { |
||||
if (!errorMap.containsKey(err_name)) |
||||
errorMap.put(err_name, comp); |
||||
} |
||||
} |
||||
|
||||
public JComponent getComp(String comp_name) { |
||||
return (JComponent) formMap.get(comp_name); |
||||
} |
||||
|
||||
public JButton getDefaultBtn() { |
||||
if (defaultBtn == null) { |
||||
JRootPane root = sxForm.getRootPane(); |
||||
return root.getDefaultButton(); |
||||
} |
||||
|
||||
return defaultBtn; |
||||
} |
||||
|
||||
/** |
||||
* |
||||
* |
||||
*/ |
||||
public void restoreValuesFromFormerSelections() { |
||||
Enumeration en; |
||||
String name; |
||||
SxField field; |
||||
Properties prop; |
||||
Object key; |
||||
Object value; |
||||
|
||||
en = formMap.keys(); |
||||
|
||||
while (en.hasMoreElements()) { |
||||
name = (String) en.nextElement(); |
||||
if (name.startsWith("F_")) { |
||||
field = getField(name); |
||||
if (field == null) |
||||
continue; |
||||
name = name.substring(2); |
||||
if (field.hasSichten()) |
||||
name += "-Sicht" + field.getSelectedSicht().getId(); |
||||
prop = (Properties) SxDefaults.getProperty(name); |
||||
if (prop == null) |
||||
continue; |
||||
try { |
||||
key = prop.get("key"); |
||||
field.setKey(key); |
||||
if (field.hasSichten()) { |
||||
if (key == null || key.toString().equals("null")) |
||||
field.getSelectedSicht().clearSelection(); |
||||
else |
||||
{ |
||||
field.getSelectedSicht().setSelectedKey(key.toString()); |
||||
|
||||
} |
||||
} |
||||
value = prop.get("value"); |
||||
|
||||
if (field.isWithCombo()) { |
||||
if (value instanceof String[]) { |
||||
String[] values = (String[]) value; |
||||
|
||||
JComboBox combo = (JComboBox) getComp("F_" + name); |
||||
int n = values.length; |
||||
for (int i = 0; i < n; i++) |
||||
combo.insertItemAt(values[i], i); |
||||
|
||||
field.setText(" < Ihre Auswahl> "); |
||||
} else { |
||||
field.setText(value.toString()); |
||||
} |
||||
|
||||
} else { //not combo
|
||||
if (key instanceof String[]) |
||||
return; |
||||
field.setText(value.toString()); |
||||
} |
||||
} |
||||
catch (Exception e) |
||||
{ |
||||
System.out.println("Problem beim Wiederherstellen von Auswahlwert "+e); |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
public boolean isErlaubt() { |
||||
return isErlaubt; |
||||
} |
||||
|
||||
/** |
||||
* Get first component that causes an error - if any |
||||
* |
||||
* @return 1st component that causes an error - null if everything OK |
||||
*/ |
||||
public Component getErrorComp() { |
||||
Enumeration en = errorMap.keys(); |
||||
String err_name; |
||||
|
||||
if (en.hasMoreElements()) { |
||||
err_name = (String) en.nextElement(); |
||||
//System.out.println("err_name: " + err_name);
|
||||
return (Component) errorMap.get(err_name); |
||||
} else |
||||
return null; |
||||
} |
||||
|
||||
public Component getErrorComp(String name) { |
||||
return (Component) errorMap.get(name); |
||||
} |
||||
|
||||
public SxField getField(Object obj) { |
||||
SxField field = null; |
||||
|
||||
if (obj == null) |
||||
return null; |
||||
|
||||
if (obj instanceof SxField) |
||||
return (SxField) obj; |
||||
|
||||
if (obj instanceof JComboBox) { |
||||
JComboBox combo = (JComboBox) obj; |
||||
field = (SxField) combo.getEditor(); |
||||
return field; |
||||
} |
||||
|
||||
return field; |
||||
} |
||||
|
||||
public SxField getField(String comp_name) { |
||||
return getField(getComp(comp_name)); |
||||
} |
||||
|
||||
/** |
||||
* fiese Methode, die für jedes Feld prüft, ob sichten hinterlegt sind, wenn |
||||
* ja wird die ausgewählte Sicht unter Feldnamen in einen Hashtable gepackt |
||||
* bei normalen Felder wird der ausgewählte Wert für den Schlüssel |
||||
* hinterlegt |
||||
* @param maskNo TODO |
||||
* |
||||
* @deprecated not really deprecated but evil |
||||
* @return Hashtable |
||||
*/ |
||||
HashMap getHashMap(Integer maskNo) { |
||||
|
||||
if (maskNo!=null) fmMap.put("Maskennummer",maskNo); |
||||
for (Enumeration enumeration = getMap().keys(); enumeration |
||||
.hasMoreElements();) { |
||||
String fieldname = (String) enumeration.nextElement(); |
||||
if (fieldname.startsWith("F_")) { |
||||
SxField aField = getField(fieldname); |
||||
if (aField.hasSichten()) { |
||||
fmMap.put(aField.getName().substring(2), aField |
||||
.getSelectedSicht()); |
||||
|
||||
aField.getSelectedSicht().updateKlappstatus(); |
||||
if (aField.getSelectedSicht().isStandbuttonWanted()) |
||||
fmMap.put(aField.getName().substring(2) + "-Stand", aField |
||||
.getSelectedSicht().getStand()); |
||||
} else { |
||||
Object o=aField.getKey(); |
||||
if (o!=null&&o.toString().equals("-1")) |
||||
o=getFieldKey(aField.getName()); |
||||
//aField.getKey() liefert falsches Ergebnis für direkeingabeFelder
|
||||
//eigentlich getFieldKey(aField.getName())); dann aber potentiell
|
||||
//zu viele ' einfache Anführungszeichen
|
||||
|
||||
fmMap.put(aField.getName().substring(2), o); |
||||
aField.getItem(); |
||||
} |
||||
} |
||||
} |
||||
return fmMap; |
||||
} |
||||
|
||||
/** |
||||
* Checks if all fields that require input also contain input If a field |
||||
* doesn't it is added to errorComp collection |
||||
* |
||||
* getFieldContents also does a check - can we just remove that? |
||||
* |
||||
* @throws Exception |
||||
*/ |
||||
void checkFields() throws Exception { |
||||
for (Enumeration enumeration = getMap().keys(); enumeration |
||||
.hasMoreElements();) { |
||||
String fieldname = (String) enumeration.nextElement(); |
||||
if (fieldname.startsWith("F_")) { |
||||
SxField aField = getField(fieldname); |
||||
|
||||
String content = aField.getText(); |
||||
if (aField.isInputNeeded() |
||||
&& (content == null || content.equals(""))) { |
||||
aField.setBackground(Color.red); |
||||
addErrorComp(aField); |
||||
} |
||||
|
||||
} |
||||
} |
||||
Component err_comp = getErrorComp(); |
||||
if (err_comp != null) { |
||||
String err_name = err_comp.getName().substring(2); |
||||
throw new Exception("Im Feld '" + err_name |
||||
+ "' müssen Sie etwas auswählen bzw. eingeben!"); |
||||
} |
||||
} |
||||
|
||||
private String getFieldContents(String field_name) { |
||||
SxField field; |
||||
String contents = null; |
||||
|
||||
field = getField(field_name); |
||||
if (field == null) |
||||
return null; |
||||
|
||||
if (field.getText().equals("")) |
||||
return null; |
||||
|
||||
if (field.getType() == SxField.TYPE_DATE) { |
||||
contents = field.getText(); |
||||
} |
||||
if (field.getType() == SxField.TYPE_DOUBLE) { |
||||
try { |
||||
Number number_value = nf.parse(field.getText().replace('.', ',')); |
||||
Double double_value = new Double(number_value.doubleValue()); |
||||
|
||||
if (double_value != null) |
||||
contents = double_value.toString(); |
||||
} catch (Exception ex) { |
||||
contents = null; |
||||
} |
||||
} |
||||
if (field.getType() == SxField.TYPE_STRING) { |
||||
contents = field.getText(); |
||||
if (contents!=null) contents=contents.replace(';','^'); |
||||
//manchmal Fehler wenn man Leeren drückt wird für execute procedure
|
||||
// zu (,,) nicht ('null',xxx)
|
||||
//evtl. hier anpassen
|
||||
//if (contents.equals("-1") contents="null";
|
||||
} |
||||
if (field.getType()==SxField.TYPE_SQL) { |
||||
contents = field.getText(); |
||||
if (contents!=null) contents=contents.replace(';','^'); |
||||
} |
||||
if (field.getType() == SxField.TYPE_INTEGER) |
||||
contents = field.getText(); |
||||
|
||||
// moved to method checkField, can I just delete it??
|
||||
if (field.isInputNeeded() && (contents == null || contents.equals(""))) { |
||||
System.err.println("Eingabe in '" + field_name.substring(2) |
||||
+ "' fehlt !"); |
||||
field.setBackground(Color.red); |
||||
addErrorComp(field); |
||||
} |
||||
|
||||
return contents; |
||||
|
||||
} |
||||
|
||||
public String getFieldKey(String field_name) { |
||||
Object obj; |
||||
SxField field; |
||||
Object key; |
||||
String sx_db = (String) SxDefaults.getPropertyValue("SxDB"); |
||||
|
||||
obj = getComp(field_name); |
||||
if (obj == null) |
||||
return null; |
||||
|
||||
field = getField(obj); |
||||
if (field == null) |
||||
return null; |
||||
|
||||
key = field.getKey(); |
||||
//System.out.println("Feldname: "+field_name+"; key: " +
|
||||
// key.toString());
|
||||
|
||||
if (!field.isWithCombo()) { |
||||
if (key instanceof String[]) |
||||
return ""; |
||||
if (key.toString().equals("null")) |
||||
if (field.getType() == SxField.TYPE_STRING |
||||
|| field.getType() == SxField.TYPE_DATE) |
||||
return "'null'"; |
||||
else |
||||
return ""; |
||||
if (key.toString().equals("-1")) { |
||||
//Einfaches Textfeld
|
||||
String w = getFieldContents(field_name); |
||||
int dummy=1; |
||||
if (w == null) |
||||
return ""; |
||||
if (field.getType() == SxField.TYPE_STRING |
||||
|| field.getType() == SxField.TYPE_DATE) |
||||
return "'" + w + "'"; |
||||
else |
||||
if (field.getType()==SxField.TYPE_DOUBLE) |
||||
return w.replace(',','.'); |
||||
else return w; |
||||
|
||||
} else { |
||||
//Dialogfeld mit key:
|
||||
if (key.toString().equals("")) |
||||
return ""; |
||||
if (field.getType() == SxField.TYPE_STRING |
||||
|| field.getType() == SxField.TYPE_DATE) |
||||
return "'" + key.toString() + "'"; |
||||
else |
||||
if (field.getType()==SxField.TYPE_DOUBLE) |
||||
return key.toString().replace(',','.'); |
||||
else |
||||
return key.toString(); |
||||
|
||||
//}
|
||||
} |
||||
} else { |
||||
//Das Applet setzt Mehrfachauswahlfelder automatisch je nach Typ um
|
||||
// als int oder string
|
||||
//Die explizite Deklaration wird in Felderinfo definiert (typ)
|
||||
String key_str = ""; |
||||
if (key instanceof String[]) { |
||||
String[] keys = (String[]) key; |
||||
|
||||
for (int i = 0; i < keys.length; i++) { |
||||
if (i > 0) |
||||
key_str = key_str + ","; |
||||
if (field.getType() == SxField.TYPE_STRING) |
||||
key_str = key_str + "'" + keys[i] + "'"; |
||||
else |
||||
key_str = key_str + keys[i]; |
||||
} |
||||
} else { |
||||
//manchmal Fehler wenn man Leeren drückt wird für execute
|
||||
// procedure zu (,,) nicht ('null',xxx)
|
||||
//evtl. getFieldContents anpassen
|
||||
|
||||
if (key.toString().equals("-1")) |
||||
return getFieldContents(field_name); |
||||
else |
||||
//System.out.println("KEYS"+field_name);
|
||||
if (field.getType() == SxField.TYPE_STRING) |
||||
return "'" + key.toString() + "'"; |
||||
else |
||||
return key.toString(); |
||||
} |
||||
|
||||
return key_str; |
||||
} |
||||
} |
||||
|
||||
public Vector getFieldVector() { |
||||
return fieldVector; |
||||
} |
||||
|
||||
public SxLogoPanel getLogo() { |
||||
return logo; |
||||
} |
||||
|
||||
public Hashtable getMap() { |
||||
return formMap; |
||||
} |
||||
|
||||
public String getParamList(String username, boolean isHtmlWanted) { |
||||
Enumeration en; |
||||
String name; |
||||
SxField field; |
||||
Properties prop; |
||||
|
||||
StringBuffer contents; |
||||
StringBuffer paramList = new StringBuffer(); |
||||
|
||||
// HTML-Properties aus SxDefaults
|
||||
String html_start = ""; |
||||
String html_end = ""; |
||||
String html_bold_on = ""; |
||||
String html_bold_off = ""; |
||||
try { |
||||
html_start = (String) SxDefaults.getPropertyValue("SxParamStart"); |
||||
html_end = (String) SxDefaults.getPropertyValue("SxParamEnd"); |
||||
html_bold_on = (String) SxDefaults |
||||
.getPropertyValue("SxParamBoldOn"); |
||||
html_bold_off = (String) SxDefaults |
||||
.getPropertyValue("SxParamBoldOff"); |
||||
} catch (NullPointerException ex) { |
||||
System.err.println(ex); |
||||
JOptionPane.showMessageDialog(sxForm, ex.toString(), "Fehler", |
||||
JOptionPane.ERROR_MESSAGE); |
||||
} |
||||
if (isHtmlWanted) |
||||
paramList.append(html_start); |
||||
|
||||
// sort keys
|
||||
//java.util.List L_keys = Arrays.asList (formMap.keySet().toArray());
|
||||
//Collections.sort (L_keys, Collator.getInstance());
|
||||
//
|
||||
String orgStand = ""; |
||||
for (int k = 0; k < fieldKeys.size(); k++) { |
||||
name = (String) fieldKeys.elementAt(k); |
||||
if (!name.startsWith("F_")) |
||||
continue; |
||||
field = getField(name); |
||||
if (field == null || !field.isVisible()) |
||||
continue; |
||||
contents = new StringBuffer(); |
||||
|
||||
if (!field.isWithCombo()) { |
||||
contents.append(field.getText()); |
||||
} else { |
||||
JComboBox combo = (JComboBox) getComp(name); |
||||
int n = combo.getItemCount(); |
||||
if (n == 0) |
||||
contents.append(field.getText()); |
||||
else |
||||
for (int i = 0; i < n; i++) { |
||||
contents.append((String) combo.getItemAt(i)); |
||||
if (i < n - 1) |
||||
contents.append(", "); |
||||
} |
||||
} |
||||
|
||||
if (field.hasSichten()) { |
||||
if (contents.length() == 0) { |
||||
contents.append("keine Einschränkung "); |
||||
} |
||||
if (!field.getSelectedSicht().isPerfectlyRegular()) |
||||
contents.append(" (" + field.getSelectedSicht().getName() |
||||
+ ")"); |
||||
if (field.getSelectedSicht().isStandbuttonWanted()) |
||||
contents.append(" - Stand " |
||||
+ field.getSelectedSicht().getStand()); |
||||
} |
||||
if (contents.length() <= 0) |
||||
continue; |
||||
|
||||
if (isHtmlWanted) |
||||
paramList.append(html_bold_on + name.substring(2) |
||||
+ html_bold_off); |
||||
else |
||||
paramList.append(name.substring(2)); |
||||
paramList.append(" = " + contents.toString() + "; "); |
||||
if (!isHtmlWanted) |
||||
paramList.append("\n"); |
||||
|
||||
} |
||||
if (isHtmlWanted) |
||||
paramList.append(html_bold_on + "User" + html_bold_off + "=" |
||||
+ username + ";<br>"); |
||||
else |
||||
paramList.append("User=" + username + "\n"); |
||||
paramList.append(this.getHinweis()); |
||||
if (isHtmlWanted) |
||||
paramList.append(html_end); |
||||
|
||||
//System.err.println("ParamList:");
|
||||
//System.err.println(paramList.toString());
|
||||
|
||||
return paramList.toString(); |
||||
} |
||||
|
||||
public void init() { |
||||
sxForm.setBorder(BorderFactory.createEtchedBorder()); |
||||
pL = new SxPosLayout(distX, distY, diffX, diffY); |
||||
pL.setPreferredSize(prefWidth, prefHeight); |
||||
sxForm.setLayout(pL); |
||||
sxForm.setFont(new Font("Arial", Font.PLAIN, 12)); |
||||
|
||||
formMap = new Hashtable(); |
||||
fieldKeys = new Vector(); |
||||
errorMap = new Hashtable(); |
||||
} |
||||
|
||||
public void removeAll() { |
||||
super.removeAll(); |
||||
|
||||
formMap.clear(); |
||||
fieldKeys.clear(); |
||||
errorMap.clear(); |
||||
|
||||
defaultBtn = null; |
||||
|
||||
posX = 20; |
||||
posY = 20; |
||||
} |
||||
|
||||
public void removeComp(String name) { |
||||
Component comp; |
||||
comp = getComp(name); |
||||
if (comp == null) |
||||
return; |
||||
formMap.remove(comp); |
||||
super.remove(comp); |
||||
comp = null; |
||||
} |
||||
|
||||
public void removeErrorComp(Component comp) { |
||||
String err_name = comp.getName(); |
||||
if (err_name != null) { |
||||
errorMap.remove(err_name); |
||||
//System.out.println("err_name in removeErrorComp: " + err_name);
|
||||
} |
||||
|
||||
} |
||||
|
||||
//MB 5/04
|
||||
//only used by SxMask for L_Parameter, obsolete
|
||||
/* |
||||
* public void resizeComp(String name, int width) { JComponent comp; |
||||
* Dimension comp_dim; comp = getComp(name); if (comp == null) return; |
||||
* |
||||
* comp_dim = comp.getSize(); comp_dim.width = width; super.remove(comp); |
||||
* comp.setSize(comp_dim); super.add(comp); } |
||||
*/ |
||||
public void setCompXY(String comp_name, int pos_x, int pos_y) { |
||||
Component comp = (Component) getComp(comp_name); |
||||
if (comp == null) |
||||
return; |
||||
Dimension dim = comp.getPreferredSize(); |
||||
pL.setPosition(comp, pos_x, pos_y, dim.width, dim.height); |
||||
} |
||||
|
||||
public void setDefaultBtn(JButton btn) { |
||||
defaultBtn = btn; |
||||
} |
||||
|
||||
public void rememberSelectionsAsDefaults() { |
||||
Enumeration en; |
||||
String name; |
||||
SxField field; |
||||
|
||||
// erlaubt=new Integer(0);
|
||||
en = formMap.keys(); |
||||
|
||||
while (en.hasMoreElements()) { |
||||
name = (String) en.nextElement(); |
||||
|
||||
if (name.startsWith("F_")) { |
||||
field = getField(name); |
||||
if (field == null) |
||||
continue; |
||||
name = name.substring(2); |
||||
if (!field.isWithCombo()) { |
||||
if (field.hasSichten()) |
||||
name += "-Sicht" + field.getSelectedSicht().getId(); |
||||
SxDefaults.addProperty(name, field.getKey(), field |
||||
.getText()); |
||||
} else { |
||||
//COMBOFIELD
|
||||
if (field.getKey() instanceof Object[]) { |
||||
String[] keys = (String[]) field.getKey(); |
||||
String[] values = new String[keys.length]; |
||||
JComboBox combo = (JComboBox) getComp("F_" + name); |
||||
int n = combo.getItemCount(); |
||||
for (int i = 0; i < n; i++) |
||||
values[i] = (String) combo.getItemAt(i); |
||||
|
||||
SxDefaults.addProperty(name, keys, values); |
||||
} else { |
||||
SxDefaults.addProperty(name, field.getKey(), field |
||||
.getText()); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} //MB die zwei Methoden werden für Institutionenauswahl
|
||||
|
||||
//benötigt, s. Kommentar in SxUtils.generateSQL()
|
||||
public void setErlaubt(boolean erl) { |
||||
isErlaubt = erl; |
||||
} |
||||
|
||||
public void setFieldVector(Vector V_field) { |
||||
fieldVector = V_field; |
||||
} |
||||
|
||||
public void setLogo(SxLogoPanel alogo) { |
||||
logo = alogo; |
||||
} |
||||
|
||||
public void setPreferredCompHeight(String comp_name, int height) { |
||||
JComponent comp = (JComponent) getComp(comp_name); |
||||
if (comp == null) |
||||
return; |
||||
Dimension dim = comp.getPreferredSize(); |
||||
dim.height = height; |
||||
comp.setPreferredSize(dim); |
||||
} |
||||
|
||||
public void setPreferredCompWidth(String comp_name, int width) { |
||||
JComponent comp = (JComponent) getComp(comp_name); |
||||
if (comp == null) |
||||
return; |
||||
Dimension dim = comp.getPreferredSize(); |
||||
dim.width = width; |
||||
comp.setPreferredSize(dim); |
||||
} |
||||
|
||||
public void setPreferredSize(int width, int height) { |
||||
prefWidth = width; |
||||
prefHeight = height; |
||||
pL.setPreferredSize(prefWidth, prefHeight); |
||||
} |
||||
|
||||
public String getHinweis() { |
||||
return hinweis != null ? hinweis : new String(""); |
||||
} |
||||
|
||||
public void setHinweis(Object Hinw) { |
||||
if (Hinw == null) |
||||
this.hinweis = null; |
||||
else |
||||
this.hinweis = Hinw.toString(); |
||||
|
||||
} |
||||
|
||||
String getDefaultStand() { |
||||
//prüfen für Default-Stand-Wert
|
||||
String defaultstand = null; |
||||
String teststring; |
||||
SxField testfield; |
||||
//Feste Abhängigkeiten rausgenommen
|
||||
//auf Wunsch von M.Winterstein 30.6.06
|
||||
/* try { |
||||
testfield = getField("F_Haushaltsjahr"); |
||||
if (testfield != null) { |
||||
String s4 = testfield.getText(); |
||||
if (s4.length() == 4) //valid date
|
||||
defaultstand = new String("1.1." + s4); |
||||
else |
||||
defaultstand = DateUtils.getTodayString(); |
||||
} |
||||
testfield = getField("F_Datum"); |
||||
if (testfield != null) |
||||
defaultstand = new String(testfield.getText()); |
||||
testfield = getField("F_Semester"); |
||||
if (testfield != null) { |
||||
SxSQL |
||||
.executeQuery("select sem_beginn from semester where eintrag='" |
||||
+ testfield.getText() + "';"); |
||||
Vector erg = SxSQL.getResultVector(); |
||||
defaultstand = (String) erg.elementAt(0); |
||||
} |
||||
|
||||
DateFormat df; |
||||
df = DateFormat.getDateInstance(DateFormat.MEDIUM); |
||||
// r.b. default Jahr 4-stellig
|
||||
df.setTimeZone(TimeZone.getDefault()); |
||||
df.setLenient(false); |
||||
|
||||
} catch (Exception e) { |
||||
|
||||
}*/ |
||||
if (defaultstand == null) |
||||
defaultstand = DateUtils.getTodayString(); |
||||
return defaultstand; |
||||
} |
||||
|
||||
|
||||
} |
@ -1,166 +0,0 @@
@@ -1,166 +0,0 @@
|
||||
package de.superx.applet; |
||||
import java.awt.Component; |
||||
import java.awt.Font; |
||||
import java.awt.GridLayout; |
||||
import java.util.Vector; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JLabel; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JTable; |
||||
import javax.swing.border.BevelBorder; |
||||
import javax.swing.table.TableCellRenderer; |
||||
/** |
||||
*Darstellung der Tabellen-Header. Wird von SxTable verwendet. |
||||
* |
||||
* @version 1.0 01/11/02 |
||||
* @author Rainer Behr |
||||
* @see SxTable |
||||
*/ |
||||
|
||||
public class SxHeaderRenderer extends JPanel implements TableCellRenderer |
||||
{ |
||||
//
|
||||
// Static Constants
|
||||
//
|
||||
|
||||
//
|
||||
// Instants
|
||||
//
|
||||
protected SxHeaderRenderer renderer; |
||||
|
||||
protected Font header_font = null; |
||||
protected Vector V_buttons = new Vector (); |
||||
protected int num_lines = 1; |
||||
protected Vector V_textlines = new Vector (); |
||||
|
||||
public SxHeaderRenderer() |
||||
{ |
||||
super(); |
||||
|
||||
renderer = this; |
||||
|
||||
renderer.setLayout(new GridLayout(0, 1)); |
||||
renderer.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); |
||||
|
||||
JLabel line = new JLabel (); |
||||
line.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); |
||||
line.setHorizontalAlignment (JLabel.CENTER); |
||||
V_buttons.addElement (line); |
||||
renderer.add (line); |
||||
|
||||
setOpaque(true); |
||||
} |
||||
|
||||
public void setNumLines(int lines) |
||||
{ |
||||
num_lines = lines; |
||||
|
||||
renderer.removeAll (); |
||||
V_buttons.removeAllElements (); |
||||
|
||||
for (int i = 0; i < num_lines; i++) |
||||
{ |
||||
JLabel line = new JLabel (); |
||||
line.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); |
||||
line.setHorizontalAlignment (JLabel.CENTER); |
||||
if (header_font != null) |
||||
line.setFont (header_font); |
||||
V_buttons.insertElementAt (line, i); |
||||
renderer.add (line); |
||||
} |
||||
} |
||||
|
||||
public int getNumLines() |
||||
{ |
||||
return num_lines; |
||||
} |
||||
|
||||
public void setTextLines(String header_value) |
||||
{ |
||||
int offset = 0; |
||||
int pos, next_pos; |
||||
int nr_lines = 0; |
||||
int n = 0; |
||||
|
||||
V_textlines.removeAllElements (); |
||||
|
||||
while (offset < header_value.length()) |
||||
{ |
||||
if ((pos = header_value.indexOf ("\\n", offset)) != -1) |
||||
{ |
||||
V_textlines.insertElementAt(header_value.substring (offset, pos), n); |
||||
n++; |
||||
nr_lines++; |
||||
|
||||
if ((next_pos = header_value.indexOf ("\\n", pos + 2)) != -1) |
||||
{ |
||||
offset = next_pos + 2; |
||||
V_textlines.insertElementAt(header_value.substring (pos + 2, next_pos), n); |
||||
n++; |
||||
nr_lines++; |
||||
} |
||||
else |
||||
{ |
||||
offset = pos + 2; |
||||
V_textlines.insertElementAt(header_value.substring (pos + 2), n); |
||||
n++; |
||||
nr_lines++; |
||||
break; |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
V_textlines.insertElementAt(header_value.substring (offset), n); |
||||
n++; |
||||
nr_lines++; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
setNumLines (nr_lines); |
||||
|
||||
for (int i = 0; i < num_lines; i++) |
||||
{ |
||||
JLabel line = (JLabel) V_buttons.elementAt (i); |
||||
line.setText ((String) V_textlines.elementAt(i)); |
||||
} |
||||
} |
||||
|
||||
public void setHeaderFont(Font newfont) |
||||
{ |
||||
header_font = newfont; |
||||
} |
||||
|
||||
public void setHorizontalAlignment(int alignment) |
||||
{ |
||||
for (int i = 0; i < num_lines; i++) |
||||
{ |
||||
JLabel line = (JLabel) V_buttons.elementAt (i); |
||||
line.setHorizontalAlignment (alignment); |
||||
} |
||||
} |
||||
|
||||
public void setText(Object value) |
||||
{ |
||||
if (V_textlines.size () == 0) |
||||
setTextLines(value.toString()); |
||||
|
||||
for (int i = 0; i < num_lines; i++) |
||||
{ |
||||
JLabel line = (JLabel) V_buttons.elementAt (i); |
||||
line.setText ((String) V_textlines.elementAt(i)); |
||||
} |
||||
} |
||||
|
||||
public Component getTableCellRendererComponent (JTable table, Object value, |
||||
boolean isSelected, |
||||
boolean hasFocus, |
||||
int row, int column) |
||||
{ |
||||
if (value != null) |
||||
setText (value.toString()); |
||||
|
||||
return (Component) renderer; |
||||
} |
||||
} |
@ -1,68 +0,0 @@
@@ -1,68 +0,0 @@
|
||||
package de.superx.applet; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.util.Vector; |
||||
|
||||
import javax.swing.JOptionPane; |
||||
import javax.swing.JTable; |
||||
/** |
||||
* |
||||
* Listener für den Einfügen-Button bei einer Mehrfachauswahl. |
||||
* @version 1.0 15.09.00 |
||||
* @author Rainer Behr |
||||
* @see SxDlg |
||||
*/ |
||||
public class SxInsertListener implements ActionListener |
||||
{ |
||||
SxTablePanel table; |
||||
JTable jtable; |
||||
JTable jtable2; |
||||
SxTablePanel table2; |
||||
|
||||
SxInsertListener() |
||||
{ |
||||
table = SxDlgManager.getDlgTable(); |
||||
jtable = table.getTable(); |
||||
table2 = SxDlgManager.getChoiceTable(); |
||||
jtable2 = table2.getTable(); |
||||
}; |
||||
|
||||
public void actionPerformed(ActionEvent e) |
||||
{ |
||||
Vector V_data = SxDlgManager.getDlgData(); |
||||
Vector V_choice = SxDlgManager.getChoiceData(); |
||||
int [] rows = jtable.getSelectedRows(); |
||||
int cols = jtable.getColumnCount(); |
||||
|
||||
SxTableSorter model = (SxTableSorter) jtable.getModel(); |
||||
SxTableSorter model2 = (SxTableSorter) jtable2.getModel(); |
||||
int [] indexes = model.getIndexes(); |
||||
|
||||
if (rows.length <= 0) |
||||
return; |
||||
|
||||
if (rows.length > 30) |
||||
{ |
||||
String msg = "Bitte nicht mehr als 30 Werte auswählen !"; |
||||
// System.err.println (msg);
|
||||
JOptionPane.showMessageDialog(table.getParent(), msg, "Dialogfehler", |
||||
JOptionPane.ERROR_MESSAGE); |
||||
return; |
||||
} |
||||
|
||||
for (int i = 0; i < rows.length; i++) |
||||
{ |
||||
|
||||
// r.b. 15.09.00
|
||||
// findet den entsprechenden Eintrag nur wenn Object-Typ in Tabelle u. Vector
|
||||
// uebereinstimmt s.o.
|
||||
if (!V_choice.contains (V_data.elementAt(indexes[rows[i]]))) |
||||
V_choice.addElement (V_data.elementAt(indexes[rows[i]])); |
||||
} |
||||
|
||||
table2.setData (V_choice); |
||||
|
||||
model2.sortByColumn (cols - 1); |
||||
} |
||||
} |
||||
|
@ -1,545 +0,0 @@
@@ -1,545 +0,0 @@
|
||||
// Beispielklasse aus dem JavaTutorial (http://java.sun.com/docs/books/tutorial) für SuperX angepasst
|
||||
/* |
||||
* @(#)JDBCAdapter.java 1.5 97/12/03 |
||||
* |
||||
* Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved. |
||||
* |
||||
* This software is the confidential and proprietary information of Sun |
||||
* Microsystems, Inc. ("Confidential Information"). You shall not |
||||
* disclose such Confidential Information and shall use it only in |
||||
* accordance with the terms of the license agreement you entered into |
||||
* with Sun. |
||||
* |
||||
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE |
||||
* SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE |
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
||||
* PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES |
||||
* SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING |
||||
* THIS SOFTWARE OR ITS DERIVATIVES. |
||||
* |
||||
*/ |
||||
|
||||
/** |
||||
* An adaptor, transforming the JDBC interface to the TableModel interface. |
||||
* |
||||
* @version 1.20 09/25/97 |
||||
* @author Philip Milne |
||||
*/ |
||||
|
||||
package de.superx.applet; |
||||
import java.math.BigDecimal; |
||||
import java.sql.Connection; |
||||
import java.sql.ResultSet; |
||||
import java.sql.SQLException; |
||||
import java.sql.Statement; |
||||
import java.sql.Timestamp; |
||||
import java.sql.Types; |
||||
import java.text.NumberFormat; |
||||
import java.text.ParseException; |
||||
import java.util.Properties; |
||||
import java.util.Vector; |
||||
|
||||
import javax.swing.table.AbstractTableModel; |
||||
|
||||
import de.superx.common.SuperX_el; |
||||
|
||||
|
||||
/** |
||||
* Ein Adapter, der das JDBC-Interface an das TableModel-Interface anpasst. |
||||
* Angepasst für SuperX |
||||
* @autor Philip Milne, erweitert von R. Behr |
||||
* @version 1.2 |
||||
*/ |
||||
|
||||
public class SxJDBCAdapter extends AbstractTableModel implements SxTableModel { |
||||
Connection connection; |
||||
Properties db_props = null; |
||||
boolean isClosed = true; |
||||
boolean isEditable = false; |
||||
Statement statement = null; |
||||
ResultSet resultSet = null; |
||||
String[] columnNames = {}; |
||||
Class[] columnTpyes = {}; |
||||
Vector rows = new Vector(); |
||||
SxSQLMetaData metaData; |
||||
NumberFormat nf = NumberFormat.getInstance(); |
||||
//DecimalFormat df=(DecimalFormat) nf;
|
||||
|
||||
/* public SxJDBCAdapter(String url, String driverName, |
||||
String user, String passwd) throws Exception { |
||||
try |
||||
{ |
||||
Class.forName(driverName); |
||||
System.err.println("Opening db connection"); |
||||
|
||||
if (!isClosed) |
||||
{ |
||||
statement.close(); |
||||
connection.close (); |
||||
isClosed = true; |
||||
} |
||||
|
||||
db_props = new Properties (); |
||||
db_props.put ("user", user); |
||||
db_props.put ("password", passwd); |
||||
|
||||
connection = DriverManager.getConnection(url, db_props); |
||||
statement = connection.createStatement(); |
||||
isClosed = false; |
||||
} |
||||
catch (Exception ex) |
||||
{ |
||||
isClosed = true; |
||||
throw new SQLException (ex.toString()); |
||||
} |
||||
}*/ |
||||
|
||||
public SxJDBCAdapter() {} |
||||
|
||||
public void executeQuery(String query) throws SQLException |
||||
{ |
||||
resultSet = statement.executeQuery(query); |
||||
// resultSet = statement.getResultSet();
|
||||
metaData = new SxSQLMetaData (new SuperX_el()); |
||||
//metaData = resultSet.getMetaData();
|
||||
|
||||
int numberOfColumns = metaData.getColumnCount(); |
||||
columnNames = new String[numberOfColumns]; |
||||
// Get the column names and cache them.
|
||||
// Then we can close the connection.
|
||||
for(int column = 0; column < numberOfColumns; column++) |
||||
{ |
||||
columnNames[column] = metaData.getColumnLabel(column+1); |
||||
// System.err.println ("Column: " + columnNames[column] + ", max width: " +
|
||||
// metaData.getColumnDisplaySize(column+1));
|
||||
} |
||||
|
||||
// Get all rows.
|
||||
rows = new Vector(); |
||||
while (resultSet.next()) |
||||
{ |
||||
Vector newRow = new Vector(); |
||||
for (int i = 0; i < getColumnCount(); i++) |
||||
{ |
||||
// newRow.addElement(dbRepresentation(i, resultSet.getObject(i + 1)));
|
||||
newRow.addElement(resultSet.getObject(i + 1)); |
||||
} |
||||
rows.addElement(newRow); |
||||
} |
||||
// close(); // Need to copy the metaData, bug in jdbc:odbc driver.
|
||||
fireTableChanged(null); // Tell the listeners a new table has arrived.
|
||||
} |
||||
|
||||
public void cancel(String url, String user, String passwd) throws Exception |
||||
{ |
||||
try |
||||
{ |
||||
System.err.println("Cancel statement"); |
||||
statement.cancel(); |
||||
} |
||||
catch (Exception e) |
||||
{ |
||||
System.err.println("Error canceling statement: " + e); |
||||
} |
||||
} |
||||
|
||||
public void close() throws SQLException |
||||
{ |
||||
try |
||||
{ |
||||
System.err.println("Closing db connection"); |
||||
if (!isClosed) |
||||
{ |
||||
if (resultSet != null) |
||||
resultSet.close(); |
||||
if (statement != null) |
||||
statement.close(); |
||||
connection.close(); |
||||
isClosed = true; |
||||
} |
||||
} |
||||
catch (SQLException e) |
||||
{ |
||||
System.err.println("Error closing db connection: " + e); |
||||
} |
||||
} |
||||
|
||||
protected void finalize() throws Throwable |
||||
{ |
||||
if (!isClosed) |
||||
{ |
||||
close(); |
||||
isClosed = true; |
||||
} |
||||
super.finalize(); |
||||
} |
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Implementation des TableModelInterface
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// MetaData
|
||||
|
||||
public String getColumnName(int column) { |
||||
if (columnNames[column] != null) { |
||||
return columnNames[column]; |
||||
} else { |
||||
return ""; |
||||
} |
||||
} |
||||
|
||||
public int getColumnSize(int column) |
||||
{ |
||||
if (metaData == null) |
||||
return -1; |
||||
|
||||
return metaData.getColumnDisplaySize(column+1); |
||||
} |
||||
|
||||
public Class getColumnClass(int column) |
||||
{ |
||||
int type; |
||||
|
||||
if (metaData == null) |
||||
return Object.class; |
||||
|
||||
type = metaData.getColumnType(column+1); |
||||
|
||||
switch(type) |
||||
{ |
||||
case Types.CHAR: |
||||
case Types.VARCHAR: |
||||
case Types.LONGVARCHAR: |
||||
return String.class; |
||||
|
||||
case Types.BIT: |
||||
return Boolean.class; |
||||
|
||||
case Types.TINYINT: |
||||
case Types.SMALLINT: |
||||
return Short.class; |
||||
|
||||
case Types.INTEGER: |
||||
return Integer.class; |
||||
|
||||
case Types.BIGINT: |
||||
return Long.class; |
||||
|
||||
case Types.FLOAT: |
||||
case Types.DOUBLE: |
||||
return Double.class; |
||||
|
||||
case Types.DATE: |
||||
return java.sql.Date.class; |
||||
|
||||
case Types.DECIMAL: |
||||
case Types.NUMERIC: |
||||
return java.math.BigDecimal.class; |
||||
|
||||
case Types.TIMESTAMP: |
||||
return java.sql.Timestamp.class; |
||||
|
||||
default: |
||||
return Object.class; |
||||
} |
||||
} |
||||
|
||||
public void setEditable(boolean editable) |
||||
{ |
||||
isEditable = editable; |
||||
} |
||||
|
||||
public boolean isCellEditable(int row, int column) |
||||
{ |
||||
if (isEditable) |
||||
return metaData.isWritable(column); |
||||
else |
||||
return false; |
||||
} |
||||
|
||||
public int getColumnCount() { |
||||
return columnNames.length; |
||||
} |
||||
|
||||
// Data methods
|
||||
|
||||
public int getRowCount() { |
||||
return rows.size(); |
||||
} |
||||
|
||||
public Object getValueAt(int aRow, int aColumn) |
||||
{ |
||||
Vector row = (Vector)rows.elementAt(aRow); |
||||
Object value = row.elementAt(aColumn); |
||||
return dbRepresentation(aColumn, value, true); |
||||
} |
||||
|
||||
public Object getObjectAt(int aRow, int aColumn) |
||||
{ |
||||
Vector row = (Vector)rows.elementAt(aRow); |
||||
return row.elementAt(aColumn); |
||||
} |
||||
|
||||
private String dbRepresentation(int column, Object value, boolean isDecimalParsingWanted) |
||||
{ |
||||
int type; |
||||
int scale; |
||||
double db; |
||||
String str; |
||||
|
||||
if (metaData == null) |
||||
return value.toString(); |
||||
|
||||
if (value == null||value.equals("")) |
||||
return " "; |
||||
|
||||
type = metaData.getColumnType(column+1); |
||||
scale = metaData.getScale(column+1); |
||||
|
||||
switch(type) |
||||
{ |
||||
case Types.SMALLINT: |
||||
int int_value = Short.MIN_VALUE; |
||||
if (value instanceof Short) |
||||
int_value = ((Short) value).shortValue(); |
||||
else |
||||
if (value instanceof Integer) |
||||
int_value = ((Integer) value).intValue(); |
||||
if (int_value == Short.MIN_VALUE) |
||||
return (" "); |
||||
return value.toString(); |
||||
case Types.INTEGER: |
||||
if (!(value instanceof Integer)) |
||||
return value.toString(); |
||||
if (((Integer) value).intValue() == Integer.MIN_VALUE) |
||||
return (" "); |
||||
return value.toString(); |
||||
case Types.DOUBLE: |
||||
if (isDecimalParsingWanted) |
||||
{ |
||||
if (((Double) value).isNaN()) |
||||
return " "; |
||||
nf.setMinimumFractionDigits(scale); // r.b. Nachkommastellen setzen
|
||||
nf.setGroupingUsed(true); |
||||
//df.setDecimalSeparatorAlwaysShown(true);
|
||||
//df.applyLocalizedPattern("#.#00,0#");
|
||||
if (scale > 3) |
||||
nf.setMaximumFractionDigits(3); // r.b. Nachkommastellen setzen
|
||||
return nf.format((Double) value); |
||||
} |
||||
else |
||||
return value.toString(); |
||||
case Types.DECIMAL: |
||||
case Types.NUMERIC: |
||||
if (isDecimalParsingWanted) |
||||
{ |
||||
db = ((BigDecimal) value).doubleValue(); |
||||
nf.setGroupingUsed(true); |
||||
if (db == Double.NaN) |
||||
return " "; |
||||
//MB bigdecimal kann immer >65000 Nachkommastellen haben, wird immer auf 5 gesetzt
|
||||
//bei Studiabfragen nach Abschlüssen, ist wahrscheinlich ganz gut, dass ,00 verschwindet (wenngleich gewichtete Fälle)
|
||||
//bei Cob abfragen wäre schön
|
||||
//if (scale > 5) nf.setMaximumFractionDigits(5); // r.b. Nachkommastellen setzen
|
||||
//else nf.setMinimumFractionDigits(scale); // r.b. Nachkommastellen setzen
|
||||
//, einfach mal fest von 2 ausgehen
|
||||
nf.setMaximumFractionDigits(2); |
||||
nf.setMinimumFractionDigits(2); |
||||
//df.setDecimalSeparatorAlwaysShown(true);
|
||||
//df.applyLocalizedPattern("#.#00,0#");
|
||||
return nf.format(db); |
||||
} |
||||
else |
||||
return value.toString(); |
||||
case Types.BIT: |
||||
return ((Boolean)value).booleanValue() ? "1" : "0"; |
||||
case Types.DATE: |
||||
str = SxDate.toString((java.sql.Date) value); |
||||
if (str.length() == 0) |
||||
return (" "); |
||||
return str; |
||||
case Types.TIMESTAMP: |
||||
str = ((Timestamp) value).toString(); |
||||
if (str.length() == 0) |
||||
return (" "); |
||||
return str; |
||||
default: |
||||
if (value.toString().length() == 0) |
||||
return (" "); |
||||
return value.toString(); |
||||
} |
||||
} |
||||
|
||||
private Object tableRepresentation(int column, Object value) |
||||
{ |
||||
int type; |
||||
|
||||
if (value == null) |
||||
{ |
||||
return ""; |
||||
} |
||||
|
||||
if (metaData == null) |
||||
return value; |
||||
|
||||
type = metaData.getColumnType(column+1); |
||||
|
||||
switch(type) |
||||
{ |
||||
case Types.SMALLINT: |
||||
{ |
||||
try |
||||
{ |
||||
return new Short (value.toString()); |
||||
} |
||||
catch (NumberFormatException e) |
||||
{ |
||||
System.err.println ("tableRepresentation: ERROR: " + value.toString()); |
||||
return ""; |
||||
} |
||||
} |
||||
case Types.INTEGER: |
||||
{ |
||||
try |
||||
{ |
||||
return new Integer (value.toString()); |
||||
} |
||||
catch (NumberFormatException e) |
||||
{ |
||||
System.err.println ("tableRepresentation: ERROR: " + value.toString()); |
||||
return ""; |
||||
} |
||||
} |
||||
case Types.DOUBLE: |
||||
case Types.FLOAT: |
||||
{ |
||||
try |
||||
{ |
||||
Number new_number = nf.parse(value.toString()); |
||||
Double new_double = new Double(new_number.doubleValue()); |
||||
return new_double; |
||||
} |
||||
catch (ParseException e) |
||||
{ |
||||
System.err.println ("tableRepresentation: ERROR parse: Double=" + value.toString()); |
||||
return ""; |
||||
} |
||||
} |
||||
case Types.DECIMAL: |
||||
{ |
||||
try |
||||
{ |
||||
Number new_number = nf.parse(value.toString()); |
||||
BigDecimal new_dec = new BigDecimal(new_number.doubleValue()); |
||||
return new_dec; |
||||
} |
||||
catch (ParseException e) |
||||
{ |
||||
System.err.println ("tableRepresentation: ERROR parse: BigDecimal=" + value.toString()); |
||||
return ""; |
||||
} |
||||
} |
||||
case Types.BIT: |
||||
return new Boolean (value.toString()); |
||||
case Types.DATE: |
||||
return SxDate.getDate(value.toString()); |
||||
case Types.TIMESTAMP: |
||||
return Timestamp.valueOf(value.toString()); |
||||
default: |
||||
return value; |
||||
} |
||||
|
||||
} |
||||
|
||||
public void setValueAt(Object value, int row, int column) |
||||
{ |
||||
try |
||||
{ |
||||
String tableName = "info_usr"; // r.b. metaData.getTableName(column+1);
|
||||
// Some of the drivers seem buggy, tableName should not be null.
|
||||
if (tableName == null) |
||||
{ |
||||
System.err.println("Table name returned null."); |
||||
} |
||||
String colName = getColumnName(column); |
||||
|
||||
Object new_value = tableRepresentation(column, value); |
||||
if (new_value == null) |
||||
throw new SQLException ("conversion error"); |
||||
|
||||
System.err.println ("column: " + colName + ", value: " + new_value); |
||||
String query = |
||||
"update "+tableName+ |
||||
" set "+colName+" = " + "'" + dbRepresentation(column, new_value, true) + "'" + |
||||
" where "; |
||||
// We don't have a model of the schema so we don't know the
|
||||
// primary keys or which columns to lock on. To demonstrate
|
||||
// that editing is possible, we'll just lock on everything.
|
||||
for(int col = 0; col<getColumnCount(); col++) |
||||
{ |
||||
String columnName = getColumnName(col); |
||||
if (columnName.equals("")) |
||||
continue; |
||||
if (col != 0) |
||||
query = query + " and "; |
||||
query = query + columnName + " = " + "'" + getValueAt(row, col) + "'"; |
||||
} |
||||
|
||||
System.err.println(query); |
||||
System.err.println("Sending update to database"); |
||||
int rc = 1; // statement.executeUpdate(query);
|
||||
if (rc == 1) |
||||
{ |
||||
System.err.println("Update succeeded"); |
||||
} |
||||
else |
||||
throw new SQLException ("Update failed: " + rc); |
||||
|
||||
Vector dataRow = (Vector)rows.elementAt(row); |
||||
dataRow.setElementAt(new_value, column); |
||||
|
||||
} |
||||
catch (SQLException e) |
||||
{ |
||||
System.err.println("ERROR: " + e); |
||||
} |
||||
|
||||
} |
||||
|
||||
public void setDataVector(Vector Rows, Vector Header, Object Meta) |
||||
{ |
||||
int numberOfColumns = Header.size(); |
||||
columnNames = new String[numberOfColumns]; |
||||
rows = Rows; |
||||
if (Meta instanceof SxSQLMetaData) |
||||
{ |
||||
metaData = (SxSQLMetaData) Meta; |
||||
// Get the column names and cache them.
|
||||
for(int column = 0; column < numberOfColumns; column++) |
||||
columnNames[column] = (String) Header.elementAt (column); |
||||
} |
||||
else |
||||
metaData = null; |
||||
fireTableChanged(null); |
||||
} |
||||
|
||||
public void setDataVector(Vector Rows) |
||||
{ |
||||
rows = Rows; |
||||
|
||||
fireTableDataChanged(); |
||||
} |
||||
/** |
||||
* MB 04/2010 hinzugefügt, weil felderinfo decimal nicht funktioniert, |
||||
* aufruf von TSxDlgManager für col1 darf bei dbrepresenation kein , sondern . enthalten |
||||
* |
||||
*/ |
||||
public Object getValueAt2(int aRow, int aColumn) |
||||
{ |
||||
Vector row = (Vector)rows.elementAt(aRow); |
||||
Object value = row.elementAt(aColumn); |
||||
return dbRepresentation(aColumn, value, false); |
||||
} |
||||
} |
@ -1,473 +0,0 @@
@@ -1,473 +0,0 @@
|
||||
package de.superx.applet; |
||||
import java.awt.Color; |
||||
import java.awt.Dimension; |
||||
import java.awt.Graphics; |
||||
import java.awt.Image; |
||||
import java.awt.image.MemoryImageSource; |
||||
import java.awt.image.PixelGrabber; |
||||
import java.util.Vector; |
||||
|
||||
import javax.swing.ImageIcon; |
||||
import javax.swing.JPanel; |
||||
|
||||
/** |
||||
* Darstellung des SuperX-Logos, das sich während Datenbankenanfragen dreht. |
||||
* |
||||
* |
||||
* @version 1.0 |
||||
* @author Rainer Behr |
||||
*/ |
||||
|
||||
|
||||
public class SxLogoPanel extends JPanel { |
||||
|
||||
|
||||
|
||||
SxLogoPanel SxThis; // this
|
||||
|
||||
|
||||
|
||||
Vector images; |
||||
|
||||
ImageIcon image; |
||||
|
||||
ImageIcon bg; |
||||
|
||||
Color bg_color; |
||||
|
||||
|
||||
|
||||
int count; |
||||
|
||||
int steps; |
||||
|
||||
int aktImage; |
||||
|
||||
int imageX,imageY; |
||||
|
||||
int imageW,imageH; |
||||
|
||||
int delay; |
||||
|
||||
|
||||
|
||||
animationThread animation = null; |
||||
|
||||
|
||||
|
||||
boolean running; |
||||
|
||||
boolean stopping; |
||||
|
||||
|
||||
|
||||
public SxLogoPanel(ImageIcon logo, int[] pixels, int steps, int delay) |
||||
|
||||
{ |
||||
|
||||
super(true); |
||||
|
||||
|
||||
|
||||
SxThis = this; |
||||
|
||||
|
||||
|
||||
this.steps = steps; |
||||
|
||||
this.delay = delay; |
||||
|
||||
|
||||
|
||||
bg_color = this.getBackground(); |
||||
|
||||
|
||||
|
||||
images = new Vector(); |
||||
|
||||
imageW = logo.getIconWidth(); |
||||
|
||||
imageH = logo.getIconHeight(); |
||||
|
||||
imageX = 5; imageY = 5; |
||||
|
||||
aktImage = this.steps/2; |
||||
|
||||
running = false; |
||||
|
||||
stopping = false; |
||||
|
||||
|
||||
|
||||
if (pixels == null) |
||||
|
||||
{ |
||||
|
||||
this.steps = 0; |
||||
|
||||
images.insertElementAt(logo, 0); |
||||
|
||||
aktImage = 0; |
||||
|
||||
count = 1; |
||||
|
||||
} |
||||
|
||||
else |
||||
|
||||
try { setImages (pixels); |
||||
|
||||
} |
||||
catch (Exception e) |
||||
{ |
||||
System.out.println("Bilder nicht verfügbar"); |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
class animationThread extends Thread |
||||
|
||||
{ |
||||
|
||||
|
||||
|
||||
public animationThread(int d) |
||||
|
||||
{ |
||||
|
||||
super(); |
||||
|
||||
delay = d; |
||||
|
||||
this.setPriority(Thread.MIN_PRIORITY); |
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
public void run() |
||||
|
||||
{ |
||||
|
||||
while (running) |
||||
|
||||
{ |
||||
|
||||
SxThis.paint(SxThis.getGraphics()); |
||||
|
||||
|
||||
|
||||
try |
||||
|
||||
{ |
||||
|
||||
if (stopping) |
||||
|
||||
if (aktImage == steps/2) |
||||
|
||||
throw new InterruptedException ("Stopping"); |
||||
|
||||
aktImage++; |
||||
|
||||
sleep(delay); |
||||
|
||||
} |
||||
|
||||
catch (InterruptedException ie) |
||||
|
||||
{ |
||||
|
||||
animation = null; |
||||
|
||||
running = false; |
||||
|
||||
aktImage = steps/2; |
||||
|
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
public void start() |
||||
|
||||
{ |
||||
|
||||
running = true; |
||||
|
||||
stopping = false; |
||||
|
||||
animation = new animationThread(this.delay); |
||||
|
||||
animation.start(); |
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
public void stop() |
||||
|
||||
{ |
||||
|
||||
stopping = true; |
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
public void setImages(int[] pixels) |
||||
|
||||
{ |
||||
|
||||
Image[] imagearray = null; |
||||
|
||||
Image[] imagearray2 = null; |
||||
|
||||
int[] tpixelarray = null; |
||||
|
||||
int turnw, turnh; |
||||
|
||||
double phi, phistep; |
||||
|
||||
|
||||
|
||||
PixelGrabber pg = null; |
||||
|
||||
|
||||
|
||||
if (pixels == null) |
||||
|
||||
return; |
||||
|
||||
tpixelarray = pixels; |
||||
|
||||
|
||||
|
||||
phi=0; |
||||
|
||||
phistep=Math.PI/steps; |
||||
|
||||
|
||||
|
||||
turnw = imageW; |
||||
|
||||
turnh = imageH; |
||||
|
||||
|
||||
|
||||
// *******************************************************
|
||||
|
||||
// * Alle einzelnen Logo-Bilder erzeugen
|
||||
|
||||
// *******************************************************
|
||||
|
||||
|
||||
|
||||
imagearray = new Image [steps]; |
||||
|
||||
imagearray2 = new Image [steps]; |
||||
|
||||
int rpixelarray[][] = new int[steps][turnw*turnh]; |
||||
|
||||
int helpimagearray[][] = new int[steps][turnw*turnh]; |
||||
|
||||
int a, b, c; |
||||
|
||||
double m; |
||||
|
||||
|
||||
|
||||
for (c = 0; c < steps; c++) |
||||
|
||||
{ |
||||
|
||||
m = Math.sin(phi); |
||||
|
||||
|
||||
|
||||
// erst mal alles transparent ausfuellen
|
||||
|
||||
for (a=0; a < turnw*turnh; a++) |
||||
|
||||
{ |
||||
|
||||
rpixelarray[c][a]=(0 << 24) | (0 << 16) | (0 << 8) | 0; |
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
for (a = 0; a < turnh; a++) |
||||
|
||||
for (b = turnw/2; b >= 0; b--) |
||||
|
||||
rpixelarray[c][(int)(Math.abs(a*turnw+turnw/2-(m*b)))]=tpixelarray[a*turnw+turnw/2-b]; |
||||
|
||||
|
||||
|
||||
for (a = 0; a < turnh; a++) |
||||
|
||||
{ |
||||
|
||||
for (b = 0; b < turnw/2; b++) |
||||
|
||||
{ |
||||
|
||||
rpixelarray[c][(int)(Math.abs(a*turnw+turnw/2+(m*b)))]=tpixelarray[a*turnw+turnw/2+b]; |
||||
|
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
imagearray[c] = createImage(new MemoryImageSource(turnw,turnh,rpixelarray[c],0,turnw)); |
||||
|
||||
|
||||
|
||||
for (a = 0; a < turnh; a++) |
||||
|
||||
for (b = 0; b < turnw; b++) |
||||
|
||||
helpimagearray[c][a*turnw+b] = rpixelarray[c][a*turnw+turnw-b-1]; |
||||
|
||||
|
||||
|
||||
imagearray2[c] = createImage(new MemoryImageSource(turnw,turnh,helpimagearray[c],0,turnw)); |
||||
|
||||
|
||||
|
||||
phi+=phistep; |
||||
|
||||
if (phi > (Math.PI)) phi %= Math.PI; |
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
count=0; |
||||
|
||||
for (int i = 0; i < steps; i++) |
||||
|
||||
{ |
||||
|
||||
images.insertElementAt(new ImageIcon (imagearray[i]), count); |
||||
|
||||
count++; |
||||
|
||||
} |
||||
|
||||
for (int i = 0; i < steps; i++) |
||||
|
||||
{ |
||||
|
||||
images.insertElementAt(new ImageIcon (imagearray2[i]), count); |
||||
|
||||
count++; |
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
// *******************************************************
|
||||
|
||||
// * Background-Bild erzeugen
|
||||
|
||||
// *******************************************************
|
||||
|
||||
Image bg_img; |
||||
|
||||
int[] bg_pixels = new int [imageW * imageH]; |
||||
|
||||
int bg_colorint = bg_color.getRGB(); |
||||
|
||||
|
||||
|
||||
for (int i = 0; i < imageW * imageH; i++) |
||||
|
||||
bg_pixels[i] = bg_colorint; |
||||
|
||||
|
||||
|
||||
bg_img = createImage(new MemoryImageSource(imageW, imageH, bg_pixels, 0, imageW)); |
||||
|
||||
bg = new ImageIcon (bg_img); |
||||
|
||||
|
||||
|
||||
bg_pixels = null; |
||||
|
||||
rpixelarray = null; |
||||
|
||||
helpimagearray = null; |
||||
|
||||
imagearray = null; |
||||
|
||||
imagearray2 = null; |
||||
|
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
public void paint(Graphics g) |
||||
|
||||
{ |
||||
|
||||
|
||||
|
||||
if (images.size() > 0) |
||||
|
||||
{ |
||||
|
||||
if (aktImage > count - 1) |
||||
|
||||
aktImage=0; |
||||
|
||||
image = (ImageIcon) images.elementAt(aktImage); |
||||
|
||||
|
||||
|
||||
if (image != null) |
||||
|
||||
g.drawImage (image.getImage(), imageX, imageY, bg_color, this); |
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
public Dimension getMinimumSize() { |
||||
|
||||
return new Dimension(imageW + imageX,imageH + imageY); |
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
public Dimension getMaximumSize() { |
||||
|
||||
return new Dimension(imageW + imageX,imageH + imageY); |
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
public Dimension getPreferredSize() { |
||||
|
||||
return new Dimension(imageW + imageX,imageH + imageY); |
||||
|
||||
} |
||||
|
||||
} |
File diff suppressed because it is too large
Load Diff
@ -1,35 +0,0 @@
@@ -1,35 +0,0 @@
|
||||
package de.superx.applet; |
||||
import java.awt.Frame; |
||||
|
||||
import de.memtext.baseobjects.User; |
||||
import de.memtext.dlg.PasswdChangeDlg; |
||||
|
||||
public class SxPasswdChangeDlg extends PasswdChangeDlg { |
||||
|
||||
public SxPasswdChangeDlg(Frame frame, String title) { |
||||
super(frame, title); |
||||
setInfoLabel("<html>Früher bereits verwendete Passwörter sollten nicht benutzt werden"); |
||||
this.pack(); |
||||
} |
||||
/** |
||||
* this method is automatically called by the PasswdChangeDlg |
||||
*/ |
||||
protected boolean isOldPasswordOK(String username, String passwd) { |
||||
boolean result = false; |
||||
// if (!SxSQL.isAdmin()) {
|
||||
try { |
||||
SxSQL.checkPwd(new User(username, passwd)); |
||||
result=true; |
||||
} catch (Exception e) { |
||||
//WarningMessage.show(e.toString(),"Fehler");
|
||||
result = false; |
||||
} |
||||
// }
|
||||
return result; |
||||
} |
||||
|
||||
|
||||
|
||||
} |
||||
|
||||
//Created on 09.01.2004 at 17:40:10
|
@ -1,280 +0,0 @@
@@ -1,280 +0,0 @@
|
||||
/* |
||||
* $Id: PosLayout.java,v 1.3 1998/01/22 12:45:30 bw Exp $ |
||||
* |
||||
* (c)1997 IoS Gesellschaft für innovative Softwareentwicklung mbH |
||||
* http://www.IoS-Online.de mailto:info@IoS-Online.de
|
||||
* |
||||
* This program is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU General Public License as |
||||
* published by the Free Software Foundation; either version 2 of |
||||
* the License, or (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||
* General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program; if not, write to the Free Software |
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
||||
*/ |
||||
|
||||
package de.superx.applet; |
||||
import java.awt.Component; |
||||
import java.awt.Container; |
||||
import java.awt.Dimension; |
||||
import java.awt.LayoutManager; |
||||
import java.awt.Point; |
||||
import java.util.Vector; |
||||
|
||||
/** |
||||
* Layout-Manager, den SxForm für die Darstellung der Maske benötigt. |
||||
* LayoutManager-Implementation fuer direkte Kontrolle ueber die Position |
||||
* der Components. |
||||
* Fuer jedes Element sollte die Methode setPosition aufgerufen werden. |
||||
* Ansonsten werden die Components linear untereinander angeordnet. |
||||
* @version 1.3 1998/01/22 |
||||
* @author IoS |
||||
*/ |
||||
|
||||
|
||||
public class SxPosLayout implements LayoutManager { |
||||
|
||||
/** |
||||
* Name of this Class |
||||
*/ |
||||
public static final String CLASS = "SxPosLayout"; |
||||
|
||||
/** |
||||
* Standard Constructor |
||||
*/ |
||||
public SxPosLayout() { |
||||
super(); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Extended Constructor, allows to define a Frame-Distance from the borders of the Container and |
||||
* a Min.-Distance between all automatically positioned Components |
||||
*/ |
||||
public SxPosLayout( int frameDistX, int frameDistY, int compDistX, int compDistY ) { |
||||
super(); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Setzt die Position einer Komponente. |
||||
* Diese Methode muss fuer jedes Element aufrufen werden! |
||||
*/ |
||||
public void setPosition(Component comp, int x, int y, int w, int h) { |
||||
if (debug) |
||||
System.out.println(CLASS+".setPosition("+x+","+y+","+w+","+h+")"); |
||||
int i=VComp.indexOf(comp); |
||||
Point p; |
||||
Dimension d; |
||||
|
||||
if (i>=0) { |
||||
p=(Point)VPoint.elementAt(i); |
||||
d=(Dimension)VDimension.elementAt(i); |
||||
p.x = x; |
||||
p.y = y; |
||||
d.width =w; |
||||
d.height=h; |
||||
if (GD.width < (x+w)) |
||||
GD.width = x+w; |
||||
if (GD.height < (y+h)) |
||||
GD.height = y+h; |
||||
} |
||||
else |
||||
if (debug) |
||||
System.out.println(CLASS+".setPosition: WARNUNG: Component nicht gefunden"); |
||||
} |
||||
|
||||
/**************************************************************************************************** |
||||
* Zu implementierende Methoden von LayoutManager |
||||
*/ |
||||
|
||||
/** |
||||
* Komponente hinzufuegen. |
||||
* Diese Methode wird nur von Container.add(String,Component) aufgerufen. |
||||
* Alle anderen add-Funktionen rufen diese Funktion nicht auf! |
||||
* Daher werden bei einem Aufruf der Methode layoutContainer (s.u.) alle |
||||
* Components des Container ueberprueft und ggf. hinzugefuegt. |
||||
*/ |
||||
public void addLayoutComponent( String name, Component comp ) { |
||||
if (debug) |
||||
System.out.println(CLASS+".addLayoutComponent"); |
||||
Dimension nD = new Dimension(0,0); |
||||
Point nP = new Point(0,0); |
||||
|
||||
VComp.addElement(comp); |
||||
VPoint.addElement(nP); |
||||
VDimension.addElement(nD); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Entfernen einer Component. |
||||
*/ |
||||
public void removeLayoutComponent( Component comp ) { |
||||
if (debug) |
||||
System.out.println(CLASS+".removeLayoutComponent"); |
||||
int i=VComp.indexOf(comp); |
||||
if (i>=0) { |
||||
VComp.removeElementAt(i); |
||||
VDimension.removeElementAt(i); |
||||
VPoint.removeElementAt(i); |
||||
} |
||||
else |
||||
if (debug) |
||||
System.out.println(CLASS+".removeLayoutCompoent: WARNUNG: Element nicht gefunden"); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Miminale Groesse des Layouts |
||||
*/ |
||||
public Dimension minimumLayoutSize(Container parent) { |
||||
if (debug) |
||||
System.out.println(CLASS+".minimumLayoutSize"); |
||||
if (minimumDim!=null) |
||||
return minimumDim; |
||||
else { |
||||
return GD; |
||||
} |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Setzen der Miniumalgroesse des Layouts. |
||||
* Fuer Faelle, in denen die Komponenten verdeckt werden koennen. |
||||
*/ |
||||
public void setMinimumSize(int w, int h) { |
||||
minimumDim = new Dimension(w,h); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Gewuenschte Groesse. |
||||
* Wird bei jedem pack aufgerufen (bei der Initialisierung des Fensters |
||||
* sogar mehrfach). |
||||
*/ |
||||
public Dimension preferredLayoutSize(Container parent) { |
||||
|
||||
if (debug) |
||||
System.out.println(CLASS+".preferredLayoutSize ["+GD+"]"); |
||||
if (preferredDim!=null) |
||||
return preferredDim; |
||||
else { |
||||
return GD; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Setzen der gewuenschten Groesse des Layouts. |
||||
* Fuer Faelle, in denen die Komponenten verdeckt werden koennen. |
||||
*/ |
||||
public void setPreferredSize(int w, int h) { |
||||
preferredDim = new Dimension(w,h); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Neuberechnung des Layouts und Positionierung der Komponenten. |
||||
* (Diese Methode wird bei jedem Repaint aufgerufen.) |
||||
*/ |
||||
public void layoutContainer(Container parent) { |
||||
if (debug) |
||||
System.out.println(CLASS+".layoutContainer"); |
||||
|
||||
int i,n = parent.getComponentCount(), |
||||
cx,cy,cw,ch; |
||||
Component c; |
||||
|
||||
if (debug) { |
||||
for (i=0; i<n ; i++) { |
||||
c=parent.getComponent(i); |
||||
if (VComp.indexOf(c)<0) { |
||||
System.out.println("SxPosLayout.layoutContainer: unknown component found: "+c); |
||||
} |
||||
} |
||||
} |
||||
|
||||
n = VComp.size(); |
||||
Dimension d; |
||||
|
||||
if (debug) { |
||||
d=parent.getPreferredSize(); |
||||
System.out.println(" Parent.getPreferredSize="+d); |
||||
} |
||||
|
||||
Point p; |
||||
for (i=0 ; i<n ; i++) { |
||||
c=(Component)(VComp .elementAt(i)); |
||||
d=(Dimension)(VDimension.elementAt(i)); |
||||
p=(Point )(VPoint .elementAt(i)); |
||||
cx=p.x; |
||||
cy=p.y; |
||||
cw=d.width; |
||||
ch=d.height; |
||||
if (debug) |
||||
System.out.println("setBounds on "+i+" to ("+cx+","+cy+","+cw+","+ch+")"); |
||||
c.setBounds(cx,cy,cw,ch); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Protected variables |
||||
*/ |
||||
|
||||
protected Dimension minimumDim = null, /* Min. Size of this Container defined manually only for minimumLayoutSize()-Requests */ |
||||
preferredDim = null; /* Pref. Size of this Container defined manually only for preferedLayoutSize()-Requests */ |
||||
|
||||
protected Dimension GD = new Dimension(0,0); /* min. Dimension of this Container */ |
||||
protected Vector VComp = new Vector(), /* Vector of added Components */ |
||||
VPoint = new Vector(), /* Vector of Comp.-Positions */ |
||||
VDimension = new Vector(); /* Vector of Comp.-Sizes */ |
||||
|
||||
/** |
||||
* Flag for internal debugging-output |
||||
*/ |
||||
public static final boolean debug = false; |
||||
}; |
||||
|
||||
/* |
||||
* $Log: PosLayout.java,v $ |
||||
* Revision 1.3 1998/01/22 12:45:30 bw |
||||
* Some updates to jdk 1.1-methods (preferrendSize, miniumSize, resize, reshape |
||||
* substituted with 1.1-methods). |
||||
* |
||||
* Revision 1.2 1997/12/10 19:38:43 bb |
||||
* Copyright eingefügt. |
||||
* |
||||
* Revision 1.1 1997/09/16 09:19:38 bw |
||||
* Package-Änderung von "ios-online" nach "ios". |
||||
* |
||||
* Revision 1.2 1997/09/09 08:42:01 fw |
||||
* moved all framework-stuff of wrede.customer to the new de.ios.framework |
||||
* |
||||
* Revision 1.2 1997/08/11 15:35:16 fw |
||||
* PositionLayout: Now also deals with the Insets of the Windows |
||||
* |
||||
* Revision 1.1 1997/08/07 09:07:16 bw |
||||
* Neue Basisklasse PosLayout. Trennung der Funktionalitaet von PositionLayout in zwei |
||||
* Klassen. |
||||
* |
||||
* |
||||
*/ |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,930 +0,0 @@
@@ -1,930 +0,0 @@
|
||||
/* |
||||
* Class responsible for db connection via servlet |
||||
* originally inspired by |
||||
// Beispielklasse aus dem JavaTutorial (http://java.sun.com/docs/books/tutorial) *
|
||||
* @(#)JDBCAdapter.java 1.5 97/12/03 |
||||
* |
||||
*/ |
||||
|
||||
package de.superx.applet; |
||||
|
||||
import java.io.BufferedReader; |
||||
import java.io.DataOutputStream; |
||||
import java.io.IOException; |
||||
import java.io.ObjectInputStream; |
||||
import java.io.ObjectOutputStream; |
||||
import java.io.PrintWriter; |
||||
import java.net.HttpURLConnection; |
||||
import java.net.InetAddress; |
||||
import java.net.MalformedURLException; |
||||
import java.net.URL; |
||||
import java.net.UnknownHostException; |
||||
import java.sql.ResultSet; |
||||
import java.sql.SQLException; |
||||
import java.sql.Statement; |
||||
import java.util.Hashtable; |
||||
import java.util.Iterator; |
||||
import java.util.List; |
||||
import java.util.StringTokenizer; |
||||
import java.util.Vector; |
||||
|
||||
import javax.swing.JOptionPane; |
||||
|
||||
import de.memtext.baseobjects.User; |
||||
import de.memtext.rights.NewPasswordChecker; |
||||
import de.memtext.util.CryptUtils; |
||||
import de.memtext.util.DSAHandler; |
||||
import de.memtext.util.NumberUtils; |
||||
import de.memtext.util.StringUtils; |
||||
import de.memtext.widgets.WarningMessage; |
||||
import de.superx.common.SxResultRow; |
||||
import de.superx.common.SuperX_el; |
||||
import de.superx.common.SxResultSet; |
||||
import de.superx.common.TemplateProcessor; |
||||
|
||||
/** |
||||
* Ein Adapter, der das JDBC interface an das TableModelinterface anpasst. |
||||
* Angepasst für SuperX |
||||
* |
||||
*/ |
||||
|
||||
public class SxSQL { |
||||
// Connection connection;
|
||||
static URL superXDbServletUrl; |
||||
static HttpURLConnection servletConnection; // Wint
|
||||
static private Integer userID = new Integer(-1); |
||||
static DSAHandler dsaHandler; |
||||
static boolean isClosed = true; |
||||
static Statement statement = null; |
||||
static ResultSet resultSet = null; |
||||
static String aktuelleNachricht = null; |
||||
// obsolete static fields, shouldn't be used,
|
||||
// because of cloning
|
||||
// static String[] columnNames = {};
|
||||
static int updateCount = -1; |
||||
static int numberOfColumns = -1; |
||||
static Class[] columnTpyes = {}; |
||||
static SxResultSet rows = new SxResultSet(); |
||||
static Vector rows_ret = new Vector(); |
||||
|
||||
static SuperX_el gesamt = new SuperX_el(); |
||||
static SxSQLMetaData metaData; |
||||
static private String logToKonsole = ""; |
||||
static StringBuffer prot_sql = new StringBuffer(); |
||||
static InetAddress client_addr = null; |
||||
static String client_ip = null; |
||||
static InetAddress client_dns = null; |
||||
static int proto_fkt_id = 2; // LOGIN_FAIL
|
||||
static int proto_id_pos = -1; |
||||
static int user_id_pos = -1; |
||||
static String errorString = null; |
||||
static Short adminUserInt = new Short((short) 0); |
||||
static String sx_db = (String) SxDefaults.getPropertyValue("SxDB"); |
||||
static ObjectInputStream inputFromServlet = null; |
||||
static ObjectOutputStream outputToServlet = null; |
||||
static TemplateProcessor templateProcessor = new TemplateProcessor(); |
||||
// wird von SxDefaults.init gesetzt
|
||||
static String mandantenID = "default"; |
||||
static String jsessionid; |
||||
static NewPasswordChecker newPasswordChecker; |
||||
|
||||
// static String originalUrl;
|
||||
// static String url;
|
||||
private SxSQL() { |
||||
} |
||||
|
||||
/** |
||||
* |
||||
* @param user |
||||
* @throws Exception |
||||
*/ |
||||
static void check(User user) throws Exception { |
||||
|
||||
initProtokolEntry(); |
||||
try { |
||||
|
||||
isClosed = false; |
||||
|
||||
// throws exeception if something is/goes wrong
|
||||
checkPwd(user); |
||||
|
||||
// Protokollierung macht UserInializer im servlet
|
||||
proto_fkt_id = 1; // LOGIN
|
||||
prot_sql.replace(proto_id_pos, proto_id_pos + 1, (new Integer( |
||||
proto_fkt_id)).toString()); |
||||
|
||||
// execute(prot_sql.toString());
|
||||
isClosed = false; |
||||
} catch (Exception ex) { |
||||
String msg = ex.toString(); |
||||
|
||||
user_id_pos = prot_sql.toString().indexOf("%"); |
||||
if (user_id_pos > 0) |
||||
prot_sql.replace(user_id_pos, user_id_pos + 1, "-1"); |
||||
// if (!isClosed) execute(prot_sql.toString());
|
||||
throw new SQLException(msg); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* @deprecated macht der UserInitializer im Servlet |
||||
* @throws UnknownHostException |
||||
*/ |
||||
static private void initProtokolEntry() throws UnknownHostException { |
||||
client_addr = InetAddress.getLocalHost(); |
||||
client_ip = client_addr.getHostAddress(); |
||||
client_dns = InetAddress.getByName(client_ip); |
||||
|
||||
// System.out.println("adrr:" + client_addr + " ip: " + client_ip + "
|
||||
// client_name: " + client_dns.getHostName());
|
||||
prot_sql.append("insert into protokoll (proto_fkt_id, userinfo_id, "); |
||||
prot_sql.append("ip_adresse, client_name, zeitpunkt) values ("); |
||||
prot_sql.append("?, "); |
||||
prot_sql.append("% , '" + client_ip); |
||||
prot_sql.append("', '" + client_dns.getHostName() + "'"); |
||||
if (sx_db.equals("Postgres")) { |
||||
prot_sql.append(", now());"); |
||||
} else { |
||||
prot_sql.append(", current);"); |
||||
} |
||||
|
||||
// , date('"+SxDate.getNowString()+"'));");
|
||||
|
||||
proto_id_pos = prot_sql.toString().indexOf("?"); |
||||
prot_sql.replace(proto_id_pos, proto_id_pos + 1, (new Integer( |
||||
proto_fkt_id)).toString()); |
||||
} |
||||
|
||||
static void readFMTemplates() throws SQLException { |
||||
// Spezielles Kommando, dass das SuperXDBServlet versteht und
|
||||
// die templates im SuperX_el Objekt zurückschickt
|
||||
executeQuery("readFMBasics"); |
||||
if (gesamt.getRawFmTemplates() == null) |
||||
throw new SQLException( |
||||
"Servlet hat keine FreeMarker Templates geschickt"); |
||||
templateProcessor.setTemplates(gesamt.getRawFmTemplates()); |
||||
if (gesamt.getRepository() == null) |
||||
throw new SQLException( |
||||
"Servlet hat keine Sx_Repository Daten geschickt"); |
||||
|
||||
templateProcessor.setRepositoryMap(gesamt.getRepository()); |
||||
// damit nicht immer hin-und her geschickt werden muss
|
||||
gesamt.setRepository(null); |
||||
} |
||||
|
||||
/** |
||||
* checkPwd initialisiert User setzt id des Users wird auch von |
||||
* SxPasswdChangeDlg aufgerufen |
||||
* |
||||
* @param user |
||||
* @throws Exception |
||||
*/ |
||||
static synchronized void checkPwd(User user) throws Exception { |
||||
|
||||
boolean login_ok = false; |
||||
try { |
||||
String auth_sql = "Anmeldung|" + user.getName() + "|" |
||||
+ user.getPasswd(); |
||||
// der select auf userinfo wird automatisch im Servlet generiert
|
||||
/* |
||||
* "|select tid, passwd_sha, administration,akt_versuch,max_versuch" |
||||
* + " from userinfo where benutzer = '" + user.getName() + "';"; |
||||
*/ |
||||
|
||||
executeQuery(auth_sql); |
||||
|
||||
if (getRowCount() == 0) { |
||||
throw new Exception("Die Anmeldung des Users '" |
||||
+ user.getName() + "' war nicht erfolgreich"); |
||||
} |
||||
SxResultRow V_row = (SxResultRow) rows.first(); |
||||
|
||||
Short aktVersuch; |
||||
Short maxVersuch; |
||||
try { |
||||
// normal Informix
|
||||
aktVersuch = (Short) V_row.get(3); |
||||
} catch (ClassCastException e) { |
||||
// Access / Postgres liefern Integer-Wrapper
|
||||
Integer dummy = (Integer) V_row.get(3); |
||||
Short dummy2 = new Short((short) dummy.shortValue()); |
||||
aktVersuch = dummy2; |
||||
} |
||||
try { |
||||
// normal Informix
|
||||
maxVersuch = (Short) V_row.get(4); |
||||
} catch (ClassCastException e) { |
||||
// Access / Postgres liefern Integer-Wrapper
|
||||
Integer dummy = (Integer) V_row.get(4); |
||||
Short dummy2 = new Short((short) dummy.shortValue()); |
||||
maxVersuch = dummy2; |
||||
} |
||||
|
||||
// Short aktVersuch = (Short) V_row.get(3);
|
||||
// Short maxVersuch = (Short) V_row.get(4);
|
||||
if (aktVersuch.shortValue() > maxVersuch.shortValue() |
||||
|| aktVersuch.shortValue() <= (maxVersuch.shortValue() * -1)) { |
||||
throw new Exception( |
||||
"Die Zahl maximaler Login-Versuche für Benutzer '" |
||||
+ user.getName() + "' ist überschritten."); |
||||
} |
||||
|
||||
userID = (Integer) V_row.get(0); |
||||
user.setId(userID); |
||||
try { |
||||
// normal Informix
|
||||
adminUserInt = (Short) V_row.get(2); |
||||
} catch (ClassCastException e) { |
||||
// Access / Postgres liefern Integer-Wrapper
|
||||
Integer dummy = (Integer) V_row.get(2); |
||||
Short dummy2 = new Short((short) dummy.shortValue()); |
||||
adminUserInt = dummy2; |
||||
} |
||||
user.setAdmin(isAdmin()); |
||||
|
||||
user_id_pos = prot_sql.toString().indexOf("%"); |
||||
if (user_id_pos > 0) |
||||
prot_sql.replace(user_id_pos, user_id_pos + 1, |
||||
userID.toString()); |
||||
String passwd_sha = (String) V_row.get(1); |
||||
Object kennwortSpalte = V_row.get(5); |
||||
|
||||
/* |
||||
* executeQuery("select pw_gueltig_bis from user_pw where userinfo_id=" |
||||
* +userID); if (rows.size()>0) { Vector zeile= (Vector) |
||||
* rows.get(0); java.util.Date datum=(java.util.Date)zeile.get(0); |
||||
* if (datum!=null&&!DateUtils.isDateInFuture(datum)) |
||||
* kennwortSpalte="ändern"; } |
||||
*/ |
||||
if (kennwortSpalte != null |
||||
&& kennwortSpalte.toString().trim().equals("ändern")) { |
||||
try { |
||||
login_ok = changePwd(user); |
||||
} catch (Exception e) { |
||||
String msg = e.toString(); |
||||
msg = msg.substring(msg.lastIndexOf(":") + 1); |
||||
e.printStackTrace(); |
||||
|
||||
JOptionPane.showMessageDialog(null, msg, "Fehler", |
||||
JOptionPane.ERROR_MESSAGE); |
||||
login_ok = false; |
||||
throw new RuntimeException("Fehler bei Passwortänderung:" |
||||
+ e); |
||||
} |
||||
|
||||
} |
||||
// DQ 6.10.2006 erstmal ins SuperxDBServlet (Methode doPost)
|
||||
// verlagert
|
||||
/* |
||||
* if (passwd_sha.equals(CryptUtils.encodeSHA(user.getPasswd()))) { |
||||
* if (aktVersuch.shortValue() >= 0) { login_ok = true; } else { |
||||
* login_ok = true; login_ok = changePwd(user); } } |
||||
*/ |
||||
login_ok = true; |
||||
|
||||
if (login_ok) { |
||||
SxSQL.initParams(); |
||||
// execute("update userinfo set akt_versuch=0 where benutzer =
|
||||
// '" + user.getName() + "'");
|
||||
} else { |
||||
String operator = "+"; |
||||
if (aktVersuch.shortValue() < 0) |
||||
operator = "-"; |
||||
/* |
||||
* String sql = "update userinfo set akt_versuch=akt_versuch" + |
||||
* operator + "1 " + " where benutzer = '" + user.getName() + |
||||
* "';"; execute(sql); |
||||
*/ |
||||
throw new Exception("Fehlerhaftes Kennwort für Benutzer '" |
||||
+ user.getName() + "'"); |
||||
|
||||
} |
||||
} catch (SQLException e) { |
||||
e.printStackTrace(); |
||||
String msg = "Datenbankverbindung konnte nicht aufgebaut werden. " |
||||
+ e.toString(); |
||||
msg = msg.replace(':', '-'); |
||||
if (msg.indexOf("NichtAngemeldetException") > -1) |
||||
throw new IllegalStateException( |
||||
"Anmeldung fehlerhaft oder abgelaufen"); |
||||
else |
||||
throw new Exception(msg); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* @deprecated sollte das XMl-Frontend machen |
||||
* @param user |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
private static boolean changePwd(User user) throws Exception { |
||||
boolean login_ok; |
||||
SxPasswdChangeDlg dlg = new SxPasswdChangeDlg(null, |
||||
"Bitte ändern Sie Ihr Passwort "); |
||||
dlg.setUsername(user.getName()); |
||||
dlg.setNewPasswordChecker(SxSQL.newPasswordChecker); |
||||
dlg.setOldPassword(user.getPasswd()); |
||||
dlg.setUsernameFieldEnabled(false); |
||||
dlg.setCheckOldPasswdWanted(false); |
||||
dlg.show(); |
||||
if (dlg.wasOkSelected()) { |
||||
storePwd(user, dlg.getNewPasswd(), false); |
||||
login_ok = true; |
||||
execute("update userinfo set kennwort=null where tid=" + userID); |
||||
} else { |
||||
login_ok = false; |
||||
WarningMessage |
||||
.show(null, |
||||
"Sie können mit SuperX nur arbeiten,wenn Sie Ihr Passwort ändern.\nBitte melden Sie dazu sich neu an.", |
||||
"SuperX"); |
||||
throw new RuntimeException("Passwortänderung nötig"); |
||||
} |
||||
return login_ok; |
||||
} |
||||
|
||||
static public Integer getUserID() { |
||||
// kopieren damit keiner von außen aus Versehen überschreibt
|
||||
if (userID != null) |
||||
return new Integer(userID.intValue()); |
||||
else { |
||||
System.out |
||||
.println("Achtung! userID dürfte eigentlich nicht null sein!!"); |
||||
return new Integer(-1); |
||||
} |
||||
} |
||||
|
||||
static public final synchronized void storePwd(User user, String newpasswd, |
||||
boolean isCheckOldPasswdWanted) throws Exception { |
||||
|
||||
if (isCheckOldPasswdWanted && !isAdmin()) |
||||
checkPwd(user); |
||||
|
||||
execute("userchange|" + NumberUtils.getRandomInt(9) |
||||
+ CryptUtils.encodeSHA(newpasswd + CryptUtils.geheimnis1) + "|" |
||||
+ user.getName()); |
||||
|
||||
if (gesamt.getUpdateCount() != 1) |
||||
throw new Exception("Benutzer '" + user.getName() + "'" |
||||
+ " nicht gefunden !"); |
||||
|
||||
user.setPasswd(newpasswd); |
||||
proto_fkt_id = 6; // CH_PASSWD_NEW
|
||||
// prot_sql.replace(proto_id_pos, proto_id_pos + 1, (new Integer(
|
||||
// proto_fkt_id)).toString());
|
||||
|
||||
// execute(prot_sql.toString());
|
||||
// damit sichergestellt wird, das kein erneues Ändern nötig
|
||||
|
||||
execute("update userinfo set akt_versuch=0 where benutzer = '" |
||||
+ user.getName() + "'"); |
||||
} |
||||
|
||||
static public boolean isAdmin() { |
||||
if (adminUserInt.intValue() > 0) |
||||
return true; |
||||
else |
||||
return false; |
||||
} |
||||
|
||||
public static synchronized void executeAll(String stmt) throws SQLException { |
||||
|
||||
// String bleibt zusammen, aber Schleife wird durchlaufen, um
|
||||
// Multi-Statement zu kennzeichnen
|
||||
|
||||
StringTokenizer st = new StringTokenizer(stmt, ";"); |
||||
int n = 0; |
||||
while (st.hasMoreTokens()) { |
||||
n++; |
||||
String sqlstmt = st.nextToken().trim(); |
||||
if (sqlstmt.length() < 10) |
||||
break; |
||||
// besser über String suchen!!
|
||||
} |
||||
// execute (sqlstmt); Wint neu++
|
||||
if (n < 2) { |
||||
executeQuery(stmt); |
||||
} else { |
||||
|
||||
executeQuery("multi:" + stmt); |
||||
} |
||||
} |
||||
|
||||
static private synchronized void execute(String stmt) throws SQLException { |
||||
|
||||
applet_servlet_connection("single" + stmt); |
||||
} |
||||
|
||||
static synchronized void executeQuery(String query) throws SQLException { |
||||
if (!query.trim().equals("") && !query.trim().equals("null")) |
||||
applet_servlet_connection(query); |
||||
} |
||||
|
||||
static public int getUpdateCount() throws SQLException { |
||||
return updateCount; |
||||
} |
||||
|
||||
static public String getAktuelleNachricht() { |
||||
return aktuelleNachricht; |
||||
} |
||||
|
||||
static public int getColumnCount() { |
||||
return numberOfColumns; |
||||
} |
||||
|
||||
/* |
||||
* static public String getColumnName(int column) { if (columnNames[column] |
||||
* != null) return columnNames[column]; else return ""; } |
||||
*/ |
||||
static public int getRowCount() { |
||||
return rows.size(); |
||||
} |
||||
|
||||
/** |
||||
* static public Object getObjectAt(int aRow, int aColumn) { ResultRow row = |
||||
* (ResultRow) rows.get(aRow); return row.get(aColumn); } |
||||
*/ |
||||
|
||||
static public Vector getResultVector() { |
||||
Vector v = new Vector(); |
||||
for (Iterator it = rows.iterator(); it.hasNext();) { |
||||
SxResultRow r = (SxResultRow) it.next(); |
||||
Vector row = new Vector(); |
||||
for (Iterator it2 = r.iterator(); it2.hasNext();) |
||||
row.add(it2.next()); |
||||
v.add(row); |
||||
} |
||||
return v; |
||||
} |
||||
|
||||
static public SxResultSet getResult() { |
||||
return rows; |
||||
} |
||||
|
||||
static public SxSQLMetaData getResultSetMetaData() { |
||||
/* |
||||
* try { FileOutputStream ostream = new FileOutputStream("t.tmp"); |
||||
* ObjectOutputStream p_out = new ObjectOutputStream(ostream); |
||||
* |
||||
* p_out.writeObject(metaData); |
||||
* |
||||
* p_out.flush(); ostream.close(); } catch (Exception ex) { |
||||
* System.err.println (ex); } |
||||
*/ |
||||
SxSQLMetaData meta = null; |
||||
/* |
||||
* try { FileInputStream istream = new FileInputStream("t.tmp"); |
||||
* ObjectInputStream p_in = new ObjectInputStream(istream); |
||||
* |
||||
* meta = (SxSQLMetaData) p_in.readObject(); |
||||
* |
||||
* istream.close(); } catch (Exception ex) { System.err.println (ex); } |
||||
*/ |
||||
|
||||
return metaData; |
||||
} |
||||
|
||||
/* |
||||
* public void cancel() throws Exception { try { System.err.println("SxSQL: |
||||
* Cancel statement"); statement.cancel(); } catch (Exception e) { |
||||
* System.err.println("SxSQL: Error canceling statement: " + e); } } |
||||
*/ |
||||
|
||||
/* |
||||
* public void cancel(String url, String user, String passwd) throws |
||||
* Exception { try { System.err.println("SxSQL: Cancel statement"); |
||||
* statement.cancel(); } catch (Exception e) { System.err.println("SxSQL: |
||||
* Error canceling statement: " + e); } } |
||||
*/ |
||||
|
||||
static public void cancel() throws Exception { |
||||
try { |
||||
System.err.println("SxSQL: Cancel statement"); |
||||
// statement.cancel();
|
||||
ObjectInputStream inputFromServlet = null; |
||||
ObjectOutputStream outputToServlet = null; |
||||
|
||||
servletConnection.disconnect(); |
||||
|
||||
} catch (Exception e) { |
||||
System.err.println("SxSQL: Error canceling statement: " + e); |
||||
} |
||||
} |
||||
|
||||
static public synchronized void close() { |
||||
int proto_fkt_id = 4; // LOGOUT
|
||||
|
||||
// prot_sql.replace( proto_id_pos, proto_id_pos + 1, (new
|
||||
// Integer(proto_fkt_id)).toString());
|
||||
System.out.println("in close"); |
||||
|
||||
try { |
||||
System.err.println("SxSQL: Closing db connection"); |
||||
if (!isClosed) { |
||||
// execute(prot_sql.toString());
|
||||
|
||||
if (resultSet != null) |
||||
resultSet.close(); |
||||
if (statement != null) |
||||
statement.close(); |
||||
|
||||
ObjectInputStream inputFromServlet = null; |
||||
ObjectOutputStream outputToServlet = null; |
||||
|
||||
servletConnection.disconnect(); |
||||
// Alter Rechte Bug - userID wurde beim Schließen der Connection
|
||||
// auf null gesetzt
|
||||
// wenn danach ein Programmteil getUserID() aufruft, wird nicht
|
||||
// null sondern
|
||||
// -1 zurückgeliefert
|
||||
// userID = null;
|
||||
// System.out.println(" SxSQl close: userID auf null gesetzt");
|
||||
isClosed = true; |
||||
} |
||||
} catch (SQLException e) { |
||||
System.err.println("SxSQL: Error closing db connection: " + e); |
||||
} |
||||
} |
||||
|
||||
static public boolean isActive() { |
||||
return !isClosed; |
||||
} |
||||
|
||||
/** |
||||
* auf diese Methode sollte man sich eh nicht verlassen static protected |
||||
* void finalize() throws Throwable { if (!isClosed) { close(); userID = |
||||
* null; System.out.println(" SxSQl finalize: userID auf null gesetzt"); |
||||
* isClosed = true; servletConnection.disconnect(); } } |
||||
* |
||||
* @throws SQLException |
||||
*/ |
||||
|
||||
/** |
||||
* für freemarker zeugs, query wird wie üblich zum Hashtable hinzugefügt |
||||
* |
||||
* @deprecated wegen Serialisierung doch nicht so gut ganzen Kram |
||||
* rüberzuschicken |
||||
*/ |
||||
static synchronized void specialExecute(String query, Hashtable htable) |
||||
throws SQLException { |
||||
PrintWriter outTest = null; |
||||
BufferedReader inTest = null; |
||||
Vector superX_elVector = new Vector(); |
||||
htable.put("query", query); |
||||
try { |
||||
|
||||
servletConnection = (HttpURLConnection) superXDbServletUrl |
||||
.openConnection(); |
||||
servletConnection.setDoInput(true); |
||||
servletConnection.setDoOutput(true); |
||||
|
||||
// Don't used a cached version of URL connection.
|
||||
servletConnection.setUseCaches(false); |
||||
|
||||
// Specify the content type that we will send binary data
|
||||
servletConnection.setRequestProperty("Content-Type", |
||||
"application/octet-stream"); |
||||
|
||||
} catch (Exception e) { |
||||
System.out.println(e.toString()); |
||||
throw new SQLException(e.toString()); |
||||
} |
||||
|
||||
rows_ret = new Vector(); |
||||
|
||||
// Query übergeben
|
||||
|
||||
try { |
||||
// send the SuperX_el object to the servlet using serialization
|
||||
|
||||
outputToServlet = new ObjectOutputStream( |
||||
servletConnection.getOutputStream()); |
||||
|
||||
outputToServlet.writeObject(htable); |
||||
outputToServlet.flush(); |
||||
outputToServlet.close(); |
||||
|
||||
} catch (IOException e) { |
||||
System.out.println(e.toString()); |
||||
throw new SQLException(e.toString()); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
throw new SQLException(e.toString()); |
||||
} |
||||
|
||||
// Read the input from the servlet.
|
||||
//
|
||||
// The servlet will return a serialized vector containing
|
||||
// SuperX_el entries.
|
||||
//
|
||||
// System.out.println("Getting input stream");
|
||||
|
||||
// output lesen
|
||||
ObjectInputStream inputFromServlet = null; |
||||
try { |
||||
inputFromServlet = new ObjectInputStream( |
||||
servletConnection.getInputStream()); |
||||
gesamt = (SuperX_el) inputFromServlet.readObject(); |
||||
aktuelleNachricht = gesamt.getAktuelleNachricht(); |
||||
// System.out.println("Nachricht:"+aktuelleNachricht);
|
||||
|
||||
// if (ErrorString.length()>1) System.out.println("Fehlermeld. vom
|
||||
// Servlet:"+ErrorString);
|
||||
numberOfColumns = gesamt.getColumnCount(); |
||||
// columnNames = gesamt.getColumnNames();
|
||||
rows = gesamt.getResultSet(); |
||||
metaData = new SxSQLMetaData(gesamt); |
||||
inputFromServlet.close(); |
||||
|
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
System.err.println(gesamt.getError_String()); // Wint
|
||||
throw new SQLException(gesamt.getError_String()); |
||||
} |
||||
// System.out.println( "nach Rueckgabe Vector in Applet!!" );
|
||||
errorString = "" + gesamt.getError_String(); |
||||
if (errorString != null && errorString.trim().length() > 1) { |
||||
if ((logToKonsole.equals("errors") || logToKonsole.equals("all")) |
||||
&& aktuelleNachricht != null) { |
||||
System.out |
||||
.println("----------------------------------------------------"); |
||||
System.out.println("Folgender Select ergab einen Fehler: "); |
||||
System.out.println(aktuelleNachricht); |
||||
// System.out.println(logquery);
|
||||
System.out |
||||
.println("----------------------------------------------------"); |
||||
|
||||
} |
||||
// Bei Fehlern in der Abfrage wird die Verbindung beendet, um
|
||||
// temporäre Tabellen zu löschen
|
||||
servletConnection.disconnect(); |
||||
throw new SQLException("im Servlet " + gesamt.getError_String()); |
||||
} |
||||
} |
||||
|
||||
static private synchronized void applet_servlet_connection(String query) |
||||
throws SQLException { |
||||
String logquery = query.trim(); |
||||
if (logquery.substring(0, 6).equals("single")) |
||||
logquery = query.substring(6); |
||||
if (logquery.substring(0, 6).equals("multi:")) |
||||
logquery = query.substring(6); |
||||
// Anmeldedaten nicht im log zeigen
|
||||
if (logquery.startsWith("Anmeldung")) |
||||
logquery = "Anmeldung"; |
||||
if (logToKonsole.equals("all")) { |
||||
System.out.println("----------------Select-Stmt, gestartet am " |
||||
+ SxDate.getNowString() + "-----------------"); |
||||
System.out.println(logquery); |
||||
// System.out.println("----------------------------------------------------");
|
||||
} |
||||
PrintWriter outTest = null; |
||||
BufferedReader inTest = null; |
||||
DataOutputStream printout; |
||||
Vector superX_elVector = new Vector(); |
||||
rows_ret = new Vector(); |
||||
|
||||
// aus Anmeldung|superx|anfang12
|
||||
// werden request param und query nur "Anmeldung"
|
||||
if (query.startsWith("Anmeldung")) { |
||||
List l = StringUtils.getStringTokenizedList(query, "|"); |
||||
try { |
||||
servletConnection = |
||||
// (HttpURLConnection) new
|
||||
// URL(superXDbServletUrl.toString()+"?kennung="+l.get(1)+"&passwort="+l.get(2)).openConnection();
|
||||
(HttpURLConnection) new URL(superXDbServletUrl.toString()) |
||||
.openConnection(); |
||||
query = "Anmeldung"; |
||||
servletConnection.setRequestProperty("Content-Type", |
||||
"application/x-www-form-urlencoded"); |
||||
servletConnection.setDoInput(true); |
||||
servletConnection.setDoOutput(true); |
||||
|
||||
// Don't used a cached version of URL connection.
|
||||
servletConnection.setUseCaches(false); |
||||
|
||||
// Send POST output.
|
||||
printout = new DataOutputStream( |
||||
servletConnection.getOutputStream()); |
||||
// System.out.println("Anmeldung für User "+ l.get(1) );
|
||||
String content = "kennung=" + l.get(1) + "&passwort=" |
||||
+ l.get(2) + "&MandantenID=" + mandantenID + "&query=" |
||||
+ query; |
||||
printout.writeBytes(content); |
||||
printout.flush(); |
||||
printout.close(); |
||||
// System.out.println("Anfrage für User "+ l.get(1)+ "
|
||||
// gesendet");
|
||||
|
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
throw new SQLException(e.toString()); |
||||
} |
||||
} else { |
||||
try { |
||||
servletConnection = (HttpURLConnection) new URL( |
||||
superXDbServletUrl.toString() + ";jsessionid=" |
||||
+ jsessionid).openConnection(); |
||||
// Specify the content type that we will send binary data
|
||||
servletConnection.setRequestProperty("Content-Type", |
||||
"application/octet-stream"); |
||||
servletConnection.setDoInput(true); |
||||
servletConnection.setDoOutput(true); |
||||
|
||||
// Don't used a cached version of URL connection.
|
||||
servletConnection.setUseCaches(false); |
||||
// send the SuperX_el object to the servlet using serialization
|
||||
|
||||
outputToServlet = new ObjectOutputStream( |
||||
servletConnection.getOutputStream()); |
||||
|
||||
// serialize the object
|
||||
// Hashtable htable=new Hashtable();
|
||||
// htable.put("query",query);
|
||||
|
||||
outputToServlet.writeObject(mandantenID); |
||||
// 3/2016 Umlaut kodierung
|
||||
query = encodeUmlauts(query); |
||||
String queryCode = de.memtext.util.CryptUtils |
||||
// .simpleEncryptString2(query);
|
||||
.encryptStringDES(query); |
||||
outputToServlet.writeObject(queryCode); |
||||
String signature = null; |
||||
if (dsaHandler != null) { |
||||
signature = dsaHandler.sign(queryCode); |
||||
} |
||||
outputToServlet.writeObject(signature); |
||||
// outputToServlet.writeObject(htable);
|
||||
outputToServlet.flush(); |
||||
outputToServlet.close(); |
||||
} catch (IOException e) { |
||||
System.out.println(e.toString()); |
||||
throw new SQLException(e.toString()); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
throw new SQLException(e.toString()); |
||||
} |
||||
} |
||||
|
||||
// Query übergeben
|
||||
|
||||
// Read the input from the servlet.
|
||||
//
|
||||
// The servlet will return a serialized vector containing
|
||||
// SuperX_el entries.
|
||||
//
|
||||
// System.out.println("Getting input stream");
|
||||
|
||||
// output lesen
|
||||
ObjectInputStream inputFromServlet = null; |
||||
// System.out.println("Response vom Server lesen" );
|
||||
|
||||
try { |
||||
inputFromServlet = new ObjectInputStream( |
||||
servletConnection.getInputStream()); |
||||
// System.out.println("Response vom Server gelesen" );
|
||||
|
||||
gesamt = (SuperX_el) inputFromServlet.readObject(); |
||||
decodeUmlauts(); |
||||
jsessionid = gesamt.getJsessionid(); |
||||
|
||||
aktuelleNachricht = gesamt.getAktuelleNachricht(); |
||||
// System.out.println("Nachricht:"+aktuelleNachricht);
|
||||
|
||||
// if (ErrorString.length()>1) System.out.println("Fehlermeld. vom
|
||||
// Servlet:"+ErrorString);
|
||||
numberOfColumns = gesamt.getColumnCount(); |
||||
// columnNames = gesamt.getColumnNames();
|
||||
rows = gesamt.getResultSet(); |
||||
metaData = new SxSQLMetaData(gesamt); |
||||
inputFromServlet.close(); |
||||
|
||||
} catch (Exception e) { |
||||
String msg = gesamt.getError_String(); |
||||
if (e instanceof java.io.StreamCorruptedException) |
||||
msg = "Anmeldefehler (falsche jsessionid?!) " + msg; |
||||
e.printStackTrace(); |
||||
System.err.println(); // Wint
|
||||
throw new SQLException(msg); |
||||
} |
||||
// System.out.println( "nach Rueckgabe Vector in Applet!!" );
|
||||
errorString = "" + gesamt.getError_String(); |
||||
if (errorString != null && errorString.trim().length() > 1) { |
||||
if ((logToKonsole.equals("errors") || logToKonsole.equals("all")) |
||||
&& aktuelleNachricht != null) { |
||||
System.out |
||||
.println("----------------------------------------------------"); |
||||
System.out.println("Folgender Select ergab einen Fehler: "); |
||||
System.out.println(aktuelleNachricht); |
||||
// System.out.println(logquery);
|
||||
System.out |
||||
.println("----------------------------------------------------"); |
||||
|
||||
} |
||||
// Bei Fehlern in der Abfrage wird die Verbindung beendet, um
|
||||
// temporäre Tabellen zu löschen
|
||||
servletConnection.disconnect(); |
||||
throw new SQLException("im Servlet " + gesamt.getError_String()); |
||||
} |
||||
|
||||
} |
||||
|
||||
public static void decodeUmlauts() { |
||||
gesamt.setError_String(decodeUmlauts(gesamt.getError_String())); |
||||
gesamt.setAktuelleNachricht(decodeUmlauts(gesamt.getAktuelleNachricht())); |
||||
gesamt.setRuntimeMessage(decodeUmlauts(gesamt.getRuntimeMessage())); |
||||
String[] colLabels = gesamt.getColumnLabels(); |
||||
for (int i = 0; i < colLabels.length; i++) { |
||||
colLabels[i] = decodeUmlauts(colLabels[i]); |
||||
|
||||
} |
||||
gesamt.setColumnLabels(colLabels); |
||||
SxResultSet rs = gesamt.getResultSet(); |
||||
for (Iterator it = rs.iterator(); it.hasNext();) { |
||||
SxResultRow row = (SxResultRow) it.next(); |
||||
int i = 0; |
||||
for (Iterator it2 = row.iterator(); it2.hasNext();) { |
||||
Object o = it2.next(); |
||||
if (o instanceof String) |
||||
{ o = decodeUmlauts(o.toString()); |
||||
row.set(i, o); |
||||
} |
||||
i++; |
||||
|
||||
} |
||||
|
||||
} |
||||
} |
||||
|
||||
private static String decodeUmlauts(String txt) { |
||||
if (txt != null) { |
||||
txt = StringUtils.replace(txt, "///oe///", "ö"); |
||||
txt = StringUtils.replace(txt, "///Oe///", "Ö"); |
||||
txt = StringUtils.replace(txt, "///ae///", "ä"); |
||||
txt = StringUtils.replace(txt, "///Ae///", "Ä"); |
||||
txt = StringUtils.replace(txt, "///ue///", "ü"); |
||||
txt = StringUtils.replace(txt, "///Ue///", "Ü"); |
||||
txt = StringUtils.replace(txt, "///ss///", "ß"); |
||||
} |
||||
return txt; |
||||
} |
||||
|
||||
static String encodeUmlauts(String query) { |
||||
query = StringUtils.replace(query, "ö", "///oe///"); |
||||
query = StringUtils.replace(query, "Ö", "///Oe///"); |
||||
query = StringUtils.replace(query, "ä", "///ae///"); |
||||
query = StringUtils.replace(query, "Ä", "///Ae///"); |
||||
query = StringUtils.replace(query, "ü", "///ue///"); |
||||
query = StringUtils.replace(query, "Ü", "///Ue///"); |
||||
query = StringUtils.replace(query, "ß", "///ss///"); |
||||
return query; |
||||
} |
||||
|
||||
static void setUrl(String url) throws MalformedURLException { |
||||
superXDbServletUrl = new URL(url); |
||||
} |
||||
|
||||
static public String getErrorString() { |
||||
return errorString; |
||||
} |
||||
|
||||
/** |
||||
* nur von SuperX.start() aufgerufen |
||||
* |
||||
* @param userID |
||||
* The userID to set. |
||||
*/ |
||||
public static void setUserID(Integer userID) { |
||||
SxSQL.userID = userID; |
||||
} |
||||
|
||||
public static void setLogMode(String logParam) { |
||||
logToKonsole = logParam; |
||||
} |
||||
|
||||
public static String getUserFromServlet() throws SQLException { |
||||
|
||||
executeQuery("get_user"); |
||||
SxResultRow row = (SxResultRow) gesamt.getResultSet().first(); |
||||
String user = (String) row.get(0); |
||||
|
||||
return user; |
||||
} |
||||
|
||||
/** |
||||
* Aufruf von SuperX.start und auch noch mal von SxSQL.checkPwd (am Ende) um |
||||
* auch bei Applicationstart dafür zu sorgen, dass privateKey geholt wird |
||||
* |
||||
* @throws Exception |
||||
*/ |
||||
public static void initParams() throws Exception { |
||||
executeQuery("get_params"); |
||||
String privateKeyEncoded = gesamt.getCheckval(); |
||||
if (privateKeyEncoded != null && !privateKeyEncoded.trim().equals("")) { |
||||
privateKeyEncoded = CryptUtils.decryptStringDES(privateKeyEncoded); |
||||
dsaHandler = new DSAHandler(privateKeyEncoded); |
||||
} else |
||||
dsaHandler = null; |
||||
newPasswordChecker = gesamt.newPasswordChecker; |
||||
} |
||||
} |
@ -1,100 +0,0 @@
@@ -1,100 +0,0 @@
|
||||
package de.superx.applet; |
||||
import java.io.Serializable; |
||||
import java.sql.SQLException; |
||||
import java.util.Vector; |
||||
|
||||
import de.superx.common.SuperX_el; |
||||
/** |
||||
* Ein Teil der Implementation des JDBC ResultSetMetaData interface.<BR> |
||||
* @author Rainer Behr (rainer@rbehr.de) |
||||
* @version 1.0 |
||||
*/ |
||||
|
||||
|
||||
|
||||
public class SxSQLMetaData implements Serializable |
||||
{ |
||||
private Vector V_cols = new Vector ();; |
||||
private int numColumns = -1; |
||||
|
||||
|
||||
public SxSQLMetaData (SuperX_el gesamt) |
||||
throws SQLException |
||||
{ |
||||
// used MetaData
|
||||
// -------------
|
||||
// String getColumnName(int column)
|
||||
// String getColumnLabel(int column)
|
||||
// int getColumnDisplaySize(int column)
|
||||
// int getColumnType(int column)
|
||||
// int getScale(int column)
|
||||
// boolean isWritable(int column)
|
||||
|
||||
//ResultSetMetaData meta = resultset.getMetaData();
|
||||
numColumns = gesamt.getColumnCount(); |
||||
|
||||
for (int i = 0; i < numColumns; i++) |
||||
{ |
||||
Vector V_column = new Vector(); |
||||
V_column.add (0, gesamt.getColumnNames() [i]); |
||||
V_column.add (1, gesamt.getColumnLabels() [i]); |
||||
V_column.add (2, new Integer (gesamt.getColumnDisplaySizes() [i])); |
||||
V_column.add (3, new Integer (gesamt.getColumnTypes() [i])); |
||||
V_column.add (4, new Integer (gesamt.getScales() [i])); |
||||
V_column.add (5, new Boolean (gesamt.getisWritable() [i])); |
||||
|
||||
V_cols.add (V_column); |
||||
} |
||||
} |
||||
|
||||
public int getColumnCount() |
||||
{ |
||||
return numColumns; |
||||
} |
||||
|
||||
/** |
||||
* |
||||
* @param column |
||||
* @return |
||||
* @deprecated not currently used |
||||
*/ |
||||
public String getColumnName (int column) |
||||
{ |
||||
Vector V_column = (Vector) V_cols.elementAt (column - 1); |
||||
return (String) V_column.elementAt (0); |
||||
} |
||||
|
||||
public String getColumnLabel (int column) |
||||
{ |
||||
Vector V_column = (Vector) V_cols.elementAt (column - 1); |
||||
return (String) V_column.elementAt (1); |
||||
} |
||||
|
||||
public int getColumnDisplaySize (int column) |
||||
{ |
||||
Vector V_column = (Vector) V_cols.elementAt (column - 1); |
||||
return ((Integer) V_column.elementAt (2)).intValue(); |
||||
} |
||||
|
||||
public int getColumnType (int column) |
||||
{ |
||||
Vector V_column = (Vector) V_cols.elementAt (column - 1); |
||||
return ((Integer) V_column.elementAt (3)).intValue(); |
||||
} |
||||
public int getScale (int column) |
||||
{ |
||||
Vector V_column = (Vector) V_cols.elementAt (column - 1); |
||||
return ((Integer) V_column.elementAt (4)).intValue(); |
||||
} |
||||
|
||||
public boolean isWritable (int column) |
||||
{ |
||||
Vector V_column = (Vector) V_cols.elementAt (column - 1); |
||||
return ((Boolean) V_column.elementAt (5)).booleanValue(); |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} |
@ -1,136 +0,0 @@
@@ -1,136 +0,0 @@
|
||||
// Beispielklasse aus dem JavaTutorial (http://java.sun.com/docs/books/tutorial) für SuperX angepasst
|
||||
/* |
||||
* @(#)TableMap.java 1.4 97/12/17 |
||||
* |
||||
* Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved. |
||||
* |
||||
* This software is the confidential and proprietary information of Sun |
||||
* Microsystems, Inc. ("Confidential Information"). You shall not |
||||
* disclose such Confidential Information and shall use it only in |
||||
* accordance with the terms of the license agreement you entered into |
||||
* with Sun. |
||||
* |
||||
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE |
||||
* SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE |
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
||||
* PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES |
||||
* SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING |
||||
* THIS SOFTWARE OR ITS DERIVATIVES. |
||||
* |
||||
*/ |
||||
|
||||
/** |
||||
* In a chain of data manipulators some behaviour is common. TableMap |
||||
* provides most of this behavour and can be subclassed by filters |
||||
* that only need to override a handful of specific methods. TableMap |
||||
* implements TableModel by routing all requests to its model, and |
||||
* TableModelListener by routing all events to its listeners. Inserting |
||||
* a TableMap which has not been subclassed into a chain of table filters |
||||
* should have no effect. |
||||
* |
||||
* @version 1.4 12/17/97 |
||||
* @author Philip Milne */ |
||||
|
||||
package de.superx.applet; |
||||
import java.util.Vector; |
||||
|
||||
import javax.swing.event.TableModelEvent; |
||||
import javax.swing.event.TableModelListener; |
||||
import javax.swing.table.AbstractTableModel; |
||||
|
||||
/** |
||||
* Erweiterung des TabellenModells. Wird für SxTable benötigt. |
||||
* |
||||
* @version 1.4 12/17/97 |
||||
* @author Philip Milne, erweitert von Rainer Behr |
||||
* @see SxTable |
||||
*/ |
||||
|
||||
|
||||
public class SxTableMap extends AbstractTableModel implements TableModelListener, SxTableModel |
||||
{ |
||||
protected SxTableModel model; |
||||
|
||||
public SxTableModel getModel() |
||||
{ |
||||
return model; |
||||
} |
||||
|
||||
public void setModel(SxTableModel model) |
||||
{ |
||||
this.model = model; |
||||
model.addTableModelListener(this); |
||||
} |
||||
|
||||
// By default, Implement TableModel by forwarding all messages
|
||||
// to the model.
|
||||
|
||||
public Object getValueAt(int aRow, int aColumn) |
||||
{ |
||||
return model.getValueAt(aRow, aColumn); |
||||
} |
||||
public Object getValueAt2(int aRow, int aColumn) |
||||
{ |
||||
return model.getValueAt2(aRow, aColumn); |
||||
} |
||||
// r.b. extension for proper sorting
|
||||
public Object getObjectAt(int aRow, int aColumn) |
||||
{ |
||||
return model.getObjectAt(aRow, aColumn); |
||||
} |
||||
|
||||
// r.b. extension for easy data setting
|
||||
public void setDataVector(Vector Rows, Vector Header, Object Meta) |
||||
{ |
||||
model.setDataVector(Rows, Header, Meta); |
||||
} |
||||
|
||||
// r.b. extension for easy data setting
|
||||
public void setDataVector(Vector Rows) |
||||
{ |
||||
model.setDataVector(Rows); |
||||
} |
||||
|
||||
public void setValueAt(Object aValue, int aRow, int aColumn) |
||||
{ |
||||
model.setValueAt(aValue, aRow, aColumn); |
||||
} |
||||
|
||||
public int getRowCount() { |
||||
return (model == null) ? 0 : model.getRowCount(); |
||||
} |
||||
|
||||
public int getColumnCount() { |
||||
return (model == null) ? 0 : model.getColumnCount(); |
||||
} |
||||
|
||||
public String getColumnName(int aColumn) { |
||||
return model.getColumnName(aColumn); |
||||
} |
||||
|
||||
// r.b. extension for max. columnsize
|
||||
public int getColumnSize(int aColumn) { |
||||
return model.getColumnSize(aColumn); |
||||
} |
||||
|
||||
public Class getColumnClass(int aColumn) { |
||||
return model.getColumnClass(aColumn); |
||||
} |
||||
|
||||
public void setEditable(boolean editable) |
||||
{ |
||||
model.setEditable(editable); |
||||
} |
||||
|
||||
public boolean isCellEditable(int row, int column) { |
||||
return model.isCellEditable(row, column); |
||||
} |
||||
//
|
||||
// Implementation of the TableModelListener interface,
|
||||
//
|
||||
|
||||
// By default forward all events to all the listeners.
|
||||
public void tableChanged(TableModelEvent e) { |
||||
fireTableChanged(e); |
||||
} |
||||
} |
@ -1,27 +0,0 @@
@@ -1,27 +0,0 @@
|
||||
|
||||
package de.superx.applet; |
||||
import java.util.Vector; |
||||
|
||||
import javax.swing.table.TableModel; |
||||
/** |
||||
* Eine Erweiterung des TableModel-Interfaces. |
||||
* @autor Rainer Behr |
||||
* @version 1.0 |
||||
* @see SxTableMap |
||||
*/ |
||||
|
||||
public interface SxTableModel extends TableModel |
||||
{ |
||||
public Object getObjectAt(int aRow, int aColumn); |
||||
|
||||
public void setDataVector(Vector rows, Vector header, Object meta); |
||||
|
||||
public void setDataVector(Vector rows); |
||||
|
||||
public int getColumnSize(int aColumn); |
||||
|
||||
public void setEditable(boolean editable); |
||||
|
||||
public Object getValueAt2(int aRow, int aColumn); |
||||
|
||||
} |
File diff suppressed because it is too large
Load Diff
@ -1,354 +0,0 @@
@@ -1,354 +0,0 @@
|
||||
// Beispielklasse aus dem JavaTutorial (http://java.sun.com/docs/books/tutorial) für SuperX angepasst
|
||||
/* |
||||
* @(#)TableSorter.java 1.3 97/10/06 |
||||
* |
||||
* Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved. |
||||
* |
||||
* This software is the confidential and proprietary information of Sun |
||||
* Microsystems, Inc. ("Confidential Information"). You shall not |
||||
* disclose such Confidential Information and shall use it only in |
||||
* accordance with the terms of the license agreement you entered into |
||||
* with Sun. |
||||
* |
||||
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE |
||||
* SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE |
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
||||
* PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES |
||||
* SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING |
||||
* THIS SOFTWARE OR ITS DERIVATIVES. |
||||
* |
||||
*/ |
||||
|
||||
/** |
||||
* A sorter for TableModels. The sorter has a model (conforming to TableModel) |
||||
* and itself implements TableModel. TableSorter does not store or copy |
||||
* the data in the TableModel, instead it maintains an array of |
||||
* integers which it keeps the same size as the number of rows in its |
||||
* model. When the model changes it notifies the sorter that something |
||||
* has changed eg. "rowsAdded" so that its internal array of integers |
||||
* can be reallocated. As requests are made of the sorter (like |
||||
* getValueAt(row, col) it redirects them to its model via the mapping |
||||
* array. That way the TableSorter appears to hold another copy of the table |
||||
* with the rows in a different order. The sorting algorthm used is stable |
||||
* which means that it does not move around rows when its comparison |
||||
* function returns 0 to denote that they are equivalent. |
||||
* |
||||
* @version 1.3 10/06/97 |
||||
* @author Philip Milne |
||||
*/ |
||||
|
||||
package de.superx.applet; |
||||
import java.util.Date; |
||||
import java.util.Vector; |
||||
|
||||
import javax.swing.event.TableModelEvent; |
||||
|
||||
/** |
||||
* Ein Sortierer für Tabellenmodelle. |
||||
* @version 1.3 10/06/97 |
||||
* @author Philip Milne |
||||
*/ |
||||
|
||||
public class SxTableSorter extends SxTableMap |
||||
{ |
||||
int indexes[]; |
||||
Vector sortingColumns = new Vector(); |
||||
boolean ascending = true; |
||||
int compares; |
||||
|
||||
public SxTableSorter() |
||||
{ |
||||
indexes = new int[0]; // For consistency.
|
||||
} |
||||
|
||||
public SxTableSorter(SxTableModel model) |
||||
{ |
||||
setModel(model); |
||||
} |
||||
|
||||
public void setModel(SxTableModel model) { |
||||
super.setModel(model); |
||||
reallocateIndexes(); |
||||
} |
||||
|
||||
public int [] getIndexes () |
||||
{ |
||||
return indexes; |
||||
} |
||||
|
||||
public int compareRowsByColumn(int row1, int row2, int column) |
||||
{ |
||||
Class type = model.getColumnClass(column); |
||||
SxTableModel data = model; |
||||
|
||||
// Check for nulls
|
||||
|
||||
Object o1 = data.getObjectAt(row1, column); |
||||
Object o2 = data.getObjectAt(row2, column); |
||||
|
||||
// If both values are null return 0
|
||||
if (o1 == null && o2 == null) { |
||||
return 0; |
||||
} |
||||
else if (o1 == null) { // Define null less than everything.
|
||||
return -1; |
||||
} |
||||
else if (o2 == null) { |
||||
return 1; |
||||
} |
||||
|
||||
/* We copy all returned values from the getValue call in case |
||||
an optimised model is reusing one object to return many values. |
||||
The Number subclasses in the JDK are immutable and so will not be used in |
||||
this way but other subclasses of Number might want to do this to save |
||||
space and avoid unnecessary heap allocation. |
||||
*/ |
||||
if (type.getSuperclass() == java.lang.Number.class) |
||||
{ |
||||
Number n1 = (Number)data.getObjectAt(row1, column); |
||||
double d1 = n1.doubleValue(); |
||||
Number n2 = (Number)data.getObjectAt(row2, column); |
||||
double d2 = n2.doubleValue(); |
||||
|
||||
if (d1 < d2) |
||||
return -1; |
||||
else if (d1 > d2) |
||||
return 1; |
||||
else |
||||
return 0; |
||||
} |
||||
else if (type == java.util.Date.class) |
||||
{ |
||||
Date d1 = (Date)data.getObjectAt(row1, column); |
||||
long n1 = d1.getTime(); |
||||
Date d2 = (Date)data.getObjectAt(row2, column); |
||||
long n2 = d2.getTime(); |
||||
|
||||
if (n1 < n2) |
||||
return -1; |
||||
else if (n1 > n2) |
||||
return 1; |
||||
else return 0; |
||||
} |
||||
else if (type == String.class) |
||||
{ |
||||
String s1 = (String)data.getObjectAt(row1, column); |
||||
String s2 = (String)data.getObjectAt(row2, column); |
||||
int result = s1.compareTo(s2); |
||||
|
||||
if (result < 0) |
||||
return -1; |
||||
else if (result > 0) |
||||
return 1; |
||||
else return 0; |
||||
} |
||||
else if (type == Boolean.class) |
||||
{ |
||||
Boolean bool1 = (Boolean)data.getObjectAt(row1, column); |
||||
boolean b1 = bool1.booleanValue(); |
||||
Boolean bool2 = (Boolean)data.getObjectAt(row2, column); |
||||
boolean b2 = bool2.booleanValue(); |
||||
|
||||
if (b1 == b2) |
||||
return 0; |
||||
else if (b1) // Define false < true
|
||||
return 1; |
||||
else |
||||
return -1; |
||||
} |
||||
else |
||||
{ |
||||
Object v1 = data.getObjectAt(row1, column); |
||||
String s1 = v1.toString(); |
||||
Object v2 = data.getObjectAt(row2, column); |
||||
String s2 = v2.toString(); |
||||
int result = s1.compareTo(s2); |
||||
|
||||
if (result < 0) |
||||
return -1; |
||||
else if (result > 0) |
||||
return 1; |
||||
else return 0; |
||||
} |
||||
} |
||||
|
||||
public int compare(int row1, int row2) |
||||
{ |
||||
compares++; |
||||
for(int level = 0; level < sortingColumns.size(); level++) |
||||
{ |
||||
Integer column = (Integer)sortingColumns.elementAt(level); |
||||
int result = compareRowsByColumn(row1, row2, column.intValue()); |
||||
if (result != 0) |
||||
return ascending ? result : -result; |
||||
} |
||||
return 0; |
||||
} |
||||
|
||||
public void reallocateIndexes() |
||||
{ |
||||
int rowCount = model.getRowCount(); |
||||
|
||||
// Set up a new array of indexes with the right number of elements
|
||||
// for the new data model.
|
||||
indexes = new int[rowCount]; |
||||
|
||||
// Initialise with the identity mapping.
|
||||
for(int row = 0; row < rowCount; row++) |
||||
indexes[row] = row; |
||||
} |
||||
|
||||
public void tableChanged(TableModelEvent e) |
||||
{ |
||||
// System.err.println("Sorter: tableChanged");
|
||||
reallocateIndexes(); |
||||
|
||||
super.tableChanged(e); |
||||
} |
||||
|
||||
public void dataChanged() |
||||
{ |
||||
reallocateIndexes(); |
||||
sort(this); |
||||
super.tableChanged(new TableModelEvent(this, 0, getRowCount())); |
||||
} |
||||
|
||||
public void checkModel() |
||||
{ |
||||
if (indexes.length != model.getRowCount()) { |
||||
// System.err.println("Sorter not informed of a change in model.");
|
||||
} |
||||
} |
||||
|
||||
public void sort(Object sender) |
||||
{ |
||||
checkModel(); |
||||
|
||||
compares = 0; |
||||
// n2sort();
|
||||
// qsort(0, indexes.length-1);
|
||||
shuttlesort((int[])indexes.clone(), indexes, 0, indexes.length); |
||||
// System.err.println("Compares: "+compares);
|
||||
} |
||||
|
||||
public void n2sort() { |
||||
for(int i = 0; i < getRowCount(); i++) { |
||||
for(int j = i+1; j < getRowCount(); j++) { |
||||
if (compare(indexes[i], indexes[j]) == -1) { |
||||
swap(i, j); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
// This is a home-grown implementation which we have not had time
|
||||
// to research - it may perform poorly in some circumstances. It
|
||||
// requires twice the space of an in-place algorithm and makes
|
||||
// NlogN assigments shuttling the values between the two
|
||||
// arrays. The number of compares appears to vary between N-1 and
|
||||
// NlogN depending on the initial order but the main reason for
|
||||
// using it here is that, unlike qsort, it is stable.
|
||||
public void shuttlesort(int from[], int to[], int low, int high) { |
||||
if (high - low < 2) { |
||||
return; |
||||
} |
||||
int middle = (low + high)/2; |
||||
shuttlesort(to, from, low, middle); |
||||
shuttlesort(to, from, middle, high); |
||||
|
||||
int p = low; |
||||
int q = middle; |
||||
|
||||
/* This is an optional short-cut; at each recursive call, |
||||
check to see if the elements in this subset are already |
||||
ordered. If so, no further comparisons are needed; the |
||||
sub-array can just be copied. The array must be copied rather |
||||
than assigned otherwise sister calls in the recursion might |
||||
get out of sinc. When the number of elements is three they |
||||
are partitioned so that the first set, [low, mid), has one |
||||
element and and the second, [mid, high), has two. We skip the |
||||
optimisation when the number of elements is three or less as |
||||
the first compare in the normal merge will produce the same |
||||
sequence of steps. This optimisation seems to be worthwhile |
||||
for partially ordered lists but some analysis is needed to |
||||
find out how the performance drops to Nlog(N) as the initial |
||||
order diminishes - it may drop very quickly. */ |
||||
|
||||
if (high - low >= 4 && compare(from[middle-1], from[middle]) <= 0) { |
||||
for (int i = low; i < high; i++) { |
||||
to[i] = from[i]; |
||||
} |
||||
return; |
||||
} |
||||
|
||||
// A normal merge.
|
||||
|
||||
for(int i = low; i < high; i++) { |
||||
if (q >= high || (p < middle && compare(from[p], from[q]) <= 0)) { |
||||
to[i] = from[p++]; |
||||
} |
||||
else { |
||||
to[i] = from[q++]; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public void swap(int i, int j) { |
||||
int tmp = indexes[i]; |
||||
indexes[i] = indexes[j]; |
||||
indexes[j] = tmp; |
||||
} |
||||
|
||||
// The mapping only affects the contents of the data rows.
|
||||
// Pass all requests to these rows through the mapping array: "indexes".
|
||||
|
||||
public Object getValueAt(int aRow, int aColumn) |
||||
{ |
||||
checkModel(); |
||||
return model.getValueAt(indexes[aRow], aColumn); |
||||
} |
||||
|
||||
// r.b. extension for proper sorting
|
||||
public Object getObjectAt(int aRow, int aColumn) |
||||
{ |
||||
checkModel(); |
||||
return model.getObjectAt(indexes[aRow], aColumn); |
||||
} |
||||
|
||||
public void setValueAt(Object aValue, int aRow, int aColumn) |
||||
{ |
||||
checkModel(); |
||||
model.setValueAt(aValue, indexes[aRow], aColumn); |
||||
} |
||||
|
||||
// r.b. extension for easy data setting
|
||||
public void setDataVector(Vector rows, Vector header, Object meta) |
||||
{ |
||||
// System.err.println ("Sorter: Rows = " + Rows.size());
|
||||
indexes = new int [rows.size()]; |
||||
|
||||
model.setDataVector(rows, header, meta); |
||||
} |
||||
|
||||
// r.b. extension for easy data setting
|
||||
public void setDataVector(Vector Rows) |
||||
{ |
||||
// System.err.println ("Sorter: Rows = " + Rows.size());
|
||||
indexes = new int [Rows.size()]; |
||||
|
||||
model.setDataVector(Rows); |
||||
} |
||||
|
||||
public void sortByColumn(int column) { |
||||
sortByColumn(column, true); |
||||
} |
||||
|
||||
public void sortByColumn(int column, boolean ascending) { |
||||
this.ascending = ascending; |
||||
sortingColumns.removeAllElements(); |
||||
sortingColumns.addElement(new Integer(column)); |
||||
sort(this); |
||||
super.tableChanged(new TableModelEvent(this, 0, getRowCount())); |
||||
} |
||||
|
||||
} |
@ -1,71 +0,0 @@
@@ -1,71 +0,0 @@
|
||||
package de.superx.applet; |
||||
/** |
||||
* |
||||
* Ein Eintrag für den Themenbaum. |
||||
* Abgelegt wird tid in der Tabelle themenbaum, Name, ggfs. Tid in der Tabelle Maskeninfo, Nummer des Vaterknotens (parent) und Erläuterungstext. |
||||
* |
||||
* @version 2.0 01/01/02 |
||||
* @author Meikel Bisping |
||||
*/ |
||||
|
||||
|
||||
public class SxThemenEintrag { |
||||
private Integer tid; |
||||
private String name; |
||||
private Integer maskeninfo_id; |
||||
private Integer parent; |
||||
private String erlaeuterung; |
||||
private String cssClass; |
||||
SxThemenEintrag () |
||||
{ |
||||
tid=null; |
||||
name=null; |
||||
maskeninfo_id=null; |
||||
parent=null; |
||||
erlaeuterung=null; |
||||
cssClass=null; |
||||
} |
||||
|
||||
SxThemenEintrag(Integer ltid, String lname, Integer lnr, Integer lparent, String lerlaeuterung, String lcssClass) |
||||
{ |
||||
tid=ltid; |
||||
name=lname; |
||||
maskeninfo_id=lnr; |
||||
parent=lparent; |
||||
erlaeuterung=lerlaeuterung; |
||||
cssClass=lcssClass; |
||||
} |
||||
|
||||
|
||||
public Integer getTid() |
||||
{ |
||||
return tid; |
||||
} |
||||
public String getName() |
||||
{ |
||||
return name; |
||||
} |
||||
public Integer getMaskeninfo_id() |
||||
{ |
||||
return maskeninfo_id; |
||||
} |
||||
public Integer getParent() |
||||
{ |
||||
return parent; |
||||
} |
||||
|
||||
public String getErlaeuterung() |
||||
{ |
||||
return erlaeuterung; |
||||
} |
||||
public String getCssClass() |
||||
{ |
||||
return cssClass; |
||||
} |
||||
|
||||
public String toString() |
||||
{ |
||||
return this.name; |
||||
} |
||||
|
||||
} |
@ -1,423 +0,0 @@
@@ -1,423 +0,0 @@
|
||||
package de.superx.applet; |
||||
import java.awt.event.MouseAdapter; |
||||
import java.awt.event.MouseEvent; |
||||
import java.sql.SQLException; |
||||
import java.util.Enumeration; |
||||
import java.util.Locale; |
||||
import java.util.Vector; |
||||
|
||||
import javax.swing.ImageIcon; |
||||
import javax.swing.JTree; |
||||
import javax.swing.event.TreeSelectionEvent; |
||||
import javax.swing.event.TreeSelectionListener; |
||||
import javax.swing.tree.DefaultMutableTreeNode; |
||||
import javax.swing.tree.DefaultTreeCellRenderer; |
||||
import javax.swing.tree.TreePath; |
||||
import javax.swing.tree.TreeSelectionModel; |
||||
|
||||
/** |
||||
* Beim ersten Aufruf wird der Themenbaum aus der Datenbank aufgebaut und in der statischen Variable tree abgelegt. |
||||
* Nur wenn ein anderer Benutzer/Stand angefordert wird, wird der Themenbaum neu aufgebaut. |
||||
* Die Darstellung wird von SxMask übernommen. |
||||
* @version 2.0 01/01/02 |
||||
* @author Meikel Bisping |
||||
*/ |
||||
|
||||
public class SxThemenbaum extends MouseAdapter implements TreeSelectionListener{ |
||||
|
||||
private Vector themenbaum; |
||||
private JTree tree; |
||||
|
||||
private SxThemenEintrag einEintrag; |
||||
static ImageIcon leaf = null; |
||||
private String standStr, lastuser; |
||||
private SxMask localmask; |
||||
private Vector rohform; |
||||
|
||||
SxThemenbaum(SxMask lmask) { |
||||
localmask = lmask; |
||||
String aktuser = new String(); |
||||
aktuser = SxSQL.getUserID().toString(); |
||||
|
||||
if (!aktuser.equals(lastuser)) { |
||||
tree = null; |
||||
standStr = null; |
||||
lastuser = aktuser; |
||||
} |
||||
|
||||
if (leaf == null) { |
||||
ClassLoader cl = getClass().getClassLoader(); |
||||
try { leaf = new ImageIcon(cl.getResource("images/leaf.gif")); |
||||
} |
||||
catch (Exception e) |
||||
{ |
||||
System.out.println("Bild für Baum nicht verfügbar"); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public JTree getTree(String lStand) throws SQLException { |
||||
// liefert Organigramm v. angegebenen Stand zurück
|
||||
String name, erlaeuterung, cssClass; |
||||
Integer tid, maskeninfo_id, parent; |
||||
//Der folgende Parameter ist nur provisorisch drin, in Zkunft kommt hier
|
||||
//Locale-Behandlung rein.
|
||||
//neu erstellen nur beim 1.mal und anderem Stand
|
||||
|
||||
// if (Stand == null || (!Stand.equals(lStand))) {
|
||||
standStr = lStand; |
||||
|
||||
//tree erzeugen für Stand
|
||||
//aus Datenbank auslesen
|
||||
String userID = SxSQL.getUserID().toString(); |
||||
|
||||
//datum String in sql.Date umformen
|
||||
java.sql.Date date = new java.sql.Date(1); |
||||
date = SxDate.getDate(standStr); |
||||
//rohform ist als Membervariable definiert, damit
|
||||
//noch erlaubteKnoten hinzugefügt werden können
|
||||
rohform = new Vector(); |
||||
|
||||
String query = ""; |
||||
|
||||
String sx_db = (String) SxDefaults.getPropertyValue("SxDB"); |
||||
//default für andere Datenbanken
|
||||
query = |
||||
"select tid, name, maskeninfo_id, parent, gueltig_seit, gueltig_bis,sort,css_class from themenbaum order by sort,name;drop table tmp_themenbaum;"; |
||||
//Makroabfragen sollen nicht erscheinen
|
||||
if (sx_db.equalsIgnoreCase("postgres")) { |
||||
query = |
||||
"select sp_user_themen(" |
||||
+ userID |
||||
+ ",today(),0);"+ //,'"+currentLocale.getLanguage()+ "')
|
||||
"select distinct tid,name,maskeninfo_id,parent,erlaeuterung,sort,css_class from tmp_themenbaum order by sort,name;drop table tmp_themenbaum;"; |
||||
} |
||||
if (sx_db.equalsIgnoreCase("informix")) |
||||
{ |
||||
query = |
||||
"execute procedure sp_user_themen(" |
||||
+ userID |
||||
+ ",today,0);"+ //'"+currentLocale.getLanguage()+ "');" +
|
||||
"select distinct tid,name,maskeninfo_id,parent,erlaeuterung,sort,css_class from tmp_themenbaum order by sort,name;drop table tmp_themenbaum;"; |
||||
} |
||||
|
||||
|
||||
SxSQL.executeAll(query); |
||||
rohform = SxSQL.getResultVector(); |
||||
|
||||
if (rohform.size() < 1) |
||||
return null; |
||||
//Umformen in Vector of SxThemenEintrag
|
||||
Vector dummy = new Vector(); |
||||
themenbaum = new Vector(); |
||||
Enumeration en1 = rohform.elements(); |
||||
|
||||
while (en1.hasMoreElements()) { |
||||
dummy = (Vector) en1.nextElement(); |
||||
if (dummy.elementAt(0)==null||!(dummy.elementAt(0) instanceof Integer)) |
||||
throw new IllegalArgumentException("Konnte Themenbaun nicht aufbauen, da Werte in tmp Tabelle fehlen oder falsch"); |
||||
tid = (Integer) dummy.elementAt(0); |
||||
if (dummy.elementAt(1)==null) |
||||
throw new IllegalArgumentException("Konnte Themenbaun nicht aufbauen, da Werte in tmp Tabelle fehlen oder falsch"); |
||||
|
||||
name = dummy.elementAt(1).toString(); |
||||
maskeninfo_id = (Integer) dummy.elementAt(2); |
||||
parent = (Integer) dummy.elementAt(3); |
||||
erlaeuterung = dummy.elementAt(4)==null?"":dummy.elementAt(4).toString(); |
||||
cssClass= dummy.elementAt(5)==null?"":dummy.elementAt(5).toString(); |
||||
einEintrag = |
||||
new SxThemenEintrag( |
||||
tid, |
||||
name, |
||||
maskeninfo_id, |
||||
parent, |
||||
erlaeuterung, |
||||
cssClass); |
||||
themenbaum.addElement(einEintrag); |
||||
} |
||||
rohform = null; |
||||
SxThemenEintrag ebene0 = |
||||
new SxThemenEintrag( |
||||
null, |
||||
"Abfragen/Berichte", |
||||
null, |
||||
null, |
||||
null, |
||||
null); |
||||
DefaultMutableTreeNode root = |
||||
new DefaultMutableTreeNode(ebene0); |
||||
|
||||
//hier werden über eine rekursive Methode alle
|
||||
//Institute in den Baum eingetragen
|
||||
insertnodes(null, root); |
||||
themenbaum = null; |
||||
|
||||
//Baum erzeugen
|
||||
tree = new JTree(root); |
||||
de.memtext.util.TreeUtils.sort(root); |
||||
tree.setRootVisible(false); |
||||
//root Abfragen/Berichte sieht man sowieso nicht
|
||||
//first child abfragen muss aufgeklappt sein
|
||||
//da Mouselistener Doubleclick umfunktioniert
|
||||
if (root.getChildCount() > 0) { |
||||
DefaultMutableTreeNode ebene1 = |
||||
(DefaultMutableTreeNode) root.getChildAt(0); |
||||
tree.expandPath(new TreePath(ebene1.getPath())); |
||||
} |
||||
|
||||
//Einfachselektion
|
||||
tree.getSelectionModel().setSelectionMode( |
||||
TreeSelectionModel.SINGLE_TREE_SELECTION); |
||||
|
||||
//Markierungsrandfarbe grau nicht gelb
|
||||
DefaultTreeCellRenderer renderer = |
||||
new DefaultTreeCellRenderer(); |
||||
renderer.setBorderSelectionColor(java.awt.Color.darkGray); |
||||
//ImageIcon leaf=new ImageIcon("h:\\mb\\leaf.gif");
|
||||
if (leaf != null) |
||||
renderer.setLeafIcon(leaf); |
||||
tree.setCellRenderer(renderer); |
||||
|
||||
//TreeSelectionListener hinzufügen
|
||||
//SxThemenDialogSecList sl = new SxThemenDialogSecList(localmask, tree);
|
||||
tree.addTreeSelectionListener(this); |
||||
|
||||
|
||||
|
||||
//MouseListener für Doppelklicks
|
||||
//(wird immer neu hinzugefügt, klappte sonst nicht?!)
|
||||
//SxThemenMouseListener ml = new SxThemenMouseListener(localmask);
|
||||
tree.addMouseListener(this); |
||||
return tree; |
||||
} |
||||
|
||||
private void insertnodes( |
||||
Integer theParent, |
||||
DefaultMutableTreeNode aktNode) { |
||||
//rekursive Methode, die Institutionen in den Baum einträgt
|
||||
Vector result = new Vector(); |
||||
result = mySelect(theParent); |
||||
Integer eintrag_tid; |
||||
|
||||
for (Enumeration el = result.elements(); el.hasMoreElements();) { |
||||
einEintrag = (SxThemenEintrag) el.nextElement(); |
||||
DefaultMutableTreeNode neuNode = |
||||
new DefaultMutableTreeNode(einEintrag); |
||||
aktNode.add(neuNode); |
||||
|
||||
eintrag_tid = einEintrag.getTid(); |
||||
//nervig null-Werte abfangen
|
||||
if (eintrag_tid != null & theParent == null) |
||||
insertnodes(einEintrag.getTid(), neuNode); |
||||
if (eintrag_tid == null & theParent == null) |
||||
System.out.println( |
||||
"Achtung! Element hat fälschlicherweise sich selbst als parent:" |
||||
+ einEintrag.getName()); |
||||
|
||||
if (eintrag_tid != null && theParent != null) |
||||
if (!theParent.equals(eintrag_tid)) |
||||
insertnodes(einEintrag.getTid(), neuNode); |
||||
else |
||||
System.out.println( |
||||
"Achtung! Element hat fälschlicherweise sich selbst als parent:" |
||||
+ einEintrag.getName() |
||||
+ "tid:" |
||||
+ einEintrag.getTid()); |
||||
} |
||||
|
||||
//wenn eine Kategorie (maskeninfo==null) keine Blätter (Abfragen)
|
||||
//enthält, die Kategorie entfernen
|
||||
einEintrag = (SxThemenEintrag) aktNode.getUserObject(); |
||||
// if (einEintrag.getMaskeninfo_id()==null&&result.size()<1)
|
||||
if (einEintrag.getMaskeninfo_id() == null && aktNode.isLeaf()) |
||||
aktNode.removeFromParent(); |
||||
|
||||
} |
||||
|
||||
private Vector mySelect(Integer pruefparent) { |
||||
//liefert alle Institute mit Parent =pruefparent zurück
|
||||
Vector result = new Vector(); |
||||
Integer eintrag_parent; |
||||
for (Enumeration el = themenbaum.elements(); |
||||
el.hasMoreElements(); |
||||
) { |
||||
einEintrag = (SxThemenEintrag) el.nextElement(); |
||||
eintrag_parent = einEintrag.getParent(); |
||||
if (eintrag_parent == null && pruefparent == null) |
||||
result.addElement(einEintrag); |
||||
if (eintrag_parent != null && pruefparent != null) |
||||
if (eintrag_parent.intValue() == pruefparent.intValue()) |
||||
result.addElement(einEintrag); |
||||
|
||||
} |
||||
return result; |
||||
} |
||||
|
||||
private void addKnotenUnique(Vector eineMaske) { |
||||
//Maske hinzufügen, falls unter dem Parent nicht schon vorhanden
|
||||
boolean schonvorhanden = false; |
||||
Vector test; |
||||
Integer maskeninfo_tid, parent; |
||||
maskeninfo_tid = (Integer) eineMaske.elementAt(2); |
||||
parent = (Integer) eineMaske.elementAt(3); |
||||
for (Enumeration el = rohform.elements(); el.hasMoreElements();) { |
||||
|
||||
test = (Vector) el.nextElement(); |
||||
if (maskeninfo_tid.equals((Integer) test.elementAt(2)) |
||||
&& parent.equals((Integer) test.elementAt(3))) { |
||||
schonvorhanden = true; |
||||
break; |
||||
} |
||||
} |
||||
if (!schonvorhanden) |
||||
rohform.add(eineMaske); // rohform ist Membervariable
|
||||
} |
||||
|
||||
public void valueChanged(TreeSelectionEvent event) { |
||||
DefaultMutableTreeNode node = |
||||
(DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); |
||||
|
||||
if (node != null) { |
||||
SxThemenEintrag themenEintrag=(SxThemenEintrag) node.getUserObject(); |
||||
MaskeninfoElement selectedMaskeninfoElement= |
||||
localmask.getSelectedMaskeninfoElement(); |
||||
|
||||
selectedMaskeninfoElement.clear(); |
||||
selectedMaskeninfoElement.setTid(themenEintrag.getMaskeninfo_id()); |
||||
selectedMaskeninfoElement.setName(themenEintrag.getName()); |
||||
localmask.terlaeuterung.setText(themenEintrag.getErlaeuterung()); |
||||
//System.out.println("Erl:"+help.getErlaeuterung());
|
||||
|
||||
} |
||||
} |
||||
public void mousePressed(MouseEvent e) { |
||||
if (e.getClickCount() == 2) { |
||||
//ausgewählter Wert wurde durch SelectionListener schon festgestellt
|
||||
if (localmask.getSelectedMaskeninfoElement().getTid()!=null) localmask.maskeOeffnen(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
// alternative Version, wird nicht genutzt
|
||||
/* private void erlaubteKnotenHinzufügen( |
||||
String userid, |
||||
java.sql.Date date) { |
||||
String query; |
||||
Vector dummy, Knoten = null; |
||||
Integer tid; |
||||
|
||||
try { |
||||
//Rechte, die dem User gegeben wurden
|
||||
query = |
||||
"select U.id from user_themen U,themenbaum T where U.id=T.tid and U.maske=0 and U.userid=" |
||||
+ userid |
||||
+ " and " |
||||
+ " T.gueltig_seit<=date('" |
||||
+ DateUtils.getTodayString() |
||||
+ "') and T.gueltig_bis>=date('" |
||||
+ DateUtils.getTodayString() |
||||
+ "') " |
||||
+ "union " |
||||
+ |
||||
//Rechte, die der Grupper gegeben wurden
|
||||
"select G.id from group_themen G,themenbaum T, user_group_bez B where G.id=T.tid" |
||||
+ " and G.maske=0 and G.groupid=B.groupinfo_id and B.userinfo_id=" |
||||
+ userid |
||||
+ " and " |
||||
+ " T.gueltig_seit<=date('" |
||||
+ DateUtils.getTodayString() |
||||
+ "') and T.gueltig_bis>=date('" |
||||
+ DateUtils.getTodayString() |
||||
+ "') "; |
||||
|
||||
SxSQL.executeQuery(query); |
||||
Knoten = SxSQL.getResultVector(); |
||||
|
||||
} catch (Exception ex) { |
||||
System.out.println(ex.toString()); |
||||
ex.printStackTrace(); |
||||
} |
||||
|
||||
for (Enumeration el = Knoten.elements(); el.hasMoreElements();) { |
||||
dummy = (Vector) el.nextElement(); |
||||
//SxSQL liefert immer Vector of Vectors zurück
|
||||
tid = (Integer) dummy.elementAt(0); |
||||
|
||||
erlaubteHinzufügenRekursion(tid, date); |
||||
|
||||
} |
||||
|
||||
} |
||||
private void erlaubteHinzufügenRekursion( |
||||
Integer themenknoten, |
||||
java.sql.Date date) { |
||||
String query; |
||||
Vector dummy, Masken, Masken2, eineMaske, Knoten = null; |
||||
Integer tid; |
||||
try { |
||||
//Masken der Auflistung hinzufügen
|
||||
query = |
||||
"select T.tid, M.name,M.tid,T.parent, M.erlaeuterung from maskeninfo M, themenbaum T where T.maskeninfo_id=M.tid and maskeninfo_id is not null and T.parent=" |
||||
+ themenknoten |
||||
+ " and T.gueltig_seit<=date('" |
||||
+ DateUtils.getTodayString() |
||||
+ "') and T.gueltig_bis>=date('" |
||||
+ DateUtils.getTodayString() |
||||
+ "') "; |
||||
|
||||
SxSQL.executeQuery(query); |
||||
Masken = SxSQL.getResultVector(); |
||||
for (Enumeration el = Masken.elements(); |
||||
el.hasMoreElements(); |
||||
) { |
||||
eineMaske = (Vector) el.nextElement(); |
||||
addKnotenUnique(eineMaske); |
||||
|
||||
//prüfen, ob die Maske noch unter anderen Knoten vorkommt, ggfs. hinzufügen
|
||||
query = |
||||
"select T.tid, M.name,M.tid,T.parent, M.erlaeuterung from maskeninfo M, themenbaum T where " |
||||
+ "T.maskeninfo_id=M.tid and maskeninfo_id=" |
||||
+ eineMaske.elementAt(2).toString() |
||||
+ " and T.parent!=" |
||||
+ themenknoten |
||||
+ " and T.gueltig_seit<=date('" |
||||
+ DateUtils.getTodayString() |
||||
+ "') and T.gueltig_bis>=date('" |
||||
+ DateUtils.getTodayString() |
||||
+ "') "; |
||||
SxSQL.executeQuery(query); |
||||
Masken2 = SxSQL.getResultVector(); |
||||
for (Enumeration el2 = Masken2.elements(); |
||||
el2.hasMoreElements(); |
||||
) { |
||||
eineMaske = (Vector) el2.nextElement(); |
||||
addKnotenUnique(eineMaske); |
||||
} |
||||
|
||||
} |
||||
|
||||
//für weitere Knoten Prozedure rekursiv aufrufen
|
||||
query = |
||||
"select T.tid from themenbaum T where T.parent=" |
||||
+ themenknoten |
||||
+ " and T.maskeninfo_id is null " |
||||
+ " and T.gueltig_seit<=date('" |
||||
+ DateUtils.getTodayString() |
||||
+ "') and T.gueltig_bis>=date('" |
||||
+ DateUtils.getTodayString() |
||||
+ "') "; |
||||
SxSQL.executeQuery(query); |
||||
Knoten = SxSQL.getResultVector(); |
||||
} catch (Exception ex) { |
||||
System.out.println(ex.toString()); |
||||
ex.printStackTrace(); |
||||
} |
||||
for (Enumeration el = Knoten.elements(); el.hasMoreElements();) { |
||||
dummy = (Vector) el.nextElement(); |
||||
//SxSQL liefert immer Vector of Vectors zurück
|
||||
tid = (Integer) dummy.elementAt(0); |
||||
|
||||
erlaubteHinzufügenRekursion(tid, date); |
||||
} |
||||
} |
||||
*/ |
@ -1,388 +0,0 @@
@@ -1,388 +0,0 @@
|
||||
package de.superx.applet; |
||||
|
||||
import java.awt.Font; |
||||
import java.awt.Frame; |
||||
import java.awt.Point; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.awt.event.MouseAdapter; |
||||
import java.awt.event.MouseEvent; |
||||
import java.awt.event.MouseListener; |
||||
import java.sql.Date; |
||||
import java.sql.SQLException; |
||||
import java.text.DateFormat; |
||||
import java.text.ParseException; |
||||
import java.util.Calendar; |
||||
import java.util.HashMap; |
||||
import java.util.Hashtable; |
||||
import java.util.Iterator; |
||||
import java.util.LinkedList; |
||||
import java.util.TimeZone; |
||||
|
||||
import javax.swing.JButton; |
||||
import javax.swing.JEditorPane; |
||||
import javax.swing.JLabel; |
||||
import javax.swing.JOptionPane; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JScrollPane; |
||||
import javax.swing.JSplitPane; |
||||
import javax.swing.tree.DefaultMutableTreeNode; |
||||
|
||||
import de.memtext.dlg.OkCancelClearDlg; |
||||
import de.memtext.tree.KeyParentEqualException; |
||||
import de.memtext.tree.NoMainEntryException; |
||||
import de.memtext.util.DateUtils; |
||||
import de.memtext.util.WindowUtils; |
||||
import de.memtext.widgets.LabeledComboBox; |
||||
import de.memtext.widgets.TitlePanel; |
||||
import de.memtext.widgets.VerticalBox; |
||||
import de.memtext.widgets.WarningMessage; |
||||
import de.superx.common.DBServletException; |
||||
import de.superx.common.FieldContainer; |
||||
import de.superx.common.SelectableItem; |
||||
import de.superx.common.Sichtgruppe; |
||||
|
||||
/** |
||||
* Ein Baumdialog, bei dem ein Element ausgewählt werden kann. Falls in der |
||||
* Sichtgruppe mehrere Sichten enthalten sind, kann eine Sicht ausgewählt |
||||
* werden. Ggfs. kann auch der Stand geändert werden. Als gewähltes Ergebnis |
||||
* kann man mit der Methode getResult ein SelectableItem-Objekt kriegen. |
||||
* |
||||
* @author Meikel Bisping |
||||
*/ |
||||
public class SxTreeDlg extends OkCancelClearDlg { |
||||
private JButton bStand; |
||||
private JEditorPane erlPane = new JEditorPane("text/html", ""); |
||||
private JScrollPane erlScrollP; |
||||
private Font fontBtns = new Font("SansSerif", Font.PLAIN, 10); |
||||
boolean result, isStandChanged; |
||||
private LinkedList selections = new LinkedList(); |
||||
JLabel lblStand; |
||||
private String standAmAnfang; |
||||
JScrollPane treeScroll = new JScrollPane(); |
||||
private SxTreeDlgMouseListener mouseList = new SxTreeDlgMouseListener(); |
||||
private LabeledComboBox cbSichten; |
||||
private Sichtgruppe sichtgruppe; |
||||
private JPanel auswahlPanel; |
||||
private SichtenChangeListener changeListener = new SichtenChangeListener(); |
||||
|
||||
public SxTreeDlg(Frame parent, String name, Sichtgruppe sichtgruppe, |
||||
String erläuterung) throws SQLException, DBServletException, |
||||
KeyParentEqualException, CloneNotSupportedException, NoMainEntryException { |
||||
super(parent, "Auswahl " + name); |
||||
selections.clear(); |
||||
Point parloc = parent.getLocation(); |
||||
setLocation(parloc.x + 30, parloc.y + 30); |
||||
// PlafUtils.setWindowsLook(this);
|
||||
this.sichtgruppe = sichtgruppe; |
||||
|
||||
setNorth(new TitlePanel("Auswahl " + name)); |
||||
initCenter(erläuterung); |
||||
|
||||
JButton btnSuchen = new JButton("Suchen"); |
||||
btnSuchen.setFont(fontBtns); |
||||
btnSuchen.addActionListener(new SuchenListener()); |
||||
addAboveOK(btnSuchen); |
||||
|
||||
for (Iterator it = sichtgruppe.iterator(); it.hasNext();) { |
||||
SichtApplet aSicht = (SichtApplet) it.next(); |
||||
aSicht.addMouseListener(mouseList); |
||||
} |
||||
|
||||
this.setSize(700, 500); |
||||
|
||||
} |
||||
|
||||
private void initCenter(String erläuterung) throws SQLException, DBServletException, KeyParentEqualException, CloneNotSupportedException, NoMainEntryException { |
||||
JSplitPane jsp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); |
||||
erlScrollP = new JScrollPane(erlPane); |
||||
// erlScrollP.setMaximumSize(new Dimension(500,300));
|
||||
jsp.add(erlScrollP); |
||||
erlPane.setText(erläuterung); |
||||
erlPane.setEditable(false); |
||||
if (erläuterung == null || erläuterung.trim().equals("")) |
||||
erlScrollP.setVisible(false); |
||||
|
||||
jsp.setDividerLocation(250); |
||||
|
||||
VerticalBox vbox = new VerticalBox(); |
||||
auswahlPanel = new JPanel(); |
||||
lblStand = new JLabel(); |
||||
|
||||
lblStand.setFont(fontBtns); |
||||
bStand = new JButton("anderer Stand"); |
||||
bStand.setFont(fontBtns); |
||||
bStand.setDefaultCapable(false); |
||||
bStand.addActionListener(new StandListener()); |
||||
auswahlPanel.add(lblStand); |
||||
auswahlPanel.add(bStand); |
||||
vbox.add(auswahlPanel); |
||||
cbSichten = new LabeledComboBox("Sicht", sichtgruppe.getSichtenlist()); |
||||
|
||||
cbSichten.addActionListener(changeListener); |
||||
if (sichtgruppe.getSelectedSicht() != null) { |
||||
cbSichten.setSelectedItem(sichtgruppe.getSelectedSicht()); |
||||
} else { |
||||
cbSichten.setSelectedIndex(0); |
||||
sichtgruppe.setSelectedSicht((SichtApplet) cbSichten |
||||
.getSelectedItem()); |
||||
try { |
||||
sichtgruppe.makeSureSelectedSichtIsOK(new Hashtable(),new HashMap(),new FieldContainer()); |
||||
} |
||||
catch (Exception e) |
||||
{ |
||||
throw new SQLException(e.toString()); |
||||
} |
||||
} |
||||
auswahlPanel.add(cbSichten); |
||||
if (sichtgruppe.size() < 2) |
||||
cbSichten.setVisible(false); |
||||
lblStand.setText("Stand: " |
||||
+ sichtgruppe.getSelectedSicht().getStand()); |
||||
standAmAnfang = sichtgruppe.getSelectedSicht().getStand(); |
||||
vbox.add(treeScroll); |
||||
jsp.add(vbox); |
||||
setCenter(jsp); |
||||
|
||||
} |
||||
|
||||
private void updateStandVisibility() { |
||||
if (sichtgruppe.getSelectedSicht().isStandbuttonWanted()) { |
||||
lblStand.setVisible(true); |
||||
bStand.setVisible(true); |
||||
} else { |
||||
lblStand.setVisible(false); |
||||
bStand.setVisible(false); |
||||
} |
||||
|
||||
} |
||||
|
||||
public void standAendern() throws SQLException, DBServletException, |
||||
KeyParentEqualException, CloneNotSupportedException, NoMainEntryException { |
||||
DateFormat df; |
||||
String neuerStand = JOptionPane |
||||
.showInputDialog(this, "Neues Datum eingeben:", "SuperX", |
||||
JOptionPane.QUESTION_MESSAGE); |
||||
if (neuerStand == null) |
||||
return; |
||||
df = DateFormat.getDateInstance(DateFormat.MEDIUM); |
||||
// r.b. default Jahr 4-stellig
|
||||
df.setTimeZone(TimeZone.getDefault()); |
||||
df.setLenient(false); |
||||
String geprueft = null; |
||||
java.sql.Date adate = 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); |
||||
|
||||
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 && adate != null |
||||
&& !SuperX.isZukünftigerStandErlaubt) { |
||||
if (DateUtils.isDateInFuture((Date) adate)) { |
||||
WarningMessage.show(this, |
||||
"Das Datum darf nicht in der Zukunft liegen", "SuperX"); |
||||
geprueft = null; |
||||
} |
||||
} |
||||
if (geprueft != null) // Form Ok
|
||||
{ |
||||
WindowUtils.setWaitCursor(this, true); |
||||
lblStand.setText("Stand: " + neuerStand); |
||||
try { |
||||
sichtgruppe.setStand(new Hashtable(),new HashMap(),new FieldContainer(),neuerStand); |
||||
} |
||||
catch (Exception e) |
||||
{ |
||||
throw new SQLException(e.toString()); |
||||
} |
||||
WindowUtils.setWaitCursor(this, false); |
||||
isStandChanged = true; |
||||
} else |
||||
JOptionPane.showMessageDialog(null, "Ungültige Eingabe!", "SuperX", |
||||
JOptionPane.ERROR_MESSAGE); |
||||
|
||||
} |
||||
|
||||
public LinkedList getSelections() { |
||||
return selections; |
||||
} |
||||
|
||||
private void suchen() { |
||||
String such = JOptionPane.showInputDialog(null, "Suche:", "SuperX", |
||||
JOptionPane.QUESTION_MESSAGE); |
||||
if (such == null || such.length() < 1) |
||||
return; |
||||
such = such.toLowerCase(); |
||||
SichtApplet sicht = (SichtApplet) sichtgruppe.getSelectedSicht(); |
||||
sicht.searchEntries(such); |
||||
} |
||||
|
||||
protected void performOk() { |
||||
|
||||
try { |
||||
removeMouseListener(sichtgruppe, mouseList); |
||||
SichtApplet sicht = (SichtApplet) sichtgruppe |
||||
.getSelectedSicht(); |
||||
if (sicht.getSelectionCount() == 0) { |
||||
SelectableItem selectedItem = new SelectableItem("-1", ""); |
||||
selectedItem.setAllowed(false); |
||||
selections.add(selectedItem); |
||||
} else |
||||
|
||||
for (int i = 0; i < sicht.getSelectionCount(); i++) { |
||||
DefaultMutableTreeNode selNode = (DefaultMutableTreeNode) sicht |
||||
.getSelectionPaths()[i].getLastPathComponent(); |
||||
if (!(selNode.getUserObject() instanceof SelectableItem)) { |
||||
performClear(); |
||||
break; |
||||
} else { |
||||
SelectableItem selectedItem = (SelectableItem) selNode |
||||
.getUserObject(); |
||||
selections.add(selectedItem); |
||||
} |
||||
|
||||
} |
||||
} catch (Exception e) { |
||||
WarningMessage.show(this, "Fehler\n" + e, "SuperX"); |
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
this.setVisible(false); |
||||
this.dispose(); |
||||
} |
||||
|
||||
protected void performCancel() { |
||||
removeMouseListener(sichtgruppe, mouseList); |
||||
/* |
||||
* if (!sichtgruppe.getLastSelectedSicht().getStand() |
||||
* .equals(standAmAnfang)) { WindowUtils.setWaitCursor(this, true); try { |
||||
* sichtgruppe.setStand(standAmAnfang); } catch (Exception e) { |
||||
* WarningMessage.show(this, "Stand konnte nicht geändert werden.\n" + |
||||
* e, "SuperX"); e.printStackTrace(); } WindowUtils.setWaitCursor(this, |
||||
* false); } |
||||
*/ |
||||
selections.clear(); |
||||
this.setVisible(false); |
||||
this.dispose(); |
||||
} |
||||
|
||||
protected void performClear() { |
||||
removeMouseListener(sichtgruppe, mouseList); |
||||
if (sichtgruppe != null) |
||||
sichtgruppe.getSelectedSicht().clearSelection(); |
||||
SelectableItem selectedItem = new SelectableItem("null", ""); |
||||
selectedItem.setAllowed(false); |
||||
selections.add(selectedItem); |
||||
this.setVisible(false); |
||||
this.dispose(); |
||||
} |
||||
|
||||
public void configure(String gewünschterStand) { |
||||
try { |
||||
sichtgruppe.setStand(new Hashtable(),new HashMap(),new FieldContainer(),gewünschterStand); |
||||
} catch (Exception e) { |
||||
WarningMessage.show(this, "Stand konnte nicht geändert werden.\n" |
||||
+ e, "SuperX"); |
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
} |
||||
|
||||
private void removeMouseListener(Sichtgruppe sichtgruppe, |
||||
MouseListener mouseList) { |
||||
for (Iterator it = sichtgruppe.iterator(); it.hasNext();) { |
||||
SichtApplet aSicht = (SichtApplet) it.next(); |
||||
try { |
||||
aSicht.removeMouseListener(mouseList); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
private void setCursor(boolean b) { |
||||
WindowUtils.setWaitCursor(this, b); |
||||
} |
||||
|
||||
class StandListener implements ActionListener { |
||||
public void actionPerformed(ActionEvent event) { |
||||
try { |
||||
standAendern(); |
||||
} catch (Exception e) { |
||||
WarningMessage.show(null, |
||||
"Stand konnte nicht geändert werden.\n" + e, "SuperX"); |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
class SuchenListener implements ActionListener { |
||||
public void actionPerformed(ActionEvent event) { |
||||
suchen(); |
||||
} |
||||
} |
||||
|
||||
class SichtenChangeListener implements ActionListener { |
||||
public void actionPerformed(ActionEvent e) { |
||||
setCursor(true); |
||||
SichtApplet newSicht = (SichtApplet) cbSichten.getSelectedItem(); |
||||
sichtgruppe.setSelectedSicht(newSicht); |
||||
|
||||
try { |
||||
sichtgruppe.makeSureSelectedSichtIsOK(new Hashtable(),new HashMap(),new FieldContainer()); |
||||
treeScroll.setViewportView(newSicht); |
||||
} catch (Exception e1) { |
||||
WarningMessage.show(null, "Fehler.\n" + e, "SuperX"); |
||||
e1.printStackTrace(); |
||||
} |
||||
updateStandVisibility(); |
||||
setCursor(false); |
||||
} |
||||
} |
||||
|
||||
/* |
||||
* Ausgebaut wegen Alt.Hier Problemen |
||||
*/ |
||||
class SxTreeDlgMouseListener extends MouseAdapter { |
||||
SxTreeDlgMouseListener() { |
||||
} |
||||
|
||||
public void mousePressed(MouseEvent e) { |
||||
if (e.getClickCount() == 2) { |
||||
// performOk();
|
||||
} |
||||
} |
||||
} |
||||
|
||||
public boolean isStandChanged() { |
||||
return isStandChanged; |
||||
} |
||||
|
||||
} |
@ -1,562 +0,0 @@
@@ -1,562 +0,0 @@
|
||||
package de.superx.applet; |
||||
|
||||
import java.io.FileNotFoundException; |
||||
import java.io.IOException; |
||||
import java.io.InputStream; |
||||
import java.text.DateFormat; |
||||
import java.text.ParseException; |
||||
import java.util.Enumeration; |
||||
import java.util.Hashtable; |
||||
import java.util.Locale; |
||||
import java.util.Properties; |
||||
|
||||
import de.memtext.util.DateUtils; |
||||
import de.memtext.util.StringUtils; |
||||
import de.memtext.widgets.WarningMessage; |
||||
|
||||
//SxNew mit superx.util.SqlStringUtils vergleichen und diese Klasse
|
||||
/** |
||||
* Die Klasse SxUtils führt String-Operationen zur Vorbereitung von |
||||
* Datenbank-Transaktionen durch |
||||
* |
||||
* @deprecated |
||||
* @author R.Behr modified by Marlies Winterstein |
||||
* @version 2.0, 5 Jan 1998 - 0.9, 31 July 1998 modified 01-2002 |
||||
* |
||||
*/ |
||||
public class SxUtils { |
||||
public final static int bufSize = 32 * 1024; |
||||
public final static String errString = "--ERROR--"; |
||||
|
||||
private static String COMM_START = "/*"; |
||||
private static String COMM_END = "*/"; |
||||
|
||||
private static int COMM_START_LEN = COMM_START.length(); |
||||
private static int COMM_END_LEN = COMM_END.length(); |
||||
|
||||
private static String COMMENT1_ANF = "{"; |
||||
private static String COMMENT1_END = "}"; |
||||
private static String COMMENT2_ANF = "--"; |
||||
private static String COMMENT2_END = "\n"; |
||||
private static String COMMENT3_ANF = "/*"; |
||||
private static String COMMENT3_END = "*/"; |
||||
private static String COMMENT1_ANF_MASK = "#K#"; |
||||
private static String COMMENT1_END_MASK = "#/K"; |
||||
private static String COMMENT2_ANF_MASK = "#S#"; |
||||
private static String COMMENT2_END_MASK = "#/S#"; |
||||
private static String COMMENT3_ANF_MASK = "#*A#"; |
||||
private static String COMMENT3_END_MASK = "#*E#"; |
||||
private static String PREV_POS = ">>"; |
||||
private static String PREV_POS_MASK = ">#>"; |
||||
private static String NEXT_POS = "<<"; |
||||
private static String NEXT_POS_MASK = "<#<"; |
||||
private static String SELECT_DELIMITER = ";"; |
||||
private static String SELECT_DELIMITER_MASK = "^"; |
||||
private static String STR_DELIMITER1 = "\""; |
||||
private static String STR_DELIMITER1_MASK = "#s1#"; |
||||
private static String STR_DELIMITER2 = "'"; |
||||
private static String STR_DELIMITER2_MASK = "#s2#"; |
||||
|
||||
private static StringBuffer buffer; |
||||
private static String prev_str; |
||||
|
||||
static { |
||||
buffer = new StringBuffer(bufSize); |
||||
} |
||||
|
||||
public synchronized static void setFieldDelimiter(String field_start, |
||||
String field_end) { |
||||
if (field_start != null) { |
||||
if (field_start.length() == 0) |
||||
NEXT_POS = ""; |
||||
else |
||||
NEXT_POS = field_start.substring(0, field_start.length() - 1); |
||||
} |
||||
|
||||
if (field_end != null) { |
||||
if (field_end.length() == 0) |
||||
PREV_POS = ""; |
||||
else |
||||
PREV_POS = field_end.substring(0, field_end.length() - 1); |
||||
} |
||||
} |
||||
|
||||
public static String getFieldPrefix() { |
||||
return new String(NEXT_POS); |
||||
} |
||||
|
||||
public static String getFieldSuffix() { |
||||
return new String(PREV_POS); |
||||
} |
||||
|
||||
public synchronized static void setComment(String comm_start, |
||||
String comm_end) { |
||||
if (comm_start != null) { |
||||
COMM_START = comm_start; |
||||
COMM_START_LEN = comm_start.length(); |
||||
} |
||||
if (comm_end != null) { |
||||
COMM_END = comm_end; |
||||
COMM_END_LEN = comm_end.length(); |
||||
} |
||||
} |
||||
|
||||
private static String noappletout(String sql_str) { |
||||
while (sql_str != null && sql_str.indexOf("--notinapplet") > -1) { |
||||
int pos = sql_str.indexOf("--notinapplet"); |
||||
String prev = sql_str.substring(0, pos); |
||||
if (prev.lastIndexOf("/*") == -1) |
||||
throw new IllegalStateException( |
||||
"--notinapplet muss eingeschlossen sein von /* */, nicht " |
||||
+ sql_str); |
||||
prev = prev.substring(0, prev.lastIndexOf("/*") - 1); |
||||
if (sql_str.indexOf(("*/"), pos) == -1) |
||||
throw new IllegalStateException( |
||||
"--notinapplet muss eingeschlossen sein von /* */, nicht " |
||||
+ sql_str); |
||||
|
||||
String post = sql_str.substring(sql_str.indexOf(("*/"), pos) + 2); |
||||
sql_str = prev + "\n" + post; |
||||
} |
||||
return sql_str; |
||||
} |
||||
|
||||
static synchronized String generateSQL(SxForm sxform, String sqlStatement) { |
||||
Object obj = null; |
||||
sqlStatement = noappletout(sqlStatement); |
||||
sqlStatement = replace(sqlStatement, "<<erlaubt>>", |
||||
sxform.isErlaubt() ? "1" : "0"); |
||||
Hashtable hashtable = sxform.getMap(); |
||||
for (Enumeration enumeration = hashtable.keys(); enumeration |
||||
.hasMoreElements();) { |
||||
String fieldname = (String) enumeration.nextElement(); |
||||
if (fieldname.startsWith("F_")) { |
||||
SxField sxField = sxform.getField(fieldname); |
||||
String fieldKey = sxform.getFieldKey("F_" |
||||
+ fieldname.substring(2)); |
||||
//kommt was anderes raus : //fieldKey =
|
||||
// sxField.getKey().toString();
|
||||
if (fieldKey != null) { |
||||
sqlStatement = replace(sqlStatement, getFieldPrefix() |
||||
+ fieldname.substring(2) + getFieldSuffix(), |
||||
fieldKey); |
||||
} |
||||
if (sxField.hasSichten()) { |
||||
SichtApplet sicht = sxField.getSelectedSicht(); |
||||
sqlStatement = replace(sqlStatement, "<<" + sicht.getArt() |
||||
+ ">>", sicht.getId().toString()); |
||||
//z.B. beim ersetzen von <<abgebende Institution-Sicht>>
|
||||
// und <<empfangende Institution-Sicht>>
|
||||
//wäre sonst beides <<Organigramm-Sicht>>
|
||||
sqlStatement = replace(sqlStatement, "<<" |
||||
+ sxField.getName().substring(2) + "-Sicht>>", |
||||
sicht.getId().toString()); |
||||
|
||||
String sx_db = (String) SxDefaults.getPropertyValue("SxDB"); |
||||
java.util.Date date = null; |
||||
try { |
||||
date = DateUtils.parse(sicht.getStand()); |
||||
} catch (ParseException e) { |
||||
e.printStackTrace(); |
||||
WarningMessage |
||||
.show( |
||||
null, |
||||
"Datum " |
||||
+ sicht.getStand() |
||||
+ " der Sicht konnte nicht interpretiert werden", |
||||
"SuperX"); |
||||
} |
||||
String replaceStr = null; |
||||
if (sx_db.equals("Postgres")) |
||||
replaceStr = "date_val('" |
||||
+ DateUtils.formatGerman(date) + "')"; |
||||
else |
||||
replaceStr = "date('" + DateUtils.formatGerman(date) |
||||
+ "')"; |
||||
|
||||
String search = "<<" + sicht.getArt() |
||||
|
||||
+ "Stand>>"; |
||||
sqlStatement = replace(sqlStatement, search, replaceStr); |
||||
if (sicht.getArt() != null |
||||
&& sicht.getArt().endsWith("Sicht")) { |
||||
search = "<<" |
||||
+ StringUtils.removeFromEnd(sicht.getArt(), |
||||
"Sicht", true) + "Stand>>"; |
||||
sqlStatement = replace(sqlStatement, search, replaceStr); |
||||
} |
||||
search = "<<" + sxField.getName().substring(2) + "-Stand>>"; |
||||
sqlStatement = replace(sqlStatement, search, replaceStr); |
||||
|
||||
} |
||||
} |
||||
} |
||||
|
||||
String sx_db = (String) SxDefaults.getPropertyValue("SxDB"); |
||||
String replaceStr = "IDS"; |
||||
if (sx_db.equals("Postgres")) |
||||
replaceStr = "PG"; |
||||
|
||||
sqlStatement = sqlStatement.replaceAll("<<DATABASE_ABBR>>", replaceStr); |
||||
// falls jetzt noch Organigramm-Stand übrig, nicht durch Sicht ersetzt,
|
||||
// also today()
|
||||
sqlStatement = sqlStatement.replaceAll("<<Organigramm-Stand>>", |
||||
"today()"); |
||||
|
||||
//MB 07/2010 macht Probleme bei Freemarker hashes
|
||||
// MB 10/2013 wieder aktiviert, bei {" drin lassen für Hashes
|
||||
sqlStatement = deleteComment(sqlStatement, "{", "}"); |
||||
|
||||
sqlStatement = deleteComment(sqlStatement, "/*", "*/"); |
||||
sqlStatement = deleteComment(sqlStatement, "--", "\n"); |
||||
int i = 1; |
||||
return sqlStatement; |
||||
} |
||||
|
||||
/** |
||||
* Kommentare werden gelöscht Für FreeMarker ist es problematisch dass {...} |
||||
* als Kommentar gelöscht wird, weil Variablen so definiert werden |
||||
* ${varname}. Änderung der Methode, dass {...} nur gelöscht wird, wenn das |
||||
* vorherige Zeichen kein $ ist |
||||
* |
||||
* @param str |
||||
* @param comm_start_str |
||||
* @param comm_end_str |
||||
* @deprecated original in SqlStringUtils |
||||
* @return |
||||
*/ |
||||
private static String deleteComment(String str, String comm_start_str, |
||||
String comm_end_str) { |
||||
String search_str = comm_start_str; |
||||
|
||||
int comm_end = -1; |
||||
int pos = -1; |
||||
int offset = 0; |
||||
int len = str.length(); |
||||
int search_len = search_str.length(); |
||||
|
||||
StringBuffer lbuffer = new StringBuffer(); |
||||
while (offset < len) { |
||||
pos = str.indexOf(search_str, offset); |
||||
if (pos != -1) { |
||||
if (pos > 0 && comm_start_str.equals("{") |
||||
&& (str.charAt(pos - 1) == '$' |
||||
//MB 16.10.13 folgendes Zeichen nicht " das sorgt dafür das Hashes erkannt bleiben
|
||||
||str.charAt(pos+1)=='"') |
||||
) { |
||||
lbuffer.append(str.substring(offset, pos + 1)); |
||||
offset = pos + 1; |
||||
continue; |
||||
} |
||||
prev_str = str.substring(offset, pos); |
||||
comm_end = str.indexOf(comm_end_str, pos + search_len); |
||||
//wenn kein Kommentar-Ende gefunden
|
||||
//wird String Ende das Kommentar-Ende sein
|
||||
if (comm_end == -1) |
||||
comm_end = str.length() - 1; |
||||
lbuffer.append(prev_str); |
||||
offset = comm_end + comm_end_str.length(); |
||||
} else { |
||||
lbuffer.append(str.substring(offset, len)); |
||||
offset = len; |
||||
} |
||||
} |
||||
|
||||
return lbuffer.toString(); |
||||
} |
||||
|
||||
public synchronized static String replace(String str, String search_str, |
||||
String replace_str) { |
||||
String return_str; |
||||
boolean delete_comment = false; |
||||
|
||||
int pos = -1; |
||||
int offset = 0; |
||||
int len = str.length(); |
||||
int search_len = search_str.length(); |
||||
int comm_start = -1; |
||||
int comm_end = -1; |
||||
int prev_pos = -1; |
||||
int next_pos = -1; |
||||
int mode = -1; |
||||
|
||||
// mode: 0 = kein Kommentar,
|
||||
// 1 = Kommentar loeschen mit Ersetzung,
|
||||
// 2 = Loeschen von COMM_START bis COMM_END
|
||||
|
||||
try { |
||||
delete_comment = replace_str.equals(""); |
||||
|
||||
while (offset < len) { |
||||
mode = -1; |
||||
|
||||
if ((pos = str.indexOf(search_str, offset)) != -1) { |
||||
prev_str = str.substring(offset, pos); |
||||
comm_start = prev_str.lastIndexOf(COMM_START); |
||||
prev_pos = prev_str.lastIndexOf(PREV_POS); |
||||
comm_end = str.indexOf(COMM_END, pos + search_len); |
||||
next_pos = str.indexOf(NEXT_POS, pos + search_len); |
||||
|
||||
if (comm_start >= 0 && prev_pos >= 0) // kein Kommentar
|
||||
if (comm_start < prev_pos) |
||||
comm_start = -1; |
||||
if (comm_end >= 0 && next_pos >= 0) // kein Kommentar
|
||||
if (comm_end > next_pos) |
||||
comm_end = -1; |
||||
|
||||
if (comm_start != -1 && comm_end != -1 && comm_start <= pos |
||||
&& comm_end >= pos) { |
||||
if (delete_comment) // keine Ersetzung,
|
||||
mode = 2; // Loeschen von '/*' - '*/'
|
||||
else |
||||
mode = 1; |
||||
} else |
||||
mode = 0; |
||||
|
||||
switch (mode) { |
||||
case 0: { |
||||
buffer.append(prev_str); |
||||
buffer.append(replace_str); |
||||
offset = pos + search_len; |
||||
break; |
||||
} |
||||
case 1: { |
||||
buffer.append(prev_str.substring(0, comm_start)); |
||||
buffer.append(prev_str.substring(comm_start |
||||
+ COMM_START_LEN)); |
||||
buffer.append(replace_str); |
||||
buffer |
||||
.append(str.substring(pos + search_len, |
||||
comm_end)); |
||||
offset = comm_end + COMM_END_LEN; |
||||
break; |
||||
} |
||||
case 2: { |
||||
buffer.append(prev_str.substring(0, comm_start)); |
||||
offset = comm_end + COMM_END_LEN; |
||||
break; |
||||
} |
||||
default: |
||||
throw new Exception(errString); |
||||
} |
||||
} else { |
||||
buffer.append(str.substring(offset, len)); |
||||
offset = len; |
||||
} |
||||
} |
||||
|
||||
} catch (Exception e) { |
||||
buffer.append(errString); |
||||
buffer.append(search_str); |
||||
} |
||||
|
||||
return_str = buffer.toString(); |
||||
buffer.setLength(0); |
||||
|
||||
return return_str; |
||||
} |
||||
|
||||
public synchronized static String replaceString(String str, |
||||
String search_str, String replace_str) { |
||||
String zs = ""; |
||||
int offset = 0; |
||||
int pos = str.indexOf(search_str, offset); |
||||
while (pos > -1) { |
||||
zs += str.substring(offset, pos); |
||||
zs += replace_str; |
||||
offset = pos + search_str.length(); |
||||
pos = str.indexOf(search_str, offset); |
||||
} |
||||
zs += str.substring(offset, str.length()); |
||||
return zs; |
||||
} |
||||
|
||||
public synchronized static String escapeString(String str) { |
||||
String escapeString; |
||||
str = replaceString(str, PREV_POS, PREV_POS_MASK); |
||||
str = replaceString(str, NEXT_POS, NEXT_POS_MASK); |
||||
str = replaceString(str, SELECT_DELIMITER, SELECT_DELIMITER_MASK); |
||||
str = replaceString(str, STR_DELIMITER1, STR_DELIMITER1_MASK); |
||||
str = replaceString(str, STR_DELIMITER2, STR_DELIMITER2_MASK); |
||||
str = replaceString(str, COMMENT1_ANF, COMMENT1_ANF_MASK); |
||||
str = replaceString(str, COMMENT2_ANF, COMMENT2_ANF_MASK); |
||||
str = replaceString(str, COMMENT3_ANF, COMMENT3_ANF_MASK); |
||||
str = replaceString(str, COMMENT1_END, COMMENT1_END_MASK); |
||||
//str=replaceString(str,COMMENT2_END,COMMENT2_END_MASK);
|
||||
str = replaceString(str, COMMENT3_END, COMMENT3_END_MASK); |
||||
escapeString = str; |
||||
return escapeString; |
||||
} |
||||
|
||||
public synchronized static String unescapeString(String str) { |
||||
String unescapeString; |
||||
str = replaceString(str, PREV_POS_MASK, PREV_POS); |
||||
str = replaceString(str, NEXT_POS_MASK, NEXT_POS); |
||||
//str=replaceString(str,SELECT_DELIMITER_MASK, SELECT_DELIMITER);
|
||||
str = replaceString(str, STR_DELIMITER1_MASK, STR_DELIMITER1); |
||||
str = replaceString(str, STR_DELIMITER2_MASK, "\\'"); |
||||
//STR_DELIMITER2);
|
||||
str = replaceString(str, COMMENT1_ANF_MASK, COMMENT1_ANF); |
||||
str = replaceString(str, COMMENT2_ANF_MASK, COMMENT2_ANF); |
||||
str = replaceString(str, COMMENT3_ANF_MASK, COMMENT3_ANF); |
||||
str = replaceString(str, COMMENT1_END_MASK, COMMENT1_END); |
||||
str = replaceString(str, COMMENT3_END_MASK, COMMENT3_END); |
||||
unescapeString = str; |
||||
return unescapeString; |
||||
} |
||||
|
||||
public synchronized static String escapeSpecialChars(String str) { |
||||
String escapeSpecialChars; |
||||
str = replaceString(str, SELECT_DELIMITER, "\\" + SELECT_DELIMITER); |
||||
str = replaceString(str, STR_DELIMITER1, "\\" + STR_DELIMITER1); |
||||
str = replaceString(str, STR_DELIMITER2, "\\" + STR_DELIMITER2); |
||||
//str=replaceString(str,"\\","\\\\");
|
||||
//str=replaceString(str,"%","\\%");
|
||||
escapeSpecialChars = str; |
||||
return escapeSpecialChars; |
||||
} |
||||
|
||||
public synchronized static String getValueAsString(Object value) { |
||||
String field_type = ""; |
||||
String f_wert = ""; |
||||
String fehler = ""; |
||||
try { |
||||
if ((value instanceof java.sql.Date)) { |
||||
f_wert = "" |
||||
+ DateFormat.getDateInstance(DateFormat.MEDIUM, |
||||
Locale.GERMANY).format(value); |
||||
//System.out.println(f_wert);
|
||||
} else { |
||||
if (value instanceof java.sql.Timestamp) { |
||||
//System.out.println(value.toString());
|
||||
f_wert = "" |
||||
+ DateFormat.getDateTimeInstance(DateFormat.MEDIUM, |
||||
DateFormat.MEDIUM, Locale.GERMANY).format( |
||||
value); |
||||
} else { |
||||
if (value instanceof java.sql.Time) |
||||
f_wert = "" |
||||
+ DateFormat.getTimeInstance(DateFormat.MEDIUM, |
||||
Locale.GERMANY).format(value); |
||||
|
||||
else |
||||
//default:
|
||||
f_wert = value.toString(); |
||||
} |
||||
} |
||||
} catch (Exception e) { |
||||
fehler = e.toString(); |
||||
if (fehler.equals("java.lang.NullPointerException")) |
||||
f_wert = ""; |
||||
else |
||||
f_wert = "Feldtyp unbekannt:" + fehler; |
||||
} |
||||
return f_wert; |
||||
} |
||||
|
||||
/* |
||||
* public synchronized static String getRelationString (String feldart, |
||||
* String relation, String attribut) { String stmt=relation; if |
||||
* (stmt.startsWith (" < <SQL>>")) { stmt = stmt.substring (7); } |
||||
* |
||||
* if(attribut.trim().equals("")==false) { if (attribut.indexOf (',') == -1) |
||||
* attribut = "tid, " + attribut; stmt = "select " + attribut + " from " + |
||||
* relation + " order by 2"; } |
||||
* |
||||
* if (feldart.equals("4")) { //Hier fehlt noch userrechte und
|
||||
* lehre-Einschränkung stmt = "SELECT organigramm.parent, |
||||
* organigramm.key_apnr, organigramm.name FROM organigramm WHERE |
||||
* gueltig_seit <now() And gueltig_bis>now() ORDER BY organigramm.name;"; } |
||||
* if (feldart.equals("6") ) { //6-Institutionsdialog für Lehreinheiten stmt =
|
||||
* "SELECT organigramm.parent, organigramm.key_apnr, organigramm.name FROM |
||||
* organigramm WHERE gueltig_seit <now() And gueltig_bis>now() ORDER BY |
||||
* organigramm.name;"; } if (feldart.equals("7") ) { //7-Institutionsdialog
|
||||
* für Lehreinheiten ohne Einschr. Userrechte stmt = "SELECT |
||||
* organigramm.parent, organigramm.key_apnr, organigramm.name FROM |
||||
* organigramm WHERE gueltig_seit <now() And gueltig_bis>now() ORDER BY |
||||
* organigramm.name;"; } String RelationString=stmt; return RelationString; } |
||||
*/ |
||||
|
||||
public static void main(String args[]) { |
||||
System.out |
||||
.println(noappletout("11764^Projekt^4^0^0^100^300^1^char^4^0^1^<<SQL>> /* execute procedure sp_user_orga_child(<<UserID>>,mdy (1, 1,year(<<Organigramm-Stand>>)),<<Organigramm-Sicht>>,<<Institution>>, <<erlaubt>>); --notinxmlfrontend */ /* execute procedure sp_user_orga(<<UserID>>,mdy (1, 1,year<<Organigramm-Stand>>)),<<Organigramm-Sicht>>); --notinapplet */ select distinct fb, fb || " |
||||
+ " || ktobez from mbs_projekte_konto where 1=1 and inst_nr in (select ch110_institut from tmp_ch110_institut) /* and dr in (<<Deckungsring>>) */ /* and jahr = <<Haushaltsjahr>> */ /* and kap in (<<Kapitel>>) */ order by 2;^ ^^")); |
||||
System.exit(1); |
||||
String sql_str = null; |
||||
String search_str = null; |
||||
String replace_str = null; |
||||
Properties props = new Properties(); |
||||
|
||||
if (args.length != 2) { |
||||
System.err.println("Usage: <filename> <propertyfile>"); |
||||
System.exit(1); |
||||
} |
||||
|
||||
String filename = "/" + args[0]; |
||||
String propname = "/" + args[1]; |
||||
|
||||
try { |
||||
byte[] buf = new byte[bufSize]; |
||||
byte[] data = new byte[bufSize]; |
||||
int read_len = 0, data_len = 0; |
||||
|
||||
InputStream is = props.getClass().getResourceAsStream(filename); |
||||
if (is == null) { |
||||
System.err.println("Resource '" + filename + "' not found"); |
||||
System.exit(1); |
||||
} |
||||
|
||||
while (read_len != -1) { |
||||
read_len = is.read(buf, 0, buf.length); |
||||
if (read_len != -1) |
||||
data_len = read_len; |
||||
} |
||||
|
||||
is.close(); |
||||
|
||||
data = new byte[data_len]; |
||||
System.arraycopy(buf, 0, data, 0, data_len); |
||||
|
||||
sql_str = new String(data); |
||||
|
||||
is = props.getClass().getResourceAsStream(propname); |
||||
if (is == null) { |
||||
System.err.println("Resource '" + propname + "' not found"); |
||||
System.exit(1); |
||||
} |
||||
|
||||
props.load(is); |
||||
is.close(); |
||||
|
||||
Enumeration en = props.propertyNames(); |
||||
String key; |
||||
String value; |
||||
|
||||
System.err.println("sql ... "); |
||||
|
||||
while (en.hasMoreElements()) { |
||||
key = (String) en.nextElement(); |
||||
value = (String) props.getProperty(key); |
||||
key = "<<" + key + ">>"; |
||||
System.err.println("Key: " + key + " = " + value); |
||||
sql_str = SxUtils.replace(sql_str, key, value); |
||||
} |
||||
//MB 07/2010 macht Probleme bei Freemarker hashes
|
||||
// sql_str = SxUtils.deleteComment(sql_str, "{", "}");
|
||||
sql_str = SxUtils.deleteComment(sql_str, "--", "\n"); |
||||
sql_str = SxUtils.deleteComment(sql_str, "/*", "*/"); |
||||
} catch (FileNotFoundException e) { |
||||
System.err.println(e); |
||||
System.exit(1); |
||||
} catch (SecurityException e) { |
||||
System.err.println(e); |
||||
System.exit(1); |
||||
} catch (IOException e) { |
||||
System.err.println(e); |
||||
System.exit(1); |
||||
} |
||||
|
||||
System.err.println("done"); |
||||
} |
||||
|
||||
} |
@ -1,28 +0,0 @@
@@ -1,28 +0,0 @@
|
||||
package de.superx.applet; |
||||
import java.awt.Container; |
||||
import java.awt.Cursor; |
||||
|
||||
import javax.swing.JComponent; |
||||
/** |
||||
* Den Cursor einer Komponente auf WAIT bzw. DEFAULT setzen. |
||||
* |
||||
* @version 1.0 |
||||
* @author Rainer Behr |
||||
*/ |
||||
|
||||
public class SxWaitCursor |
||||
{ |
||||
|
||||
public static void set(JComponent comp, boolean isWait) |
||||
{ |
||||
Container toplevel = comp.getTopLevelAncestor (); |
||||
if (toplevel != null) |
||||
{ |
||||
if (isWait) |
||||
toplevel.setCursor (new Cursor (Cursor.WAIT_CURSOR)); |
||||
else |
||||
toplevel.setCursor (new Cursor (Cursor.DEFAULT_CURSOR)); |
||||
} |
||||
|
||||
} |
||||
} |
@ -1,103 +0,0 @@
@@ -1,103 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
import java.awt.Component; |
||||
import java.awt.event.MouseEvent; |
||||
import java.util.EventObject; |
||||
|
||||
import javax.swing.JTable; |
||||
import javax.swing.JTree; |
||||
import javax.swing.event.CellEditorListener; |
||||
import javax.swing.event.ChangeEvent; |
||||
import javax.swing.event.EventListenerList; |
||||
import javax.swing.table.TableCellEditor; |
||||
import javax.swing.tree.TreeCellEditor; |
||||
|
||||
public class AbstractCellEditor |
||||
implements TableCellEditor, TreeCellEditor { |
||||
protected EventListenerList listenerList = |
||||
new EventListenerList(); |
||||
protected Object value; |
||||
protected ChangeEvent changeEvent = null; |
||||
protected int clickCountToStart = 1; |
||||
|
||||
public Object getCellEditorValue() { |
||||
return value; |
||||
} |
||||
public void setCellEditorValue(Object value) { |
||||
this.value = value; |
||||
} |
||||
public void setClickCountToStart(int count) { |
||||
clickCountToStart = count; |
||||
} |
||||
public int getClickCountToStart() { |
||||
return clickCountToStart; |
||||
} |
||||
public boolean isCellEditable(EventObject anEvent) { |
||||
if (anEvent instanceof MouseEvent) { |
||||
if (((MouseEvent)anEvent).getClickCount() < |
||||
clickCountToStart) |
||||
return false; |
||||
} |
||||
return true; |
||||
} |
||||
public boolean shouldSelectCell(EventObject anEvent) { |
||||
if (this.isCellEditable(anEvent)) { |
||||
if (anEvent == null || |
||||
((MouseEvent)anEvent).getClickCount() >= |
||||
clickCountToStart) |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
public boolean stopCellEditing() { |
||||
fireEditingStopped(); |
||||
return true; |
||||
} |
||||
public void cancelCellEditing() { |
||||
fireEditingCanceled(); |
||||
} |
||||
public void addCellEditorListener(CellEditorListener l) { |
||||
listenerList.add(CellEditorListener.class, l); |
||||
} |
||||
public void removeCellEditorListener(CellEditorListener l) { |
||||
listenerList.remove(CellEditorListener.class, l); |
||||
} |
||||
public Component getTreeCellEditorComponent( |
||||
JTree tree, Object value, |
||||
boolean isSelected, |
||||
boolean expanded, |
||||
boolean leaf, int row) { |
||||
return null; |
||||
} |
||||
public Component getTableCellEditorComponent( |
||||
JTable table, Object value, |
||||
boolean isSelected, |
||||
int row, int column) { |
||||
return null; |
||||
} |
||||
protected void fireEditingStopped() { |
||||
Object[] listeners = listenerList.getListenerList(); |
||||
|
||||
for (int i = listeners.length-2; i>=0; i-=2) { |
||||
if (listeners[i]==CellEditorListener.class) { |
||||
if (changeEvent == null) |
||||
changeEvent = new ChangeEvent(this); |
||||
|
||||
((CellEditorListener) |
||||
listeners[i+1]).editingStopped(changeEvent); |
||||
} |
||||
} |
||||
} |
||||
protected void fireEditingCanceled() { |
||||
Object[] listeners = listenerList.getListenerList(); |
||||
|
||||
for (int i = listeners.length-2; i>=0; i-=2) { |
||||
if (listeners[i]==CellEditorListener.class) { |
||||
if (changeEvent == null) |
||||
changeEvent = new ChangeEvent(this); |
||||
|
||||
((CellEditorListener) |
||||
listeners[i+1]).editingCanceled(changeEvent); |
||||
} |
||||
} |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -1,47 +0,0 @@
@@ -1,47 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
|
||||
/** |
||||
* Insert the type's description here. Creation date: (13.09.01 18:26:13) |
||||
* |
||||
* @author: Administrator |
||||
*/ |
||||
|
||||
import java.awt.Frame; |
||||
import java.awt.event.MouseAdapter; |
||||
import java.awt.event.MouseEvent; |
||||
import java.util.Vector; |
||||
|
||||
import javax.swing.JScrollPane; |
||||
import javax.swing.tree.DefaultMutableTreeNode; |
||||
import javax.swing.tree.DefaultTreeModel; |
||||
|
||||
public class AdminOrgaMouseListener extends MouseAdapter { |
||||
AdminOrga derDialog; |
||||
MBDragTree derTree; |
||||
JScrollPane anzeige; |
||||
Vector merkungültig; |
||||
|
||||
AdminOrgaMouseListener(AdminOrga dlg, MBDragTree ltree, Vector lmerkungültig) { |
||||
super(); |
||||
derDialog = dlg; |
||||
derTree = ltree; |
||||
merkungültig = lmerkungültig; |
||||
// anzeige=lanzeige;
|
||||
} |
||||
|
||||
public void mousePressed(MouseEvent e) { |
||||
|
||||
if (e.getClickCount() == 2) { |
||||
|
||||
DefaultMutableTreeNode node = (DefaultMutableTreeNode) derTree |
||||
.getLastSelectedPathComponent(); |
||||
if (node.getUserObject() instanceof OrgaEintrag2) { |
||||
OrgaBearbDialog dlg2 = new OrgaBearbDialog( |
||||
(Frame)derDialog.getTopLevelAncestor(), node, merkungültig); |
||||
DefaultTreeModel dtm = (DefaultTreeModel) derTree.getModel(); |
||||
|
||||
dtm.nodeChanged(node); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,36 +0,0 @@
@@ -1,36 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
import java.awt.Component; |
||||
|
||||
import javax.swing.JTree; |
||||
import javax.swing.tree.DefaultMutableTreeNode; |
||||
import javax.swing.tree.DefaultTreeCellRenderer; |
||||
|
||||
class AdminOrgaPrintRenderer extends DefaultTreeCellRenderer |
||||
{ |
||||
|
||||
|
||||
public Component getTreeCellRendererComponent( |
||||
JTree tree, |
||||
Object value, |
||||
boolean sel, |
||||
boolean expanded, |
||||
boolean leaf, |
||||
int row, |
||||
boolean hasFocus) |
||||
{ |
||||
|
||||
super.getTreeCellRendererComponent( |
||||
tree, value, sel, |
||||
expanded, leaf, row, |
||||
hasFocus); |
||||
|
||||
DefaultMutableTreeNode theNode=(DefaultMutableTreeNode)value; |
||||
|
||||
if (theNode.getUserObject() instanceof OrgaEintrag2) |
||||
{ |
||||
OrgaEintrag2 x=(OrgaEintrag2)theNode.getUserObject(); |
||||
setText(x.getName()+" ("+x.getKeyApnr().toString()+")"); |
||||
} |
||||
return this; |
||||
} |
||||
} |
@ -1,27 +0,0 @@
@@ -1,27 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
import javax.swing.event.TreeSelectionEvent; |
||||
import javax.swing.event.TreeSelectionListener; |
||||
import javax.swing.tree.DefaultMutableTreeNode; |
||||
|
||||
class AdminOrgaSelList implements TreeSelectionListener { |
||||
|
||||
AdminOrga derDialog; |
||||
MBDragTree tree; |
||||
AdminOrgaSelList(AdminOrga dlg, MBDragTree ltree) |
||||
{ |
||||
super(); |
||||
derDialog=dlg; |
||||
tree=ltree; |
||||
} |
||||
public void valueChanged(TreeSelectionEvent event) { |
||||
DefaultMutableTreeNode node = |
||||
(DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); |
||||
|
||||
if (node != null) { |
||||
OrgaEintrag2 was = (OrgaEintrag2)node.getUserObject(); |
||||
derDialog.setGewaehlt(was); |
||||
|
||||
} |
||||
} |
||||
} |
||||
|
@ -1,14 +0,0 @@
@@ -1,14 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
/** |
||||
* Insert the type's description here. |
||||
* Creation date: (19.11.2001 15:34:23) |
||||
* @author: |
||||
*/ |
||||
class BenutzerVerwaltung { |
||||
/** |
||||
* BenutzerVerwaltung constructor comment. |
||||
*/ |
||||
public BenutzerVerwaltung() { |
||||
super(); |
||||
} |
||||
} |
@ -1,105 +0,0 @@
@@ -1,105 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
import java.io.File; |
||||
import java.io.FileInputStream; |
||||
import java.io.FileNotFoundException; |
||||
import java.io.IOException; |
||||
import java.security.MessageDigest; |
||||
|
||||
public class CheckPwd |
||||
{ |
||||
|
||||
public static void main(String args[]) |
||||
{ |
||||
MessageDigest sha = null; |
||||
File out_file = null; |
||||
FileInputStream fis = null; |
||||
|
||||
byte [] data = null; |
||||
String data_value = null; |
||||
StringBuffer str_value = new StringBuffer (); |
||||
String filename = null; |
||||
String password = null; |
||||
|
||||
if (args.length != 2) |
||||
{ |
||||
System.err.println("usage: CheckPwd <password> <file>"); |
||||
System.exit(1); |
||||
} |
||||
else |
||||
{ |
||||
password = args[0]; |
||||
filename = args[1]; |
||||
} |
||||
|
||||
try |
||||
{ |
||||
int read_len, file_len; |
||||
|
||||
File in_file = new File (filename + ".sha"); |
||||
file_len = (int) in_file.length (); |
||||
data = new byte [file_len]; |
||||
|
||||
fis = new FileInputStream (in_file); |
||||
|
||||
read_len = fis.read (data, 0, data.length); |
||||
|
||||
fis.close (); |
||||
|
||||
if (read_len != file_len) |
||||
throw new IOException ("ERROR: read_len != file_len"); |
||||
data_value = new String (data); |
||||
} |
||||
|
||||
catch (FileNotFoundException e) |
||||
{ |
||||
System.err.println (e); |
||||
System.exit (1); |
||||
} |
||||
|
||||
catch (SecurityException e) |
||||
{ |
||||
System.err.println (e); |
||||
System.exit (1); |
||||
} |
||||
|
||||
catch (IOException e) |
||||
{ |
||||
System.err.println (e); |
||||
System.exit (1); |
||||
} |
||||
|
||||
byte[] buf = password.getBytes(); |
||||
byte[] digest = null; |
||||
|
||||
try |
||||
{ |
||||
String value; |
||||
int n; |
||||
|
||||
sha = MessageDigest.getInstance("SHA-1"); |
||||
sha.update(buf); |
||||
digest = sha.digest(); |
||||
|
||||
for (int i = 0; i < digest.length; i++) |
||||
{ |
||||
n = (int) digest[i]; |
||||
if (n < 0) |
||||
n += 256; |
||||
value = Integer.toHexString(n); |
||||
if (n < 16) |
||||
value = "0" + value; |
||||
str_value.append (value); |
||||
} |
||||
if (data_value.equals (str_value.toString())) |
||||
System.err.println ("Same password as encrypted in file '" + |
||||
filename + ".sha'"); |
||||
else |
||||
throw new Exception ("Not the same password !"); |
||||
} |
||||
catch (Exception e) |
||||
{ |
||||
System.err.println(e); |
||||
System.exit (1); |
||||
} |
||||
} |
||||
} |
File diff suppressed because one or more lines are too long
@ -1,32 +0,0 @@
@@ -1,32 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
//MB Sep 2001
|
||||
import java.awt.Component; |
||||
|
||||
import javax.swing.JLabel; |
||||
import javax.swing.JList; |
||||
import javax.swing.ListCellRenderer; |
||||
|
||||
class ComboViewRenderer extends JLabel implements ListCellRenderer |
||||
{ |
||||
|
||||
|
||||
public Component getListCellRendererComponent( |
||||
JList list, |
||||
Object value, |
||||
int index, |
||||
boolean isSelected, |
||||
boolean cellHasFocus) { |
||||
//Object[] array = (Object[])value;
|
||||
|
||||
|
||||
//setText((String)array[1]);
|
||||
if (value!=null&&(value instanceof java.lang.String)) |
||||
{ |
||||
|
||||
setText(value.toString()); |
||||
} |
||||
return this; |
||||
} |
||||
} |
||||
|
||||
|
@ -1,203 +0,0 @@
@@ -1,203 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
|
||||
/** |
||||
* Insert the type's description here. Creation date: (08.01.2002 16:15:26) |
||||
* |
||||
* @author: |
||||
*/ |
||||
import java.sql.Connection; |
||||
import java.sql.ResultSet; |
||||
import java.sql.Statement; |
||||
import java.util.Enumeration; |
||||
import java.util.Vector; |
||||
|
||||
import javax.swing.JOptionPane; |
||||
|
||||
class DBAccess { |
||||
static Connection myConnection; |
||||
static Vector userliste, gruppenliste, maskenliste = null; |
||||
static SxSQL sxsql;; |
||||
|
||||
public static void init(String url, String logToKonsole, String user, |
||||
String passwd) throws Exception { |
||||
|
||||
sxsql = new SxSQL(url, logToKonsole, user, passwd); |
||||
|
||||
} |
||||
|
||||
public static String getString(ResultSet rs1, String feldname) { |
||||
Object test; |
||||
String rückgabe = null; |
||||
try { |
||||
|
||||
test = rs1.getObject(feldname); |
||||
if (test != null) |
||||
rückgabe = test.toString(); |
||||
else |
||||
rückgabe = new String(""); |
||||
} catch (Exception e) { |
||||
} |
||||
return rückgabe; |
||||
} |
||||
|
||||
public static String getStringOrNull(String was) { |
||||
String back; |
||||
if (was.equals("")) |
||||
back = null; |
||||
else |
||||
back = "'" + was.trim() + "'"; |
||||
return back; |
||||
} |
||||
|
||||
public static String getIntegerOrNull(String was) { |
||||
String back; |
||||
if (was.equals("")) |
||||
back = null; |
||||
else |
||||
back = was.trim(); |
||||
|
||||
return back; |
||||
} |
||||
|
||||
public static Integer getInteger(ResultSet rs1, String feldname) { |
||||
Object test; |
||||
Integer rückgabe = null; |
||||
try { |
||||
|
||||
test = rs1.getObject(feldname); |
||||
if ((test != null) && (test instanceof Integer)) |
||||
rückgabe = (Integer) test; |
||||
} catch (Exception e) { |
||||
} |
||||
return rückgabe; |
||||
} |
||||
|
||||
public static Vector getMaskenListe() { |
||||
Vector liste = new Vector(); |
||||
Vector row; |
||||
Integer id; |
||||
String name; |
||||
try { |
||||
|
||||
String query = "select tid, name, erlaeuterung, select_stmt, cleanup_stmt,xil_proplist from maskeninfo order by 2"; |
||||
liste = executeQuery(query); |
||||
} catch (Exception e) { |
||||
JOptionPane.showMessageDialog(null, |
||||
"Fehler beim Lesen aus der Datenbank: " + e.toString(), |
||||
"SuperX DB Admin", JOptionPane.WARNING_MESSAGE); |
||||
e.printStackTrace(); |
||||
} |
||||
return liste; |
||||
|
||||
} |
||||
|
||||
public static Vector getUserListe() { |
||||
if (userliste == null) |
||||
userListeNeuEinlesen(); |
||||
return userliste; |
||||
} |
||||
|
||||
static void userListeNeuEinlesen() { |
||||
try { |
||||
userliste = new Vector(); |
||||
Vector row; |
||||
Integer id; |
||||
String benutzer, email, name, max_versuch, akt_versuch, info; |
||||
Object wert; |
||||
|
||||
String query = "select tid, benutzer,name,email,info,max_versuch,akt_versuch,passwd_sha from userinfo order by benutzer"; |
||||
userliste = executeQuery(query); |
||||
for (Enumeration en = userliste.elements(); en.hasMoreElements();) { |
||||
row = (Vector) en.nextElement(); |
||||
for (Enumeration en2 = row.elements(); en2.hasMoreElements();) { |
||||
wert = en2.nextElement(); |
||||
if (wert == null) |
||||
wert = new String(""); |
||||
} |
||||
} |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
JOptionPane.showMessageDialog(null, "Fehler bei Datenbankzugriff: " |
||||
+ e.toString(), "DBAccess", 1); |
||||
} |
||||
|
||||
} |
||||
|
||||
public static Vector NutzerListeEinlesen_Alt() { |
||||
Vector liste = new Vector(); |
||||
Vector row; |
||||
Integer id; |
||||
String benutzer; |
||||
try { |
||||
|
||||
String query = "select tid, benutzer from userinfo order by benutzer"; |
||||
Statement statement = myConnection.createStatement(); |
||||
ResultSet rs1 = statement.executeQuery(query); |
||||
while (rs1.next()) { |
||||
id = (Integer) rs1.getObject("tid"); |
||||
benutzer = rs1.getObject("benutzer").toString(); |
||||
row = new Vector(); |
||||
row.add(id); |
||||
row.add(benutzer.trim()); |
||||
liste.add(row); |
||||
|
||||
} |
||||
rs1.close(); |
||||
statement.close(); |
||||
|
||||
} catch (Exception e) { |
||||
JOptionPane.showMessageDialog(null, |
||||
"Fehler beim Lesen aus der Datenbank: " + e.toString(), |
||||
"SuperX DB Admin", JOptionPane.WARNING_MESSAGE); |
||||
e.printStackTrace(); |
||||
} |
||||
return liste; |
||||
} |
||||
|
||||
public static Vector GruppenListeEinlesen() { |
||||
Vector liste = new Vector(); |
||||
try { |
||||
String query = "select tid, name from groupinfo order by 2"; |
||||
liste = executeQuery(query); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
JOptionPane.showMessageDialog(null, "Fehler bei Datenbankzugriff: " |
||||
+ e.toString(), "DBAccess", 1); |
||||
} |
||||
|
||||
return liste; |
||||
} |
||||
|
||||
public static Vector executeQuery(String query) throws Exception { |
||||
//ein Vector im Vector wird geliefert
|
||||
Vector erg = null; |
||||
|
||||
sxsql.executeQuery(query); |
||||
|
||||
erg = sxsql.getResultVector(); |
||||
return erg; |
||||
} |
||||
|
||||
public static Object executeQuerySingleValue(String query) throws Exception { |
||||
Object rück = null; |
||||
|
||||
Vector erg = executeQuery(query); |
||||
//ein Vector im Vector wird geliefert
|
||||
Vector help = (Vector) erg.get(0); |
||||
rück = help.get(0); |
||||
|
||||
return rück; |
||||
} |
||||
|
||||
public static void executeUpdate(String upd) throws Exception { |
||||
|
||||
sxsql.execute(upd); |
||||
|
||||
} |
||||
|
||||
public static void executeUpdateAll(String upd) throws Exception { |
||||
|
||||
sxsql.executeAll(upd); |
||||
|
||||
} |
||||
} |
@ -1,995 +0,0 @@
@@ -1,995 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
// Gruppenrechte für Institutionen
|
||||
//bisher nicht vorgesehen
|
||||
import java.awt.BorderLayout; |
||||
import java.awt.Container; |
||||
import java.awt.Cursor; |
||||
import java.awt.Font; |
||||
import java.awt.Frame; |
||||
import java.awt.GridLayout; |
||||
import java.awt.dnd.DragGestureListener; |
||||
import java.awt.dnd.DragSource; |
||||
import java.awt.dnd.DragSourceListener; |
||||
import java.awt.dnd.DropTarget; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.sql.Connection; |
||||
import java.sql.ResultSet; |
||||
import java.sql.ResultSetMetaData; |
||||
import java.sql.Statement; |
||||
import java.text.DateFormat; |
||||
import java.text.ParseException; |
||||
import java.util.Calendar; |
||||
import java.util.Enumeration; |
||||
import java.util.GregorianCalendar; |
||||
import java.util.TimeZone; |
||||
import java.util.Vector; |
||||
|
||||
import javax.swing.CellEditor; |
||||
import javax.swing.JButton; |
||||
import javax.swing.JLabel; |
||||
import javax.swing.JOptionPane; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JScrollPane; |
||||
import javax.swing.JTextField; |
||||
import javax.swing.JTree; |
||||
import javax.swing.event.CellEditorListener; |
||||
import javax.swing.event.ChangeEvent; |
||||
import javax.swing.tree.DefaultMutableTreeNode; |
||||
import javax.swing.tree.DefaultTreeModel; |
||||
import javax.swing.tree.TreePath; |
||||
import javax.swing.tree.TreeSelectionModel; |
||||
|
||||
class GroupInst extends JPanel implements CellEditorListener, ActionListener { |
||||
boolean result; |
||||
boolean etwasGeändert = false; |
||||
Frame dummyframe; |
||||
OrgaEintrag2 gewaehlt = null; |
||||
OrgaEintrag2 einEintrag; |
||||
Vector orga; |
||||
Vector merkungültig; |
||||
int AnzahlEinträge; |
||||
JLabel Standlabel; |
||||
GregorianCalendar cal = new GregorianCalendar(); |
||||
String Stand; |
||||
JTextField suchtext; |
||||
Container cp; |
||||
JTree tree=null; |
||||
DefaultTreeModel treeModel; |
||||
JScrollPane treeScroll; |
||||
DefaultMutableTreeNode root; |
||||
DragSource dragSource; |
||||
DropTarget dropTarget; |
||||
private DragGestureListener dgListener; |
||||
private DragSourceListener dsListener; |
||||
Connection myConnection = null; |
||||
int userid=-999; |
||||
SuperXDBAdmin linkToMain; |
||||
|
||||
public GroupInst(SuperXDBAdmin llinkToMain,Connection conn) { |
||||
super(); |
||||
linkToMain=llinkToMain; |
||||
myConnection=conn; |
||||
this.setLayout(new BorderLayout()); |
||||
//top panel für Stand
|
||||
|
||||
Stand = |
||||
cal.get(Calendar.DATE) |
||||
+ "." |
||||
+ (cal.get(Calendar.MONTH) + 1) |
||||
+ "." |
||||
+ cal.get(Calendar.YEAR); |
||||
//aktuelles Datum ist default
|
||||
|
||||
JPanel top = new JPanel(); |
||||
|
||||
MBComboBox mbt = new MBComboBox(DBAccess.GruppenListeEinlesen()); |
||||
//mbt.AddActionListener(this);
|
||||
|
||||
top.add(mbt); |
||||
Standlabel = new JLabel("Stand: " + Stand); |
||||
Standlabel.setFont(new Font("Arial", Font.PLAIN, 10)); |
||||
JButton bStand = new JButton("anderer Stand"); |
||||
bStand.setFont(new Font("Arial", Font.PLAIN, 10)); |
||||
bStand.setDefaultCapable(false); |
||||
bStand.addActionListener(this); |
||||
top.add(Standlabel); |
||||
top.add(bStand); |
||||
|
||||
this.add(top, "North"); |
||||
|
||||
//JTree erzeugen
|
||||
JPanel center = new JPanel();//new GridLayout(1, 2));
|
||||
|
||||
tree = tree_erzeugen(); |
||||
treeScroll = new JScrollPane(tree); |
||||
center.add(treeScroll); |
||||
// cp.add(treeScroll, "Center");
|
||||
this.add(center, "Center"); |
||||
|
||||
//Suchen Feld + Buttons
|
||||
JPanel down = new JPanel(); |
||||
down.setLayout(new GridLayout(3, 1)); |
||||
|
||||
JPanel psuchen = new JPanel(); |
||||
suchtext = new JTextField(10); |
||||
suchtext.setFont(new Font("Arial", Font.PLAIN, 10)); |
||||
psuchen.add(suchtext); |
||||
|
||||
JButton suchen = new JButton("Suchen"); |
||||
suchen.setFont(new Font("Arial", Font.PLAIN, 10)); |
||||
suchen.addActionListener(this); |
||||
|
||||
psuchen.add(suchen); |
||||
|
||||
down.add(psuchen); |
||||
|
||||
JPanel pspeichern=new JPanel(); |
||||
JButton speichern=new JButton("speichern"); |
||||
speichern.addActionListener(this); |
||||
pspeichern.add(speichern); |
||||
down.add(pspeichern); |
||||
|
||||
|
||||
|
||||
this.add("South", down); |
||||
//pack();
|
||||
|
||||
if (linkToMain.getLastGroup()!=-999) mbt.setSelection(linkToMain.getLastGroup()); |
||||
} |
||||
public void actionPerformed(ActionEvent event) { |
||||
if (event.getActionCommand().equals("speichern")) |
||||
GruppenRechteSpeichern(); |
||||
|
||||
if (event.getActionCommand().equals("Suchen")) |
||||
suchen(); |
||||
|
||||
Object src = event.getSource(); |
||||
if (src instanceof MBComboBox) { |
||||
MBComboBox localbox = (MBComboBox) event.getSource(); |
||||
DefaultMutableTreeNode r=(DefaultMutableTreeNode) tree.getModel().getRoot(); |
||||
userid=localbox.getSelectedID(); |
||||
GruppenRechteLesen(r,userid); |
||||
tree.repaint(); |
||||
} |
||||
|
||||
} |
||||
|
||||
public void GruppeAuswählen() { |
||||
String[][] Nutzer = new String[1000][2]; |
||||
try { |
||||
|
||||
String query = "select tid, benutzer from userinfo"; |
||||
|
||||
Statement statement = myConnection.createStatement(); |
||||
ResultSet rs1 = statement.executeQuery(query); |
||||
int i = 0; |
||||
while (rs1.next()) { |
||||
Nutzer[i][0] = rs1.getObject("tid").toString(); |
||||
Nutzer[i][1] = rs1.getObject("benutzer").toString(); |
||||
i++; |
||||
} |
||||
|
||||
rs1.close(); |
||||
statement.close(); |
||||
|
||||
} catch (Exception e) { |
||||
JOptionPane.showMessageDialog( |
||||
null, |
||||
"Fehler beim Lesen aus der Datenbank: " + e.toString(), |
||||
"SuperX DB Admin", |
||||
JOptionPane.WARNING_MESSAGE); |
||||
e.printStackTrace(); |
||||
System.exit(-1); |
||||
} |
||||
|
||||
String selectedValue = |
||||
(String) JOptionPane.showInputDialog( |
||||
null, |
||||
"Mehrere Treffer!\nBitte auswählen...", |
||||
"SuperX", |
||||
JOptionPane.INFORMATION_MESSAGE, |
||||
null, |
||||
Nutzer, |
||||
Nutzer[0]); |
||||
} |
||||
|
||||
public void andererStand() { |
||||
int result = |
||||
JOptionPane.showConfirmDialog( |
||||
null, |
||||
"Bei Auswahl eines anderen Stands gehen eventuell gemachte Änderungen verloren!\n Erst speichern?", |
||||
"SuperX DB Admin", |
||||
JOptionPane.YES_NO_OPTION); |
||||
if (result == JOptionPane.OK_OPTION) { |
||||
GruppenRechteSpeichern(); |
||||
} |
||||
String Standneu = |
||||
JOptionPane.showInputDialog( |
||||
this, |
||||
"Neues Datum eingeben:", |
||||
"SuperX", |
||||
JOptionPane.QUESTION_MESSAGE); |
||||
if (Standneu != null && DatumOK(Standneu)) //and FormOk
|
||||
|
||||
{ |
||||
cp.setCursor(new Cursor(Cursor.WAIT_CURSOR)); |
||||
|
||||
Stand = Standneu; |
||||
Standlabel.setText("Stand: " + Stand); |
||||
tree = this.tree_erzeugen(); |
||||
|
||||
cp.remove(treeScroll); |
||||
treeScroll = new JScrollPane(tree); |
||||
cp.add(treeScroll); |
||||
cp.validate(); |
||||
cp.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); |
||||
} |
||||
} |
||||
private void children_freischalten(DefaultMutableTreeNode node) { |
||||
DefaultMutableTreeNode aNode; |
||||
OrgaEintrag2 x; |
||||
for (Enumeration en = node.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
x = (OrgaEintrag2) aNode.getUserObject(); |
||||
x.setErlaubt(true); |
||||
} |
||||
} |
||||
public void childrenSperren(DefaultMutableTreeNode node) { |
||||
DefaultMutableTreeNode aNode; |
||||
OrgaEintrag2 x; |
||||
for (Enumeration en = node.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
x = (OrgaEintrag2) aNode.getUserObject(); |
||||
x.setErlaubt(false); |
||||
} |
||||
} |
||||
|
||||
public String dateToString(java.sql.Date inp) { |
||||
java.text.DateFormat df; |
||||
df = java.text.DateFormat.getDateInstance(java.text.DateFormat.MEDIUM); |
||||
// r.b. default Jahr 4-stellig
|
||||
df.setTimeZone(TimeZone.getDefault()); |
||||
df.setLenient(false); |
||||
|
||||
String help = df.format((java.util.Date) inp); |
||||
return help; |
||||
} |
||||
public boolean DatumOK(String dat) { |
||||
DateFormat df; |
||||
df = DateFormat.getDateInstance(DateFormat.MEDIUM); |
||||
// r.b. default Jahr 4-stellig
|
||||
df.setTimeZone(TimeZone.getDefault()); |
||||
df.setLenient(false); |
||||
String geprueft = null; |
||||
try { |
||||
if (dat.endsWith("00")) { |
||||
switch (dat.charAt(dat.length() - 3)) { |
||||
case '-' : |
||||
case '.' : |
||||
case '/' : |
||||
dat = dat.substring(0, dat.length() - 2) + "2000"; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
java.util.Date date = df.parse(dat); |
||||
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); |
||||
|
||||
//wenn Format nicht OK bleibt geprueft null
|
||||
geprueft = df.format((java.util.Date) date); |
||||
} catch (ParseException e_parse) { |
||||
// System.err.println ("SxDate: ERROR: parse: Date != " + value);
|
||||
} catch (IllegalArgumentException e_arg) { |
||||
// System.err.println ("SxDate: ERROR: arg: Date != " + value);
|
||||
} |
||||
|
||||
return geprueft == null ? false : true; |
||||
} |
||||
public void druckanzeige() { |
||||
AdminOrgaPrintRenderer aopr = new AdminOrgaPrintRenderer(); |
||||
|
||||
tree.setCellRenderer(aopr); |
||||
DefaultMutableTreeNode aNode; |
||||
DefaultMutableTreeNode theRoot = |
||||
(DefaultMutableTreeNode) tree.getModel().getRoot(); |
||||
TreePath tp; |
||||
for (Enumeration en = theRoot.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
tp = new TreePath(aNode.getPath()); |
||||
if (tree.isCollapsed(tp)) |
||||
tree.expandPath(tp); |
||||
|
||||
} |
||||
//PrintUtilities.printComponent(treeScroll);
|
||||
|
||||
int level; |
||||
OrgaEintrag2 x; |
||||
String keyApnr; |
||||
for (Enumeration en = theRoot.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
if (aNode.getUserObject() instanceof OrgaEintrag2) { |
||||
x = (OrgaEintrag2) aNode.getUserObject(); |
||||
level = aNode.getLevel(); |
||||
for (int i = 1; i <= level; i++) |
||||
System.out.print(" "); |
||||
keyApnr = x.getKeyApnr() == null ? "" : x.getKeyApnr().toString(); |
||||
System.out.println(x.getName() + " (" + keyApnr + ")"); |
||||
|
||||
} |
||||
|
||||
} |
||||
} |
||||
public void editingCanceled(ChangeEvent e) { |
||||
CellEditor cellEditor = (CellEditor) e.getSource(); |
||||
/* SelectableFile sf = |
||||
(SelectableFile) |
||||
cellEditor.getCellEditorValue(); |
||||
|
||||
System.out.println("editing canceled: " + |
||||
sf.toString());*/ |
||||
} |
||||
public void editingStopped(ChangeEvent e) { |
||||
// CellEditor cellEditor = (CellEditor)e.getSource();
|
||||
InstEditor cellEditor = (InstEditor) e.getSource(); |
||||
DefaultMutableTreeNode node = |
||||
(DefaultMutableTreeNode) cellEditor.getLastEditedNode(); |
||||
|
||||
OrgaEintrag2 x = (OrgaEintrag2) node.getUserObject(); |
||||
|
||||
if (x.getErlaubt().intValue() == 1) { |
||||
children_freischalten(node); |
||||
prüfeObParentFreischalten(node); |
||||
} else |
||||
{ |
||||
parents_sperren(node); |
||||
childrenSperren(node); |
||||
} |
||||
|
||||
} |
||||
public static java.sql.Date getDate(String value) { |
||||
|
||||
DateFormat df; |
||||
java.util.Date date; |
||||
java.sql.Date sql_date; |
||||
Calendar calendar; |
||||
|
||||
df = DateFormat.getDateInstance(DateFormat.MEDIUM); |
||||
// r.b. default Jahr 4-stellig
|
||||
df.setTimeZone(TimeZone.getDefault()); |
||||
df.setLenient(false); |
||||
|
||||
try { |
||||
if (value.endsWith("00")) { |
||||
switch (value.charAt(value.length() - 3)) { |
||||
case '-' : |
||||
case '.' : |
||||
case '/' : |
||||
value = value.substring(0, value.length() - 2) + "2000"; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
date = df.parse(value); |
||||
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); |
||||
|
||||
sql_date = new java.sql.Date(calendar.getTime().getTime()); |
||||
return sql_date; |
||||
} catch (ParseException e_parse) { |
||||
// System.err.println ("SxDate: ERROR: parse: Date != " + value);
|
||||
} catch (IllegalArgumentException e_arg) { |
||||
// System.err.println ("SxDate: ERROR: arg: Date != " + value);
|
||||
} |
||||
|
||||
return null; |
||||
} |
||||
public Frame getFrame() { |
||||
return dummyframe; |
||||
} |
||||
public OrgaEintrag2 getGewaehlt() { |
||||
return gewaehlt; |
||||
} |
||||
private void insertnodes(String theParent, DefaultMutableTreeNode aktNode) { |
||||
//rekursive Methode, die Institutionen in den Baum einträgt
|
||||
Vector result = new Vector(); |
||||
result = mySelect(theParent); |
||||
String eintrag_key; |
||||
for (Enumeration el = result.elements(); el.hasMoreElements();) { |
||||
einEintrag = (OrgaEintrag2) el.nextElement(); |
||||
DefaultMutableTreeNode neuNode = new DefaultMutableTreeNode(einEintrag); |
||||
aktNode.add(neuNode); |
||||
|
||||
eintrag_key = einEintrag.getKeyApnr(); |
||||
//nervig null-Werte abfangen
|
||||
if (eintrag_key != null & theParent == null) |
||||
insertnodes(einEintrag.getKeyApnr(), neuNode); |
||||
if (eintrag_key == null & theParent == null) |
||||
System.out.println( |
||||
"Achtung! Element hat fälschlicherweise sich selbst als parent:" |
||||
+ einEintrag.getName()); |
||||
|
||||
if (eintrag_key != null && theParent != null) |
||||
if (!theParent.equals(eintrag_key)) |
||||
insertnodes(einEintrag.getKeyApnr(), neuNode); |
||||
else |
||||
System.out.println( |
||||
"Achtung! Element hat fälschlicherweise sich selbst als parent:" |
||||
+ einEintrag.getName() |
||||
+ " key_apnr:" |
||||
+ einEintrag.getKeyApnr()); |
||||
} |
||||
|
||||
} |
||||
public int KinderZählen(DefaultMutableTreeNode node) { |
||||
int zähler = 0; |
||||
DefaultMutableTreeNode aNode; |
||||
for (Enumeration en = node.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
zähler++; |
||||
} |
||||
return zähler - 1; |
||||
|
||||
} |
||||
public void log(String was) { |
||||
System.out.println(was); |
||||
//ggfs. in Datei schreiben
|
||||
} |
||||
private Vector mySelect(String pruefparent) { |
||||
//liefert alle Institute mit Parent =pruefparent zurück
|
||||
Vector result = new Vector(); |
||||
String eintrag_parent; |
||||
for (Enumeration el = orga.elements(); el.hasMoreElements();) { |
||||
einEintrag = (OrgaEintrag2) el.nextElement(); |
||||
eintrag_parent = einEintrag.getParent(); |
||||
if (eintrag_parent == null && pruefparent == null) |
||||
result.addElement(einEintrag); |
||||
if (eintrag_parent != null && pruefparent != null) |
||||
if (eintrag_parent.equals(pruefparent)) |
||||
result.addElement(einEintrag); |
||||
|
||||
} |
||||
return result; |
||||
} |
||||
|
||||
|
||||
|
||||
private void GruppenRechteLesen(DefaultMutableTreeNode start, int userID) { |
||||
Integer institut; |
||||
DefaultMutableTreeNode aNode, childNode; |
||||
OrgaEintrag2 x; |
||||
|
||||
//erstmal alles auf erlaubt=false setzen
|
||||
for (Enumeration en = start.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
if (aNode.getUserObject() instanceof OrgaEintrag2) { |
||||
x = (OrgaEintrag2) aNode.getUserObject(); |
||||
x.setErlaubt(false); |
||||
} |
||||
} |
||||
|
||||
try { |
||||
|
||||
//Datumsabfrage
|
||||
//datum String in sql.Date umformen
|
||||
java.sql.Date date = new java.sql.Date(1); |
||||
SxDate mydate = new SxDate(); |
||||
date = mydate.getDate(Stand); |
||||
|
||||
String query = |
||||
"select ch110_institut, hierarchie,lehre,gueltig_seit,gueltig_bis from user_institution where userid=" |
||||
+ userID |
||||
+ " and gueltig_seit<=date('" |
||||
+ date |
||||
+ "') and gueltig_bis>=date('" |
||||
+ date |
||||
+ "')"; |
||||
|
||||
Statement statement = myConnection.createStatement(); |
||||
ResultSet rs1 = statement.executeQuery(query); |
||||
Integer hierarchie, lehre; |
||||
java.sql.Date gueltig_seit, gueltig_bis; |
||||
Object input; |
||||
while (rs1.next()) { |
||||
|
||||
institut = (Integer) rs1.getObject("ch110_institut"); |
||||
for (Enumeration en = start.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
if (aNode.getUserObject() instanceof OrgaEintrag2) { |
||||
x = (OrgaEintrag2) aNode.getUserObject(); |
||||
//standardmäßig erstmal erlaubt=false setzen
|
||||
|
||||
if (x.getKeyApnr().equals(institut)) { |
||||
input = rs1.getObject("hierarchie"); |
||||
x.setHierarchie(input == null ? null : new Integer(input.toString())); |
||||
input = rs1.getObject("lehre"); |
||||
x.setLehre(input == null ? null : new Integer(input.toString())); |
||||
//Gueltigkeitswerte aus user_inst in orgaEintrag übertragen, damit bei speichern erhalten bleiben
|
||||
gueltig_seit = (java.sql.Date) rs1.getObject("gueltig_seit"); |
||||
gueltig_bis = (java.sql.Date) rs1.getObject("gueltig_bis"); |
||||
x.setGueltigSeit(gueltig_seit); |
||||
x.setGueltigBis(gueltig_bis); |
||||
x.setErlaubt(true); |
||||
//Kinder auch
|
||||
for (Enumeration en2 = aNode.depthFirstEnumeration(); en2.hasMoreElements();) { |
||||
childNode = (DefaultMutableTreeNode) en2.nextElement(); |
||||
x = (OrgaEintrag2) childNode.getUserObject(); |
||||
x.setErlaubt(true); |
||||
} |
||||
|
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
rs1.close(); |
||||
statement.close(); |
||||
linkToMain.setStatus("Gruppe geändert"); |
||||
//linkToMain.setLastGroup(groupid);
|
||||
} catch (Exception e) { |
||||
JOptionPane.showMessageDialog( |
||||
null, |
||||
"Fehler beim Lesen aus der Datenbank: " + e.toString(), |
||||
"SuperX DB Admin", |
||||
JOptionPane.WARNING_MESSAGE); |
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
} |
||||
|
||||
public void GruppenRechteSpeichern() { |
||||
Enumeration en; |
||||
int i = 0; |
||||
String ins = null; |
||||
String wo = null; |
||||
|
||||
//datum String in sql.Date umformen
|
||||
java.sql.Date date = new java.sql.Date(1); |
||||
SxDate mydate = new SxDate(); |
||||
date = mydate.getDate(Stand); |
||||
|
||||
// MBProgressBar progress=new MBProgressBar(10);
|
||||
try { |
||||
Statement statement = myConnection.createStatement(); |
||||
DefaultMutableTreeNode lroot = |
||||
(DefaultMutableTreeNode) tree.getModel().getRoot(); |
||||
DefaultMutableTreeNode aNode; |
||||
OrgaEintrag2 x; |
||||
String upd = |
||||
"delete from user_institution where userid="+userid |
||||
+ " and gueltig_seit<=date('" |
||||
+ date |
||||
+ "') and gueltig_bis>=date('" |
||||
+ date |
||||
+ "')"; |
||||
statement.executeUpdate(upd); |
||||
|
||||
TreePath tp; |
||||
DefaultMutableTreeNode vorher; |
||||
aNode = null; |
||||
for (en = lroot.breadthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
x = (OrgaEintrag2) aNode.getUserObject(); |
||||
if (x instanceof OrgaEintrag2) { |
||||
|
||||
if (x.isErlaubt()) { |
||||
ins = |
||||
new String( |
||||
"insert into user_institution (userid, name,ch110_institut,hierarchie,gueltig_seit,gueltig_bis,lehre) " |
||||
+ "values ("+ |
||||
userid+",'" |
||||
+ x.getName() |
||||
+ "'," |
||||
+ x.getKeyApnr() |
||||
+ "," |
||||
+ x.getHierarchie() |
||||
+ ",date('" |
||||
+ SxUtils.GetValueAsString(x.getGueltigSeit()) |
||||
+ "'),date('" |
||||
+ SxUtils.GetValueAsString(x.getGueltigBis()) |
||||
+ "')," |
||||
+ x.getLehre() |
||||
+ ")"); |
||||
statement.executeUpdate(ins); |
||||
i++; |
||||
//children sperren, da nur Eintrag von hierarchiehöchstem Element nötig
|
||||
childrenSperren(aNode); |
||||
|
||||
} |
||||
//progress.inc();
|
||||
} |
||||
} |
||||
|
||||
linkToMain.setStatus(i + " Einträge in user_institution geschrieben"); |
||||
etwasGeändert = false; |
||||
//da Kinder der Verarbeitung wegen gesperrt wurden, muss neu eingelesen werden
|
||||
GruppenRechteLesen(root,userid); |
||||
} catch (Exception e) { |
||||
JOptionPane.showMessageDialog( |
||||
null, |
||||
"Fehler beim Schreiben in die Datenbank:\n " + e.toString(), |
||||
"SuperX DB Admin", |
||||
JOptionPane.WARNING_MESSAGE); |
||||
System.out.println(wo + ": " + ins); |
||||
e.printStackTrace(); |
||||
System.exit(-1); |
||||
} |
||||
//progress.hide();
|
||||
//progress.dispose();
|
||||
|
||||
|
||||
|
||||
|
||||
} |
||||
|
||||
private void parents_sperren(DefaultMutableTreeNode node) { |
||||
DefaultMutableTreeNode aNode; |
||||
OrgaEintrag2 x; |
||||
boolean go = true; |
||||
while (go) { |
||||
aNode = (DefaultMutableTreeNode) node.getParent(); |
||||
if (aNode == null || !(aNode.getUserObject() instanceof OrgaEintrag2)) |
||||
return; //root
|
||||
|
||||
x = (OrgaEintrag2) aNode.getUserObject(); |
||||
if (x.getErlaubt().intValue() == 1) |
||||
//wenn parent erlaubt ist, den auf false setzen
|
||||
// und in Schleife weitermachen
|
||||
//denn sobald nur eines der Kinderelemente eines parents nicht erlaubt,
|
||||
//ist er selbst nicht mehr erlaubt
|
||||
x.setErlaubt(false); |
||||
// ansonsten war parent schon auf false und man braucht nicht weitermachen
|
||||
else |
||||
go = false; |
||||
node = aNode; |
||||
} |
||||
|
||||
} |
||||
public void prüfeDifferenzen(DefaultMutableTreeNode root) { |
||||
Vector problemfälle; |
||||
problemfälle = (Vector) orga.clone(); |
||||
DefaultMutableTreeNode aNode; |
||||
OrgaEintrag2 x; |
||||
String name; |
||||
Integer key_apnr; |
||||
java.sql.Date gueltig_seit, gueltig_bis; |
||||
|
||||
//Problemfälle enthält zu Anfang alle eingelesenen, gültigen Einträge
|
||||
//diejenigen, die in Baum vorkommen werden ausgelöscht
|
||||
for (Enumeration en = root.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
x = (OrgaEintrag2) aNode.getUserObject(); |
||||
problemfälle.remove(x); |
||||
} |
||||
|
||||
if (problemfälle.size() > 0) { |
||||
JOptionPane.showMessageDialog( |
||||
null, |
||||
"Achtung!\nEs gibt " |
||||
+ problemfälle.size() |
||||
+ " gültige Einträge, die nicht in die Baumstruktur passten!\n(Bitte Organigramm korrigieren)", |
||||
"SuperX Admin", |
||||
JOptionPane.WARNING_MESSAGE); |
||||
log( |
||||
problemfälle.size() |
||||
+ " gültige Einträge, die nicht in die Baumstruktur passten:"); |
||||
|
||||
/* DefaultMutableTreeNode fehlernode = new DefaultMutableTreeNode("Fehler"); |
||||
|
||||
for (Enumeration el = problemfälle.elements(); el.hasMoreElements();) { |
||||
x = (orgaEintrag2) el.nextElement(); |
||||
fehlernode.add(new DefaultMutableTreeNode(x)); |
||||
log(x.getKeyApnr() + " - " + x.getName() + "parent (" + x.getParent() + ")"); |
||||
|
||||
} |
||||
root.add(fehlernode); |
||||
*/ |
||||
} |
||||
} |
||||
private void prüfeObParentFreischalten(DefaultMutableTreeNode node) { |
||||
DefaultMutableTreeNode aNode; |
||||
DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent(); |
||||
OrgaEintrag2 x; |
||||
boolean alleKinderErlaubt = true; |
||||
for (Enumeration en = parent.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
if (!aNode.equals(parent)) { |
||||
x = (OrgaEintrag2) aNode.getUserObject(); |
||||
if (x.getErlaubt().intValue() == 0) |
||||
alleKinderErlaubt = false; |
||||
} |
||||
} |
||||
if (alleKinderErlaubt) { |
||||
x = (OrgaEintrag2) parent.getUserObject(); |
||||
x.setErlaubt(true); |
||||
} |
||||
if (!parent.isRoot()) |
||||
prüfeObParentFreischalten(parent); |
||||
} |
||||
|
||||
private void suchen() { |
||||
String such = suchtext.getText().toLowerCase(); |
||||
String teststring; |
||||
TreePath tp; |
||||
boolean gefunden = false; |
||||
DefaultMutableTreeNode test, ausgesucht; |
||||
ausgesucht = null; |
||||
Vector treffer = new Vector(); |
||||
Vector treffernodes = new Vector(); |
||||
|
||||
if (such.length() < 1) { |
||||
JOptionPane.showMessageDialog(null, "Bitte Suchbegriff eingeben!", "SuperX", 1); |
||||
return; |
||||
} |
||||
such = such.toLowerCase(); |
||||
//JOptionPane.showMessageDialog(null, "neu","SuperX",1);
|
||||
//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) JOptionPane.showInputDialog( |
||||
null, |
||||
"Mehrere Treffer!\nBitte 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.addSelectionPath(tp); |
||||
//tree.makeVisible(tp);
|
||||
|
||||
// tree.validate();
|
||||
// tree.repaint();
|
||||
} else |
||||
JOptionPane.showMessageDialog(null, "Keine Treffer", "SuperX", 1); |
||||
} |
||||
public JTree tree_erzeugen() { |
||||
DefaultMutableTreeNode eb1, eb2, eb3, eb4, eb5, eb6; |
||||
|
||||
int i = 0; |
||||
orga = new Vector(); |
||||
merkungültig = new Vector(); |
||||
String name, drucktext; |
||||
Integer ebene, lehre, orgstruktur; |
||||
String key_apnr,parent; |
||||
java.sql.Date gueltig_seit = null, gueltig_bis = null; |
||||
JTree ltree; |
||||
/* |
||||
String url = "jdbc:odbc:minisuperx"; |
||||
String driverClass = "sun.jdbc.odbc.JdbcOdbcDriver"; |
||||
|
||||
try { |
||||
Class.forName(driverClass); |
||||
myConnection = DriverManager.getConnection(url); |
||||
checkForWarning(myConnection.getWarnings()); |
||||
myDatabaseMetaData = myConnection.getMetaData(); |
||||
} catch (Exception e) { |
||||
System.out.println(e.toString()); |
||||
}*/ |
||||
// addWindowListener(new WindowClosingAdapter());
|
||||
//Einfaches TreeModel bauen
|
||||
|
||||
String query = |
||||
"SELECT name,drucktext,key_apnr,ebene,parent,lehre,gueltig_seit,gueltig_bis,orgstruktur FROM organigramm order by name"; |
||||
|
||||
int AnzahlGültige = 0; |
||||
int AnzahlFehler = 0; |
||||
try { |
||||
Statement statement = myConnection.createStatement(); |
||||
ResultSet rs1 = statement.executeQuery(query); |
||||
AnzahlEinträge = 0; |
||||
java.sql.Timestamp mytimestamp; |
||||
long mytimestampwert; |
||||
java.sql.Date StandDate = getDate(Stand); |
||||
// new java.sql.Date(cal.getTime().getTime());
|
||||
|
||||
while (rs1.next()) { |
||||
|
||||
name = rs1.getObject("name").toString(); |
||||
drucktext = rs1.getObject("drucktext").toString(); |
||||
key_apnr = (String) rs1.getObject("key_apnr"); |
||||
ebene = (Integer) rs1.getObject("ebene"); |
||||
parent = (String) rs1.getObject("parent"); |
||||
lehre = new Integer(1); |
||||
Object helpx = rs1.getObject("lehre"); |
||||
|
||||
if (key_apnr.equals(parent)) { |
||||
AnzahlFehler++; |
||||
log("Eintrag hat sich selbst als parent: " + key_apnr); |
||||
} |
||||
|
||||
lehre = new Integer(helpx.toString()); |
||||
orgstruktur = (Integer) rs1.getObject("orgstruktur"); |
||||
ResultSetMetaData rsmd = rs1.getMetaData(); |
||||
//System.out.println(rsmd.getColumnClassName(4));
|
||||
//für Access
|
||||
/*if (DB.equals("access")) { |
||||
mytimestamp = (java.sql.Timestamp) rs1.getObject("gueltig_seit"); |
||||
mytimestampwert = mytimestamp.getTime(); |
||||
gueltig_seit = new java.sql.Date(mytimestampwert); |
||||
|
||||
mytimestamp = (java.sql.Timestamp) rs1.getObject("gueltig_bis"); |
||||
mytimestampwert = mytimestamp.getTime(); |
||||
gueltig_bis = new java.sql.Date(mytimestampwert); |
||||
} |
||||
if (DB.equals("informix")) {*/ |
||||
gueltig_seit = (java.sql.Date) rs1.getObject("gueltig_seit"); |
||||
gueltig_bis = (java.sql.Date) rs1.getObject("gueltig_bis"); |
||||
|
||||
einEintrag = |
||||
new OrgaEintrag2( |
||||
name, |
||||
drucktext, |
||||
key_apnr, |
||||
ebene, |
||||
parent, |
||||
lehre, |
||||
gueltig_seit, |
||||
gueltig_bis, |
||||
orgstruktur); |
||||
|
||||
if ((gueltig_seit.equals(StandDate) || gueltig_seit.before(StandDate)) |
||||
&& (gueltig_bis.equals(StandDate) || gueltig_bis.after(StandDate))) { |
||||
orga.addElement(einEintrag); |
||||
AnzahlEinträge++;; |
||||
} |
||||
|
||||
|
||||
} |
||||
rs1.close(); |
||||
statement.close(); |
||||
|
||||
} catch (Exception e) { |
||||
JOptionPane.showMessageDialog( |
||||
null, |
||||
"Fehler beim Lesen aus der Datenbank: " + e.toString(), |
||||
"SuperX DB Admin", |
||||
JOptionPane.WARNING_MESSAGE); |
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
if (AnzahlFehler > 0) |
||||
JOptionPane.showMessageDialog( |
||||
null, |
||||
"Achtung!\n" + AnzahlFehler + " Einträge haben sich selbst als parent!", |
||||
"SuperX Admin", |
||||
JOptionPane.WARNING_MESSAGE); |
||||
|
||||
OrgaEintrag2 hochschule = |
||||
new OrgaEintrag2("Hochschule", null, null, null, null, null, null, null, null); |
||||
root = new DefaultMutableTreeNode(hochschule); |
||||
|
||||
/* DefaultMutableTreeNode e1=new DefaultMutableTreeNode(new orgaEintrag2("Studierende", null, null, null, null, null, null, null, null)); |
||||
e1.add(new DefaultMutableTreeNode(new orgaEintrag2("ca-werte", null, null, null, null, null, null, null, null))); |
||||
root.add(e1); |
||||
|
||||
e1.add(new DefaultMutableTreeNode(new orgaEintrag2("Stud. allgmein", null, null, null, null, null, null, null, null))); |
||||
|
||||
DefaultMutableTreeNode e2=new DefaultMutableTreeNode(new orgaEintrag2("Haushalt", null, null, null, null, null, null, null, null)); |
||||
|
||||
DefaultMutableTreeNode e2b= new DefaultMutableTreeNode(new orgaEintrag2("Haushaltszeitreihen", null, null, null, null, null, null, null, null)); |
||||
DefaultMutableTreeNode e2c= new DefaultMutableTreeNode(new orgaEintrag2("Haushalt (Zeitreihe)", null, null, null, null, null, null, null, null)); |
||||
e2b.add(e2c); |
||||
e2.add(e2b); |
||||
|
||||
e2.add(new DefaultMutableTreeNode( new orgaEintrag2("Altersstruktur der Beschäftigen", null, null, null, null, null, null, null, null))); |
||||
root.add(e2); |
||||
|
||||
DefaultMutableTreeNode e3=new DefaultMutableTreeNode(new orgaEintrag2("Kennzahlen", null, null, null, null, null, null, null, null)); |
||||
DefaultMutableTreeNode e3b=new DefaultMutableTreeNode(new orgaEintrag2("Basiskennzahlen", null, null, null, null, null, null, null, null)); |
||||
e3b.add(new DefaultMutableTreeNode(new orgaEintrag2("ca-werte", null, null, null, null, null, null, null, null))); |
||||
e3.add(e3b); |
||||
e3.add(new DefaultMutableTreeNode(new orgaEintrag2("Neue Kennzahlabfrage", null, null, null, null, null, null, null, null))); |
||||
root.add(e3); |
||||
|
||||
*/ |
||||
|
||||
//hier werden über eine rekursive Methode alle
|
||||
//Institute in den Baum eingetragen
|
||||
insertnodes(null, root); |
||||
|
||||
//Konsistenz prüfen
|
||||
int TreeEinträge = KinderZählen(root); |
||||
if (AnzahlGültige != TreeEinträge) |
||||
prüfeDifferenzen(root); |
||||
|
||||
//Rechte der Gruppeeinlesen
|
||||
GruppenRechteLesen((DefaultMutableTreeNode) root.getChildAt(0), 10); |
||||
|
||||
//Baum erzeugen
|
||||
treeModel = new DefaultTreeModel(root); |
||||
|
||||
//AdminOrgaModelListener aoml=new AdminOrgaModelListener();
|
||||
//treeModel.addTreeModelListener(new AdminOrgaModelListener());
|
||||
|
||||
ltree = new JTree(treeModel); |
||||
ltree.setRootVisible(false); |
||||
ltree.setEditable(true); |
||||
// ltree.setBackground(Color.lightGray);
|
||||
//root Hochschule sieht man sowieso nicht
|
||||
//first child GMU Duisburg muss aufgeklappt sein
|
||||
//da Mouselistener Doubleclick umfunktioniert
|
||||
|
||||
DefaultMutableTreeNode ebene1 = (DefaultMutableTreeNode) root.getChildAt(0); |
||||
ltree.expandPath(new TreePath(ebene1.getPath())); |
||||
|
||||
//Einfachselektion
|
||||
ltree.getSelectionModel().setSelectionMode( |
||||
TreeSelectionModel.SINGLE_TREE_SELECTION); |
||||
|
||||
InstRenderer renderer = new InstRenderer(); |
||||
InstEditor editor = new InstEditor(); |
||||
editor.addCellEditorListener(this); |
||||
ltree.setEditable(true); |
||||
ltree.setCellRenderer(renderer); |
||||
ltree.setCellEditor(new InstImmediateEditor(ltree, renderer, editor)); |
||||
|
||||
//TreeSelectionListener hinzufügen
|
||||
// AdminOrgaSelList adosl = new AdminOrgaSelList(this, ltree);
|
||||
// ltree.addTreeSelectionListener(adosl);
|
||||
|
||||
// AdminOrgaMouseListener ml =
|
||||
// new AdminOrgaMouseListener(this, ltree, merkungültig);
|
||||
// ltree.addMouseListener(ml);
|
||||
|
||||
linkToMain.setStatus(AnzahlEinträge + " OrgaEinträge eingelesen"); |
||||
|
||||
return ltree; |
||||
} |
||||
} |
@ -1,198 +0,0 @@
@@ -1,198 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
|
||||
import java.awt.GridLayout; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.util.Enumeration; |
||||
import java.util.Vector; |
||||
|
||||
import javax.swing.JButton; |
||||
import javax.swing.JLabel; |
||||
import javax.swing.JOptionPane; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JTextField; |
||||
|
||||
import de.memtext.util.WindowUtils; |
||||
|
||||
class GroupStammPanel extends JPanel implements ActionListener { |
||||
|
||||
Vector gruppenliste; |
||||
MBComboBox mbt; |
||||
JTextField tname = new JTextField(15); |
||||
|
||||
public GroupStammPanel() { |
||||
|
||||
mbt = new MBComboBox(); |
||||
|
||||
mbt.addActionListener(this); |
||||
this.setLayout(new GridLayout(3, 1)); |
||||
JPanel p0 = new JPanel(); |
||||
p0.add(mbt); |
||||
this.add(p0); |
||||
JPanel p1 = new JPanel(); |
||||
JLabel lname = new JLabel("Name:"); |
||||
p1.add(lname); |
||||
p1.add(tname); |
||||
JButton bspeich = new JButton("Name ändern"); |
||||
bspeich.addActionListener(this); |
||||
p1.add(bspeich); |
||||
this.add(p1); |
||||
|
||||
JPanel p5 = new JPanel(); |
||||
JButton blöschen = new JButton("Gruppe löschen"); |
||||
blöschen.addActionListener(this); |
||||
p5.add(blöschen); |
||||
JButton bneu = new JButton("Gruppe anlegen"); |
||||
bneu.addActionListener(this); |
||||
p5.add(bneu); |
||||
|
||||
this.add(p5); |
||||
|
||||
} |
||||
|
||||
public void prepare() { |
||||
WindowUtils.setWaitCursor(this,true); |
||||
gruppenliste = DBAccess.GruppenListeEinlesen(); |
||||
mbt.removeAllItems(); |
||||
//special version
|
||||
mbt.addAll(gruppenliste); |
||||
if (SuperXDBAdmin.getLastGroup() != -999) |
||||
mbt.setSelection(SuperXDBAdmin.getLastGroup()); |
||||
WindowUtils.setWaitCursor(this,false); |
||||
} |
||||
|
||||
public void actionPerformed(ActionEvent event) { |
||||
// if (event.getActionCommand().equals("speichern"))
|
||||
// NutzerRechteSpeichern();
|
||||
if (event.getActionCommand().equals("Name ändern")) |
||||
gruppenDatenSpeichern(); |
||||
|
||||
if (event.getActionCommand().equals("Gruppe löschen")) |
||||
gruppeLöschen(mbt.getSelectedID()); |
||||
|
||||
if (event.getActionCommand().equals("Gruppe anlegen")) |
||||
gruppeAnlegen(); |
||||
|
||||
Object src = event.getSource(); |
||||
if (src instanceof MBComboBox) { |
||||
MBComboBox localbox = (MBComboBox) event.getSource(); |
||||
|
||||
SuperXDBAdmin.setLastGroup(localbox.getSelectedID()); |
||||
gruppeGewählt(SuperXDBAdmin.getLastGroup()); |
||||
} |
||||
|
||||
} |
||||
|
||||
private void gruppenDatenSpeichern() { |
||||
try { |
||||
WindowUtils.setWaitCursor(this,true); |
||||
String upd = "update groupinfo set name=" |
||||
+ DBAccess.getStringOrNull(tname.getText()) + "" |
||||
+ " where tid=" + mbt.getSelectedID(); |
||||
|
||||
DBAccess.executeUpdate(upd); |
||||
SuperXDBAdmin.setStatus("Gruppendaten gespeichert!"); |
||||
gruppenliste = DBAccess.GruppenListeEinlesen(); |
||||
mbt.neuAufbauen(gruppenliste); |
||||
} catch (Exception e) { |
||||
JOptionPane |
||||
.showMessageDialog(null, |
||||
"Fehler beim Schreiben in die Datenbank:\n " |
||||
+ e.toString(), "SuperX DB Admin", |
||||
JOptionPane.WARNING_MESSAGE); |
||||
|
||||
e.printStackTrace(); |
||||
|
||||
} |
||||
finally |
||||
{ |
||||
WindowUtils.setWaitCursor(this,false); |
||||
} |
||||
} |
||||
|
||||
private void gruppeGewählt(int gruppeid) { |
||||
Vector zeile; |
||||
Integer test; |
||||
String help; |
||||
for (Enumeration el = gruppenliste.elements(); el.hasMoreElements();) { |
||||
zeile = ((Vector) el.nextElement()); |
||||
test = (Integer) zeile.get(0); |
||||
if (test.intValue() == gruppeid) { |
||||
tname.setText((String) zeile.get(1)); |
||||
tname.setCaretPosition(0); |
||||
} |
||||
} |
||||
|
||||
this.repaint(); |
||||
SuperXDBAdmin.setLastGroup(gruppeid); |
||||
} |
||||
|
||||
private void gruppeLöschen(int gruppeid) { |
||||
String nochEingetrageneUser = new String(""); |
||||
try { |
||||
Vector erg = DBAccess |
||||
.executeQuery("select unique benutzer,name from userinfo U,user_group_bez B where U.tid=B.userinfo_id and b.groupinfo_id=" |
||||
+ gruppeid); |
||||
Vector help; |
||||
for (Enumeration el = erg.elements(); el.hasMoreElements();) { |
||||
help = (Vector) el.nextElement(); |
||||
if (nochEingetrageneUser.equals("")) |
||||
nochEingetrageneUser = new String( |
||||
"Folgende Nutzer gehören zu dieser Gruppe:"); |
||||
nochEingetrageneUser += "\n" + help.get(0).toString() + " (" |
||||
+ help.get(1).toString() + ")"; |
||||
} |
||||
if (!nochEingetrageneUser.equals("")) |
||||
nochEingetrageneUser += "\n"; |
||||
} catch (Exception e) { |
||||
SuperXDBAdmin.setStatus("Ein Datenbankfehler ist aufgetreten"+e); |
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
int rc = JOptionPane.showConfirmDialog(null, nochEingetrageneUser |
||||
+ "Gruppe wirklich löschen?", "SuperX", |
||||
JOptionPane.YES_NO_OPTION); |
||||
if (rc == JOptionPane.YES_OPTION) { |
||||
try { |
||||
//DBAccess .executeUpdate("delete from group_themen where groupid=" + gruppeid);
|
||||
DBAccess |
||||
.executeUpdate("delete from user_group_bez where groupinfo_id=" |
||||
+ gruppeid); |
||||
DBAccess.executeUpdate("delete from groupinfo where tid =" |
||||
+ gruppeid); |
||||
SuperXDBAdmin.setStatus("Gruppe gelöscht"); |
||||
mbt.neuAufbauen(DBAccess.GruppenListeEinlesen()); |
||||
SuperXDBAdmin.setLastGroup(-999); |
||||
} catch (Exception e) { |
||||
SuperXDBAdmin |
||||
.setStatus("Ein Fehler ist aufgetreten - Gruppe nicht gelöscht"+e); |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
private void gruppeAnlegen() { |
||||
try { |
||||
Integer tid = (Integer) DBAccess |
||||
.executeQuerySingleValue("select max(tid) as tid from groupinfo"); |
||||
int newtid = tid.intValue() + 1; |
||||
|
||||
String name = JOptionPane.showInputDialog(this, "Name eingeben", |
||||
"SuperX", JOptionPane.QUESTION_MESSAGE); |
||||
if (name != null) { |
||||
String ins = "insert into groupinfo values (" + newtid + ",'" |
||||
+ name + "')"; |
||||
DBAccess.executeUpdate(ins); |
||||
gruppenliste = DBAccess.GruppenListeEinlesen(); |
||||
mbt.neuAufbauen(gruppenliste); |
||||
mbt.setSelection(name); |
||||
gruppeGewählt(newtid); |
||||
SuperXDBAdmin.setLastGroup(newtid); |
||||
SuperXDBAdmin.setStatus("Gruppe angelegt!"); |
||||
} |
||||
} catch (Exception e) { |
||||
SuperXDBAdmin.setStatus("Interner Fehler: " + e.toString()); |
||||
} |
||||
} |
||||
} |
@ -1,819 +0,0 @@
@@ -1,819 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
/** |
||||
* Insert the type's description here. |
||||
* Creation date: (23.01.2002 09:48:04) |
||||
* @author: Meikel Bisping |
||||
*/ |
||||
|
||||
import java.awt.BorderLayout; |
||||
import java.awt.Container; |
||||
import java.awt.Cursor; |
||||
import java.awt.Font; |
||||
import java.awt.GridLayout; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.text.DateFormat; |
||||
import java.text.ParseException; |
||||
import java.util.Calendar; |
||||
import java.util.Enumeration; |
||||
import java.util.GregorianCalendar; |
||||
import java.util.TimeZone; |
||||
import java.util.Vector; |
||||
|
||||
import javax.swing.CellEditor; |
||||
import javax.swing.JButton; |
||||
import javax.swing.JLabel; |
||||
import javax.swing.JOptionPane; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JScrollPane; |
||||
import javax.swing.JTextField; |
||||
import javax.swing.JTree; |
||||
import javax.swing.event.CellEditorListener; |
||||
import javax.swing.event.ChangeEvent; |
||||
import javax.swing.tree.DefaultMutableTreeNode; |
||||
import javax.swing.tree.DefaultTreeModel; |
||||
import javax.swing.tree.TreePath; |
||||
import javax.swing.tree.TreeSelectionModel; |
||||
|
||||
class GroupThemen |
||||
extends JPanel |
||||
implements CellEditorListener, ActionListener { |
||||
boolean result; |
||||
boolean etwasGeändert = false; |
||||
Vector themenbaum; |
||||
int AnzahlEinträge; |
||||
JLabel Standlabel; |
||||
GregorianCalendar cal = new GregorianCalendar(); |
||||
String Stand; |
||||
JTextField suchtext; |
||||
Container cp; |
||||
JTree tree = null; |
||||
SxThemenEintrag2 einEintrag; |
||||
DefaultTreeModel treeModel; |
||||
JScrollPane treeScroll; |
||||
DefaultMutableTreeNode root; |
||||
SuperXDBAdmin linkToMain; |
||||
|
||||
public GroupThemen(SuperXDBAdmin llinkToMain) { |
||||
super(); |
||||
linkToMain = llinkToMain; |
||||
this.setLayout(new BorderLayout()); |
||||
//top panel für Stand
|
||||
|
||||
Stand = |
||||
cal.get(Calendar.DATE) |
||||
+ "." |
||||
+ (cal.get(Calendar.MONTH) + 1) |
||||
+ "." |
||||
+ cal.get(Calendar.YEAR); |
||||
//aktuelles Datum ist default
|
||||
|
||||
JPanel top = new JPanel(); |
||||
|
||||
MBComboBox mbt = new MBComboBox(DBAccess.GruppenListeEinlesen()); |
||||
//mbt.AddActionListener(this);
|
||||
|
||||
top.add(mbt); |
||||
Standlabel = new JLabel("Stand: " + Stand); |
||||
Standlabel.setFont(new Font("Arial", Font.PLAIN, 10)); |
||||
JButton bStand = new JButton("anderer Stand"); |
||||
bStand.setFont(new Font("Arial", Font.PLAIN, 10)); |
||||
bStand.setDefaultCapable(false); |
||||
bStand.addActionListener(this); |
||||
top.add(Standlabel); |
||||
top.add(bStand); |
||||
|
||||
this.add(top, "North"); |
||||
|
||||
//JTree erzeugen
|
||||
JPanel center = new JPanel(); //new GridLayout(1, 2));
|
||||
|
||||
tree = tree_erzeugen(Stand); |
||||
treeScroll = new JScrollPane(tree); |
||||
//,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
|
||||
center.add(treeScroll); |
||||
// cp.add(treeScroll, "Center");
|
||||
this.add(treeScroll, "Center"); |
||||
|
||||
//Suchen Feld + Buttons
|
||||
JPanel down = new JPanel(); |
||||
down.setLayout(new GridLayout(3, 1)); |
||||
|
||||
JPanel psuchen = new JPanel(); |
||||
suchtext = new JTextField(10); |
||||
suchtext.setFont(new Font("Arial", Font.PLAIN, 10)); |
||||
psuchen.add(suchtext); |
||||
|
||||
JButton suchen = new JButton("Suchen"); |
||||
suchen.setFont(new Font("Arial", Font.PLAIN, 10)); |
||||
suchen.addActionListener(this); |
||||
|
||||
psuchen.add(suchen); |
||||
|
||||
down.add(psuchen); |
||||
|
||||
JPanel pspeichern = new JPanel(); |
||||
JButton speichern = new JButton("speichern"); |
||||
speichern.addActionListener(this); |
||||
pspeichern.add(speichern); |
||||
down.add(pspeichern); |
||||
|
||||
this.add("South", down); |
||||
//pack();
|
||||
if (linkToMain.getLastGroup() != -999) |
||||
mbt.setSelection(linkToMain.getLastGroup()); |
||||
|
||||
} |
||||
public void actionPerformed(ActionEvent event) { |
||||
if (event.getActionCommand().equals("speichern")) |
||||
GruppenRechteSpeichern(); |
||||
|
||||
if (event.getActionCommand().equals("Suchen")) |
||||
suchen(); |
||||
|
||||
Object src = event.getSource(); |
||||
if (src instanceof MBComboBox) { |
||||
MBComboBox localbox = (MBComboBox) event.getSource(); |
||||
linkToMain.setLastGroup(localbox.getSelectedID()); |
||||
GruppenRechteLesen(linkToMain.getLastGroup()); |
||||
tree.repaint(); |
||||
} |
||||
|
||||
} |
||||
public void andererStand() { |
||||
int result = |
||||
JOptionPane.showConfirmDialog( |
||||
null, |
||||
"Bei Auswahl eines anderen Stands gehen eventuell gemachte Änderungen verloren!\n Erst speichern?", |
||||
"SuperX DB Admin", |
||||
JOptionPane.YES_NO_OPTION); |
||||
if (result == JOptionPane.OK_OPTION) { |
||||
GruppenRechteSpeichern(); |
||||
} |
||||
String Standneu = |
||||
JOptionPane.showInputDialog( |
||||
this, |
||||
"Neues Datum eingeben:", |
||||
"SuperX", |
||||
JOptionPane.QUESTION_MESSAGE); |
||||
if (Standneu != null && DatumOK(Standneu)) //and FormOk
|
||||
|
||||
{ |
||||
cp.setCursor(new Cursor(Cursor.WAIT_CURSOR)); |
||||
|
||||
Stand = Standneu; |
||||
Standlabel.setText("Stand: " + Stand); |
||||
tree = this.tree_erzeugen(Stand); |
||||
|
||||
cp.remove(treeScroll); |
||||
treeScroll = new JScrollPane(tree); |
||||
cp.add(treeScroll); |
||||
cp.validate(); |
||||
cp.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); |
||||
} |
||||
} |
||||
private void children_freischalten(DefaultMutableTreeNode node) { |
||||
DefaultMutableTreeNode aNode; |
||||
SxThemenEintrag2 x; |
||||
for (Enumeration en = node.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
x = (SxThemenEintrag2) aNode.getUserObject(); |
||||
x.setErlaubt(true); |
||||
wennMaskeÜberall(aNode, "freischalten"); |
||||
} |
||||
} |
||||
public void childrenSperren(DefaultMutableTreeNode node) { |
||||
DefaultMutableTreeNode aNode; |
||||
SxThemenEintrag2 x; |
||||
for (Enumeration en = node.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
x = (SxThemenEintrag2) aNode.getUserObject(); |
||||
x.setErlaubt(false); |
||||
wennMaskeÜberall(aNode, "sperren"); |
||||
} |
||||
} |
||||
public String dateToString(java.sql.Date inp) { |
||||
java.text.DateFormat df; |
||||
df = java.text.DateFormat.getDateInstance(java.text.DateFormat.MEDIUM); |
||||
// r.b. default Jahr 4-stellig
|
||||
df.setTimeZone(TimeZone.getDefault()); |
||||
df.setLenient(false); |
||||
|
||||
String help = df.format((java.util.Date) inp); |
||||
return help; |
||||
} |
||||
public boolean DatumOK(String dat) { |
||||
DateFormat df; |
||||
df = DateFormat.getDateInstance(DateFormat.MEDIUM); |
||||
// r.b. default Jahr 4-stellig
|
||||
df.setTimeZone(TimeZone.getDefault()); |
||||
df.setLenient(false); |
||||
String geprueft = null; |
||||
try { |
||||
if (dat.endsWith("00")) { |
||||
switch (dat.charAt(dat.length() - 3)) { |
||||
case '-' : |
||||
case '.' : |
||||
case '/' : |
||||
dat = dat.substring(0, dat.length() - 2) + "2000"; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
java.util.Date date = df.parse(dat); |
||||
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); |
||||
|
||||
//wenn Format nicht OK bleibt geprueft null
|
||||
geprueft = df.format((java.util.Date) date); |
||||
} |
||||
catch (ParseException e_parse) { |
||||
// System.err.println ("SxDate: ERROR: parse: Date != " + value);
|
||||
} |
||||
catch (IllegalArgumentException e_arg) { |
||||
// System.err.println ("SxDate: ERROR: arg: Date != " + value);
|
||||
} |
||||
|
||||
return geprueft == null ? false : true; |
||||
} |
||||
public void editingCanceled(ChangeEvent e) { |
||||
CellEditor cellEditor = (CellEditor) e.getSource(); |
||||
/* SelectableFile sf = |
||||
(SelectableFile) |
||||
cellEditor.getCellEditorValue(); |
||||
|
||||
System.out.println("editing canceled: " + |
||||
sf.toString());*/ |
||||
} |
||||
public void editingStopped(ChangeEvent e) { |
||||
// CellEditor cellEditor = (CellEditor)e.getSource();
|
||||
InstEditor cellEditor = (InstEditor) e.getSource(); |
||||
DefaultMutableTreeNode node = |
||||
(DefaultMutableTreeNode) cellEditor.getLastEditedNode(); |
||||
|
||||
SxThemenEintrag2 x = (SxThemenEintrag2) node.getUserObject(); |
||||
|
||||
if (x.isErlaubt()) { |
||||
children_freischalten(node); |
||||
prüfeObParentFreischalten(node); |
||||
wennMaskeÜberall(node, "freischalten"); |
||||
} |
||||
else { |
||||
parents_sperren(node); |
||||
childrenSperren(node); |
||||
wennMaskeÜberall(node, "sperren"); |
||||
} |
||||
|
||||
} |
||||
public static java.sql.Date getDate(String value) { |
||||
|
||||
DateFormat df; |
||||
java.util.Date date; |
||||
java.sql.Date sql_date; |
||||
Calendar calendar; |
||||
|
||||
df = DateFormat.getDateInstance(DateFormat.MEDIUM); |
||||
// r.b. default Jahr 4-stellig
|
||||
df.setTimeZone(TimeZone.getDefault()); |
||||
df.setLenient(false); |
||||
|
||||
try { |
||||
if (value.endsWith("00")) { |
||||
switch (value.charAt(value.length() - 3)) { |
||||
case '-' : |
||||
case '.' : |
||||
case '/' : |
||||
value = value.substring(0, value.length() - 2) + "2000"; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
date = df.parse(value); |
||||
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); |
||||
|
||||
sql_date = new java.sql.Date(calendar.getTime().getTime()); |
||||
return sql_date; |
||||
} |
||||
catch (ParseException e_parse) { |
||||
// System.err.println ("SxDate: ERROR: parse: Date != " + value);
|
||||
} |
||||
catch (IllegalArgumentException e_arg) { |
||||
// System.err.println ("SxDate: ERROR: arg: Date != " + value);
|
||||
} |
||||
|
||||
return null; |
||||
} |
||||
private void insertnodes(Integer theParent, DefaultMutableTreeNode aktNode) { |
||||
//rekursive Methode, die Institutionen in den Baum einträgt
|
||||
Vector result = new Vector(); |
||||
result = mySelect(theParent); |
||||
Integer eintrag_tid; |
||||
|
||||
for (Enumeration el = result.elements(); el.hasMoreElements();) { |
||||
einEintrag = (SxThemenEintrag2) el.nextElement(); |
||||
DefaultMutableTreeNode neuNode = new DefaultMutableTreeNode(einEintrag); |
||||
aktNode.add(neuNode); |
||||
|
||||
eintrag_tid = einEintrag.getTid(); |
||||
//nervig null-Werte abfangen
|
||||
if (eintrag_tid != null & theParent == null) |
||||
insertnodes(einEintrag.getTid(), neuNode); |
||||
if (eintrag_tid == null & theParent == null) |
||||
System.out.println( |
||||
"Achtung! Element hat fälschlicherweise sich selbst als parent:" |
||||
+ einEintrag.getName()); |
||||
|
||||
if (eintrag_tid != null && theParent != null) |
||||
if (!theParent.equals(eintrag_tid)) |
||||
insertnodes(einEintrag.getTid(), neuNode); |
||||
else |
||||
System.out.println( |
||||
"Achtung! Element hat fälschlicherweise sich selbst als parent:" |
||||
+ einEintrag.getName() |
||||
+ "tid:" |
||||
+ einEintrag.getTid()); |
||||
} |
||||
|
||||
//wenn eine Kategorie (maskeninfo==null) keine Blätter (Abfragen)
|
||||
//enthält, die Kategorie entfernen
|
||||
einEintrag = (SxThemenEintrag2) aktNode.getUserObject(); |
||||
// if (einEintrag.getMaskeninfo_id()==null&&result.size()<1)
|
||||
if (einEintrag.getMaskeninfo_id() == null && aktNode.isLeaf()) |
||||
aktNode.removeFromParent(); |
||||
|
||||
} |
||||
public int KinderZählen(DefaultMutableTreeNode node) { |
||||
int zähler = 0; |
||||
DefaultMutableTreeNode aNode; |
||||
for (Enumeration en = node.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
zähler++; |
||||
} |
||||
return zähler - 1; |
||||
|
||||
} |
||||
public void log(String was) { |
||||
System.out.println(was); |
||||
//ggfs. in Datei schreiben
|
||||
} |
||||
private Vector mySelect(Integer pruefparent) { |
||||
//liefert alle Institute mit Parent =pruefparent zurück
|
||||
Vector result = new Vector(); |
||||
Integer eintrag_parent; |
||||
for (Enumeration el = themenbaum.elements(); el.hasMoreElements();) { |
||||
einEintrag = (SxThemenEintrag2) el.nextElement(); |
||||
eintrag_parent = einEintrag.getParent(); |
||||
if (eintrag_parent == null && pruefparent == null) |
||||
result.addElement(einEintrag); |
||||
if (eintrag_parent != null && pruefparent != null) |
||||
if (eintrag_parent.intValue() == pruefparent.intValue()) |
||||
result.addElement(einEintrag); |
||||
|
||||
} |
||||
return result; |
||||
} |
||||
private void GruppenRechteLesen(int GroupID) { |
||||
GruppenRechteLesen(GroupID, false); |
||||
} |
||||
|
||||
private void GruppenRechteLesen(int GroupID, boolean mute) { |
||||
Integer id; |
||||
DefaultMutableTreeNode aNode, childNode; |
||||
SxThemenEintrag2 x; |
||||
DefaultMutableTreeNode start = |
||||
(DefaultMutableTreeNode) tree.getModel().getRoot(); |
||||
//erstmal alles auf erlaubt=false setzen
|
||||
for (Enumeration en = start.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
if (aNode.getUserObject() instanceof SxThemenEintrag2) { |
||||
x = (SxThemenEintrag2) aNode.getUserObject(); |
||||
x.setErlaubt(false); |
||||
} |
||||
} |
||||
|
||||
try { |
||||
|
||||
String query = "select id, maske from Group_themen where groupid=" + GroupID; |
||||
|
||||
Vector erg = DBAccess.executeQuery(query); |
||||
String maske; |
||||
Vector help; |
||||
for (Enumeration el = erg.elements(); el.hasMoreElements();) { |
||||
help = (Vector) el.nextElement(); |
||||
id = (Integer) help.get(0); |
||||
maske = help.get(1).toString(); |
||||
|
||||
for (Enumeration en = start.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
if (aNode.getUserObject() instanceof SxThemenEintrag2) { |
||||
x = (SxThemenEintrag2) aNode.getUserObject(); |
||||
|
||||
if ((maske.equals("0") && x.getTid().equals(id)) |
||||
|| (maske.equals("1") |
||||
&& x.getMaskeninfo_id() != null |
||||
&& x.getMaskeninfo_id().equals(id))) { |
||||
x.setErlaubt(true); |
||||
//Kinder auch
|
||||
for (Enumeration en2 = aNode.depthFirstEnumeration(); en2.hasMoreElements();) { |
||||
childNode = (DefaultMutableTreeNode) en2.nextElement(); |
||||
x = (SxThemenEintrag2) childNode.getUserObject(); |
||||
x.setErlaubt(true); |
||||
} |
||||
|
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
if (!mute) |
||||
linkToMain.setStatus("Group geändert"); |
||||
linkToMain.setLastGroup(GroupID); |
||||
} |
||||
catch (Exception e) { |
||||
JOptionPane.showMessageDialog( |
||||
null, |
||||
"Fehler beim Lesen aus der Datenbank: " + e.toString(), |
||||
"SuperX DB Admin", |
||||
JOptionPane.WARNING_MESSAGE); |
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
} |
||||
public void GruppenRechteSpeichern() { |
||||
Enumeration en; |
||||
int i = 0; |
||||
String ins = null; |
||||
String wo = null; |
||||
|
||||
//datum String in sql.Date umformen
|
||||
java.sql.Date date = new java.sql.Date(1); |
||||
SxDate mydate = new SxDate(); |
||||
date = mydate.getDate(Stand); |
||||
|
||||
// MBProgressBar progress=new MBProgressBar(10);
|
||||
try { |
||||
DefaultMutableTreeNode lroot = |
||||
(DefaultMutableTreeNode) tree.getModel().getRoot(); |
||||
DefaultMutableTreeNode aNode; |
||||
SxThemenEintrag2 x; |
||||
Object userobj; |
||||
String upd = |
||||
"delete from group_themen where groupid=" + linkToMain.getLastGroup(); |
||||
DBAccess.executeUpdate(upd); |
||||
|
||||
TreePath tp; |
||||
DefaultMutableTreeNode vorher; |
||||
aNode = null; |
||||
String id; |
||||
int maske = 0; |
||||
for (en = lroot.breadthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
userobj = aNode.getUserObject(); |
||||
if (userobj instanceof SxThemenEintrag2 && aNode != lroot) { |
||||
x = (SxThemenEintrag2) userobj; |
||||
if (x.isErlaubt()) { |
||||
if (x.getMaskeninfo_id() != null) { |
||||
id = x.getMaskeninfo_id().toString(); |
||||
maske = 1; |
||||
} |
||||
else { |
||||
id = x.getTid().toString(); |
||||
maske = 0; |
||||
} |
||||
|
||||
ins = |
||||
new String( |
||||
"insert into group_themen (groupid, id,maske) " |
||||
+ "values (" |
||||
+ linkToMain.getLastGroup() |
||||
+ "," |
||||
+ id |
||||
+ "," |
||||
+ maske |
||||
+ ")"); |
||||
DBAccess.executeUpdate(ins); |
||||
i++; |
||||
//children sperren, da nur Eintrag von hierarchiehöchstem Element nötig
|
||||
|
||||
childrenSperren(aNode); |
||||
|
||||
} |
||||
//progress.inc();
|
||||
} |
||||
} |
||||
|
||||
linkToMain.setStatus(i + " Einträge in group_themen geschrieben"); |
||||
etwasGeändert = false; |
||||
//da Kinder der Verarbeitung wegen gesperrt wurden, muss neu eingelesen werden
|
||||
GruppenRechteLesen(linkToMain.getLastGroup(), true); |
||||
} |
||||
catch (Exception e) { |
||||
JOptionPane.showMessageDialog( |
||||
null, |
||||
"Fehler beim Schreiben in die Datenbank:\n " + e.toString(), |
||||
"SuperX DB Admin", |
||||
JOptionPane.WARNING_MESSAGE); |
||||
System.out.println(wo + ": " + ins); |
||||
e.printStackTrace(); |
||||
|
||||
} |
||||
//progress.hide();
|
||||
//progress.dispose();
|
||||
|
||||
} |
||||
private void parents_sperren(DefaultMutableTreeNode node) { |
||||
DefaultMutableTreeNode aNode; |
||||
SxThemenEintrag2 x; |
||||
boolean go = true; |
||||
while (go) { |
||||
aNode = (DefaultMutableTreeNode) node.getParent(); |
||||
if (aNode == null || !(aNode.getUserObject() instanceof SxThemenEintrag2)) |
||||
return; //root
|
||||
|
||||
x = (SxThemenEintrag2) aNode.getUserObject(); |
||||
if (x.isErlaubt()) |
||||
//wenn parent erlaubt ist, den auf false setzen
|
||||
// und in Schleife weitermachen
|
||||
//denn sobald nur eines der Kinderelemente eines parents nicht erlaubt,
|
||||
//ist er selbst nicht mehr erlaubt
|
||||
x.setErlaubt(false); |
||||
// ansonsten war parent schon auf false und man braucht nicht weitermachen
|
||||
else |
||||
go = false; |
||||
node = aNode; |
||||
} |
||||
|
||||
} |
||||
|
||||
private void prüfeObParentFreischalten(DefaultMutableTreeNode node) { |
||||
DefaultMutableTreeNode aNode; |
||||
DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent(); |
||||
SxThemenEintrag2 x; |
||||
boolean alleKinderErlaubt = true; |
||||
for (Enumeration en = parent.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
if (!aNode.equals(parent)) { |
||||
x = (SxThemenEintrag2) aNode.getUserObject(); |
||||
if (!x.isErlaubt()) |
||||
alleKinderErlaubt = false; |
||||
} |
||||
} |
||||
if (alleKinderErlaubt) { |
||||
x = (SxThemenEintrag2) parent.getUserObject(); |
||||
x.setErlaubt(true); |
||||
} |
||||
if (!parent.isRoot()) |
||||
prüfeObParentFreischalten(parent); |
||||
} |
||||
|
||||
private void suchen() { |
||||
String such = suchtext.getText().toLowerCase(); |
||||
String teststring; |
||||
TreePath tp; |
||||
boolean gefunden = false; |
||||
DefaultMutableTreeNode test, ausgesucht; |
||||
ausgesucht = null; |
||||
Vector treffer = new Vector(); |
||||
Vector treffernodes = new Vector(); |
||||
|
||||
if (such.length() < 1) { |
||||
JOptionPane.showMessageDialog(null, "Bitte Suchbegriff eingeben!", "SuperX", 1); |
||||
return; |
||||
} |
||||
such = such.toLowerCase(); |
||||
//JOptionPane.showMessageDialog(null, "neu","SuperX",1);
|
||||
//alle Knoten durchlaufen
|
||||
DefaultMutableTreeNode 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) JOptionPane.showInputDialog( |
||||
null, |
||||
"Mehrere Treffer!\nBitte 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.addSelectionPath(tp); |
||||
//tree.makeVisible(tp);
|
||||
|
||||
// tree.validate();
|
||||
// tree.repaint();
|
||||
} |
||||
else |
||||
JOptionPane.showMessageDialog(null, "Keine Treffer", "SuperX", 1); |
||||
} |
||||
public JTree tree_erzeugen(String lStand) { |
||||
|
||||
//liefert Organigramm v. angegebenen Stand zurück
|
||||
String name, erlaeuterung; |
||||
Integer tid, maskeninfo_id, parent; |
||||
java.sql.Date gueltig_seit, gueltig_bis; |
||||
|
||||
JTree ltree=null; |
||||
//neu erstellen nur beim 1.mal und anderem Stand
|
||||
try { |
||||
// if (Stand == null || (!Stand.equals(lStand))) {
|
||||
Stand = lStand; |
||||
|
||||
//tree erzeugen für Stand
|
||||
//aus Datenbank auslesen
|
||||
|
||||
//datum String in sql.Date umformen
|
||||
java.sql.Date date = new java.sql.Date(1); |
||||
SxDate mydate = new SxDate(); |
||||
date = mydate.getDate(Stand); |
||||
Vector rohform = new Vector(); |
||||
|
||||
//Rohfassung (vector in vector) aus DB
|
||||
|
||||
//informix
|
||||
String query = |
||||
//Kategorien, wie Studierende/Prüfungen
|
||||
//wenn keine Rechte für Abfragen darunter werden die Äste wieder gelöscht
|
||||
|
||||
"select T.tid,T.name, T.maskeninfo_id, T.parent, T.erlaeuterung,T.gueltig_seit,T.gueltig_bis " |
||||
+ "from themenbaum T " |
||||
+ "where T.maskeninfo_id is null and " |
||||
+ "T.gueltig_seit<=date('" |
||||
+ date |
||||
+ "') and T.gueltig_bis>=date('" |
||||
+ date |
||||
+ "') " |
||||
+ " union " |
||||
+ |
||||
|
||||
//und alle Abfragen
|
||||
"select T.tid,M.name, T.maskeninfo_id, T.parent, M.erlaeuterung,T.gueltig_seit,T.gueltig_bis " |
||||
+ "from themenbaum T, maskeninfo M " |
||||
+ "where T.maskeninfo_id=M.tid and " |
||||
+ "T.gueltig_seit<=date('" |
||||
+ date |
||||
+ "') and T.gueltig_bis>=date('" |
||||
+ date |
||||
+ "') " |
||||
+ " order by 2"; |
||||
|
||||
Vector zeile; |
||||
rohform = DBAccess.executeQuery(query); |
||||
if (rohform.size() < 1) |
||||
return null; |
||||
//Umformen in Vector of SxThemenEintrag2
|
||||
Vector dummy = new Vector(); |
||||
themenbaum = new Vector(); |
||||
Enumeration en1 = rohform.elements(); |
||||
while (en1.hasMoreElements()) { |
||||
dummy = (Vector) en1.nextElement(); |
||||
tid = (Integer) dummy.elementAt(0); |
||||
name = (String) dummy.elementAt(1); |
||||
name = name.trim(); |
||||
maskeninfo_id = (Integer) dummy.elementAt(2); |
||||
parent = (Integer) dummy.elementAt(3); |
||||
erlaeuterung = (String) dummy.elementAt(4); |
||||
gueltig_seit = (java.sql.Date) dummy.elementAt(5); |
||||
gueltig_bis = (java.sql.Date) dummy.elementAt(6); |
||||
einEintrag = |
||||
new SxThemenEintrag2(tid, name, maskeninfo_id, parent, erlaeuterung,gueltig_seit,gueltig_bis); |
||||
themenbaum.addElement(einEintrag); |
||||
} |
||||
rohform = null; |
||||
SxThemenEintrag2 ebene0 = |
||||
new SxThemenEintrag2(null, "Abfragen/Berichte", null, null, null,null,null); |
||||
DefaultMutableTreeNode root = new DefaultMutableTreeNode(ebene0); |
||||
|
||||
//hier werden über eine rekursive Methode alle
|
||||
//Institute in den Baum eingetragen
|
||||
insertnodes(null, root); |
||||
themenbaum = null; |
||||
|
||||
//Baum erzeugen
|
||||
ltree = new JTree(root); |
||||
ltree.setRootVisible(false); |
||||
//root Abfragen/Berichte sieht man sowieso nicht
|
||||
//first child abfragen muss aufgeklappt sein
|
||||
//da Mouselistener Doubleclick umfunktioniert
|
||||
if (root.getChildCount() > 0) { |
||||
DefaultMutableTreeNode ebene1 = (DefaultMutableTreeNode) root.getChildAt(0); |
||||
ltree.expandPath(new TreePath(ebene1.getPath())); |
||||
} |
||||
|
||||
//Einfachselektion
|
||||
ltree.getSelectionModel().setSelectionMode( |
||||
TreeSelectionModel.SINGLE_TREE_SELECTION); |
||||
|
||||
InstRenderer renderer = new InstRenderer(); |
||||
//Markierungsrandfarbe grau nicht gelb
|
||||
// renderer.setBorderSelectionColor(java.awt.Color.darkGray);
|
||||
|
||||
InstEditor editor = new InstEditor(); |
||||
editor.addCellEditorListener(this); |
||||
ltree.setEditable(true); |
||||
ltree.setCellRenderer(renderer); |
||||
ltree.setCellEditor(new InstImmediateEditor(ltree, renderer, editor)); |
||||
|
||||
//TreeSelectionListener hinzufügen
|
||||
// AdminOrgaSelList adosl = new AdminOrgaSelList(this, ltree);
|
||||
// ltree.addTreeSelectionListener(adosl);
|
||||
|
||||
// AdminOrgaMouseListener ml =
|
||||
// new AdminOrgaMouseListener(this, ltree, merkungültig);
|
||||
// ltree.addMouseListener(ml);
|
||||
|
||||
linkToMain.setStatus(AnzahlEinträge + " ThemenEinträge eingelesen"); |
||||
|
||||
} |
||||
catch (Exception e) { |
||||
e.printStackTrace(); |
||||
JOptionPane.showMessageDialog( |
||||
null, |
||||
"Fehler bei Datenbankzugriff: " + e.toString(), |
||||
"GroupThemen", |
||||
1); |
||||
} |
||||
return ltree; |
||||
} |
||||
|
||||
private void wennMaskeÜberall(DefaultMutableTreeNode node, String was) { |
||||
Object userobj = node.getUserObject(); |
||||
DefaultMutableTreeNode aNode; |
||||
DefaultMutableTreeNode root = |
||||
(DefaultMutableTreeNode) tree.getModel().getRoot(); |
||||
|
||||
SxThemenEintrag2 test; |
||||
if (userobj instanceof SxThemenEintrag2) { |
||||
SxThemenEintrag2 x = (SxThemenEintrag2) userobj; |
||||
if (x.getMaskeninfo_id() != null) { |
||||
|
||||
for (Enumeration en = root.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
test = (SxThemenEintrag2) aNode.getUserObject(); |
||||
if (test.getMaskeninfo_id() != null |
||||
&& test.getMaskeninfo_id().equals(x.getMaskeninfo_id())) { |
||||
if (was.equals("freischalten")) |
||||
test.setErlaubt(true); |
||||
else |
||||
test.setErlaubt(false); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
} |
@ -1,52 +0,0 @@
@@ -1,52 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
import java.awt.Component; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
import javax.swing.JCheckBox; |
||||
import javax.swing.JTree; |
||||
import javax.swing.tree.DefaultMutableTreeNode; |
||||
|
||||
class InstEditor extends AbstractCellEditor { |
||||
InstEditorRenderer renderer; |
||||
DefaultMutableTreeNode lastEditedNode; |
||||
JCheckBox checkBox; |
||||
|
||||
public InstEditor() { |
||||
renderer = new InstEditorRenderer(); |
||||
checkBox = renderer.getCheckBox(); |
||||
|
||||
checkBox.addActionListener(new ActionListener() { |
||||
public void actionPerformed(ActionEvent e) { |
||||
Object userobj=lastEditedNode.getUserObject(); |
||||
if (userobj instanceof OrgaEintrag2) |
||||
{ |
||||
OrgaEintrag2 x=(OrgaEintrag2)userobj; |
||||
x.setErlaubt(checkBox.isSelected()); |
||||
} |
||||
if (userobj instanceof SxThemenEintrag2) |
||||
{ |
||||
SxThemenEintrag2 x=(SxThemenEintrag2)userobj; |
||||
x.setErlaubt(checkBox.isSelected()); |
||||
} |
||||
stopCellEditing(); |
||||
} |
||||
}); |
||||
} |
||||
public Object getCellEditorValue() { |
||||
return lastEditedNode.getUserObject(); |
||||
} |
||||
public DefaultMutableTreeNode getLastEditedNode() { |
||||
return lastEditedNode; |
||||
} |
||||
public Component getTreeCellEditorComponent( |
||||
JTree tree, Object value, |
||||
boolean selected, boolean expanded, |
||||
boolean leaf, int row) { |
||||
lastEditedNode = (DefaultMutableTreeNode)value; |
||||
|
||||
return renderer.getTreeCellRendererComponent(tree, |
||||
value, selected, expanded, |
||||
leaf, row, true); // hasFocus ignored
|
||||
} |
||||
} |
@ -1,21 +0,0 @@
@@ -1,21 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
import java.awt.Component; |
||||
|
||||
import javax.swing.JCheckBox; |
||||
import javax.swing.JTree; |
||||
class InstEditorRenderer extends InstRenderer { |
||||
public JCheckBox getCheckBox() { |
||||
return checkBox; |
||||
} |
||||
public Component getTreeCellRendererComponent( |
||||
JTree tree, Object value, |
||||
boolean selected, boolean expanded, |
||||
boolean leaf, int row, |
||||
boolean hasFocus) { |
||||
Component c = super.getTreeCellRendererComponent(tree, |
||||
value, selected, expanded, |
||||
leaf, row, hasFocus); |
||||
setIcon(null); |
||||
return c; |
||||
} |
||||
} |
@ -1,65 +0,0 @@
@@ -1,65 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
import java.awt.Dimension; |
||||
import java.awt.Rectangle; |
||||
import java.awt.event.MouseEvent; |
||||
import java.util.EventObject; |
||||
|
||||
import javax.swing.JTree; |
||||
import javax.swing.tree.DefaultMutableTreeNode; |
||||
import javax.swing.tree.DefaultTreeCellEditor; |
||||
import javax.swing.tree.TreePath; |
||||
|
||||
class InstImmediateEditor extends DefaultTreeCellEditor { |
||||
private InstRenderer renderer; |
||||
|
||||
public InstImmediateEditor(JTree tree, |
||||
InstRenderer renderer, |
||||
InstEditor editor) { |
||||
super(tree, renderer, editor); |
||||
this.renderer = renderer; |
||||
} |
||||
protected boolean canEditImmediately(EventObject e) { |
||||
boolean rv = false; // rv = return value
|
||||
|
||||
if(e instanceof MouseEvent) { |
||||
MouseEvent me = (MouseEvent)e; |
||||
rv = inCheckBoxHitRegion(me); |
||||
} |
||||
return rv; |
||||
} |
||||
public boolean shouldSelectCell(EventObject e) { |
||||
boolean rv = false; // only mouse events
|
||||
|
||||
if(e instanceof MouseEvent) { |
||||
MouseEvent me = (MouseEvent)e; |
||||
TreePath path = tree.getPathForLocation(me.getX(), |
||||
me.getY()); |
||||
//FileNode node = (FileNode)
|
||||
// path.getLastPathComponent();
|
||||
|
||||
rv = !inCheckBoxHitRegion(me); |
||||
} |
||||
return rv; |
||||
} |
||||
public boolean inCheckBoxHitRegion(MouseEvent e) { |
||||
TreePath path = tree.getPathForLocation(e.getX(), |
||||
e.getY()); |
||||
|
||||
if (path==null) return false; |
||||
boolean rv = false; |
||||
|
||||
DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent(); |
||||
// offset and lastRow DefaultTreeCellEditor
|
||||
// protected members
|
||||
|
||||
Rectangle bounds = tree.getRowBounds(lastRow); |
||||
Dimension checkBoxOffset = |
||||
renderer.getCheckBoxOffset(); |
||||
|
||||
//bounds.translate(offset + checkBoxOffset.width-21, checkBoxOffset.height);
|
||||
bounds.translate(10 ,0); |
||||
rv = bounds.contains(e.getPoint()); |
||||
|
||||
return rv; |
||||
} |
||||
} |
@ -1,125 +0,0 @@
@@ -1,125 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
import java.awt.Color; |
||||
import java.awt.Component; |
||||
import java.awt.Dimension; |
||||
import java.awt.FlowLayout; |
||||
import java.awt.FontMetrics; |
||||
import java.awt.Graphics; |
||||
import java.util.Enumeration; |
||||
|
||||
import javax.swing.Box; |
||||
import javax.swing.JCheckBox; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JTree; |
||||
import javax.swing.UIManager; |
||||
import javax.swing.tree.DefaultMutableTreeNode; |
||||
import javax.swing.tree.DefaultTreeCellRenderer; |
||||
|
||||
class InstRenderer extends DefaultTreeCellRenderer { |
||||
// protected JCheckBox checkBox = new JCheckBox(" ");
|
||||
protected JCheckBox checkBox = new JCheckBox(""); |
||||
private Component strut = Box.createHorizontalStrut(5); |
||||
private JPanel panel = new JPanel(); |
||||
|
||||
public InstRenderer() { |
||||
Color color = UIManager.getColor("Tree.textBackground"); |
||||
setBackground(color); |
||||
setBackgroundNonSelectionColor(color); |
||||
setBackgroundSelectionColor(color); |
||||
|
||||
panel.setBackground(color); |
||||
|
||||
setOpaque(false); |
||||
checkBox.setOpaque(false); |
||||
panel.setOpaque(false); |
||||
|
||||
panel.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0)); |
||||
panel.add(this); |
||||
//panel.add(strut);
|
||||
panel.add(checkBox); |
||||
|
||||
} |
||||
public Component getTreeCellRendererComponent( |
||||
JTree tree, |
||||
Object value, |
||||
boolean selected, |
||||
boolean expanded, |
||||
boolean leaf, |
||||
int row, |
||||
boolean hasFocus) { |
||||
DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; |
||||
|
||||
super.getTreeCellRendererComponent( |
||||
tree, |
||||
value, |
||||
selected, |
||||
expanded, |
||||
leaf, |
||||
row, |
||||
hasFocus); |
||||
boolean erl = false; |
||||
Object userobj = node.getUserObject(); |
||||
if (userobj instanceof OrgaEintrag2) { |
||||
OrgaEintrag2 x = (OrgaEintrag2) node.getUserObject(); |
||||
erl = x.getErlaubt().intValue() == 0 ? false : true; |
||||
} |
||||
if (userobj instanceof SxThemenEintrag2) { |
||||
SxThemenEintrag2 x = (SxThemenEintrag2) node.getUserObject(); |
||||
erl = x.isErlaubt(); |
||||
} |
||||
checkBox.setSelected(erl); |
||||
if (erl) |
||||
this.setForeground(new Color(0, 200, 0)); |
||||
else |
||||
this.setForeground(colorcheck(node)); |
||||
|
||||
return panel; |
||||
} |
||||
|
||||
private Color colorcheck(DefaultMutableTreeNode node) { |
||||
Color ergfarbe = Color.red; |
||||
|
||||
DefaultMutableTreeNode aNode; |
||||
OrgaEintrag2 x; |
||||
SxThemenEintrag2 y; |
||||
Object userobj; |
||||
for (Enumeration en = node.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
userobj = aNode.getUserObject(); |
||||
if (userobj instanceof OrgaEintrag2) { |
||||
x = (OrgaEintrag2) userobj; |
||||
if (x.getErlaubt().intValue() == 1) { |
||||
ergfarbe = new Color(130, 90, 0); |
||||
break; |
||||
} |
||||
} |
||||
|
||||
if (userobj instanceof SxThemenEintrag2) { |
||||
y = (SxThemenEintrag2) userobj; |
||||
if (y.isErlaubt() == true) { |
||||
ergfarbe = new Color(130, 90, 0); |
||||
break; |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
return ergfarbe; |
||||
} |
||||
|
||||
public Dimension getCheckBoxOffset() { |
||||
Graphics g = panel.getGraphics(); |
||||
int xoffset = 0; |
||||
|
||||
if (g != null) { |
||||
try { |
||||
FontMetrics fm = g.getFontMetrics(); |
||||
xoffset = fm.stringWidth(getText());// + strut.getPreferredSize().width;
|
||||
} |
||||
finally { |
||||
g.dispose(); |
||||
} |
||||
} |
||||
return new Dimension(xoffset, 0); |
||||
} |
||||
} |
@ -1,104 +0,0 @@
@@ -1,104 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
import java.util.Enumeration; |
||||
import java.util.Vector; |
||||
|
||||
import javax.swing.JComboBox; |
||||
class MBComboBox extends JComboBox { |
||||
/** |
||||
* MBComboBox constructor comment. |
||||
*/ |
||||
// JComboBox box;
|
||||
Vector daten, zeile; |
||||
String einItem; |
||||
public MBComboBox() { |
||||
super(); |
||||
this.setEditable(false); |
||||
} |
||||
public MBComboBox(Vector daten) { |
||||
super(); |
||||
this.setEditable(false); |
||||
addAll(daten); |
||||
} |
||||
public void addAll(Vector ldaten) |
||||
{ |
||||
daten = ldaten; |
||||
|
||||
for (Enumeration el = daten.elements(); el.hasMoreElements();) { |
||||
zeile=new Vector(); |
||||
zeile = ((Vector) el.nextElement()); |
||||
einItem=(String)zeile.get(1); |
||||
this.addItem(einItem); |
||||
} |
||||
} |
||||
|
||||
|
||||
public void neuAufbauen(Vector ldaten) { |
||||
Vector zeile; |
||||
daten = ldaten; |
||||
this.removeAllItems(); |
||||
for (Enumeration el = daten.elements(); el.hasMoreElements();) { |
||||
zeile = ((Vector) el.nextElement()); |
||||
einItem=(String)zeile.get(1); |
||||
this.addItem(einItem); |
||||
} |
||||
} |
||||
|
||||
public int getSelectedID() { |
||||
Vector zeile; |
||||
int rückgabe = -999; |
||||
Integer umr; |
||||
String umr1; |
||||
String x = (String)super.getSelectedItem(); |
||||
//daten durchsuchen bis gefunden
|
||||
for (Enumeration el = daten.elements(); el.hasMoreElements();) { |
||||
zeile = ((Vector) el.nextElement()); |
||||
einItem=(String)zeile.get(1); |
||||
if (einItem.equals(x)) { |
||||
umr = (Integer) zeile.get(0); |
||||
rückgabe = umr.intValue(); |
||||
break; |
||||
} |
||||
|
||||
} |
||||
return rückgabe; |
||||
} |
||||
|
||||
public void setSelection(String was) |
||||
// für erscheinenden Text
|
||||
{ |
||||
String item; |
||||
String eintrag;Object help; |
||||
was = was.trim(); |
||||
for (int i = 0; i < this.getItemCount(); i++) { |
||||
eintrag = (String) this.getItemAt(i); |
||||
eintrag = eintrag.trim(); |
||||
if (was.equals(eintrag)) { |
||||
help=this.getItemAt(i); |
||||
this.setSelectedItem(help); |
||||
this.validate(); |
||||
this.repaint(); |
||||
break; |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
public void setSelection(int ID) |
||||
//für interne ID
|
||||
{ |
||||
Integer testid; |
||||
String was=null; |
||||
|
||||
for (Enumeration el = daten.elements(); el.hasMoreElements();) { |
||||
zeile = ((Vector) el.nextElement()); |
||||
testid = (Integer) zeile.get(0); |
||||
if (testid.intValue() == ID) { |
||||
einItem=(String)zeile.get(1); |
||||
setSelection(einItem); |
||||
break; |
||||
|
||||
} |
||||
} |
||||
|
||||
} |
||||
} |
File diff suppressed because one or more lines are too long
@ -1,33 +0,0 @@
@@ -1,33 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
import javax.swing.event.TreeModelEvent; |
||||
import javax.swing.event.TreeModelListener; |
||||
import javax.swing.tree.DefaultMutableTreeNode; |
||||
|
||||
class MBDragModelListener implements TreeModelListener { |
||||
public void treeNodesChanged(TreeModelEvent e) { |
||||
DefaultMutableTreeNode node; |
||||
node = (DefaultMutableTreeNode) |
||||
(e.getTreePath().getLastPathComponent()); |
||||
|
||||
/* |
||||
* If the event lists children, then the changed |
||||
* node is the child of the node we've already |
||||
* gotten. Otherwise, the changed node and the |
||||
* specified node are the same. |
||||
*/ |
||||
try { |
||||
int index = e.getChildIndices()[0]; |
||||
node = (DefaultMutableTreeNode) |
||||
(node.getChildAt(index)); |
||||
} catch (NullPointerException exc) {} |
||||
|
||||
// System.out.println("The user has finished editing the node.");
|
||||
// System.out.println("New value: " + node.getUserObject());
|
||||
} |
||||
public void treeNodesInserted(TreeModelEvent e) { |
||||
} |
||||
public void treeNodesRemoved(TreeModelEvent e) { |
||||
} |
||||
public void treeStructureChanged(TreeModelEvent e) { |
||||
} |
||||
} |
@ -1,137 +0,0 @@
@@ -1,137 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
|
||||
import java.awt.Point; |
||||
import java.awt.datatransfer.Transferable; |
||||
import java.awt.dnd.DnDConstants; |
||||
import java.awt.dnd.DragGestureEvent; |
||||
import java.awt.dnd.DragGestureListener; |
||||
import java.awt.dnd.DragSource; |
||||
import java.awt.dnd.DragSourceDragEvent; |
||||
import java.awt.dnd.DragSourceDropEvent; |
||||
import java.awt.dnd.DragSourceEvent; |
||||
import java.awt.dnd.DragSourceListener; |
||||
import java.awt.dnd.DropTarget; |
||||
import java.awt.dnd.DropTargetDragEvent; |
||||
import java.awt.dnd.DropTargetDropEvent; |
||||
import java.awt.dnd.DropTargetEvent; |
||||
import java.awt.dnd.DropTargetListener; |
||||
import java.util.Enumeration; |
||||
|
||||
import javax.swing.tree.DefaultMutableTreeNode; |
||||
import javax.swing.tree.DefaultTreeModel; |
||||
import javax.swing.tree.TreePath; |
||||
|
||||
import de.memtext.tree.AutoScrollJTree; |
||||
|
||||
class MBDragTree extends AutoScrollJTree implements DragGestureListener, |
||||
DragSourceListener, DropTargetListener { |
||||
|
||||
public MBDragTree() { |
||||
|
||||
DragSource dragSource = DragSource.getDefaultDragSource(); |
||||
|
||||
dragSource.createDefaultDragGestureRecognizer(this, // component where
|
||||
// drag originates
|
||||
DnDConstants.ACTION_MOVE, // actions
|
||||
this); // drag gesture recognizer
|
||||
|
||||
DropTarget dropTarget = new DropTarget(this, DnDConstants.ACTION_MOVE, |
||||
this); |
||||
|
||||
} |
||||
|
||||
//source
|
||||
public void dragDropEnd(DragSourceDropEvent e) { |
||||
} |
||||
|
||||
public void dragEnter(DragSourceDragEvent e) { |
||||
} |
||||
|
||||
public void dragEnter(DropTargetDragEvent e) { |
||||
} |
||||
|
||||
public void dragExit(DragSourceEvent e) { |
||||
} |
||||
|
||||
public void dragExit(DropTargetEvent e) { |
||||
} |
||||
|
||||
public void dragGestureRecognized(DragGestureEvent e) { |
||||
|
||||
TreePath path = this.getLeadSelectionPath(); |
||||
DefaultMutableTreeNode was = (DefaultMutableTreeNode) path |
||||
.getLastPathComponent(); |
||||
Transferable tr = (Transferable) was.getUserObject(); |
||||
|
||||
e.startDrag(DragSource.DefaultMoveDrop, // cursor
|
||||
tr, // transferable
|
||||
this); // drag source listener
|
||||
} |
||||
|
||||
public void dragOver(DragSourceDragEvent e) { |
||||
} |
||||
|
||||
public void dragOver(DropTargetDragEvent e) { |
||||
e.acceptDrag(DnDConstants.ACTION_MOVE); |
||||
} |
||||
|
||||
//target
|
||||
public void drop(DropTargetDropEvent e) { |
||||
try { |
||||
TreePath path = this.getLeadSelectionPath(); |
||||
DefaultMutableTreeNode verschiebNode = (DefaultMutableTreeNode) path |
||||
.getLastPathComponent(); |
||||
DefaultMutableTreeNode oldparent = (DefaultMutableTreeNode) verschiebNode |
||||
.getParent(); |
||||
verschiebNode.removeFromParent(); |
||||
String newParentKeyApnr; |
||||
|
||||
//Transferable tr=e.getTransferable();
|
||||
Point loc = e.getLocation(); |
||||
TreePath destinationPath = this.getPathForLocation(loc.x, loc.y); |
||||
DefaultMutableTreeNode newParent = (DefaultMutableTreeNode) destinationPath |
||||
.getLastPathComponent(); |
||||
OrgaEintrag2 newParentOrgaEintrag = (OrgaEintrag2) newParent |
||||
.getUserObject(); |
||||
newParentKeyApnr = newParentOrgaEintrag.getKeyApnr(); |
||||
|
||||
newParent.add(verschiebNode); |
||||
OrgaEintrag2 verschiebOrgaEintrag = (OrgaEintrag2) verschiebNode |
||||
.getUserObject(); |
||||
//parent anpassen
|
||||
verschiebOrgaEintrag.setParent(newParentKeyApnr); |
||||
//Ebene knoten selbst + alle Unterknoten anpassen
|
||||
Integer neueEbene = new Integer(verschiebNode.getLevel() - 1); |
||||
verschiebOrgaEintrag.setEbene(neueEbene); |
||||
DefaultMutableTreeNode aNode; |
||||
OrgaEintrag2 x; |
||||
for (Enumeration en = verschiebNode.depthFirstEnumeration(); en |
||||
.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
neueEbene = new Integer(aNode.getLevel() - 1); |
||||
x = (OrgaEintrag2) aNode.getUserObject(); |
||||
x.setEbene(neueEbene); |
||||
} |
||||
|
||||
e.acceptDrop(DnDConstants.ACTION_MOVE); |
||||
e.getDropTargetContext().dropComplete(true); |
||||
//model neu laden und Ast aufklappen
|
||||
DefaultTreeModel model = (DefaultTreeModel) getModel(); |
||||
model.reload(oldparent); |
||||
model.reload(newParent); |
||||
TreePath parentPath = new TreePath(newParent.getPath()); |
||||
expandPath(parentPath); |
||||
} catch (Exception ex) { |
||||
ex.printStackTrace(); |
||||
} |
||||
this.validate(); |
||||
this.repaint(); |
||||
} |
||||
|
||||
public void dropActionChanged(DragSourceDragEvent e) { |
||||
} |
||||
|
||||
public void dropActionChanged(DropTargetDragEvent e) { |
||||
} |
||||
|
||||
} |
@ -1,49 +0,0 @@
@@ -1,49 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
/** |
||||
* Insert the type's description here. |
||||
* Creation date: (24.09.2001 14:47:19) |
||||
* @author: Administrator |
||||
*/ |
||||
|
||||
import java.awt.BorderLayout; |
||||
import java.awt.Container; |
||||
import java.awt.GridLayout; |
||||
|
||||
import javax.swing.JFrame; |
||||
import javax.swing.JLabel; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JProgressBar; |
||||
import javax.swing.JTextField; |
||||
|
||||
class MBProgressBar extends JFrame { |
||||
|
||||
JTextField progressTextField; |
||||
JProgressBar progressBar; |
||||
|
||||
public MBProgressBar (int max) { |
||||
Container cp=this.getContentPane(); |
||||
cp.setLayout(new BorderLayout()); |
||||
|
||||
progressTextField = new JTextField("Titel"); |
||||
cp.add(progressTextField, BorderLayout.NORTH); |
||||
|
||||
JPanel bottomPanel = new JPanel(); |
||||
progressBar = new JProgressBar(); |
||||
|
||||
progressBar.setMinimum(0); |
||||
progressBar.setMaximum(max); |
||||
|
||||
progressBar.setStringPainted(true); |
||||
bottomPanel.setLayout(new GridLayout(0,1)); |
||||
bottomPanel.add(progressBar); |
||||
bottomPanel.add(new JLabel("Status")); |
||||
cp.add(bottomPanel, BorderLayout.SOUTH); |
||||
this.pack(); |
||||
this.show(); |
||||
} |
||||
public void inc() |
||||
{ |
||||
int value = progressBar.getValue(); |
||||
progressBar.setValue(value+1); |
||||
} |
||||
} |
@ -1,82 +0,0 @@
@@ -1,82 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Container; |
||||
import java.awt.Frame; |
||||
import java.awt.Point; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.util.Vector; |
||||
|
||||
import javax.swing.JButton; |
||||
import javax.swing.JDialog; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JScrollPane; |
||||
import javax.swing.JTable; |
||||
|
||||
class MBTableSelect extends JDialog implements ActionListener { |
||||
JTable table; |
||||
JScrollPane scrollPane; |
||||
Vector rows; |
||||
public MBTableSelect(Frame owner, String title, Vector lrows, Vector colnames,boolean hidecol1, int selectionMode) { |
||||
super(owner, title, true); |
||||
Vector rows=lrows; |
||||
Point parloc = owner.getLocation(); |
||||
setLocation(parloc.x + 30, parloc.y + 30); |
||||
/*Windows-Look |
||||
String plaf = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"; |
||||
try { |
||||
|
||||
UIManager.setLookAndFeel(plaf); |
||||
SwingUtilities.updateComponentTreeUI(this); |
||||
} catch (Exception e) { |
||||
System.err.println(e.toString()); |
||||
}*/ |
||||
|
||||
//Fenster
|
||||
Container cp = getContentPane(); |
||||
cp.setLayout(new BorderLayout()); |
||||
|
||||
table=new JTable(rows,colnames); |
||||
//table.setSelectionMode(selectionMode);
|
||||
|
||||
scrollPane=new JScrollPane(table); |
||||
cp.add(scrollPane,"Center"); |
||||
JButton OK=new JButton("OK"); |
||||
OK.addActionListener(this); |
||||
JButton Abbr=new JButton("Abbrechen"); |
||||
Abbr.addActionListener(this); |
||||
JPanel down=new JPanel(); |
||||
down.add(OK);down.add(Abbr); |
||||
cp.add(down,"South"); |
||||
this.pack(); |
||||
this.repaint(); |
||||
} |
||||
|
||||
public void actionPerformed(ActionEvent event) { |
||||
String cmd=event.getActionCommand(); |
||||
if (cmd.equals("Abbrechen")) { |
||||
table.clearSelection(); |
||||
this.setVisible(false); |
||||
this.dispose(); |
||||
} |
||||
|
||||
if (cmd.equals("OK")) { |
||||
this.setVisible(false); |
||||
this.dispose(); |
||||
} |
||||
|
||||
} |
||||
|
||||
public Vector getGewählt() |
||||
{ |
||||
int[] selectedrows=table.getSelectedRows(); |
||||
Vector erg=new Vector(); |
||||
for (int i=0;i<selectedrows.length;i++) |
||||
{ |
||||
erg.add((Vector)rows.get(selectedrows[i])); |
||||
|
||||
} |
||||
return erg; |
||||
} |
||||
|
||||
} |
@ -1,400 +0,0 @@
@@ -1,400 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
import java.awt.Dimension; |
||||
import java.awt.FlowLayout; |
||||
import java.awt.GridLayout; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.security.MessageDigest; |
||||
import java.util.Enumeration; |
||||
import java.util.Vector; |
||||
|
||||
import javax.swing.JButton; |
||||
import javax.swing.JLabel; |
||||
import javax.swing.JOptionPane; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JScrollPane; |
||||
import javax.swing.JTextArea; |
||||
import javax.swing.JTextField; |
||||
|
||||
/** |
||||
* Insert the type's description here. |
||||
* Creation date: (25.03.2002 15:18:32) |
||||
* @author: |
||||
*/ |
||||
class MaskeAendern extends JPanel implements ActionListener { |
||||
SuperXDBAdmin linkToMain; |
||||
Vector liste; |
||||
MBComboBox mbt; |
||||
JTextField tname = new JTextField(50); |
||||
JTextArea terläuterung=new JTextArea(60,2); |
||||
JTextArea tselect=new JTextArea(60,6); |
||||
JTextArea tcleanup=new JTextArea(60,2); |
||||
JTextArea txil=new JTextArea(60,2); |
||||
|
||||
public MaskeAendern(SuperXDBAdmin llinkToMain) { |
||||
super(); |
||||
linkToMain = llinkToMain; |
||||
mbt=new MBComboBox(DBAccess.getMaskenListe()); |
||||
//mbt.AddActionListener(this);
|
||||
this.setLayout(new GridLayout(7, 1)); |
||||
JPanel p0 = new JPanel(); |
||||
p0.add(mbt); |
||||
this.add(p0); |
||||
JPanel p1 = new JPanel(); |
||||
JLabel lname = new JLabel("Name:"); |
||||
|
||||
p1.add(lname); |
||||
p1.add(tname); |
||||
JPanel p2=new JPanel(new FlowLayout()); |
||||
JLabel lerl=new JLabel("Erläuterung"); |
||||
p2.add(lerl); |
||||
|
||||
terläuterung.setLineWrap(true); |
||||
terläuterung.setWrapStyleWord(true); |
||||
terläuterung.setEditable(true); |
||||
|
||||
JScrollPane terlscroll=new JScrollPane(terläuterung); |
||||
terlscroll.setPreferredSize(new Dimension(350,40)); |
||||
p2.add(terlscroll); |
||||
this.add(p2); |
||||
|
||||
JPanel p3=new JPanel(new FlowLayout()); |
||||
JLabel lselect=new JLabel("Select Statement"); |
||||
p3.add(lselect); |
||||
|
||||
tselect.setLineWrap(true); |
||||
tselect.setWrapStyleWord(true); |
||||
tselect.setEditable(true); |
||||
|
||||
JScrollPane tselectscroll=new JScrollPane(tselect); |
||||
tselectscroll.setPreferredSize(new Dimension(350,100)); |
||||
p3.add(tselectscroll); |
||||
this.add(p3); |
||||
|
||||
JPanel p4=new JPanel(new FlowLayout()); |
||||
JLabel lcleanup=new JLabel("Cleanup Statement"); |
||||
p4.add(lcleanup); |
||||
|
||||
tcleanup.setLineWrap(true); |
||||
tcleanup.setWrapStyleWord(true); |
||||
tcleanup.setEditable(true); |
||||
|
||||
JScrollPane tcleanupscroll=new JScrollPane(tcleanup); |
||||
tcleanupscroll.setPreferredSize(new Dimension(350,40)); |
||||
p4.add(tcleanupscroll); |
||||
this.add(p4); |
||||
|
||||
JPanel p5=new JPanel(new FlowLayout()); |
||||
JLabel lxil=new JLabel("XIL List"); |
||||
p5.add(lxil); |
||||
|
||||
txil.setLineWrap(false); |
||||
txil.setWrapStyleWord(false); |
||||
tcleanup.setEditable(true); |
||||
|
||||
JScrollPane txilscroll=new JScrollPane(txil); |
||||
txilscroll.setPreferredSize(new Dimension(350,100)); |
||||
p5.add(txilscroll); |
||||
this.add(p5); |
||||
|
||||
JPanel p6 = new JPanel(); |
||||
JButton bspeich = new JButton("speichern"); |
||||
bspeich.addActionListener(this); |
||||
p5.add(bspeich); |
||||
this.add(p6); |
||||
|
||||
maskeGewählt(); |
||||
} |
||||
|
||||
public void actionPerformed(ActionEvent event) { |
||||
// if (event.getActionCommand().equals("speichern"))
|
||||
// NutzerRechteSpeichern();
|
||||
if (event.getActionCommand().equals("speichern")) |
||||
maskenDatenSpeichern(); |
||||
|
||||
|
||||
Object src = event.getSource(); |
||||
if (src instanceof MBComboBox) { |
||||
MBComboBox localbox = (MBComboBox) event.getSource(); |
||||
|
||||
|
||||
//linkToMain.setSelectedUser(localbox.getSelectedID());
|
||||
|
||||
|
||||
maskeGewählt(); |
||||
} |
||||
|
||||
} |
||||
|
||||
private void maskenDatenSpeichern() { |
||||
try { |
||||
|
||||
if (terläuterung.getText().length()>240||tcleanup.getText().length()>240) |
||||
{ |
||||
// info=info.substring(0,254);
|
||||
JOptionPane.showMessageDialog( |
||||
null, |
||||
"Achtung! Es wurden nur die ersten 240 Zeichen der Felder Erläuterung und Cleanup gespeichert ", |
||||
"SuperX DB Admin", |
||||
JOptionPane.WARNING_MESSAGE); |
||||
} |
||||
int tid=mbt.getSelectedID(); |
||||
String upd = |
||||
"update maskeninfo set name=" |
||||
+ DBAccess.getStringOrNull(tname.getText()) |
||||
+ ",erlaeuterung=" |
||||
+ DBAccess.getStringOrNull(terläuterung.getText()) |
||||
+ ",select_stmt=" |
||||
+ DBAccess.getStringOrNull(tselect.getText()) |
||||
+ ",cleanup_stmt=" |
||||
+ DBAccess.getStringOrNull(tcleanup.getText()) |
||||
+ " ,xil_proplist=" |
||||
+ DBAccess.getStringOrNull(txil.getText()) |
||||
+ " where tid=" |
||||
+ tid; |
||||
System.out.println(upd); |
||||
DBAccess.executeUpdate(upd); |
||||
linkToMain.setStatus("Maske aktualisiert!"); |
||||
// DBAccess.UserListeNeuEinlesen();
|
||||
mbt.neuAufbauen(DBAccess.getMaskenListe()); |
||||
mbt.setSelection(tid); |
||||
} |
||||
catch (Exception e) { |
||||
JOptionPane.showMessageDialog( |
||||
null, |
||||
"Fehler beim Schreiben in die Datenbank:\n " + e.toString(), |
||||
"SuperX DB Admin", |
||||
JOptionPane.WARNING_MESSAGE); |
||||
|
||||
e.printStackTrace(); |
||||
System.exit(-1); |
||||
} |
||||
|
||||
} |
||||
|
||||
/* public Vector NutzerListeEinlesen() { |
||||
liste = new Vector(); |
||||
Vector row; |
||||
Integer id; |
||||
String benutzer, email, name, max_versuch, akt_versuch, info; |
||||
|
||||
try { |
||||
|
||||
String query = |
||||
"select tid, benutzer,name,email,info,max_versuch,akt_versuch,passwd_sha from userinfo order by benutzer"; |
||||
Statement statement = myConnection.createStatement(); |
||||
ResultSet rs1 = statement.executeQuery(query); |
||||
while (rs1.next()) { |
||||
name=rs1.getString("passwd_sha"); |
||||
id = (Integer) rs1.getObject("tid"); |
||||
benutzer = rs1.getObject("benutzer").toString(); |
||||
email = DBAccess.getString(rs1, "email"); |
||||
info= DBAccess.getString(rs1,"info"); |
||||
name = DBAccess.getString(rs1, "name"); |
||||
max_versuch = DBAccess.getString(rs1, "max_versuch"); |
||||
akt_versuch = DBAccess.getString(rs1, "akt_versuch"); |
||||
row = new Vector(); |
||||
row.add(id); |
||||
row.add(benutzer); |
||||
row.add(name); |
||||
row.add(email); |
||||
row.add(info); |
||||
row.add(max_versuch); |
||||
row.add(akt_versuch); |
||||
liste.add(row); |
||||
|
||||
} |
||||
rs1.close(); |
||||
statement.close(); |
||||
|
||||
} |
||||
catch (Exception e) { |
||||
JOptionPane.showMessageDialog( |
||||
null, |
||||
"Fehler beim Lesen aus der Datenbank: " + e.toString(), |
||||
"SuperX DB Admin", |
||||
JOptionPane.WARNING_MESSAGE); |
||||
e.printStackTrace(); |
||||
} |
||||
return liste; |
||||
}*/ |
||||
|
||||
private void maskeGewählt() { |
||||
Vector zeile; |
||||
Integer test; |
||||
String help;Object help2; |
||||
for (Enumeration el = DBAccess.getMaskenListe().elements(); el.hasMoreElements();) { |
||||
zeile = ((Vector) el.nextElement()); |
||||
test = (Integer) zeile.get(0); |
||||
if (test.intValue() == mbt.getSelectedID()) { |
||||
tname.setText((String) zeile.get(1)); |
||||
tname.setCaretPosition(0); |
||||
terläuterung.setText((String) zeile.get(2)); |
||||
terläuterung.setCaretPosition(0); |
||||
tselect.setText((String)zeile.get(3)); |
||||
tselect.setCaretPosition(0); |
||||
tcleanup.setText((String)zeile.get(4)); |
||||
tcleanup.setCaretPosition(0); |
||||
txil.setText((String)zeile.get(5)); |
||||
tcleanup.setCaretPosition(0); |
||||
|
||||
// System.out.println("Erl. Länge:"+terläuterung.getText().length());
|
||||
} |
||||
} |
||||
|
||||
this.repaint(); |
||||
|
||||
} |
||||
|
||||
private void newPassword() { |
||||
try { |
||||
String passwd = |
||||
JOptionPane.showInputDialog( |
||||
this, |
||||
"Neues Passwort", |
||||
"SuperX", |
||||
JOptionPane.QUESTION_MESSAGE); |
||||
if (passwd==null) throw new Exception("Aktion abgebrochen"); |
||||
String passwd2 = |
||||
JOptionPane.showInputDialog( |
||||
this, |
||||
"Passwort bestätigen", |
||||
"SuperX", |
||||
JOptionPane.QUESTION_MESSAGE); |
||||
|
||||
if (passwd.equals(passwd2)) { |
||||
|
||||
|
||||
String upd_passwd_sha = null; |
||||
byte[] buf = passwd.getBytes(); |
||||
byte[] digest = null; |
||||
StringBuffer passwd_str = new StringBuffer(); |
||||
String value; |
||||
int n; |
||||
|
||||
MessageDigest sha = MessageDigest.getInstance("SHA-1"); |
||||
sha.update(buf); |
||||
digest = sha.digest(); |
||||
|
||||
for (int i = 0; i < digest.length; i++) { |
||||
n = (int) digest[i]; |
||||
if (n < 0) |
||||
n += 256; |
||||
value = Integer.toHexString(n); |
||||
if (n < 16) |
||||
value = "0" + value; |
||||
passwd_str.append(value); |
||||
} |
||||
|
||||
upd_passwd_sha = |
||||
"update userinfo set passwd_sha = '" |
||||
+ passwd_str |
||||
+ "'" |
||||
+ " where tid = " |
||||
+ linkToMain.getSelectedUser(); |
||||
|
||||
DBAccess.executeUpdate(upd_passwd_sha); |
||||
linkToMain.setStatus("Password geändert"); |
||||
|
||||
} |
||||
else |
||||
JOptionPane.showMessageDialog( |
||||
null, |
||||
"Eingaben stimmten nicht überein!", |
||||
"SuperX", |
||||
JOptionPane.WARNING_MESSAGE); |
||||
|
||||
} |
||||
catch (Exception e) { |
||||
linkToMain.setStatus("Password nicht geändert!! "+e.toString()); |
||||
} |
||||
|
||||
} |
||||
|
||||
private void benutzerLöschen() { |
||||
int rc = |
||||
JOptionPane.showConfirmDialog( |
||||
null, |
||||
"Benutzer wirklich löschen?", |
||||
"SuperX", |
||||
JOptionPane.YES_NO_OPTION); |
||||
if (rc == JOptionPane.YES_OPTION) { |
||||
try { |
||||
|
||||
|
||||
DBAccess.executeUpdate("delete from user_masken_bez where userinfo_id=" + linkToMain.getSelectedUser()); |
||||
DBAccess.executeUpdate("delete from user_institution where userid=" + linkToMain.getSelectedUser()); |
||||
DBAccess.executeUpdate("delete from user_group_bez where userinfo_id=" + linkToMain.getSelectedUser()); |
||||
DBAccess.executeUpdate("delete from protokoll where userinfo_id=" + linkToMain.getSelectedUser()); |
||||
DBAccess.executeUpdate("delete from userinfo where tid=" + linkToMain.getSelectedUser()); |
||||
linkToMain.setStatus("Benutzer gelöscht"); |
||||
DBAccess.userListeNeuEinlesen(); |
||||
mbt.neuAufbauen(DBAccess.getUserListe()); |
||||
linkToMain.setSelectedUser(mbt.getSelectedID()); |
||||
} |
||||
catch (Exception e) { |
||||
linkToMain.setStatus("Ein Fehler ist aufgetreten - Benutzer nicht gelöscht"); |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
private void benutzerAnlegen() |
||||
{ |
||||
try { |
||||
|
||||
Integer tid=(Integer)DBAccess.executeQuerySingleValue("select max(tid) as tid from userinfo"); |
||||
int newtid=tid.intValue()+1; |
||||
|
||||
String kennung = |
||||
JOptionPane.showInputDialog( |
||||
this, |
||||
"Kennung eingeben", |
||||
"SuperX", |
||||
JOptionPane.QUESTION_MESSAGE); |
||||
String ins="insert into userinfo values ("+newtid+",'"+kennung+"','',null,5,0,null,0,0,null,null)"; |
||||
DBAccess.executeUpdate(ins); |
||||
|
||||
//Startpasswort anfang setzten
|
||||
String upd_passwd_sha = null; |
||||
String passwd="anfang"; |
||||
byte[] buf = passwd.getBytes(); |
||||
byte[] digest = null; |
||||
StringBuffer passwd_str = new StringBuffer(); |
||||
String value; |
||||
int n; |
||||
|
||||
MessageDigest sha = MessageDigest.getInstance("SHA-1"); |
||||
sha.update(buf); |
||||
digest = sha.digest(); |
||||
|
||||
for (int i = 0; i < digest.length; i++) { |
||||
n = (int) digest[i]; |
||||
if (n < 0) |
||||
n += 256; |
||||
value = Integer.toHexString(n); |
||||
if (n < 16) |
||||
value = "0" + value; |
||||
passwd_str.append(value); |
||||
} |
||||
|
||||
upd_passwd_sha = |
||||
"update userinfo set passwd_sha = '" |
||||
+ passwd_str |
||||
+ "'" |
||||
+ " where tid = " |
||||
+ newtid; |
||||
|
||||
DBAccess.executeUpdate(upd_passwd_sha); |
||||
DBAccess.userListeNeuEinlesen(); |
||||
mbt.neuAufbauen(DBAccess.getUserListe()); |
||||
mbt.setSelection(kennung); |
||||
maskeGewählt(); |
||||
linkToMain.setStatus("Benutzer mit Standardpasswort angelegt!"); |
||||
} |
||||
catch (Exception e) |
||||
{ |
||||
linkToMain.setStatus("Interner Fehler: "+e.toString()); |
||||
} |
||||
} |
||||
} |
@ -1,84 +0,0 @@
@@ -1,84 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
import java.awt.Container; |
||||
import java.awt.Font; |
||||
import java.awt.Frame; |
||||
import java.awt.GridLayout; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
import javax.swing.JButton; |
||||
import javax.swing.JLabel; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JTextField; |
||||
class Maskenauswahl extends javax.swing.JDialog implements ActionListener { |
||||
Container cp; |
||||
JTextField tnummer; |
||||
int gewählt=-1; |
||||
MBComboBox mcb; |
||||
|
||||
public Maskenauswahl(Frame owner) { |
||||
super(owner, "Maskenauswahl", true); |
||||
cp = getContentPane(); |
||||
cp.setLayout(new GridLayout(4, 1)); |
||||
JPanel titel = new JPanel(); |
||||
JLabel ltitel = new JLabel("Nummer der Maske eingeben oder auswählen:"); |
||||
ltitel.setFont(new Font("Arial", Font.BOLD, 14)); |
||||
titel.add(ltitel); |
||||
cp.add(titel); |
||||
JPanel top = new JPanel(); |
||||
|
||||
JLabel lnr = new JLabel("Nummer:"); |
||||
top.add(lnr); |
||||
tnummer = new JTextField(7); |
||||
top.add(tnummer); |
||||
cp.add(top); |
||||
JPanel combob=new JPanel(); |
||||
mcb=new MBComboBox(DBAccess.getMaskenListe()); |
||||
combob.add(mcb); |
||||
cp.add(combob); |
||||
|
||||
JPanel down = new JPanel(); |
||||
JButton bok = new JButton("OK"); |
||||
bok.addActionListener(this); |
||||
down.add(bok); |
||||
JButton babbr = new JButton("Abbrechen"); |
||||
babbr.addActionListener(this); |
||||
down.add(babbr); |
||||
cp.add(down); |
||||
pack(); |
||||
setLocation(200, 200); |
||||
|
||||
} |
||||
public void actionPerformed(ActionEvent event) { |
||||
if (event.getActionCommand().equals("OK")) { |
||||
gewählt=mcb.getSelectedID(); |
||||
|
||||
String tb = tnummer.getText(); |
||||
if (tb.length()>1) |
||||
try { |
||||
Integer dummy = new Integer(tb); |
||||
gewählt = dummy.intValue(); |
||||
} |
||||
catch (Exception e) { |
||||
gewählt = -1; |
||||
} |
||||
|
||||
|
||||
this.setVisible(false); |
||||
} |
||||
|
||||
|
||||
|
||||
if (event.getActionCommand().equals("Abbrechen")) { |
||||
|
||||
gewählt = -1; |
||||
this.setVisible(false); |
||||
} |
||||
|
||||
} |
||||
public int getGewählt() |
||||
{ |
||||
return gewählt; |
||||
} |
||||
|
||||
} |
@ -1,96 +0,0 @@
@@ -1,96 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
import java.awt.Font; |
||||
import java.awt.GridLayout; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.sql.Connection; |
||||
|
||||
import javax.swing.JButton; |
||||
import javax.swing.JLabel; |
||||
import javax.swing.JOptionPane; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JTextField; |
||||
/** |
||||
* Insert the type's description here. |
||||
* Creation date: (21.01.2002 15:14:04) |
||||
* @author: |
||||
*/ |
||||
class Nachricht extends JPanel implements ActionListener { |
||||
Connection myConnection; |
||||
SuperXDBAdmin linkToMain; |
||||
JTextField tnachricht = new JTextField(30); |
||||
|
||||
public Nachricht(SuperXDBAdmin llinkToMain, Connection conn) { |
||||
super(); |
||||
linkToMain = llinkToMain; |
||||
myConnection = conn; |
||||
this.setLayout(new GridLayout(3, 1)); |
||||
JPanel p = new JPanel(); |
||||
JLabel lbl = new JLabel("Aktuelle Nachricht"); |
||||
lbl.setFont(new Font("Arial", Font.BOLD, 14)); |
||||
p.add(lbl); |
||||
this.add(p); |
||||
JPanel p0 = new JPanel(); |
||||
p0.add(tnachricht); |
||||
this.add(p0); |
||||
JPanel p1 = new JPanel(); |
||||
JButton bspeich = new JButton("speichern"); |
||||
bspeich.addActionListener(this); |
||||
p1.add(bspeich); |
||||
this.add(p1); |
||||
NachrichtHolen(); |
||||
} |
||||
|
||||
public void actionPerformed(ActionEvent event) { |
||||
// if (event.getActionCommand().equals("speichern"))
|
||||
// NutzerRechteSpeichern();
|
||||
if (event.getActionCommand().equals("speichern")) |
||||
NachrichtSpeichern(); |
||||
|
||||
} |
||||
private void NachrichtHolen() { |
||||
String nachricht = null; |
||||
try{ |
||||
//prüfen ob Input gegeben
|
||||
Object input = |
||||
DBAccess.executeQuerySingleValue("select aktuell from nachricht"); |
||||
|
||||
nachricht = input == null ? "<keine Nachricht>" : input.toString(); |
||||
nachricht = nachricht.trim(); |
||||
tnachricht.setText(nachricht); |
||||
|
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
JOptionPane.showMessageDialog( |
||||
null, |
||||
"Fehler bei Datenbankzugriff: "+e.toString(), |
||||
"Nachricht", |
||||
1); |
||||
} |
||||
|
||||
} |
||||
|
||||
private void NachrichtSpeichern() { |
||||
try{ |
||||
DBAccess.executeUpdate("delete from nachricht where 1=1"); |
||||
if (tnachricht.getText() != null) { |
||||
String update = |
||||
"insert into Nachricht (aktuell) values('" |
||||
+ tnachricht.getText().trim() |
||||
+ "');"; |
||||
DBAccess.executeUpdate(update); |
||||
NachrichtHolen(); |
||||
} |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
JOptionPane.showMessageDialog( |
||||
null, |
||||
"Fehler bei Datenbankzugriff: "+e.toString(), |
||||
"Nachricht", |
||||
1); |
||||
} |
||||
|
||||
|
||||
} |
||||
|
||||
} |
@ -1,312 +0,0 @@
@@ -1,312 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
/** |
||||
* Insert the type's description here. |
||||
* Creation date: (12.09.01 19:20:55) |
||||
* @author: Administrator |
||||
*/ |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Container; |
||||
import java.awt.FlowLayout; |
||||
import java.awt.Frame; |
||||
import java.awt.GridLayout; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.util.Enumeration; |
||||
import java.util.TimeZone; |
||||
import java.util.Vector; |
||||
|
||||
import javax.swing.JButton; |
||||
import javax.swing.JCheckBox; |
||||
import javax.swing.JLabel; |
||||
import javax.swing.JOptionPane; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JTextField; |
||||
import javax.swing.tree.DefaultMutableTreeNode; |
||||
|
||||
class OrgaBearbDialog extends javax.swing.JDialog implements ActionListener { |
||||
OrgaEintrag2 derEintrag; |
||||
JTextField tname; |
||||
JTextField tdrucktext; |
||||
JTextField tkey; |
||||
JTextField tebene; |
||||
JTextField tparent; |
||||
JTextField tlehre; |
||||
JCheckBox clehre; |
||||
JTextField torgstruktur; |
||||
JTextField tgueltig_seit; |
||||
JTextField tgueltig_bis; |
||||
String oldKeyApnr; |
||||
java.sql.Date oldGueltigSeit, oldGueltigBis; |
||||
DefaultMutableTreeNode theNode, theRoot; |
||||
Vector ungültigeEinträge; |
||||
boolean bearbeiteNeueOrgaEinheit; |
||||
|
||||
public OrgaBearbDialog( |
||||
Frame owner, |
||||
DefaultMutableTreeNode node, |
||||
Vector ungültigeE) { |
||||
super(owner, "OrgaEintrag bearbeiten", true); |
||||
bearbeiteNeueOrgaEinheit = false; |
||||
theNode = node; |
||||
theRoot = (DefaultMutableTreeNode) node.getRoot(); |
||||
ungültigeEinträge = ungültigeE; |
||||
init(); |
||||
} |
||||
public OrgaBearbDialog( |
||||
Frame owner, |
||||
DefaultMutableTreeNode node, |
||||
Vector ungültigeE, |
||||
DefaultMutableTreeNode lRoot) { |
||||
super(owner, "Neue OrgaEintrag bearbeiten", true); |
||||
bearbeiteNeueOrgaEinheit = true; |
||||
theNode = node; |
||||
theRoot = lRoot; |
||||
ungültigeEinträge = ungültigeE; |
||||
init(); |
||||
} |
||||
public void actionPerformed(ActionEvent event) { |
||||
|
||||
String cmd = event.getActionCommand(); |
||||
|
||||
if (cmd.equals("Abbrechen")) { |
||||
//wenn neue Einheit bearbeitet wird null zurückliefern, sonst einfach belassen wie's ist
|
||||
if (bearbeiteNeueOrgaEinheit) |
||||
theNode = null; |
||||
this.setVisible(false); |
||||
this.dispose(); |
||||
} |
||||
|
||||
if (cmd.equals("OK")) |
||||
OKÄnderungAusführen(); |
||||
|
||||
} |
||||
public String dateToString(java.sql.Date inp) { |
||||
java.text.DateFormat df; |
||||
df = java.text.DateFormat.getDateInstance(java.text.DateFormat.MEDIUM); |
||||
// r.b. default Jahr 4-stellig
|
||||
df.setTimeZone(TimeZone.getDefault()); |
||||
df.setLenient(false); |
||||
|
||||
String help = df.format((java.util.Date) inp); |
||||
return help; |
||||
} |
||||
public void init() { |
||||
derEintrag = (OrgaEintrag2) theNode.getUserObject(); |
||||
Container cp = this.getContentPane(); |
||||
cp.setLayout(new BorderLayout()); |
||||
|
||||
JPanel pcenter = new JPanel(new GridLayout(9, 1)); |
||||
JPanel p1 = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
||||
JLabel lname = new JLabel(" Name "); |
||||
tname = new JTextField(60); |
||||
tname.setText(derEintrag.getName()); |
||||
p1.add(lname); |
||||
p1.add(tname); |
||||
pcenter.add(p1); |
||||
JPanel p1b=new JPanel(new FlowLayout(FlowLayout.LEFT)); |
||||
JLabel ldrucktext=new JLabel("Drucktext "); |
||||
tdrucktext = new JTextField(60); |
||||
tdrucktext.setText(derEintrag.getDrucktext()); |
||||
p1b.add(ldrucktext);p1b.add(tdrucktext); |
||||
pcenter.add(p1b); |
||||
JPanel p2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
||||
JLabel lkey = new JLabel("Key_apnr "); |
||||
tkey = new JTextField(15); |
||||
tkey.setText(derEintrag.getKeyApnr().toString()); |
||||
//keyapnr merken, da bei änderung children angepasst werden müssen s.u.
|
||||
oldKeyApnr = derEintrag.getKeyApnr(); |
||||
p2.add(lkey); |
||||
p2.add(tkey); |
||||
pcenter.add(p2); |
||||
JPanel p3 = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
||||
JLabel lebene = new JLabel("Ebene "); |
||||
tebene = new JTextField(3); |
||||
tebene.setText(derEintrag.getEbene().toString()); |
||||
p3.add(lebene); |
||||
p3.add(tebene); |
||||
pcenter.add(p3); |
||||
JPanel p4 = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
||||
JLabel lparent = new JLabel("Parent: "); |
||||
Object parobj=derEintrag.getParent(); |
||||
String itsParent; |
||||
if (parobj==null) |
||||
itsParent=""; else itsParent=parobj.toString(); |
||||
tparent = new JTextField(itsParent); |
||||
JLabel lparentNum = new JLabel(itsParent); |
||||
p4.add(lparent); |
||||
p4.add(lparentNum); |
||||
pcenter.add(p4); |
||||
|
||||
JPanel p5 = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
||||
JLabel llehre = new JLabel("Lehre"); |
||||
//tlehre=new JTextField(derEintrag.getLehre().toString());
|
||||
clehre = new JCheckBox("Lehre", derEintrag.isLehre()); |
||||
p5.add(clehre); |
||||
pcenter.add(p5); |
||||
JPanel p5b = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
||||
JLabel lorgstruktur=new JLabel("Orgstruktur"); |
||||
torgstruktur=new JTextField(4); |
||||
Object help_orgstruktur=derEintrag.getOrgstruktur(); |
||||
String help_orgstruktur2; |
||||
if (help_orgstruktur==null) help_orgstruktur2=""; else help_orgstruktur2=help_orgstruktur.toString(); |
||||
torgstruktur.setText(help_orgstruktur2); |
||||
p5b.add(lorgstruktur);p5b.add(torgstruktur); |
||||
pcenter.add(p5b); |
||||
|
||||
JPanel p6 = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
||||
JLabel lgueltig_seit = new JLabel("gültig seit"); |
||||
oldGueltigSeit = derEintrag.getGueltigSeit(); |
||||
tgueltig_seit = new JTextField(dateToString(oldGueltigSeit)); |
||||
p6.add(lgueltig_seit); |
||||
p6.add(tgueltig_seit); |
||||
pcenter.add(p6); |
||||
JPanel p7 = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
||||
JLabel lgueltig_bis = new JLabel("gültig bis "); |
||||
oldGueltigBis = derEintrag.getGueltigBis(); |
||||
tgueltig_bis = new JTextField(dateToString(oldGueltigBis)); |
||||
p7.add(lgueltig_bis); |
||||
p7.add(tgueltig_bis); |
||||
pcenter.add(p7); |
||||
cp.add(pcenter, BorderLayout.CENTER); |
||||
JPanel pOKAbr = new JPanel(); |
||||
JButton OK = new JButton("OK"); |
||||
OK.addActionListener(this); |
||||
pOKAbr.add(OK); |
||||
JButton Abbr = new JButton("Abbrechen"); |
||||
Abbr.addActionListener(this); |
||||
pOKAbr.add(Abbr); |
||||
cp.add(pOKAbr, BorderLayout.SOUTH); |
||||
//this.setSize(250,190);
|
||||
this.pack(); |
||||
this.setLocation(100, 100); |
||||
this.show(); |
||||
|
||||
} |
||||
public boolean keyApnrOK(String keyApnr) { |
||||
Enumeration en; |
||||
DefaultMutableTreeNode aNode; |
||||
OrgaEintrag2 x; |
||||
boolean isOK = true; |
||||
for (en = theRoot.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
// nicht mit sich selbst und root vergleichen (root "Hochschule" hat keine key_apnr -> null pointer exception)
|
||||
if (!aNode.equals(theNode) && !aNode.equals(theRoot)&&aNode.getUserObject() instanceof OrgaEintrag2) { |
||||
|
||||
x = (OrgaEintrag2) aNode.getUserObject(); |
||||
if (keyApnr.equals(x.getKeyApnr())) |
||||
isOK = false; |
||||
} |
||||
} |
||||
return isOK; |
||||
} |
||||
public boolean neueGültigkeitOK( |
||||
String newKeyApnr, |
||||
java.sql.Date gs, |
||||
java.sql.Date gb) { |
||||
boolean isOK = true; |
||||
boolean pruef1, pruef2; |
||||
OrgaEintrag2 x; |
||||
for (Enumeration el = ungültigeEinträge.elements(); el.hasMoreElements();) { |
||||
x = (OrgaEintrag2) el.nextElement(); |
||||
|
||||
if (x.getKeyApnr().equals(newKeyApnr)) { |
||||
pruef1 = (gs.before(x.getGueltigSeit()) && gb.before(x.getGueltigSeit())); |
||||
pruef2 = (gs.after(x.getGueltigBis()) && gb.after(x.getGueltigBis())); |
||||
if ((pruef1 == false) && (pruef2 == false)) |
||||
isOK = false; |
||||
|
||||
} |
||||
|
||||
} |
||||
return isOK; |
||||
} |
||||
public void OKÄnderungAusführen() { |
||||
OrgaEintrag2 einEintrag; |
||||
|
||||
String neuname = tname.getText(); |
||||
String newKeyApnr = tkey.getText().trim(); |
||||
if (!keyApnrOK(newKeyApnr)) { |
||||
JOptionPane.showMessageDialog( |
||||
null, |
||||
"Key_apnr bereits vergeben!", |
||||
"SuperX DB Admin", |
||||
JOptionPane.WARNING_MESSAGE); |
||||
return; |
||||
} |
||||
|
||||
//wenn sich die KeyApnr geändert hat, muss auch
|
||||
//der parent-Eintrag der direkten Kinder geändert werden
|
||||
DefaultMutableTreeNode x; |
||||
if (!newKeyApnr.equals(oldKeyApnr)) { |
||||
Enumeration en = theNode.children(); |
||||
while (en.hasMoreElements()) { |
||||
x = (DefaultMutableTreeNode) en.nextElement(); |
||||
einEintrag = (OrgaEintrag2) x.getUserObject(); |
||||
einEintrag.setParent(newKeyApnr); |
||||
} |
||||
} |
||||
String drucktext=tdrucktext.getText(); |
||||
Integer neuEbene = new Integer(tebene.getText()); |
||||
// parent nur automatisch ändern
|
||||
// derEintrag.parent=new Integer(tparent.getText());
|
||||
int lehre = clehre.isSelected() ? 1 : 0; |
||||
Integer neulehre = new Integer(lehre); |
||||
|
||||
Integer orgstruktur=torgstruktur.getText().equals("")?null:new Integer(torgstruktur.getText()); |
||||
java.sql.Date gs = stringToDate(tgueltig_seit.getText()); |
||||
java.sql.Date gb = stringToDate(tgueltig_bis.getText()); |
||||
if (gs == null || gb == null || gb.before(gs)) { |
||||
JOptionPane.showMessageDialog( |
||||
null, |
||||
"Fehler in Datumsfeldern!", |
||||
"SuperX DB Admin", |
||||
JOptionPane.WARNING_MESSAGE); |
||||
return; |
||||
} |
||||
//prüfen falls sich an Gültigkeitseinträgen was geändert hat
|
||||
if (!oldGueltigSeit.equals(gs) || !oldGueltigBis.equals(gb)) { |
||||
if (!neueGültigkeitOK(newKeyApnr, gs, gb)) { |
||||
JOptionPane.showMessageDialog( |
||||
null, |
||||
"Die eingegebene Gültigkeit überlappt sich\nmit der Gültigkeit einer schon bestehenden key_apnr!", |
||||
"SuperX DB Admin", |
||||
JOptionPane.WARNING_MESSAGE); |
||||
return; |
||||
} else |
||||
JOptionPane.showMessageDialog( |
||||
null, |
||||
"Die Gültigkeit wurde geändert!\nGgf. Organigramm neu einlesen oder Stand ändern!", |
||||
"SuperX DB Admin", |
||||
JOptionPane.INFORMATION_MESSAGE); |
||||
} |
||||
|
||||
derEintrag.name = neuname; |
||||
derEintrag.drucktext=drucktext; |
||||
derEintrag.key_apnr = newKeyApnr; |
||||
derEintrag.lehre = neulehre; |
||||
derEintrag.ebene = neuEbene; |
||||
derEintrag.orgstruktur=orgstruktur; |
||||
derEintrag.gueltig_seit = gs; |
||||
derEintrag.gueltig_bis = gb; |
||||
|
||||
this.setVisible(false); |
||||
this.dispose(); |
||||
|
||||
} |
||||
public java.sql.Date stringToDate(String datum) { |
||||
java.text.DateFormat df; |
||||
df = java.text.DateFormat.getDateInstance(java.text.DateFormat.MEDIUM); |
||||
// r.b. default Jahr 4-stellig
|
||||
df.setTimeZone(TimeZone.getDefault()); |
||||
df.setLenient(false); |
||||
|
||||
java.sql.Date date = null; |
||||
try { |
||||
java.util.Date date1 = df.parse(datum); |
||||
date = new java.sql.Date(date1.getTime()); |
||||
} catch (Exception e) { |
||||
System.out.println(e.toString()); |
||||
} |
||||
return date; |
||||
} |
||||
} |
@ -1,207 +0,0 @@
@@ -1,207 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
import java.awt.datatransfer.DataFlavor; |
||||
import java.awt.datatransfer.Transferable; |
||||
import java.awt.datatransfer.UnsupportedFlavorException; |
||||
import java.io.IOException; |
||||
import java.io.Serializable; |
||||
import java.sql.Date; |
||||
|
||||
class OrgaEintrag2 implements Transferable, Serializable |
||||
{ |
||||
final public static DataFlavor ORGA_FLAVOR= new DataFlavor(OrgaEintrag2.class,"orgaEintrag2"); |
||||
static DataFlavor flavors[]={ORGA_FLAVOR}; |
||||
|
||||
String name; |
||||
String drucktext; |
||||
String key_apnr; |
||||
Integer ebene; |
||||
String parent; |
||||
Integer hierarchie; |
||||
Integer lehre; |
||||
Integer orgstruktur; |
||||
Integer erlaubt; |
||||
|
||||
java.sql.Date gueltig_seit,gueltig_bis; |
||||
|
||||
|
||||
OrgaEintrag2() |
||||
{ |
||||
name=null; |
||||
drucktext=null; |
||||
key_apnr=null; |
||||
ebene=null; |
||||
parent=null; |
||||
lehre=null; |
||||
gueltig_seit=null; |
||||
gueltig_bis=null; |
||||
orgstruktur=null; |
||||
erlaubt=null; |
||||
} |
||||
OrgaEintrag2(String lname, String ldrucktext,String lkey_apnr, Integer lebene,String lparent, Integer llehre, Date gs, Date gb, Integer lorgstruktur) |
||||
{ |
||||
//akt. Änderung
|
||||
char bindestrich=150; |
||||
name=lname; |
||||
if (name!=null) name=name.replace(bindestrich,'-'); |
||||
|
||||
drucktext=ldrucktext; |
||||
if (drucktext!=null) drucktext=drucktext.replace(bindestrich,'-'); |
||||
key_apnr=lkey_apnr; |
||||
|
||||
//if (key_apnr!=null&&key_apnr.equals("E07011100x"))
|
||||
//test();
|
||||
|
||||
ebene=lebene; |
||||
parent=lparent; |
||||
lehre=llehre; |
||||
gueltig_seit=gs; |
||||
gueltig_bis=gb; |
||||
orgstruktur=lorgstruktur; |
||||
erlaubt=new Integer(0); |
||||
int i=0; |
||||
hierarchie=null; |
||||
} |
||||
private void test() |
||||
{ |
||||
int i=1; |
||||
System.out.println((int)name.charAt(25)); |
||||
int i2=1; |
||||
} |
||||
public void setHierarchie(Integer was) |
||||
{ |
||||
hierarchie=was; |
||||
} |
||||
|
||||
public String getDrucktext() |
||||
{ |
||||
return drucktext; |
||||
} |
||||
public Integer getEbene() |
||||
{ |
||||
return ebene; |
||||
} |
||||
public Integer getErlaubt() |
||||
{ |
||||
return erlaubt; |
||||
} |
||||
public java.sql.Date getGueltigBis() |
||||
{ |
||||
return gueltig_bis; |
||||
} |
||||
|
||||
public void setGueltigBis(java.sql.Date bis) |
||||
{ |
||||
gueltig_bis=bis; |
||||
} |
||||
|
||||
public java.sql.Date getGueltigSeit() |
||||
{ |
||||
return gueltig_seit; |
||||
} |
||||
|
||||
public void setGueltigSeit(java.sql.Date seit) |
||||
{ |
||||
gueltig_seit=seit; |
||||
} |
||||
|
||||
public String getKeyApnr() |
||||
{ |
||||
return key_apnr; |
||||
} |
||||
public Integer getLehre() |
||||
{ |
||||
return lehre; |
||||
} |
||||
public String getName() |
||||
{ |
||||
return name.trim(); |
||||
} |
||||
public Integer getOrgstruktur() |
||||
{ |
||||
return orgstruktur; |
||||
} |
||||
public String getParent() |
||||
{ |
||||
return parent; |
||||
} |
||||
public Object getTransferData(DataFlavor df) throws UnsupportedFlavorException, IOException |
||||
{ |
||||
if (df.equals(ORGA_FLAVOR)){ |
||||
return this; |
||||
} |
||||
else throw new UnsupportedFlavorException(df); |
||||
} |
||||
public DataFlavor[] getTransferDataFlavors(){ |
||||
return flavors; |
||||
} |
||||
// -----------transferable
|
||||
public boolean isDataFlavorSupported(DataFlavor df) |
||||
{ |
||||
return df.equals(ORGA_FLAVOR); |
||||
} |
||||
public boolean isLehre() |
||||
{ |
||||
return lehre.intValue()==1?true:false; |
||||
|
||||
} |
||||
private void readObject(java.io.ObjectInputStream in) |
||||
throws IOException, ClassNotFoundException { |
||||
in.defaultReadObject(); |
||||
} |
||||
public void setDrucktext(String ldrucktext) |
||||
{ |
||||
drucktext=ldrucktext; |
||||
} |
||||
public void setEbene(Integer neueEbene) |
||||
{ |
||||
ebene=neueEbene; |
||||
} |
||||
public void setErlaubt(Integer erl) |
||||
{ |
||||
erlaubt=erl; |
||||
} |
||||
public void setErlaubt(boolean was) |
||||
{ |
||||
erlaubt=was?new Integer(1):new Integer(0); |
||||
} |
||||
|
||||
public boolean isErlaubt() |
||||
{ |
||||
return erlaubt.intValue()==0?false:true; |
||||
} |
||||
|
||||
public void setKeyApnr(String was) |
||||
{ |
||||
key_apnr=was; |
||||
} |
||||
public void setOrgstruktur(Integer lorgstruktur) |
||||
{ |
||||
orgstruktur=lorgstruktur; |
||||
} |
||||
public void setParent(String was) |
||||
{ |
||||
parent=was; |
||||
} |
||||
public String toString() |
||||
{ |
||||
//akt. Änderung
|
||||
String result=""; |
||||
if (getKeyApnr()!=null)result+=getKeyApnr().trim()+"-"; |
||||
result+=name.trim(); |
||||
return result; |
||||
} |
||||
|
||||
public void setLehre(Integer lehr) |
||||
{ |
||||
lehre=lehr; |
||||
} |
||||
//-------serializable
|
||||
private void writeObject(java.io.ObjectOutputStream out) throws IOException { |
||||
out.defaultWriteObject(); |
||||
} |
||||
|
||||
public Integer getHierarchie() |
||||
{ |
||||
return hierarchie; |
||||
} |
||||
} |
@ -1,574 +0,0 @@
@@ -1,574 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
|
||||
import java.awt.BorderLayout; |
||||
import java.awt.Color; |
||||
import java.awt.Component; |
||||
import java.awt.Cursor; |
||||
import java.awt.Dimension; |
||||
import java.awt.FlowLayout; |
||||
import java.awt.Font; |
||||
import java.awt.GridLayout; |
||||
import java.awt.Label; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.sql.Connection; |
||||
import java.sql.SQLException; |
||||
import java.sql.SQLWarning; |
||||
import java.util.Enumeration; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JButton; |
||||
import javax.swing.JLabel; |
||||
import javax.swing.JOptionPane; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JScrollPane; |
||||
import javax.swing.JTree; |
||||
import javax.swing.event.TreeSelectionEvent; |
||||
import javax.swing.event.TreeSelectionListener; |
||||
import javax.swing.tree.DefaultMutableTreeNode; |
||||
import javax.swing.tree.TreePath; |
||||
|
||||
import de.memtext.dlg.LoginDlg; |
||||
import de.memtext.util.PlafUtils; |
||||
import de.memtext.util.WindowUtils; |
||||
import de.memtext.widgets.CardLayoutPanel; |
||||
import de.memtext.widgets.MBFrame; |
||||
import de.memtext.widgets.TitlePanel; |
||||
import de.memtext.widgets.WarningMessage; |
||||
|
||||
/** |
||||
* Hauptklasse des SuperX-DBAdmintools |
||||
* |
||||
* @autor Meikel Bisping |
||||
*/ |
||||
|
||||
public class SuperXDBAdmin extends MBFrame implements ActionListener, |
||||
TreeSelectionListener { |
||||
private static final String TITLE = "SuperX-Admin 0.94 beta"; |
||||
private Label erg,lnachricht; |
||||
|
||||
private JPanel pcenter = null; |
||||
private CardLayoutPanel workPanel = null; |
||||
static JLabel status; |
||||
private static int selectedUser = -999, lastgroup = -999; |
||||
private Connection myConnection = null; |
||||
private SxSQL sxsql; |
||||
private JTree tree = null; |
||||
private AdminOrga adminOrga; |
||||
private ThemenbaumPanel themenbaumPanel; |
||||
private UserStammPanel userStammPanel; |
||||
private UserGroupMembershipPanel userGroupMembershipPanel; |
||||
private GroupStammPanel groupStammPanel; |
||||
private UserThemenPanel userThemenPanel; |
||||
private JScrollPane taskSelectionScrollPane; |
||||
private TreePath lastSelectedPath; |
||||
private boolean isAutoLogin = true; |
||||
|
||||
boolean selectionZurückgesetzt = false; |
||||
private String sxTitle, serverURL, logToKonsole, myDocBase; |
||||
//hier werden die Knoten im Auswahlbaum definiert,
|
||||
//(-> makeTree())
|
||||
//wenn ein Knoten angeklickt wird, wird in der
|
||||
//Methode valueChanged überprüft, um welchen Knoten
|
||||
//es sich handelt. z.B. if (angeklickterKnoten==userthemen) zeige...
|
||||
private DefaultMutableTreeNode root, userv, usereinzel, userstamm, |
||||
userthemen, userinst, gruppen, gruppenstamm, gruppenmitgliedschaft, |
||||
gruppenthemen, gruppeninst, nachricht, maskenverw, maskeändern, |
||||
maskelöschen, organigramm, themenb; |
||||
|
||||
/* |
||||
* Konstruktor, baut Hauptauswahlfenster auf, es wird ein BorderLayout |
||||
* benutzt im Zentrum ist ein FlowLayout Panel mit links dem Auswahlbaum und |
||||
* rechts dem "Themenblatt", das wird je nach angeklicktem Knoten |
||||
* ausgetauscht |
||||
*/ |
||||
|
||||
public SuperXDBAdmin(String propfile, String docBase) { |
||||
super(TITLE); |
||||
WarningMessage.show(this,"Veraltet - GEHT NICHT -müsste überarbeitet werden","Achtung"); |
||||
//TODO statt Vector in Vector SxResultSet mit SxResultRows!!!
|
||||
setSystemExitOnClose(false); |
||||
SxDefaults.setPropertyFile(propfile); |
||||
SxDefaults.setDefaultServerUrl(getCorrectDocBase(docBase)); |
||||
|
||||
PlafUtils.setWindowsLook(this); |
||||
try { |
||||
|
||||
SxDefaults.setDefaultServerUrl(getDefaultServerUrl(docBase)); |
||||
SxDefaults.init(); |
||||
serverURL = (String) SxDefaults.getPropertyValue("SxServerURL"); |
||||
|
||||
} catch (Exception ex) { |
||||
System.err.println(ex); |
||||
JOptionPane.showMessageDialog(null, ex.toString(), "Fehler", |
||||
JOptionPane.ERROR_MESSAGE); |
||||
} |
||||
|
||||
try { |
||||
logToKonsole = (String) SxDefaults.getPropertyValue("logToKonsole"); |
||||
} catch (Exception ex) { |
||||
logToKonsole = "none"; |
||||
} |
||||
|
||||
try { |
||||
sxTitle = (String) SxDefaults.getPropertyValue("SxTitle"); |
||||
|
||||
} catch (Exception ex) { |
||||
} |
||||
|
||||
String user = new String(""); |
||||
String passwd = new String(""); |
||||
try { |
||||
LoginDlg dlg = new LoginDlg(this, "AdminTool Anmeldung"); |
||||
|
||||
WindowUtils.center(dlg); |
||||
if (!isAutoLogin) |
||||
dlg.show(); |
||||
user = dlg.getUsername(); |
||||
passwd = dlg.getPassword(); |
||||
if (isAutoLogin) { |
||||
user = "superx"; |
||||
passwd = "anfang12"; |
||||
} |
||||
if (user == null || passwd == null) |
||||
System.exit(1); |
||||
|
||||
// DBAccess.init(url,driverClass,"superx","");
|
||||
DBAccess.init(serverURL, logToKonsole, user, passwd); |
||||
|
||||
// String user = props.getProperty("Username");
|
||||
// String passwd = props.getProperty("Passwort");
|
||||
|
||||
/* |
||||
* try { Class.forName(driverClass); myConnection = |
||||
* DriverManager.getConnection(url, user, passwd); |
||||
* checkForWarning(myConnection.getWarnings()); |
||||
* dropTempTables(myConnection); DatabaseMetaData myDatabaseMetaData = |
||||
* myConnection.getMetaData(); } catch (Exception e) { |
||||
* JOptionPane.showMessageDialog( null, "Fehler beim Aufbau der |
||||
* Datenbankverbindung:\n " + e.toString(), "SuperX DB Admin", |
||||
* JOptionPane.WARNING_MESSAGE); e.printStackTrace(); |
||||
* System.exit(-1); } DBAccess.setConnection(myConnection);; |
||||
*/ |
||||
|
||||
//p.add(p1);
|
||||
//this.add(p);
|
||||
/* |
||||
* JPanel p2 = new JPanel(new FlowLayout(FlowLayout.CENTER)); |
||||
* JButton button = new JButton("Organigramm"); |
||||
* button.addActionListener(this); p2.add(button); JButton button2 = |
||||
* new JButton("Themenbaum"); button2.addActionListener(this); |
||||
* button2.setEnabled(false); p2.add(button2); JButton bnachr = new |
||||
* JButton("Nachricht festlegen"); bnachr.addActionListener(this); |
||||
* p2.add(bnachr); p.add(p2); JPanel p3 = new JPanel(new |
||||
* FlowLayout(FlowLayout.CENTER)); JLabel luser=new JLabel("User"); |
||||
* luser.setFont(new Font("Arial", Font.BOLD, 12)); p3.add(luser); |
||||
* JButton bstamm = new JButton("Stammdaten"); bstamm.setFont(new |
||||
* Font("Arial", Font.PLAIN, 10)); bstamm.addActionListener(this); |
||||
* p3.add(bstamm); JButton bgroup = new JButton("Gruppen"); |
||||
* bgroup.setFont(new Font("Arial", Font.PLAIN, 10)); |
||||
* bgroup.addActionListener(this); p3.add(bgroup); |
||||
* |
||||
* JButton babfrage = new JButton("Rechte für Abfragen"); |
||||
* babfrage.setFont(new Font("Arial", Font.PLAIN, 10)); |
||||
* babfrage.addActionListener(this); p3.add(babfrage); JButton |
||||
* binst=new JButton("Rechte für Institutionen"); binst.setFont(new |
||||
* Font("Arial", Font.PLAIN, 10)); binst.addActionListener(this); |
||||
* p3.add(binst); p.add(p3); |
||||
*/ |
||||
setNorth(new TitlePanel(TITLE)); |
||||
|
||||
// lnachricht = new Label(this.getNachricht());
|
||||
// lnachricht.setBackground(java.awt.Color.cyan);
|
||||
// this.add(lnachricht);
|
||||
|
||||
initCenterPanel(); |
||||
|
||||
//cp.add("Center",pcenter);
|
||||
JPanel down = new JPanel(new GridLayout(2, 1)); |
||||
|
||||
JPanel p4 = new JPanel(new FlowLayout(FlowLayout.CENTER)); |
||||
JButton Ende = new JButton("Ende"); |
||||
Ende.setFont(new Font("Arial", Font.BOLD, 14)); |
||||
//OK.setSize(14,100);
|
||||
Ende.addActionListener(this); |
||||
p4.add(Ende); |
||||
down.add(p4); |
||||
JPanel p5 = new JPanel(); |
||||
p5.setBorder(BorderFactory.createEtchedBorder()); |
||||
status = new JLabel(); |
||||
p5.add(status); |
||||
down.add(p5); |
||||
setSouth(down); |
||||
|
||||
setLocation(50, 50); |
||||
setSize(700, 700); |
||||
initWorkPanel(); |
||||
setVisible(true); |
||||
backupsAnlegen(); |
||||
|
||||
} catch (Exception e) { |
||||
JOptionPane.showMessageDialog(null, |
||||
"Fehler beim Aufbau der Datenbankverbindung:\n " |
||||
+ e.toString(), "SuperX DB Admin", |
||||
JOptionPane.WARNING_MESSAGE); |
||||
e.printStackTrace(); |
||||
setVisible(false); |
||||
System.exit(-1); |
||||
} |
||||
|
||||
} |
||||
|
||||
private void initWorkPanel() { |
||||
workPanel.add(new JPanel(), "leer"); |
||||
|
||||
adminOrga = new AdminOrga(); |
||||
workPanel.add(adminOrga, "adminOrga"); |
||||
themenbaumPanel = new ThemenbaumPanel(); |
||||
workPanel.add(themenbaumPanel, "themenbaumPanel"); |
||||
userStammPanel = new UserStammPanel(); |
||||
workPanel.add(userStammPanel, "userStammPanel"); |
||||
userGroupMembershipPanel=new UserGroupMembershipPanel(); |
||||
workPanel.add(userGroupMembershipPanel, "userGroupMembershipPanel"); |
||||
groupStammPanel=new GroupStammPanel(); |
||||
workPanel.add(groupStammPanel, "groupStammPanel"); |
||||
userThemenPanel=new UserThemenPanel(); |
||||
workPanel.add(userThemenPanel,"userThemenPanel"); |
||||
} |
||||
|
||||
private String getDefaultServerUrl(String docBase) { |
||||
String prop_file = docBase + "superx.properties"; |
||||
//System.out.println("prop_file: " + prop_file); //Wint
|
||||
int pos = docBase.indexOf("superx/applet"); |
||||
String defaultServerUrl = null; |
||||
if (pos > 0) { |
||||
defaultServerUrl = docBase.substring(0, pos) |
||||
+ "superx/servlet/SuperXDBServlet"; |
||||
//System.out.println("default URL of Servlet:
|
||||
// "+defaultServerUrl);
|
||||
} else { |
||||
System.out |
||||
.println("Can't identify SxServerURL automatically, since CodeBase doesn't contain super/applet.SxServerURL has to be specified in superx.properties"); |
||||
} |
||||
return defaultServerUrl; |
||||
} |
||||
|
||||
public void actionPerformed(ActionEvent event) { |
||||
String cmd = event.getActionCommand(); |
||||
if (cmd.equals("Ende")) { |
||||
this.setVisible(false); |
||||
System.exit(1); |
||||
|
||||
} |
||||
|
||||
} |
||||
|
||||
protected void doBeforeExit() { |
||||
setVisible(false); |
||||
|
||||
try { |
||||
|
||||
DBAccess.sxsql.close(); |
||||
} catch (Exception e2) { |
||||
e2.printStackTrace(); |
||||
} |
||||
} |
||||
|
||||
private void backupsAnlegen() { |
||||
/* |
||||
* try{ |
||||
* |
||||
* Statement statement=myConnection.createStatement(); |
||||
* statement.execute("unload to orgamb.bak select * from organigramm"); |
||||
* setStatus("Backups angelegt!"); } |
||||
* |
||||
* catch (Exception e) { setStatus(" <html> <font color=red>Achtung! |
||||
* Fehler beim Anlegen der Backups!"+e.toString()+" </font> </html>"); } |
||||
*/ |
||||
|
||||
} |
||||
|
||||
private static void checkForWarning(SQLWarning warn) throws SQLException { |
||||
if (warn != null) { |
||||
System.out.println("***** Eine Warnung ist aufgetreten *****"); |
||||
|
||||
while (warn != null) { |
||||
System.out.println("SQL State: " + warn.getSQLState() |
||||
+ "\nMessage: " + warn.getMessage() + "\nVendor: " |
||||
+ warn.getErrorCode()); |
||||
warn = warn.getNextWarning(); |
||||
} |
||||
} else { |
||||
//System.out.println("***** Datenbankverbindung aufgebaut *****");
|
||||
} |
||||
} |
||||
|
||||
private void dropTempTables(Connection myConnection) { |
||||
/* |
||||
* try{ DatabaseMetaData dmd = myConnection.getMetaData(); Statement |
||||
* stmt = myConnection.createStatement(); String sql; |
||||
* |
||||
* String[] type = {"TABLE","GLOBAL TEMPORARY", "LOCAL TEMPORARY" }; |
||||
* |
||||
* |
||||
* stmt.execute("create temp table tmp_orga7 (institut integer) ;"); |
||||
* ResultSet rs= dmd.getTables(null,null,"tmp%",type); //ResultSet rs=
|
||||
* dmd.getTableTypes(); |
||||
* |
||||
* |
||||
* while(rs.next()) { sql="drop table "+rs.getString("TABLE_NAME"); |
||||
* stmt.execute(sql); // System.out.println(rs.getString(1)); };
|
||||
* rs.close(); stmt.close(); } catch (SQLException e) { |
||||
* System.out.println(e.toString()); } |
||||
*/} |
||||
|
||||
public static int getLastGroup() { |
||||
return lastgroup; |
||||
} |
||||
|
||||
public static int getSelectedUser() { |
||||
return selectedUser; |
||||
} |
||||
|
||||
public static void main(String[] args) { |
||||
//SuperXDBAdmin wnd = new SuperXDBAdmin("file:superx.properties", System .getProperty("user.dir") + System.getProperty("file.separator"));
|
||||
SuperXDBAdmin wnd = new SuperXDBAdmin("file:e:/mb/diss/workspace/superx/superx.properties", System .getProperty("user.dir") + System.getProperty("file.separator")); |
||||
wnd.setVisible(true); |
||||
|
||||
} |
||||
|
||||
private void makeTree() { |
||||
|
||||
root = new DefaultMutableTreeNode("Admin"); |
||||
organigramm = new DefaultMutableTreeNode("Organigramm"); |
||||
root.add(organigramm); |
||||
themenb = new DefaultMutableTreeNode("Themenbaum"); |
||||
root.add(themenb); |
||||
// nachricht=new DefaultMutableTreeNode("Nachricht");
|
||||
//root.add(nachricht);
|
||||
userv = new DefaultMutableTreeNode("Userverwaltung"); |
||||
|
||||
usereinzel = new DefaultMutableTreeNode("Einzeluser"); |
||||
userstamm = new DefaultMutableTreeNode("Stammdaten"); |
||||
gruppenmitgliedschaft = new DefaultMutableTreeNode( |
||||
"Gruppenmitgliedschaft"); |
||||
userthemen = new DefaultMutableTreeNode("Themenrechte"); |
||||
userinst = new DefaultMutableTreeNode("Institutionen"); |
||||
usereinzel.add(userstamm); |
||||
usereinzel.add(gruppenmitgliedschaft); |
||||
// usereinzel.add(userthemen);
|
||||
// usereinzel.add(userinst);
|
||||
gruppen = new DefaultMutableTreeNode("Gruppen"); |
||||
gruppenstamm = new DefaultMutableTreeNode("Stammdaten"); |
||||
gruppenthemen = new DefaultMutableTreeNode("Themenrechte"); |
||||
gruppen.add(gruppenstamm); |
||||
// gruppen.add(gruppenthemen);
|
||||
//Gruppenrechte für Institutionen bisher nicht vorgesehen
|
||||
// gruppeninst= new DefaultMutableTreeNode("Institutionen");
|
||||
// gruppen.add(gruppeninst);
|
||||
userv.add(usereinzel); |
||||
userv.add(gruppen); |
||||
root.add(userv); |
||||
|
||||
maskenverw = new DefaultMutableTreeNode("Maskenverwaltung"); |
||||
maskelöschen = new DefaultMutableTreeNode("Maske löschen"); |
||||
// maskenverw.add(maskelöschen);
|
||||
maskeändern = new DefaultMutableTreeNode("Maske ändern"); |
||||
maskenverw.add(maskeändern); |
||||
//root.add(maskenverw);
|
||||
tree = new JTree(root); |
||||
tree.addTreeSelectionListener(this); |
||||
|
||||
DefaultMutableTreeNode aNode; |
||||
TreePath tp; |
||||
for (Enumeration en = root.depthFirstEnumeration(); en |
||||
.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
tp = new TreePath(aNode.getPath()); |
||||
if (tree.isCollapsed(tp)) |
||||
tree.expandPath(tp); |
||||
} |
||||
|
||||
} |
||||
|
||||
public static void setLastGroup(int was) { |
||||
lastgroup = was; |
||||
} |
||||
|
||||
public static void setSelectedUser(int was) { |
||||
selectedUser = was; |
||||
} |
||||
|
||||
public static void setStatus(String stat) { |
||||
status.setText(stat); |
||||
|
||||
} |
||||
|
||||
public static String getStatus() { |
||||
return status.getText(); |
||||
} |
||||
|
||||
private void initCenterPanel() { |
||||
|
||||
pcenter = new JPanel(new BorderLayout()); |
||||
|
||||
makeTree(); |
||||
taskSelectionScrollPane = new JScrollPane(tree); |
||||
taskSelectionScrollPane.setMinimumSize(new Dimension(250, 400)); |
||||
pcenter.add(taskSelectionScrollPane, BorderLayout.WEST); |
||||
workPanel = new CardLayoutPanel(); |
||||
workPanel.setMinimumSize(new Dimension(400, 400)); |
||||
workPanel.setBorder(BorderFactory.createLineBorder(Color.black)); |
||||
|
||||
pcenter.add(workPanel, BorderLayout.CENTER); |
||||
this.setCenter(pcenter); |
||||
this.validate(); |
||||
this.repaint(); |
||||
|
||||
} |
||||
|
||||
public void valueChanged(TreeSelectionEvent e) { |
||||
|
||||
DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree |
||||
.getLastSelectedPathComponent(); |
||||
|
||||
if (selectionZurückgesetzt) { |
||||
selectionZurückgesetzt = false; |
||||
return; |
||||
} |
||||
|
||||
if (adminOrga.isSaveNecessary() || themenbaumPanel.isSaveNecessary()) { |
||||
int erg = JOptionPane |
||||
.showConfirmDialog( |
||||
this, |
||||
"Achtung!\n Änderungen wurden noch nicht gespeichert.\n Wollen Sie wirklich wechseln?", |
||||
"SuperX DB Admin", JOptionPane.YES_NO_OPTION); |
||||
if (erg == JOptionPane.NO_OPTION) { |
||||
selectionZurückgesetzt = true; |
||||
//tree.clearSelection();
|
||||
tree.setSelectionPath(lastSelectedPath); |
||||
|
||||
return; |
||||
} |
||||
} |
||||
|
||||
if (node == organigramm) { |
||||
setStatus("Lese Organigramm ein..."); |
||||
adminOrga.backupAnlegen(); |
||||
adminOrga.readTreeFromDb(); |
||||
workPanel.show("adminOrga"); |
||||
|
||||
} |
||||
|
||||
if (node == themenb) { |
||||
themenbaumPanel.readTreeFromDb(null); |
||||
workPanel.show("themenbaumPanel"); |
||||
|
||||
} |
||||
|
||||
if (node == userstamm) { |
||||
userStammPanel.prepare(); |
||||
workPanel.show("userStammPanel"); |
||||
} |
||||
|
||||
if (node == userthemen) { |
||||
userThemenPanel.prepare(); |
||||
workPanel.show("userThemenPanel"); |
||||
|
||||
} |
||||
|
||||
if (node == userinst) { |
||||
// workPanel = new UserInst(this);
|
||||
|
||||
} |
||||
|
||||
if (node == gruppenstamm) { |
||||
groupStammPanel.prepare(); |
||||
workPanel.show("groupStammPanel"); |
||||
} |
||||
|
||||
if (node == gruppenthemen) { |
||||
// workPanel = new GroupThemen(this);
|
||||
|
||||
} |
||||
|
||||
if (node == gruppeninst) { |
||||
// workPanel = new GroupInst(this, myConnection);
|
||||
|
||||
} |
||||
|
||||
if (node == gruppenmitgliedschaft) { |
||||
userGroupMembershipPanel.prepare(); |
||||
workPanel.show("userGroupMembershipPanel"); |
||||
|
||||
} |
||||
if (node == nachricht) { |
||||
// workPanel = new Nachricht(this, myConnection);
|
||||
|
||||
} |
||||
|
||||
if (node == maskeändern) { |
||||
// workPanel = new MaskeAendern(this);
|
||||
|
||||
} |
||||
|
||||
if (node == maskelöschen) { |
||||
//Maske auswählen MaskenAuswahl
|
||||
//Eintrag löschen in maskeninfo, themenbaum where T.maskeninfo_id=
|
||||
//delete from felderinfo where in tid in (select felderinfo_id from
|
||||
// maske_felder_bez where maskeninfo_id=x)
|
||||
//delete from maske_felder_bez where maskeninfo_id=x
|
||||
//delete from user_themen where maske=1 and id=x
|
||||
//delte from group_themen where maske=1 and id=x
|
||||
|
||||
//
|
||||
} |
||||
|
||||
lastSelectedPath = tree.getSelectionPath(); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* Set the component's cursor to an hourglass. |
||||
* |
||||
* @param c |
||||
* The component over which to change the cursor. |
||||
*/ |
||||
public static final void gotoWaitCursor(Component c) { |
||||
// Set cursor to notify user to wait.
|
||||
c.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); |
||||
} |
||||
|
||||
/** |
||||
* Set the component's cursor to the default pointer. |
||||
* |
||||
* @param c |
||||
* The component over which to change the cursor. |
||||
*/ |
||||
public static final void gotoDefaultCursor(Component c) { |
||||
// Set cursor back to what it was.
|
||||
c.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
||||
} |
||||
|
||||
private String getCorrectDocBase(String docBase) { |
||||
|
||||
if (docBase.indexOf(".htm") > 0 || docBase.indexOf(".html") > 0 |
||||
|| docBase.indexOf(".jsp") > 0) { |
||||
int posSeparator = docBase.lastIndexOf("/"); |
||||
//System.out.print("correcting docbase: shouldn't be "+docBase);
|
||||
System.out.print("korrigiere docbase: sollte nicht " + docBase |
||||
+ " sein"); |
||||
docBase = docBase.substring(0, posSeparator + 1); |
||||
System.out.println(" sondern " + docBase); |
||||
} |
||||
if (!docBase.substring(docBase.length() - 1, docBase.length()).equals( |
||||
"/")) { |
||||
System.out.println("docBase doesn't end with /, " + docBase |
||||
+ " trying to correct it by clipping"); |
||||
int posSeparator = docBase.lastIndexOf("/"); |
||||
docBase = docBase.substring(0, posSeparator + 1); |
||||
} |
||||
return docBase; |
||||
} |
||||
|
||||
} |
@ -1,29 +0,0 @@
@@ -1,29 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
import javax.swing.JApplet; |
||||
|
||||
public class SxAdminApplet |
||||
extends JApplet |
||||
{ |
||||
SuperXDBAdmin sxdbadmin; |
||||
|
||||
public void init() |
||||
{ |
||||
String propfile= getCodeBase()+ "superx.properties"; |
||||
System.out.println("propfile:"+propfile); |
||||
sxdbadmin = new SuperXDBAdmin(propfile,getDocumentBase().toString()); |
||||
|
||||
sxdbadmin.setLocation(50, 50); |
||||
sxdbadmin.setSize(700, 700); |
||||
} |
||||
|
||||
public void start() |
||||
{ |
||||
sxdbadmin.setVisible(true); |
||||
} |
||||
|
||||
public void stop() |
||||
{ |
||||
sxdbadmin.setVisible(false); |
||||
} |
||||
} |
||||
//Creation date: (05.02.2002 11:25:20)
|
@ -1,111 +0,0 @@
@@ -1,111 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
import java.text.DateFormat; |
||||
import java.text.ParseException; |
||||
import java.util.Calendar; |
||||
import java.util.GregorianCalendar; |
||||
import java.util.TimeZone; |
||||
|
||||
/** |
||||
* Statische Klasse mit Hilfsfunktionen für Datumsobjekte. |
||||
* |
||||
* @version 2.0 01/01/02 |
||||
* @author Rainer Behr, modified by Meikel Bisping |
||||
*/ |
||||
|
||||
public class SxDate { |
||||
static DateFormat df; |
||||
static java.util.Date date; |
||||
static java.sql.Date sql_date; |
||||
static Calendar calendar; |
||||
|
||||
static { |
||||
df = DateFormat.getDateInstance(DateFormat.MEDIUM); |
||||
// r.b. default Jahr 4-stellig
|
||||
df.setTimeZone(TimeZone.getDefault()); |
||||
df.setLenient(false); |
||||
} |
||||
|
||||
/** |
||||
* Wandelt einen String in ein java.sql.Date-Objekt um. |
||||
* @param value umzuformender String |
||||
* @return java.sql.Date-Objekt. Wenn der String nicht in Ordnung ist, wird NULL zurückgeliefert. |
||||
*/ |
||||
public static java.sql.Date getDate(String value) { |
||||
try { |
||||
if (value.endsWith("00")) { |
||||
switch (value.charAt(value.length() - 3)) { |
||||
case '-' : |
||||
case '.' : |
||||
case '/' : |
||||
value = value.substring(0, value.length() - 2) + "2000"; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
date = df.parse(value); |
||||
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); |
||||
|
||||
sql_date = new java.sql.Date(calendar.getTime().getTime()); |
||||
return sql_date; |
||||
} catch (ParseException e_parse) { |
||||
// System.err.println ("SxDate: ERROR: parse: Date != " + value);
|
||||
} catch (IllegalArgumentException e_arg) { |
||||
// System.err.println ("SxDate: ERROR: arg: Date != " + value);
|
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
/** |
||||
* Wandelt ein java.sql.Date-Objekt in einen String um. |
||||
* @param value umzuwandelndes sql.Date-Objekt |
||||
* @return String |
||||
*/ |
||||
|
||||
public static String toString(java.sql.Date aDate) { |
||||
return df.format((java.util.Date) aDate); |
||||
} |
||||
|
||||
/** |
||||
* Liefert das aktuelle Datum als String zurück. |
||||
* @return aktuelles Datum als String |
||||
*/ |
||||
|
||||
public static String getTodayString() { |
||||
GregorianCalendar cal = new GregorianCalendar(); |
||||
String today = |
||||
cal.get(Calendar.DATE) |
||||
+ "." |
||||
+ (cal.get(Calendar.MONTH) + 1) |
||||
+ "." |
||||
+ cal.get(Calendar.YEAR); |
||||
|
||||
return today; |
||||
} |
||||
public static String getNowString() { |
||||
GregorianCalendar cal = new GregorianCalendar(); |
||||
String jetzt = |
||||
cal.get(Calendar.DATE) |
||||
+ "." |
||||
+ (cal.get(Calendar.MONTH) + 1) |
||||
+ "." |
||||
+ cal.get(Calendar.YEAR) |
||||
+ " " |
||||
+ (cal.get(Calendar.HOUR_OF_DAY)) |
||||
+ ":" |
||||
+ cal.get(Calendar.MINUTE) |
||||
+ ":" |
||||
+ cal.get(Calendar.SECOND); |
||||
|
||||
|
||||
return jetzt; |
||||
} |
||||
|
||||
|
||||
} |
@ -1,144 +0,0 @@
@@ -1,144 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
import java.io.IOException; |
||||
import java.io.InputStream; |
||||
import java.net.URL; |
||||
import java.util.Enumeration; |
||||
import java.util.Hashtable; |
||||
import java.util.Properties; |
||||
|
||||
import javax.swing.JOptionPane; |
||||
|
||||
/** |
||||
* Defaultwerte werden aus superx.properties-Datei eingelesen (der wichtigste Wert ist SxServerURL, die URL des Servlets). |
||||
* <br>Weiterhin werden Defaultwerte von Auswahlfeldern (wie Semester oder Hörerstatus) abgelegt und wieder abgerufen.Diese Funktion wird in SxForm genutzt. |
||||
* @version 1.0 23.4.99 |
||||
* @author Rainer Behr |
||||
*/ |
||||
public class SxDefaults |
||||
{ |
||||
static Hashtable defaults_map; |
||||
static String propertyFile; |
||||
static String defaultServerUrl; |
||||
static |
||||
{ |
||||
defaults_map = new Hashtable (); |
||||
propertyFile = null; |
||||
} |
||||
|
||||
public static void setPropertyFile (String file) |
||||
{ |
||||
propertyFile = new String (file); |
||||
} |
||||
|
||||
public static void addProperty (String name, Object nkey, Object nvalue) |
||||
{ |
||||
Properties prop = new Properties (); |
||||
prop.put ("key", nkey); |
||||
prop.put ("value", nvalue); |
||||
|
||||
defaults_map.put (name, prop); |
||||
} |
||||
|
||||
public static Properties getProperty (String name) |
||||
{ |
||||
Properties prop = (Properties) defaults_map.get (name); |
||||
return prop; |
||||
|
||||
} |
||||
|
||||
public static Object getPropertyValue (String name) |
||||
{ |
||||
Properties prop = (Properties) defaults_map.get (name); |
||||
if (prop != null) |
||||
return prop.getProperty ("value"); |
||||
else |
||||
{ |
||||
String msg = "Property '" + name + "' in 'superx.properties' nicht gefunden !"; |
||||
throw new NullPointerException (msg); |
||||
} |
||||
} |
||||
|
||||
public static void contents() |
||||
{ |
||||
Enumeration en; |
||||
Properties prop; |
||||
String name; |
||||
Object key; |
||||
Object value; |
||||
|
||||
en = defaults_map.keys(); |
||||
|
||||
while (en.hasMoreElements()) |
||||
{ |
||||
name = (String) en.nextElement(); |
||||
prop = (Properties) SxDefaults.getProperty (name); |
||||
if (prop == null) |
||||
continue; |
||||
key = prop.get ("key"); |
||||
value = prop.get ("value"); |
||||
//System.out.println (name + ": key=" + key.toString() + ", value=" + value.toString());
|
||||
} |
||||
} |
||||
|
||||
public static void clear() |
||||
{ |
||||
defaults_map.clear(); |
||||
defaults_map = new Hashtable (); |
||||
|
||||
init (); |
||||
} |
||||
|
||||
public static void init () |
||||
{ |
||||
// Default Properties
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
String prop_file; |
||||
Properties props = new Properties(); |
||||
int b_len = 0; |
||||
|
||||
if (propertyFile != null) |
||||
prop_file = propertyFile; |
||||
else |
||||
prop_file = "file:superx.properties"; |
||||
|
||||
try |
||||
{ |
||||
URL props_url = new URL (prop_file); |
||||
InputStream is = props_url.openStream(); |
||||
if (is == null) |
||||
{ |
||||
String msg = "Ressourcedatei '" + prop_file + "' nicht gefunden."; |
||||
throw new IOException (msg); |
||||
} |
||||
|
||||
props.load (is); |
||||
is.close (); |
||||
|
||||
// Properties in Class SxDefaults einfuegen
|
||||
String key; |
||||
String value; |
||||
if (props.getProperty("SxServerURL")==null) |
||||
props.setProperty("SxServerURL",defaultServerUrl); |
||||
Enumeration en = props.propertyNames(); |
||||
|
||||
while (en.hasMoreElements()) |
||||
{ |
||||
key = (String) en.nextElement(); |
||||
value = (String) props.getProperty (key); |
||||
addProperty (key, key, value); |
||||
} |
||||
|
||||
} |
||||
catch (IOException ex) |
||||
{ |
||||
System.err.println (ex); |
||||
JOptionPane.showMessageDialog(null, ex.toString(), "Fehler", |
||||
JOptionPane.ERROR_MESSAGE); |
||||
} |
||||
} |
||||
public static void setDefaultServerUrl (String url) |
||||
{ |
||||
defaultServerUrl=url; |
||||
} |
||||
} |
File diff suppressed because one or more lines are too long
@ -1,95 +0,0 @@
@@ -1,95 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
import java.io.Serializable; |
||||
import java.sql.SQLException; |
||||
import java.util.Vector; |
||||
|
||||
import de.superx.common.SuperX_el; |
||||
|
||||
/** |
||||
* The SxSQLMetaData class is a subset implementation of the |
||||
* JDBC ResultSetMetaData interface.<BR> |
||||
* Last modified %D% |
||||
* @version %A% |
||||
* @author Rainer Behr (rainer@rbehr.de) |
||||
*/ |
||||
|
||||
public class SxSQLMetaData implements Serializable |
||||
{ |
||||
private Vector V_cols = new Vector ();; |
||||
private int numColumns = -1; |
||||
|
||||
|
||||
public SxSQLMetaData (SuperX_el gesamt) |
||||
throws SQLException |
||||
{ |
||||
// used MetaData
|
||||
// -------------
|
||||
// String getColumnName(int column)
|
||||
// String getColumnLabel(int column)
|
||||
// int getColumnDisplaySize(int column)
|
||||
// int getColumnType(int column)
|
||||
// int getScale(int column)
|
||||
// boolean isWritable(int column)
|
||||
|
||||
//ResultSetMetaData meta = resultset.getMetaData();
|
||||
numColumns = gesamt.getColumnCount(); |
||||
|
||||
for (int i = 0; i < numColumns; i++) |
||||
{ |
||||
Vector V_column = new Vector(); |
||||
V_column.add (0, gesamt.getColumnNames() [i]); |
||||
V_column.add (1, gesamt.getColumnLabels() [i]); |
||||
V_column.add (2, new Integer (gesamt.getColumnDisplaySizes() [i])); |
||||
V_column.add (3, new Integer (gesamt.getColumnTypes() [i])); |
||||
V_column.add (4, new Integer (gesamt.getScales() [i])); |
||||
V_column.add (5, new Boolean (gesamt.getisWritable() [i])); |
||||
|
||||
V_cols.add (V_column); |
||||
} |
||||
} |
||||
|
||||
public int getColumnCount() |
||||
{ |
||||
return numColumns; |
||||
} |
||||
|
||||
public String getColumnName (int column) |
||||
{ |
||||
Vector V_column = (Vector) V_cols.elementAt (column - 1); |
||||
return (String) V_column.elementAt (0); |
||||
} |
||||
|
||||
public String getColumnLabel (int column) |
||||
{ |
||||
Vector V_column = (Vector) V_cols.elementAt (column - 1); |
||||
return (String) V_column.elementAt (1); |
||||
} |
||||
|
||||
public int getColumnDisplaySize (int column) |
||||
{ |
||||
Vector V_column = (Vector) V_cols.elementAt (column - 1); |
||||
return ((Integer) V_column.elementAt (2)).intValue(); |
||||
} |
||||
|
||||
public int getColumnType (int column) |
||||
{ |
||||
Vector V_column = (Vector) V_cols.elementAt (column - 1); |
||||
return ((Integer) V_column.elementAt (3)).intValue(); |
||||
} |
||||
public int getScale (int column) |
||||
{ |
||||
Vector V_column = (Vector) V_cols.elementAt (column - 1); |
||||
return ((Integer) V_column.elementAt (4)).intValue(); |
||||
} |
||||
|
||||
public boolean isWritable (int column) |
||||
{ |
||||
Vector V_column = (Vector) V_cols.elementAt (column - 1); |
||||
return ((Boolean) V_column.elementAt (5)).booleanValue(); |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} |
@ -1,184 +0,0 @@
@@ -1,184 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
/** |
||||
Eintrag für den Themenbaum |
||||
*/ |
||||
import java.awt.datatransfer.DataFlavor; |
||||
import java.awt.datatransfer.Transferable; |
||||
import java.awt.datatransfer.UnsupportedFlavorException; |
||||
import java.io.IOException; |
||||
import java.io.Serializable; |
||||
|
||||
class SxThemenEintrag2 implements Transferable, Serializable, Cloneable |
||||
{ |
||||
final public static DataFlavor THEMEN_FLAVOR= new DataFlavor(SxThemenEintrag2.class,"SxThemenEintrag2"); |
||||
static DataFlavor flavors[]={THEMEN_FLAVOR}; |
||||
|
||||
Integer tid; |
||||
String name; |
||||
Integer maskeninfo_id; |
||||
Integer parent; |
||||
String erlaeuterung; |
||||
boolean erlaubt; |
||||
java.sql.Date gueltig_seit,gueltig_bis ; |
||||
|
||||
public SxThemenEintrag2() |
||||
{ |
||||
tid=null; |
||||
name=null; |
||||
maskeninfo_id=null; |
||||
parent=null; |
||||
erlaeuterung=null; |
||||
erlaubt=false; |
||||
gueltig_seit=gueltig_seit.valueOf("1900-01-01"); |
||||
gueltig_bis =gueltig_bis.valueOf("2999-01-01");; |
||||
|
||||
} |
||||
|
||||
public SxThemenEintrag2(Integer ltid,String lname) |
||||
{ |
||||
tid=ltid; |
||||
name=lname; |
||||
gueltig_seit=gueltig_seit.valueOf("1900-01-01"); |
||||
gueltig_bis =gueltig_bis.valueOf("2999-01-01");; |
||||
} |
||||
|
||||
public SxThemenEintrag2(Integer ltid, String lname, Integer lnr, Integer lparent) |
||||
{ |
||||
tid=ltid; |
||||
name=lname; |
||||
maskeninfo_id=lnr; |
||||
parent=lparent; |
||||
gueltig_seit=gueltig_seit.valueOf("1900-01-01"); |
||||
gueltig_bis =gueltig_bis.valueOf("2999-01-01");; |
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
public SxThemenEintrag2(Integer ltid, String lname, Integer lnr, Integer lparent, String lerlaeuterung,java.sql.Date lgueltig_seit,java.sql.Date lgueltig_bis) |
||||
{ |
||||
tid=ltid; |
||||
name=lname; |
||||
maskeninfo_id=lnr; |
||||
parent=lparent; |
||||
erlaeuterung=lerlaeuterung; |
||||
erlaubt=false; |
||||
gueltig_seit=lgueltig_seit; |
||||
gueltig_bis=lgueltig_bis; |
||||
} |
||||
|
||||
|
||||
public boolean isErlaubt() |
||||
{ |
||||
return erlaubt; |
||||
} |
||||
|
||||
public void setErlaubt(boolean lerlaubt) |
||||
{ |
||||
erlaubt=lerlaubt; |
||||
} |
||||
|
||||
public Integer getTid() |
||||
{ |
||||
return tid; |
||||
} |
||||
|
||||
public void setTid(Integer ltid) |
||||
{ |
||||
tid=ltid; |
||||
} |
||||
|
||||
public String getName() |
||||
{ |
||||
return name; |
||||
} |
||||
public Integer getMaskeninfo_id() |
||||
{ |
||||
return maskeninfo_id; |
||||
} |
||||
|
||||
public boolean isKnoten() |
||||
{ |
||||
return maskeninfo_id==null?true:false; |
||||
} |
||||
|
||||
public Integer getParent() |
||||
{ |
||||
return parent; |
||||
} |
||||
|
||||
public void setParent(Integer lparent) |
||||
{ |
||||
parent=lparent; |
||||
} |
||||
|
||||
public java.sql.Date getGueltigBis() |
||||
{ |
||||
return gueltig_bis; |
||||
} |
||||
|
||||
public void setGueltigBis(java.sql.Date bis) |
||||
{ |
||||
gueltig_bis=bis; |
||||
} |
||||
|
||||
public java.sql.Date getGueltigSeit() |
||||
{ |
||||
return gueltig_seit; |
||||
} |
||||
|
||||
public void setGueltigSeit(java.sql.Date seit) |
||||
{ |
||||
gueltig_seit=seit; |
||||
} |
||||
|
||||
public String getErlaeuterung() |
||||
{ |
||||
return erlaeuterung; |
||||
} |
||||
|
||||
|
||||
public String toString() |
||||
{ |
||||
return this.name; |
||||
} |
||||
|
||||
public Object getTransferData(DataFlavor df) throws UnsupportedFlavorException, IOException |
||||
{ |
||||
if (df.equals(THEMEN_FLAVOR)){ |
||||
return this; |
||||
} |
||||
else throw new UnsupportedFlavorException(df); |
||||
} |
||||
public DataFlavor[] getTransferDataFlavors(){ |
||||
return flavors; |
||||
} |
||||
// -----------transferable
|
||||
public boolean isDataFlavorSupported(DataFlavor df) |
||||
{ |
||||
return df.equals(THEMEN_FLAVOR); |
||||
} |
||||
|
||||
|
||||
private void readObject(java.io.ObjectInputStream in) |
||||
throws IOException, ClassNotFoundException { |
||||
in.defaultReadObject(); |
||||
} |
||||
//-------serializable
|
||||
private void writeObject(java.io.ObjectOutputStream out) throws IOException { |
||||
out.defaultWriteObject(); |
||||
} |
||||
|
||||
public Object clone() |
||||
{ |
||||
Object neu=null; |
||||
try |
||||
{ |
||||
neu= super.clone(); |
||||
} |
||||
catch (Exception e) |
||||
{} |
||||
return neu; |
||||
} |
||||
} |
@ -1,540 +0,0 @@
@@ -1,540 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
import java.io.FileNotFoundException; |
||||
import java.io.IOException; |
||||
import java.io.InputStream; |
||||
import java.text.DateFormat; |
||||
import java.util.Enumeration; |
||||
import java.util.Properties; |
||||
import java.util.Vector; |
||||
/** |
||||
* Die Klasse SxUtils führt String-Operationen zur Vorbereitung von Datenbank-Transaktionen durch |
||||
* |
||||
* |
||||
* @author R.Behr modified by Marlies Winterstein |
||||
* @version 2.0, 5 Jan 1998 - 0.9, 31 July 1998 modified 01-2002 |
||||
* |
||||
*/ |
||||
public class SxUtils |
||||
{ |
||||
public final static int bufSize = 32 * 1024; |
||||
public final static String errString = "--ERROR--"; |
||||
|
||||
private static String COMM_START = "/*"; |
||||
private static String COMM_END = "*/"; |
||||
|
||||
private static int COMM_START_LEN = COMM_START.length(); |
||||
private static int COMM_END_LEN = COMM_END.length(); |
||||
|
||||
private static String COMMENT1_ANF = "{"; |
||||
private static String COMMENT1_END = "}"; |
||||
private static String COMMENT2_ANF = "--"; |
||||
private static String COMMENT2_END = "\n"; |
||||
private static String COMMENT3_ANF = "/*"; |
||||
private static String COMMENT3_END = "*/"; |
||||
private static String COMMENT1_ANF_MASK = "#K#"; |
||||
private static String COMMENT1_END_MASK = "#/K"; |
||||
private static String COMMENT2_ANF_MASK = "#S#"; |
||||
private static String COMMENT2_END_MASK = "#/S#"; |
||||
private static String COMMENT3_ANF_MASK = "#*A#"; |
||||
private static String COMMENT3_END_MASK = "#*E#"; |
||||
private static String PREV_POS = ">>"; |
||||
private static String PREV_POS_MASK =">#>"; |
||||
private static String NEXT_POS = "<<"; |
||||
private static String NEXT_POS_MASK ="<#<"; |
||||
private static String SELECT_DELIMITER=";"; |
||||
private static String SELECT_DELIMITER_MASK="^"; |
||||
private static String STR_DELIMITER1="\""; |
||||
private static String STR_DELIMITER1_MASK="#s1#"; |
||||
private static String STR_DELIMITER2="'"; |
||||
private static String STR_DELIMITER2_MASK="#s2#"; |
||||
|
||||
|
||||
private static StringBuffer buffer; |
||||
private static String prev_str; |
||||
|
||||
static |
||||
{ |
||||
buffer = new StringBuffer (bufSize); |
||||
} |
||||
|
||||
public synchronized static void setFieldDelimiter (String field_start, String field_end) |
||||
{ |
||||
if (field_start != null) |
||||
{ |
||||
if (field_start.length() == 0) |
||||
NEXT_POS = ""; |
||||
else |
||||
NEXT_POS = field_start.substring (0, field_start.length() - 1); |
||||
} |
||||
|
||||
if (field_end != null) |
||||
{ |
||||
if (field_end.length() == 0) |
||||
PREV_POS = ""; |
||||
else |
||||
PREV_POS = field_end.substring (0, field_end.length() - 1); |
||||
} |
||||
} |
||||
|
||||
public static String getFieldPrefix () |
||||
{ |
||||
return new String (NEXT_POS); |
||||
} |
||||
|
||||
public static String getFieldSuffix () |
||||
{ |
||||
return new String (PREV_POS); |
||||
} |
||||
|
||||
public synchronized static void setComment (String comm_start, String comm_end) |
||||
{ |
||||
if (comm_start != null) |
||||
{ |
||||
COMM_START = comm_start; |
||||
COMM_START_LEN = comm_start.length(); |
||||
} |
||||
if (comm_end != null) |
||||
{ |
||||
COMM_END = comm_end; |
||||
COMM_END_LEN = comm_end.length(); |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
public synchronized static String deleteComment (String str, String comm_start_str, String comm_end_str) |
||||
{ |
||||
String return_str; |
||||
String search_str = comm_start_str; |
||||
|
||||
int comm_end = -1; |
||||
int pos = -1; |
||||
int offset = 0; |
||||
int len = str.length(); |
||||
int search_len = search_str.length(); |
||||
|
||||
try |
||||
{ |
||||
while (offset < len) |
||||
{ |
||||
if ((pos = str.indexOf (search_str, offset)) != -1) |
||||
{ |
||||
prev_str = str.substring (offset, pos); |
||||
comm_end = str.indexOf (comm_end_str, pos + search_len); |
||||
if (comm_end == -1) |
||||
throw new Exception ("no Comment-End found"); |
||||
buffer.append (prev_str); |
||||
offset = comm_end + comm_end_str.length(); |
||||
} |
||||
else |
||||
{ |
||||
buffer.append (str.substring (offset, len)); |
||||
offset = len; |
||||
} |
||||
} |
||||
} |
||||
catch (Exception e) |
||||
{ |
||||
System.err.println (e.toString()); |
||||
buffer.append (errString); |
||||
buffer.append (search_str); |
||||
} |
||||
|
||||
return_str = buffer.toString(); |
||||
buffer.setLength (0); |
||||
|
||||
return return_str; |
||||
} |
||||
|
||||
public synchronized static String replace (String str, String search_str, String replace_str) |
||||
{ |
||||
String return_str; |
||||
boolean delete_comment = false; |
||||
|
||||
int pos = -1; |
||||
int offset = 0; |
||||
int len = str.length(); |
||||
int search_len = search_str.length(); |
||||
int comm_start = -1; |
||||
int comm_end = -1; |
||||
int prev_pos = -1; |
||||
int next_pos = -1; |
||||
int mode = -1; |
||||
|
||||
// mode: 0 = kein Kommentar,
|
||||
// 1 = Kommentar loeschen mit Ersetzung,
|
||||
// 2 = Loeschen von COMM_START bis COMM_END
|
||||
|
||||
try |
||||
{ |
||||
delete_comment = replace_str.equals (""); |
||||
|
||||
while (offset < len) |
||||
{ |
||||
mode = -1; |
||||
|
||||
if ((pos = str.indexOf (search_str, offset)) != -1) |
||||
{ |
||||
prev_str = str.substring (offset, pos); |
||||
comm_start = prev_str.lastIndexOf (COMM_START); |
||||
prev_pos = prev_str.lastIndexOf (PREV_POS); |
||||
comm_end = str.indexOf (COMM_END, pos + search_len); |
||||
next_pos = str.indexOf (NEXT_POS, pos + search_len); |
||||
|
||||
if (comm_start >= 0 && prev_pos >= 0) // kein Kommentar
|
||||
if (comm_start < prev_pos) |
||||
comm_start = -1; |
||||
if (comm_end >= 0 && next_pos >=0) // kein Kommentar
|
||||
if (comm_end > next_pos) |
||||
comm_end = -1; |
||||
|
||||
if (comm_start != -1 && |
||||
comm_end != -1 && |
||||
comm_start <= pos && |
||||
comm_end >= pos) |
||||
{ |
||||
if (delete_comment) // keine Ersetzung,
|
||||
mode = 2; // Loeschen von '/*' - '*/'
|
||||
else |
||||
mode = 1; |
||||
} |
||||
else |
||||
mode = 0; |
||||
|
||||
switch (mode) |
||||
{ |
||||
case 0: |
||||
{ |
||||
buffer.append (prev_str); |
||||
buffer.append (replace_str); |
||||
offset = pos + search_len; |
||||
break; |
||||
} |
||||
case 1: |
||||
{ |
||||
buffer.append (prev_str.substring (0, comm_start)); |
||||
buffer.append (prev_str.substring (comm_start + COMM_START_LEN)); |
||||
buffer.append (replace_str); |
||||
buffer.append (str.substring (pos + search_len, comm_end)); |
||||
offset = comm_end + COMM_END_LEN; |
||||
break; |
||||
} |
||||
case 2: |
||||
{ |
||||
buffer.append (prev_str.substring (0, comm_start)); |
||||
offset = comm_end + COMM_END_LEN; |
||||
break; |
||||
} |
||||
default: |
||||
throw new Exception (errString); |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
buffer.append (str.substring (offset, len)); |
||||
offset = len; |
||||
} |
||||
} |
||||
|
||||
} |
||||
catch (Exception e) |
||||
{ |
||||
buffer.append (errString); |
||||
buffer.append (search_str); |
||||
} |
||||
|
||||
return_str = buffer.toString(); |
||||
buffer.setLength (0); |
||||
|
||||
return return_str; |
||||
} |
||||
|
||||
public synchronized static Vector getHeader (String str) |
||||
{ |
||||
Vector header = new Vector (); |
||||
int pos = 0; |
||||
int end_pos = 0; |
||||
int offset = 0; |
||||
int len = str.length(); |
||||
String search_str = "heading_text=\""; |
||||
String header_str = null; |
||||
int search_len = search_str.length(); |
||||
|
||||
while (offset < len) |
||||
{ |
||||
if ((pos = str.indexOf (search_str, offset)) != -1) |
||||
{ |
||||
if ((end_pos = str.indexOf ("\"", pos + search_len)) != -1) |
||||
{ |
||||
header_str = str.substring (pos + search_len, end_pos); |
||||
header.addElement (header_str); |
||||
offset = pos + search_len + header_str.length() + 1; |
||||
} |
||||
else |
||||
break; |
||||
} |
||||
else |
||||
break; |
||||
} |
||||
|
||||
return header; |
||||
} |
||||
|
||||
public synchronized static Vector getWidth (String str) |
||||
{ |
||||
Vector width = new Vector (); |
||||
int pos = 0; |
||||
int end_pos = 0; |
||||
int offset = 0; |
||||
int len = str.length(); |
||||
String search_str = "width="; |
||||
String width_str = null; |
||||
int search_len = search_str.length(); |
||||
|
||||
while (offset < len) |
||||
{ |
||||
if ((pos = str.indexOf (search_str, offset)) != -1) |
||||
{ |
||||
//gesucht wird bis Zeilenende, da keine Begrenzung durch "
|
||||
if ((end_pos = str.indexOf ("\n", pos + search_len)) != -1) |
||||
{ |
||||
width_str = str.substring (pos + search_len, end_pos); |
||||
//falls dummerweise danach noch weitere Eigenschaften in
|
||||
//gleicher Zeile
|
||||
int pos_leer = 0; |
||||
if ((pos_leer = width_str.indexOf(" ")) != -1) |
||||
width_str = width_str.substring(0, pos_leer); |
||||
width.addElement (width_str); |
||||
offset = pos + search_len + width_str.length() + 1; |
||||
} |
||||
else |
||||
break; |
||||
} |
||||
else |
||||
break; |
||||
} |
||||
|
||||
return width; |
||||
} |
||||
public synchronized static String replaceString (String str, String search_str, String replace_str) |
||||
{ |
||||
String zs=""; |
||||
int offset = 0; |
||||
int pos = str.indexOf (search_str, offset); |
||||
while (pos>-1) |
||||
{ |
||||
zs += str.substring(offset, pos); |
||||
zs += replace_str; |
||||
offset=pos + search_str.length(); |
||||
pos= str.indexOf (search_str, offset); |
||||
} |
||||
zs += str.substring(offset,str.length()); |
||||
return zs; |
||||
} |
||||
|
||||
|
||||
public synchronized static String escapeString (String str) |
||||
{ |
||||
String escapeString; |
||||
str=replaceString(str,PREV_POS,PREV_POS_MASK); |
||||
str=replaceString(str,NEXT_POS,NEXT_POS_MASK); |
||||
str=replaceString(str,SELECT_DELIMITER,SELECT_DELIMITER_MASK); |
||||
str=replaceString(str,STR_DELIMITER1,STR_DELIMITER1_MASK); |
||||
str=replaceString(str,STR_DELIMITER2,STR_DELIMITER2_MASK); |
||||
str=replaceString(str,COMMENT1_ANF,COMMENT1_ANF_MASK); |
||||
str=replaceString(str,COMMENT2_ANF,COMMENT2_ANF_MASK); |
||||
str=replaceString(str,COMMENT3_ANF,COMMENT3_ANF_MASK); |
||||
str=replaceString(str,COMMENT1_END,COMMENT1_END_MASK); |
||||
//str=replaceString(str,COMMENT2_END,COMMENT2_END_MASK);
|
||||
str=replaceString(str,COMMENT3_END,COMMENT3_END_MASK); |
||||
escapeString=str; |
||||
return escapeString; |
||||
} |
||||
public synchronized static String unescapeString (String str) |
||||
{ |
||||
String unescapeString; |
||||
str=replaceString(str,PREV_POS_MASK,PREV_POS); |
||||
str=replaceString(str,NEXT_POS_MASK,NEXT_POS); |
||||
//str=replaceString(str,SELECT_DELIMITER_MASK, SELECT_DELIMITER);
|
||||
str=replaceString(str,STR_DELIMITER1_MASK,STR_DELIMITER1); |
||||
str=replaceString(str,STR_DELIMITER2_MASK,"\\'"); //STR_DELIMITER2);
|
||||
str=replaceString(str,COMMENT1_ANF_MASK,COMMENT1_ANF); |
||||
str=replaceString(str,COMMENT2_ANF_MASK,COMMENT2_ANF); |
||||
str=replaceString(str,COMMENT3_ANF_MASK,COMMENT3_ANF); |
||||
str=replaceString(str,COMMENT1_END_MASK,COMMENT1_END); |
||||
str=replaceString(str,COMMENT3_END_MASK,COMMENT3_END); |
||||
unescapeString=str; |
||||
return unescapeString; |
||||
} |
||||
public synchronized static String escapeSpecialChars (String str) |
||||
{ |
||||
String escapeSpecialChars; |
||||
str=replaceString(str,SELECT_DELIMITER,"\\"+SELECT_DELIMITER); |
||||
str=replaceString(str,STR_DELIMITER1,"\\"+STR_DELIMITER1); |
||||
str=replaceString(str,STR_DELIMITER2,"\\"+STR_DELIMITER2); |
||||
//str=replaceString(str,"\\","\\\\");
|
||||
//str=replaceString(str,"%","\\%");
|
||||
escapeSpecialChars=str; |
||||
return escapeSpecialChars; |
||||
} |
||||
public synchronized static String GetValueAsString (Object value) |
||||
{ |
||||
String field_type=""; |
||||
String f_wert=""; |
||||
String fehler=""; |
||||
try { |
||||
if ((value instanceof java.sql.Date)) |
||||
f_wert = "" +DateFormat.getDateInstance().format(value); |
||||
else |
||||
{ |
||||
if (value instanceof java.sql.Timestamp) |
||||
f_wert = "" +DateFormat.getDateTimeInstance().format(value); |
||||
else |
||||
{ |
||||
if (value instanceof java.sql.Time) |
||||
f_wert = "" +DateFormat.getTimeInstance().format(value); |
||||
|
||||
else //default:
|
||||
f_wert=value.toString(); |
||||
} |
||||
} |
||||
} |
||||
catch (Exception e) |
||||
{ |
||||
fehler=e.toString(); |
||||
if (fehler.equals("java.lang.NullPointerException")) |
||||
f_wert=""; |
||||
else |
||||
f_wert="Feldtyp unbekannt:"+fehler; |
||||
} |
||||
String GetValueAsString=f_wert; |
||||
return GetValueAsString; |
||||
} |
||||
public synchronized static String RelationString (String feldart, String relation, String attribut) |
||||
{ |
||||
String stmt=relation; |
||||
if (stmt.startsWith ("<<SQL>>")) |
||||
{ |
||||
stmt = stmt.substring (7); |
||||
} |
||||
|
||||
if(attribut.trim().equals("")==false) |
||||
{ |
||||
if (attribut.indexOf (',') == -1) |
||||
attribut = "tid, " + attribut; |
||||
stmt = "select " + attribut + " from " + relation + " order by 2"; |
||||
} |
||||
|
||||
if (feldart.equals("4")) |
||||
{ |
||||
//Hier fehlt noch userrechte und lehre-Einschränkung
|
||||
stmt = "SELECT organigramm.parent, organigramm.key_apnr, organigramm.name FROM organigramm WHERE gueltig_seit<now() And gueltig_bis>now() ORDER BY organigramm.name;"; |
||||
} |
||||
if (feldart.equals("6") ) |
||||
{ |
||||
//6-Institutionsdialog für Lehreinheiten
|
||||
stmt = "SELECT organigramm.parent, organigramm.key_apnr, organigramm.name FROM organigramm WHERE gueltig_seit<now() And gueltig_bis>now() ORDER BY organigramm.name;"; |
||||
} |
||||
if (feldart.equals("7") ) |
||||
{ |
||||
//7-Institutionsdialog für Lehreinheiten ohne Einschr. Userrechte
|
||||
stmt = "SELECT organigramm.parent, organigramm.key_apnr, organigramm.name FROM organigramm WHERE gueltig_seit<now() And gueltig_bis>now() ORDER BY organigramm.name;"; |
||||
} |
||||
String RelationString=stmt; |
||||
return RelationString; |
||||
} |
||||
public static void main (String args[]) |
||||
{ |
||||
String sql_str = null; |
||||
String search_str = null; |
||||
String replace_str = null; |
||||
Properties props = new Properties(); |
||||
|
||||
if (args.length != 2) |
||||
{ |
||||
System.err.println ("Usage: <filename> <propertyfile>"); |
||||
System.exit(1); |
||||
} |
||||
|
||||
String filename = "/" + args[0]; |
||||
String propname = "/" + args[1]; |
||||
|
||||
try |
||||
{ |
||||
byte [] buf = new byte[bufSize]; |
||||
byte [] data = new byte[bufSize]; |
||||
int read_len = 0, data_len = 0; |
||||
|
||||
InputStream is = props.getClass().getResourceAsStream(filename); |
||||
if (is == null) |
||||
{ |
||||
System.err.println ("Resource '" + filename + "' not found"); |
||||
System.exit (1); |
||||
} |
||||
|
||||
while (read_len != -1) |
||||
{ |
||||
read_len = is.read (buf, 0, buf.length); |
||||
if (read_len != -1) |
||||
data_len = read_len; |
||||
} |
||||
|
||||
is.close (); |
||||
|
||||
data = new byte [data_len]; |
||||
System.arraycopy (buf, 0, data, 0, data_len); |
||||
|
||||
sql_str = new String (data); |
||||
|
||||
is = props.getClass().getResourceAsStream(propname); |
||||
if (is == null) |
||||
{ |
||||
System.err.println ("Resource '" + propname + "' not found"); |
||||
System.exit (1); |
||||
} |
||||
|
||||
props.load (is); |
||||
is.close (); |
||||
|
||||
Enumeration en = props.propertyNames(); |
||||
String key; |
||||
String value; |
||||
|
||||
System.err.println ("sql ... "); |
||||
|
||||
while (en.hasMoreElements()) |
||||
{ |
||||
key = (String) en.nextElement(); |
||||
value = (String) props.getProperty (key); |
||||
key = "<<" + key + ">>"; |
||||
System.err.println ("Key: " + key + " = " + value); |
||||
sql_str = SxUtils.replace (sql_str, key, value); |
||||
} |
||||
|
||||
sql_str = SxUtils.deleteComment (sql_str, "{", "}"); |
||||
sql_str = SxUtils.deleteComment (sql_str, "--", "\n"); |
||||
sql_str = SxUtils.deleteComment (sql_str, "/*", "*/"); |
||||
} |
||||
|
||||
catch (FileNotFoundException e) |
||||
{ |
||||
System.err.println (e); |
||||
System.exit (1); |
||||
} |
||||
|
||||
catch (SecurityException e) |
||||
{ |
||||
System.err.println (e); |
||||
System.exit (1); |
||||
} |
||||
|
||||
catch (IOException e) |
||||
{ |
||||
System.err.println (e); |
||||
System.exit (1); |
||||
} |
||||
|
||||
System.err.println ("done"); |
||||
} |
||||
|
||||
} |
@ -1,305 +0,0 @@
@@ -1,305 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
|
||||
import java.awt.Cursor; |
||||
import java.awt.Image; |
||||
import java.awt.Point; |
||||
import java.awt.datatransfer.Transferable; |
||||
import java.awt.dnd.DnDConstants; |
||||
import java.awt.dnd.DragGestureEvent; |
||||
import java.awt.dnd.DragGestureListener; |
||||
import java.awt.dnd.DragGestureRecognizer; |
||||
import java.awt.dnd.DragSource; |
||||
import java.awt.dnd.DragSourceContext; |
||||
import java.awt.dnd.DragSourceDragEvent; |
||||
import java.awt.dnd.DragSourceDropEvent; |
||||
import java.awt.dnd.DragSourceEvent; |
||||
import java.awt.dnd.DragSourceListener; |
||||
import java.awt.dnd.DropTarget; |
||||
import java.awt.dnd.DropTargetDragEvent; |
||||
import java.awt.dnd.DropTargetDropEvent; |
||||
import java.awt.dnd.DropTargetEvent; |
||||
import java.awt.dnd.DropTargetListener; |
||||
import java.awt.dnd.peer.DragSourceContextPeer; |
||||
import java.awt.event.InputEvent; |
||||
import java.util.Enumeration; |
||||
|
||||
import javax.swing.tree.DefaultMutableTreeNode; |
||||
import javax.swing.tree.DefaultTreeModel; |
||||
import javax.swing.tree.TreePath; |
||||
|
||||
import de.memtext.tree.AutoScrollJTree; |
||||
|
||||
class ThemenDragTree extends AutoScrollJTree implements DragGestureListener, |
||||
DragSourceListener, DropTargetListener { |
||||
private DragSource dragSource; |
||||
private DragSourceContext dragSourceContext = null; |
||||
private DropTarget dropTarget; |
||||
int maxtid = 0; |
||||
|
||||
int actions; |
||||
|
||||
//DefaultTreeModel model;
|
||||
//private ThemenbaumPanel themenb;
|
||||
public ThemenDragTree(String actionstr) { |
||||
super(); |
||||
|
||||
// dragSource = DragSource.getDefaultDragSource();
|
||||
|
||||
/* |
||||
* ein Bug im Quellcode führt zu Cursorflakern, |
||||
* http://www.javaworld.com/javaworld/javatips/jw-javatip97.html daher
|
||||
* updateCursor überlagern import
|
||||
* java.awt.dnd.peer.DragSourceContextPeer; nötig |
||||
*/ |
||||
dragSource = new DragSource() { |
||||
protected DragSourceContext createDragSourceContext( |
||||
DragSourceContextPeer dscp, DragGestureEvent dgl, |
||||
Cursor dragCursor, Image dragImage, Point imageOffset, |
||||
Transferable t, DragSourceListener dsl) { |
||||
return new DragSourceContext(dscp, dgl, dragCursor, dragImage, |
||||
imageOffset, t, dsl) { |
||||
protected void updateCurrentCursor(int dropOp, |
||||
int targetAct, int status) { |
||||
} |
||||
}; |
||||
}; |
||||
}; |
||||
|
||||
if (actionstr.equals("copy_move")) |
||||
actions = DnDConstants.ACTION_COPY_OR_MOVE; |
||||
else |
||||
actions = DnDConstants.ACTION_COPY; |
||||
|
||||
DragGestureRecognizer dgr = dragSource |
||||
.createDefaultDragGestureRecognizer(this, // drag Herkunft
|
||||
// Component
|
||||
actions, // actions
|
||||
this); // drag gesture recognizer
|
||||
|
||||
//rechte Maustaste ignorieren
|
||||
dgr.setSourceActions(dgr.getSourceActions() & ~InputEvent.BUTTON3_MASK); |
||||
|
||||
dropTarget = new DropTarget(this, actions, this); |
||||
|
||||
} |
||||
|
||||
private void setNoDropCursor() { |
||||
//dragSourceContext vorher als Membervariable definiert
|
||||
if (dragSourceContext != null) |
||||
dragSourceContext.setCursor(DragSource.DefaultMoveNoDrop); |
||||
} |
||||
|
||||
private void setCursor(DragSourceDragEvent e) { |
||||
dragSourceContext = e.getDragSourceContext(); |
||||
dragSourceContext.setCursor(selectCursor(e.getDropAction())); |
||||
} |
||||
|
||||
private Cursor selectCursor(int action) { |
||||
return (action == DnDConstants.ACTION_MOVE) ? DragSource.DefaultMoveDrop |
||||
: DragSource.DefaultCopyDrop; |
||||
} |
||||
|
||||
//source
|
||||
public void dragDropEnd(DragSourceDropEvent e) { |
||||
} |
||||
|
||||
public void dragEnter(DragSourceDragEvent e) { |
||||
setCursor(e); |
||||
} |
||||
|
||||
public void dragEnter(DropTargetDragEvent e) { |
||||
} |
||||
|
||||
public void dragExit(DragSourceEvent e) { |
||||
} |
||||
|
||||
public void dragExit(DropTargetEvent e) { |
||||
} |
||||
|
||||
public void dragGestureRecognized(DragGestureEvent e) { |
||||
TreePath path = this.getLeadSelectionPath(); |
||||
DefaultMutableTreeNode was = (DefaultMutableTreeNode) path |
||||
.getLastPathComponent(); |
||||
Transferable tr = (Transferable) was.getUserObject(); |
||||
Cursor cursor = selectCursor(e.getDragAction()); |
||||
dragSource.startDrag(e, cursor, tr, this); |
||||
/* |
||||
* e.startDrag( cursor, // cursor null, // transferable this); // drag
|
||||
* source listener |
||||
*/ |
||||
} |
||||
|
||||
public void dragOver(DragSourceDragEvent e) { |
||||
setCursor(e); |
||||
} |
||||
|
||||
public void dragOver(DropTargetDragEvent e) { |
||||
//set cursor location. Needed in setCursor method
|
||||
|
||||
Point cursorLocationBis = e.getLocation(); |
||||
TreePath destinationPath = getPathForLocation(cursorLocationBis.x, |
||||
cursorLocationBis.y); |
||||
|
||||
if (destinationPath == null) { |
||||
e.rejectDrag(); |
||||
setNoDropCursor(); |
||||
return; |
||||
} |
||||
|
||||
DefaultMutableTreeNode node = (DefaultMutableTreeNode) destinationPath |
||||
.getLastPathComponent(); |
||||
Object userobj = node.getUserObject(); |
||||
if (userobj instanceof SxThemenEintrag2) { |
||||
SxThemenEintrag2 x = (SxThemenEintrag2) userobj; |
||||
if (x.isKnoten()) |
||||
e.acceptDrag(actions); |
||||
else { |
||||
e.rejectDrag(); |
||||
setNoDropCursor(); |
||||
} |
||||
} else { |
||||
setNoDropCursor(); |
||||
e.rejectDrag(); |
||||
} |
||||
} |
||||
|
||||
public void dropActionChanged(DragSourceDragEvent e) { |
||||
setCursor(e); |
||||
} |
||||
|
||||
//target
|
||||
public void drop(DropTargetDropEvent e) { |
||||
DefaultMutableTreeNode oldParent = null, newParent = null; |
||||
SxThemenEintrag2 x; |
||||
try { |
||||
TreePath selectedNodePath = this.getLeadSelectionPath(); |
||||
DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) selectedNodePath |
||||
.getLastPathComponent(); |
||||
|
||||
Point loc = e.getLocation(); |
||||
TreePath destinationPath = this.getPathForLocation(loc.x, loc.y); |
||||
newParent = (DefaultMutableTreeNode) destinationPath |
||||
.getLastPathComponent(); |
||||
SxThemenEintrag2 xnewparent = (SxThemenEintrag2) newParent |
||||
.getUserObject(); |
||||
//Transferable transferable=e.getTransferable();
|
||||
DefaultMutableTreeNode newChild = null; |
||||
if (e.getDropAction() == DnDConstants.ACTION_COPY) { //neues Kind
|
||||
// erstellen
|
||||
//SxThemenEintrag2
|
||||
// inhalt=(SxThemenEintrag2)selectedNode.getUserObject();
|
||||
// Object data = transferable.getTransferData();
|
||||
// newChild = new DefaultMutableTreeNode(data.clone());
|
||||
// newChild=new DefaultMutableTreeNode(inhalt);
|
||||
newChild = nodeCopy(selectedNode, xnewparent.getTid()); |
||||
} else { //move
|
||||
newChild = selectedNode; |
||||
oldParent = (DefaultMutableTreeNode) selectedNode.getParent(); |
||||
oldParent.remove(newChild); |
||||
x = (SxThemenEintrag2) newChild.getUserObject(); |
||||
x.setParent(xnewparent.getTid()); |
||||
} |
||||
newParent.add(newChild); |
||||
|
||||
if (e.getDropAction() == DnDConstants.ACTION_COPY) |
||||
e.acceptDrop(DnDConstants.ACTION_COPY); |
||||
else |
||||
e.acceptDrop(DnDConstants.ACTION_MOVE); |
||||
e.getDropTargetContext().dropComplete(true); |
||||
/* |
||||
* DefaultMutableTreeNode |
||||
* oldparent=(DefaultMutableTreeNode)selectedNode.getParent(); |
||||
* verschiebNode.removeFromParent(); Integer newParentKeyApnr; |
||||
* |
||||
* //Transferable tr=e.getTransferable(); Point loc =
|
||||
* e.getLocation(); TreePath destinationPath = |
||||
* this.getPathForLocation(loc.x, loc.y); DefaultMutableTreeNode |
||||
* newParent = (DefaultMutableTreeNode) |
||||
* destinationPath.getLastPathComponent(); SxThemenEintrag2 |
||||
* newParentOrgaEintrag=(SxThemenEintrag2)newParent.getUserObject(); //
|
||||
* newParentKeyApnr=newParentOrgaEintrag.getKeyApnr(); |
||||
* |
||||
* newParent.add(selectedNode); orgaEintrag2 |
||||
* verschiebOrgaEintrag=(orgaEintrag2)verschiebNode.getUserObject(); |
||||
* //parent anpassen
|
||||
* verschiebOrgaEintrag.setParent(newParentKeyApnr); //Ebene knoten
|
||||
* selbst + alle Unterknoten anpassen Integer neueEbene=new |
||||
* Integer(verschiebNode.getLevel()-1); |
||||
* verschiebOrgaEintrag.setEbene(neueEbene); DefaultMutableTreeNode |
||||
* aNode;orgaEintrag2 x; for (Enumeration en = |
||||
* verschiebNode.depthFirstEnumeration() ; en.hasMoreElements() ;) { |
||||
* aNode=(DefaultMutableTreeNode)en.nextElement(); neueEbene=new |
||||
* Integer(aNode.getLevel()-1); |
||||
* x=(orgaEintrag2)aNode.getUserObject(); x.setEbene(neueEbene); } |
||||
* |
||||
* e.acceptDrop(DnDConstants.ACTION_MOVE); |
||||
* e.getDropTargetContext().dropComplete(true); //model neu laden
|
||||
* und Ast aufklappen DefaultTreeModel model=(DefaultTreeModel) |
||||
* getModel(); model.reload(oldparent); model.reload(newParent); |
||||
* TreePath parentPath=new TreePath(newParent.getPath()); |
||||
* expandPath(parentPath); |
||||
*/ |
||||
|
||||
((DefaultTreeModel) getModel()).reload(oldParent); |
||||
((DefaultTreeModel) getModel()).reload(newParent); |
||||
|
||||
} catch (Exception ex) { |
||||
ex.printStackTrace(); |
||||
} |
||||
this.validate(); |
||||
this.repaint(); |
||||
} |
||||
|
||||
public void dropActionChanged(DropTargetDragEvent e) { |
||||
} |
||||
|
||||
private void parentEintragAnpassen(DefaultMutableTreeNode node) { |
||||
DefaultMutableTreeNode aNode; |
||||
SxThemenEintrag2 x2; |
||||
SxThemenEintrag2 x = (SxThemenEintrag2) node.getUserObject(); |
||||
//für weitere Unterknoten rekursiv aufrufen
|
||||
for (Enumeration en = node.depthFirstEnumeration(); en |
||||
.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
if (aNode != node) { |
||||
x2 = (SxThemenEintrag2) aNode.getUserObject(); |
||||
x2.setParent(x.getTid()); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public int getMaxTid() { |
||||
return maxtid; |
||||
} |
||||
|
||||
public void setMaxTid(int neu) { |
||||
maxtid = neu; |
||||
} |
||||
|
||||
public void incMaxTid() { |
||||
maxtid++; |
||||
} |
||||
|
||||
private DefaultMutableTreeNode nodeCopy(DefaultMutableTreeNode org, |
||||
Integer parent) { |
||||
DefaultMutableTreeNode aNode, weitererKnoten; |
||||
SxThemenEintrag2 x = (SxThemenEintrag2) org.getUserObject(); |
||||
SxThemenEintrag2 xneu = (SxThemenEintrag2) x.clone(); |
||||
int newtid = getMaxTid() + 1; |
||||
xneu.setTid(new Integer(newtid)); |
||||
setMaxTid(newtid); |
||||
xneu.setParent(parent); |
||||
DefaultMutableTreeNode neu = new DefaultMutableTreeNode(xneu); |
||||
|
||||
//für weitere Unterknoten rekursiv aufrufen
|
||||
for (Enumeration en = org.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
if (aNode != org) { |
||||
weitererKnoten = nodeCopy(aNode, new Integer(newtid)); |
||||
neu.add(weitererKnoten); |
||||
} |
||||
|
||||
} |
||||
return neu; |
||||
} |
||||
} |
@ -1,719 +0,0 @@
@@ -1,719 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
|
||||
//24.7.04 dq: Postgres themenbaum auf date_val geändert.
|
||||
import java.awt.BorderLayout; |
||||
import java.awt.Frame; |
||||
import java.awt.GridLayout; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.awt.event.KeyEvent; |
||||
import java.awt.event.KeyListener; |
||||
import java.sql.SQLException; |
||||
import java.util.Enumeration; |
||||
import java.util.TimeZone; |
||||
import java.util.Vector; |
||||
|
||||
import javax.swing.JButton; |
||||
import javax.swing.JOptionPane; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JScrollPane; |
||||
import javax.swing.tree.DefaultMutableTreeNode; |
||||
import javax.swing.tree.DefaultTreeCellRenderer; |
||||
import javax.swing.tree.DefaultTreeModel; |
||||
import javax.swing.tree.TreePath; |
||||
import javax.swing.tree.TreeSelectionModel; |
||||
|
||||
import de.memtext.util.DateUtils; |
||||
import de.memtext.util.WindowUtils; |
||||
|
||||
class ThemenbaumPanel extends JPanel implements ActionListener, KeyListener { |
||||
static Vector themenbaum; |
||||
static ThemenDragTree tree; |
||||
|
||||
static SxThemenEintrag2 einEintrag; |
||||
static JScrollPane scrollp; |
||||
static String standDatum; |
||||
static Vector problemfälle; |
||||
private boolean isSaveNecessary; |
||||
|
||||
public ThemenbaumPanel() { |
||||
super(); |
||||
|
||||
this.setLayout(new BorderLayout()); |
||||
|
||||
tree = new ThemenDragTree("copy_move"); |
||||
tree.setRootVisible(false); |
||||
|
||||
//Markierungsrandfarbe grau nicht gelb
|
||||
DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer(); |
||||
renderer.setBorderSelectionColor(java.awt.Color.darkGray); |
||||
tree.setCellRenderer(renderer); |
||||
|
||||
tree.addKeyListener(this); |
||||
|
||||
scrollp = new JScrollPane(tree); |
||||
this.add(scrollp, "Center"); |
||||
JPanel down = new JPanel(new GridLayout(2, 1)); |
||||
JPanel p1 = new JPanel(); |
||||
JButton blöschen = new JButton("löschen"); |
||||
blöschen.addActionListener(this); |
||||
p1.add(blöschen); |
||||
JButton bneuerKnoten = new JButton("Knoten hinzufügen"); |
||||
bneuerKnoten.addActionListener(this); |
||||
p1.add(bneuerKnoten); |
||||
JButton bneueMaske = new JButton("Maske hinzufügen"); |
||||
bneueMaske.addActionListener(this); |
||||
p1.add(bneueMaske); |
||||
down.add(p1); |
||||
JPanel p2 = new JPanel(); |
||||
JButton bspeich = new JButton("speichern"); |
||||
bspeich.addActionListener(this); |
||||
p2.add(bspeich); |
||||
JButton bneueinlesen = new JButton("neu einlesen"); |
||||
bneueinlesen.addActionListener(this); |
||||
p2.add(bneueinlesen); |
||||
JButton bbackuprestore = new JButton("Backup wiederherstellen"); |
||||
bbackuprestore.addActionListener(this); |
||||
p2.add(bbackuprestore); |
||||
|
||||
down.add(p2); |
||||
this.add(down, "South"); |
||||
backupAnlegen(); |
||||
|
||||
} |
||||
|
||||
public void actionPerformed(ActionEvent e) { |
||||
String cmd = e.getActionCommand(); |
||||
|
||||
if (cmd.equals("löschen")) |
||||
löschen(); |
||||
|
||||
if (cmd.equals("Knoten hinzufügen")) |
||||
knotenHinzufügen(); |
||||
|
||||
if (cmd.equals("Maske hinzufügen")) |
||||
MaskeHinzufügen(); |
||||
|
||||
if (cmd.equals("speichern")) |
||||
speichern(); |
||||
if (cmd.equals("neu einlesen")) |
||||
neuEinlesen(); |
||||
if (cmd.equals("Backup wiederherstellen")) |
||||
backupRestore(); |
||||
|
||||
} |
||||
|
||||
private void backupAnlegen() { |
||||
try { |
||||
|
||||
DBAccess.executeUpdate("delete from themenbaum_bak where 1=1"); |
||||
DBAccess |
||||
.executeUpdate("insert into themenbaum_bak select * from themenbaum"); |
||||
|
||||
} catch (Exception e) { |
||||
JOptionPane.showMessageDialog(null, |
||||
"Fehler beim Datenbank-Zugriff:\n " + e.toString(), |
||||
"SuperX DB Admin", JOptionPane.WARNING_MESSAGE); |
||||
|
||||
e.printStackTrace(); |
||||
} |
||||
SuperXDBAdmin.setStatus("Backup von Tabelle themenbaum angelegt!"); |
||||
|
||||
} |
||||
|
||||
private void backupRestore() { |
||||
try { |
||||
|
||||
DBAccess.executeUpdate("delete from themenbaum where 1=1"); |
||||
DBAccess |
||||
.executeUpdate("insert into themenbaum select * from themenbaum_bak"); |
||||
neuEinlesen(); |
||||
} catch (Exception e) { |
||||
JOptionPane.showMessageDialog(null, |
||||
"Fehler beim Datenbank-Zugriff:\n " + e.toString(), |
||||
"SuperX DB Admin", JOptionPane.WARNING_MESSAGE); |
||||
|
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
} |
||||
|
||||
private void neuEinlesen() { |
||||
readTreeFromDb(standDatum); |
||||
this.validate(); |
||||
isSaveNecessary=false; |
||||
} |
||||
|
||||
private void MaskeHinzufügen() { |
||||
String rückmeldung = ""; |
||||
TreePath currentSelection = tree.getSelectionPath(); |
||||
if (currentSelection != null) { |
||||
DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode) (currentSelection |
||||
.getLastPathComponent()); |
||||
Object userobj = currentNode.getUserObject(); |
||||
SxThemenEintrag2 x = (SxThemenEintrag2) userobj; |
||||
|
||||
if (!x.isKnoten()) { |
||||
currentNode = (DefaultMutableTreeNode) currentNode.getParent(); |
||||
userobj = currentNode.getUserObject(); |
||||
x = (SxThemenEintrag2) userobj; |
||||
|
||||
} |
||||
|
||||
Maskenauswahl ma = new Maskenauswahl((Frame) this |
||||
.getTopLevelAncestor()); |
||||
ma.show(); |
||||
if (ma.getGewählt() != -1) { |
||||
try { |
||||
String name = (String) DBAccess |
||||
.executeQuerySingleValue("select name from maskeninfo where tid=" |
||||
+ ma.getGewählt()); |
||||
tree.incMaxTid(); |
||||
SxThemenEintrag2 neu = new SxThemenEintrag2(new Integer( |
||||
tree.getMaxTid()), name, new Integer(ma |
||||
.getGewählt()), x.getTid()); |
||||
DefaultMutableTreeNode neuerKnoten = new DefaultMutableTreeNode( |
||||
neu); |
||||
currentNode.add(neuerKnoten); |
||||
((DefaultTreeModel) tree.getModel()).reload(currentNode); |
||||
rückmeldung = new String("Maske hinzugefügt!"); |
||||
isSaveNecessary = true; |
||||
} catch (Exception e) { |
||||
if (e.toString().indexOf("No current row") > 0) |
||||
rückmeldung = new String("Maske nicht gefunden"); |
||||
else |
||||
rückmeldung = "Fehler beim Datenbankzugriff - " |
||||
+ e.toString(); |
||||
} |
||||
} |
||||
} else |
||||
rückmeldung = new String( |
||||
"Es muss erst ein Knoten ausgewählt werden"); |
||||
SuperXDBAdmin.setStatus(rückmeldung); |
||||
} |
||||
|
||||
private void löschen() { |
||||
TreePath currentSelection = tree.getSelectionPath(); |
||||
if (currentSelection != null) { |
||||
int erg = JOptionPane |
||||
.showConfirmDialog( |
||||
this, |
||||
"Soll dieser Eintrag gelöscht werden?\n\nHinweis: Es wird nur der Eintrag im Themenbaum gelöscht.\nWenn Sie eine Maske komplett löschen wollen,\ntun Sie dies unter Maskenverwaltung!", |
||||
"SuperX DB Admin", JOptionPane.YES_NO_OPTION); |
||||
if (erg != JOptionPane.YES_OPTION) |
||||
return; |
||||
|
||||
DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode) (currentSelection |
||||
.getLastPathComponent()); |
||||
DefaultMutableTreeNode parent = (DefaultMutableTreeNode) (currentNode |
||||
.getParent()); |
||||
if (parent != null) { |
||||
parent.remove(currentNode); |
||||
|
||||
((DefaultTreeModel) tree.getModel()).reload(parent); |
||||
isSaveNecessary = true; |
||||
} |
||||
} |
||||
|
||||
this.validate(); |
||||
this.repaint(); |
||||
} |
||||
|
||||
private void knotenHinzufügen() { |
||||
java.sql.Date gueltig_seit = new java.sql.Date(1); |
||||
gueltig_seit = gueltig_seit.valueOf("1900-01-01"); |
||||
java.sql.Date gueltig_bis = new java.sql.Date(1); |
||||
gueltig_bis = gueltig_bis.valueOf("2999-01-01"); |
||||
TreePath currentSelection = tree.getSelectionPath(); |
||||
if (currentSelection != null) { |
||||
DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode) (currentSelection |
||||
.getLastPathComponent()); |
||||
Object userobj = currentNode.getUserObject(); |
||||
if (userobj instanceof SxThemenEintrag2) { |
||||
SxThemenEintrag2 x = (SxThemenEintrag2) userobj; |
||||
if (x.isKnoten()) { |
||||
String eingabe = JOptionPane.showInputDialog(this, |
||||
"Name des neuen Knotens:", "SuperX", |
||||
JOptionPane.QUESTION_MESSAGE); |
||||
if (eingabe != null) { |
||||
tree.incMaxTid(); |
||||
SxThemenEintrag2 neu = new SxThemenEintrag2( |
||||
new Integer(tree.getMaxTid()), eingabe); |
||||
neu.setParent(x.getTid()); |
||||
neu.setGueltigSeit(gueltig_seit); |
||||
neu.setGueltigBis(gueltig_bis); |
||||
DefaultMutableTreeNode neuerKnoten = new DefaultMutableTreeNode( |
||||
neu); |
||||
currentNode.add(neuerKnoten); |
||||
((DefaultTreeModel) tree.getModel()) |
||||
.reload(currentNode); |
||||
isSaveNecessary = true; |
||||
} |
||||
|
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
void readTreeFromDb(String lStand) { |
||||
WindowUtils.setWaitCursor(this, true); |
||||
//liefert Themenbaum v. angegebenen Stand zurück
|
||||
String name, erlaeuterung; |
||||
Integer tid, maskeninfo_id, parent; |
||||
java.sql.Date gueltig_seit, gueltig_bis; |
||||
//neu erstellen nur beim 1.mal und anderem Stand
|
||||
int entryCount; |
||||
// if (Stand == null || (!Stand.equals(lStand))) {
|
||||
if (lStand == null) |
||||
lStand = DateUtils.getTodayString(); |
||||
standDatum = lStand; |
||||
String sx_db = (String) SxDefaults.getPropertyValue("SxDB"); |
||||
|
||||
//tree erzeugen für Stand
|
||||
//aus Datenbank auslesen
|
||||
try { |
||||
|
||||
//datum String in sql.Date umformen
|
||||
java.sql.Date date = new java.sql.Date(1); |
||||
SxDate mydate = new SxDate(); |
||||
date = mydate.getDate(standDatum); |
||||
Vector rohform = new Vector(); |
||||
String query = ""; |
||||
//Rohfassung (vector in vector) aus DB
|
||||
if (sx_db.equals("Postgres")) { |
||||
query = "select T.tid,T.name, T.maskeninfo_id, T.parent, T.erlaeuterung,T.gueltig_seit,T.gueltig_bis " |
||||
+ "from themenbaum T " |
||||
+ "where T.maskeninfo_id is null and " |
||||
+ "T.gueltig_seit<=date_val('" |
||||
+ standDatum |
||||
+ "') and T.gueltig_bis>=date_val('" |
||||
+ standDatum |
||||
+ "') " |
||||
+ " union " |
||||
+ |
||||
|
||||
//und alle Abfragen
|
||||
"select T.tid,M.name, T.maskeninfo_id, T.parent, M.erlaeuterung,T.gueltig_seit,T.gueltig_bis " |
||||
+ "from themenbaum T, maskeninfo M " |
||||
+ "where T.maskeninfo_id=M.tid and " |
||||
+ "T.gueltig_seit<=date_val('" |
||||
+ standDatum |
||||
+ "') and T.gueltig_bis>=date_val('" |
||||
+ standDatum |
||||
+ "') " + " order by 2"; |
||||
} else { |
||||
|
||||
//informix
|
||||
|
||||
query = "select T.tid,T.name, T.maskeninfo_id, T.parent, T.erlaeuterung,T.gueltig_seit,T.gueltig_bis " |
||||
+ "from themenbaum T " |
||||
+ "where T.maskeninfo_id is null and " |
||||
+ "T.gueltig_seit<=date('" |
||||
+ standDatum |
||||
+ "') and T.gueltig_bis>=date('" |
||||
+ standDatum |
||||
+ "') " |
||||
+ " union " |
||||
+ |
||||
|
||||
//und alle Abfragen
|
||||
"select T.tid,M.name, T.maskeninfo_id, T.parent, M.erlaeuterung,T.gueltig_seit,T.gueltig_bis " |
||||
+ "from themenbaum T, maskeninfo M " |
||||
+ "where T.maskeninfo_id=M.tid and " |
||||
+ "T.gueltig_seit<=date('" |
||||
+ standDatum |
||||
+ "') and T.gueltig_bis>=date('" |
||||
+ standDatum |
||||
+ "') " |
||||
+ " order by 2"; |
||||
|
||||
} |
||||
Integer mtid = (Integer) DBAccess |
||||
.executeQuerySingleValue("select max(tid) from themenbaum"); |
||||
tree.setMaxTid(mtid.intValue()); |
||||
|
||||
rohform = DBAccess.executeQuery(query); |
||||
if (rohform.size() < 1) |
||||
throw new Exception(); |
||||
entryCount = rohform.size(); |
||||
//Umformen in Vector of SxThemenEintrag2
|
||||
Vector dummy = new Vector(); |
||||
themenbaum = new Vector(); |
||||
Enumeration en1 = rohform.elements(); |
||||
while (en1.hasMoreElements()) { |
||||
dummy = (Vector) en1.nextElement(); |
||||
tid = (Integer) dummy.elementAt(0); |
||||
name = (String) dummy.elementAt(1); |
||||
name = name.trim(); |
||||
maskeninfo_id = (Integer) dummy.elementAt(2); |
||||
parent = (Integer) dummy.elementAt(3); |
||||
erlaeuterung = (String) dummy.elementAt(4); |
||||
gueltig_seit = (java.sql.Date) dummy.elementAt(5); |
||||
gueltig_bis = (java.sql.Date) dummy.elementAt(6); |
||||
einEintrag = new SxThemenEintrag2(tid, name, maskeninfo_id, |
||||
parent, erlaeuterung, gueltig_seit, gueltig_bis); |
||||
themenbaum.addElement(einEintrag); |
||||
} |
||||
rohform = null; |
||||
SxThemenEintrag2 ebene0 = new SxThemenEintrag2(null, |
||||
"Abfragen/Berichte", null, null, null, null, null); |
||||
DefaultMutableTreeNode root = new DefaultMutableTreeNode(ebene0); |
||||
|
||||
//hier werden über eine rekursive Methode alle
|
||||
//Institute in den Baum eingetragen
|
||||
insertnodes(null, root); |
||||
//
|
||||
|
||||
//Baum erzeugen
|
||||
DefaultTreeModel treeModel = new DefaultTreeModel(root); |
||||
tree.setModel(treeModel); |
||||
prüfeDifferenzen(themenbaum); |
||||
themenbaum = null; |
||||
//root Abfragen/Berichte sieht man sowieso nicht
|
||||
//first child abfragen muss aufgeklappt sein
|
||||
//da Mouselistener Doubleclick umfunktioniert
|
||||
if (root.getChildCount() > 0) { |
||||
DefaultMutableTreeNode ebene1 = (DefaultMutableTreeNode) root |
||||
.getChildAt(0); |
||||
tree.expandPath(new TreePath(ebene1.getPath())); |
||||
} |
||||
|
||||
//Einfachselektion
|
||||
tree.getSelectionModel().setSelectionMode( |
||||
TreeSelectionModel.SINGLE_TREE_SELECTION); |
||||
|
||||
prüfeToteEinträge(); |
||||
SuperXDBAdmin.setStatus(" Themenbaum eingelesen (" + entryCount |
||||
+ " Einträge)"); |
||||
|
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
JOptionPane.showMessageDialog(null, "Fehler bei Datenbankzugriff: " |
||||
+ e.toString(), "Themenbaum", 1); |
||||
} finally { |
||||
WindowUtils.setWaitCursor(this, false); |
||||
} |
||||
|
||||
} |
||||
|
||||
private void prüfeToteEinträge() throws Exception { |
||||
Vector eintrag; |
||||
Vector tot = DBAccess |
||||
.executeQuery("select maskeninfo_id,name, tid from themenbaum where maskeninfo_id not in (select tid from maskeninfo)"); |
||||
if (tot.size() > 0) { |
||||
System.out |
||||
.println("Einträge in Themenbaum, für die kein Eintrag mehr in maskeninfo ist:"); |
||||
for (Enumeration en = tot.elements(); en.hasMoreElements();) { |
||||
eintrag = (Vector) en.nextElement(); |
||||
System.out.println(eintrag.get(0) + ": " + eintrag.get(1) |
||||
+ " themenbaum.tid=" + eintrag.get(2)); |
||||
} |
||||
JOptionPane |
||||
.showMessageDialog( |
||||
null, |
||||
"Es gibt " |
||||
+ tot.size() |
||||
+ " Einträge in Themenbaum, für die kein Eintrag mehr in maskeninfo ist.\n(siehe Konsole) Wenn Sie speichern werden diese Einträge gelöscht!", |
||||
"SuperX DB Admin", 1); |
||||
|
||||
} |
||||
} |
||||
|
||||
public boolean isSaveNecessary() { |
||||
return isSaveNecessary; |
||||
} |
||||
|
||||
private void insertnodes(Integer theParent, DefaultMutableTreeNode aktNode) { |
||||
//rekursive Methode, die Institutionen in den Baum einträgt
|
||||
Vector result = new Vector(); |
||||
result = mySelect(theParent); |
||||
Integer eintrag_tid; |
||||
|
||||
for (Enumeration el = result.elements(); el.hasMoreElements();) { |
||||
einEintrag = (SxThemenEintrag2) el.nextElement(); |
||||
DefaultMutableTreeNode neuNode = new DefaultMutableTreeNode( |
||||
einEintrag); |
||||
aktNode.add(neuNode); |
||||
|
||||
eintrag_tid = einEintrag.getTid(); |
||||
//nervig null-Werte abfangen
|
||||
if (eintrag_tid != null & theParent == null) |
||||
insertnodes(einEintrag.getTid(), neuNode); |
||||
if (eintrag_tid == null & theParent == null) |
||||
System.out |
||||
.println("Achtung! Element hat fälschlicherweise sich selbst als parent:" |
||||
+ einEintrag.getName()); |
||||
|
||||
if (eintrag_tid != null && theParent != null) |
||||
if (!theParent.equals(eintrag_tid)) |
||||
insertnodes(einEintrag.getTid(), neuNode); |
||||
else |
||||
System.out |
||||
.println("Achtung! Element hat fälschlicherweise sich selbst als parent:" |
||||
+ einEintrag.getName() |
||||
+ "tid:" |
||||
+ einEintrag.getTid()); |
||||
} |
||||
|
||||
} |
||||
|
||||
private Vector mySelect(Integer pruefparent) { |
||||
//liefert alle Institute mit Parent =pruefparent zurück
|
||||
Vector result = new Vector(); |
||||
Integer eintrag_parent; |
||||
for (Enumeration el = themenbaum.elements(); el.hasMoreElements();) { |
||||
einEintrag = (SxThemenEintrag2) el.nextElement(); |
||||
eintrag_parent = einEintrag.getParent(); |
||||
if (eintrag_parent == null && pruefparent == null) |
||||
result.addElement(einEintrag); |
||||
if (eintrag_parent != null && pruefparent != null) |
||||
if (eintrag_parent.intValue() == pruefparent.intValue()) |
||||
result.addElement(einEintrag); |
||||
|
||||
} |
||||
return result; |
||||
} |
||||
|
||||
private void addNode() { |
||||
/* |
||||
* DefaultMutableTreeNode parentNode = null; TreePath parentPath = |
||||
* tree.getSelectionPath(); |
||||
* |
||||
* if (parentPath == null) { parentNode = root; } else { parentNode = |
||||
* (DefaultMutableTreeNode) (parentPath.getLastPathComponent()); } |
||||
* |
||||
* //ebene feststellen int ebene = parentNode.getLevel();
|
||||
* |
||||
* orgaEintrag2 parentEintrag = (orgaEintrag2) |
||||
* parentNode.getUserObject(); |
||||
* |
||||
* java.sql.Date gueltig_seit = new java.sql.Date(1); gueltig_seit = |
||||
* gueltig_seit.valueOf("2001-10-01"); java.sql.Date gueltig_bis = new |
||||
* java.sql.Date(1); gueltig_bis = gueltig_bis.valueOf("2999-01-01"); |
||||
* orgaEintrag2 neuerEintrag = new orgaEintrag2( "Neue OrgaEinheit","", |
||||
* new Integer(1), new Integer(ebene), parentEintrag.getKeyApnr(), new |
||||
* Integer(1), gueltig_seit, gueltig_bis,new Integer(0)); |
||||
* DefaultMutableTreeNode childNode = new |
||||
* DefaultMutableTreeNode(neuerEintrag); |
||||
* |
||||
* OrgaBearbDialog dlg = new OrgaBearbDialog( linkToMain, childNode, |
||||
* merkungültig, (DefaultMutableTreeNode) parentNode.getRoot()); |
||||
* |
||||
* //wenn nicht Abbrechen, null setzen klappt aus irgend einem Grund
|
||||
* nicht if (childNode != null) { neuerEintrag = (orgaEintrag2) |
||||
* childNode.getUserObject(); if (!neuerEintrag.getName().equals("Neue |
||||
* OrgaEinheit")) { treeModel.insertNodeInto(childNode, parentNode, |
||||
* parentNode.getChildCount()); |
||||
* // Make sure the user can see the lovely new node.
|
||||
* |
||||
* tree.scrollPathToVisible(new TreePath(childNode.getPath())); |
||||
* etwasGeändert = true; } } |
||||
*/ |
||||
} |
||||
|
||||
public void bearbeiten() { |
||||
/* |
||||
* etwasGeändert = true; DefaultMutableTreeNode node = |
||||
* (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); |
||||
* |
||||
* OrgaBearbDialog dlg2 = new OrgaBearbDialog(dummyframe, node, |
||||
* merkungültig); DefaultTreeModel dtm = (DefaultTreeModel) |
||||
* tree.getModel(); |
||||
* |
||||
* dtm.nodeChanged(node); |
||||
*/ |
||||
} |
||||
|
||||
public String dateToString(java.sql.Date inp) { |
||||
java.text.DateFormat df; |
||||
df = java.text.DateFormat.getDateInstance(java.text.DateFormat.MEDIUM); |
||||
// r.b. default Jahr 4-stellig
|
||||
df.setTimeZone(TimeZone.getDefault()); |
||||
df.setLenient(false); |
||||
|
||||
String help = df.format((java.util.Date) inp); |
||||
return help; |
||||
} |
||||
|
||||
private void speichern() { |
||||
String ins; |
||||
int i = 0; |
||||
String sql = null; |
||||
String sx_db = (String) SxDefaults.getPropertyValue("SxDB"); |
||||
|
||||
//erstmal von Informix ausgehen
|
||||
|
||||
try { |
||||
|
||||
DefaultMutableTreeNode lroot = (DefaultMutableTreeNode) tree |
||||
.getModel().getRoot(); |
||||
DefaultMutableTreeNode aNode; |
||||
SxThemenEintrag2 x; |
||||
//DBAccess.executeUpdate("delete from themenbaum where 1=1");
|
||||
|
||||
DefaultMutableTreeNode vorher; |
||||
aNode = null; |
||||
sql = "create temp table tmp_themenbaum (" + "tid integer," |
||||
+ "name char(50) not null ," + "maskeninfo_id integer," |
||||
+ "parent integer," + "gueltig_seit date," |
||||
+ "gueltig_bis date," + "erlaeuterung char(240)); "; |
||||
for (Enumeration en = lroot.depthFirstEnumeration(); en |
||||
.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
if (!(aNode.getUserObject() instanceof SxThemenEintrag2)) |
||||
continue; |
||||
x = (SxThemenEintrag2) aNode.getUserObject(); |
||||
|
||||
if (x.getTid() != null) { |
||||
// erstmal von Informix ausgehen
|
||||
|
||||
ins = new String( |
||||
"insert into tmp_themenbaum (tid,name,maskeninfo_id,parent,gueltig_seit,gueltig_bis) values (" |
||||
+ x.getTid() |
||||
+ ",'" |
||||
+ x.getName() |
||||
+ "'," |
||||
+ x.getMaskeninfo_id() |
||||
+ "," |
||||
+ x.getParent() |
||||
+ ",date('" |
||||
+ SxUtils.GetValueAsString(x |
||||
.getGueltigSeit()) |
||||
+ "'),date('" |
||||
+ SxUtils.GetValueAsString(x |
||||
.getGueltigBis()) + "')); "); |
||||
if (sx_db.equals("Postgres")) { |
||||
ins = "insert into tmp_themenbaum (tid,name,maskeninfo_id,parent,gueltig_seit,gueltig_bis) values (" |
||||
+ x.getTid() |
||||
+ ",'" |
||||
+ x.getName() |
||||
+ "'," |
||||
+ x.getMaskeninfo_id() |
||||
+ "," |
||||
+ x.getParent() |
||||
+ ",date_val('" |
||||
+ SxUtils.GetValueAsString(x.getGueltigSeit()) |
||||
+ "'),date('" |
||||
+ SxUtils.GetValueAsString(x.getGueltigBis()) |
||||
+ "')); "; |
||||
} |
||||
sql += ins; |
||||
i++; |
||||
//progress.inc();
|
||||
//System.out.println(ins);
|
||||
|
||||
} |
||||
} |
||||
try { |
||||
sql += "delete from themenbaum where 1=1; "; |
||||
sql += "insert into themenbaum select * from tmp_themenbaum;"; |
||||
sql += "drop table tmp_themenbaum;"; |
||||
DBAccess.executeUpdateAll(sql); |
||||
} catch (SQLException e) { |
||||
System.out.println(sql); |
||||
System.out.println("Fehler beim Schreiben in die Datenbank:\n " |
||||
+ e.toString()); |
||||
} |
||||
|
||||
//Probleme sind unter Knoten Fehler schon aufgeführt und werden
|
||||
// auch mit der ersten
|
||||
//Schleife gespeichert!!
|
||||
|
||||
//falls es Problemfälle gab, diese auch noch speichern
|
||||
/* |
||||
* if(problemfälle != null) { for (Enumeration |
||||
* en=problemfälle.elements(); en.hasMoreElements(); ) { |
||||
* x=(SxThemenEintrag2)en.nextElement(); ins = new String( "insert |
||||
* into themenbaum |
||||
* (tid,name,maskeninfo_id,parent,gueltig_seit,gueltig_bis) values (" + |
||||
* x.getTid() + ",'" + x.getName() + "'," + x.getMaskeninfo_id() + |
||||
* "," + x.getParent() //
|
||||
* +",date('01.01.1900'),date('01.01.3000'),null)"); + ",date('" + |
||||
* SxUtils.GetValueAsString(x.getGueltigSeit())+"'),date('" + |
||||
* SxUtils.GetValueAsString(x.getGueltigBis())+"'))"); |
||||
* |
||||
* try { DBAccess.executeUpdate(ins); } catch (SQLException e){ |
||||
* System.out.println(ins); System.out.println("Fehler beim |
||||
* Schreiben eines Problemfalls in die Datenbank:\n " + |
||||
* e.toString()); } i++; |
||||
* } //von for-Schleife } //wenn es Problemfälle gab
|
||||
*/ |
||||
|
||||
isSaveNecessary=false; |
||||
|
||||
} catch (Exception e) { |
||||
JOptionPane |
||||
.showMessageDialog(null, |
||||
"Fehler beim Schreiben in die Datenbank:\n " |
||||
+ e.toString(), "SuperX DB Admin", |
||||
JOptionPane.WARNING_MESSAGE); |
||||
|
||||
e.printStackTrace(); |
||||
} |
||||
//progress.hide();
|
||||
//progress.dispose();
|
||||
|
||||
SuperXDBAdmin.setStatus(i + " Einträge in themenbaum geschrieben"); |
||||
WindowUtils.setWaitCursor(this, false); |
||||
|
||||
} |
||||
|
||||
public void keyPressed(KeyEvent event) { |
||||
System.out.println(event.getKeyCode()); |
||||
if (event.getKeyCode() == KeyEvent.VK_DELETE) |
||||
löschen(); |
||||
|
||||
} |
||||
|
||||
public void keyReleased(KeyEvent event) { |
||||
} |
||||
|
||||
public void keyTyped(KeyEvent event) { |
||||
if (event.getKeyCode() == KeyEvent.VK_DELETE) |
||||
löschen(); |
||||
} |
||||
|
||||
private void prüfeDifferenzen(Vector themenbaum) { |
||||
problemfälle = null; |
||||
DefaultMutableTreeNode aNode; |
||||
DefaultMutableTreeNode root = (DefaultMutableTreeNode) tree.getModel() |
||||
.getRoot(); |
||||
SxThemenEintrag2 x; |
||||
//Themenbaum enthält zu Anfang alle eingelesenen, gültigen Einträge
|
||||
//diejenigen, die in Baum vorkommen werden ausgelöscht
|
||||
|
||||
for (Enumeration en = root.depthFirstEnumeration(); en |
||||
.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
x = (SxThemenEintrag2) aNode.getUserObject(); |
||||
themenbaum.remove(x); |
||||
} |
||||
//System.out.println(themenbaum.size());
|
||||
|
||||
if (themenbaum.size() > 0) { |
||||
JOptionPane |
||||
.showMessageDialog( |
||||
null, |
||||
"Achtung!\nEs gibt " |
||||
+ themenbaum.size() |
||||
+ " gültige Einträge, die nicht in die Baumstruktur passten!\n(Siehe Konsole)", |
||||
"SuperX Admin", JOptionPane.WARNING_MESSAGE); |
||||
|
||||
DefaultMutableTreeNode fehlernode = new DefaultMutableTreeNode( |
||||
"Fehler"); |
||||
|
||||
for (Enumeration el = themenbaum.elements(); el.hasMoreElements();) { |
||||
x = (SxThemenEintrag2) el.nextElement(); |
||||
fehlernode.add(new DefaultMutableTreeNode(x)); |
||||
System.out.println(x.getTid() + ":" + x.getName() + " parent:" |
||||
+ x.getParent()); |
||||
|
||||
} |
||||
root.add(fehlernode); |
||||
((DefaultTreeModel) tree.getModel()).reload(); |
||||
tree.validate(); |
||||
problemfälle = themenbaum; |
||||
} |
||||
|
||||
} |
||||
} |
@ -1,239 +0,0 @@
@@ -1,239 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
|
||||
import java.awt.Font; |
||||
import java.awt.GridLayout; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.util.Enumeration; |
||||
import java.util.Vector; |
||||
|
||||
import javax.swing.JButton; |
||||
import javax.swing.JCheckBox; |
||||
import javax.swing.JLabel; |
||||
import javax.swing.JOptionPane; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JTextField; |
||||
|
||||
import de.memtext.util.WindowUtils; |
||||
|
||||
class UserGroupMembershipPanel extends JPanel implements ActionListener { |
||||
|
||||
private MBComboBox mbt; |
||||
private JTextField tname = new JTextField(10); |
||||
private JTextField tkenn = new JTextField(10); |
||||
private JCheckBox[] groups; |
||||
private JPanel groupsPanel; |
||||
|
||||
public UserGroupMembershipPanel() { |
||||
super(); |
||||
mbt = new MBComboBox(); |
||||
mbt.addActionListener(this); |
||||
this.setLayout(new GridLayout(5, 1)); |
||||
JPanel p0 = new JPanel(); |
||||
p0.add(mbt); |
||||
this.add(p0); |
||||
JPanel p1 = new JPanel(); |
||||
JLabel lkenn = new JLabel("Kennung:"); |
||||
|
||||
p1.add(lkenn); |
||||
tkenn.setEnabled(false); |
||||
p1.add(tkenn); |
||||
JLabel lname = new JLabel("Name:"); |
||||
p1.add(lname); |
||||
p1.add(tname); |
||||
this.add(p1); |
||||
|
||||
groupsPanel = new JPanel(new GridLayout(10, 10)); |
||||
|
||||
this.add(groupsPanel); |
||||
JPanel p5 = new JPanel(); |
||||
JButton bspeich = new JButton("speichern"); |
||||
bspeich.addActionListener(this); |
||||
p5.add(bspeich); |
||||
this.add(p5); |
||||
|
||||
} |
||||
|
||||
void prepare() { |
||||
WindowUtils.setWaitCursor(this,true); |
||||
mbt.removeAllItems(); |
||||
//special version!
|
||||
mbt.addAll(DBAccess.getUserListe()); |
||||
if (SuperXDBAdmin.getSelectedUser() != -999) |
||||
mbt.setSelection(SuperXDBAdmin.getSelectedUser()); |
||||
else |
||||
SuperXDBAdmin.setSelectedUser(mbt.getSelectedID()); |
||||
|
||||
//array wird auch beim speichern noch gebraucht
|
||||
groups = gruppenEinlesen(); |
||||
groupsPanel.removeAll(); |
||||
for (int i = 0; i < groups.length; i++) { |
||||
groupsPanel.add(groups[i]); |
||||
} |
||||
nutzerGewählt(); |
||||
WindowUtils.setWaitCursor(this,false); |
||||
} |
||||
|
||||
private JCheckBox[] gruppenEinlesen() { |
||||
JCheckBox[] gruppen = null; |
||||
String name; |
||||
Vector liste = new Vector(); |
||||
try { |
||||
|
||||
String query = "select name from groupinfo order by 1"; |
||||
|
||||
liste = DBAccess.executeQuery(query); |
||||
|
||||
gruppen = new JCheckBox[liste.size()]; |
||||
int i = 0; |
||||
Vector help; |
||||
for (Enumeration el = liste.elements(); el.hasMoreElements();) { |
||||
help = (Vector) el.nextElement(); |
||||
name = (String) help.get(0); |
||||
gruppen[i] = new JCheckBox(name); |
||||
gruppen[i].setFont(new Font("Times", Font.PLAIN, 10)); |
||||
i++; |
||||
} |
||||
} catch (Exception e) { |
||||
JOptionPane.showMessageDialog(null, |
||||
"Fehler beim Lesen aus der Datenbank: " + e.toString(), |
||||
"SuperX DB Admin", JOptionPane.WARNING_MESSAGE); |
||||
e.printStackTrace(); |
||||
} |
||||
return gruppen; |
||||
} |
||||
|
||||
public void actionPerformed(ActionEvent event) { |
||||
// if (event.getActionCommand().equals("speichern"))
|
||||
// NutzerRechteSpeichern();
|
||||
if (event.getActionCommand().equals("speichern")) |
||||
userDatenSpeichern(); |
||||
|
||||
if (event.getSource() instanceof MBComboBox) { |
||||
MBComboBox localbox = (MBComboBox) event.getSource(); |
||||
SuperXDBAdmin.setSelectedUser(localbox.getSelectedID()); |
||||
nutzerGewählt(); |
||||
} |
||||
|
||||
} |
||||
|
||||
/* |
||||
* public Vector NutzerListeEinlesen() { Vector userliste = new Vector(); |
||||
* Vector row; Integer id; String benutzer, email, name, max_versuch, |
||||
* akt_versuch; |
||||
* |
||||
* try { |
||||
* |
||||
* String query = "select tid, benutzer,name,email,max_versuch,akt_versuch |
||||
* from userinfo order by benutzer"; Statement statement = |
||||
* myConnection.createStatement(); ResultSet rs1 = |
||||
* statement.executeQuery(query); while (rs1.next()) { id = (Integer) |
||||
* rs1.getObject("tid"); benutzer = rs1.getObject("benutzer").toString(); |
||||
* email = DBAccess.getString(rs1, "email"); name = DBAccess.getString(rs1, |
||||
* "name"); max_versuch = DBAccess.getString(rs1, "max_versuch"); |
||||
* akt_versuch = DBAccess.getString(rs1, "akt_versuch"); row = new Vector(); |
||||
* row.add(id); row.add(benutzer); row.add(name); row.add(email); |
||||
* row.add(max_versuch); row.add(akt_versuch); userliste.add(row); |
||||
* } rs1.close(); statement.close(); |
||||
* } catch (Exception e) { JOptionPane.showMessageDialog( null, "Fehler |
||||
* beim Lesen aus der Datenbank: " + e.toString(), "SuperX DB Admin", |
||||
* JOptionPane.WARNING_MESSAGE); e.printStackTrace(); } return userliste; } |
||||
*/ |
||||
|
||||
private void nutzerGewählt() { |
||||
Vector zeile; |
||||
|
||||
Integer test; |
||||
|
||||
for (Enumeration el = DBAccess.getUserListe().elements(); el |
||||
.hasMoreElements();) { |
||||
zeile = ((Vector) el.nextElement()); |
||||
test = (Integer) zeile.get(0); |
||||
if (test.intValue() == SuperXDBAdmin.getSelectedUser()) { |
||||
tkenn.setText((String) zeile.get(1)); |
||||
tkenn.setCaretPosition(0); |
||||
tname.setText((String) zeile.get(2)); |
||||
tname.setCaretPosition(0); |
||||
|
||||
} |
||||
} |
||||
try { |
||||
|
||||
String query = "select G.name from groupinfo G, user_group_bez U where G.tid=U.groupinfo_id and " |
||||
+ " U.userinfo_id=" |
||||
+ SuperXDBAdmin.getSelectedUser() |
||||
+ " order by 1"; |
||||
String help2, help3; |
||||
|
||||
Vector mitgliedschaft = DBAccess.executeQuery(query); |
||||
|
||||
//erstmal auf false
|
||||
for (int i2 = 0; i2 < groups.length; i2++) { |
||||
groups[i2].setSelected(false); |
||||
} |
||||
Vector help; |
||||
for (Enumeration el = mitgliedschaft.elements(); el |
||||
.hasMoreElements();) { |
||||
help = (Vector) el.nextElement(); //weil Vector in Vector
|
||||
// zurückgeliefert
|
||||
|
||||
help2 = (String) help.get(0); |
||||
help2 = help2.trim(); |
||||
for (int i = 0; i < groups.length; i++) { |
||||
help3 = groups[i].getText().trim(); |
||||
if (help2.equals(help3)) { |
||||
groups[i].setSelected(true); |
||||
} |
||||
} |
||||
} |
||||
this.validate(); |
||||
this.repaint(); |
||||
SuperXDBAdmin.setStatus("Benutzer ausgewählt"); |
||||
|
||||
} |
||||
|
||||
catch (Exception e) { |
||||
SuperXDBAdmin.setStatus("interner Fehler: " + e.toString()); |
||||
|
||||
} |
||||
this.repaint(); |
||||
} |
||||
|
||||
private void userDatenSpeichern() { |
||||
try { |
||||
WindowUtils.setWaitCursor(this,true); |
||||
String upd = "delete from user_group_bez where userinfo_id=" |
||||
+ SuperXDBAdmin.getSelectedUser(); |
||||
DBAccess.executeUpdate(upd); |
||||
Integer tid; |
||||
for (int i = 0; i < groups.length; i++) { |
||||
if (groups[i].isSelected()) { |
||||
|
||||
tid = (Integer) DBAccess |
||||
.executeQuerySingleValue("select tid from groupinfo where name='" |
||||
+ groups[i].getText().trim() + "'"); |
||||
upd = "insert into user_group_bez values(" |
||||
+ SuperXDBAdmin.getSelectedUser() + "," + tid + ")"; |
||||
DBAccess.executeUpdate(upd); |
||||
} |
||||
} |
||||
|
||||
SuperXDBAdmin.setStatus("Gruppenzuordnung gespeichert!"); |
||||
|
||||
} catch (Exception e) { |
||||
JOptionPane |
||||
.showMessageDialog(null, |
||||
"Fehler beim Schreiben in die Datenbank:\n " |
||||
+ e.toString(), "SuperX DB Admin", |
||||
JOptionPane.WARNING_MESSAGE); |
||||
|
||||
e.printStackTrace(); |
||||
|
||||
} |
||||
finally |
||||
{ |
||||
WindowUtils.setWaitCursor(this,false); |
||||
} |
||||
|
||||
} |
||||
} |
@ -1,946 +0,0 @@
@@ -1,946 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Container; |
||||
import java.awt.Cursor; |
||||
import java.awt.Font; |
||||
import java.awt.Frame; |
||||
import java.awt.GridLayout; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.text.DateFormat; |
||||
import java.text.ParseException; |
||||
import java.util.Calendar; |
||||
import java.util.Enumeration; |
||||
import java.util.GregorianCalendar; |
||||
import java.util.TimeZone; |
||||
import java.util.Vector; |
||||
|
||||
import javax.swing.CellEditor; |
||||
import javax.swing.JButton; |
||||
import javax.swing.JLabel; |
||||
import javax.swing.JOptionPane; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JScrollPane; |
||||
import javax.swing.JTextField; |
||||
import javax.swing.JTree; |
||||
import javax.swing.event.CellEditorListener; |
||||
import javax.swing.event.ChangeEvent; |
||||
import javax.swing.tree.DefaultMutableTreeNode; |
||||
import javax.swing.tree.DefaultTreeModel; |
||||
import javax.swing.tree.TreePath; |
||||
import javax.swing.tree.TreeSelectionModel; |
||||
|
||||
class UserInst extends JPanel implements CellEditorListener, ActionListener { |
||||
boolean result; |
||||
boolean etwasGeändert = false; |
||||
Frame dummyframe; |
||||
OrgaEintrag2 gewaehlt = null; |
||||
OrgaEintrag2 einEintrag; |
||||
Vector orga; |
||||
Vector merkungültig; |
||||
int AnzahlEinträge; |
||||
JLabel Standlabel; |
||||
GregorianCalendar cal = new GregorianCalendar(); |
||||
String Stand; |
||||
JTextField suchtext; |
||||
Container cp; |
||||
JTree tree=null; |
||||
DefaultTreeModel treeModel; |
||||
JScrollPane treeScroll; |
||||
DefaultMutableTreeNode root; |
||||
|
||||
|
||||
SuperXDBAdmin linkToMain; |
||||
|
||||
public UserInst(SuperXDBAdmin llinkToMain) { |
||||
super(); |
||||
linkToMain=llinkToMain; |
||||
this.setLayout(new BorderLayout()); |
||||
//top panel für Stand
|
||||
|
||||
Stand = |
||||
cal.get(Calendar.DATE) |
||||
+ "." |
||||
+ (cal.get(Calendar.MONTH) + 1) |
||||
+ "." |
||||
+ cal.get(Calendar.YEAR); |
||||
//aktuelles Datum ist default
|
||||
|
||||
JPanel top = new JPanel(); |
||||
|
||||
MBComboBox mbt = new MBComboBox(DBAccess.getUserListe()); |
||||
//mbt.AddActionListener(this);
|
||||
|
||||
top.add(mbt); |
||||
Standlabel = new JLabel("Stand: " + Stand); |
||||
Standlabel.setFont(new Font("Arial", Font.PLAIN, 10)); |
||||
JButton bStand = new JButton("anderer Stand"); |
||||
bStand.setFont(new Font("Arial", Font.PLAIN, 10)); |
||||
bStand.setDefaultCapable(false); |
||||
bStand.addActionListener(this); |
||||
top.add(Standlabel); |
||||
top.add(bStand); |
||||
|
||||
this.add(top, "North"); |
||||
|
||||
//JTree erzeugen
|
||||
|
||||
|
||||
tree = tree_erzeugen(); |
||||
treeScroll = new JScrollPane(tree); |
||||
|
||||
// cp.add(treeScroll, "Center");
|
||||
this.add(treeScroll, "Center"); |
||||
|
||||
//Suchen Feld + Buttons
|
||||
JPanel down = new JPanel(); |
||||
down.setLayout(new GridLayout(3, 1)); |
||||
|
||||
JPanel psuchen = new JPanel(); |
||||
suchtext = new JTextField(10); |
||||
suchtext.setFont(new Font("Arial", Font.PLAIN, 10)); |
||||
psuchen.add(suchtext); |
||||
|
||||
JButton suchen = new JButton("Suchen"); |
||||
suchen.setFont(new Font("Arial", Font.PLAIN, 10)); |
||||
suchen.addActionListener(this); |
||||
|
||||
psuchen.add(suchen); |
||||
|
||||
down.add(psuchen); |
||||
|
||||
JPanel pspeichern=new JPanel(); |
||||
JButton speichern=new JButton("speichern"); |
||||
speichern.addActionListener(this); |
||||
pspeichern.add(speichern); |
||||
down.add(pspeichern); |
||||
|
||||
|
||||
|
||||
this.add("South", down); |
||||
//pack();
|
||||
|
||||
if (linkToMain.getSelectedUser()!=-999) mbt.setSelection(linkToMain.getSelectedUser()); |
||||
else linkToMain.setSelectedUser(mbt.getSelectedID()); |
||||
readUserRights(); |
||||
|
||||
|
||||
} |
||||
public void actionPerformed(ActionEvent event) { |
||||
if (event.getActionCommand().equals("speichern")) |
||||
saveUserRights(); |
||||
|
||||
if (event.getActionCommand().equals("Suchen")) |
||||
suchen(); |
||||
|
||||
Object src = event.getSource(); |
||||
if (src instanceof MBComboBox) { |
||||
MBComboBox localbox = (MBComboBox) event.getSource(); |
||||
linkToMain.setSelectedUser(localbox.getSelectedID()); |
||||
readUserRights(); |
||||
tree.repaint(); |
||||
} |
||||
|
||||
} |
||||
|
||||
public void andererStand() { |
||||
int result = |
||||
JOptionPane.showConfirmDialog( |
||||
null, |
||||
"Bei Auswahl eines anderen Stands gehen eventuell gemachte Änderungen verloren!\n Erst speichern?", |
||||
"SuperX DB Admin", |
||||
JOptionPane.YES_NO_OPTION); |
||||
if (result == JOptionPane.OK_OPTION) { |
||||
saveUserRights(); |
||||
} |
||||
String Standneu = |
||||
JOptionPane.showInputDialog( |
||||
this, |
||||
"Neues Datum eingeben:", |
||||
"SuperX", |
||||
JOptionPane.QUESTION_MESSAGE); |
||||
if (Standneu != null && DatumOK(Standneu)) //and FormOk
|
||||
|
||||
{ |
||||
cp.setCursor(new Cursor(Cursor.WAIT_CURSOR)); |
||||
|
||||
Stand = Standneu; |
||||
Standlabel.setText("Stand: " + Stand); |
||||
tree = this.tree_erzeugen(); |
||||
|
||||
cp.remove(treeScroll); |
||||
treeScroll = new JScrollPane(tree); |
||||
cp.add(treeScroll); |
||||
cp.validate(); |
||||
cp.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); |
||||
} |
||||
} |
||||
private void children_freischalten(DefaultMutableTreeNode node) { |
||||
DefaultMutableTreeNode aNode; |
||||
OrgaEintrag2 x; |
||||
for (Enumeration en = node.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
x = (OrgaEintrag2) aNode.getUserObject(); |
||||
x.setErlaubt(true); |
||||
} |
||||
} |
||||
public void childrenSperren(DefaultMutableTreeNode node) { |
||||
DefaultMutableTreeNode aNode; |
||||
OrgaEintrag2 x; |
||||
for (Enumeration en = node.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
x = (OrgaEintrag2) aNode.getUserObject(); |
||||
x.setErlaubt(false); |
||||
} |
||||
} |
||||
|
||||
public String dateToString(java.sql.Date inp) { |
||||
java.text.DateFormat df; |
||||
df = java.text.DateFormat.getDateInstance(java.text.DateFormat.MEDIUM); |
||||
// r.b. default Jahr 4-stellig
|
||||
df.setTimeZone(TimeZone.getDefault()); |
||||
df.setLenient(false); |
||||
|
||||
String help = df.format((java.util.Date) inp); |
||||
return help; |
||||
} |
||||
public boolean DatumOK(String dat) { |
||||
DateFormat df; |
||||
df = DateFormat.getDateInstance(DateFormat.MEDIUM); |
||||
// r.b. default Jahr 4-stellig
|
||||
df.setTimeZone(TimeZone.getDefault()); |
||||
df.setLenient(false); |
||||
String geprueft = null; |
||||
try { |
||||
if (dat.endsWith("00")) { |
||||
switch (dat.charAt(dat.length() - 3)) { |
||||
case '-' : |
||||
case '.' : |
||||
case '/' : |
||||
dat = dat.substring(0, dat.length() - 2) + "2000"; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
java.util.Date date = df.parse(dat); |
||||
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); |
||||
|
||||
//wenn Format nicht OK bleibt geprueft null
|
||||
geprueft = df.format((java.util.Date) date); |
||||
} catch (ParseException e_parse) { |
||||
// System.err.println ("SxDate: ERROR: parse: Date != " + value);
|
||||
} catch (IllegalArgumentException e_arg) { |
||||
// System.err.println ("SxDate: ERROR: arg: Date != " + value);
|
||||
} |
||||
|
||||
return geprueft == null ? false : true; |
||||
} |
||||
public void druckanzeige() { |
||||
AdminOrgaPrintRenderer aopr = new AdminOrgaPrintRenderer(); |
||||
|
||||
tree.setCellRenderer(aopr); |
||||
DefaultMutableTreeNode aNode; |
||||
DefaultMutableTreeNode theRoot = |
||||
(DefaultMutableTreeNode) tree.getModel().getRoot(); |
||||
TreePath tp; |
||||
for (Enumeration en = theRoot.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
tp = new TreePath(aNode.getPath()); |
||||
if (tree.isCollapsed(tp)) |
||||
tree.expandPath(tp); |
||||
|
||||
} |
||||
//PrintUtilities.printComponent(treeScroll);
|
||||
|
||||
int level; |
||||
OrgaEintrag2 x; |
||||
String keyApnr; |
||||
for (Enumeration en = theRoot.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
if (aNode.getUserObject() instanceof OrgaEintrag2) { |
||||
x = (OrgaEintrag2) aNode.getUserObject(); |
||||
level = aNode.getLevel(); |
||||
for (int i = 1; i <= level; i++) |
||||
System.out.print(" "); |
||||
keyApnr = x.getKeyApnr() == null ? "" : x.getKeyApnr().toString(); |
||||
System.out.println(x.getName() + " (" + keyApnr + ")"); |
||||
|
||||
} |
||||
|
||||
} |
||||
} |
||||
public void editingCanceled(ChangeEvent e) { |
||||
CellEditor cellEditor = (CellEditor) e.getSource(); |
||||
/* SelectableFile sf = |
||||
(SelectableFile) |
||||
cellEditor.getCellEditorValue(); |
||||
|
||||
System.out.println("editing canceled: " + |
||||
sf.toString());*/ |
||||
} |
||||
public void editingStopped(ChangeEvent e) { |
||||
// CellEditor cellEditor = (CellEditor)e.getSource();
|
||||
InstEditor cellEditor = (InstEditor) e.getSource(); |
||||
DefaultMutableTreeNode node = |
||||
(DefaultMutableTreeNode) cellEditor.getLastEditedNode(); |
||||
|
||||
OrgaEintrag2 x = (OrgaEintrag2) node.getUserObject(); |
||||
|
||||
if (x.getErlaubt().intValue() == 1) { |
||||
children_freischalten(node); |
||||
prüfeObParentFreischalten(node); |
||||
} else |
||||
{ |
||||
parents_sperren(node); |
||||
childrenSperren(node); |
||||
} |
||||
|
||||
} |
||||
public static java.sql.Date getDate(String value) { |
||||
|
||||
DateFormat df; |
||||
java.util.Date date; |
||||
java.sql.Date sql_date; |
||||
Calendar calendar; |
||||
|
||||
df = DateFormat.getDateInstance(DateFormat.MEDIUM); |
||||
// r.b. default Jahr 4-stellig
|
||||
df.setTimeZone(TimeZone.getDefault()); |
||||
df.setLenient(false); |
||||
|
||||
try { |
||||
if (value.endsWith("00")) { |
||||
switch (value.charAt(value.length() - 3)) { |
||||
case '-' : |
||||
case '.' : |
||||
case '/' : |
||||
value = value.substring(0, value.length() - 2) + "2000"; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
date = df.parse(value); |
||||
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); |
||||
|
||||
sql_date = new java.sql.Date(calendar.getTime().getTime()); |
||||
return sql_date; |
||||
} catch (ParseException e_parse) { |
||||
// System.err.println ("SxDate: ERROR: parse: Date != " + value);
|
||||
} catch (IllegalArgumentException e_arg) { |
||||
// System.err.println ("SxDate: ERROR: arg: Date != " + value);
|
||||
} |
||||
|
||||
return null; |
||||
} |
||||
public Frame getFrame() { |
||||
return dummyframe; |
||||
} |
||||
public OrgaEintrag2 getGewaehlt() { |
||||
return gewaehlt; |
||||
} |
||||
private void insertnodes(String theParent, DefaultMutableTreeNode aktNode) { |
||||
//rekursive Methode, die Institutionen in den Baum einträgt
|
||||
Vector result = new Vector(); |
||||
result = mySelect(theParent); |
||||
String eintrag_key; |
||||
for (Enumeration el = result.elements(); el.hasMoreElements();) { |
||||
einEintrag = (OrgaEintrag2) el.nextElement(); |
||||
DefaultMutableTreeNode neuNode = new DefaultMutableTreeNode(einEintrag); |
||||
aktNode.add(neuNode); |
||||
|
||||
eintrag_key = einEintrag.getKeyApnr(); |
||||
//nervig null-Werte abfangen
|
||||
if (eintrag_key != null & theParent == null) |
||||
insertnodes(einEintrag.getKeyApnr(), neuNode); |
||||
if (eintrag_key == null & theParent == null) |
||||
System.out.println( |
||||
"Achtung! Element hat fälschlicherweise sich selbst als parent:" |
||||
+ einEintrag.getName()); |
||||
|
||||
if (eintrag_key != null && theParent != null) |
||||
if (!theParent.equals(eintrag_key)) |
||||
insertnodes(einEintrag.getKeyApnr(), neuNode); |
||||
else |
||||
System.out.println( |
||||
"Achtung! Element hat fälschlicherweise sich selbst als parent:" |
||||
+ einEintrag.getName() |
||||
+ " key_apnr:" |
||||
+ einEintrag.getKeyApnr()); |
||||
} |
||||
|
||||
} |
||||
public int KinderZählen(DefaultMutableTreeNode node) { |
||||
int zähler = 0; |
||||
DefaultMutableTreeNode aNode; |
||||
for (Enumeration en = node.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
zähler++; |
||||
} |
||||
return zähler - 1; |
||||
|
||||
} |
||||
public void log(String was) { |
||||
System.out.println(was); |
||||
//ggfs. in Datei schreiben
|
||||
} |
||||
private Vector mySelect(String pruefparent) { |
||||
//liefert alle Institute mit Parent =pruefparent zurück
|
||||
Vector result = new Vector(); |
||||
String eintrag_parent; |
||||
for (Enumeration el = orga.elements(); el.hasMoreElements();) { |
||||
einEintrag = (OrgaEintrag2) el.nextElement(); |
||||
eintrag_parent = einEintrag.getParent(); |
||||
if (eintrag_parent == null && pruefparent == null) |
||||
result.addElement(einEintrag); |
||||
if (eintrag_parent != null && pruefparent != null) |
||||
if (eintrag_parent.equals(pruefparent)) |
||||
result.addElement(einEintrag); |
||||
|
||||
} |
||||
return result; |
||||
} |
||||
|
||||
|
||||
|
||||
private void readUserRights() { |
||||
Integer institut; |
||||
DefaultMutableTreeNode aNode, childNode; |
||||
OrgaEintrag2 x; |
||||
|
||||
DefaultMutableTreeNode theRoot = (DefaultMutableTreeNode) tree.getModel().getRoot(); |
||||
|
||||
//erstmal alles auf erlaubt=false setzen
|
||||
for (Enumeration en = theRoot.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
if (aNode.getUserObject() instanceof OrgaEintrag2) { |
||||
x = (OrgaEintrag2) aNode.getUserObject(); |
||||
x.setErlaubt(false); |
||||
} |
||||
} |
||||
|
||||
try { |
||||
|
||||
//Datumsabfrage
|
||||
//datum String in sql.Date umformen
|
||||
java.sql.Date date = new java.sql.Date(1); |
||||
SxDate mydate = new SxDate(); |
||||
date = mydate.getDate(Stand); |
||||
|
||||
String query = |
||||
"select ch110_institut, hierarchie,lehre,gueltig_seit,gueltig_bis from user_institution where userid=" |
||||
+ linkToMain.getSelectedUser() |
||||
+ " and gueltig_seit<=date('" |
||||
+ date |
||||
+ "') and gueltig_bis>=date('" |
||||
+ date |
||||
+ "')"; |
||||
|
||||
|
||||
Vector erg=DBAccess.executeQuery(query); |
||||
Integer hierarchie, lehre; |
||||
java.sql.Date gueltig_seit, gueltig_bis; |
||||
Object input;Vector help; |
||||
for (Enumeration el=erg.elements(); el.hasMoreElements(); ) { |
||||
|
||||
help=(Vector)el.nextElement(); |
||||
|
||||
|
||||
institut = (Integer) help.get(0); |
||||
for (Enumeration en = theRoot.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
if (aNode.getUserObject() instanceof OrgaEintrag2) { |
||||
x = (OrgaEintrag2) aNode.getUserObject(); |
||||
//standardmäßig erstmal erlaubt=false setzen
|
||||
|
||||
if (x.getKeyApnr()!=null&&x.getKeyApnr().equals(institut)) { |
||||
input = help.get(1); |
||||
x.setHierarchie(input == null ? null : new Integer(input.toString())); |
||||
input = help.get(2); |
||||
x.setLehre(input == null ? null : new Integer(input.toString())); |
||||
//Gueltigkeitswerte aus user_inst in orgaEintrag übertragen, damit bei speichern erhalten bleiben
|
||||
gueltig_seit = (java.sql.Date) help.get(3);; |
||||
gueltig_bis = (java.sql.Date) help.get(4); |
||||
x.setGueltigSeit(gueltig_seit); |
||||
x.setGueltigBis(gueltig_bis); |
||||
x.setErlaubt(true); |
||||
//Kinder auch
|
||||
for (Enumeration en2 = aNode.depthFirstEnumeration(); en2.hasMoreElements();) { |
||||
childNode = (DefaultMutableTreeNode) en2.nextElement(); |
||||
x = (OrgaEintrag2) childNode.getUserObject(); |
||||
x.setErlaubt(true); |
||||
} |
||||
|
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
linkToMain.setStatus("User geändert"); |
||||
} catch (Exception e) { |
||||
JOptionPane.showMessageDialog( |
||||
null, |
||||
"Fehler beim Lesen aus der Datenbank: " + e.toString(), |
||||
"SuperX DB Admin", |
||||
JOptionPane.WARNING_MESSAGE); |
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
} |
||||
|
||||
public void saveUserRights() { |
||||
Enumeration en; |
||||
int i = 0; |
||||
String ins = null; |
||||
String wo = null; |
||||
|
||||
//datum String in sql.Date umformen
|
||||
java.sql.Date date = new java.sql.Date(1); |
||||
SxDate mydate = new SxDate(); |
||||
date = mydate.getDate(Stand); |
||||
|
||||
// MBProgressBar progress=new MBProgressBar(10);
|
||||
try { |
||||
DefaultMutableTreeNode lroot = |
||||
(DefaultMutableTreeNode) tree.getModel().getRoot(); |
||||
DefaultMutableTreeNode aNode; |
||||
OrgaEintrag2 x; |
||||
String upd = |
||||
"delete from user_institution where userid="+linkToMain.getSelectedUser() |
||||
+ " and gueltig_seit<=date('" |
||||
+ date |
||||
+ "') and gueltig_bis>=date('" |
||||
+ date |
||||
+ "')"; |
||||
DBAccess.executeUpdate(upd); |
||||
|
||||
TreePath tp; |
||||
DefaultMutableTreeNode vorher; |
||||
aNode = null; |
||||
for (en = lroot.breadthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
x = (OrgaEintrag2) aNode.getUserObject(); |
||||
if (x instanceof OrgaEintrag2) { |
||||
|
||||
if (x.isErlaubt()) { |
||||
ins = |
||||
new String( |
||||
"insert into user_institution (userid, name,ch110_institut,hierarchie,gueltig_seit,gueltig_bis,lehre) " |
||||
+ "values ("+ |
||||
linkToMain.getSelectedUser()+",'" |
||||
+ x.getName() |
||||
+ "'," |
||||
+ x.getKeyApnr() |
||||
+ "," |
||||
+ x.getHierarchie() |
||||
+ ",date('" |
||||
+ SxUtils.GetValueAsString(x.getGueltigSeit()) |
||||
+ "'), date('" |
||||
+ SxUtils.GetValueAsString(x.getGueltigBis()) |
||||
+ "')," |
||||
+ x.getLehre() |
||||
+ ")"); |
||||
DBAccess.executeUpdate(ins); |
||||
i++; |
||||
//children sperren, da nur Eintrag von hierarchiehöchstem Element nötig
|
||||
childrenSperren(aNode); |
||||
|
||||
} |
||||
//progress.inc();
|
||||
} |
||||
} |
||||
|
||||
linkToMain.setStatus(i + " Einträge in user_institution geschrieben"); |
||||
etwasGeändert = false; |
||||
//da Kinder der Verarbeitung wegen gesperrt wurden, muss neu eingelesen werden
|
||||
readUserRights(); |
||||
} catch (Exception e) { |
||||
JOptionPane.showMessageDialog( |
||||
null, |
||||
"Fehler beim Schreiben in die Datenbank:\n " + e.toString(), |
||||
"SuperX DB Admin", |
||||
JOptionPane.WARNING_MESSAGE); |
||||
System.out.println(wo + ": " + ins); |
||||
e.printStackTrace(); |
||||
System.exit(-1); |
||||
} |
||||
//progress.hide();
|
||||
//progress.dispose();
|
||||
|
||||
|
||||
|
||||
|
||||
} |
||||
|
||||
private void parents_sperren(DefaultMutableTreeNode node) { |
||||
DefaultMutableTreeNode aNode; |
||||
OrgaEintrag2 x; |
||||
boolean go = true; |
||||
while (go) { |
||||
aNode = (DefaultMutableTreeNode) node.getParent(); |
||||
if (aNode == null || !(aNode.getUserObject() instanceof OrgaEintrag2)) |
||||
return; //root
|
||||
|
||||
x = (OrgaEintrag2) aNode.getUserObject(); |
||||
if (x.getErlaubt().intValue() == 1) |
||||
//wenn parent erlaubt ist, den auf false setzen
|
||||
// und in Schleife weitermachen
|
||||
//denn sobald nur eines der Kinderelemente eines parents nicht erlaubt,
|
||||
//ist er selbst nicht mehr erlaubt
|
||||
x.setErlaubt(false); |
||||
// ansonsten war parent schon auf false und man braucht nicht weitermachen
|
||||
else |
||||
go = false; |
||||
node = aNode; |
||||
} |
||||
|
||||
} |
||||
public void prüfeDifferenzen(DefaultMutableTreeNode root) { |
||||
Vector problemfälle; |
||||
problemfälle = (Vector) orga.clone(); |
||||
DefaultMutableTreeNode aNode; |
||||
OrgaEintrag2 x; |
||||
String name; |
||||
Integer key_apnr; |
||||
java.sql.Date gueltig_seit, gueltig_bis; |
||||
|
||||
//Problemfälle enthält zu Anfang alle eingelesenen, gültigen Einträge
|
||||
//diejenigen, die in Baum vorkommen werden ausgelöscht
|
||||
for (Enumeration en = root.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
x = (OrgaEintrag2) aNode.getUserObject(); |
||||
problemfälle.remove(x); |
||||
} |
||||
|
||||
if (problemfälle.size() > 0) { |
||||
JOptionPane.showMessageDialog( |
||||
null, |
||||
"Achtung!\nEs gibt " |
||||
+ problemfälle.size() |
||||
+ " gültige Einträge, die nicht in die Baumstruktur passten!\n(Bitte Organigramm korrigieren)", |
||||
"SuperX Admin", |
||||
JOptionPane.WARNING_MESSAGE); |
||||
log( |
||||
problemfälle.size() |
||||
+ " gültige Einträge, die nicht in die Baumstruktur passten:"); |
||||
|
||||
/* DefaultMutableTreeNode fehlernode = new DefaultMutableTreeNode("Fehler"); |
||||
|
||||
for (Enumeration el = problemfälle.elements(); el.hasMoreElements();) { |
||||
x = (orgaEintrag2) el.nextElement(); |
||||
fehlernode.add(new DefaultMutableTreeNode(x)); |
||||
log(x.getKeyApnr() + " - " + x.getName() + "parent (" + x.getParent() + ")"); |
||||
|
||||
} |
||||
root.add(fehlernode); |
||||
*/ |
||||
} |
||||
} |
||||
private void prüfeObParentFreischalten(DefaultMutableTreeNode node) { |
||||
DefaultMutableTreeNode aNode; |
||||
DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent(); |
||||
OrgaEintrag2 x; |
||||
boolean alleKinderErlaubt = true; |
||||
for (Enumeration en = parent.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
if (!aNode.equals(parent)) { |
||||
x = (OrgaEintrag2) aNode.getUserObject(); |
||||
if (x.getErlaubt().intValue() == 0) |
||||
alleKinderErlaubt = false; |
||||
} |
||||
} |
||||
if (alleKinderErlaubt) { |
||||
x = (OrgaEintrag2) parent.getUserObject(); |
||||
x.setErlaubt(true); |
||||
} |
||||
if (!parent.isRoot()) |
||||
prüfeObParentFreischalten(parent); |
||||
} |
||||
|
||||
private void suchen() { |
||||
String such = suchtext.getText().toLowerCase(); |
||||
String teststring; |
||||
TreePath tp; |
||||
boolean gefunden = false; |
||||
DefaultMutableTreeNode test, ausgesucht; |
||||
ausgesucht = null; |
||||
Vector treffer = new Vector(); |
||||
Vector treffernodes = new Vector(); |
||||
|
||||
if (such.length() < 1) { |
||||
JOptionPane.showMessageDialog(null, "Bitte Suchbegriff eingeben!", "SuperX", 1); |
||||
return; |
||||
} |
||||
such = such.toLowerCase(); |
||||
//JOptionPane.showMessageDialog(null, "neu","SuperX",1);
|
||||
//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) JOptionPane.showInputDialog( |
||||
null, |
||||
"Mehrere Treffer!\nBitte 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.addSelectionPath(tp); |
||||
//tree.makeVisible(tp);
|
||||
|
||||
// tree.validate();
|
||||
// tree.repaint();
|
||||
} else |
||||
JOptionPane.showMessageDialog(null, "Keine Treffer", "SuperX", 1); |
||||
} |
||||
public JTree tree_erzeugen() { |
||||
DefaultMutableTreeNode eb1, eb2, eb3, eb4, eb5, eb6; |
||||
|
||||
int i = 0; |
||||
orga = new Vector(); |
||||
merkungültig = new Vector(); |
||||
String name, drucktext; |
||||
Integer ebene, lehre, orgstruktur; |
||||
String key_apnr,parent; |
||||
java.sql.Date gueltig_seit = null, gueltig_bis = null; |
||||
JTree ltree; |
||||
/* |
||||
String url = "jdbc:odbc:minisuperx"; |
||||
String driverClass = "sun.jdbc.odbc.JdbcOdbcDriver"; |
||||
|
||||
try { |
||||
Class.forName(driverClass); |
||||
myConnection = DriverManager.getConnection(url); |
||||
checkForWarning(myConnection.getWarnings()); |
||||
myDatabaseMetaData = myConnection.getMetaData(); |
||||
} catch (Exception e) { |
||||
System.out.println(e.toString()); |
||||
}*/ |
||||
// addWindowListener(new WindowClosingAdapter());
|
||||
//Einfaches TreeModel bauen
|
||||
|
||||
String query = |
||||
"SELECT name,drucktext,key_apnr,ebene,parent,lehre,gueltig_seit,gueltig_bis,orgstruktur FROM organigramm order by name"; |
||||
|
||||
int AnzahlGültige = 0; |
||||
int AnzahlFehler = 0; |
||||
try { |
||||
|
||||
Vector erg=DBAccess.executeQuery(query); |
||||
AnzahlEinträge = 0; |
||||
java.sql.Timestamp mytimestamp; |
||||
long mytimestampwert; |
||||
java.sql.Date StandDate = getDate(Stand); |
||||
// new java.sql.Date(cal.getTime().getTime());
|
||||
Object input; |
||||
for (Enumeration el=erg.elements(); el.hasMoreElements(); ) { |
||||
Vector help=(Vector)el.nextElement(); |
||||
|
||||
|
||||
name = help.get(0).toString(); |
||||
drucktext = help.get(1).toString(); |
||||
key_apnr = (String) help.get(2); |
||||
ebene = (Integer) help.get(3); |
||||
input=help.get(4); |
||||
if (input==null) parent = null; else parent=(String)input; |
||||
Object helpx = help.get(5); |
||||
|
||||
if (key_apnr.equals(parent)) { |
||||
AnzahlFehler++; |
||||
log("Eintrag hat sich selbst als parent: " + key_apnr); |
||||
} |
||||
|
||||
lehre = new Integer(helpx.toString()); |
||||
input=help.get(8); |
||||
if (input==null) orgstruktur = null; else orgstruktur=(Integer) input; |
||||
//ResultSetMetaData rsmd = rs1.getMetaData();
|
||||
//System.out.println(rsmd.getColumnClassName(4));
|
||||
//für Access
|
||||
/*if (DB.equals("access")) { |
||||
mytimestamp = (java.sql.Timestamp) rs1.getObject("gueltig_seit"); |
||||
mytimestampwert = mytimestamp.getTime(); |
||||
gueltig_seit = new java.sql.Date(mytimestampwert); |
||||
|
||||
mytimestamp = (java.sql.Timestamp) rs1.getObject("gueltig_bis"); |
||||
mytimestampwert = mytimestamp.getTime(); |
||||
gueltig_bis = new java.sql.Date(mytimestampwert); |
||||
} |
||||
if (DB.equals("informix")) {*/ |
||||
gueltig_seit = (java.sql.Date) help.get(6); |
||||
gueltig_bis = (java.sql.Date) help.get(7); |
||||
|
||||
einEintrag = |
||||
new OrgaEintrag2( |
||||
name, |
||||
drucktext, |
||||
key_apnr, |
||||
ebene, |
||||
parent, |
||||
lehre, |
||||
gueltig_seit, |
||||
gueltig_bis, |
||||
orgstruktur); |
||||
|
||||
if ((gueltig_seit.equals(StandDate) || gueltig_seit.before(StandDate)) |
||||
&& (gueltig_bis.equals(StandDate) || gueltig_bis.after(StandDate))) { |
||||
orga.addElement(einEintrag); |
||||
AnzahlEinträge++;; |
||||
} |
||||
|
||||
|
||||
} |
||||
|
||||
} catch (Exception e) { |
||||
JOptionPane.showMessageDialog( |
||||
null, |
||||
"Fehler beim Lesen aus der Datenbank: " + e.toString(), |
||||
"SuperX DB Admin", |
||||
JOptionPane.WARNING_MESSAGE); |
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
if (AnzahlFehler > 0) |
||||
JOptionPane.showMessageDialog( |
||||
null, |
||||
"Achtung!\n" + AnzahlFehler + " Einträge haben sich selbst als parent!", |
||||
"SuperX Admin", |
||||
JOptionPane.WARNING_MESSAGE); |
||||
|
||||
OrgaEintrag2 hochschule = |
||||
new OrgaEintrag2("Hochschule", null, null, null, null, null, null, null, null); |
||||
root = new DefaultMutableTreeNode(hochschule); |
||||
|
||||
/* DefaultMutableTreeNode e1=new DefaultMutableTreeNode(new orgaEintrag2("Studierende", null, null, null, null, null, null, null, null)); |
||||
e1.add(new DefaultMutableTreeNode(new orgaEintrag2("ca-werte", null, null, null, null, null, null, null, null))); |
||||
root.add(e1); |
||||
|
||||
e1.add(new DefaultMutableTreeNode(new orgaEintrag2("Stud. allgmein", null, null, null, null, null, null, null, null))); |
||||
|
||||
DefaultMutableTreeNode e2=new DefaultMutableTreeNode(new orgaEintrag2("Haushalt", null, null, null, null, null, null, null, null)); |
||||
|
||||
DefaultMutableTreeNode e2b= new DefaultMutableTreeNode(new orgaEintrag2("Haushaltszeitreihen", null, null, null, null, null, null, null, null)); |
||||
DefaultMutableTreeNode e2c= new DefaultMutableTreeNode(new orgaEintrag2("Haushalt (Zeitreihe)", null, null, null, null, null, null, null, null)); |
||||
e2b.add(e2c); |
||||
e2.add(e2b); |
||||
|
||||
e2.add(new DefaultMutableTreeNode( new orgaEintrag2("Altersstruktur der Beschäftigen", null, null, null, null, null, null, null, null))); |
||||
root.add(e2); |
||||
|
||||
DefaultMutableTreeNode e3=new DefaultMutableTreeNode(new orgaEintrag2("Kennzahlen", null, null, null, null, null, null, null, null)); |
||||
DefaultMutableTreeNode e3b=new DefaultMutableTreeNode(new orgaEintrag2("Basiskennzahlen", null, null, null, null, null, null, null, null)); |
||||
e3b.add(new DefaultMutableTreeNode(new orgaEintrag2("ca-werte", null, null, null, null, null, null, null, null))); |
||||
e3.add(e3b); |
||||
e3.add(new DefaultMutableTreeNode(new orgaEintrag2("Neue Kennzahlabfrage", null, null, null, null, null, null, null, null))); |
||||
root.add(e3); |
||||
|
||||
*/ |
||||
|
||||
//hier werden über eine rekursive Methode alle
|
||||
//Institute in den Baum eingetragen
|
||||
insertnodes(null, root); |
||||
|
||||
//Konsistenz prüfen
|
||||
int TreeEinträge = KinderZählen(root); |
||||
if (AnzahlGültige != TreeEinträge) |
||||
prüfeDifferenzen(root); |
||||
|
||||
//Rechte des Nutzers einlesen
|
||||
// NutzerRechteLesen((DefaultMutableTreeNode) root.getChildAt(0));
|
||||
|
||||
//Baum erzeugen
|
||||
treeModel = new DefaultTreeModel(root); |
||||
|
||||
//AdminOrgaModelListener aoml=new AdminOrgaModelListener();
|
||||
//treeModel.addTreeModelListener(new AdminOrgaModelListener());
|
||||
|
||||
ltree = new JTree(treeModel); |
||||
ltree.setRootVisible(false); |
||||
ltree.setEditable(true); |
||||
// ltree.setBackground(Color.lightGray);
|
||||
//root Hochschule sieht man sowieso nicht
|
||||
//first child GMU Duisburg muss aufgeklappt sein
|
||||
//da Mouselistener Doubleclick umfunktioniert
|
||||
|
||||
DefaultMutableTreeNode ebene1 = (DefaultMutableTreeNode) root.getChildAt(0); |
||||
ltree.expandPath(new TreePath(ebene1.getPath())); |
||||
|
||||
//Einfachselektion
|
||||
ltree.getSelectionModel().setSelectionMode( |
||||
TreeSelectionModel.SINGLE_TREE_SELECTION); |
||||
|
||||
InstRenderer renderer = new InstRenderer(); |
||||
InstEditor editor = new InstEditor(); |
||||
editor.addCellEditorListener(this); |
||||
ltree.setEditable(true); |
||||
ltree.setCellRenderer(renderer); |
||||
ltree.setCellEditor(new InstImmediateEditor(ltree, renderer, editor)); |
||||
|
||||
//TreeSelectionListener hinzufügen
|
||||
// AdminOrgaSelList adosl = new AdminOrgaSelList(this, ltree);
|
||||
// ltree.addTreeSelectionListener(adosl);
|
||||
|
||||
// AdminOrgaMouseListener ml =
|
||||
// new AdminOrgaMouseListener(this, ltree, merkungültig);
|
||||
// ltree.addMouseListener(ml);
|
||||
|
||||
linkToMain.setStatus(AnzahlEinträge + " OrgaEinträge eingelesen"); |
||||
|
||||
return ltree; |
||||
} |
||||
} |
@ -1,370 +0,0 @@
@@ -1,370 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
|
||||
import java.awt.Dimension; |
||||
import java.awt.FlowLayout; |
||||
import java.awt.GridLayout; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.security.MessageDigest; |
||||
import java.util.Enumeration; |
||||
import java.util.Vector; |
||||
|
||||
import javax.swing.JButton; |
||||
import javax.swing.JLabel; |
||||
import javax.swing.JOptionPane; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JScrollPane; |
||||
import javax.swing.JTextArea; |
||||
import javax.swing.JTextField; |
||||
|
||||
import de.memtext.util.WindowUtils; |
||||
|
||||
class UserStammPanel extends JPanel implements ActionListener { |
||||
|
||||
Vector liste; |
||||
MBComboBox mbt; |
||||
JTextField tname = new JTextField(10); |
||||
JTextField tkenn = new JTextField(10); |
||||
JTextField temail = new JTextField(20); |
||||
JTextField tmaxversuch = new JTextField(3); |
||||
JTextField taktversuch = new JTextField(3); |
||||
JTextArea tinfo = new JTextArea(60, 3); |
||||
|
||||
public UserStammPanel() { |
||||
super(); |
||||
|
||||
mbt = new MBComboBox(); |
||||
mbt.addActionListener(this); |
||||
this.setLayout(new GridLayout(8, 1)); |
||||
JPanel p0 = new JPanel(); |
||||
p0.add(mbt); |
||||
this.add(p0); |
||||
JPanel p1 = new JPanel(); |
||||
JLabel lkenn = new JLabel("Kennung:"); |
||||
|
||||
p1.add(lkenn); |
||||
p1.add(tkenn); |
||||
JLabel lname = new JLabel("Name:"); |
||||
p1.add(lname); |
||||
p1.add(tname); |
||||
this.add(p1); |
||||
JPanel p1b = new JPanel(); |
||||
JLabel lemail = new JLabel("Email"); |
||||
p1b.add(lemail); |
||||
p1b.add(temail); |
||||
this.add(p1b); |
||||
JPanel p1c = new JPanel(new FlowLayout()); |
||||
JLabel linfo = new JLabel("Info"); |
||||
p1c.add(linfo); |
||||
|
||||
tinfo.setLineWrap(true); |
||||
tinfo.setWrapStyleWord(true); |
||||
tinfo.setEditable(true); |
||||
|
||||
JScrollPane tinfoscroll = new JScrollPane(tinfo); |
||||
tinfoscroll.setPreferredSize(new Dimension(350, 60)); |
||||
p1c.add(tinfoscroll); |
||||
this.add(p1c); |
||||
JPanel p2 = new JPanel(); |
||||
JLabel lmaxversuch = new JLabel("Max Versuch"); |
||||
p2.add(lmaxversuch); |
||||
p2.add(tmaxversuch); |
||||
JLabel laktversuch = new JLabel("akt.Versuch"); |
||||
p2.add(laktversuch); |
||||
p2.add(taktversuch); |
||||
this.add(p2); |
||||
JPanel p3 = new JPanel(); |
||||
JButton bkennw = new JButton("Kennwort"); |
||||
bkennw.addActionListener(this); |
||||
p3.add(bkennw); |
||||
this.add(p3); |
||||
JPanel p4 = new JPanel(); |
||||
JButton blöschen = new JButton("Benutzer löschen"); |
||||
blöschen.addActionListener(this); |
||||
p4.add(blöschen); |
||||
JButton bneu = new JButton("Benutzer anlegen"); |
||||
bneu.addActionListener(this); |
||||
p4.add(bneu); |
||||
|
||||
this.add(p4); |
||||
JPanel p5 = new JPanel(); |
||||
JButton bspeich = new JButton("speichern"); |
||||
bspeich.addActionListener(this); |
||||
p5.add(bspeich); |
||||
this.add(p5); |
||||
|
||||
} |
||||
|
||||
public void prepare() { |
||||
WindowUtils.setWaitCursor(this,true); |
||||
mbt.removeAllItems(); |
||||
//vector mit Daten nimmt einfach erstes element für display
|
||||
mbt.addAll(DBAccess.getUserListe()); |
||||
|
||||
if (SuperXDBAdmin.getSelectedUser() != -999) |
||||
mbt.setSelection(SuperXDBAdmin.getSelectedUser()); |
||||
else |
||||
SuperXDBAdmin.setSelectedUser(mbt.getSelectedID()); |
||||
nutzerGewählt(); |
||||
WindowUtils.setWaitCursor(this,false); |
||||
} |
||||
|
||||
public void actionPerformed(ActionEvent event) { |
||||
// if (event.getActionCommand().equals("speichern"))
|
||||
// NutzerRechteSpeichern();
|
||||
if (event.getActionCommand().equals("speichern")) |
||||
userDatenSpeichern(); |
||||
|
||||
if (event.getActionCommand().equals("Kennwort")) |
||||
newPassword(); |
||||
|
||||
if (event.getActionCommand().equals("Benutzer löschen")) |
||||
benutzerLöschen(); |
||||
|
||||
if (event.getActionCommand().equals("Benutzer anlegen")) |
||||
benutzerAnlegen(); |
||||
|
||||
Object src = event.getSource(); |
||||
if (src instanceof MBComboBox) { |
||||
MBComboBox localbox = (MBComboBox) event.getSource(); |
||||
|
||||
SuperXDBAdmin.setSelectedUser(localbox.getSelectedID()); |
||||
|
||||
nutzerGewählt(); |
||||
} |
||||
|
||||
} |
||||
|
||||
private void userDatenSpeichern() { |
||||
try { |
||||
WindowUtils.setWaitCursor(this,true); |
||||
String info = tinfo.getText(); |
||||
if (info.length() > 255) { |
||||
info = info.substring(0, 254); |
||||
JOptionPane |
||||
.showMessageDialog( |
||||
null, |
||||
"Achtung! Es wurden nur die ersten 255 Zeichen des Infotexts gespeichert ", |
||||
"SuperX DB Admin", JOptionPane.WARNING_MESSAGE); |
||||
} |
||||
|
||||
String upd = "update userinfo set benutzer=" |
||||
+ DBAccess.getStringOrNull(tkenn.getText()) + ", name=" |
||||
+ DBAccess.getStringOrNull(tname.getText()) + ",email=" |
||||
+ DBAccess.getStringOrNull(temail.getText()) + ",info=" |
||||
+ DBAccess.getStringOrNull(info) + ",max_versuch=" |
||||
+ DBAccess.getIntegerOrNull(tmaxversuch.getText()) |
||||
+ " ,akt_versuch=" |
||||
+ DBAccess.getIntegerOrNull(taktversuch.getText()) |
||||
+ " where tid=" + SuperXDBAdmin.getSelectedUser(); |
||||
DBAccess.executeUpdate(upd); |
||||
SuperXDBAdmin.setStatus("Userdaten gespeichert!"); |
||||
DBAccess.userListeNeuEinlesen(); |
||||
mbt.neuAufbauen(DBAccess.getUserListe()); |
||||
mbt.setSelection(SuperXDBAdmin.getSelectedUser()); |
||||
} catch (Exception e) { |
||||
JOptionPane |
||||
.showMessageDialog(null, |
||||
"Fehler beim Schreiben in die Datenbank:\n " |
||||
+ e.toString(), "SuperX DB Admin", |
||||
JOptionPane.WARNING_MESSAGE); |
||||
|
||||
e.printStackTrace(); |
||||
|
||||
} |
||||
finally |
||||
{ |
||||
WindowUtils.setWaitCursor(this,false); |
||||
} |
||||
|
||||
} |
||||
|
||||
/* |
||||
* public Vector NutzerListeEinlesen() { liste = new Vector(); Vector row; |
||||
* Integer id; String benutzer, email, name, max_versuch, akt_versuch, info; |
||||
* |
||||
* try { |
||||
* |
||||
* String query = "select tid, |
||||
* benutzer,name,email,info,max_versuch,akt_versuch,passwd_sha from userinfo |
||||
* order by benutzer"; Statement statement = myConnection.createStatement(); |
||||
* ResultSet rs1 = statement.executeQuery(query); while (rs1.next()) { |
||||
* name=rs1.getString("passwd_sha"); id = (Integer) rs1.getObject("tid"); |
||||
* benutzer = rs1.getObject("benutzer").toString(); email = |
||||
* DBAccess.getString(rs1, "email"); info= DBAccess.getString(rs1,"info"); |
||||
* name = DBAccess.getString(rs1, "name"); max_versuch = |
||||
* DBAccess.getString(rs1, "max_versuch"); akt_versuch = |
||||
* DBAccess.getString(rs1, "akt_versuch"); row = new Vector(); row.add(id); |
||||
* row.add(benutzer); row.add(name); row.add(email); row.add(info); |
||||
* row.add(max_versuch); row.add(akt_versuch); liste.add(row); |
||||
* } rs1.close(); statement.close(); |
||||
* } catch (Exception e) { JOptionPane.showMessageDialog( null, "Fehler |
||||
* beim Lesen aus der Datenbank: " + e.toString(), "SuperX DB Admin", |
||||
* JOptionPane.WARNING_MESSAGE); e.printStackTrace(); } return liste; } |
||||
*/ |
||||
|
||||
private void nutzerGewählt() { |
||||
Vector zeile; |
||||
Integer test; |
||||
String help; |
||||
Object help2; |
||||
for (Enumeration el = DBAccess.getUserListe().elements(); el |
||||
.hasMoreElements();) { |
||||
zeile = ((Vector) el.nextElement()); |
||||
test = (Integer) zeile.get(0); |
||||
if (test.intValue() == SuperXDBAdmin.getSelectedUser()) { |
||||
tkenn.setText((String) zeile.get(1)); |
||||
tkenn.setCaretPosition(0); |
||||
tname.setText((String) zeile.get(2)); |
||||
tname.setCaretPosition(0); |
||||
temail.setText((String) zeile.get(3)); |
||||
temail.setCaretPosition(0); |
||||
tinfo.setText((String) zeile.get(4)); |
||||
tinfo.setCaretPosition(0); |
||||
|
||||
tmaxversuch.setText(zeile.get(5).toString()); |
||||
tmaxversuch.setCaretPosition(0); |
||||
taktversuch.setText(zeile.get(6).toString()); |
||||
taktversuch.setCaretPosition(0); |
||||
} |
||||
} |
||||
|
||||
this.repaint(); |
||||
|
||||
} |
||||
|
||||
private void newPassword() { |
||||
try { |
||||
String passwd = JOptionPane.showInputDialog(this, "Neues Passwort", |
||||
"SuperX", JOptionPane.QUESTION_MESSAGE); |
||||
if (passwd == null) |
||||
throw new Exception("Aktion abgebrochen"); |
||||
String passwd2 = JOptionPane.showInputDialog(this, |
||||
"Passwort bestätigen", "SuperX", |
||||
JOptionPane.QUESTION_MESSAGE); |
||||
|
||||
if (passwd.equals(passwd2)) { |
||||
|
||||
String upd_passwd_sha = null; |
||||
byte[] buf = passwd.getBytes(); |
||||
byte[] digest = null; |
||||
StringBuffer passwd_str = new StringBuffer(); |
||||
String value; |
||||
int n; |
||||
|
||||
MessageDigest sha = MessageDigest.getInstance("SHA-1"); |
||||
sha.update(buf); |
||||
digest = sha.digest(); |
||||
|
||||
for (int i = 0; i < digest.length; i++) { |
||||
n = (int) digest[i]; |
||||
if (n < 0) |
||||
n += 256; |
||||
value = Integer.toHexString(n); |
||||
if (n < 16) |
||||
value = "0" + value; |
||||
passwd_str.append(value); |
||||
} |
||||
|
||||
upd_passwd_sha = "update userinfo set passwd_sha = '" |
||||
+ passwd_str + "'" + " where tid = " |
||||
+ SuperXDBAdmin.getSelectedUser(); |
||||
|
||||
DBAccess.executeUpdate(upd_passwd_sha); |
||||
SuperXDBAdmin.setStatus("Password geändert"); |
||||
|
||||
} else |
||||
JOptionPane.showMessageDialog(null, |
||||
"Eingaben stimmten nicht überein!", "SuperX", |
||||
JOptionPane.WARNING_MESSAGE); |
||||
|
||||
} catch (Exception e) { |
||||
SuperXDBAdmin |
||||
.setStatus("Password nicht geändert!! " + e.toString()); |
||||
} |
||||
|
||||
} |
||||
|
||||
private void benutzerLöschen() { |
||||
int rc = JOptionPane.showConfirmDialog(null, |
||||
"Benutzer wirklich löschen?", "SuperX", |
||||
JOptionPane.YES_NO_OPTION); |
||||
if (rc == JOptionPane.YES_OPTION) { |
||||
try { |
||||
|
||||
DBAccess |
||||
.executeUpdate("delete from user_masken_bez where userinfo_id=" |
||||
+ SuperXDBAdmin.getSelectedUser()); |
||||
DBAccess |
||||
.executeUpdate("delete from user_institution where userid=" |
||||
+ SuperXDBAdmin.getSelectedUser()); |
||||
DBAccess |
||||
.executeUpdate("delete from user_group_bez where userinfo_id=" |
||||
+ SuperXDBAdmin.getSelectedUser()); |
||||
DBAccess |
||||
.executeUpdate("delete from protokoll where userinfo_id=" |
||||
+ SuperXDBAdmin.getSelectedUser()); |
||||
DBAccess.executeUpdate("delete from userinfo where tid=" |
||||
+ SuperXDBAdmin.getSelectedUser()); |
||||
SuperXDBAdmin.setStatus("Benutzer gelöscht"); |
||||
DBAccess.userListeNeuEinlesen(); |
||||
mbt.neuAufbauen(DBAccess.getUserListe()); |
||||
SuperXDBAdmin.setSelectedUser(mbt.getSelectedID()); |
||||
} catch (Exception e) { |
||||
SuperXDBAdmin |
||||
.setStatus("Ein Fehler ist aufgetreten - Benutzer nicht gelöscht"); |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
private void benutzerAnlegen() { |
||||
try { |
||||
|
||||
Integer tid = (Integer) DBAccess |
||||
.executeQuerySingleValue("select max(tid) as tid from userinfo"); |
||||
int newtid = tid.intValue() + 1; |
||||
|
||||
String kennung = JOptionPane.showInputDialog(this, |
||||
"Kennung eingeben", "SuperX", JOptionPane.QUESTION_MESSAGE); |
||||
String ins = "insert into userinfo values (" + newtid + ",'" |
||||
+ kennung + "','',null,5,0,null,0,0,null,null)"; |
||||
DBAccess.executeUpdate(ins); |
||||
|
||||
//Startpasswort anfang setzten
|
||||
String upd_passwd_sha = null; |
||||
String passwd = "anfang"; |
||||
byte[] buf = passwd.getBytes(); |
||||
byte[] digest = null; |
||||
StringBuffer passwd_str = new StringBuffer(); |
||||
String value; |
||||
int n; |
||||
|
||||
MessageDigest sha = MessageDigest.getInstance("SHA-1"); |
||||
sha.update(buf); |
||||
digest = sha.digest(); |
||||
|
||||
for (int i = 0; i < digest.length; i++) { |
||||
n = (int) digest[i]; |
||||
if (n < 0) |
||||
n += 256; |
||||
value = Integer.toHexString(n); |
||||
if (n < 16) |
||||
value = "0" + value; |
||||
passwd_str.append(value); |
||||
} |
||||
|
||||
upd_passwd_sha = "update userinfo set passwd_sha = '" + passwd_str |
||||
+ "'" + " where tid = " + newtid; |
||||
|
||||
DBAccess.executeUpdate(upd_passwd_sha); |
||||
DBAccess.userListeNeuEinlesen(); |
||||
mbt.neuAufbauen(DBAccess.getUserListe()); |
||||
mbt.setSelection(kennung); |
||||
nutzerGewählt(); |
||||
SuperXDBAdmin.setStatus("Benutzer mit Standardpasswort angelegt!"); |
||||
} catch (Exception e) { |
||||
SuperXDBAdmin.setStatus("Interner Fehler: " + e.toString()); |
||||
} |
||||
} |
||||
} |
@ -1,782 +0,0 @@
@@ -1,782 +0,0 @@
|
||||
package de.superx.dbadmin; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Container; |
||||
import java.awt.Font; |
||||
import java.awt.GridLayout; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.text.DateFormat; |
||||
import java.text.ParseException; |
||||
import java.util.Calendar; |
||||
import java.util.Enumeration; |
||||
import java.util.GregorianCalendar; |
||||
import java.util.TimeZone; |
||||
import java.util.Vector; |
||||
|
||||
import javax.swing.JButton; |
||||
import javax.swing.JLabel; |
||||
import javax.swing.JOptionPane; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JScrollPane; |
||||
import javax.swing.JTextField; |
||||
import javax.swing.JTree; |
||||
import javax.swing.event.CellEditorListener; |
||||
import javax.swing.event.ChangeEvent; |
||||
import javax.swing.tree.DefaultMutableTreeNode; |
||||
import javax.swing.tree.DefaultTreeModel; |
||||
import javax.swing.tree.TreePath; |
||||
import javax.swing.tree.TreeSelectionModel; |
||||
|
||||
import de.memtext.tree.CheckBoxNodeDec; |
||||
import de.memtext.tree.CheckBoxTreeDec; |
||||
|
||||
class UserThemenPanel extends JPanel implements CellEditorListener, ActionListener { |
||||
private static final Font BTN_FONT = new Font("Arial", Font.PLAIN, 10); |
||||
boolean result; |
||||
boolean etwasGeändert = false; |
||||
Vector themenbaum; |
||||
int AnzahlEinträge; |
||||
JLabel Standlabel; |
||||
GregorianCalendar cal = new GregorianCalendar(); |
||||
String standString; |
||||
JTextField suchtext; |
||||
Container cp; |
||||
JTree tree = null; |
||||
SxThemenEintrag2 einEintrag; |
||||
JScrollPane treeScroll; |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public UserThemenPanel() { |
||||
super(); |
||||
|
||||
this.setLayout(new BorderLayout()); |
||||
//top panel für Stand
|
||||
|
||||
|
||||
|
||||
JPanel top = new JPanel(); |
||||
|
||||
MBComboBox mbt = new MBComboBox(DBAccess.getUserListe()); |
||||
// mbt.AddActionListener(this);
|
||||
top.add(mbt); |
||||
|
||||
//Standauswahl erstmal nicht anzeigen
|
||||
// top.add(Standlabel);
|
||||
// top.add(bStand);
|
||||
|
||||
this.add(top, "North"); |
||||
|
||||
//JTree erzeugen
|
||||
JPanel center = new JPanel(); //new GridLayout(1, 2));
|
||||
|
||||
tree = new JTree(); |
||||
|
||||
//,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
|
||||
center.add(new CheckBoxTreeDec(tree,"setAllowed")); |
||||
// cp.add(treeScroll, "Center");
|
||||
this.add(treeScroll, "Center"); |
||||
|
||||
//Suchen Feld + Buttons
|
||||
JPanel down = new JPanel(); |
||||
down.setLayout(new GridLayout(3, 1)); |
||||
|
||||
JPanel psuchen = new JPanel(); |
||||
suchtext = new JTextField(10); |
||||
suchtext.setFont(BTN_FONT); |
||||
psuchen.add(suchtext); |
||||
|
||||
JButton suchen = new JButton("Suchen"); |
||||
suchen.setFont(BTN_FONT); |
||||
suchen.addActionListener(this); |
||||
|
||||
psuchen.add(suchen); |
||||
|
||||
down.add(psuchen); |
||||
|
||||
JPanel pspeichern = new JPanel(); |
||||
JButton speichern = new JButton("speichern"); |
||||
speichern.addActionListener(this); |
||||
pspeichern.add(speichern); |
||||
down.add(pspeichern); |
||||
|
||||
this.add("South", down); |
||||
//darf erst hier unten stehen, da tree schon existieren muss
|
||||
if (SuperXDBAdmin.getSelectedUser()!=-999) mbt.setSelection(SuperXDBAdmin.getSelectedUser()); |
||||
|
||||
} |
||||
public void prepare() |
||||
{ |
||||
tree_erzeugen(); |
||||
} |
||||
public void actionPerformed(ActionEvent event) { |
||||
if (event.getActionCommand().equals("speichern")) |
||||
saveUserRights(); |
||||
|
||||
if (event.getActionCommand().equals("Suchen")) |
||||
suchen(); |
||||
|
||||
Object src = event.getSource(); |
||||
if (src instanceof MBComboBox) { |
||||
MBComboBox localbox = (MBComboBox) event.getSource(); |
||||
|
||||
SuperXDBAdmin.setSelectedUser(localbox.getSelectedID()); |
||||
readUserRights(); |
||||
tree.repaint(); |
||||
} |
||||
|
||||
} |
||||
|
||||
/* Methode um alle Kinder eines Knotens freizuschalten. Wenn es sich bei einem Eintrag um eine Maske |
||||
* handelt, wird sie überall im Baum freigeschaltet |
||||
* param node Knoten desses Kinder freigeschaltet werden sollen |
||||
*/ |
||||
private void children_freischalten(DefaultMutableTreeNode node) { |
||||
DefaultMutableTreeNode aNode; |
||||
SxThemenEintrag2 x; |
||||
for (Enumeration en = node.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
x = (SxThemenEintrag2) aNode.getUserObject(); |
||||
x.setErlaubt(true); |
||||
wennMaskeÜberall(aNode,"freischalten"); |
||||
} |
||||
} |
||||
|
||||
/* Methode um alle Kinder eines Knotens zu sprren. Wenn es sich bei einem Eintrag um eine Maske |
||||
* handelt, wird sie überall im Baum gesperrt |
||||
* param node Knoten desses Kinder gesperrt werden sollen |
||||
*/ |
||||
public void childrenSperren(DefaultMutableTreeNode node) { |
||||
DefaultMutableTreeNode aNode; |
||||
SxThemenEintrag2 x; |
||||
for (Enumeration en = node.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
x = (SxThemenEintrag2) aNode.getUserObject(); |
||||
x.setErlaubt(false); |
||||
wennMaskeÜberall(aNode,"sperren"); |
||||
} |
||||
} |
||||
|
||||
public void editingCanceled(ChangeEvent e) { |
||||
} |
||||
/* Methode die das Ende einer Bearbeitung feststellt |
||||
*/ |
||||
public void editingStopped(ChangeEvent e) { |
||||
// CellEditor cellEditor = (CellEditor)e.getSource();
|
||||
InstEditor cellEditor = (InstEditor) e.getSource(); |
||||
DefaultMutableTreeNode node = |
||||
(DefaultMutableTreeNode) cellEditor.getLastEditedNode(); |
||||
|
||||
SxThemenEintrag2 x = (SxThemenEintrag2) node.getUserObject(); |
||||
|
||||
if (x.isErlaubt()) { |
||||
children_freischalten(node); |
||||
prüfeObParentFreischalten(node); |
||||
wennMaskeÜberall(node,"freischalten"); |
||||
} |
||||
else { |
||||
parents_sperren(node); |
||||
childrenSperren(node); |
||||
wennMaskeÜberall(node,"sperren"); |
||||
} |
||||
|
||||
} |
||||
|
||||
/* Einen String in ein java.sql.Date-Objekt umformen |
||||
* |
||||
* returns java.sql.Date |
||||
*/ |
||||
public static java.sql.Date getDate(String value) { |
||||
|
||||
DateFormat df; |
||||
java.util.Date date; |
||||
java.sql.Date sql_date; |
||||
Calendar calendar; |
||||
|
||||
df = DateFormat.getDateInstance(DateFormat.MEDIUM); |
||||
// r.b. default Jahr 4-stellig
|
||||
df.setTimeZone(TimeZone.getDefault()); |
||||
df.setLenient(false); |
||||
|
||||
try { |
||||
if (value.endsWith("00")) { |
||||
switch (value.charAt(value.length() - 3)) { |
||||
case '-' : |
||||
case '.' : |
||||
case '/' : |
||||
value = value.substring(0, value.length() - 2) + "2000"; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
date = df.parse(value); |
||||
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); |
||||
|
||||
sql_date = new java.sql.Date(calendar.getTime().getTime()); |
||||
return sql_date; |
||||
} |
||||
catch (ParseException e_parse) { |
||||
// System.err.println ("SxDate: ERROR: parse: Date != " + value);
|
||||
} |
||||
catch (IllegalArgumentException e_arg) { |
||||
// System.err.println ("SxDate: ERROR: arg: Date != " + value);
|
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
/* rekursive Methode, die Institutionen in den Baum einträgt |
||||
* param Integer Parent - Nummer des Vaterknotens |
||||
* param aktNode - der Aktuelle Knoten |
||||
*/ |
||||
private void insertnodes(Integer theParent, ThemenNode aktNode) { |
||||
Vector result = new Vector(); |
||||
result = mySelect(theParent); |
||||
Integer eintrag_tid; |
||||
|
||||
for (Enumeration el = result.elements(); el.hasMoreElements();) { |
||||
einEintrag = (SxThemenEintrag2) el.nextElement(); |
||||
ThemenNode neuNode = new ThemenNode(einEintrag); |
||||
aktNode.add(neuNode); |
||||
|
||||
eintrag_tid = einEintrag.getTid(); |
||||
//nervig null-Werte abfangen
|
||||
if (eintrag_tid != null & theParent == null) |
||||
insertnodes(einEintrag.getTid(), neuNode); |
||||
if (eintrag_tid == null & theParent == null) |
||||
System.out.println( |
||||
"Achtung! Element hat fälschlicherweise sich selbst als parent:" |
||||
+ einEintrag.getName()); |
||||
|
||||
if (eintrag_tid != null && theParent != null) |
||||
if (!theParent.equals(eintrag_tid)) |
||||
insertnodes(einEintrag.getTid(), neuNode); |
||||
else |
||||
System.out.println( |
||||
"Achtung! Element hat fälschlicherweise sich selbst als parent:" |
||||
+ einEintrag.getName() |
||||
+ "tid:" |
||||
+ einEintrag.getTid()); |
||||
} |
||||
|
||||
//wenn eine Kategorie (maskeninfo==null) keine Blätter (Abfragen)
|
||||
//enthält, die Kategorie entfernen
|
||||
einEintrag = (SxThemenEintrag2) aktNode.getUserObject(); |
||||
// if (einEintrag.getMaskeninfo_id()==null&&result.size()<1)
|
||||
if (einEintrag.getMaskeninfo_id() == null && aktNode.isLeaf()) |
||||
aktNode.removeFromParent(); |
||||
|
||||
} |
||||
|
||||
/* Liefert die Anzahl der Kinder eines Knotens zurück |
||||
*/ |
||||
public int countChildren(DefaultMutableTreeNode node) { |
||||
int zähler = 0; |
||||
DefaultMutableTreeNode aNode; |
||||
for (Enumeration en = node.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
zähler++; |
||||
} |
||||
return zähler - 1; |
||||
|
||||
} |
||||
public void log(String was) { |
||||
System.out.println(was); |
||||
//ggfs. in Datei schreiben
|
||||
} |
||||
|
||||
/* Liefert ähnlich wie ein SQL-select alle Einträge mit einem bestimmten parent zurück |
||||
* param pruefparent - |
||||
* returns Vector |
||||
*/ |
||||
private Vector mySelect(Integer pruefparent) { |
||||
Vector result = new Vector(); |
||||
Integer eintrag_parent; |
||||
for (Enumeration el = themenbaum.elements(); el.hasMoreElements();) { |
||||
einEintrag = (SxThemenEintrag2) el.nextElement(); |
||||
eintrag_parent = einEintrag.getParent(); |
||||
if (eintrag_parent == null && pruefparent == null) |
||||
result.addElement(einEintrag); |
||||
if (eintrag_parent != null && pruefparent != null) |
||||
if (eintrag_parent.intValue() == pruefparent.intValue()) |
||||
result.addElement(einEintrag); |
||||
|
||||
} |
||||
return result; |
||||
} |
||||
|
||||
private void readUserRights() |
||||
{ |
||||
readUserRights(false); |
||||
} |
||||
|
||||
/* Rechte eines Nutzers einlesen und den Baum aktualisieren |
||||
* param mute - boolean gibt an ob am Ende ein Hinweis "User geändert" ausgegeben werden soll |
||||
*/ |
||||
private void readUserRights(boolean mute) { |
||||
Integer id; |
||||
DefaultMutableTreeNode aNode, childNode, nochnKnoten; |
||||
SxThemenEintrag2 x,x2; |
||||
DefaultMutableTreeNode root = (DefaultMutableTreeNode) tree.getModel().getRoot(); |
||||
//erstmal alles auf erlaubt=false setzen
|
||||
for (Enumeration en = root.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
if (aNode.getUserObject() instanceof SxThemenEintrag2) { |
||||
x = (SxThemenEintrag2) aNode.getUserObject(); |
||||
x.setErlaubt(false); |
||||
} |
||||
} |
||||
|
||||
try { |
||||
|
||||
String query = |
||||
"select id, maske from user_themen where userid=" + SuperXDBAdmin.getSelectedUser(); |
||||
// "select userinfo_id, maskeninfo_id from user_masken_bez where userinfo_id=" + SuperXDBAdmin.getSelectedUser();
|
||||
|
||||
|
||||
Vector erg=DBAccess.executeQuery(query); |
||||
String maske;Vector help; |
||||
for (Enumeration el=erg.elements(); el.hasMoreElements(); ) { |
||||
help=(Vector)el.nextElement(); |
||||
|
||||
id = (Integer) help.get(0); |
||||
maske = help.get(1).toString(); |
||||
|
||||
for (Enumeration en = root.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
if (aNode.getUserObject() instanceof SxThemenEintrag2) { |
||||
x = (SxThemenEintrag2) aNode.getUserObject(); |
||||
|
||||
// wenn eine Maske freigegeben ist
|
||||
|
||||
if (maske.equals("1") |
||||
&& x.getMaskeninfo_id() != null |
||||
&& x.getMaskeninfo_id().equals(id)) |
||||
x.setErlaubt(true); |
||||
|
||||
|
||||
// wenn es sich um keine Maske handelt, aber die Tid freigeben ist
|
||||
// also bei Knoten wie "Haushalt"
|
||||
if (maske.equals("0") && x.getTid().equals(id)) |
||||
{ |
||||
x.setErlaubt(true); |
||||
//Kinder auch
|
||||
for (Enumeration en2 = aNode.depthFirstEnumeration(); en2.hasMoreElements();) { |
||||
childNode = (DefaultMutableTreeNode) en2.nextElement(); |
||||
x = (SxThemenEintrag2) childNode.getUserObject(); |
||||
x.setErlaubt(true); |
||||
//entsprechende Maske überall im Baum freischalten
|
||||
for (Enumeration en3 = root.depthFirstEnumeration(); en3.hasMoreElements();) { |
||||
nochnKnoten=(DefaultMutableTreeNode)en3.nextElement(); |
||||
x2=(SxThemenEintrag2)nochnKnoten.getUserObject(); |
||||
if (x2.getMaskeninfo_id()!=null&&x2.getMaskeninfo_id().equals(x.getMaskeninfo_id())) |
||||
x2.setErlaubt(true); |
||||
} |
||||
|
||||
} |
||||
|
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
if (!mute) SuperXDBAdmin.setStatus("User geändert"); |
||||
} |
||||
catch (Exception e) { |
||||
JOptionPane.showMessageDialog( |
||||
null, |
||||
"Fehler beim Lesen aus der Datenbank: " + e.toString(), |
||||
"SuperX DB Admin", |
||||
JOptionPane.WARNING_MESSAGE); |
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
} |
||||
|
||||
/* Rechte eines Nutzers in die Datenbank eintragen. Erst werden alle Einträge gelöscht. |
||||
* Wenn ein ganzer Knoten (mit Kindern) wie "Haushalt" freigegeben ist, wird nur die tid |
||||
* dieses Knotens in der Tabelle themenbaum in die Tabelle user_themen eingetragen. |
||||
* Wenn eine einzele Maske freigegeben wird, wird deren maskeninfo-id in user_themen eingetragen. |
||||
*/ |
||||
public void saveUserRights() { |
||||
Enumeration en; |
||||
int i = 0; |
||||
String ins = null; |
||||
String wo = null; |
||||
|
||||
//datum String in sql.Date umformen
|
||||
java.sql.Date date = new java.sql.Date(1); |
||||
SxDate mydate = new SxDate(); |
||||
date = mydate.getDate(standString); |
||||
|
||||
// MBProgressBar progress=new MBProgressBar(10);
|
||||
try { |
||||
DefaultMutableTreeNode lroot = |
||||
(DefaultMutableTreeNode) tree.getModel().getRoot(); |
||||
DefaultMutableTreeNode aNode; |
||||
SxThemenEintrag2 x;Object userobj; |
||||
String upd = "delete from user_themen where userid=" + SuperXDBAdmin.getSelectedUser(); |
||||
DBAccess.executeUpdate(upd); |
||||
|
||||
TreePath tp; |
||||
DefaultMutableTreeNode vorher; |
||||
aNode = null; |
||||
String id; |
||||
int maske = 0; |
||||
for (en = lroot.breadthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
userobj = aNode.getUserObject(); |
||||
if (userobj instanceof SxThemenEintrag2&&aNode!=lroot) { |
||||
x=(SxThemenEintrag2)userobj; |
||||
if (x.isErlaubt()) { |
||||
if (x.getMaskeninfo_id() != null) { |
||||
id = x.getMaskeninfo_id().toString(); |
||||
maske = 1; |
||||
} |
||||
else { |
||||
id = x.getTid().toString(); |
||||
maske = 0; |
||||
} |
||||
|
||||
ins = |
||||
new String( |
||||
"insert into user_themen (userid, id,maske) " |
||||
+ "values (" |
||||
+ SuperXDBAdmin.getSelectedUser() |
||||
+ "," |
||||
+ id |
||||
+ "," |
||||
+ maske |
||||
+ ")"); |
||||
DBAccess.executeUpdate(ins); |
||||
i++; |
||||
//children sperren, da nur Eintrag von hierarchiehöchstem Element nötig
|
||||
|
||||
childrenSperren(aNode); |
||||
|
||||
} |
||||
//progress.inc();
|
||||
} |
||||
} |
||||
|
||||
SuperXDBAdmin.setStatus(i + " Einträge in user_themen geschrieben"); |
||||
etwasGeändert = false; |
||||
//da Kinder der Verarbeitung wegen gesperrt wurden, muss neu eingelesen werden
|
||||
readUserRights(true); |
||||
} |
||||
catch (Exception e) { |
||||
JOptionPane.showMessageDialog( |
||||
null, |
||||
"Fehler beim Schreiben in die Datenbank:\n " + e.toString(), |
||||
"SuperX DB Admin", |
||||
JOptionPane.WARNING_MESSAGE); |
||||
System.out.println(wo + ": " + ins); |
||||
e.printStackTrace(); |
||||
|
||||
} |
||||
//progress.hide();
|
||||
//progress.dispose();
|
||||
|
||||
} |
||||
|
||||
/* Parent eines Knotens und ggfs. wiederum desses Parent sperren |
||||
*/ |
||||
private void parents_sperren(DefaultMutableTreeNode node) { |
||||
DefaultMutableTreeNode aNode; |
||||
SxThemenEintrag2 x; |
||||
boolean go = true; |
||||
while (go) { |
||||
aNode = (DefaultMutableTreeNode) node.getParent(); |
||||
if (aNode == null || !(aNode.getUserObject() instanceof SxThemenEintrag2)) |
||||
return; //root
|
||||
|
||||
x = (SxThemenEintrag2) aNode.getUserObject(); |
||||
if (x.isErlaubt()) |
||||
//wenn parent erlaubt ist, den auf false setzen
|
||||
// und in Schleife weitermachen
|
||||
//denn sobald nur eines der Kinderelemente eines parents nicht erlaubt,
|
||||
//ist er selbst nicht mehr erlaubt
|
||||
x.setErlaubt(false); |
||||
// ansonsten war parent schon auf false und man braucht nicht weitermachen
|
||||
else |
||||
go = false; |
||||
node = aNode; |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
private void prüfeObParentSperren(DefaultMutableTreeNode node) { |
||||
DefaultMutableTreeNode aNode; |
||||
DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent(); |
||||
SxThemenEintrag2 x; |
||||
boolean alleKinderErlaubt = true; |
||||
for (Enumeration en = parent.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
if (!aNode.equals(parent)) { |
||||
x = (SxThemenEintrag2) aNode.getUserObject(); |
||||
if (!x.isErlaubt()) |
||||
alleKinderErlaubt = false; |
||||
} |
||||
} |
||||
if (!alleKinderErlaubt) { |
||||
x = (SxThemenEintrag2) parent.getUserObject(); |
||||
x.setErlaubt(false); |
||||
} |
||||
if (!parent.isRoot()) |
||||
prüfeObParentSperren(parent); |
||||
|
||||
} |
||||
|
||||
private void prüfeObParentFreischalten(DefaultMutableTreeNode node) { |
||||
DefaultMutableTreeNode aNode; |
||||
DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent(); |
||||
SxThemenEintrag2 x; |
||||
boolean alleKinderErlaubt = true; |
||||
for (Enumeration en = parent.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
if (!aNode.equals(parent)) { |
||||
x = (SxThemenEintrag2) aNode.getUserObject(); |
||||
if (!x.isErlaubt()) |
||||
alleKinderErlaubt = false; |
||||
} |
||||
} |
||||
if (alleKinderErlaubt) { |
||||
x = (SxThemenEintrag2) parent.getUserObject(); |
||||
x.setErlaubt(true); |
||||
} |
||||
if (!parent.isRoot()) |
||||
prüfeObParentFreischalten(parent); |
||||
} |
||||
|
||||
|
||||
private void suchen() { |
||||
String such = suchtext.getText().toLowerCase(); |
||||
String teststring; |
||||
TreePath tp; |
||||
boolean gefunden = false; |
||||
DefaultMutableTreeNode test, ausgesucht; |
||||
ausgesucht = null; |
||||
Vector treffer = new Vector(); |
||||
Vector treffernodes = new Vector(); |
||||
|
||||
if (such.length() < 1) { |
||||
JOptionPane.showMessageDialog(null, "Bitte Suchbegriff eingeben!", "SuperX", 1); |
||||
return; |
||||
} |
||||
such = such.toLowerCase(); |
||||
//JOptionPane.showMessageDialog(null, "neu","SuperX",1);
|
||||
//alle Knoten durchlaufen
|
||||
DefaultMutableTreeNode 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) JOptionPane.showInputDialog( |
||||
null, |
||||
"Mehrere Treffer!\nBitte 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.addSelectionPath(tp); |
||||
//tree.makeVisible(tp);
|
||||
|
||||
// tree.validate();
|
||||
// tree.repaint();
|
||||
} |
||||
else |
||||
JOptionPane.showMessageDialog(null, "Keine Treffer", "SuperX", 1); |
||||
} |
||||
private void tree_erzeugen() { |
||||
|
||||
|
||||
String name, erlaeuterung; |
||||
Integer tid, maskeninfo_id, parent; |
||||
java.sql.Date gueltig_seit, gueltig_bis; |
||||
|
||||
try { |
||||
Vector rohform = new Vector(); |
||||
|
||||
//informix
|
||||
String query = |
||||
//Kategorien, wie Studierende/Prüfungen
|
||||
//wenn keine Rechte für Abfragen darunter werden die Äste wieder gelöscht
|
||||
|
||||
"select T.tid,T.name, T.maskeninfo_id, T.parent, T.erlaeuterung,T.gueltig_seit,T.gueltig_bis " |
||||
+ "from themenbaum T " |
||||
+ "where T.maskeninfo_id is null" |
||||
//+ " and T.gueltig_seit<=date('" + date + "') and T.gueltig_bis>=date('" + date + "') "
|
||||
+ " union " |
||||
+ |
||||
|
||||
//und alle Abfragen
|
||||
"select T.tid,M.name, T.maskeninfo_id, T.parent, M.erlaeuterung,T.gueltig_seit,T.gueltig_bis " |
||||
+ "from themenbaum T, maskeninfo M " |
||||
+ "where T.maskeninfo_id=M.tid" |
||||
//+ "and T.gueltig_seit<=date('" + date + "') and T.gueltig_bis>=date('" + date + "') "
|
||||
+ " order by 2"; |
||||
|
||||
|
||||
|
||||
rohform = DBAccess.executeQuery(query); |
||||
if (rohform.size() < 1) |
||||
throw new RuntimeException("Keine Themenbaum-Einträge für User gefunden"); |
||||
//Umformen in Vector of SxThemenEintrag2
|
||||
Vector dummy = new Vector(); |
||||
themenbaum = new Vector(); |
||||
Enumeration en1 = rohform.elements(); |
||||
while (en1.hasMoreElements()) { |
||||
dummy = (Vector) en1.nextElement(); |
||||
tid = (Integer) dummy.elementAt(0); |
||||
name = (String) dummy.elementAt(1); |
||||
name = name.trim(); |
||||
maskeninfo_id = (Integer) dummy.elementAt(2); |
||||
parent = (Integer) dummy.elementAt(3); |
||||
erlaeuterung = (String) dummy.elementAt(4); |
||||
gueltig_seit = (java.sql.Date) dummy.elementAt(5); |
||||
gueltig_bis = (java.sql.Date) dummy.elementAt(6); |
||||
|
||||
einEintrag = |
||||
new SxThemenEintrag2(tid, name, maskeninfo_id, parent, erlaeuterung,gueltig_seit,gueltig_bis); |
||||
themenbaum.addElement(einEintrag); |
||||
} |
||||
rohform = null; |
||||
SxThemenEintrag2 ebene0 = |
||||
new SxThemenEintrag2(null, "Abfragen/Berichte", null, null, null,null,null); |
||||
ThemenNode root = new ThemenNode(ebene0); |
||||
|
||||
//hier werden über eine rekursive Methode alle
|
||||
//Institute in den Baum eingetragen
|
||||
insertnodes(null, root); |
||||
themenbaum = null; |
||||
|
||||
//Baum erzeugen
|
||||
|
||||
tree.setModel(new DefaultTreeModel(root)); |
||||
//root Abfragen/Berichte sieht man sowieso nicht
|
||||
//first child abfragen muss aufgeklappt sein
|
||||
//da Mouselistener Doubleclick umfunktioniert
|
||||
if (root.getChildCount() > 0) { |
||||
DefaultMutableTreeNode ebene1 = (DefaultMutableTreeNode) root.getChildAt(0); |
||||
tree.expandPath(new TreePath(ebene1.getPath())); |
||||
} |
||||
|
||||
tree.setRootVisible(false); |
||||
//Einfachselektion
|
||||
tree.getSelectionModel().setSelectionMode( |
||||
TreeSelectionModel.SINGLE_TREE_SELECTION); |
||||
|
||||
SuperXDBAdmin.setStatus(AnzahlEinträge + " ThemenEinträge eingelesen"); |
||||
|
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
JOptionPane.showMessageDialog( |
||||
null, |
||||
"Fehler bei Datenbankzugriff: " + e.toString(), |
||||
"UserThemen", |
||||
1); |
||||
} |
||||
|
||||
|
||||
|
||||
} |
||||
|
||||
private void wennMaskeÜberall(DefaultMutableTreeNode node, String was) { |
||||
Object userobj = node.getUserObject(); |
||||
DefaultMutableTreeNode root = |
||||
(DefaultMutableTreeNode) tree.getModel().getRoot(); |
||||
|
||||
DefaultMutableTreeNode aNode; |
||||
SxThemenEintrag2 test; |
||||
if (userobj instanceof SxThemenEintrag2) { |
||||
SxThemenEintrag2 x = (SxThemenEintrag2) userobj; |
||||
if (x.getMaskeninfo_id()!= null) { |
||||
|
||||
for (Enumeration en = root.depthFirstEnumeration(); en.hasMoreElements();) { |
||||
aNode = (DefaultMutableTreeNode) en.nextElement(); |
||||
test = (SxThemenEintrag2) aNode.getUserObject(); |
||||
if (test.getMaskeninfo_id() != null |
||||
&& test.getMaskeninfo_id().equals(x.getMaskeninfo_id())) |
||||
{ |
||||
if (was.equals("freischalten")) |
||||
{test.setErlaubt(true);prüfeObParentFreischalten(aNode);} |
||||
else |
||||
{test.setErlaubt(false); |
||||
prüfeObParentSperren(aNode); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
class ThemenNode extends CheckBoxNodeDec |
||||
{ |
||||
public ThemenNode(DefaultMutableTreeNode node, String setMethodName, boolean isCheckBoxVisible) { |
||||
super(node, setMethodName, isCheckBoxVisible); |
||||
} |
||||
public ThemenNode(Object userobj) { |
||||
super(null,null,false); |
||||
} |
||||
private boolean isAllowed; |
||||
|
||||
public void setAllowed(boolean allowed) |
||||
{ |
||||
isAllowed=allowed; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,35 @@
@@ -0,0 +1,35 @@
|
||||
package de.superx.util.saxon.extensions; |
||||
|
||||
import de.memtext.util.DateUtils; |
||||
import net.sf.saxon.s9api.ExtensionFunction; |
||||
import net.sf.saxon.s9api.ItemType; |
||||
import net.sf.saxon.s9api.OccurrenceIndicator; |
||||
import net.sf.saxon.s9api.QName; |
||||
import net.sf.saxon.s9api.SaxonApiException; |
||||
import net.sf.saxon.s9api.SequenceType; |
||||
import net.sf.saxon.s9api.XdmAtomicValue; |
||||
import net.sf.saxon.s9api.XdmValue; |
||||
|
||||
public class DateTodayString implements ExtensionFunction { |
||||
|
||||
@Override |
||||
public XdmValue call(XdmValue[] arg0) throws SaxonApiException { |
||||
return new XdmAtomicValue(DateUtils.getTodayString()); |
||||
} |
||||
|
||||
@Override |
||||
public SequenceType[] getArgumentTypes() { |
||||
return new SequenceType[] {}; |
||||
} |
||||
|
||||
@Override |
||||
public QName getName() { |
||||
return new QName("http://memtext.de", "getTodayString"); |
||||
} |
||||
|
||||
@Override |
||||
public SequenceType getResultType() { |
||||
return SequenceType.makeSequenceType(ItemType.STRING, OccurrenceIndicator.ONE); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,52 @@
@@ -0,0 +1,52 @@
|
||||
package de.superx.util.saxon.extensions; |
||||
|
||||
import de.memtext.util.StringUtils; |
||||
import de.superx.util.HtmlUtils.HeaderMatrix; |
||||
import net.sf.saxon.s9api.ExtensionFunction; |
||||
import net.sf.saxon.s9api.ItemType; |
||||
import net.sf.saxon.s9api.OccurrenceIndicator; |
||||
import net.sf.saxon.s9api.QName; |
||||
import net.sf.saxon.s9api.SaxonApiException; |
||||
import net.sf.saxon.s9api.SequenceType; |
||||
import net.sf.saxon.s9api.XdmAtomicValue; |
||||
import net.sf.saxon.s9api.XdmValue; |
||||
import net.sf.saxon.trans.XPathException; |
||||
|
||||
public class Headers2Html implements ExtensionFunction { |
||||
|
||||
@Override |
||||
public QName getName() { |
||||
return new QName("http://memtext.de", "headers2html"); |
||||
} |
||||
|
||||
@Override |
||||
public SequenceType getResultType() { |
||||
return SequenceType.makeSequenceType(ItemType.STRING, OccurrenceIndicator.ONE); |
||||
} |
||||
|
||||
@Override |
||||
public net.sf.saxon.s9api.SequenceType[] getArgumentTypes() { |
||||
return new SequenceType[] {SequenceType.makeSequenceType(ItemType.STRING, OccurrenceIndicator.ONE)}; |
||||
} |
||||
|
||||
@Override |
||||
public XdmValue call(XdmValue[] arguments) throws SaxonApiException { |
||||
//de-escapting \\n to regular \n
|
||||
String headerStr = null; |
||||
try { |
||||
headerStr = arguments[0].getUnderlyingValue().getStringValue(); |
||||
} catch (XPathException e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
headerStr = headerStr.trim(); |
||||
//headerStr=headerStr.replaceAll("\\n","\n");
|
||||
if (headerStr.endsWith("^")) headerStr = headerStr.substring(0, headerStr.length() - 1); |
||||
StringBuffer buf = new StringBuffer(headerStr); |
||||
StringUtils.replace(buf, "\\n", "\n"); |
||||
StringUtils.replace(buf, "\\000", "\000"); |
||||
HeaderMatrix headers = null; |
||||
headers = new HeaderMatrix(buf.toString(), "^", "\000"); |
||||
return new XdmAtomicValue(headers.toString()); |
||||
} |
||||
|
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue