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. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -142,6 +142,7 @@ public class JopLoginApplet extends JApplet { ...@@ -142,6 +142,7 @@ public class JopLoginApplet extends JApplet {
private void checkUser() { private void checkUser() {
String user = textUser.getText(); String user = textUser.getText();
String passwd = new String(textPassword.getPassword()); String passwd = new String(textPassword.getPassword());
passwd = JopCrypt.crypt( "aa", passwd);
int sts = gdh.login( user, passwd); int sts = gdh.login( user, passwd);
if ( sts % 2 == 0) { if ( sts % 2 == 0) {
JOptionPane.showMessageDialog( this, "User not authorized", 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. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -91,9 +91,7 @@ public class JopLoginFrame extends JFrame { ...@@ -91,9 +91,7 @@ public class JopLoginFrame extends JFrame {
}); });
buttonClear.addActionListener( new ActionListener() { buttonClear.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent e) { public void actionPerformed( ActionEvent e) {
textUser.setText(""); clear();
textPassword.setText("");
labelMessage.setText(" ");
} }
}); });
textUser.addActionListener( new ActionListener() { textUser.addActionListener( new ActionListener() {
...@@ -109,9 +107,17 @@ public class JopLoginFrame extends JFrame { ...@@ -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() { private void checkUser() {
String user = textUser.getText(); String user = textUser.getText();
String passwd = new String(textPassword.getPassword()); String passwd = new String(textPassword.getPassword());
passwd = JopCrypt.crypt( "aa", passwd);
int sts = session.getEngine().gdh.login( user, passwd); int sts = session.getEngine().gdh.login( user, passwd);
if ( sts % 2 == 0) { if ( sts % 2 == 0) {
JOptionPane.showMessageDialog( this, "User not authorized", JOptionPane.showMessageDialog( this, "User not authorized",
...@@ -119,7 +125,11 @@ public class JopLoginFrame extends JFrame { ...@@ -119,7 +125,11 @@ public class JopLoginFrame extends JFrame {
labelMessage.setText(" "); labelMessage.setText(" ");
} }
else { else {
textUser.setText("");
textPassword.setText("");
labelMessage.setText( "User " + user + " logged in"); 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. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -28,6 +28,7 @@ public class JopOpWindow extends JPanel { ...@@ -28,6 +28,7 @@ public class JopOpWindow extends JPanel {
JopSession session; JopSession session;
JopEngine en; JopEngine en;
Object root; Object root;
JLabel label = null;
public JopOpWindow( JopSession session, Object root) { public JopOpWindow( JopSession session, Object root) {
// super( BoxLayout.Y_AXIS); // super( BoxLayout.Y_AXIS);
...@@ -46,19 +47,19 @@ public class JopOpWindow extends JPanel { ...@@ -46,19 +47,19 @@ public class JopOpWindow extends JPanel {
CdhrString srettxt = en.gdh.getObjectInfoString( s); CdhrString srettxt = en.gdh.getObjectInfoString( s);
if ( srettxt.evenSts()) return; if ( srettxt.evenSts()) return;
JLabel label = new JLabel( srettxt.str); JLabel llabel = new JLabel( srettxt.str);
Font f = new Font("Helvetica", Font.BOLD, 24); Font f = new Font("Helvetica", Font.BOLD, 24);
label.setFont( f); llabel.setFont( f);
this.add( label); this.add( llabel);
s = sret.str + ".Text"; s = sret.str + ".Text";
srettxt = en.gdh.getObjectInfoString( s); srettxt = en.gdh.getObjectInfoString( s);
if ( srettxt.evenSts()) return; if ( srettxt.evenSts()) return;
label = new JLabel( srettxt.str); llabel = new JLabel( srettxt.str);
f = new Font("Helvetica", Font.BOLD, 16); f = new Font("Helvetica", Font.BOLD, 16);
label.setFont( f); llabel.setFont( f);
this.add( label); this.add( llabel);
this.add( new JSeparator()); this.add( new JSeparator());
...@@ -66,11 +67,19 @@ public class JopOpWindow extends JPanel { ...@@ -66,11 +67,19 @@ public class JopOpWindow extends JPanel {
CdhrInt iret = en.gdh.getObjectInfoInt( s); CdhrInt iret = en.gdh.getObjectInfoInt( s);
if ( iret.evenSts()) return; if ( iret.evenSts()) return;
label = new JLabel();
this.add( label);
OpWindButton button; OpWindButton button;
if ( iret.value != 0) { if ( iret.value != 0) {
button = new OpWindButton( session, "", "Login", button = new OpWindButton( session, "", "Login",
OpWindButton.LOGIN); OpWindButton.LOGIN);
this.add( button); this.add( button);
button = new OpWindButton( session, "", "Logout",
OpWindButton.LOGOUT);
this.add( button);
} }
s = sret.str + ".EnableAlarmList"; s = sret.str + ".EnableAlarmList";
...@@ -172,11 +181,12 @@ public class JopOpWindow extends JPanel { ...@@ -172,11 +181,12 @@ public class JopOpWindow extends JPanel {
public static final int WEBGRAPH = 1; public static final int WEBGRAPH = 1;
public static final int WEBLINK = 2; public static final int WEBLINK = 2;
public static final int LOGIN = 3; public static final int LOGIN = 3;
public static final int NAVIGATOR = 4; public static final int LOGOUT = 4;
public static final int ALARMLIST = 5; public static final int NAVIGATOR = 5;
public static final int EVENTLOG = 6; public static final int ALARMLIST = 6;
public static final int HELP = 7; public static final int EVENTLOG = 7;
public static final int PROVIEW = 8; public static final int HELP = 8;
public static final int PROVIEW = 9;
JopSession session; JopSession session;
String action; String action;
int type; int type;
...@@ -199,27 +209,45 @@ public class JopOpWindow extends JPanel { ...@@ -199,27 +209,45 @@ public class JopOpWindow extends JPanel {
public void mouseReleased(MouseEvent e) { public void mouseReleased(MouseEvent e) {
switch ( type) { switch ( type) {
case NAVIGATOR: case NAVIGATOR:
if ( ! en.gdh.isAuthorized( Pwr.mAccess_AllPwr))
break;
session.openNavigator( null); session.openNavigator( null);
break; break;
case LOGIN: case LOGIN:
session.openLogin(); session.openLogin();
break; break;
case LOGOUT:
en.gdh.logout();
setLabelText( " ");
break;
case ALARMLIST: case ALARMLIST:
if ( ! en.gdh.isAuthorized( Pwr.mAccess_AllPwr))
break;
session.openAlarmList(); session.openAlarmList();
break; break;
case EVENTLOG: case EVENTLOG:
if ( ! en.gdh.isAuthorized( Pwr.mAccess_AllPwr))
break;
session.openEventLog(); session.openEventLog();
break; break;
case HELP: case HELP:
if ( ! en.gdh.isAuthorized( Pwr.mAccess_AllPwr))
break;
session.executeCommand("help index"); session.executeCommand("help index");
break; break;
case PROVIEW: case PROVIEW:
if ( ! en.gdh.isAuthorized( Pwr.mAccess_AllPwr))
break;
session.executeCommand("open url \"$pwr_doc/sv_se/index.html\""); session.executeCommand("open url \"$pwr_doc/sv_se/index.html\"");
break; break;
case WEBGRAPH: case WEBGRAPH:
if ( ! en.gdh.isAuthorized( Pwr.mAccess_AllPwr))
break;
session.openGraphFrame( action, instance, scrollbar, false); session.openGraphFrame( action, instance, scrollbar, false);
break; break;
case WEBLINK: case WEBLINK:
if ( ! en.gdh.isAuthorized( Pwr.mAccess_AllPwr))
break;
String cmd = "open url \"" + action + "\""; String cmd = "open url \"" + action + "\"";
session.executeCommand( cmd); session.executeCommand( cmd);
break; break;
...@@ -235,7 +263,10 @@ public class JopOpWindow extends JPanel { ...@@ -235,7 +263,10 @@ public class JopOpWindow extends JPanel {
public void setInstance( String instance) { public void setInstance( String instance) {
this.instance = 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. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -62,6 +62,10 @@ public class JopOpWindowApplet extends JopApplet ...@@ -62,6 +62,10 @@ public class JopOpWindowApplet extends JopApplet
super.destroy(); super.destroy();
} }
public void setLabelText( String text) {
localPanel.setLabelText( text);
}
public void init() public void init()
{ {
super.init(); super.init();
...@@ -88,5 +92,7 @@ public class JopOpWindowApplet extends JopApplet ...@@ -88,5 +92,7 @@ public class JopOpWindowApplet extends JopApplet
public void stop() { 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. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -51,6 +51,10 @@ public class JopOpWindowFrame extends JFrame { ...@@ -51,6 +51,10 @@ public class JopOpWindowFrame extends JFrame {
pack(); pack();
} }
public void setLabelText( String text) {
localPanel.setLabelText( text);
}
private void init() { private void init() {
contentPane = (JPanel) this.getContentPane(); contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(borderLayout1); 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. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -120,9 +120,13 @@ public class JopSession { ...@@ -120,9 +120,13 @@ public class JopSession {
return ((JopSessionIfc) sessionRep).isOpWindowApplet(); return ((JopSessionIfc) sessionRep).isOpWindowApplet();
} }
public void openSearch(String object ){ public void openSearch( String object ){
((JopSessionIfc) sessionRep).openSearch(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. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -42,4 +42,5 @@ public interface JopSessionIfc { ...@@ -42,4 +42,5 @@ public interface JopSessionIfc {
public boolean isApplication(); public boolean isApplication();
public boolean isOpWindowApplet(); public boolean isOpWindowApplet();
public void openSearch(String object); 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. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -102,6 +102,7 @@ public class JopSessionRep implements JopSessionIfc { ...@@ -102,6 +102,7 @@ public class JopSessionRep implements JopSessionIfc {
login.setVisible( true); login.setVisible( true);
} }
else { else {
login.clear();
login.setVisible( true); login.setVisible( true);
login.setState(Frame.NORMAL); login.setState(Frame.NORMAL);
login.toFront(); login.toFront();
...@@ -300,12 +301,22 @@ public class JopSessionRep implements JopSessionIfc { ...@@ -300,12 +301,22 @@ public class JopSessionRep implements JopSessionIfc {
public boolean isOpWindowApplet() { public boolean isOpWindowApplet() {
return ( root instanceof JopOpWindowApplet); return ( root instanceof JopOpWindowApplet);
} }
public boolean isOpWindowFrame() {
return ( root instanceof JopOpWindowFrame);
}
public void openSearch(String object){ public void openSearch(String object){
HistSearch HSWindow = new HistSearch(object,session ); HistSearch HSWindow = new HistSearch(object,session );
HSWindow.pack(); HSWindow.pack();
HSWindow.setVisible(true); 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