tn5250j/src/org/tn5250j Connect.java,1.15,1.16

[email protected]
Newsgroups gmane.comp.java.tn5250j.cvs
Message-ID <[email protected]>
Update of /cvsroot/tn5250j/tn5250j/src/org/tn5250j
In directory sc8-pr-cvs1:/tmp/cvs-serv21669/src/org/tn5250j

Modified Files:
	Connect.java 
Log Message:
Update related to the restricted option access tab, now also internationalisited.

Index: Connect.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/Connect.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** Connect.java	3 Dec 2003 09:21:28 -0000	1.15
--- Connect.java	15 Dec 2003 15:52:57 -0000	1.16
***************
*** 99,103 ****
  	JPanel interfacePanel = new JPanel();
  	JPanel sessionOpts = new JPanel();
! 	JPanel sessionOptPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 30, 10));
  	JPanel emulOptPanel = new JPanel();
  	JPanel emptyPane = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10));
--- 99,104 ----
  	JPanel interfacePanel = new JPanel();
  	JPanel sessionOpts = new JPanel();
! 	JPanel sessionOptPanel =
! 		new JPanel(new FlowLayout(FlowLayout.CENTER, 30, 10));
  	JPanel emulOptPanel = new JPanel();
  	JPanel emptyPane = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10));
***************
*** 135,142 ****
  	BorderLayout borderLayout = new BorderLayout();
  
!    TN5250jMultiSelectList accessOptions;
!    // password protection field for access to options list
!    JPasswordField password;
!    JButton setPassButton;
  
  	//  Selection value for connection
--- 136,143 ----
  	BorderLayout borderLayout = new BorderLayout();
  
! 	TN5250jMultiSelectList accessOptions;
! 	// password protection field for access to options list
! 	JPasswordField password;
! 	JButton setPassButton;
  
  	//  Selection value for connection
***************
*** 178,185 ****
  		optionTabs.addChangeListener(this);
  
! 		optionTabs.addTab(LangTool.getString("ss.labelConnections"),sessionPanel);
  		optionTabs.addTab(LangTool.getString("ss.labelOptions1"), emulOptPanel);
  
!       createAccessPanel();
  		optionTabs.addTab(LangTool.getString("ss.labelOptions2"), accessPanel);
  
--- 179,188 ----
  		optionTabs.addChangeListener(this);
  
! 		optionTabs.addTab(
! 			LangTool.getString("ss.labelConnections"),
! 			sessionPanel);
  		optionTabs.addTab(LangTool.getString("ss.labelOptions1"), emulOptPanel);
  
! 		createAccessPanel();
  		optionTabs.addTab(LangTool.getString("ss.labelOptions2"), accessPanel);
  
***************
*** 240,249 ****
  			.equals(LangTool.getString("ss.labelConnections"))) {
  			connectButton.setEnabled(false);
! 			this.setTitle(LangTool.getString("ss.title") + " - " +
! 				LangTool.getString("ss.labelOptions1"));
! 			}
! 		else {
! 			this.setTitle(LangTool.getString("ss.title") + " - " +
! 				LangTool.getString("ss.labelConnections"));
  			connectButton.setEnabled(true);
  		}
--- 243,255 ----
  			.equals(LangTool.getString("ss.labelConnections"))) {
  			connectButton.setEnabled(false);
! 			this.setTitle(
! 				LangTool.getString("ss.title")
! 					+ " - "
! 					+ LangTool.getString("ss.labelOptions1"));
! 		} else {
! 			this.setTitle(
! 				LangTool.getString("ss.title")
! 					+ " - "
! 					+ LangTool.getString("ss.labelConnections"));
  			connectButton.setEnabled(true);
  		}
***************
*** 410,424 ****
  
  		gbc = new GridBagConstraints();
! 		gbc.gridx = 0; gbc.gridy = 0;
  		gbc.anchor = GridBagConstraints.WEST;
  		gbc.insets = new Insets(10, 10, 5, 10);
  		interfacePanel.add(intTABS, gbc);
  		gbc = new GridBagConstraints();
! 		gbc.gridx = 0; gbc.gridy = 1;
  		gbc.anchor = GridBagConstraints.WEST;
  		gbc.insets = new Insets(5, 27, 5, 10);
  		interfacePanel.add(hideTabBar, gbc);
  		gbc = new GridBagConstraints();
! 		gbc.gridx = 0; gbc.gridy = 2;
  		gbc.anchor = GridBagConstraints.WEST;
  		gbc.insets = new Insets(5, 10, 10, 10);
--- 416,433 ----
  
  		gbc = new GridBagConstraints();
! 		gbc.gridx = 0;
! 		gbc.gridy = 0;
  		gbc.anchor = GridBagConstraints.WEST;
  		gbc.insets = new Insets(10, 10, 5, 10);
  		interfacePanel.add(intTABS, gbc);
  		gbc = new GridBagConstraints();
! 		gbc.gridx = 0;
! 		gbc.gridy = 1;
  		gbc.anchor = GridBagConstraints.WEST;
  		gbc.insets = new Insets(5, 27, 5, 10);
  		interfacePanel.add(hideTabBar, gbc);
  		gbc = new GridBagConstraints();
! 		gbc.gridx = 0;
! 		gbc.gridy = 2;
  		gbc.anchor = GridBagConstraints.WEST;
  		gbc.insets = new Insets(5, 10, 10, 10);
***************
*** 428,433 ****
  		// create show me panel
  		JPanel showMePanel = new JPanel();
! 		TitledBorder smb = BorderFactory.createTitledBorder(
! 			LangTool.getString("ss.title"));
  		smb.setTitleJustification(TitledBorder.CENTER);
  
--- 437,442 ----
  		// create show me panel
  		JPanel showMePanel = new JPanel();
! 		TitledBorder smb =
! 			BorderFactory.createTitledBorder(LangTool.getString("ss.title"));
  		smb.setTitleJustification(TitledBorder.CENTER);
  
***************
*** 453,551 ****
  	}
  
!    private void createAccessPanel() {
  
!       accessOptions = new TN5250jMultiSelectList();
  
!       if (props.getProperty("emul.accessDigest") != null)
!          accessOptions.setEnabled(false);
  
!       Vector options = OptionAccessFactory.getInstance().getOptions();
  
!       // set up a hashtable of option descriptions to options
!       Hashtable ht = new Hashtable(options.size());
!       for (int x = 0; x < options.size(); x++) {
!          ht.put(LangTool.getString("key."+options.get(x)),options.get(x));
!       }
  
!       // get the sorted descriptions of the options
!       Vector descriptions = OptionAccessFactory.getInstance().getOptionDescriptions();
  
!       // set the option descriptions
!       accessOptions.setListData(descriptions);
  
!       // we now mark the invalid options
!       int num = OptionAccessFactory.getInstance().getNumberOfRestrictedOptions();
!       int[] si = new int[num];
!       int i = 0;
!       for (int x = 0;x < descriptions.size();x++) {
!          if (!OptionAccessFactory.getInstance().isValidOption(
!                   (String)ht.get(descriptions.get(x))  ) )
!             si[i++] = x;
!       }
  
!       accessOptions.setSelectedIndices(si);
  
!       accessOptions.setSourceHeader(LangTool.getString("ss.labelActive"));
!       accessOptions.setSelectionHeader(LangTool.getString("ss.labelRestricted"));
  
  		// create emulator options panel
  		accessPanel.setLayout(new BorderLayout());
  
!       accessPanel.add(accessOptions,BorderLayout.CENTER);
! 
!       JPanel passPanel = new JPanel();
  
!       Action action = new AbstractAction(LangTool.getString("ss.labelSetPass")) {
!             public void actionPerformed(ActionEvent e) {
!                if (password.getPassword().length > 0) {
!                   try {
!                      DESSHA1 sha = new DESSHA1();
!                      props.setProperty("emul.accessDigest",
!                         sha.digest(new String(password.getPassword()),"tn5205j"));
!                   }
!                   catch (Exception ex) {}
!                }
!             }
!         };
  
!       setPassButton = new JButton(action);
  
!       if (props.getProperty("emul.accessDigest") != null)
!          setPassButton.setEnabled(false);
  
!       passPanel.add(setPassButton);
  
!       password = new JPasswordField(20);
!       password.setDocument(new CheckPasswordDocument());
  
!       passPanel.add(password);
  
!       accessPanel.add(passPanel,BorderLayout.NORTH);
  
!    }
  
!    private void doSomethingEntered() {
  
!       if (props.getProperty("emul.accessDigest") != null) {
!          try {
!             DESSHA1 sha = new DESSHA1();
! //            System.out.println(props.getProperty("emul.accessDigest")
! //                     + " -> " + sha.digest(new String(password.getPassword()),"tn5205j"));
!             if (props.getProperty("emul.accessDigest").equals(
!                   sha.digest(new String(password.getPassword()),"tn5205j"))) {
!                accessOptions.setEnabled(true);
!                setPassButton.setEnabled(true);
!             }
!          }
!          catch (Exception ex) {
!             System.out.println(ex.getMessage());
!          }
!       }
!    }
  
!    private void doNothingEntered() {
  
  
!    }
  
  	private void createButtonOptions() {
--- 462,573 ----
  	}
  
! 	private void createAccessPanel() {
  
! 		accessOptions = new TN5250jMultiSelectList();
  
! 		if (props.getProperty("emul.accessDigest") != null)
! 			accessOptions.setEnabled(false);
  
! 		Vector options = OptionAccessFactory.getInstance().getOptions();
  
! 		// set up a hashtable of option descriptions to options
! 		Hashtable ht = new Hashtable(options.size());
! 		for (int x = 0; x < options.size(); x++) {
! 			ht.put(LangTool.getString("key." + options.get(x)), options.get(x));
! 		}
  
! 		// get the sorted descriptions of the options
! 		Vector descriptions =
! 			OptionAccessFactory.getInstance().getOptionDescriptions();
  
! 		// set the option descriptions
! 		accessOptions.setListData(descriptions);
  
! 		// we now mark the invalid options
! 		int num =
! 			OptionAccessFactory.getInstance().getNumberOfRestrictedOptions();
! 		int[] si = new int[num];
! 		int i = 0;
! 		for (int x = 0; x < descriptions.size(); x++) {
! 			if (!OptionAccessFactory
! 				.getInstance()
! 				.isValidOption((String) ht.get(descriptions.get(x))))
! 				si[i++] = x;
! 		}
  
! 		accessOptions.setSelectedIndices(si);
  
! 		accessOptions.setSourceHeader(LangTool.getString("ss.labelActive"));
! 		accessOptions.setSelectionHeader(
! 			LangTool.getString("ss.labelRestricted"));
  
  		// create emulator options panel
  		accessPanel.setLayout(new BorderLayout());
+ 		accessPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 10, 5));
  
! 		accessPanel.add(accessOptions, BorderLayout.CENTER);
  
! 		JPanel passPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10));
  
! 		Action action =
! 			new AbstractAction(LangTool.getString("ss.labelSetPass")) {
! 			public void actionPerformed(ActionEvent e) {
! 				if (password.getPassword().length > 0) {
! 					try {
! 						DESSHA1 sha = new DESSHA1();
! 						props.setProperty(
! 							"emul.accessDigest",
! 							sha.digest(
! 								new String(password.getPassword()),
! 								"tn5205j"));
! 					} catch (Exception ex) {
! 					}
! 				}
! 			}
! 		};
  
! 		setPassButton = new JButton(action);
! 		setPassButton.setPreferredSize(new Dimension(150, 27));
  
! 		if (props.getProperty("emul.accessDigest") != null)
! 			setPassButton.setEnabled(false);
  
! 		passPanel.add(setPassButton);
  
! 		password = new JPasswordField(15);
! 		password.setDocument(new CheckPasswordDocument());
! 		password.setPreferredSize(new Dimension(password.getWidth(), 27));
  
! 		passPanel.add(password);
  
! 		accessPanel.add(passPanel, BorderLayout.NORTH);
  
! 	}
  
! 	private void doSomethingEntered() {
  
! 		if (props.getProperty("emul.accessDigest") != null) {
! 			try {
! 				DESSHA1 sha = new DESSHA1();
! 				//            System.out.println(props.getProperty("emul.accessDigest")
! 				//                     + " -> " + sha.digest(new String(password.getPassword()),"tn5205j"));
! 				if (props
! 					.getProperty("emul.accessDigest")
! 					.equals(
! 						sha.digest(
! 							new String(password.getPassword()),
! 							"tn5205j"))) {
! 					accessOptions.setEnabled(true);
! 					setPassButton.setEnabled(true);
! 				}
! 			} catch (Exception ex) {
! 				System.out.println(ex.getMessage());
! 			}
! 		}
! 	}
  
+ 	private void doNothingEntered() {
  
! 	}
  
  	private void createButtonOptions() {
***************
*** 583,587 ****
  		button.setEnabled(enabled);
  		button.setActionCommand(ac);
!       button.setPreferredSize(new Dimension(140, 28));
  
  		// we check if there was mnemonic specified and if there was then we
--- 605,609 ----
  		button.setEnabled(enabled);
  		button.setActionCommand(ac);
! 		button.setPreferredSize(new Dimension(140, 28));
  
  		// we check if there was mnemonic specified and if there was then we
***************
*** 664,668 ****
  	private void saveProps() {
  
!       setOptionAccess();
  
  		ConfigureFactory.getInstance().saveSettings(
--- 686,690 ----
  	private void saveProps() {
  
! 		setOptionAccess();
  
  		ConfigureFactory.getInstance().saveSettings(
***************
*** 670,696 ****
  			"------ Session Information --------");
  
!       OptionAccessFactory.getInstance().reload();
  	}
  
!    private void setOptionAccess() {
  
!       Vector options = OptionAccessFactory.getInstance().getOptions();
  
!       // set up a hashtable of option descriptions to options
!       Hashtable ht = new Hashtable(options.size());
!       for (int x = 0; x < options.size(); x++) {
!          ht.put(LangTool.getString("key."+options.get(x)),options.get(x));
!       }
  
!       // get the sorted descriptions of the options
!       Vector descriptions = OptionAccessFactory.getInstance().getOptionDescriptions();
  
!       Object[] restrict = accessOptions.getSelectedValues();
!       String s = "";
!       for (int x = 0; x < restrict.length; x++) {
!          s +=ht.get(restrict[x]) + ";";
!       }
!       props.setProperty("emul.restricted",s);
!    }
  
  	private void addLabelComponent(
--- 692,719 ----
  			"------ Session Information --------");
  
! 		OptionAccessFactory.getInstance().reload();
  	}
  
! 	private void setOptionAccess() {
  
! 		Vector options = OptionAccessFactory.getInstance().getOptions();
  
! 		// set up a hashtable of option descriptions to options
! 		Hashtable ht = new Hashtable(options.size());
! 		for (int x = 0; x < options.size(); x++) {
! 			ht.put(LangTool.getString("key." + options.get(x)), options.get(x));
! 		}
  
! 		// get the sorted descriptions of the options
! 		Vector descriptions =
! 			OptionAccessFactory.getInstance().getOptionDescriptions();
  
! 		Object[] restrict = accessOptions.getSelectedValues();
! 		String s = "";
! 		for (int x = 0; x < restrict.length; x++) {
! 			s += ht.get(restrict[x]) + ";";
! 		}
! 		props.setProperty("emul.restricted", s);
! 	}
  
  	private void addLabelComponent(
***************
*** 748,767 ****
  	}
  
!    public class CheckPasswordDocument extends PlainDocument {
  
!       public void insertString(int offs, String str, AttributeSet a)
!                                                    throws BadLocationException {
  
!          super.insertString(offs, str, a);
!          if (getText(0, getLength()).length() > 0)
!             doSomethingEntered();
!       }
  
!       public void remove(int offs, int len) throws BadLocationException {
!          super.remove(offs, len);
!          if (getText(0, getLength()).length() == 0)
!             doNothingEntered();
!       }
!    }
  
  	class ConfigureTableModel
--- 771,790 ----
  	}
  
! 	public class CheckPasswordDocument extends PlainDocument {
  
! 		public void insertString(int offs, String str, AttributeSet a)
! 			throws BadLocationException {
  
! 			super.insertString(offs, str, a);
! 			if (getText(0, getLength()).length() > 0)
! 				doSomethingEntered();
! 		}
  
! 		public void remove(int offs, int len) throws BadLocationException {
! 			super.remove(offs, len);
! 			if (getText(0, getLength()).length() == 0)
! 				doNothingEntered();
! 		}
! 	}
  
  	class ConfigureTableModel




-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.