/** * constructor * * @param sshare session share */ public SpotterButton(SessionShare sshare) { JMenuItem item; this.sshare = sshare; // setBackground(Global.BGCOLOR); setContentAreaFilled(false); // setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); setMargin(new Insets(0, 0, 0, 0)); setBorder(new VButtonBorder()); setUnderline(false); setIcon(Util.getImageIcon("search_20.png")); setToolTipText(Util.getLabel("_Locator_Statements")); addMouseListener( new MouseAdapter() { public void mousePressed(MouseEvent evt) { // Save startup time by not filling this menu until // it is first clicked. fillPopupMenu(); } }); addPopListener( new PopListener() { public void popHappened(String popStr) { SessionShare sshare = ResultTable.getSshare(); if (popStr.startsWith("save:")) { String saveName = popStr.substring(5); StatementHistory history = sshare.statementHistory(); history.readNamedStatement(saveName); } else if (popStr.startsWith("command:")) { String commandName = popStr.substring(8); int index = commandName.indexOf('/'); String objType = commandName.substring(0, index); LocatorHistory lh = sshare.getLocatorHistory(); // Set History Active Object type to this type. lh.setActiveObjType(objType); // Now get history for this type. StatementHistory history = sshare.statementHistory(); history.appendLastOfType(commandName); } else if (popStr.startsWith("title:")) { String objType = popStr.substring(6); LocatorHistory lh = sshare.getLocatorHistory(); // Update locator to the most recent statement for this type lh.setHistoryToThisType(objType); } } }); DisplayOptions.addChangeListener(this); } // SpotterButton()
/** * ************************************************ * * <pre> * Summary: Constructor, Add buttons to dialog box * * </pre> * * ************************************************* */ public TagAddRemoveDialog() { super(Util.getLabel("_Locator_Add_Remove")); // Make a panel for the buttons panelForBtns = new JPanel(); // It looks better with a border panelForBtns.setBorder(BorderFactory.createEmptyBorder(20, 35, 20, 35)); // Create the two items. addButton = new JButton("Add to Group"); removeButton = new JButton("Remove From Group"); // Add items to panel panelForBtns.add(addButton); panelForBtns.add(removeButton); // Add the panel top of the dialog. getContentPane().add(panelForBtns, BorderLayout.NORTH); // Set the buttons and the text item up with Listeners cancelButton.setActionCommand("cancel"); cancelButton.addActionListener(this); helpButton.setActionCommand("help"); helpButton.addActionListener(this); addButton.setActionCommand("add"); addButton.addActionListener(this); addButton.setMnemonic('a'); removeButton.setActionCommand("remove"); removeButton.addActionListener(this); removeButton.setMnemonic('r'); // OK disabled. okButton.setEnabled(false); setBgColor(Util.getBgColor()); DisplayOptions.addChangeListener(this); // Make the frame fit its contents. pack(); }
public void mouseClicked(MouseEvent evt) { int btn = evt.getButton(); if (btn == MouseEvent.BUTTON3) { JPopupMenu helpMenu = new JPopupMenu(); String helpLabel = Util.getLabel("CSHMenu"); JMenuItem helpMenuItem = new JMenuItem(helpLabel); helpMenuItem.setActionCommand("help"); helpMenu.add(helpMenuItem); ActionListener alMenuItem = new ActionListener() { public void actionPerformed(ActionEvent e) { String topic = ""; try { JComponent c1 = (JComponent) tabbedPane.getSelectedComponent(); // This component should contain the following embedded items. // We want m_helplink out of the top VGroup. // PushpinObj // XMLToolPanel // JScrollpane // JViewport // JPanel // VGroup // Work down to the VGroup, checking for class type along // the way. if (c1 instanceof PushpinObj) { Component c2[] = c1.getComponents(); int cnt; for (cnt = 0; cnt < c2.length; cnt++) { // The PushpinObj can have multiple items, find the one we want if (c2[cnt] instanceof XMLToolPanel) break; } if (cnt < c2.length && c2[cnt] instanceof XMLToolPanel) { Component c3[] = ((JComponent) c2[cnt]).getComponents(); if (c3[0] instanceof JScrollPane) { Component c4[] = ((JComponent) c3[0]).getComponents(); if (c4[0] instanceof JViewport) { Component c5[] = ((JComponent) c4[0]).getComponents(); if (c5[0] instanceof JPanel) { Component c6[] = ((JComponent) c5[0]).getComponents(); if (c6[0] instanceof VGroup) { // Get the helplink info from the VGroup topic = ((VGroup) c6[0]).getAttribute(VObjDef.HELPLINK); } } } } } } // If no helplink found, try the Tab's name if (topic == null || topic.length() == 0) { topic = c1.getName(); if (topic.equals("Locator")) topic = getLocatorName(); topic = topic.replace(" ", "_"); } } catch (Exception ex) { } // Get the ID and display the help content CSH_Util.displayCSHelp(topic); } }; helpMenuItem.addActionListener(alMenuItem); Point pt = evt.getPoint(); helpMenu.show(VTabbedToolPanel.this, (int) pt.getX(), (int) pt.getY()); } }
/** * Title: WGlobal Description: This file has the global variables implemented for the Wanda * interface. Copyright: Copyright (c) 2002 */ public class WGlobal { public static final String AREA1 = "Area1"; public static final String AREA2 = "Area2"; public static final String INFODIR = "Infodir"; public static final String BUILD = "Build"; public static final String WRITE = "Write"; public static final String CLEAR = "Clear"; public static final String ALL = "All"; public static final String SET_VISIBLE = "Set visible"; public static final String SAVEUSER = vnmr.util.Util.getLabel("_admin_Save_User"); public static final String SAVEGROUP = "Save Group"; public static final String SAVEUSER_NOERROR = "Save User No Error"; public static final String USER_CHANGE = "User Change"; public static final String GROUP_CHANGE = "Group Change"; public static final String DELETE_USER = "******"; public static final String ITEM_LIST = "Item List"; public static final String ACTIVATE = "Activate Account"; public static final String BGCOLOR = "BgColor"; public static final String FONTSCOLORS = "Fonts Colors"; public static final String SEPERATOR = "_"; public static final String SUDO = getSudo(); public static final String SHTOOLCMD = System.getProperty("shtoolcmd"); public static final String SHTOOLOPTION = System.getProperty("shtooloption"); public static final String NAME = "accname"; public static final String FULLNAME = "name"; public static final String PART11 = "part11"; public static final String ITEM_AREA1 = "Item" + SEPERATOR + AREA1; public static final String ITEM_AREA2 = "Item" + SEPERATOR + AREA2; public static final String DETAIL_AREA1 = "Detail" + SEPERATOR + AREA1; public static final String DETAIL_AREA2 = "Detail" + SEPERATOR + AREA2; public static final String ADMIN_BGCOLOR = "Wanda" + BGCOLOR; public static final String PANELLEVEL = "30"; public static final String IMGDIR = FileUtil.sysdir() + File.separator + Global.IMAGING; public static final String WALKUPDIR = FileUtil.sysdir(); public static final String LCDIR = FileUtil.sysdir() + File.separator + Global.LC; public static final String SBIN = getSbin(); public static final String OPT_PER_FILE = "USER/PERSISTENCE/AdminOptions"; // persistence file public static final String TRASHCAN_FILE = "SYSTEM/PROFILES/trashcan"; /** label for admin interface */ public static String ADMINIFLBL = Util.getLabel("_Global_Administrative", Global.ADMINIF); /** label for walkup interface */ public static String WALKUPIFLBL = Util.getLabel("_Global_Walkup", Global.WALKUPIF); /** label for imaging interface */ public static String IMGIFLBL = Util.getLabel("_Global_Imaging", Global.IMGIF); /** label for lc interface */ public static String LCIFLBL = Util.getLabel("_Global_LCIF", Global.LCIF); /** The array of requried fields for a user. */ public static final String[] USR_REQ_FIELDS = { NAME, "home", "userdir", "sysdir", "datadir", "itype" }; // "sysdir", "datadir", "appdir", "itype"}; public static final String[] USR_PART11_REQ_FIELDS = { NAME, "home", "name", "userdir", "sysdir", "datadir", "itype" }; // "sysdir", "datadir", "appdir", "itype"}; public static final String[] USR_REQ_FIELDS_WIN = { NAME, "home", "userdir", "sysdir", "datadir", "itype" }; public static final String[] USR_PART11_REQ_FIELDS_WIN = { NAME, "home", "name", "userdir", "sysdir", "datadir", "itype" }; public static String getPropName(String strLabel) { String strPropName = strLabel; String strTmp = strLabel.toLowerCase(); if (strTmp.startsWith("fonts")) strPropName = FONTSCOLORS; return strPropName; } public static String getSbin() { String strSbin = "/usr/varian/sbin/"; if (Util.iswindows()) { strSbin = "/vnmr/bin/"; } else { UNFile file = new UNFile(strSbin); if (!file.exists()) strSbin = FileUtil.sysdir() + "/bin/"; } return strSbin; } public static String getSudo() { // Default to /usr/bin String strSudo = "/usr/bin/sudo "; if (Util.iswindows()) strSudo = ""; UNFile file = new UNFile("/usr/bin/sudo"); if (!file.exists()) { // If no /usr/bin/sudo, then try /usr/local/bin file = new UNFile("/usr/local/bin/sudo"); if (file.exists()) strSudo = "/usr/local/bin/sudo "; } // Messages.postDebug("SUDO path=" + strSudo); return strSudo; } private WGlobal() { // not meant to be used. } }
protected void enterLogin() { char[] password = m_passwordField.getPassword(); String strUser = (String) m_cmbUser.getSelectedItem(); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); boolean blogin = WUserUtil.isOperatorNameok(strUser, false); if (blogin) { blogin = vnmrjPassword(strUser, password); if (!blogin) blogin = unixPassword(strUser, password); } if (blogin) { m_lblLogin.setForeground(Color.black); m_lblLogin.setText("Login Successful"); m_lblLogin.setVisible(true); // Get the Email column string for access to the operator data String emStr = vnmr.util.Util.getLabel("_admin_Email"); String stremail = WUserUtil.getOperatordata(strUser, emStr); // Get the Panel Level column string for access to the operator data String plStr = vnmr.util.Util.getLabel("_admin_Panel_Level"); String strPanel = WUserUtil.getOperatordata(strUser, plStr); if (stremail == null || stremail.equals("null")) stremail = ""; try { Integer.parseInt(strPanel); } catch (Exception e) { strPanel = WGlobal.PANELLEVEL; } m_trayTimer.stop(); Messages.postDebug(" Login: "******"appdir('reset','") .append(strUser) .append("','") .append(stremail) .append("',") .append(strPanel) .append(")") .toString()); exp.sendToVnmr("vnmrjcmd('util', 'bgReady')\n"); } setVisible(false); // Save the current position and size of this panel in case it // was changed Dimension size = getSize(); width = size.width; height = size.height; position = getLocation(); writePersistence(); // Call the macro to update this operator's // ExperimentSelector_operatorName.xml file // from the protocols themselves. This macro will // cause an update of the ES when it is finished // Util.getAppIF().sendToVnmr("updateExpSelector"); // I am not sure why we need to force updates since updateExpSelector // should have caused an update by writing to ES_op.xml file. // However, it works better if we do the force update. // ExpSelector.setForceUpdate(true); } else { m_lblLogin.setForeground(DisplayOptions.getColor("Error")); // m_lblLogin.setText("<HTML>Incorrect username/password <p> Please try again </HTML>"); m_lblLogin.setVisible(true); } setCursor(Cursor.getDefaultCursor()); }
protected void dolayout(String strDir, String strFreq, String strTraynum) { // TopBar String strTitle = gettitle(strFreq); Color color = DisplayOptions.getColor("Heading3"); // Center Panel JPanel panelCenter = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints( 0, 0, 1, 1, 0.2, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0); ImageIcon icon = getImageIcon(); // panelCenter.add(new JLabel(icon)); addComp(panelCenter, new JLabel(icon), gbc, 0, 0); strTitle = getSampleName(strDir, strTraynum); m_lblSampleName = new JLabel(strTitle); if (strTitle == null || !strTitle.trim().equals("")) strTitle = "3"; Font font = m_lblSampleName.getFont(); font = DisplayOptions.getFont(font.getName(), Font.BOLD, 300); m_lblSampleName.setFont(font); m_lblSampleName.setForeground(color); // panelCenter.add(m_lblSampleName); m_pnlSampleName = new JPanel(new CardLayout()); m_pnlSampleName.add(m_lblSampleName, OTHER); addComp(panelCenter, m_pnlSampleName, gbc, 1, 0); m_pnlSampleName.setVisible(false); m_pnlTrays = new JPanel(new GridLayout(1, 0)); // Vast panels VBox pnlVast1 = new VBox(m_pnlTrays, "1"); m_pnlTrays.add(pnlVast1); m_pnlVast[0] = pnlVast1; VBox pnlVast2 = new VBox(m_pnlTrays, "2"); m_pnlTrays.add(pnlVast2); m_pnlVast[1] = pnlVast2; VBox pnlVast3 = new VBox(m_pnlTrays, "3"); m_pnlTrays.add(pnlVast3); m_pnlVast[2] = pnlVast3; VBox pnlVast4 = new VBox(m_pnlTrays, "4"); m_pnlTrays.add(pnlVast4); m_pnlVast[3] = pnlVast4; VBox pnlVast5 = new VBox(m_pnlTrays, "5"); m_pnlTrays.add(pnlVast5); m_pnlVast[4] = pnlVast5; m_pnlSampleName.add(m_pnlTrays, VAST); // Login Panel JPanel panelThird = new JPanel(new BorderLayout()); JPanel panelLogin = new JPanel(new GridBagLayout()); gbc = new GridBagConstraints(); panelThird.add(panelLogin); Object[] aStrUser = getOperators(); m_cmbUser = new JComboBox(aStrUser); BasicComboBoxRenderer renderer = new BasicComboBoxRenderer(); m_cmbUser.setRenderer(renderer); m_cmbUser.setEditable(true); m_passwordField = new JPasswordField(); // *Warning, working around a Java problem* // When we went to the T3500 running Redhat 5.3, the JPasswordField // fields sometimes does not allow ANY entry of characters. Setting // the enableInputMethods() to true fixed this problem. There are // comments that indicate that this could cause the typed characters // to be visible. I have not found that to be a problem. // This may not be required in the future, or could cause characters // to become visible in the future if Java changes it's code. // GRS 8/20/09 m_passwordField.enableInputMethods(true); m_lblLogin = new VLoginLabel(null, "Incorrect username/password \n Please try again ", 0, 0); m_lblLogin.setVisible(false); okButton.setActionCommand("enter"); okButton.addActionListener(this); cancelButton.setActionCommand("cancel"); cancelButton.addActionListener(this); helpButton.setActionCommand("help"); helpButton.addActionListener(this); m_passwordField.addKeyListener( new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) enterLogin(); } }); // These is some wierd problem such that sometimes, the vnmrj command // area gets the focus and these items in the login box do not get // the focus. Even clicking in these items does not bring focus to // them. Issuing requestFocus() does not bring focus to them. // I can however, determing if either the operator entry box or // the password box has focus and if neither does, I can unshow and // reshow the panel and that fixes the focus. So, I have added this // to the mouseClicked action. If neither has focus, it will // take focus with setVisible false then true. comboTextField = m_cmbUser.getEditor().getEditorComponent(); m_passwordField.addMouseListener(this); comboTextField.addMouseListener(this); m_lblUsername = new JLabel(Util.getLabel("_Operator")); addComp(panelLogin, m_lblUsername, gbc, 0, 0); addComp(panelLogin, m_cmbUser, gbc, 1, 0); m_lblPassword = new JLabel(Util.getLabel("_Password")); addComp(panelLogin, m_lblPassword, gbc, 0, 1); addComp(panelLogin, m_passwordField, gbc, 1, 1); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.gridheight = GridBagConstraints.REMAINDER; addComp(panelLogin, m_lblLogin, gbc, 2, 0); setPref(); Container container = getContentPane(); JPanel panelLoginBox = new JPanel(new BorderLayout()); panelLoginBox.add(panelCenter, BorderLayout.CENTER); panelLoginBox.add(panelThird, BorderLayout.SOUTH); container.add(panelLoginBox, BorderLayout.CENTER); }