public void paint(Graphics g) { m_fm = g.getFontMetrics(); g.setColor(getBackground()); g.fillRect(0, 0, getWidth(), getHeight()); getBorder().paintBorder(this, g, 0, 0, getWidth(), getHeight()); g.setColor(getForeground()); g.setFont(getFont()); m_insets = getInsets(); int x = m_insets.left; int y = m_insets.top + m_fm.getAscent(); StringTokenizer st = new StringTokenizer(getText(), "\t"); while (st.hasMoreTokens()) { String sNext = st.nextToken(); g.drawString(sNext, x, y); x += m_fm.stringWidth(sNext); if (!st.hasMoreTokens()) break; int index = 0; while (x >= getTab(index)) index++; x = getTab(index); } }
protected void buildPanel(String strPath) { BufferedReader reader = WFileUtil.openReadFile(strPath); String strLine; if (reader == null) return; try { while ((strLine = reader.readLine()) != null) { if (strLine.startsWith("#") || strLine.startsWith("%") || strLine.startsWith("@")) continue; StringTokenizer sTokLine = new StringTokenizer(strLine, ":"); // first token is the label e.g. Password Length if (sTokLine.hasMoreTokens()) { createLabel(sTokLine.nextToken(), this); } // second token is the value String strValue = sTokLine.hasMoreTokens() ? sTokLine.nextToken() : ""; if (strValue.equalsIgnoreCase("yes") || strValue.equalsIgnoreCase("no")) createChkBox(strValue, this); else createTxf(strValue, this); } } catch (Exception e) { Messages.writeStackTrace(e); // e.printStackTrace(); Messages.postDebug(e.toString()); } }
{ StringBuffer sb = new StringBuffer(); StringTokenizer st = new StringTokenizer(cfg.REQPARAM_CONTACT_LIST_LOGIN_IDS, ","); while (st.hasMoreTokens()) { sb.append(st.nextToken()); if (st.hasMoreTokens()) sb.append("\n"); } contactList.setText(sb.toString()); }
public void setVisible(boolean bShow, String title) { if (bShow) { String strDir = ""; String strFreq = ""; String strTraynum = ""; m_strHelpFile = getHelpFile(title); String strSampleName = getSampleName(title); String frameBounds = getFrameBounds(title); StringTokenizer tok = new QuotedStringTokenizer(title); if (tok.hasMoreTokens()) strDir = tok.nextToken(); if (tok.hasMoreTokens()) strFreq = tok.nextToken(); if (tok.hasMoreTokens()) strTraynum = tok.nextToken(); else { try { Integer.parseInt(strDir); // if strdir is number, then strdir is empty, and the // strfreq is the number strTraynum = strFreq; strFreq = strDir; strDir = ""; } catch (Exception e) { } } try { setTitle(gettitle(strFreq)); m_lblSampleName.setText("3"); boolean bVast = isVast(strTraynum); CardLayout layout = (CardLayout) m_pnlSampleName.getLayout(); if (!bVast) { if (strSampleName == null) { strSampleName = getSampleName(strDir, strTraynum); } m_lblSampleName.setText(strSampleName); layout.show(m_pnlSampleName, OTHER); } else { m_strDir = strDir; setTrays(); layout.show(m_pnlSampleName, VAST); m_trayTimer.start(); } boolean bSample = bVast || !strSampleName.trim().equals(""); m_pnlSampleName.setVisible(bSample); m_lblLogin.setForeground(getBackground()); m_lblLogin.setVisible(false); m_passwordField.setText(""); m_passwordField.setCaretPosition(0); } catch (Exception e) { Messages.writeStackTrace(e); } setBounds(frameBounds); ExpPanel exp = Util.getActiveView(); if (exp != null) exp.waitLogin(true); } writePersistence(); setVisible(bShow); }
/** * This method is activated on the Keystrokes we are listening to in this implementation. Here it * listens for Copy and Paste ActionCommands. Selections comprising non-adjacent cells result in * invalid selection and then copy action cannot be performed. Paste is done by aligning the upper * left corner of the selection with the 1st element in the current selection of the JTable. */ public void actionPerformed(ActionEvent e) { if (e.getActionCommand().compareTo("Copy") == 0) { StringBuffer sbf = new StringBuffer(); // Check to ensure we have selected only a contiguous block of // cells int numcols = jTable1.getSelectedColumnCount(); int numrows = jTable1.getSelectedRowCount(); int[] rowsselected = jTable1.getSelectedRows(); int[] colsselected = jTable1.getSelectedColumns(); if (!((numrows - 1 == rowsselected[rowsselected.length - 1] - rowsselected[0] && numrows == rowsselected.length) && (numcols - 1 == colsselected[colsselected.length - 1] - colsselected[0] && numcols == colsselected.length))) { JOptionPane.showMessageDialog( null, "Invalid Copy Selection", "Invalid Copy Selection", JOptionPane.ERROR_MESSAGE); return; } for (int i = 0; i < numrows; i++) { for (int j = 0; j < numcols; j++) { sbf.append(jTable1.getValueAt(rowsselected[i], colsselected[j])); if (j < numcols - 1) sbf.append("\t"); } sbf.append("\n"); } stsel = new StringSelection(sbf.toString()); system = Toolkit.getDefaultToolkit().getSystemClipboard(); system.setContents(stsel, stsel); } if (e.getActionCommand().compareTo("Paste") == 0) { System.out.println("Trying to Paste"); int startRow = (jTable1.getSelectedRows())[0]; int startCol = (jTable1.getSelectedColumns())[0]; try { String trstring = (String) (system.getContents(this).getTransferData(DataFlavor.stringFlavor)); System.out.println("String is:" + trstring); StringTokenizer st1 = new StringTokenizer(trstring, "\n"); for (int i = 0; st1.hasMoreTokens(); i++) { rowstring = st1.nextToken(); StringTokenizer st2 = new StringTokenizer(rowstring, "\t"); for (int j = 0; st2.hasMoreTokens(); j++) { value = (String) st2.nextToken(); if (startRow + i < jTable1.getRowCount() && startCol + j < jTable1.getColumnCount()) jTable1.setValueAt(value, startRow + i, startCol + j); System.out.println( "Putting " + value + "at row = " + startRow + i + "column = " + startCol + j); } } } catch (Exception ex) { ex.printStackTrace(); } } }
private void commit() { String serverName = (String) server.getSelectedItem(); if (serverName == null || serverName.equals("")) { vlog.error("No server name specified!"); if (VncViewer.nViewers == 1) if (cc.viewer instanceof VncViewer) { ((VncViewer) cc.viewer).exit(1); } ret = false; endDialog(); } // set params if (opts.via != null && opts.via.indexOf(':') >= 0) { opts.serverName = serverName; } else { opts.serverName = Hostname.getHost(serverName); opts.port = Hostname.getPort(serverName); } // Update the history list String valueStr = UserPreferences.get("ServerDialog", "history"); String t = (valueStr == null) ? "" : valueStr; StringTokenizer st = new StringTokenizer(t, ","); StringBuffer sb = new StringBuffer().append((String) server.getSelectedItem()); while (st.hasMoreTokens()) { String str = st.nextToken(); if (!str.equals((String) server.getSelectedItem()) && !str.equals("")) { sb.append(','); sb.append(str); } } UserPreferences.set("ServerDialog", "history", sb.toString()); UserPreferences.save("ServerDialog"); }
static String replaceUrlSymbol(JopSession session, String url) { Gdh gdh = session.getGdh(); CdhrObjid webConfig = gdh.getClassList(Pwrb.cClass_WebBrowserConfig); if (webConfig.evenSts()) return url; CdhrString webName = gdh.objidToName(webConfig.objid, Cdh.mName_volumeStrict); if (webConfig.evenSts()) return url; for (int i = 0; i < 10; i++) { String attr = webName.str + ".URL_Symbols[" + i + "]"; CdhrString attrValue = gdh.getObjectInfoString(attr); if (attrValue.evenSts()) return url; if (attrValue.str.equals("")) continue; StringTokenizer token = new StringTokenizer(attrValue.str); String symbol = "$" + token.nextToken(); if (!token.hasMoreTokens()) continue; String value = token.nextToken(); int idx = url.lastIndexOf(symbol); while (idx != -1) { url = url.substring(0, idx) + value + url.substring(idx + symbol.length()); idx = url.lastIndexOf(symbol); } } return url; }
/** Update state from Infostat. */ public void updateStatus(String msg) { // Messages.postDebug("VLcStatusChart.updateStatus(" + msg + ")");/*CMP*/ if (msg == null) { return; } StringTokenizer tok = new StringTokenizer(msg); if (tok.hasMoreTokens()) { String key = tok.nextToken(); String val = ""; if (tok.hasMoreTokens()) { val = tok.nextToken("").trim(); // Get remainder of msg } if (key.equals(statkey)) { if (val != null && !val.equals("-")) { valstr = val; setState(state); } /*System.out.println("Chart: statkey=" + statkey + ", val=" + val);/*CMP*/ } if (key.equals(statpar)) { if (val != null && !val.equals("-")) { /*System.out.println("Chart statpar=" + statpar + ", value=" + value);/*CMP*/ setState(state); } } if (key.equals(statset)) { if (val != null && !val.equals("-")) { setval = val; try { String num = val.substring(0, val.indexOf(' ')); setStatusValue(Double.parseDouble(num)); } catch (NumberFormatException nfe) { Messages.postDebug("VLcStatusChart.updateStatus(): " + "Non-numeric value: " + msg); } catch (StringIndexOutOfBoundsException sioobe) { setStatusValue(0); // No value found } /*System.out.println("Chart statset=" + statset + ", setval=" + setval);/*CMP*/ setState(state); } } } repaint(); }
public Object stringToValue(String text) throws ParseException { StringTokenizer tokenizer = new StringTokenizer(text, "."); byte[] a = new byte[4]; for (int i = 0; i < 4; i++) { int b = 0; if (!tokenizer.hasMoreTokens()) throw new ParseException("Too few bytes", 0); try { b = Integer.parseInt(tokenizer.nextToken()); } catch (NumberFormatException e) { throw new ParseException("Not an integer", 0); } if (b < 0 || b >= 256) throw new ParseException("Byte out of range", 0); a[i] = (byte) b; } if (tokenizer.hasMoreTokens()) throw new ParseException("Too many bytes", 0); return a; }
// createericlist with a String signature is used to process a String // containing a sequence of GAIGS structures // createericlist creates the list of graphics primitives for these snapshot(s). // After creating these lists, that are then appended to l, the list of snapshots, // Also must return the number of snapshots loaded from the string public /*synchronized*/ int createericlist(String structString) { int numsnaps = 0; if (debug) System.out.println("In create eric " + structString); StringTokenizer st = new StringTokenizer(structString, "\r\n"); while (st.hasMoreTokens()) { numsnaps++; // ?? String tempString; LinkedList tempList = new LinkedList(); StructureType strct; tempString = st.nextToken(); try { boolean headers = true; while (headers) { headers = false; if (tempString.toUpperCase().startsWith("VIEW")) { tempString = HandleViewParams(tempString, tempList, st); headers = true; } if (tempString.toUpperCase().startsWith("FIBQUESTION ") || tempString.toUpperCase().startsWith("MCQUESTION ") || tempString.toUpperCase().startsWith("MSQUESTION ") || tempString.toUpperCase().startsWith("TFQUESTION ")) { tempString = add_a_question(tempString, st); headers = true; } } if (tempString.toUpperCase().equals("STARTQUESTIONS")) { numsnaps--; // questions don't count as snapshots readQuestions(st); break; } // After returning from HandleViewParams, tempString should now contain // the line with the structure type and possible additional text height info StringTokenizer structLine = new StringTokenizer(tempString, " \t"); String structType = structLine.nextToken(); if (debug) System.out.println("About to assign structure" + structType); strct = assignStructureType(structType); strct.loadTextHeights(structLine, tempList, this); strct.loadLinesPerNodeInfo(st, tempList, this); strct.loadTitle(st, tempList, this); strct.loadStructure(st, tempList, this); strct.calcDimsAndStartPts(tempList, this); strct.drawTitle(tempList, this); strct.drawStructure(tempList, this); } catch (VisualizerLoadException e) { System.out.println(e.toString()); } // // You've just created a snapshot. Need to insure that "**" is appended // // to the URLList for this snapshot IF no VIEW ALGO line was parsed in the // // string for the snapshot. This could probably best be done in the // // HandleViewParams method list_of_snapshots.append(tempList); Snaps++; } return (numsnaps); } // createericlist(string)
private String subString(String s, String m, String d) { String r = ""; StringTokenizer tok = new StringTokenizer(s, " \t\':+-*/\"/()=,\0", true); while (tok.hasMoreTokens()) { String t = tok.nextToken(); if (t.equals(m)) r += d; else r += t; } return r; }
protected void createButtons(JPanel panel) { panel.add(new Filler(24, 20)); JComboBox drawingChoice = new JComboBox(); drawingChoice.addItem(fgUntitled); String param = getParameter("DRAWINGS"); if (param == null) { param = ""; } StringTokenizer st = new StringTokenizer(param); while (st.hasMoreTokens()) { drawingChoice.addItem(st.nextToken()); } if (drawingChoice.getItemCount() > 1) { panel.add(drawingChoice); } else { panel.add(new JLabel(fgUntitled)); } drawingChoice.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { loadDrawing((String) e.getItem()); } } }); panel.add(new Filler(6, 20)); JButton button; button = new CommandButton(new DeleteCommand("Delete", this)); panel.add(button); button = new CommandButton(new DuplicateCommand("Duplicate", this)); panel.add(button); button = new CommandButton(new GroupCommand("Group", this)); panel.add(button); button = new CommandButton(new UngroupCommand("Ungroup", this)); panel.add(button); button = new JButton("Help"); button.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { showHelp(); } }); panel.add(button); fUpdateButton = new JButton("Simple Update"); fUpdateButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { if (fSimpleUpdate) { setBufferedDisplayUpdate(); } else { setSimpleDisplayUpdate(); } } }); }
public final String readCommand(byte[] b) throws IOException, InterruptedException, MessagingNetworkException { InputStream is = getInputStream(); synchronized (is) { long abortTime = System.currentTimeMillis() + 1000 * MSNMessagingNetwork.REQPARAM_SOCKET_TIMEOUT_SECONDS; int ofs = 0; boolean d = false; for (; ; ) { if (Thread.currentThread().isInterrupted()) throw new InterruptedIOException(); int by = is.read(); if (by == -1) throw new IOException("unexpected EOF"); if (by == 10 && d) break; d = (by == 13); if (ofs < b.length) { b[ofs++] = (byte) by; } if (System.currentTimeMillis() > abortTime) throw new IOException("connection timed out"); /* if (len >= buffer.length) { ... return ...; } int pos = findCRLF(); if (pos != -1) break; fill(is, abortTime); */ } if (b[ofs - 1] == 13) --ofs; String line = new String(b, 0, ofs, "ASCII"); if (StringUtil.startsWith(line, "MSG")) { StringTokenizer st = new StringTokenizer(line); String len_s = null; while (st.hasMoreTokens()) { len_s = st.nextToken(); } if (len_s == null) throw new AssertException("len_s is null"); int len; try { len = Integer.parseInt(len_s); } catch (NumberFormatException ex) { ServerConnection.throwProtocolViolated("MSG length must be int"); len = 0; } String msg = readMSG(len); line = line + "\r\n" + msg; } if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug("S: " + line); return line; } }
/** * Set the helpfile string from the given "title". * The "title" is a series of tokens of the form: * <pre> * autodir h1freq traymax [help:path] [nextloc:loc] * <pre> * @param title The "title" passed in. * @return The path to the help file, or null. */ protected String getHelpFile(String title) { StringTokenizer tok = new QuotedStringTokenizer(title); String path = null; while (tok.hasMoreTokens()) { String strValue = tok.nextToken(); if (strValue.startsWith("help:")) { path = strValue.substring(5); } } return path; }
/** * Gets the keyword telling where to place the login frame. * The "title" is a series of tokens of the form: * <pre> * autodir h1freq traymax [help:path] [nextloc:loc] [frameBounds:keyword] * <pre> * @param title The "title" passed in. * @return The frame location keyword. */ private String getFrameBounds(String title) { String bounds = null; StringTokenizer tok = new QuotedStringTokenizer(title); while (tok.hasMoreTokens()) { String strValue = tok.nextToken(); if (strValue.startsWith("frameBounds:")) { bounds = strValue.substring(12); } } return bounds; }
/** * Get the "next sample" string from the given "title". * The "title" is a series of tokens of the form: * <pre> * autodir h1freq traymax [help:path] [nextloc:loc] [frameBounds:keyword] * <pre> * @param title The "title" passed in. * @return The next available sample location, or null. */ protected String getSampleName(String title) { String name = null; StringTokenizer tok = new QuotedStringTokenizer(title); while (tok.hasMoreTokens()) { String strValue = tok.nextToken(); if (strValue.startsWith("nextloc:")) { name = strValue.substring(8); } } return name; }
/** * List results by date * * @param reslist result list * @param ldisp */ private void listByDateRun(ResultList reslist, boolean ldisp) { StringTokenizer tokenizer = new StringTokenizer((String) reslist.get("list"), "\n"); Vector vdata = new Vector(); while (tokenizer.hasMoreTokens()) { String data = convertToPretty(tokenizer.nextToken()); if (datasets.contains(data) || ldisp) vdata.add(data); } datasets.removeAllElements(); Enumeration en = vdata.elements(); while (en.hasMoreElements()) datasets.addElement(en.nextElement()); }
String[] getContactList() { java.util.List cl = new java.util.LinkedList(); StringTokenizer st = new StringTokenizer(contactList.getText()); StringBuffer sb = new StringBuffer(); StringBuffer dbg = new StringBuffer("test applet contactlist: "); while (st.hasMoreTokens()) { String loginId = st.nextToken().trim(); if (loginId.length() == 0) continue; dbg.append("'" + loginId + "' "); cl.add(loginId); sb.append(loginId).append('\n'); } CAT.info(dbg.toString()); contactList.setText(sb.toString()); return (String[]) cl.toArray(new String[cl.size()]); }
MyNode findNode(String fqn) { MyNode curr, n; StringTokenizer tok; String child_name; if (fqn == null) return null; curr = this; tok = new StringTokenizer(fqn, ReplicatedTreeView.SEP); while (tok.hasMoreTokens()) { child_name = tok.nextToken(); n = curr.findChild(child_name); if (n == null) return null; curr = n; } return curr; }
protected void loadJarFiles(AppletClassLoader loader) throws IOException, InterruptedException { // Load the archives if present. // REMIND - this probably should be done in a separate thread, // or at least the additional archives (epll). String jarFiles = getJarFiles(); if (jarFiles != null) { StringTokenizer st = new StringTokenizer(jarFiles, ",", false); while (st.hasMoreTokens()) { String tok = st.nextToken().trim(); try { loader.addJar(tok); } catch (IllegalArgumentException e) { // bad archive name continue; } } } }
AboutPanel() { setFont(UIManager.getFont("Label.font")); fm = getFontMetrics(getFont()); setForeground(new Color(96, 96, 96)); image = new ImageIcon(getClass().getResource("/org/gjt/sp/jedit/icons/about.png")); setBorder(new MatteBorder(1, 1, 1, 1, Color.gray)); text = new Vector(50); StringTokenizer st = new StringTokenizer(jEdit.getProperty("about.text"), "\n"); while (st.hasMoreTokens()) { String line = st.nextToken(); text.addElement(line); maxWidth = Math.max(maxWidth, fm.stringWidth(line) + 10); } scrollPosition = -250; thread = new AnimationThread(); }
/** * Adds a new node to the view. Intermediary nodes will be created if they don't yet exist. * Returns the first node that was created or null if node already existed */ public MyNode add(String fqn) { MyNode curr, n, ret = null; StringTokenizer tok; String child_name; if (fqn == null) return null; curr = this; tok = new StringTokenizer(fqn, ReplicatedTreeView.SEP); while (tok.hasMoreTokens()) { child_name = tok.nextToken(); n = curr.findChild(child_name); if (n == null) { n = new MyNode(child_name); if (ret == null) ret = n; curr.add(n); } curr = n; } return ret; }
/** * Creates the components based on the information in each line. * * @param sTokLine the tokens in a line. * <p>The file is of the following format: auditDir:/vnmr/part11/auditTrails:system * part11Dir:/vnmr/part11/data:system part11Dir:/vnmr/part11/data:system * file:standard:cmdHistory:yes file:standard:fid:yes file:standard:procpar:yes * file:standard:conpar:yes * <p>Based on this format, the line is parsed as follows: 1) if the line starts with the * keyword 'file', then it skips over the first two tokens in the line which are 'file' and * 'standard', and the third token in the line is the label of the item, and the fourth token * in the line corresponds to the value of the checkbox. 2) if the line doesnot start with the * keyword 'file', then the second and the fourth tokens are skipped, first token in the line * is the label of the item, and the third token is the value of the textfield. */ protected void createJComps(StringTokenizer sTokLine) { boolean bFile = false; boolean bMode = false; JComponent compValue = null; boolean bDir = false; for (int i = 0; sTokLine.hasMoreTokens(); i++) { String strTok = sTokLine.nextToken(); if (i == 0) { bFile = strTok.equalsIgnoreCase("file") ? true : false; bMode = strTok.equalsIgnoreCase("dataType") ? true : false; bDir = false; if (strTok.equalsIgnoreCase("dir")) bDir = true; // Case 2, create a label for the first token. if (!bFile && !bDir) createLabel(strTok, m_pnlDisplay); } else { // Case 1 => file:standard:conpar:yes if (bFile) { // skip over the first tokenwhich is the keyword 'file' if (i == 1) continue; // else check for checkbox value. else if (strTok.equalsIgnoreCase("yes") || strTok.equalsIgnoreCase("no")) compValue = createChkBox(strTok, m_pnlDisplay); // else create a label. else createLabel(strTok, m_pnlDisplay); } // Case 2 => part11Dir:/vnmr/part11/data:system Or dataType:Non-FDA else if (!bDir) { if (i == 1) { // create a combobox if (bMode) compValue = createCombo(strTok, m_pnlDisplay); // create a textfield and sets it's value. else compValue = createTxf(strTok, m_pnlDisplay); } } } } m_aListComp.add(compValue); }
private /*synchronized*/ void readQuestions(StringTokenizer st) throws VisualizerLoadException { String tmpStr = "STARTQUESTIONS\n"; // When CG's QuestionFactory parses from a string, it looks for // a line with STARTQUESTIONS -- hence we add it artificially here try { // Build the string for the QuestionFactory while (st.hasMoreTokens()) { tmpStr += st.nextToken() + "\n"; } } catch (Exception e) { e.printStackTrace(); throw new VisualizerLoadException("Ooof! bad question format"); } try { // System.out.println(tmpStr); // Problem -- must make this be line oriented GaigsAV.questionCollection = QuestionFactory.parseScript(tmpStr); } catch (QuestionParseException e) { e.printStackTrace(); System.out.println("Error parsing questions."); throw new VisualizerLoadException("Ooof! bad question format"); // throw new IOException(); } } // readQuestions(st)
/** * Saves all configuration settings when the "Save" button is pressed. * * @param e the <tt>ActionEvent</tt> that notified us of the button action */ public void actionPerformed(ActionEvent e) { JButton button = (JButton) e.getSource(); if (button.equals(saveButton)) { Iterator<ChatRoomConfigurationFormField> configurationSet = configForm.getConfigurationSet(); while (configurationSet.hasNext()) { ChatRoomConfigurationFormField formField = configurationSet.next(); // If the field is of type fixed the user could not change it, // so we skip it. if (formField.getType().equals(ChatRoomConfigurationFormField.TYPE_TEXT_FIXED)) continue; JComponent c = uiFieldsTable.get(formField.getName()); if (c instanceof JTextComponent) { String newValue = ((JTextComponent) c).getText(); if (formField.getType().equals(ChatRoomConfigurationFormField.TYPE_ID_MULTI)) { // extract values StringTokenizer idTokens = new StringTokenizer(newValue, System.getProperty("line.separator")); while (idTokens.hasMoreTokens()) { formField.addValue(idTokens.nextToken()); } } else formField.addValue(newValue); } else if (c instanceof AbstractButton) { boolean isSelected = ((AbstractButton) c).isSelected(); formField.addValue(isSelected); } else if (c instanceof JComboBox) { Object selectedObject = ((JComboBox) c).getSelectedItem(); formField.addValue(selectedObject); } else if (c instanceof JPanel) { Component[] components = c.getComponents(); for (Component comp : components) { if (!(comp instanceof JCheckBox)) continue; JCheckBox checkBox = (JCheckBox) comp; formField.addValue(checkBox.getText()); } } } new Thread() { @Override public void run() { try { configForm.submit(); } catch (Exception e) { new ErrorDialog( ChatRoomConfigurationWindow.this, GuiActivator.getResources().getI18NString("service.gui.ERROR"), GuiActivator.getResources() .getI18NString("service.gui.CHAT_ROOM_CONFIGURATION_SUBMIT_FAILED"), e) .showDialog(); } } }.start(); } this.dispose(); }
/** * Save the data to the file. Read the data from the file, and copy everything to the * stringbuffer. The lines in the file are of the form: * auditDir:system:/vnmr/part11/auditTrails:system file:standard:text:yes Based on these formats, * get the value of either the directory or the checkbox from the corresponding components, and * replace that value in the stringbuffer. */ protected void saveData() { BufferedReader reader = WFileUtil.openReadFile(m_strPath); String strLine = null; StringBuffer sbData = new StringBuffer(); if (reader == null) return; int nLineInd = 0; try { while ((strLine = reader.readLine()) != null) { // if the line starts with a comment from sccs, add '#' to it, // to make it a comment if (strLine.startsWith("%") || strLine.startsWith("@")) strLine = "# " + strLine; if (strLine.startsWith("#")) { sbData.append(strLine + "\n"); continue; } StringTokenizer sTok = new StringTokenizer(strLine, File.pathSeparator); boolean bFile = false; boolean bLineEnd = false; boolean bDir = false; for (int i = 0; sTok.hasMoreTokens(); i++) { String strValue = sTok.nextToken(); if (i == 0) { bFile = strValue.equalsIgnoreCase("file") ? true : false; bDir = false; if (strValue.equalsIgnoreCase("dir")) bDir = true; } else { // Case => file:standard:procpar:yes // skip over 'standard', 'procpar', // and get the value 'yes' or 'no' from the checkbox if (bFile) { if (i == 3) { String strNewValue = getValue(nLineInd); if (strNewValue != null) strValue = strNewValue; bLineEnd = true; } else bLineEnd = false; } else if (bDir) { bLineEnd = false; if (i == 3) bLineEnd = true; } // Case => part11Dir:/vnmr/part11/data 0r // Case => dataType:FDA // skip over 'part11Dir' // and get the value of the directory from the textfield, // or from the combobox else { if (i == 1) { String strNewValue = getValue(nLineInd); if (strNewValue != null) strValue = strNewValue; bLineEnd = true; } else bLineEnd = false; } } // copy the value to the stringbuffer sbData.append(strValue); if (!bLineEnd) sbData.append(File.pathSeparator); } nLineInd++; sbData.append("\n"); } // write the data to the file reader.close(); BufferedWriter writer = WFileUtil.openWriteFile(m_strPath); WFileUtil.writeAndClose(writer, sbData); m_objTimer = new javax.swing.Timer( 200, new ActionListener() { public void actionPerformed(ActionEvent e) { VItemAreaIF.firePropertyChng(Global.PART11_CONFIG_FILE, "all", ""); m_objTimer.stop(); } }); m_objTimer.start(); } catch (Exception e) { Messages.writeStackTrace(e); // e.printStackTrace(); Messages.postDebug(e.toString()); } }
public void propertyChange(PropertyChangeEvent e) { String strPropName = e.getPropertyName(); if (strPropName.equals(WGlobal.USER_CHANGE)) { String strName = (String) e.getNewValue(); String strAccount = null; VDetailArea objDetailArea = m_adminIF.getDetailArea1(); if (objDetailArea != null) strAccount = objDetailArea.getItemValue("itype"); if (strAccount == null) strAccount = ""; strAccount = strAccount.trim(); String strDir = getPathDir() + strName; if (this instanceof DisplayTemplate) { if (strAccount.equals(Global.IMGIF)) strDir = strDir + ".img"; else if (strAccount.equals(Global.WALKUPIF)) strDir = strDir + ".walkup"; } String strPath = FileUtil.openPath(strDir); boolean bDefaultFile = false; if (strPath == null) { strPath = FileUtil.openPath(getDefaultFile(strAccount)); bDefaultFile = true; } clear(this); layoutUIComponents(strPath, bDefaultFile); } else if (strPropName.indexOf(WGlobal.IMGDIR) >= 0) { String strName = (String) e.getNewValue(); StringTokenizer strTokenizer = new StringTokenizer(strPropName); String strInterface = null; boolean bDefaultFile = false; if (strTokenizer.hasMoreTokens()) strTokenizer.nextToken(); if (strTokenizer.hasMoreTokens()) strInterface = strTokenizer.nextToken(); if (strInterface == null) strInterface = ""; strInterface = strInterface.trim(); String strDir = getPathDir() + strName; if (this instanceof DisplayTemplate) { if (strInterface.equals(WGlobal.IMGDIR)) strDir = strDir + ".img"; else if (strInterface.equals(WGlobal.WALKUPDIR)) strDir = strDir + ".walkup"; } String strPath = FileUtil.openPath(strDir); if (strPath == null) { String strAccount = Global.WALKUPIF; if (strInterface.equals(WGlobal.IMGDIR)) strAccount = Global.IMGIF; else if (strInterface.equals(WGlobal.WALKUPDIR)) strAccount = Global.WALKUPIF; strPath = FileUtil.openPath(getDefaultFile(strAccount)); bDefaultFile = true; } clear(this); layoutUIComponents(strPath, bDefaultFile); } else if (strPropName.indexOf(WGlobal.SAVEUSER_NOERROR) >= 0) { Object objValue = e.getNewValue(); String strName = ""; if (objValue instanceof String) strName = (String) objValue; else if (objValue instanceof WItem) strName = ((WItem) objValue).getText(); VDetailArea objDetail = m_adminIF.getDetailArea1(); String strAccount = null; if (objDetail != null) strAccount = objDetail.getItemValue("itype"); if (strAccount == null) strAccount = ""; strAccount = strAccount.trim(); String strDir = getPathDir() + strName; if (this instanceof DisplayTemplate) { if (strAccount.equals(Global.IMGIF)) strDir = strDir + ".img"; else if (strAccount.equals(Global.WALKUPIF)) strDir = strDir + ".walkup"; } TextFieldValues objTxf = getTxfValues(); writeFile(strName, strDir, objTxf.getTxfLabel(), objTxf.getTxfValue()); } else if (strPropName.indexOf(WGlobal.DELETE_USER) >= 0) { clear(this); String strPath = FileUtil.openPath(getDefaultFile("")); layoutUIComponents(strPath, true); } }
/** Reads the file, and sets the label and the values in the hashmap. */ protected void setHM(String strPath, HashMap hmPnl) { BufferedReader reader = WFileUtil.openReadFile(strPath); boolean bFileEmpty = true; boolean bPart11Pnl = isPart11Pnl(); boolean bDefaultFile = isDefaultFile(); // if the file is empty, then create an empty set of textfields. if (reader == null) { // displayNewTxf("",""); return; } String strLine = null; StringTokenizer strTok; try { // read the file, and create a new set of textfields, // with the values from the file. while ((strLine = reader.readLine()) != null) { String strLabel = ""; String strValue = ""; bFileEmpty = false; if (strLine.startsWith("#") || strLine.startsWith("@") || strLine.startsWith("%") || strLine.startsWith("\"@")) continue; if (strLine.startsWith("\"")) strTok = new StringTokenizer(strLine, "\""); else strTok = new StringTokenizer(strLine, File.pathSeparator + ",\n"); if (!strTok.hasMoreTokens()) continue; strLabel = strTok.nextToken(); // the format for the part11 Default file is a little different // only parse out the part11Dir, and don't display other defaults if (bPart11Pnl && bDefaultFile) { if (!strLabel.equalsIgnoreCase("part11Dir")) continue; } if (strTok.hasMoreTokens()) { while (strTok.hasMoreTokens()) { strValue += strTok.nextToken(); if (strTok.hasMoreTokens()) strValue += " "; } } // append "/data/$name" to part11Dir if (bPart11Pnl && bDefaultFile && strLabel.equalsIgnoreCase("part11Dir")) { StringBuffer sbDir = new StringBuffer(strValue); if (sbDir.lastIndexOf(File.separator) < sbDir.length() - 1) sbDir.append(File.separator); sbDir.append("data" + File.separator + "$"); sbDir.append(WGlobal.NAME); strValue = sbDir.toString(); } // displayNewTxf(strLabel, strValue); if (strLabel != null && strLabel.trim().length() > 0) hmPnl.put(strLabel, strValue); } reader.close(); } catch (Exception e) { Messages.writeStackTrace(e); // e.printStackTrace(); Messages.postDebug(e.toString()); } }
public static void main(String argv[]) { System.setErr(System.out); try { UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); } catch (Exception e) { try { UIManager.setLookAndFeel("javax.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception e1) { try { UIManager.setLookAndFeel("javax.swing.plaf.motif.MotifLookAndFeel"); } catch (Exception e2) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e3) { } } } } UIManager.put("TextField.background", new Color(255, 255, 255)); String strCreateTables = null, strRunTests = null, strCleanUp = null, strCreateProc = null, strCreateResult = null, strDropResult = null, strLogLevel = null; String strTPCCRun = null, strTPCCLoad = null; BenchMain.bench = new BenchMain(); bench.m_bInApplet = false; if (argv.length > 0) for (int nArg = 0; nArg < argv.length; nArg++) { if (argv[nArg].toUpperCase().startsWith("URL=")) bench.m_strURL = argv[nArg].substring(argv[nArg].indexOf("=") + 1); else if (argv[nArg].toUpperCase().startsWith("USER="******"=") + 1); else if (argv[nArg].toUpperCase().startsWith("PASSWORD="******"=") + 1); else if (argv[nArg].toUpperCase().startsWith("DRIVER=")) bench.m_strDriver = argv[nArg].substring(argv[nArg].indexOf("=") + 1); else if (argv[nArg].toUpperCase().startsWith("DRIVERTYPE=")) bench.m_nDriverType = Integer.valueOf(argv[nArg].substring(argv[nArg].indexOf("=") + 1)).intValue(); else if (argv[nArg].toUpperCase().startsWith("CREATETABLES=")) strCreateTables = argv[nArg].substring(argv[nArg].indexOf("=") + 1); else if (argv[nArg].toUpperCase().startsWith("RUNTEST=")) strRunTests = argv[nArg].substring(argv[nArg].indexOf("=") + 1); else if (argv[nArg].toUpperCase().startsWith("CLEANUP")) strCleanUp = argv[nArg]; else if (argv[nArg].toUpperCase().startsWith("CREATEPROC")) strCreateProc = argv[nArg]; else if (argv[nArg].toUpperCase().startsWith("CREATERESULT")) strCreateResult = argv[nArg]; else if (argv[nArg].toUpperCase().startsWith("DROPRESULT")) strDropResult = argv[nArg]; else if (argv[nArg].toUpperCase().startsWith("LOGLEVEL=")) strLogLevel = argv[nArg].substring(argv[nArg].indexOf("=") + 1); else if (argv[nArg].toUpperCase().startsWith("TPCCRUN=")) strTPCCRun = argv[nArg].substring(argv[nArg].indexOf("=") + 1); else if (argv[nArg].toUpperCase().startsWith("TPCCLOAD=")) strTPCCLoad = argv[nArg].substring(argv[nArg].indexOf("=") + 1); } bench.m_bInApplet = false; try { if (strCreateTables != null || strRunTests != null || strCleanUp != null || strCreateProc != null || strCreateResult != null || strDropResult != null || strTPCCRun != null || strTPCCLoad != null) { // batch TextProgress progress = new TextProgress(); Bench.BenchPanel pane = new Bench.BenchPanel( bench.m_strDriver, bench.m_strURL, bench.m_strUserName, bench.m_strPassword, bench.m_nDriverType); Bench.Logger new_log = new Bench.Logger() { int m_nLogLevel = 0; public synchronized void log(String strMessage, int nLevel) { if (nLevel <= m_nLogLevel) System.out.print(strMessage); } public synchronized void taskDone() { notify(); } public synchronized void waitOn() throws InterruptedException { wait(); } public synchronized void setLogLevel(int nNewLogLevel) { m_nLogLevel = nNewLogLevel; } public synchronized int getLogLevel() { return m_nLogLevel; } }; if (strLogLevel != null) new_log.setLogLevel(Integer.valueOf(strLogLevel).intValue()); pane.setLogger(new_log); if (strCreateTables != null) { StringTokenizer createTokens = new StringTokenizer(strCreateTables, ",;/"); int nBranchCount = 10, nTellerCount = 100, nAccountCount = 1000; if (createTokens.hasMoreTokens()) nBranchCount = Integer.valueOf(createTokens.nextToken()).intValue(); if (createTokens.hasMoreTokens()) nTellerCount = Integer.valueOf(createTokens.nextToken()).intValue(); if (createTokens.hasMoreTokens()) nAccountCount = Integer.valueOf(createTokens.nextToken()).intValue(); // FIXME pane.setMaxTableLimits(nBranchCount,nTellerCount,nAccountCount); // FIXME pane.doCreateTables(true,true,true,true,true,true,true,true); } // FIXME if(strCreateProc != null) // pane.doLoadProcedures(pane.pool.getConnection(0)); if (strRunTests != null) { int nNumThreads = 1, nNumRuns = 100, nTestType = 1, nWaitMinutes = -1; boolean bTrans = false, bQuery = true; StringTokenizer runTokens = new StringTokenizer(strRunTests, ",;/"); if (runTokens.hasMoreTokens()) nNumThreads = Integer.valueOf(runTokens.nextToken()).intValue(); if (runTokens.hasMoreTokens()) nNumRuns = Integer.valueOf(runTokens.nextToken()).intValue(); if (runTokens.hasMoreTokens()) bTrans = runTokens.nextToken().toUpperCase().equals("TRUE"); if (runTokens.hasMoreTokens()) bQuery = runTokens.nextToken().toUpperCase().equals("TRUE"); if (runTokens.hasMoreTokens()) nTestType = Integer.valueOf(runTokens.nextToken()).intValue(); if (runTokens.hasMoreTokens()) nWaitMinutes = Integer.valueOf(runTokens.nextToken()).intValue(); // FIXME pane.doRunTests(nNumThreads,nNumRuns,nWaitMinutes,nTestType == // 1,nTestType == 2,nTestType == 3,bTrans,bQuery); } // FIXME if(strCleanUp != null) pane.doCleanUp(pane.pool.getConnection(0), // true,true,true,true); if (strDropResult != null) pane.doDropResult(); // FIXME if(strCreateResult != null) pane.doCreateResult(); // ========TPCCTest // if(strTPCCLoad != null) { // int n_ware = 1; // StringTokenizer runTokens = new StringTokenizer(strTPCCLoad,",;/"); // // System.out.println("tpcload = " + strTPCCLoad); // if(runTokens.hasMoreTokens()) { // n_ware = Integer.valueOf(runTokens.nextToken()).intValue(); // // System.out.println("N_ware = " + n_ware); // } // pane.doTpccLoadData(pane.pool.getConnection(0), // n_ware,Bench.TPCCBench.DIST_PER_WARE,Bench.TPCCBench.CUST_PER_DIST,Bench.TPCCBench.MAXITEMS,Bench.TPCCBench.ORD_PER_DIST); // } // if(strTPCCRun != null) { // int n_rounds = 1, local_w_id = 1, n_ware = 1, n_threads = 1; // StringTokenizer runTokens = new StringTokenizer(strTPCCRun,",;/"); // if(runTokens.hasMoreTokens()) // n_rounds = Integer.valueOf(runTokens.nextToken()).intValue(); // if(runTokens.hasMoreTokens()) // local_w_id = Integer.valueOf(runTokens.nextToken()).intValue(); // if(runTokens.hasMoreTokens()) // n_ware = Integer.valueOf(runTokens.nextToken()).intValue(); // if(runTokens.hasMoreTokens()) // n_threads = Integer.valueOf(runTokens.nextToken()).intValue(); // pane.doTpccRun(n_threads, n_rounds,local_w_id,n_ware); // } pane.closeConnection(true); System.exit(0); } } catch (Exception e) { System.out.println(e.getMessage()); } // go interactive JFrame frame = new JFrame("JBench - Generic JDBC Benchmark Utility"); WindowListener l = new WindowAdapter() { public void windowClosing(WindowEvent e) { BenchMain.bench.m_pane.closeConnection(true); System.exit(0); } }; frame.addWindowListener(l); bench.m_parentFrame = frame; bench.init(); frame.getContentPane().add(bench); frame.setSize(675, 400); frame.validate(); frame.setVisible(true); }
protected void _init() { setLayout(new BorderLayout()); JPanel panel = new JPanel(new GridLayout(2, 1)); showToolbar = new JCheckBox(jEdit.getProperty("options.toolbar.showToolbar")); showToolbar.setSelected(jEdit.getBooleanProperty("view.showToolbar")); panel.add(showToolbar); panel.add(new JLabel(jEdit.getProperty("options.toolbar.caption"))); add(BorderLayout.NORTH, panel); String toolbar = jEdit.getProperty("view.toolbar"); StringTokenizer st = new StringTokenizer(toolbar); listModel = new DefaultListModel(); while (st.hasMoreTokens()) { String actionName = (String) st.nextToken(); if (actionName.equals("-")) listModel.addElement(new ToolBarOptionPane.Button("-", null, null, "-")); else { EditAction action = jEdit.getAction(actionName); if (action == null) continue; String label = action.getLabel(); if (label == null) continue; Icon icon; String iconName; if (actionName.equals("-")) { iconName = null; icon = null; } else { iconName = jEdit.getProperty(actionName + ".icon"); if (iconName == null) icon = GUIUtilities.loadIcon("BrokenImage.png"); else { icon = GUIUtilities.loadIcon(iconName); if (icon == null) icon = GUIUtilities.loadIcon("BrokenImage.png"); } } listModel.addElement(new Button(actionName, iconName, icon, label)); } } list = new JList(listModel); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.addListSelectionListener(new ListHandler()); list.setCellRenderer(new ButtonCellRenderer()); add(BorderLayout.CENTER, new JScrollPane(list)); JPanel buttons = new JPanel(); buttons.setBorder(new EmptyBorder(3, 0, 0, 0)); buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS)); ActionHandler actionHandler = new ActionHandler(); add = new RolloverButton(GUIUtilities.loadIcon("Plus.png")); add.setToolTipText(jEdit.getProperty("options.toolbar.add")); add.addActionListener(actionHandler); buttons.add(add); buttons.add(Box.createHorizontalStrut(6)); remove = new RolloverButton(GUIUtilities.loadIcon("Minus.png")); remove.setToolTipText(jEdit.getProperty("options.toolbar.remove")); remove.addActionListener(actionHandler); buttons.add(remove); buttons.add(Box.createHorizontalStrut(6)); moveUp = new RolloverButton(GUIUtilities.loadIcon("ArrowU.png")); moveUp.setToolTipText(jEdit.getProperty("options.toolbar.moveUp")); moveUp.addActionListener(actionHandler); buttons.add(moveUp); buttons.add(Box.createHorizontalStrut(6)); moveDown = new RolloverButton(GUIUtilities.loadIcon("ArrowD.png")); moveDown.setToolTipText(jEdit.getProperty("options.toolbar.moveDown")); moveDown.addActionListener(actionHandler); buttons.add(moveDown); buttons.add(Box.createHorizontalStrut(6)); edit = new RolloverButton(GUIUtilities.loadIcon("ButtonProperties.png")); edit.setToolTipText(jEdit.getProperty("options.toolbar.edit")); edit.addActionListener(actionHandler); buttons.add(edit); buttons.add(Box.createGlue()); updateButtons(); add(BorderLayout.SOUTH, buttons); iconList = new DefaultComboBoxModel(); st = new StringTokenizer(jEdit.getProperty("icons")); while (st.hasMoreElements()) { String icon = st.nextToken(); iconList.addElement(new IconListEntry(GUIUtilities.loadIcon(icon), icon)); } }