Commit 75901483 authored by claes's avatar claes

Label with username added and login frame improved

parent 3912277b
/*
* Proview $Id: JopLoginApplet.java,v 1.2 2005-09-01 14:57:50 claes Exp $
* Proview $Id: JopLoginApplet.java,v 1.3 2008-06-24 13:33:26 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -142,6 +142,7 @@ public class JopLoginApplet extends JApplet {
private void checkUser() {
String user = textUser.getText();
String passwd = new String(textPassword.getPassword());
passwd = JopCrypt.crypt( "aa", passwd);
int sts = gdh.login( user, passwd);
if ( sts % 2 == 0) {
JOptionPane.showMessageDialog( this, "User not authorized",
......
/*
* Proview $Id: JopLoginFrame.java,v 1.2 2005-09-01 14:57:50 claes Exp $
* Proview $Id: JopLoginFrame.java,v 1.3 2008-06-24 13:34:14 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -91,9 +91,7 @@ public class JopLoginFrame extends JFrame {
});
buttonClear.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent e) {
textUser.setText("");
textPassword.setText("");
labelMessage.setText(" ");
clear();
}
});
textUser.addActionListener( new ActionListener() {
......@@ -109,9 +107,17 @@ public class JopLoginFrame extends JFrame {
});
}
public void clear() {
textUser.setText("");
textPassword.setText("");
labelMessage.setText(" ");
javax.swing.FocusManager.getCurrentManager().focusNextComponent( textUser);
}
private void checkUser() {
String user = textUser.getText();
String passwd = new String(textPassword.getPassword());
passwd = JopCrypt.crypt( "aa", passwd);
int sts = session.getEngine().gdh.login( user, passwd);
if ( sts % 2 == 0) {
JOptionPane.showMessageDialog( this, "User not authorized",
......@@ -119,7 +125,11 @@ public class JopLoginFrame extends JFrame {
labelMessage.setText(" ");
}
else {
textUser.setText("");
textPassword.setText("");
labelMessage.setText( "User " + user + " logged in");
session.setOpWindowLabelText( user + " logged in");
hide();
}
}
}
/*
* Proview $Id: JopOpWindow.java,v 1.7 2007-01-30 06:52:55 claes Exp $
* Proview $Id: JopOpWindow.java,v 1.8 2008-06-24 13:35:11 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -28,6 +28,7 @@ public class JopOpWindow extends JPanel {
JopSession session;
JopEngine en;
Object root;
JLabel label = null;
public JopOpWindow( JopSession session, Object root) {
// super( BoxLayout.Y_AXIS);
......@@ -46,19 +47,19 @@ public class JopOpWindow extends JPanel {
CdhrString srettxt = en.gdh.getObjectInfoString( s);
if ( srettxt.evenSts()) return;
JLabel label = new JLabel( srettxt.str);
JLabel llabel = new JLabel( srettxt.str);
Font f = new Font("Helvetica", Font.BOLD, 24);
label.setFont( f);
this.add( label);
llabel.setFont( f);
this.add( llabel);
s = sret.str + ".Text";
srettxt = en.gdh.getObjectInfoString( s);
if ( srettxt.evenSts()) return;
label = new JLabel( srettxt.str);
llabel = new JLabel( srettxt.str);
f = new Font("Helvetica", Font.BOLD, 16);
label.setFont( f);
this.add( label);
llabel.setFont( f);
this.add( llabel);
this.add( new JSeparator());
......@@ -66,11 +67,19 @@ public class JopOpWindow extends JPanel {
CdhrInt iret = en.gdh.getObjectInfoInt( s);
if ( iret.evenSts()) return;
label = new JLabel();
this.add( label);
OpWindButton button;
if ( iret.value != 0) {
button = new OpWindButton( session, "", "Login",
OpWindButton.LOGIN);
this.add( button);
button = new OpWindButton( session, "", "Logout",
OpWindButton.LOGOUT);
this.add( button);
}
s = sret.str + ".EnableAlarmList";
......@@ -172,11 +181,12 @@ public class JopOpWindow extends JPanel {
public static final int WEBGRAPH = 1;
public static final int WEBLINK = 2;
public static final int LOGIN = 3;
public static final int NAVIGATOR = 4;
public static final int ALARMLIST = 5;
public static final int EVENTLOG = 6;
public static final int HELP = 7;
public static final int PROVIEW = 8;
public static final int LOGOUT = 4;
public static final int NAVIGATOR = 5;
public static final int ALARMLIST = 6;
public static final int EVENTLOG = 7;
public static final int HELP = 8;
public static final int PROVIEW = 9;
JopSession session;
String action;
int type;
......@@ -199,27 +209,45 @@ public class JopOpWindow extends JPanel {
public void mouseReleased(MouseEvent e) {
switch ( type) {
case NAVIGATOR:
if ( ! en.gdh.isAuthorized( Pwr.mAccess_AllPwr))
break;
session.openNavigator( null);
break;
case LOGIN:
session.openLogin();
break;
case LOGOUT:
en.gdh.logout();
setLabelText( " ");
break;
case ALARMLIST:
if ( ! en.gdh.isAuthorized( Pwr.mAccess_AllPwr))
break;
session.openAlarmList();
break;
case EVENTLOG:
if ( ! en.gdh.isAuthorized( Pwr.mAccess_AllPwr))
break;
session.openEventLog();
break;
case HELP:
if ( ! en.gdh.isAuthorized( Pwr.mAccess_AllPwr))
break;
session.executeCommand("help index");
break;
case PROVIEW:
if ( ! en.gdh.isAuthorized( Pwr.mAccess_AllPwr))
break;
session.executeCommand("open url \"$pwr_doc/sv_se/index.html\"");
break;
case WEBGRAPH:
if ( ! en.gdh.isAuthorized( Pwr.mAccess_AllPwr))
break;
session.openGraphFrame( action, instance, scrollbar, false);
break;
case WEBLINK:
if ( ! en.gdh.isAuthorized( Pwr.mAccess_AllPwr))
break;
String cmd = "open url \"" + action + "\"";
session.executeCommand( cmd);
break;
......@@ -235,7 +263,10 @@ public class JopOpWindow extends JPanel {
public void setInstance( String instance) {
this.instance = instance;
}
}
public void setLabelText( String text) {
label.setText( text);
}
}
......
/*
* Proview $Id: JopOpWindowApplet.java,v 1.2 2005-09-01 14:57:50 claes Exp $
* Proview $Id: JopOpWindowApplet.java,v 1.3 2008-06-24 13:35:11 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -62,6 +62,10 @@ public class JopOpWindowApplet extends JopApplet
super.destroy();
}
public void setLabelText( String text) {
localPanel.setLabelText( text);
}
public void init()
{
super.init();
......@@ -88,5 +92,7 @@ public class JopOpWindowApplet extends JopApplet
public void stop() {
}
}
/*
* Proview $Id: JopOpWindowFrame.java,v 1.3 2005-09-01 14:57:50 claes Exp $
* Proview $Id: JopOpWindowFrame.java,v 1.4 2008-06-24 13:35:11 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -51,6 +51,10 @@ public class JopOpWindowFrame extends JFrame {
pack();
}
public void setLabelText( String text) {
localPanel.setLabelText( text);
}
private void init() {
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(borderLayout1);
......
/*
* Proview $Id: JopSession.java,v 1.5 2007-01-30 06:52:55 claes Exp $
* Proview $Id: JopSession.java,v 1.6 2008-06-24 13:35:11 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -120,9 +120,13 @@ public class JopSession {
return ((JopSessionIfc) sessionRep).isOpWindowApplet();
}
public void openSearch(String object ){
((JopSessionIfc) sessionRep).openSearch(object);
}
public void openSearch( String object ){
((JopSessionIfc) sessionRep).openSearch(object);
}
public void setOpWindowLabelText( String text ){
((JopSessionIfc) sessionRep).setOpWindowLabelText( text);
}
}
......
/*
* Proview $Id: JopSessionIfc.java,v 1.5 2007-01-30 06:52:55 claes Exp $
* Proview $Id: JopSessionIfc.java,v 1.6 2008-06-24 13:35:11 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -42,4 +42,5 @@ public interface JopSessionIfc {
public boolean isApplication();
public boolean isOpWindowApplet();
public void openSearch(String object);
public void setOpWindowLabelText( String text );
}
/*
* Proview $Id: JopSessionRep.java,v 1.11 2007-01-30 13:02:27 claes Exp $
* Proview $Id: JopSessionRep.java,v 1.12 2008-06-24 13:35:11 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -102,6 +102,7 @@ public class JopSessionRep implements JopSessionIfc {
login.setVisible( true);
}
else {
login.clear();
login.setVisible( true);
login.setState(Frame.NORMAL);
login.toFront();
......@@ -300,12 +301,22 @@ public class JopSessionRep implements JopSessionIfc {
public boolean isOpWindowApplet() {
return ( root instanceof JopOpWindowApplet);
}
public boolean isOpWindowFrame() {
return ( root instanceof JopOpWindowFrame);
}
public void openSearch(String object){
HistSearch HSWindow = new HistSearch(object,session );
HSWindow.pack();
HSWindow.setVisible(true);
}
public void openSearch(String object){
HistSearch HSWindow = new HistSearch(object,session );
HSWindow.pack();
HSWindow.setVisible(true);
}
public void setOpWindowLabelText( String text) {
if ( isOpWindowApplet())
((JopOpWindowApplet)root).setLabelText( text);
else if ( isOpWindowFrame())
((JopOpWindowFrame)root).setLabelText( text);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment