You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
314 lines
12 KiB
314 lines
12 KiB
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(); |
|
} |
|
|
|
} |
|
} |