List of usage examples for java.util Vector get
public synchronized E get(int index)
From source file:com.duroty.utils.mail.MessageUtilities.java
/** * DOCUMENT ME!/*w w w . j a v a 2 s .c o m*/ * * @param dmailParts DOCUMENT ME! * @param contentType DOCUMENT ME! * @param buffer DOCUMENT ME! * * @return DOCUMENT ME! * * @throws MessagingException DOCUMENT ME! */ protected static StringBuffer scanDmailParts(Vector dmailParts, StringBuffer buffer, boolean chooseHtml, String breakLine) throws MessagingException { if ((buffer.length() == 0) && (dmailParts != null)) { int size = dmailParts.size(); int j = 0; for (int i = 0; i < size; i++) { //message/rfc822 MailPart dmailPart = (MailPart) dmailParts.get(j); //ContentType xctype = MessageUtilities.getContentType(dmailPart.getContentType()); ContentType xctype = MessageUtilities.getContentType(dmailPart.getPart()); if (xctype.match("text/plain") && !chooseHtml) { String xjcharset = xctype.getParameter("charset"); if (xjcharset == null) { // not present, assume ASCII character encoding try { Header xheader; Enumeration xe = dmailPart.getPart().getAllHeaders(); for (; xe.hasMoreElements();) { xheader = (Header) xe.nextElement(); String aux = xheader.getName().toLowerCase().trim(); if (aux.indexOf("subject") > -1) { int pos1 = aux.indexOf("=?"); int pos2 = aux.indexOf("?q?"); if ((pos1 > -1) && (pos2 > -1)) { xjcharset = aux.substring(pos1, pos2); } break; } } } catch (Exception ex) { } if (xjcharset == null) { xjcharset = Charset.defaultCharset().displayName(); // US-ASCII in JAVA terms } } //String str = JavaScriptFilter.apply(buff.toString()); xjcharset = MimeUtility.javaCharset(xjcharset); MessageUtilities.decodeTextPlain(buffer, dmailPart.getPart(), breakLine, xjcharset); dmailParts.removeElementAt(j); break; } else if (xctype.match("text/html") && chooseHtml) { String xjcharset = xctype.getParameter("charset"); if (xjcharset == null) { // not present, assume ASCII character encoding try { Header xheader; Enumeration xe = dmailPart.getPart().getAllHeaders(); for (; xe.hasMoreElements();) { xheader = (Header) xe.nextElement(); String aux = xheader.getName().toLowerCase().trim(); if (aux.indexOf("subject") > -1) { int pos1 = aux.indexOf("=?"); int pos2 = aux.indexOf("?q?"); if ((pos1 > -1) && (pos2 > -1)) { xjcharset = aux.substring(pos1, pos2); } break; } } } catch (Exception ex) { } if (xjcharset == null) { xjcharset = Charset.defaultCharset().displayName(); // US-ASCII in JAVA terms } } xjcharset = MimeUtility.javaCharset(xjcharset); MessageUtilities.decodeTextHtml(buffer, dmailPart.getPart(), xjcharset); dmailParts.removeElementAt(j); break; } else { j++; } } } return buffer; }
From source file:net.sf.maltcms.chromaui.charts.Chromatogram1DChartProvider.java
/** * * @param f// ww w .j av a2 s.c o m * @param ordinateValues * @param useScanAcquisitionTime * @return */ public List<XYPointerAnnotation> getCSVPeakAnnotations(IFileFragment f, Array ordinateValues, boolean useScanAcquisitionTime) { List<XYPointerAnnotation> l = new ArrayList<>(); try { String basename = StringTools.removeFileExt(f.getName()); File peakAnnotations = new File(new File(f.getAbsolutePath()).getParentFile(), basename + ".csv"); Logger.getLogger(Chromatogram1DChartProvider.class.getName()).log(Level.INFO, "Looking for file {0}", peakAnnotations); if (!peakAnnotations.exists()) { Logger.getLogger(Chromatogram1DChartProvider.class.getName()).info("File does not exist!"); return l; } Logger.getLogger(Chromatogram1DChartProvider.class.getName()).info("File exists!"); CSVReader csvr = new CSVReader(); try { Tuple2D<Vector<Vector<String>>, Vector<String>> t = csvr .read(new BufferedInputStream(new FileInputStream(peakAnnotations))); HashMap<String, Vector<String>> hm = csvr.getColumns(t); Vector<String> rt = hm.get("RT"); Vector<String> scan = hm.get("SCAN"); int i = 0; Vector<String> id = hm.get("NO"); for (String s : rt) { XYPointerAnnotation xypa = null; //correct chemstation scan index by -1 (1 based) int scanIdx = Integer.parseInt(scan.get(i)) - 1; double apex = ordinateValues.getDouble(scanIdx); if (useScanAcquisitionTime) { double srt = (Double.parseDouble(s)); xypa = new XYPointerAnnotation(id.get(i), srt * 60.0, apex, -0.8); } else { xypa = new XYPointerAnnotation(id.get(i), scanIdx, apex, -0.8); } xypa.setTipRadius(0.01); xypa.setLabelOffset(1); xypa.setBaseRadius(10); xypa.setTextAnchor(TextAnchor.BOTTOM_LEFT); l.add(xypa); Logger.getLogger(Chromatogram1DChartProvider.class.getName()).log(Level.INFO, "Adding annotation at: {0}", xypa.getX()); i++; } } catch (FileNotFoundException ex) { Exceptions.printStackTrace(ex); } } catch (ResourceNotAvailableException rnae) { } return l; }
From source file:edu.ku.brc.specify.utilapps.RegisterApp.java
/** * @param statName//w ww.j ava 2 s.c o m * @return */ protected Vector<Pair<String, Integer>> getCollValuesFromList(final String statName) { String sql = "SELECT Value, COUNT(Value) AS CNT FROM registeritem WHERE Name = '" + statName + "' GROUP BY Value ORDER BY CNT"; System.err.println(sql); Vector<Pair<String, Integer>> values = new Vector<Pair<String, Integer>>(); Vector<Object[]> list = BasicSQLUtils.query(sql); for (int i = 0; i < list.size(); i++) { Object[] row = list.get(i); values.add(new Pair<String, Integer>(row[0].toString(), ((Long) row[1]).intValue())); } return values; }
From source file:com.mysql.stresstool.RunnableQueryInsertPartRange.java
public void run() { BufferedReader d = null;//ww w . j ava2 s.co m Connection conn = null; try { if (stikyconnection && jdbcUrlMap.get("dbType") != null && !((String) jdbcUrlMap.get("dbType")).equals("MySQL")) { conn = DriverManager.getConnection((String) jdbcUrlMap.get("dbType"), "test", "test"); } else if (stikyconnection) conn = DriverManager.getConnection((String) jdbcUrlMap.get("jdbcUrl")); } catch (SQLException ex) { ex.printStackTrace(); } try { long execTime = 0; int pkStart = 0; int pkEnds = 0; int intDeleteInterval = 0; int intBlobInterval = 0; int intBlobIntervalLimit = StressTool.getNumberFromRandom(4).intValue(); ThreadInfo thInfo; long threadTimeStart = System.currentTimeMillis(); active = true; thInfo = new ThreadInfo(); thInfo.setId(this.ID); thInfo.setType("insert"); thInfo.setStatusActive(this.isActive()); StressTool.setInfo(this.ID, thInfo); boolean lazy = false; int lazyInterval = 0; for (int repeat = 0; repeat <= repeatNumber; repeat++) { if (!stikyconnection) { try { if (conn != null && !conn.isClosed()) { conn.close(); } SoftReference sf = new SoftReference( DriverManager.getConnection((String) jdbcUrlMap.get("jdbcUrl"))); conn = (Connection) sf.get(); } catch (SQLException ex) { for (int icon = 0; icon <= 3; icon++) { try { Thread.sleep(10000); SoftReference sf = new SoftReference( DriverManager.getConnection((String) jdbcUrlMap.get("jdbcUrl"))); conn = (Connection) sf.get(); } catch (SQLException ex2) { ex2.printStackTrace(); } } //ex.printStackTrace(); } } if (conn != null) { Statement stmt = null; // ResultSet rs = null; // ResultSet rs2 = null; conn.setAutoCommit(false); stmt = conn.createStatement(); stmt.execute("SET AUTOCOMMIT=0"); String query = null; ArrayList insert1 = null; ArrayList insert2 = null; int pk = 0; if (repeat > 0 && lazyInterval < 500) { lazy = true; ++lazyInterval; } else { lazy = false; lazyInterval = 0; } intBlobInterval++; //IMPLEMENTING lazy Vector v = this.getTablesValues(lazy); insert1 = (ArrayList<String>) v.get(0); insert2 = (ArrayList<String>) v.get(1); // System.out.println(insert1); // System.out.println(insert2); // pk = ((Integer) v.get(2)).intValue(); int[] iLine = { 0, 0 }; // pkStart = StressTool.getNumberFromRandom(2147483647).intValue(); // pkEnds = StressTool.getNumberFromRandom(2147483647).intValue(); try { long timeStart = System.currentTimeMillis(); if (this.ignoreBinlog) stmt.execute("SET sql_log_bin=0"); //stmt.execute("SET GLOBAL max_allowed_packet=1073741824"); if (dbType.equals("MySQL") && !engine.toUpperCase().equals("BRIGHTHOUSE")) stmt.execute("BEGIN"); else stmt.execute("COMMIT"); // stmt.execute("SET TRANSACTION NAME 'TEST'"); { Iterator<String> it = insert1.iterator(); while (it.hasNext()) { stmt.addBatch(it.next()); } } if (!this.doSimplePk) { if (intBlobInterval > intBlobIntervalLimit) { Iterator<String> it = insert2.iterator(); while (it.hasNext()) { stmt.addBatch(it.next()); } intBlobInterval = 0; } } if (debug) { System.out.println("Thread " + thInfo.getId() + " Executing loop " + thInfo.getExecutedLoops() + " QUERY1==" + insert1); System.out.println("Thread " + thInfo.getId() + " Executing loop " + thInfo.getExecutedLoops() + " QUERY2==" + insert2); } iLine = executeSQL(stmt); // System.out.println("Query1 = " + insert1); // System.out.println("Query2 = " + insert2); // stmt.execute("START TRANSACTION"); // stmt.execute(insert1); // iLine = stmt.executeBatch(); // conn.commit(); long timeEnds = System.currentTimeMillis(); execTime = (timeEnds - timeStart); } catch (SQLException sqle) { conn.rollback(); System.out.println("FAILED QUERY1==" + insert1); System.out.println("FAILED QUERY2==" + insert2); sqle.printStackTrace(); System.exit(1); //conn.close(); //this.setJdbcUrl(jdbcUrl); //System.out.println("Query Insert TH RE-INIZIALIZING"); } finally { // conn.commit(); if (conn != null && !conn.isClosed()) { try { stmt.addBatch("COMMIT"); executeSQL(stmt); } catch (SQLException sqle) { System.out.println( "#####################\n[Warning] Cannot explicitly commit given error\n#################"); conn.close(); continue; } } else { System.out.println( "#####################\n[Warning] Cannot explicitly commit given connection was interrupted unexpectedly\n#################"); } // intDeleteInterval++; if (doLog) { System.out.println("Query Insert TH = " + this.getID() + " Loop N = " + repeat + " " + iLine[0] + "|" + ((iLine.length > 1) ? iLine[1] : 0) + " Exec Time(ms) =" + execTime + " Running = " + repeat + " of " + repeatNumber + " to go =" + (repeatNumber - repeat) + " Using Lazy=" + lazy); } } thInfo.setExecutedLoops(repeat); if (sleepFor > 0 || this.getSleepWrite() > 0) { if (this.getSleepWrite() > 0) { Thread.sleep(getSleepWrite()); } else Thread.sleep(sleepFor); } } } long threadTimeEnd = System.currentTimeMillis(); this.executionTime = (threadTimeEnd - threadTimeStart); // this.setExecutionTime(executionTime); active = false; // System.out.println("Query Insert TH = " + this.getID() + " COMPLETED! TOTAL TIME = " + execTime + "(ms) Sec =" + (execTime/1000)); thInfo.setExecutionTime(executionTime); thInfo.setStatusActive(false); StressTool.setInfo(this.ID, thInfo); return; } catch (Exception ex) { ex.printStackTrace(); try { conn.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
From source file:Default.YTDownloadThread.java
private void saveBinaryData() throws IOException { FileOutputStream fos = null;//w w w .j av a2 s .c o m try { File file; Integer idUpCount = 0; String directoryChoosed; directoryChoosed = (String) "/home/simpleman/Videos"; //JFCMainClient.CONFIG.getProperty("savefolder"); outputDebugMessage("title: ".concat(this.getTitle()).concat("sfilename: ").concat(this.getTitle())); do { Vector<String> fileNames = getFileNames(this.getTitle(), this.response.getFirstHeader("Content-Type").getValue()); file = new File(directoryChoosed, fileNames.get(0).concat((idUpCount > 0 ? "(".concat(idUpCount.toString()).concat(")") : "")) .concat(".").concat(fileNames.get(1))); idUpCount += 1; } while (file.exists()); this.setFileName(file.getAbsolutePath()); Long bytesReadSum = (long) 0; Long percentage = (long) -1; Long bytesMax = Long.parseLong(this.response.getFirstHeader("Content-Length").getValue()); fos = new FileOutputStream(file); outputDebugMessage(String.format("writing %d bytes to: %s", bytesMax, this.getFileName())); output(("file size of \"").concat(this.getTitle()).concat("\" = ").concat(bytesMax.toString()) .concat(" Bytes").concat(" ~ ").concat(Long.toString((bytesMax / 1024)).concat(" KiB")) .concat(" ~ ").concat(Long.toString((bytesMax / 1024 / 1024)).concat(" MiB"))); byte[] bytes = new byte[4096]; Integer bytesRead = 1; // adjust blocks of percentage to output - larger files are shown with smaller pieces Integer blocks = 10; if (bytesMax > 20 * 1024 * 1024) blocks = 4; if (bytesMax > 32 * 1024 * 1024) blocks = 2; if (bytesMax > 56 * 1024 * 1024) blocks = 1; while (!this.isInterrupted && bytesRead > 0) { bytesRead = this.binaryReader.read(bytes); bytesReadSum += bytesRead; // update percentage of download if ((((bytesReadSum * 100 / bytesMax) / blocks) * blocks) > percentage) { percentage = (((bytesReadSum * 100 / bytesMax) / blocks) * blocks); //this.youtubeUrl.setPercentage(percentage.intValue()); //JFCMainClient.updateYoutubeUrlInList(this.youtubeUrl); } // TODO calculate and show ETA for bigger downloads (remaining time > 60s) - every 20%? try { fos.write(bytes, 0, bytesRead); } catch (IndexOutOfBoundsException ioob) { } this.isInterrupted = false; // try to get information about application shutdown } // this.youtubeUrl.setDownloadingFinished(); // JFCMainClient.updateYoutubeUrlInList(this.youtubeUrl); // rename files if download was interrupted before completion of download if (this.isInterrupted && bytesReadSum < bytesMax) { try { // this part is especially for our M$-Windows users because of the different behavior of File.renameTo() in contrast to non-windows // see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6213298 and others // even with Java 1.6.0_22 the renameTo() does not work directly on M$-Windows! fos.close(); } catch (Exception e) { } // System.gc(); // we don't have to do this but to be sure the file handle gets released we do a thread sleep try { Thread.sleep(50); } catch (InterruptedException e) { } // this part runs on *ix platforms without closing the FileOutputStream explicitly this.httpClient.close(); // otherwise binaryreader.close() would cause the entire datastream to be transmitted outputDebugMessage(String.format("download canceled. (%d)", (bytesRead))); changeFileNamewith("CANCELED."); String message = ("renaming unfinished file to: ").concat(this.getFileName()); output(message); outputDebugMessage(message); // CANCELED filenames overwrite others as we do not test for CANCELED one, two... if (!file.renameTo(new File(this.getFileName()))) { message = ("error renaming unfinished file to: ").concat(this.getFileName()); output(message); outputDebugMessage(message); } } outputDebugMessage("done writing."); } catch (FileNotFoundException fnfe) { throw (fnfe); } catch (IOException ioe) { outputDebugMessage("IOException"); throw (ioe); } finally { this.videoUrl = null; try { fos.close(); } catch (Exception e) { } try { this.textReader.close(); } catch (Exception e) { } try { this.binaryReader.close(); } catch (Exception e) { } } }
From source file:edu.ku.brc.specify.utilapps.RegisterApp.java
protected Vector<Pair<String, Integer>> getCollNumValuesFromList(final String statName) { String sql = "SELECT RegisterID, Value, CountAmt FROM registeritem WHERE Name = '" + statName + "' OR Name = 'Collection_name' ORDER BY RegisterID"; Vector<Pair<String, Integer>> values = new Vector<Pair<String, Integer>>(); for (RegProcEntry entry : rp.getRoot(INCL_ANON).getKids()) { if (entry.get("reg_type").equals("Collection")) { }/*from w ww .j a v a2s .c o m*/ } Vector<Object[]> list = BasicSQLUtils.query(sql); for (int i = 0; i < list.size(); i++) { Object[] row1 = list.get(i); i++; if (i < list.size()) { Object[] row2 = list.get(i); int id1 = (Integer) row1[0]; int id2 = (Integer) row2[0]; if (id1 == id2) { String desc = (String) (row1[1] != null ? row1[1] : row2[1]); Integer count = (Integer) (row1[2] != null ? row1[2] : row2[2]); values.add(new Pair<String, Integer>(desc, count)); } else { i--; } } } return values; }
From source file:edu.ku.brc.specify.config.init.SpecifyDBSetupWizard.java
/** * @param wizardType//from w w w. java2s . c o m * @param listener */ public SpecifyDBSetupWizard(final WizardType wizardType, final WizardListener listener) { super(); this.wizardType = wizardType; this.listener = listener; System.setProperty(DBMSUserMgr.factoryName, "edu.ku.brc.dbsupport.MySQLDMBSUserMgr"); /*setupXMLPath = UIRegistry.getUserHomeAppDir() + File.separator + "setup_prefs.xml"; try { props.loadFromXML(new FileInputStream(new File(setupXMLPath))); } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(SpecifyDBSetupWizard.class, ex); }*/ HelpMgr.setLoadingPage("Load"); cardPanel = new JPanel(cardLayout); cancelBtn = createButton(UIRegistry.getResourceString("CANCEL")); helpBtn = createButton(UIRegistry.getResourceString("HELP")); JPanel btnBar; backBtn = createButton(UIRegistry.getResourceString("BACK")); nextBtn = createButton(UIRegistry.getResourceString("NEXT")); CellConstraints cc = new CellConstraints(); PanelBuilder bbpb = new PanelBuilder(new FormLayout("f:p:g,p,4px,p,4px,p,4px,p,4px", "p")); bbpb.add(helpBtn, cc.xy(2, 1)); bbpb.add(backBtn, cc.xy(4, 1)); bbpb.add(nextBtn, cc.xy(6, 1)); bbpb.add(cancelBtn, cc.xy(8, 1)); btnBar = bbpb.getPanel(); boolean doTesting = AppPreferences.getLocalPrefs().getBoolean("wizard.defaults", false); if (doTesting && wizardType == WizardType.Institution) { props.put("hostName", "localhost"); props.put("dbName", "testfish"); props.put("dbUserName", "Specify"); props.put("dbPassword", "Specify"); props.put("saUserName", "Master"); props.put("saPassword", "Master"); props.put("firstName", "Test"); props.put("lastName", "User"); props.put("middleInitial", "a"); props.put("email", "tester@ku.edu"); props.put("usrUsername", "testuser"); props.put("usrPassword", "testuser"); props.put("instName", "KU natural History Museum"); props.put("instAbbrev", "KU-NHM"); props.put("divName", "Fish"); props.put("divAbbrev", "IT"); props.put("collName", "Fish"); props.put("collPrefix", "KUFSH"); // Address props.put("addr1", "1345 Jayhawk Blvd"); props.put("addr2", "606 Dyche Hall"); props.put("city", "Lawrence"); props.put("state", "KS"); props.put("country", "USA"); props.put("zip", "66044"); props.put("phone", "785-864-5555"); props.put("addtaxon", true); } else { props.put("hostName", "localhost"); props.put("dbName", "specify"); } props.put("userType", SpecifyUserTypes.UserType.Manager.toString()); UIFieldFormatterMgr.setDoingLocal(true); String accessionFmt = null; if (wizardType == WizardType.Institution) { props.put("fromwizard", "true"); dbPanel = new DatabasePanel(nextBtn, backBtn, getHelpCntxt("wizard_mysql_username"), true); panels.add(dbPanel); HelpMgr.registerComponent(helpBtn, dbPanel.getHelpContext()); if (listener != null) { listener.helpContextChanged(dbPanel.getHelpContext()); } panels.add(new MasterUserPanel("SA", "ENTER_SA_INFO", getHelpCntxt("wizard_master_username"), new String[] { "SA_USERNAME", "SA_PASSWORD" }, new String[] { "saUserName", "saPassword" }, new Integer[] { 32, 32 }, nextBtn, backBtn, true)); panels.add(new GenericFormPanel("SECURITY", "SECURITY_INFO", getHelpCntxt("wizard_security_on"), new String[] { "SECURITY_ON" }, new String[] { "security_on" }, new String[] { "checkbox" }, nextBtn, backBtn, true)); userInfoPanel = new UserInfoPanel("AGENT", "ENTER_COLMGR_INFO", getHelpCntxt("wizard_create_it_user"), new String[] { "FIRSTNAME", "LASTNAME", "MIDNAME", "EMAIL", null, "USERLOGININFO", "USERNAME", "PASSWORD" }, new String[] { "firstName", "lastName", "middleInitial", "email", " ", "-", "usrUsername", "usrPassword" }, new boolean[] { true, true, false, true, true, false, true, true }, new Integer[] { 50, 120, 50, 50, null, null, 64, 32 }, nextBtn, backBtn); panels.add(userInfoPanel); panels.add(new GenericFormPanel("INST", "ENTER_INST_INFO", getHelpCntxt("wizard_create_institution"), new String[] { "NAME", "ABBREV", null, "INST_ADDR", "ADDR1", "ADDR2", "CITY", "STATE", "COUNTRY", "ZIP", "PHONE" }, new String[] { "instName", "instAbbrev", " ", "-", "addr1", "addr2", "city", "state", "country", "zip", "phone" }, new boolean[] { true, true, false, false, true, false, true, true, true, true, true }, new Integer[] { 255, 32, 50, null, 255, 255, 64, 64, 64, 32, 50 }, nextBtn, backBtn, true)); accessionPanel = new GenericFormPanel("ACCESSIONGLOBALLY", "ENTER_ACC_INFO", getHelpCntxt("wizard_choose_accession_level"), new String[] { "ACCGLOBALLY" }, new String[] { "accglobal" }, new String[] { "checkbox" }, nextBtn, backBtn, true); panels.add(accessionPanel); if (wizardType == WizardType.Institution) { accessionPickerGbl = new FormatterPickerPanel("ACCNOFMT", getHelpCntxt("wizard_create_accession_number"), nextBtn, backBtn, false, null); panels.add(accessionPickerGbl); } storageTDPanel = new TreeDefSetupPanel(StorageTreeDef.class, getResourceString("Storage"), "Storage", getHelpCntxt("wizard_configure_storage_tree"), "CONFIG_TREEDEF", nextBtn, backBtn, null); panels.add(storageTDPanel); panels.add(new InstSetupPanel("CREATEINST", "CREATEINST", getHelpCntxt("wizard_create_institution"), new String[] {}, new String[] {}, new Integer[] {}, nextBtn, backBtn, true)); } if (wizardType == WizardType.Institution || wizardType == WizardType.Division) { DivisionPanel divPanel = new DivisionPanel("DIV", "ENTER_DIV_INFO", getHelpCntxt("wizard_enter_division"), new String[] { "NAME", "ABBREV" }, new String[] { "divName", "divAbbrev" }, new Integer[] { 255, 64 }, nextBtn, backBtn, true); panels.add(divPanel); if (wizardType == WizardType.Division) { HelpMgr.registerComponent(helpBtn, divPanel.getHelpContext()); } } if (wizardType != WizardType.Institution) { Institution institution = AppContextMgr.getInstance().getClassObject(Institution.class); Division division = AppContextMgr.getInstance().getClassObject(Division.class); if (!institution.getIsAccessionsGlobal()) { String sql = "SELECT ans.FormatName FROM autonumberingscheme ans Inner Join autonumsch_div ad ON ans.AutoNumberingSchemeID = ad.AutoNumberingSchemeID " + "INNER JOIN division d ON ad.DivisionID = d.UserGroupScopeId WHERE d.DivisionID = " + division.getId(); log.debug(sql); Vector<Object> rows = BasicSQLUtils.querySingleCol(sql); if (rows.size() == 1) { accessionFmt = rows.get(0).toString(); } else { log.error("The return " + rows.size()); } } } if (wizardType == WizardType.Institution || wizardType == WizardType.Division || wizardType == WizardType.Discipline) { nextBtn.setEnabled(false); disciplinePanel = new DisciplinePanel(getHelpCntxt("wizard_choose_discipline_type"), nextBtn, backBtn); panels.add(disciplinePanel); if (wizardType == WizardType.Discipline) { HelpMgr.registerComponent(helpBtn, disciplinePanel.getHelpContext()); } taxonTDPanel = new TreeDefSetupPanel(TaxonTreeDef.class, getResourceString("Taxon"), "Taxon", getHelpCntxt("wizard_configure_taxon_tree"), "CONFIG_TREEDEF", nextBtn, backBtn, disciplinePanel); panels.add(taxonTDPanel); panels.add(new TaxonLoadSetupPanel(getHelpCntxt("wizard_preload_taxon"), nextBtn, backBtn)); geoTDPanel = new TreeDefSetupPanel(GeographyTreeDef.class, getResourceString("Geography"), "Geography", getHelpCntxt("wizard_configure_geography_tree"), "CONFIG_TREEDEF", nextBtn, backBtn, disciplinePanel); panels.add(geoTDPanel); } CollectionPanel colPanel = new CollectionPanel("COLLECTION", "ENTER_COL_INFO", getHelpCntxt("wizard_create_collection"), new String[] { "NAME", "PREFIX", }, new String[] { "collName", "collPrefix", }, new Integer[] { 50, 50 }, nextBtn, backBtn, true); panels.add(colPanel); if (wizardType == WizardType.Collection) { HelpMgr.registerComponent(helpBtn, colPanel.getHelpContext()); } catNumPicker = new FormatterPickerPanel("CATNOFMT", getHelpCntxt("wizard_create_catalog_number"), nextBtn, backBtn, true, null); panels.add(catNumPicker); if (wizardType != WizardType.Institution) { Division division = AppContextMgr.getInstance().getClassObject(Division.class); String sql = "SELECT COUNT(*) FROM division d INNER JOIN collection c ON d.UserGroupScopeId = c.DisciplineID WHERE d.UserGroupScopeId = " + division.getId(); log.debug(sql); int numCollectionsByDiv = BasicSQLUtils.getCountAsInt(sql); if (numCollectionsByDiv == 0) { Institution inst = AppContextMgr.getInstance().getClassObject(Institution.class); if (inst != null && !inst.getIsAccessionsGlobal()) { //if (wizardType != WizardType.Division) { accessionPickerCol = new FormatterPickerPanel("ACCNOFMT", getHelpCntxt("wizard_create_accession_number"), nextBtn, backBtn, false, accessionFmt); accessionPickerCol.setDoingDisciplineCollection(wizardType != WizardType.Division); panels.add(accessionPickerCol); } } } } else { accessionPickerCol = new FormatterPickerPanel("ACCNOFMT", getHelpCntxt("wizard_create_accession_number"), nextBtn, backBtn, false, null); panels.add(accessionPickerCol); } panels.add(new SummaryPanel("SUMMARY", getHelpCntxt("wizard_summary"), nextBtn, backBtn, panels)); lastStep = panels.size(); if (backBtn != null) { backBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { if (step > 0) { if (disciplinePanel != null) { DisciplineType disciplineType = disciplinePanel.getDisciplineType(); if (disciplineType != null && disciplineType.isPaleo() && panels.get(step - 1) instanceof TaxonLoadSetupPanel) { //step--; } } if (panels.get(step - 1) == accessionPickerGbl) { if (!((Boolean) props.get("accglobal"))) { step--; } } if (panels.get(step - 1) == accessionPickerCol) { boolean isAccGlobal; if (accessionPanel != null) { accessionPanel.getValues(props); isAccGlobal = (Boolean) props.get("accglobal"); } else { Institution inst = AppContextMgr.getInstance().getClassObject(Institution.class); isAccGlobal = inst != null && !inst.getIsAccessionsGlobal(); } if (isAccGlobal) { step--; } } step--; panels.get(step).doingPrev(); HelpMgr.registerComponent(helpBtn, panels.get(step).getHelpContext()); cardLayout.show(cardPanel, Integer.toString(step)); } updateBtnBar(); if (listener != null) { listener.panelChanged(getResourceString(panels.get(step).getPanelName() + ".TITLE")); listener.helpContextChanged(panels.get(step).getHelpContext()); } } }); backBtn.setEnabled(false); } nextBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { if (step == lastStep - 2) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { Component c = SpecifyDBSetupWizard.this.getParent(); while (!(c instanceof Window) && c != null) { c = c.getParent(); } if (c != null) { ((Window) c).pack(); } } }); } if (step < lastStep - 1) { DisciplineType disciplineType = null; if (disciplinePanel == null) { Discipline discipline = AppContextMgr.getInstance().getClassObject(Discipline.class); disciplineType = DisciplineType.getByName(discipline.getType()); } else { disciplineType = disciplinePanel.getDisciplineType(); } panels.get(step).getValues(props); panels.get(step).aboutToLeave(); if (step == 1) { String isCnvUploadVal = props.getProperty(DatabasePanel.DB_STRUCT_ONLY); boolean isCnvUpload = StringUtils.isNotEmpty(isCnvUploadVal) ? isCnvUploadVal.equals("true") : false; if (isCnvUpload) { setupLoginPrefs(); JOptionPane.showMessageDialog(UIRegistry.getTopWindow(), getResourceString("CONVUPLD_DONE"), getResourceString("COMPLETE"), JOptionPane.INFORMATION_MESSAGE); SpecifyDBSetupWizard.this.listener.finished(); return; } } if (disciplineType != null && disciplineType.isPaleo() && panels.get(step) instanceof TreeDefSetupPanel && ((TreeDefSetupPanel) panels.get(step)).getClassType() == TaxonTreeDef.class) { //step++; } if (panels.get(step) == accessionPanel) { accessionPanel.getValues(props); if (!((Boolean) props.get("accglobal"))) { step++; } } if (panels.get(step) == catNumPicker) { if (accessionPanel != null) { accessionPanel.getValues(props); boolean isAccGlobal = (Boolean) props.get("accglobal"); if (isAccGlobal) { step++; } } } advanceToNextPanel(); } else { nextBtn.setEnabled(false); if (wizardType == WizardType.Institution) { configSetup(); configureDatabase(); } else { //SpecifyDBSetupWizard.this.listener.hide(); SpecifyDBSetupWizard.this.listener.finished(); } } } }); cancelBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { if (SpecifyDBSetupWizard.this.listener != null) { if (step == lastStep) { SpecifyDBSetupWizard.this.listener.finished(); } else { if (UIHelper.promptForAction("QUIT", "NO", "CANCEL", getResourceString("SURE_QUIT"))) { SpecifyDBSetupWizard.this.listener.cancelled(); } } } } }); for (int i = 0; i < panels.size(); i++) { cardPanel.add(Integer.toString(i), panels.get(i)); panels.get(i).setValues(props); } cardLayout.show(cardPanel, "0"); if (dbPanel != null) { dbPanel.updateBtnUI(); } PanelBuilder builder = new PanelBuilder(new FormLayout("f:p:g", "f:p:g,10px,p")); builder.add(cardPanel, cc.xy(1, 1)); builder.add(btnBar, cc.xy(1, 3)); builder.setDefaultDialogBorder(); setLayout(new BorderLayout()); PanelBuilder iconBldr = new PanelBuilder(new FormLayout("20px, f:p:g,p,f:p:g,8px", "20px,t:p,f:p:g, 8px")); JLabel iconLbl = new JLabel(IconManager.getIcon(getIconName())); iconLbl.setVerticalAlignment(SwingConstants.TOP); iconBldr.add(iconLbl, cc.xy(2, 3)); add(iconBldr.getPanel(), BorderLayout.WEST); add(builder.getPanel(), BorderLayout.CENTER); progressBar = new JProgressBar(0, lastStep - 1); progressBar.setStringPainted(true); add(progressBar, BorderLayout.SOUTH); panels.get(0).updateBtnUI(); }
From source file:edu.ku.brc.specify.tasks.subpane.wb.FormPane.java
protected Vector<Object> getValues(final WorkbenchTemplateMappingItem wbtmi) { Vector<WorkbenchTemplateMappingItem> wbtmis = new Vector<WorkbenchTemplateMappingItem>(); wbtmis.addAll(workbench.getWorkbenchTemplate().getWorkbenchTemplateMappingItems()); Collections.sort(wbtmis);/*from ww w . j a v a2s . c om*/ int wbCol = -1; for (int c = 0; c < wbtmis.size(); c++) { if (wbtmis.get(c) == wbtmi) { wbCol = c; break; } } if (wbCol != -1) { if (workbenchPane.getSpreadSheet().getColumnModel().getColumn(wbCol) .getCellEditor() instanceof WorkbenchPaneSS.GridCellListEditor) { ComboBoxModel model = ((WorkbenchPaneSS.GridCellListEditor) workbenchPane.getSpreadSheet() .getColumnModel().getColumn(wbCol).getCellEditor()).getList(); Vector<Object> result = new Vector<Object>(); for (int i = 0; i < model.getSize(); i++) { result.add(model.getElementAt(i)); } return result; } } return null; }
From source file:cn.labthink.ReadAccess060.java
private void outputexcelInfo(Vector<String> TestInfoName, Vector<String> TestInfoValue) { if (outputfile == null) { return;//ww w . jav a 2s .c o m } if (book == null) { try { // book = Workbook.createWorkbook(outputfile); } catch (IOException ex) { Logger.getLogger(ReadAccess060.class.getName()).log(Level.SEVERE, null, ex); } } else { //? } try { WritableSheet sheet1 = book.createSheet("TestIno", 0);// 0 Label l = new Label(0, 0, "testID");//i0 Enumeration<TableColumn> en = jTable1.getTableHeader().getColumnModel().getColumns(); int col = 0; Label linsert = null; for (int i = 0; i < TestInfoName.size(); i++) { linsert = new Label(col, i, TestInfoName.get(i));//iirow sheet1.addCell(linsert); col++; linsert = new Label(col, i, TestInfoValue.get(i));//iirow sheet1.addCell(linsert); col = 0; } // while (en.hasMoreElements()) { // // // TableColumn tc = en.nextElement(); // // linsert = new Label(col, row, (String) tc.getHeaderValue());//iirow // sheet1.addCell(linsert); // col++; // linsert = new Label(col, row, ""+ jTable1.getValueAt(selectedrow, row++));//iirow // sheet1.addCell(linsert); // col = 0; // } } catch (WriteException ex) { Logger.getLogger(ReadAccess060.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:cn.labthink.ReadAccess330.java
private void outputexcelInfo(Vector<String> TestInfoName, Vector<String> TestInfoValue) { if (outputfile == null) { return;/*from ww w . j a v a 2 s . c o m*/ } if (book == null) { try { // book = Workbook.createWorkbook(outputfile); } catch (IOException ex) { Logger.getLogger(ReadAccess330.class.getName()).log(Level.SEVERE, null, ex); } } else { //? } try { WritableSheet sheet1 = book.createSheet("TestIno", 0);// 0 Label l = new Label(0, 0, "testID");//i0 Enumeration<TableColumn> en = jTable1.getTableHeader().getColumnModel().getColumns(); int col = 0; Label linsert = null; for (int i = 0; i < TestInfoName.size(); i++) { linsert = new Label(col, i, TestInfoName.get(i));//iirow sheet1.addCell(linsert); col++; linsert = new Label(col, i, TestInfoValue.get(i));//iirow sheet1.addCell(linsert); col = 0; } // while (en.hasMoreElements()) { // // // TableColumn tc = en.nextElement(); // // linsert = new Label(col, row, (String) tc.getHeaderValue());//iirow // sheet1.addCell(linsert); // col++; // linsert = new Label(col, row, ""+ jTable1.getValueAt(selectedrow, row++));//iirow // sheet1.addCell(linsert); // col = 0; // } } catch (WriteException ex) { Logger.getLogger(ReadAccess330.class.getName()).log(Level.SEVERE, null, ex); } }