public void propertyChange(PropertyChangeEvent evt) { if (fg != null) { fgColor = DisplayOptions.getColor(fg); setForeground(fgColor); } changeFont(); }
public VCaretEntry(SessionShare sshare, ButtonIF vif, String typ) { this.type = typ; this.vnmrIf = vif; this.fg = "black"; this.fontSize = "8"; setText(""); setOpaque(false); orgBg = VnmrRgb.getColorByName("darkGray"); setHorizontalAlignment(JTextField.LEFT); setMargin(new Insets(0, 2, 0, 2)); ml = new MouseAdapter() { public void mouseClicked(MouseEvent evt) { int clicks = evt.getClickCount(); int modifier = evt.getModifiers(); if ((modifier & (1 << 4)) != 0) { if (clicks >= 2) ParamEditUtil.setEditObj((VObjIF) evt.getSource()); } } }; new DropTarget(this, this); DisplayOptions.addChangeListener(this); setEditable(true); caret = new VCaret(); setCaret(caret); addCaretListener(this); }
public VText(SessionShare sshare, ButtonIF vif, String typ) { this.vnmrIf = vif; setOpaque(false); setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); twin = new VTextWin(this, sshare, vif, typ); setViewportView(twin); JViewport vp = getViewport(); vp.setBackground(Util.getBgColor()); orgBg = getBackground(); ml = new MouseAdapter() { public void mouseClicked(MouseEvent evt) { int clicks = evt.getClickCount(); int modifier = evt.getModifiers(); if ((modifier & (1 << 4)) != 0) { if (clicks >= 2) { ParamEditUtil.setEditObj((VObjIF) evt.getSource()); } } } }; new DropTarget(this, this); DisplayOptions.addChangeListener(this); }
public void propertyChange(PropertyChangeEvent evt) { if (DisplayOptions.isUpdateUIEvent(evt)) { SwingUtilities.updateComponentTreeUI(this); gradientPanel.remove(drawable); JPanel newpanel = createGradientPanel(); contentPane.remove(gradientPanel); gradientPanel = newpanel; gradientPanel.add(drawable, BorderLayout.CENTER); contentPane.add(gradientPanel, BorderLayout.CENTER); } }
/** * 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()
protected void setPref() { Color color = DisplayOptions.getColor("PlainText"); Font font = DisplayOptions.getFont("PlainText"); m_lblUsername.setForeground(color); m_lblUsername.setFont(font); m_lblPassword.setForeground(color); m_lblPassword.setFont(font); m_cmbUser.getEditor().getEditorComponent().setForeground(color); m_cmbUser.getEditor().getEditorComponent().setFont(font); m_passwordField.setForeground(color); m_passwordField.setFont(font); color = DisplayOptions.getColor("Heading3"); font = DisplayOptions.getFont("Heading3"); m_lblSampleName.setForeground(color); m_pnlTrays.setBorder( BorderDeli.createBorder("Empty", "Sample Trays", "Bottom", "Center", color, font)); VBox.setforeground(color); VBox.setfont(font); }
public void changeFont() { font = DisplayOptions.getFont(fontName, fontStyle, fontSize); setFont(font); fontH = font.getSize(); rHeight = fontH; if (!inEditMode) { if ((curDim.height > 0) && (rHeight > curDim.height)) { adjustFont(curDim.width, curDim.height); } } repaint(); }
public GLDemo() { super(VNMRFrame.getVNMRFrame(), "Jogl Demo", false); DisplayOptions.addChangeListener(this); contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); gradientPanel = createGradientPanel(); contentPane.add(gradientPanel, BorderLayout.CENTER); checkBox = new JCheckBox("Transparent", true); checkBox.setActionCommand("transparancy"); checkBox.addActionListener(this); optionsPan = new JPanel(); optionsPan.setLayout(new SimpleH2Layout(SimpleH2Layout.LEFT, 5, 0, true, false)); optionsPan.setBorder(new EtchedBorder(EtchedBorder.LOWERED)); optionsPan.add(checkBox); runButton = new JToggleButton("Run"); runButton.setActionCommand("run"); runButton.setSelected(false); runButton.addActionListener(this); optionsPan.add(runButton); getContentPane().add(optionsPan, BorderLayout.SOUTH); setSize(300, 300); setLocation(300, 300); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { // Run this on another thread than the AWT event queue to // make sure the call to Animator.stop() completes before // exiting new Thread( new Runnable() { public void run() { stop(); } }) .start(); } }); setVisible(false); }
public void adjustFont(int w, int h) { if (h <= 0) return; int oldH = rHeight; if (font == null) { font = getFont(); fontH = font.getSize(); rHeight = fontH; } nHeight = h; if (fontH >= h) rHeight = h - 2; else rHeight = fontH; if ((rHeight < 10) && (fontH > 10)) rHeight = 10; if (oldH != rHeight) { // Font curFont = font.deriveFont((float) rHeight); Font curFont = DisplayOptions.getFont(font.getName(), font.getStyle(), rHeight); setFont(curFont); } if (rHeight > h) rHeight = h; }
public LoginBox() { super("VnmrJ Login"); dolayout("", "", ""); setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); // setVast(); DisplayOptions.addChangeListener(this); try { InetAddress inetAddress = InetAddress.getLocalHost(); m_strHostname = inetAddress.getHostName(); } catch (Exception e) { m_strHostname = "localhost"; } VNMRFrame vnmrFrame = VNMRFrame.getVNMRFrame(); Dimension size = vnmrFrame.getSize(); position = vnmrFrame.getLocationOnScreen(); AppIF appIF = Util.getAppIF(); int h = appIF.statusBar.getSize().height; width = size.width; height = size.height - h; // Allow resizing and use the previous size and position // To stop resizing, use setResizable(false); readPersistence(); // setSize(width, height); // setLocation(position); // setResizable(false); setBackgroundColor(Util.getBgColor()); m_trayTimer = new javax.swing.Timer( 6000, new ActionListener() { public void actionPerformed(ActionEvent e) { setTrays(); } }); }
public void destroy() { DisplayOptions.removeChangeListener(this); }
public void setAttribute(int attr, String c) { switch (attr) { case TYPE: type = c; break; case FGCOLOR: fg = c; fgColor = DisplayOptions.getColor(fg); setForeground(fgColor); repaint(); break; case BGCOLOR: if (!DisplayOptions.isOption(DisplayOptions.COLOR, c)) c = null; bg = c; if (c != null) { bgColor = DisplayOptions.getColor(c); setOpaque(true); } else { bgColor = Util.getBgColor(); if (isActive < 1) setOpaque(true); else setOpaque(inEditMode); } setBackground(bgColor); repaint(); break; case COLOR2: caretColor = c; if (DisplayOptions.isOption(DisplayOptions.COLOR, c)) { Color col = DisplayOptions.getColor(c); setCaretColor(col); setSelectionColor(col); } break; case SHOW: showVal = c; setBorder(isEnabled); break; case FONT_NAME: fontName = c; break; case FONT_STYLE: fontStyle = c; break; case FONT_SIZE: fontSize = c; break; case SETVAL: setVal = c; break; case SETVAL2: caretQuery = c; break; case VARIABLE: vnmrVar = c; break; case CMD: vnmrCmd = c; break; case CMD2: caretCmd = c; break; case NUMDIGIT: precision = c; break; case LABEL: label = c; break; case VALUE: value = c; setText(c); break; case KEYSTR: keyStr = c; break; case KEYVAL: setText(c); break; case DISABLE: m_strDisAbl = c; break; } }
public void fillPopupMenu() { JMenuItem item; TextImageIcon textIcon; StatementHistory history; int rowCount = 0; int numRows = 0; Insets margin = new Insets(0, 0, 0, 0); // Get the font defined in the displayOptions panel for menus Font ft = DisplayOptions.getFont("Menu1"); // We need a fairly small font, so make it 2 smaller. int size = ft.getSize(); // If larger than 12, subtract 2 if (size > 12) size -= 2; Font font = DisplayOptions.getFont(ft.getName(), ft.getStyle(), size); // This flag is used so that we only fill the menu when needed if (menuAlreadyFilled) return; menuAlreadyFilled = true; history = sshare.statementHistory(); ArrayList list = history.getNamedStatementList(); Color bgColor = Util.getBgColor(); // Only show the Saved Statements section if there are some. if (list != null && list.size() != 0) { item = popup.add("Saved Statements"); rowCount++; // item.setForeground(Color.blue); // item.setBackground(bgColor); item.setFont(font); item.setMargin(margin); popup.add(item); for (int i = 0; i < list.size(); i++) { ArrayList nameNlabel = (ArrayList) list.get(i); // first item in nameNlabel is name and second is label item = popup.add(" " + (String) nameNlabel.get(1)); rowCount++; item.setActionCommand("save:" + (String) nameNlabel.get(0)); // item.setBackground(bgColor); item.addActionListener(popActionListener); item.setFont(font); item.setMargin(margin); } } // the rest of menu (return object types, statement types, etc.) ShufflerService shufflerService = sshare.shufflerService(); ArrayList objTypes = shufflerService.getAllMenuObjectTypes(); for (int i = 0; i < objTypes.size(); i++) { String objType = (String) objTypes.get(i); // Do not display menu for DB_AVAIL_SUB_TYPES if (objType.equals(Shuf.DB_AVAIL_SUB_TYPES)) continue; // addSeparator looks bad using GridLayout because it creates rows // and columns which are all equal in size. It cannot have a row // with a separator which is a different height than the other // rectangles it creates. So just use dashes. item = popup.add(separator); item.setFont(font); item.setMargin(margin); rowCount++; item = popup.add(shufflerService.getCategoryLabel(objType)); rowCount++; // item.setForeground(Color.blue); item.setActionCommand("title:" + objType); // item.setBackground(bgColor); item.addActionListener(popActionListener); item.setFont(font); item.setMargin(margin); ArrayList menuStrings = shufflerService.getmenuStringsThisObj(objType); // If current rowCount plus the next section size is too big, // specify the numRows to the current value of rowCount -1. // That is, put this next section in a new column. // 47 is emperical number of rows to fit 90% full screen. if (numRows == 0 && rowCount - 1 + menuStrings.size() > 44) { numRows = rowCount - 2; } for (int j = 0; j < menuStrings.size(); j++) { String menuString = (String) menuStrings.get(j); item = popup.add(" " + menuString); rowCount++; item.setActionCommand("command:" + objType + "/" + menuString); // item.setBackground(bgColor); item.addActionListener(popActionListener); item.setFont(font); item.setMargin(margin); } // The spotter menu changes dynamically when // the list of saved statements changes. history.addStatementListener( new StatementAdapter() { public void saveListChanged() { refreshSaveMenu(); } }); } if (numRows == 0) numRows = rowCount; GridLayoutCol lm = new GridLayoutCol(numRows, 0); popup.setLayout(lm); }
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); }