List of usage examples for javax.swing JFileChooser getSelectedFiles
public File[] getSelectedFiles()
From source file:base.BasePlayer.Main.java
public void actionPerformed(ActionEvent e) { //Logo.frame.setVisible(false); if (e.getSource() == pleiadesButton) { gotoURL("http://kaptah.local.lab.helsinki.fi/pleiades/"); } else if (e.getSource() == manage) { if (VariantHandler.frame == null) { VariantHandler.main(argsit); }/*from w w w. jav a 2s . co m*/ VariantHandler.frame.setLocation( frame.getLocationOnScreen().x + frame.getWidth() / 2 - VariantHandler.frame.getWidth() / 2, frame.getLocationOnScreen().y + frame.getHeight() / 6); VariantHandler.frame.setState(JFrame.NORMAL); VariantHandler.frame.setVisible(true); Draw.calculateVars = true; Draw.updatevars = true; drawCanvas.repaint(); } else if (e.getSource() == tbrowser) { tablebrowser.frame.setLocation( frame.getLocationOnScreen().x + frame.getWidth() / 2 - VariantCaller.frame.getWidth() / 2, frame.getLocationOnScreen().y + frame.getHeight() / 6); tablebrowser.frame.setState(JFrame.NORMAL); tablebrowser.frame.setVisible(true); } else if (e.getSource() == bconvert) { bedconverter.frame.setLocation( frame.getLocationOnScreen().x + frame.getWidth() / 2 - VariantCaller.frame.getWidth() / 2, frame.getLocationOnScreen().y + frame.getHeight() / 6); bedconverter.frame.setState(JFrame.NORMAL); bedconverter.frame.setVisible(true); } else if (e.getSource() == peakCaller) { if (PeakCaller.frame == null) { PeakCaller.main(argsit); } PeakCaller.frame.setLocation( frame.getLocationOnScreen().x + frame.getWidth() / 2 - VariantCaller.frame.getWidth() / 2, frame.getLocationOnScreen().y + frame.getHeight() / 6); PeakCaller.frame.setState(JFrame.NORMAL); PeakCaller.frame.setVisible(true); } else if (e.getSource() == variantCaller) { //FileRead.checkSamples(); if (VariantCaller.frame == null) { VariantCaller.main(argsit); } VariantCaller.frame.setLocation( frame.getLocationOnScreen().x + frame.getWidth() / 2 - VariantCaller.frame.getWidth() / 2, frame.getLocationOnScreen().y + frame.getHeight() / 6); VariantCaller.frame.setState(JFrame.NORMAL); VariantCaller.frame.setVisible(true); } else if (e.getSource() == average) { if (Average.frame == null) { Average.createAndShowGUI(); } Average.setSamples(); Average.frame.setLocation( frame.getLocationOnScreen().x + frame.getWidth() / 2 - Average.frame.getWidth() / 2, frame.getLocationOnScreen().y + frame.getHeight() / 6); Average.frame.setState(JFrame.NORMAL); Average.frame.setVisible(true); } else if (e.getSource() == errorlog) { ErrorLog.frame.setLocation( frame.getLocationOnScreen().x + frame.getWidth() / 2 - ErrorLog.frame.getWidth() / 2, frame.getLocationOnScreen().y + frame.getHeight() / 6); // VariantHandler.frame.setAlwaysOnTop(true); ErrorLog.frame.setState(JFrame.NORMAL); ErrorLog.frame.setVisible(true); } /* else if(e.getSource() == help) { JOptionPane.showMessageDialog(Main.chromDraw, "This is pre-release version of BasePlayer\nContact: help@baseplayer.fi\nUniversity of Helsinki", "Help", JOptionPane.INFORMATION_MESSAGE); }*/ else if (e.getSource() == settings) { Settings.frame.setLocation( frame.getLocationOnScreen().x + frame.getWidth() / 2 - Settings.frame.getWidth() / 2, frame.getLocationOnScreen().y + frame.getHeight() / 6); Settings.frame.setState(JFrame.NORMAL); Settings.frame.setVisible(true); } else if (e.getSource() == update) { try { Updater update = new Updater(); update.execute(); } catch (Exception ex) { ex.printStackTrace(); } } else if (e.getSource() == clearMemory) { FileRead.nullifyVarNodes(); //FileRead.removeNonListVariants();f System.gc(); chromDraw.repaint(); } else if (e.getSource() == zoomout) { zoomout(); } else if (e.getSource() == dosomething) { BedNode currentbed = bedCanvas.bedTrack.get(0).getHead().getNext(); VarNode currentvar = FileRead.head.getNext(); while (currentbed != null) { while (currentvar != null && currentvar.getPosition() < currentbed.getPosition()) { currentvar = currentvar.getNext(); } while (currentbed != null && currentvar.getPosition() > currentbed.getPosition() + currentbed.getLength()) { currentbed = currentbed.getNext(); } if (currentvar != null && currentvar.getPosition() >= currentbed.getPosition() && currentvar.getPosition() < currentbed.getPosition() + currentbed.getLength()) { currentvar.setBedhit(true); currentvar = currentvar.getNext(); } if (currentvar == null) { break; } currentbed = currentbed.getNext(); } } else if (e.getSource() == clear) { clearData(); } else if (e.getSource() == exit) { System.exit(0); } else if (e.getSource() == openbams) { try { if (!checkGenome()) return; if (VariantHandler.frame != null) { VariantHandler.frame.setState(Frame.ICONIFIED); } FileDialog fc = new FileDialog(frame, "Choose BAM file(s)", FileDialog.LOAD); fc.setDirectory(path); fc.setFile("*.bam;*.cram;*.link"); fc.setFilenameFilter(new FilenameFilter() { public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(".bam") || name.toLowerCase().endsWith(".cram") || name.toLowerCase().endsWith(".link"); } }); fc.setMultipleMode(true); fc.setVisible(true); File[] openfiles = fc.getFiles(); if (openfiles != null && openfiles.length > 0) { path = openfiles[0].getParent(); writeToConfig("DefaultDir=" + path); FileRead filereader = new FileRead(openfiles); filereader.start = (int) drawCanvas.selectedSplit.start; filereader.end = (int) drawCanvas.selectedSplit.end; filereader.readBAM = true; filereader.execute(); } else { //Main.showError("File(s) does not exist.", "Error"); } } catch (Exception ex) { Main.showError(ex.getMessage(), "Error"); } } else if (e.getSource() == openvcfs) { try { if (!checkGenome()) return; if (VariantHandler.frame != null) { VariantHandler.frame.setState(Frame.ICONIFIED); } FileDialog fc = new FileDialog(frame, "Choose VCF file(s)", FileDialog.LOAD); fc.setDirectory(path); fc.setFile("*.vcf"); fc.setFilenameFilter(new FilenameFilter() { public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(".vcf") || name.toLowerCase().endsWith(".vcf.gz"); } }); fc.setMultipleMode(true); fc.setVisible(true); File[] openfiles = fc.getFiles(); if (openfiles != null && openfiles.length > 0) { path = openfiles[0].getParent(); writeToConfig("DefaultDir=" + path); FileRead filereader = new FileRead(openfiles); filereader.start = (int) drawCanvas.selectedSplit.start; filereader.end = (int) drawCanvas.selectedSplit.end; filereader.readVCF = true; filereader.execute(); } else { //Main.showError("File(s) does not exist.", "Error"); } if (1 == 1) { return; } JFileChooser chooser = new JFileChooser(path); getText(chooser.getComponents()); chooser.setMultiSelectionEnabled(true); //chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setAcceptAllFileFilterUsed(false); chooser.addChoosableFileFilter(vcfFilter); chooser.addChoosableFileFilter(bamFilter); chooser.addChoosableFileFilter(linkFilter); if (defaultSelectType == "vcf") { chooser.setFileFilter(vcfFilter); } else if (defaultSelectType == "bam") { chooser.setFileFilter(bamFilter); } else { chooser.setFileFilter(linkFilter); } chooser.setDialogTitle("Add samples"); chooser.setPreferredSize( new Dimension((int) screenSize.getWidth() / 3, (int) screenSize.getHeight() / 3)); int returnVal = chooser.showOpenDialog((Component) this.getParent()); if (returnVal == JFileChooser.APPROVE_OPTION) { File vcffiles[] = chooser.getSelectedFiles(); if (vcffiles.length == 1 && !vcffiles[0].exists() && pleiades) { if (Main.chooserText.contains("`")) { Main.chooserText.replace("`", "?"); } if (Main.chooserText.contains(" ")) { Main.chooserText.replace(" ", "%20"); } if (Main.chooserText.contains("pleiades")) { try { URL url = new URL(Main.chooserText); //System.out.println(Main.chooserText); HttpURLConnection httpConn = (HttpURLConnection) url.openConnection(); httpConn.connect(); int responseCode = httpConn.getResponseCode(); if (responseCode == HttpsURLConnection.HTTP_OK) { String loading = drawCanvas.loadingtext; InputStream inputStream = httpConn.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); Main.drawCanvas.loadingtext = loading + " 0MB"; String line; StringBuffer buffer = new StringBuffer(""); while ((line = reader.readLine()) != null) { buffer.append(line); } inputStream.close(); reader.close(); String split2; String[] split = buffer.toString().split("dataUnit"); String location; ArrayList<File> array = new ArrayList<File>(); File[] paths; FileSystemView fsv = FileSystemView.getFileSystemView(); paths = File.listRoots(); String loc = "/mnt"; boolean missingfiles = false; for (File path : paths) { if (fsv.getSystemDisplayName(path).contains("merit")) { loc = path.getCanonicalPath(); } } for (int i = 0; i < split.length; i++) { if (!split[i].contains("lastLocation")) { continue; } split2 = split[i].split("\"lastLocation\":\"")[1]; location = split2.substring(0, split2.indexOf("\"}")); String filename = ""; String testloc = location.replace("/mnt", loc) + "/wgspipeline/"; File testDir = new File(testloc); if (testDir.exists() && testDir.isDirectory()) { if (chooser.getFileFilter() .equals(chooser.getChoosableFileFilters()[1])) { File[] addDir = testDir.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(".bam") || name.toLowerCase().endsWith(".cram"); } }); if (addDir.length > 0) { filename = addDir[0].getName(); } } else { File[] addDir = testDir.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(".vcf.gz"); } }); if (addDir.length > 0) { filename = addDir[0].getName(); } } } location = testloc + "/" + filename; if (!new File(location).exists()) { if (!new File(location).exists()) { missingfiles = true; ErrorLog.addError("No sample files found in " + testloc); } else { array.add(new File(location)); } } else { array.add(new File(location)); } } File[] files = new File[array.size()]; for (int i = 0; i < files.length; i++) { files[i] = array.get(i); } FileRead filereader = new FileRead(files); filereader.start = (int) drawCanvas.selectedSplit.start; filereader.end = (int) drawCanvas.selectedSplit.end; if (chooser.getFileFilter().equals(chooser.getChoosableFileFilters()[1])) { filereader.readBAM = true; } else { filereader.readVCF = true; } filereader.execute(); if (missingfiles) { JOptionPane.showMessageDialog(Main.drawScroll, "Missing files. Check Tools->View log", "Note", JOptionPane.INFORMATION_MESSAGE); } } } catch (Exception ex) { ex.printStackTrace(); } } return; } if (vcffiles.length > 0) { path = vcffiles[0].getParent(); writeToConfig("DefaultDir=" + path); FileRead filereader = new FileRead(vcffiles); if (chooser.getFileFilter().equals(chooser.getChoosableFileFilters()[0])) { defaultSelectType = "vcf"; filereader.start = (int) drawCanvas.selectedSplit.start; filereader.end = (int) drawCanvas.selectedSplit.end; filereader.readVCF = true; filereader.execute(); } else if (chooser.getFileFilter().equals(chooser.getChoosableFileFilters()[1])) { defaultSelectType = "bam"; filereader.readBAM = true; filereader.execute(); } else if (chooser.getFileFilter().equals(chooser.getChoosableFileFilters()[2])) { defaultSelectType = "link"; filereader.readBAM = true; filereader.execute(); } } else { JOptionPane.showMessageDialog(Main.drawScroll, "The file does not exist. The file link may be broken.\nThe problem may also be the Java run time version in Linux.", "Note", JOptionPane.INFORMATION_MESSAGE); } } } catch (Exception ex) { ex.printStackTrace(); } } else if (e.getSource() == addcontrols) { if (!checkGenome()) return; if (VariantHandler.frame != null) { VariantHandler.frame.setState(Frame.ICONIFIED); } FileDialog fc = new FileDialog(frame, "Choose control file(s)", FileDialog.LOAD); fc.setDirectory(Main.controlDir); fc.setFile("*.vcf.gz"); fc.setFilenameFilter(new FilenameFilter() { public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(".vcf.gz"); } }); fc.setMultipleMode(true); fc.setVisible(true); File[] openfiles = fc.getFiles(); if (openfiles != null && openfiles.length > 0) { controlDir = openfiles[0].getParent(); writeToConfig("DefaultControlDir=" + controlDir); Control.addFiles(openfiles); } if (1 == 1) { return; } JFileChooser chooser = new JFileChooser(controlDir); // JFileChooser chooser = new JFileChooser(path); chooser.setMultiSelectionEnabled(true); chooser.setAcceptAllFileFilterUsed(false); Control.MyFilter vcfFilter = new Control.MyFilter(); chooser.addChoosableFileFilter(vcfFilter); chooser.setDialogTitle("Add controls"); chooser.setPreferredSize( new Dimension((int) screenSize.getWidth() / 3, (int) screenSize.getHeight() / 3)); int returnVal = chooser.showOpenDialog((Component) this.getParent()); if (returnVal == JFileChooser.APPROVE_OPTION) { File vcffiles[] = chooser.getSelectedFiles(); controlDir = vcffiles[0].getParent(); writeToConfig("DefaultControlDir=" + controlDir); if (chooser.getFileFilter().equals(chooser.getChoosableFileFilters()[0])) { Control.addFiles(vcffiles); } } } else if (e.getSource() == addtracks) { if (!checkGenome()) return; try { if (!checkGenome()) return; if (VariantHandler.frame != null) { VariantHandler.frame.setState(Frame.ICONIFIED); } FileDialog fc = new FileDialog(frame, "Choose track file(s)", FileDialog.LOAD); fc.setDirectory(Main.trackDir); fc.setFile( "*.bed;*.bedgraph.gz;*.gff.gz;*.gff3.gz;*.bigwig;*.bw;*.bigbed;*.bb;*.tsv.gz;*.tsv.bgz;*.txt"); fc.setFilenameFilter(new FilenameFilter() { public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(".bed") || name.toLowerCase().endsWith(".bed.gz") || name.toLowerCase().endsWith(".bedgraph.gz") || name.toLowerCase().endsWith(".bedgraph.gz") || name.toLowerCase().endsWith(".bedgraph.gz") || name.toLowerCase().endsWith(".gff.gz") || name.toLowerCase().endsWith(".gff3.gz") || name.toLowerCase().endsWith(".bigwig") || name.toLowerCase().endsWith(".bw") || name.toLowerCase().endsWith(".bigbed") || name.toLowerCase().endsWith(".bb") || name.toLowerCase().endsWith(".tsv.gz") || name.toLowerCase().endsWith(".tsv.bgz") || name.toLowerCase().endsWith(".txt"); } }); fc.setMultipleMode(true); fc.setVisible(true); File[] openfiles = fc.getFiles(); if (openfiles != null && openfiles.length > 0) { trackDir = openfiles[0].getParent(); writeToConfig("DefaultTrackDir=" + trackDir); FileRead filereader = new FileRead(openfiles); filereader.readBED = true; filereader.execute(); } else { //Main.showError("File(s) does not exist.", "Error"); } } catch (Exception ex) { Main.showError(ex.getMessage(), "Error"); } if (1 == 1) { return; } if (VariantHandler.frame != null) { VariantHandler.frame.setState(Frame.ICONIFIED); } JFileChooser chooser = new JFileChooser(Main.trackDir); getText(chooser.getComponents()); chooser.setMultiSelectionEnabled(true); chooser.setAcceptAllFileFilterUsed(false); MyFilterBED bedFilter = new MyFilterBED(); MyFilterTXT txtFilter = new MyFilterTXT(); chooser.addChoosableFileFilter(bedFilter); chooser.addChoosableFileFilter(txtFilter); chooser.setDialogTitle("Add tracks"); chooser.setPreferredSize( new Dimension((int) screenSize.getWidth() / 3, (int) screenSize.getHeight() / 3)); int returnVal = chooser.showOpenDialog((Component) this.getParent()); try { if (returnVal == JFileChooser.APPROVE_OPTION) { File bedfiles[] = chooser.getSelectedFiles(); if (bedfiles[0].exists()) { trackDir = bedfiles[0].getParent(); writeToConfig("DefaultTrackDir=" + trackDir); FileRead filereader = new FileRead(bedfiles); filereader.readBED(bedfiles); } else { if (Main.chooserText.length() > 5 && Main.chooserText.endsWith(".bed.gz") || Main.chooserText.endsWith(".gff.gz") || Main.chooserText.endsWith(".gff3.gz") || Main.chooserText.endsWith(".bedgraph.gz")) { if (Main.chooserText.startsWith("http://") || Main.chooserText.startsWith("ftp://")) { URL url = new URL(Main.chooserText); SeekableStream stream = SeekableStreamFactory.getInstance().getStreamFor(url); TabixReader tabixReader = null; String index = null; try { tabixReader = new TabixReader(Main.chooserText, Main.chooserText + ".tbi", stream); index = Main.chooserText + ".tbi"; } catch (Exception ex) { try { tabixReader = new TabixReader(Main.chooserText, Main.chooserText.substring(0, Main.chooserText.indexOf(".gz")) + ".tbi", stream); index = Main.chooserText.substring(0, Main.chooserText.indexOf(".gz")) + ".tbi"; } catch (Exception exc) { exc.printStackTrace(); } } if (tabixReader != null && index != null) { FileRead filereader = new FileRead(bedfiles); filereader.readBED(Main.chooserText, index, false); tabixReader.close(); } } } else { if (Main.chooserText.contains("://")) { try { // bbreader = new BBFileReader(Main.chooserText, stream); } catch (Exception ex) { ex.printStackTrace(); } // if(bbreader != null) { FileRead filereader = new FileRead(bedfiles); filereader.readBED(Main.chooserText, "nan", false); // } // stream.close(); } } } } } catch (Exception ex) { ex.printStackTrace(); } } else if (e.getSource() == openProject) { if (!checkGenome()) return; if (VariantHandler.frame != null) { VariantHandler.frame.setState(Frame.ICONIFIED); } openProject(); } else if (e.getSource() == saveProjectAs) { if (VariantHandler.frame != null) { VariantHandler.frame.setState(Frame.ICONIFIED); } try { File savefile = null; FileDialog fs = new FileDialog(frame, "Save project as...", FileDialog.SAVE); fs.setDirectory(projectDir); fs.setFile("*.ses"); fs.setFilenameFilter(new FilenameFilter() { public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(".ses"); } }); fs.setVisible(true); while (true) { String filename = fs.getFile(); if (filename != null) { savefile = new File(fs.getDirectory() + "/" + filename); projectDir = fs.getDirectory(); writeToConfig("DefaultProjectDir=" + projectDir); /* if(!Files.isWritable(Paths.get(savefile.getParent()))) { Main.showError("No permission to write.", "Error"); continue; }*/ if (!savefile.getAbsolutePath().endsWith(".ses")) { savefile = new File(savefile.getAbsolutePath() + ".ses"); } Serializer ser = new Serializer(); ser.serialize(savefile); break; } else { break; } } if (1 == 1) { return; } JFileChooser chooser = new JFileChooser(); chooser.setAcceptAllFileFilterUsed(false); MyFilterSES sesFilter = new MyFilterSES(); chooser.addChoosableFileFilter(sesFilter); chooser.setDialogTitle("Save project as..."); int returnVal = chooser.showSaveDialog((Component) this.getParent()); if (returnVal == JFileChooser.APPROVE_OPTION) { File outfile = chooser.getSelectedFile(); if (!outfile.getAbsolutePath().endsWith(".ses")) { outfile = new File(outfile.getAbsolutePath() + ".ses"); } Serializer ser = new Serializer(); ser.serialize(outfile); } } catch (Exception ex) { ex.printStackTrace(); } } else if (e.getSource() == saveProject) { if (drawCanvas.drawVariables.projectName.equals("Untitled")) { saveProjectAs.doClick(); } else { Serializer ser = new Serializer(); ser.serialize(drawCanvas.drawVariables.projectFile); } } /* else if(e.getSource() == welcome) { WelcomeScreen.main(args); WelcomeScreen.frame.setVisible(true); WelcomeScreen.frame.setLocation(frame.getLocationOnScreen().x+frame.getWidth()/2 - WelcomeScreen.frame.getWidth()/2, frame.getLocationOnScreen().y+frame.getHeight()/6); }*/ }
From source file:op.tools.SYSTools.java
public static File[] chooseFile(Component parent, boolean multiselection) { File[] result = null;//from w ww .ja v a 2 s.co m String cname = parent.getClass().getName(); String startdir = System.getProperty("user.home"); if (OPDE.getProps().containsKey("DIR." + cname)) { startdir = OPDE.getProps().getProperty("DIR." + cname); } JFileChooser jfc = new JFileChooser(startdir); jfc.setMultiSelectionEnabled(multiselection); int response = jfc.showOpenDialog(parent); if (response == JFileChooser.APPROVE_OPTION) { if (multiselection) { result = jfc.getSelectedFiles(); } else { result = new File[] { jfc.getSelectedFile() }; } //String newPath = result[0].getAbsolutePath(); String myPath = result[0].getParent(); SYSPropsTools.storeProp("DIR." + cname, myPath, OPDE.getLogin().getUser()); } return result; }
From source file:org.domainmath.gui.MainFrame.java
/** * Creates file chooser dialog box and allows the user to select files * and importData selected files in fileTab. *///from www . j a va2s . c o m public void open() { JFileChooser fc = new JFileChooser(); // set current directory. if (fileTab.getTabCount() > 0) { File f = new File(fileTab.getToolTipTextAt(fileTab.getSelectedIndex())); fc.setCurrentDirectory(f.getParentFile()); } else { fc.setCurrentDirectory(new File(System.getProperty("user.dir") + File.separator + "works")); } FileNameExtensionFilter filter = new FileNameExtensionFilter("M-Files (*.m)", "m"); fc.setAcceptAllFileFilterUsed(false); fc.setFileFilter(filter); fc.setMultiSelectionEnabled(true); fc.setFileView(new ScriptFileView()); File file1[]; int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { file1 = fc.getSelectedFiles(); this.setCurrentDirFileTab(fc.getCurrentDirectory().getAbsolutePath()); for (int i = 0; i < file1.length; i++) { if (!fileNameList.contains(file1[i].getAbsolutePath())) { open(file1[i], i); } else { System.out.println(file1[i].getAbsolutePath() + " already open!"); } } } }
From source file:org.eurocarbdb.application.glycoworkbench.plugin.s3.Cockpit.java
/** * Event handler for this application, handles all menu items. *//* w ww. j av a 2 s .c o m*/ public void actionPerformed(ActionEvent event) { // Service Menu Events if ("LoginEvent".equals(event.getActionCommand())) { loginEvent(null); } else if ("LogoutEvent".equals(event.getActionCommand())) { logoutEvent(); } else if (event.getActionCommand() != null && event.getActionCommand().startsWith("LoginSwitch")) { String loginName = event.getActionCommand().substring("LoginSwitch:".length()); AWSCredentials awsCredentials = (AWSCredentials) loginAwsCredentialsMap.get(loginName); loginEvent(awsCredentials); } else if ("QuitEvent".equals(event.getActionCommand())) { System.exit(0); } // Bucket Events. else if ("ViewBucketProperties".equals(event.getActionCommand())) { listBucketProperties(); } else if ("RefreshBuckets".equals(event.getActionCommand())) { listAllBuckets(); } else if ("CreateBucket".equals(event.getActionCommand())) { createBucketAction(); } else if ("DeleteBucket".equals(event.getActionCommand())) { deleteSelectedBucket(); } else if ("ManageDistributions".equals(event.getActionCommand())) { S3Bucket[] buckets = bucketTableModel.getBuckets(); String[] bucketNames = new String[buckets.length]; for (int i = 0; i < buckets.length; i++) { bucketNames[i] = buckets[i].getName(); } ManageDistributionsDialog.showDialog(ownerFrame, cloudFrontService, bucketNames, this); } else if ("AddThirdPartyBucket".equals(event.getActionCommand())) { addThirdPartyBucket(); } else if ("UpdateBucketACL".equals(event.getActionCommand())) { updateBucketAccessControlList(); } else if ("UpdateBucketRequesterPaysStatus".equals(event.getActionCommand())) { updateBucketRequesterPaysSetting(); } // Object Events else if ("ViewOrModifyObjectAttributes".equals(event.getActionCommand())) { displayObjectsAttributesDialog(); } else if ("CopyObjects".equals(event.getActionCommand())) { copyObjects(); } else if ("RefreshObjects".equals(event.getActionCommand())) { listObjects(); } else if ("UpdateObjectACL".equals(event.getActionCommand())) { displayAclModificationDialog(); } else if ("GeneratePublicGetURLs".equals(event.getActionCommand())) { generatePublicGetUrls(); } else if ("GenerateTorrentURL".equals(event.getActionCommand())) { generateTorrentUrl(); } else if ("DeleteObjects".equals(event.getActionCommand())) { deleteSelectedObjects(); } else if ("DownloadObjects".equals(event.getActionCommand())) { downloadSelectedObjects(); } else if ("UploadFiles".equals(event.getActionCommand())) { JFileChooser fileChooser = new JFileChooser(); fileChooser.setMultiSelectionEnabled(true); fileChooser.setDialogTitle("Choose files to upload"); fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); fileChooser.setApproveButtonText("Upload files"); fileChooser.setCurrentDirectory(fileChoosersLastUploadDirectory); int returnVal = fileChooser.showOpenDialog(ownerFrame); if (returnVal != JFileChooser.APPROVE_OPTION) { return; } final File[] uploadFiles = fileChooser.getSelectedFiles(); if (uploadFiles.length == 0) { return; } // Save the chosen directory location for next time. fileChoosersLastUploadDirectory = uploadFiles[0].getParentFile(); uploadFiles(uploadFiles); } else if (event.getSource().equals(filterObjectsCheckBox)) { if (filterObjectsCheckBox.isSelected()) { filterObjectsPanel.setVisible(true); } else { filterObjectsPanel.setVisible(false); filterObjectsPrefix.setText(""); if (filterObjectsDelimiter.getSelectedIndex() != 0) { filterObjectsDelimiter.setSelectedIndex(0); } } } // Tools events else if ("BucketLogging".equals(event.getActionCommand())) { S3Bucket[] buckets = bucketTableModel.getBuckets(); BucketLoggingDialog.showDialog(ownerFrame, s3ServiceMulti.getS3Service(), buckets, this); } // Preference Events else if ("PreferencesDialog".equals(event.getActionCommand())) { PreferencesDialog.showDialog(cockpitPreferences, ownerFrame, this); // Save a user's preferences if requested, otherwise wipe any existing preferences file. File cockpitPreferencesPropertiesFile = new File(cockpitHomeDirectory, Constants.COCKPIT_PROPERTIES_FILENAME); if (cockpitPreferences.isRememberPreferences()) { try { Properties properties = cockpitPreferences.toProperties(); if (!cockpitHomeDirectory.exists()) { cockpitHomeDirectory.mkdir(); } properties.list(new PrintStream(new FileOutputStream(cockpitPreferencesPropertiesFile))); } catch (IOException e) { String message = "Unable to save your preferences"; log.error(message, e); ErrorDialog.showDialog(ownerFrame, this, message, e); } } else if (cockpitPreferencesPropertiesFile.exists()) { // User elected not to store preferences, delete the existing preferences file. cockpitPreferencesPropertiesFile.delete(); } if (cockpitPreferences.isEncryptionPasswordSet()) { try { encryptionUtil = new EncryptionUtil(cockpitPreferences.getEncryptionPassword(), cockpitPreferences.getEncryptionAlgorithm(), EncryptionUtil.DEFAULT_VERSION); } catch (Exception e) { String message = "Unable to start encryption utility"; log.error(message, e); ErrorDialog.showDialog(ownerFrame, this, message, e); } } else { encryptionUtil = null; } } // Ooops... else { log.debug("Unrecognised ActionEvent command '" + event.getActionCommand() + "' in " + event); } }
From source file:org.javaswift.cloudie.CloudiePanel.java
protected void onCreateStoredObject() { Container container = getSelectedContainer(); JFileChooser chooser = new JFileChooser(); chooser.setMultiSelectionEnabled(true); chooser.setCurrentDirectory(lastFolder); if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { File[] selectedFiles = chooser.getSelectedFiles(); ops.createStoredObjects(container, selectedFiles, callback); lastFolder = chooser.getCurrentDirectory(); }//from ww w . ja va2s. co m }
From source file:org.jax.haplotype.io.SnpStreamUtil.java
/** * A main for snp data conversion/*from w w w . jav a 2s . com*/ * @param args * dont care * @throws IOException * if we get one */ public static void main(String[] args) throws IOException { JFileChooser inputFileChooser = new JFileChooser(); inputFileChooser.setDialogTitle("Select CSV Chromosome Input Files"); inputFileChooser.setMultiSelectionEnabled(true); inputFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); int userSelection = inputFileChooser.showOpenDialog(null); if (userSelection == JFileChooser.APPROVE_OPTION) { JFileChooser outputDirectoryChooser = new JFileChooser(); outputDirectoryChooser.setDialogTitle("Select an Output Directory"); outputDirectoryChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int outputUserSelection = outputDirectoryChooser.showOpenDialog(null); if (outputUserSelection == JFileChooser.APPROVE_OPTION) { File selectedOutputDirectory = outputDirectoryChooser.getSelectedFile(); File[] selectedInputFiles = inputFileChooser.getSelectedFiles(); for (File selectedInputFile : selectedInputFiles) { writeBinaryChromosomeData(new GenotypeParser(), selectedInputFile, selectedOutputDirectory); } } } else { System.out.println("user doesn't want to open the file"); } }
From source file:org.jets3t.apps.cockpitlite.CockpitLite.java
/** * Event handler for this application, handles all menu items. *///from www . j a v a 2s . c om public void actionPerformed(ActionEvent event) { if (event.getSource().equals(loginButton)) { new Thread() { @Override public void run() { listObjects(); } }.start(); } // Object Events else if ("ViewObjectProperties".equals(event.getActionCommand())) { listObjectProperties(); } else if ("RefreshObjects".equals(event.getActionCommand())) { new Thread() { @Override public void run() { listObjects(); } }.start(); } else if ("TogglePublicPrivate".equals(event.getActionCommand())) { new Thread() { @Override public void run() { S3Object object = getSelectedObjects()[0]; String aclStatus = objectTableModel.getObjectAclStatus(object); boolean originalAclWasPublic = ACL_PUBLIC_DESCRIPTION.equals(aclStatus); ToggleAclDialog dialog = new ToggleAclDialog(ownerFrame, originalAclWasPublic, null, cockpitLiteProperties.getProperties()); dialog.setVisible(true); // Update ACL setting. S3Object minimalObject = new S3Object(object.getKey()); AccessControlList newAcl = (dialog.isPublicAclSet() ? AccessControlList.REST_CANNED_PUBLIC_READ : AccessControlList.REST_CANNED_PRIVATE); if (newAcl != null) { if (AccessControlList.REST_CANNED_PRIVATE.equals(newAcl)) { minimalObject.addMetadata(Constants.REST_HEADER_PREFIX + "acl", "private"); } else if (AccessControlList.REST_CANNED_PUBLIC_READ.equals(newAcl)) { minimalObject.addMetadata(Constants.REST_HEADER_PREFIX + "acl", "public-read"); } } updateObjectsAccessControlLists(new S3Object[] { minimalObject }, newAcl); dialog.dispose(); } }.start(); } else if ("GeneratePublicGetURL".equals(event.getActionCommand())) { generatePublicGetUrl(); } else if ("DeleteObjects".equals(event.getActionCommand())) { deleteSelectedObjects(); } else if ("DownloadObjects".equals(event.getActionCommand())) { try { downloadSelectedObjects(); } catch (Exception ex) { String message = "Unable to download objects from S3"; log.error(message, ex); ErrorDialog.showDialog(ownerFrame, this, cockpitLiteProperties.getProperties(), message, ex); } } else if ("UploadFiles".equals(event.getActionCommand())) { JFileChooser fileChooser = new JFileChooser(); fileChooser.setMultiSelectionEnabled(true); fileChooser.setDialogTitle("Choose file(s) to upload"); fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); fileChooser.setApproveButtonText("Upload files"); fileChooser.setCurrentDirectory(fileChoosersLastUploadDirectory); int returnVal = fileChooser.showOpenDialog(ownerFrame); if (returnVal != JFileChooser.APPROVE_OPTION) { return; } final File[] uploadFiles = fileChooser.getSelectedFiles(); if (uploadFiles.length == 0) { return; } // Save the chosen directory location for next time. fileChoosersLastUploadDirectory = uploadFiles[0].getParentFile(); new Thread() { @Override public void run() { prepareForFilesUpload(uploadFiles); } }.start(); } else if (event.getSource().equals(filterObjectsCheckBox)) { if (filterObjectsCheckBox.isSelected()) { filterObjectsPanel.setVisible(true); } else { filterObjectsPanel.setVisible(false); filterObjectsPrefix.setText(""); } } // Ooops... else { log.warn("Unrecognised ActionEvent command '" + event.getActionCommand() + "' in " + event); } }
From source file:org.ohdsi.whiteRabbit.WhiteRabbitMain.java
private void pickTables() { DbSettings sourceDbSettings = getSourceDbSettings(); if (sourceDbSettings != null) { if (sourceDbSettings.dataType == DbSettings.CSVFILES) { JFileChooser fileChooser = new JFileChooser(new File(folderField.getText())); fileChooser.setMultiSelectionEnabled(true); fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); FileNameExtensionFilter filter = new FileNameExtensionFilter("Delimited text files", "csv", "txt"); fileChooser.setFileFilter(filter); int returnVal = fileChooser.showDialog(frame, "Select tables"); if (returnVal == JFileChooser.APPROVE_OPTION) { for (File table : fileChooser.getSelectedFiles()) { String tableName = DirectoryUtilities.getRelativePath(new File(folderField.getText()), table);//from w w w.j a va2s . c o m if (!tables.contains(tableName)) tables.add(tableName); tableList.setListData(tables); } } } else if (sourceDbSettings.dataType == DbSettings.DATABASE) { RichConnection connection = new RichConnection(sourceDbSettings.server, sourceDbSettings.domain, sourceDbSettings.user, sourceDbSettings.password, sourceDbSettings.dbType); String tableNames = StringUtilities.join(connection.getTableNames(sourceDbSettings.database), "\t"); if (tableNames.length() == 0) { JOptionPane.showMessageDialog(frame, "No tables found in database " + sourceDbSettings.database, "Error fetching table names", JOptionPane.ERROR_MESSAGE); } else { DBTableSelectionDialog selectionDialog = new DBTableSelectionDialog(frame, true, tableNames); if (selectionDialog.getAnswer()) { for (Object item : selectionDialog.getSelectedItems()) { if (!tables.contains(item)) tables.add((String) item); tableList.setListData(tables); } } } connection.close(); } } }
From source file:org.photovault.swingui.BrowserWindow.java
/** Shows an file selection dialog that allows user to select a file to import. After that shows the PhotoInfo dialog to allow the user to edit the eriginal information about the file. *//*from w w w . j a v a2 s .c om*/ protected void importFile() { // Show the file chooser dialog JFileChooser fc = new JFileChooser(); fc.addChoosableFileFilter(new ImageFilter()); fc.setAccessory(new ImagePreview(fc)); fc.setMultiSelectionEnabled(true); int retval = fc.showDialog(window, "Import"); if (retval == JFileChooser.APPROVE_OPTION) { // Add the selected file to the database and allow user to edit its attributes final File[] files = fc.getSelectedFiles(); final ProgressDlg pdlg = new ProgressDlg(window, true); // Add all the selected files to DB final PhotoInfo[] photos = new PhotoInfo[files.length]; Thread importThread = new Thread() { @Override public void run() { for (int n = 0; n < files.length; n++) { try { photos[n] = PhotoInfo.addToDB(files[n]); pdlg.setProgressPercent((n * 100) / files.length); pdlg.setStatus("" + (n + 1) + " of " + files.length + " files imported."); } catch (Exception e) { log.error("Unexpected exception: " + e.getMessage()); } } pdlg.completed(); } }; importThread.start(); pdlg.setVisible(true); // Show editor dialog for the added photos // PhotoInfoDlg dlg = new PhotoInfoDlg( window, false, photos ); PhotoInfoDlg dlg = null; dlg.showDialog(); } }
From source file:org.thelq.stackexchange.dbimport.gui.GUI.java
public GUI(Controller passedController) { //Initialize logger logAppender = new GUILogAppender(this); //Set our Look&Feel try {//from w w w. ja va 2s.c om if (SystemUtils.IS_OS_WINDOWS) UIManager.setLookAndFeel(new WindowsLookAndFeel()); else UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { log.warn("Defaulting to Swing L&F due to exception", e); } this.controller = passedController; frame = new JFrame(); frame.setTitle("Unified StackExchange Data Dump Importer v" + Controller.VERSION); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); //Setup menu JMenuBar menuBar = new JMenuBar(); menuAdd = new JMenuItem("Add Folders/Archives"); menuAdd.setMnemonic(KeyEvent.VK_F); menuBar.add(menuAdd); frame.setJMenuBar(menuBar); //Primary panel FormLayout primaryLayout = new FormLayout("5dlu, pref:grow, 5dlu, 5dlu, pref", "pref, top:pref, pref, fill:140dlu:grow, pref, fill:80dlu"); PanelBuilder primaryBuilder = new PanelBuilder(primaryLayout) .border(BorderFactory.createEmptyBorder(5, 5, 5, 5)); //DB Config panel primaryBuilder.addSeparator("Database Configuration", CC.xyw(1, 1, 2)); FormLayout configLayout = new FormLayout("pref, 3dlu, pref:grow, 6dlu, pref", "pref, pref:grow, 3dlu, pref:grow, 3dlu, pref:grow, 3dlu, pref:grow, 3dlu, pref:grow, 3dlu, pref:grow"); configLayout.setHonorsVisibility(true); final PanelBuilder configBuilder = new PanelBuilder(configLayout); configBuilder.addLabel("Server", CC.xy(1, 2), dbType = new JComboBox<DatabaseOption>(), CC.xy(3, 2)); configBuilder.add(dbAdvanced = new JCheckBox("Show advanced options"), CC.xy(5, 2)); configBuilder.addLabel("JDBC Connection", CC.xy(1, 4), jdbcString = new JTextField(15), CC.xyw(3, 4, 3)); configBuilder.addLabel("Username", CC.xy(1, 6), username = new JTextField(10), CC.xy(3, 6)); configBuilder.addLabel("Password", CC.xy(1, 8), password = new JPasswordField(10), CC.xy(3, 8)); configBuilder.add(importButton = new JButton("Import"), CC.xywh(5, 6, 1, 3)); //Add hidden JLabel dialectLabel = new JLabel("Dialect"); dialectLabel.setVisible(false); configBuilder.add(dialectLabel, CC.xy(1, 10), dialect = new JTextField(10), CC.xyw(3, 10, 3)); dialect.setVisible(false); JLabel driverLabel = new JLabel("Driver"); driverLabel.setVisible(false); configBuilder.add(driverLabel, CC.xy(1, 12), driver = new JTextField(10) { @Override public void setText(String text) { if (StringUtils.isBlank(text)) log.debug("Text is blank", new RuntimeException("Text " + text + " is blank")); super.setText(text); } }, CC.xyw(3, 12, 3)); driver.setVisible(false); primaryBuilder.add(configBuilder.getPanel(), CC.xy(2, 2)); //Options primaryBuilder.addSeparator("Options", CC.xyw(4, 1, 2)); FormLayout optionsLayout = new FormLayout("pref, 3dlu, pref:grow", ""); DefaultFormBuilder optionsBuilder = new DefaultFormBuilder(optionsLayout); optionsBuilder.append(disableCreateTables = new JCheckBox("Disable Creating Tables"), 3); optionsBuilder.append("Global Table Prefix", globalTablePrefix = new JTextField(7)); optionsBuilder.append("Threads", threads = new JSpinner()); //Save a core for the database int numThreads = Runtime.getRuntime().availableProcessors(); numThreads = (numThreads != 1) ? numThreads - 1 : numThreads; threads.setModel(new SpinnerNumberModel(numThreads, 1, 100, 1)); optionsBuilder.append("Batch Size", batchSize = new JSpinner()); batchSize.setModel(new SpinnerNumberModel(500, 1, 500000, 1)); primaryBuilder.add(optionsBuilder.getPanel(), CC.xy(5, 2)); //Locations primaryBuilder.addSeparator("Dump Locations", CC.xyw(1, 3, 5)); FormLayout locationsLayout = new FormLayout("pref, 15dlu, pref, 5dlu, pref, 5dlu, pref:grow, 2dlu, pref", ""); locationsBuilder = new DefaultFormBuilder(locationsLayout, new ScrollablePanel()).background(Color.WHITE) .lineGapSize(Sizes.ZERO); locationsPane = new JScrollPane(locationsBuilder.getPanel()); locationsPane.getViewport().setBackground(Color.white); locationsPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); locationsPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); primaryBuilder.add(locationsPane, CC.xyw(2, 4, 4)); //Logger primaryBuilder.addSeparator("Log", CC.xyw(1, 5, 5)); loggerText = new JTextPane(); loggerText.setEditable(false); JPanel loggerTextPanel = new JPanel(new BorderLayout()); loggerTextPanel.add(loggerText); JScrollPane loggerPane = new JScrollPane(loggerTextPanel); loggerPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); loggerPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); JPanel loggerPanePanel = new JPanel(new BorderLayout()); loggerPanePanel.add(loggerPane); primaryBuilder.add(loggerPanePanel, CC.xyw(2, 6, 4)); menuAdd.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { //TODO: Allow 7z files but handle corner cases final JFileChooser fc = new JFileChooser(); fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); fc.setMultiSelectionEnabled(true); fc.setDialogTitle("Select Folders/Archives"); fc.addChoosableFileFilter(new FileNameExtensionFilter("Archives", "7z", "zip")); fc.addChoosableFileFilter(new FileFilter() { @Getter protected String description = "Folders"; @Override public boolean accept(File file) { return file.isDirectory(); } }); if (fc.showOpenDialog(frame) != JFileChooser.APPROVE_OPTION) return; //Add files and folders in a seperate thread while updating gui in EDT importButton.setEnabled(false); for (File curFile : fc.getSelectedFiles()) { DumpContainer dumpContainer = null; try { if (curFile.isDirectory()) dumpContainer = new FolderDumpContainer(curFile); else dumpContainer = new ArchiveDumpContainer(controller, curFile); controller.addDumpContainer(dumpContainer); } catch (Exception ex) { String type = (dumpContainer != null) ? dumpContainer.getType() : ""; LoggerFactory.getLogger(getClass()).error("Cannot open " + type, ex); String location = (dumpContainer != null) ? Utils.getLongLocation(dumpContainer) : ""; showErrorDialog(ex, "Cannot open " + location, curFile.getAbsolutePath()); continue; } } updateLocations(); importButton.setEnabled(true); } }); //Add options (Could be in a map, but this is cleaner) dbType.addItem(new DatabaseOption().name("MySQL 5.5.3+") .jdbcString("jdbc:mysql://127.0.0.1:3306/stackexchange?rewriteBatchedStatements=true") .dialect("org.hibernate.dialect.MySQL5Dialect").driver("com.mysql.jdbc.Driver")); dbType.addItem(new DatabaseOption().name("PostgreSQL 8.1") .jdbcString("jdbc:postgresql://127.0.0.1:5432/stackexchange") .dialect("org.hibernate.dialect.PostgreSQL81Dialect").driver("org.postgresql.Driver")); dbType.addItem(new DatabaseOption().name("PostgreSQL 8.2+") .jdbcString("jdbc:postgresql://127.0.0.1:5432/stackexchange") .dialect("org.hibernate.dialect.PostgreSQL82Dialect").driver("org.postgresql.Driver")); dbType.addItem(new DatabaseOption().name("SQL Server") .jdbcString("jbdc:jtds:mssql://127.0.0.1:1433/stackexchange") .dialect("org.hibernate.dialect.SQLServerDialect").driver("net.sourceforge.jtds.jdbc.Driver")); dbType.addItem(new DatabaseOption().name("SQL Server 2005+") .jdbcString("jbdc:jtds:mssql://127.0.0.1:1433/stackexchange") .dialect("org.hibernate.dialect.SQLServer2005Dialect").driver("net.sourceforge.jtds.jdbc.Driver")); dbType.addItem(new DatabaseOption().name("SQL Server 2008+") .jdbcString("jbdc:jtds:mssql://127.0.0.1:1433/stackexchange") .dialect("org.hibernate.dialect.SQLServer2008Dialect").driver("net.sourceforge.jtds.jdbc.Driver")); dbType.addItem(new DatabaseOption().name("H2").jdbcString("jdbc:h2:stackexchange") .dialect("org.hibernate.dialect.H2Dialect").driver("org.h2.Driver")); dbType.setSelectedItem(null); dbType.addItemListener(new ItemListener() { boolean shownMysqlWarning = false; public void itemStateChanged(ItemEvent e) { //Don't run this twice for a single select if (e.getStateChange() == ItemEvent.DESELECTED) return; DatabaseOption selectedOption = (DatabaseOption) dbType.getSelectedItem(); if (selectedOption.name().startsWith("MySQL") && !shownMysqlWarning) { //Hide popup so you don't have to click twice on the dialog dbType.setPopupVisible(false); JOptionPane.showMessageDialog(frame, "Warning: Your server must be configured with character_set_server=utf8mb4" + "\nOtherwise, data dumps that contain 4 byte UTF-8 characters will fail", "MySQL Warning", JOptionPane.WARNING_MESSAGE); shownMysqlWarning = true; } setDbOption(selectedOption); } }); //Show and hide advanced options with checkbox dbAdvanced.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { boolean selected = ((JCheckBox) e.getSource()).isSelected(); driver.setVisible(selected); ((JLabel) driver.getClientProperty("labeledBy")).setVisible(selected); dialect.setVisible(selected); ((JLabel) dialect.getClientProperty("labeledBy")).setVisible(selected); } }); importButton.addActionListener(new ActionListener() { protected void showImportError(String error) { JOptionPane.showMessageDialog(frame, error, "Configuration Error", JOptionPane.ERROR_MESSAGE); } protected void showInputErrorDatabase(String error) { if (dbType.getSelectedItem() == null) showImportError("No dbType specified, " + StringUtils.uncapitalize(error)); else showImportError(error); } public void actionPerformed(ActionEvent e) { boolean validationPassed = false; if (controller.getDumpContainers().isEmpty()) showImportError("Please add dump folders/archives"); else if (StringUtils.isBlank(jdbcString.getText())) showInputErrorDatabase("Must specify JDBC String"); else if (StringUtils.isBlank(driver.getText())) showInputErrorDatabase("Must specify driver"); else if (StringUtils.isBlank(dialect.getText())) showInputErrorDatabase("Must specify hibernate dialect"); else validationPassed = true; if (!validationPassed) return; //Disable all GUI components so they can't change anything during processing setGuiEnabled(false); //Run in new thread controller.getGeneralThreadPool().execute(new Runnable() { public void run() { try { start(); } catch (final Exception e) { //Show an error message box SwingUtilities.invokeLater(new Runnable() { public void run() { LoggerFactory.getLogger(getClass()).error("Cannot import", e); showErrorDialog(e, "Cannot import", null); } }); } //Renable GUI SwingUtilities.invokeLater(new Runnable() { public void run() { setGuiEnabled(true); } }); } }); } }); //Done, init logger logAppender.init(); log.info("Finished creating GUI"); //Display frame.setContentPane(primaryBuilder.getPanel()); frame.pack(); frame.setMinimumSize(frame.getSize()); frame.setVisible(true); }