List of usage examples for java.awt FileDialog setDirectory
public void setDirectory(String dir)
From source file:jpad.MainEditor.java
public void saveAs_OSX_Nix() { String fileToSaveTo = null;//from w ww .j av a2s . c o m FilenameFilter awtFilter = new FilenameFilter() { @Override public boolean accept(File dir, String name) { String lowercaseName = name.toLowerCase(); if (lowercaseName.endsWith(".txt")) { return true; } else { return false; } } }; FileDialog fd = new FileDialog(this, "Save Text File", FileDialog.SAVE); fd.setDirectory(System.getProperty("java.home")); if (curFile == null) fd.setFile("Untitled.txt"); else fd.setFile(curFile); fd.setFilenameFilter(awtFilter); fd.setVisible(true); if (fd.getFile() != null) fileToSaveTo = fd.getDirectory() + fd.getFile(); else { fileToSaveTo = fd.getFile(); return; } curFile = fileToSaveTo; JRootPane root = this.getRootPane(); root.putClientProperty("Window.documentFile", new File(curFile)); hasChanges = false; hasSavedToFile = true; }
From source file:net.chaosserver.timelord.swingui.Timelord.java
/** * Persists out the timelord file and allows the user to choose where * the file should go./*w w w. j av a 2 s .co m*/ * * @param rwClassName the name of the RW class * (e.g. "net.chaosserver.timelord.data.ExcelDataReaderWriter") * @param userSelect allows the user to select where the file should * be persisted. */ public void writeTimeTrackData(String rwClassName, boolean userSelect) { try { Class<?> rwClass = Class.forName(rwClassName); TimelordDataReaderWriter timelordDataRW = (TimelordDataReaderWriter) rwClass.newInstance(); int result = JFileChooser.APPROVE_OPTION; File outputFile = timelordDataRW.getDefaultOutputFile(); if (timelordDataRW instanceof TimelordDataReaderWriterUI) { TimelordDataReaderWriterUI timelordDataReaderWriterUI = (TimelordDataReaderWriterUI) timelordDataRW; timelordDataReaderWriterUI.setParentFrame(applicationFrame); JDialog configDialog = timelordDataReaderWriterUI.getConfigDialog(); configDialog.pack(); configDialog.setLocationRelativeTo(applicationFrame); configDialog.setVisible(true); } if (userSelect) { if (OsUtil.isMac()) { FileDialog fileDialog = new FileDialog(applicationFrame, "Select File", FileDialog.SAVE); fileDialog.setDirectory(outputFile.getParent()); fileDialog.setFile(outputFile.getName()); fileDialog.setVisible(true); if (fileDialog.getFile() != null) { outputFile = new File(fileDialog.getDirectory(), fileDialog.getFile()); } } else { JFileChooser fileChooser = new JFileChooser(outputFile.getParentFile()); fileChooser.setSelectedFile(outputFile); fileChooser.setFileFilter(timelordDataRW.getFileFilter()); result = fileChooser.showSaveDialog(applicationFrame); if (result == JFileChooser.APPROVE_OPTION) { outputFile = fileChooser.getSelectedFile(); } } } if (result == JFileChooser.APPROVE_OPTION) { timelordDataRW.writeTimelordData(getTimelordData(), outputFile); } } catch (Exception e) { JOptionPane.showMessageDialog(applicationFrame, "Error writing to file.\n" + "Do you have the output file open?", "Save Error", JOptionPane.ERROR_MESSAGE, applicationIcon); if (log.isErrorEnabled()) { log.error("Error persisting file", e); } } }
From source file:edu.ucla.stat.SOCR.analyses.util.moduls.frm.Panels.Jpan_btn.java
private FitxerDades getFitxerDades(final String sPath) { final FileDialog fd = new FileDialog(fDialog, Language.getLabel(9), FileDialog.LOAD); FitxerDades fitx;/*from w w w. j av a2 s.com*/ fitx = new FitxerDades(); fd.setDirectory(sPath); fd.setVisible(true); if (fd.getFile() == null) { fitx = null; } else { fitx.setNom(fd.getFile()); fitx.setPath(fd.getDirectory()); } return fitx; }
From source file:edu.ku.brc.af.core.db.MySQLBackupService.java
@Override public void doRestore() { AppPreferences remotePrefs = AppPreferences.getLocalPrefs(); final String mysqlLoc = remotePrefs.get(MYSQL_LOC, getDefaultMySQLLoc()); final String backupLoc = remotePrefs.get(MYSQLBCK_LOC, getDefaultBackupLoc()); if (!(new File(mysqlLoc)).exists()) { UIRegistry.showLocalizedError("MySQLBackupService.MYSQL_NO_RESTORE", mysqlLoc); return;//from ww w . j av a2 s .co m } File backupDir = new File(backupLoc); if (!backupDir.exists()) { if (!backupDir.mkdir()) { UIRegistry.showLocalizedError("MySQLBackupService.MYSQL_NO_BK_DIR", backupDir.getAbsoluteFile()); return; } } FileDialog dlg = new FileDialog(((Frame) UIRegistry.getTopWindow()), getResourceString("Open"), FileDialog.LOAD); dlg.setDirectory(backupLoc); dlg.setVisible(true); String dirStr = dlg.getDirectory(); String fileName = dlg.getFile(); if (StringUtils.isEmpty(dirStr) || StringUtils.isEmpty(fileName)) { return; } errorMsg = null; final String path = dirStr + fileName; final JStatusBar statusBar = UIRegistry.getStatusBar(); statusBar.setIndeterminate(STATUSBAR_NAME, true); String databaseName = DBConnection.getInstance().getDatabaseName(); SimpleGlassPane glassPane = UIRegistry .writeSimpleGlassPaneMsg(getLocalizedMessage("MySQLBackupService.RESTORING", databaseName), 24); doCompareBeforeRestore(path, glassPane); }
From source file:edu.ku.brc.specify.tasks.ReportsBaseTask.java
protected void importReport() { FileDialog fileDialog = new FileDialog((Frame) UIRegistry.get(UIRegistry.FRAME), getResourceString("CHOOSE_WORKBENCH_IMPORT_FILE"), FileDialog.LOAD); //Really shouldn't override workbench prefs with report stuff??? fileDialog.setDirectory(WorkbenchTask.getDefaultDirPath(WorkbenchTask.IMPORT_FILE_PATH)); fileDialog.setFilenameFilter(new java.io.FilenameFilter() { public boolean accept(File dir, String filename) { return FilenameUtils.getExtension(filename).equalsIgnoreCase("jrxml"); }/*from w w w .j a va 2s. co m*/ }); UIHelper.centerAndShow(fileDialog); fileDialog.dispose(); String fileName = fileDialog.getFile(); String path = fileDialog.getDirectory(); if (StringUtils.isNotEmpty(path)) { AppPreferences localPrefs = AppPreferences.getLocalPrefs(); localPrefs.put(WorkbenchTask.IMPORT_FILE_PATH, path); } File file; if (StringUtils.isNotEmpty(fileName) && StringUtils.isNotEmpty(path)) { file = new File(path + File.separator + fileName); } else { return; } if (file.exists()) { if (MainFrameSpecify.importJasperReport(file, true, null)) { refreshCommands(); } //else -- assume feedback during importJasperReport() } }
From source file:edu.ku.brc.specify.config.ResourceImportExportDlg.java
/** * /* w w w . j ava2s. co m*/ */ protected void exportResource() { int index = levelCBX.getSelectedIndex(); if (index > -1) { String exportedName = null; String data = null; String fileName = null; AppResourceIFace appRes = null; if (tabbedPane.getSelectedComponent() == viewsPanel) { if (viewSetsList.getSelectedIndex() > -1) { SpViewSetObj vso = (SpViewSetObj) viewSetsList.getSelectedValue(); exportedName = vso.getName(); fileName = FilenameUtils.getName(vso.getFileName()); data = vso.getDataAsString(true); } } else { JList theList = tabbedPane.getSelectedComponent() == repPanel ? repList : resList; if (theList.getSelectedIndex() > 0) { appRes = (AppResourceIFace) theList.getSelectedValue(); exportedName = appRes.getName(); fileName = FilenameUtils.getName(exportedName); data = appRes.getDataAsString(); } } if (StringUtils.isNotEmpty(data)) { final String EXP_DIR_PREF = "RES_LAST_EXPORT_DIR"; String initalExportDir = AppPreferences.getLocalPrefs().get(EXP_DIR_PREF, getUserHomeDir()); FileDialog fileDlg = new FileDialog(this, getResourceString("RIE_ExportResource"), FileDialog.SAVE); File expDir = new File(initalExportDir); if (StringUtils.isNotEmpty(initalExportDir) && expDir.exists()) { fileDlg.setDirectory(initalExportDir); } fileDlg.setFile(fileName); UIHelper.centerAndShow(fileDlg); String dirStr = fileDlg.getDirectory(); fileName = fileDlg.getFile(); if (StringUtils.isNotEmpty(dirStr) && StringUtils.isNotEmpty(fileName)) { AppPreferences.getLocalPrefs().put(EXP_DIR_PREF, dirStr); File expFile = new File(dirStr + File.separator + fileName); try { if (isReportResource((SpAppResource) appRes) && isSpReportResource((SpAppResource) appRes)) { writeSpReportResToZipFile(expFile, data, appRes); } else { FileUtils.writeStringToFile(expFile, data); } } catch (FileNotFoundException ex) { showLocalizedMsg("RIE_NOFILEPERM"); } catch (Exception ex) { ex.printStackTrace(); edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ResourceImportExportDlg.class, ex); } } } if (exportedName != null) { getStatusBar().setText(getLocalizedMessage("RIE_RES_EXPORTED", exportedName)); } } }
From source file:edu.ku.brc.specify.config.ResourceImportExportDlg.java
/** * /* ww w . ja va2s .c o m*/ */ protected void importResource() { int levelIndex = levelCBX.getSelectedIndex(); if (levelIndex > -1) { String importedName = null; final String IMP_DIR_PREF = "RES_LAST_IMPORT_DIR"; String initalImportDir = AppPreferences.getLocalPrefs().get(IMP_DIR_PREF, getUserHomeDir()); FileDialog fileDlg = new FileDialog(this, getResourceString("RIE_IMPORT_RES"), FileDialog.LOAD); File impDir = new File(initalImportDir); if (StringUtils.isNotEmpty(initalImportDir) && impDir.exists()) { fileDlg.setDirectory(initalImportDir); } UIHelper.centerAndShow(fileDlg); String dirStr = fileDlg.getDirectory(); String fileName = fileDlg.getFile(); if (StringUtils.isNotEmpty(dirStr) && StringUtils.isNotEmpty(fileName)) { AppPreferences.getLocalPrefs().put(IMP_DIR_PREF, dirStr); String data = null; String fullFileName = dirStr + File.separator + fileName; File importFile = new File(fullFileName); if (importFile.exists()) { String repResourceName = getSpReportResourceName(importFile); boolean isSpReportRes = repResourceName != null; boolean isJRReportRes = false; try { data = FileUtils.readFileToString(importFile); isJRReportRes = isJasperReport(data); } catch (Exception ex) { ex.printStackTrace(); edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ResourceImportExportDlg.class, ex); return; } boolean isReportRes = isJRReportRes || isSpReportRes; if (tabbedPane.getSelectedComponent() == viewsPanel) { int viewIndex = viewSetsList.getSelectedIndex(); if (viewIndex > -1) { boolean isAddItemForImport = viewSetsList.getSelectedValue() instanceof String; boolean isOK = false; SpViewSetObj vso = null; DataProviderSessionIFace session = null; try { session = DataProviderFactory.getInstance().createSession(); session.beginTransaction(); if (!isAddItemForImport) { vso = (SpViewSetObj) viewSetsList.getSelectedValue(); SpAppResourceDir appResDir = vso.getSpAppResourceDir(); importedName = vso.getName(); if (vso.getSpViewSetObjId() == null) { appResDir.getSpPersistedViewSets().add(vso); vso.setSpAppResourceDir(appResDir); } vso.setDataAsString(data, true); session.saveOrUpdate(appResDir); } else { SpAppResourceDir appResDir = dirs.get(levelIndex); vso = new SpViewSetObj(); vso.initialize(); vso.setLevel((short) levelIndex); vso.setName(FilenameUtils.getBaseName(importFile.getName())); appResDir.getSpPersistedViewSets().add(vso); vso.setSpAppResourceDir(appResDir); vso.setDataAsString(data); session.saveOrUpdate(appResDir); } session.saveOrUpdate(vso); for (SpAppResourceData ard : vso.getSpAppResourceDatas()) { session.saveOrUpdate(ard); } session.commit(); session.flush(); setHasChanged(true); isOK = true; completeMsg = getLocalizedMessage("RIE_RES_IMPORTED", importedName == null ? fileName : importedName); } catch (Exception ex) { ex.printStackTrace(); edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance() .capture(ResourceImportExportDlg.class, ex); session.rollback(); } finally { try { session.close(); } catch (Exception ex) { ex.printStackTrace(); edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance() .capture(ResourceImportExportDlg.class, ex); } } if (isOK) { if (isAddItemForImport) { viewSetsModel.clear(); viewSetsModel.addElement(vso); } else { viewSetsModel.remove(viewIndex); viewSetsModel.insertElementAt(vso, viewIndex); } viewSetsList.repaint(); } } } else { boolean isResourcePanel = tabbedPane.getSelectedComponent() == repPanel; JList theList = isResourcePanel ? repList : resList; int resIndex = theList.getSelectedIndex(); Object selObj = theList.getSelectedValue(); if (resIndex > -1) { if (resIndex == 0) // means we are adding a new resource { try { SpecifyUser user = contextMgr.getClassObject(SpecifyUser.class); Agent agent = contextMgr.getClassObject(Agent.class); SpAppResourceDir dir = dirs.get(levelIndex); SpAppResource appRes = new SpAppResource(); appRes.initialize(); appRes.setName(fileName); appRes.setCreatedByAgent(agent); appRes.setSpecifyUser(user); if (dir.getId() == null) { dir.mergeTransientResourceAndViewSets(); } Pair<SpAppResource, String> retValues = checkForOverwriteOrNewName(dir, isSpReportRes ? repResourceName : fileName, isSpReportRes); if (retValues != null && retValues.first == null && retValues.second == null) { return; // Dialog was Cancelled } SpAppResource fndAppRes = retValues != null && retValues.first != null ? retValues.first : null; String newResName = retValues != null && retValues.second != null ? retValues.second : null; if (isReportRes) { if (fndAppRes != null) { if (isSpReportRes) { ReportsBaseTask.deleteReportAndResource(null, fndAppRes.getId()); } else { //XXX ??????????? if (fndAppRes.getSpAppResourceId() != null) { contextMgr.removeAppResourceSp(fndAppRes.getSpAppResourceDir(), fndAppRes); } } } /*else if (newResName == null) { return; }*/ if (isSpReportRes) { appRes = importSpReportZipResource(importFile, appRes, dir, newResName); if (appRes != null) { importedName = appRes.getName(); } } else { if (MainFrameSpecify.importJasperReport(importFile, false, newResName)) { importedName = importFile.getName(); } else { return; } } if (importedName != null) { CommandDispatcher.dispatch(new CommandAction(ReportsBaseTask.REPORTS, ReportsBaseTask.REFRESH, null)); CommandDispatcher.dispatch(new CommandAction(QueryTask.QUERY, QueryTask.REFRESH_QUERIES, null)); levelSelected(); } } else if (fndAppRes != null) // overriding { appRes.setMetaData(fndAppRes.getMetaData()); appRes.setDescription(fndAppRes.getDescription()); appRes.setFileName(fileName); appRes.setMimeType(appRes.getMimeType()); appRes.setName(fileName); appRes.setLevel(fndAppRes.getLevel()); } else if (!getMetaInformation(appRes, fileName)) { return; } if (!isReportRes) { appRes.setSpAppResourceDir(dir); dir.getSpAppResources().add(appRes); appRes.setDataAsString(data); contextMgr.saveResource(appRes); completeMsg = getLocalizedMessage("RIE_RES_IMPORTED", importedName == null ? fileName : importedName); } setHasChanged(true); } catch (Exception e) { e.printStackTrace(); edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance() .capture(ResourceImportExportDlg.class, e); } } else if (selObj instanceof AppResourceIFace) { //if (isResourcePanel) resIndex++; AppResourceIFace fndAppRes = null; for (AppResourceIFace appRes : resources) { if (appRes == selObj) { fndAppRes = appRes; break; } } if (fndAppRes != null) { String importedFileName = fndAppRes.getFileName(); String fName = FilenameUtils.getName(importedFileName); String dbBaseName = FilenameUtils.getBaseName(fileName); //log.debug("["+fName+"]["+dbBaseName+"]"); boolean doOverwrite = true; if (!dbBaseName.equals(fName)) { String msg = getLocalizedMessage("RIE_OVRDE_MSG", dbBaseName, fName); doOverwrite = displayConfirm(getResourceString("RIE_OVRDE_TITLE"), msg, getResourceString("RIE_OVRDE"), getResourceString("CANCEL"), JOptionPane.QUESTION_MESSAGE); } if (doOverwrite) { fndAppRes.setDataAsString(data); contextMgr.saveResource(fndAppRes); completeMsg = getLocalizedMessage("RIE_RES_IMPORTED", importedName == null ? fileName : importedName); } } else { UIRegistry.showError("Strange error - Couldn't resource."); } } } } if (importedName != null) { completeMsg = getLocalizedMessage("RIE_RES_IMPORTED", importedName == null ? fileName : importedName); } if (hasChanged()) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { okBtn.doClick(); } }); } } else { UIRegistry.showLocalizedError("FILE_NO_EXISTS", fullFileName); } } enableUI(); } }
From source file:com.jug.MoMA.java
/** * Shows a JFileChooser set up to accept the selection of folders. If * 'cancel' is pressed this method terminates the MotherMachine app. * * @param guiFrame/*from w ww .ja v a2 s .c o m*/ * parent frame * @param path * path to the folder to open initially * @return an instance of {@link File} pointing at the selected folder. */ private File showFolderChooser(final JFrame guiFrame, final String path) { File selectedFile = null; if (SystemUtils.IS_OS_MAC) { // --- ON MAC SYSTEMS --- ON MAC SYSTEMS --- ON MAC SYSTEMS --- ON MAC SYSTEMS --- ON MAC SYSTEMS --- System.setProperty("apple.awt.fileDialogForDirectories", "true"); final FileDialog fd = new FileDialog(guiFrame, "Select folder containing image sequence...", FileDialog.LOAD); fd.setDirectory(path); // fd.setLocation(50,50); fd.setVisible(true); selectedFile = new File(fd.getDirectory() + "/" + fd.getFile()); if (fd.getFile() == null) { System.exit(0); return null; } System.setProperty("apple.awt.fileDialogForDirectories", "false"); } else { // --- NOT ON A MAC --- NOT ON A MAC --- NOT ON A MAC --- NOT ON A MAC --- NOT ON A MAC --- NOT ON A MAC --- final JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new java.io.File(path)); chooser.setDialogTitle("Select folder containing image sequence..."); chooser.setFileFilter(new FileFilter() { @Override public final boolean accept(final File file) { return file.isDirectory(); } @Override public String getDescription() { return "We only take directories"; } }); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setAcceptAllFileFilterUsed(false); if (chooser.showOpenDialog(guiFrame) == JFileChooser.APPROVE_OPTION) { selectedFile = chooser.getSelectedFile(); } else { System.exit(0); return null; } } return selectedFile; }
From source file:base.BasePlayer.AddGenome.java
@Override public void mousePressed(MouseEvent e) { if (e.getSource() == tree) { if (selectedNode != null && selectedNode.toString().contains("Add new refe")) { try { FileDialog fs = new FileDialog(frame, "Select reference fasta-file", FileDialog.LOAD); fs.setDirectory(Main.downloadDir); fs.setVisible(true);//from ww w .j ava 2 s . c om String filename = fs.getFile(); fs.setFile("*.fasta;*.fa"); fs.setFilenameFilter(new FilenameFilter() { public boolean accept(File dir, String name) { return name.toLowerCase().contains(".fasta") || name.toLowerCase().contains(".fa"); } }); if (filename != null) { File addfile = new File(fs.getDirectory() + "/" + filename); if (addfile.exists()) { genomeFile = addfile; Main.downloadDir = genomeFile.getParent(); Main.writeToConfig("DownloadDir=" + genomeFile.getParent()); OutputRunner runner = new OutputRunner(genomeFile.getName().replace(".fasta", "") .replace(".fa", "").replace(".gz", ""), genomeFile, null); runner.createGenome = true; runner.execute(); } else { Main.showError("File does not exists.", "Error", frame); } } if (1 == 1) { return; } JFileChooser chooser = new JFileChooser(Main.downloadDir); chooser.setMultiSelectionEnabled(false); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setAcceptAllFileFilterUsed(false); MyFilterFasta fastaFilter = new MyFilterFasta(); chooser.addChoosableFileFilter(fastaFilter); chooser.setDialogTitle("Select reference fasta-file"); if (Main.screenSize != null) { chooser.setPreferredSize(new Dimension((int) Main.screenSize.getWidth() / 3, (int) Main.screenSize.getHeight() / 3)); } int returnVal = chooser.showOpenDialog((Component) this.getParent()); if (returnVal == JFileChooser.APPROVE_OPTION) { genomeFile = chooser.getSelectedFile(); Main.downloadDir = genomeFile.getParent(); Main.writeToConfig("DownloadDir=" + genomeFile.getParent()); OutputRunner runner = new OutputRunner( genomeFile.getName().replace(".fasta", "").replace(".gz", ""), genomeFile, null); runner.createGenome = true; runner.execute(); } } catch (Exception ex) { ex.printStackTrace(); } } else if (selectedNode != null && selectedNode.isLeaf() && selectedNode.toString().contains("Add new anno")) { try { FileDialog fs = new FileDialog(frame, "Select annotation gff3/gtf-file", FileDialog.LOAD); fs.setDirectory(Main.downloadDir); fs.setVisible(true); String filename = fs.getFile(); fs.setFile("*.gff3;*.gtf"); fs.setFilenameFilter(new FilenameFilter() { public boolean accept(File dir, String name) { return name.toLowerCase().contains(".gff3") || name.toLowerCase().contains(".gtf"); } }); if (filename != null) { File addfile = new File(fs.getDirectory() + "/" + filename); if (addfile.exists()) { annotationFile = addfile; Main.downloadDir = annotationFile.getParent(); Main.writeToConfig("DownloadDir=" + annotationFile.getParent()); OutputRunner runner = new OutputRunner(selectedNode.getParent().toString(), null, annotationFile); runner.createGenome = true; runner.execute(); } else { Main.showError("File does not exists.", "Error", frame); } } if (1 == 1) { return; } JFileChooser chooser = new JFileChooser(Main.downloadDir); chooser.setMultiSelectionEnabled(false); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setAcceptAllFileFilterUsed(false); MyFilterGFF gffFilter = new MyFilterGFF(); chooser.addChoosableFileFilter(gffFilter); chooser.setDialogTitle("Select annotation gff3-file"); if (Main.screenSize != null) { chooser.setPreferredSize(new Dimension((int) Main.screenSize.getWidth() / 3, (int) Main.screenSize.getHeight() / 3)); } int returnVal = chooser.showOpenDialog((Component) this.getParent()); if (returnVal == JFileChooser.APPROVE_OPTION) { annotationFile = chooser.getSelectedFile(); Main.downloadDir = annotationFile.getParent(); Main.writeToConfig("DownloadDir=" + annotationFile.getParent()); OutputRunner runner = new OutputRunner(selectedNode.getParent().toString(), null, annotationFile); runner.createGenome = true; runner.execute(); } } catch (Exception ex) { ex.printStackTrace(); } } } if (e.getSource() == genometable) { if (new File(".").getFreeSpace() / 1048576 < sizeHash.get(genometable.getValueAt(genometable.getSelectedRow(), 0))[0] / 1048576) { sizeError.setVisible(true); download.setEnabled(false); AddGenome.getLinks.setEnabled(false); } else { sizeError.setVisible(false); download.setEnabled(true); AddGenome.getLinks.setEnabled(true); } tree.clearSelection(); remove.setEnabled(false); checkUpdates.setEnabled(false); } }
From source file:edu.ku.brc.specify.tasks.QueryTask.java
/** * /* w w w .j av a2s. c o m*/ */ protected void importQueries() { UsageTracker.incrUsageCount("QB.IMPORT"); String path = AppPreferences.getLocalPrefs().get(XML_PATH_PREF, null); try { FileDialog fDlg = new FileDialog(((Frame) UIRegistry.getTopWindow()), "Open", FileDialog.LOAD); if (path != null) { fDlg.setDirectory(path); } fDlg.setVisible(true); String dirStr = fDlg.getDirectory(); String fileName = fDlg.getFile(); if (StringUtils.isEmpty(dirStr) || StringUtils.isEmpty(fileName)) { return; } path = dirStr + fileName; AppPreferences.getLocalPrefs().put(XML_PATH_PREF, path); Vector<Pair<SpQuery, Boolean>> queries = getQueriesFromFile(path, getTopLevelNodeSelector()); ToggleButtonChooserDlg<Pair<SpQuery, Boolean>> dlg = new ToggleButtonChooserDlg<Pair<SpQuery, Boolean>>( (Frame) UIRegistry.getMostRecentWindow(), "QY_IMPORT_QUERIES", "QY_SEL_QUERIES_IMP", queries, CustomDialog.OKCANCELHELP, ToggleButtonChooserPanel.Type.Checkbox); dlg.setAddSelectAll(true); dlg.setUseScrollPane(true); dlg.setHelpContext("QBImport"); UIHelper.centerAndShow(dlg); List<Pair<SpQuery, Boolean>> queriesList = dlg.getSelectedObjects(); if (queriesList == null || queriesList.size() == 0) { return; } Vector<String> names = new Vector<String>(); //For exportschemamappings, mapping name is assumed to be the same as associated query name List<Object> nameObjs = BasicSQLUtils.querySingleCol("select name from spquery order by 1"); for (Object q : nameObjs) { names.add((String) q); } adjustImportedQueryNames(queries, names); if (saveImportedQueries(queriesList)) { for (Pair<SpQuery, Boolean> query : queriesList) { RecordSet rs = new RecordSet(); rs.initialize(); rs.set(query.getFirst().getName(), SpQuery.getClassTableId(), RecordSet.GLOBAL); rs.addItem(query.getFirst().getSpQueryId()); addToNavBox(rs); } navBox.validate(); navBox.repaint(); } } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(QueryTask.class, ex); ex.printStackTrace(); } }