List of usage examples for javax.swing JOptionPane ERROR_MESSAGE
int ERROR_MESSAGE
To view the source code for javax.swing JOptionPane ERROR_MESSAGE.
Click Source Link
From source file:fi.smaa.jsmaa.gui.JSMAAMainFrame.java
private boolean trySaveModel(File file) { try {/*from w w w .j ava 2s. com*/ FileOutputStream fos = new FileOutputStream(file); JSMAABinding.writeModel(modelManager.getModel(), new BufferedOutputStream(fos)); fos.close(); modelManager.setSaved(true); return true; } catch (Exception e) { JOptionPane.showMessageDialog(this, "Error saving model to " + getCanonicalPath(file) + ", " + e.getMessage(), "Save error", JOptionPane.ERROR_MESSAGE); return false; } }
From source file:com.documentgenerator.view.MainWindow.java
public void generateReport() { if (DocumentCollector.getNameDetails() == null) { JOptionPane.showMessageDialog(null, "Please Submit the Name Details", "Error Message", JOptionPane.ERROR_MESSAGE); return;/*from w w w.j av a 2 s. co m*/ } if (DocumentCollector.getScheduleDetails() == null) { JOptionPane.showMessageDialog(null, "Please Submit the Schedule Details", "Error Message", JOptionPane.ERROR_MESSAGE); return; } if (DocumentCollector.getTabelDetails() == null) { JOptionPane.showMessageDialog(null, "Please Submit the Document Table Details", "Error Message", JOptionPane.ERROR_MESSAGE); return; } String path = WindowUtils.getDocumentPapth() + "\\dg.rtf"; try { Print.generate(path); } catch (Exception ex) { Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex); JOptionPane.showMessageDialog(null, ex, "Error Message", JOptionPane.ERROR_MESSAGE); } }
From source file:co.com.soinsoftware.hotelero.view.JFRoomPayment.java
private boolean validateDataForSave() { boolean valid = true; final Invoice invoice = this.getInvoiceSelected(); final InvoiceStatus status = this.getInvoiceStatusSelected(); if (invoice == null) { valid = false;//from w ww .j a v a2 s . c o m ViewUtils.showMessage(this, MSG_ROOM_REQUIRED, ViewUtils.TITLE_REQUIRED_FIELDS, JOptionPane.ERROR_MESSAGE); } else if (status.getName().equals("Sin pago")) { valid = false; ViewUtils.showMessage(this, MSG_INVOICE_STATUS_REQUIRED, ViewUtils.TITLE_REQUIRED_FIELDS, JOptionPane.ERROR_MESSAGE); } return valid; }
From source file:net.sf.jabref.importer.fetcher.ACMPortalFetcher.java
@Override public boolean processQueryGetPreview(String query, FetcherPreviewDialog preview, OutputPrinter status) { this.terms = query; piv = 0;//from w w w . ja va2 s .co m shouldContinue = true; acmOrGuide = acmButton.isSelected(); fetchAbstract = absCheckBox.isSelected(); String address = makeUrl(); LinkedHashMap<String, JLabel> previews = new LinkedHashMap<>(); try { URLDownload dl = new URLDownload(address); String page = dl.downloadToString(Globals.prefs.getDefaultEncoding()); int hits = getNumberOfHits(page, RESULTS_FOUND_PATTERN, ACMPortalFetcher.HITS_PATTERN); int index = page.indexOf(RESULTS_FOUND_PATTERN); if (index >= 0) { page = page.substring(index + RESULTS_FOUND_PATTERN.length()); } if (hits == 0) { status.showMessage(Localization.lang("No entries found for the search string '%0'", terms), Localization.lang("Search %0", getTitle()), JOptionPane.INFORMATION_MESSAGE); return false; } else if (hits > 20) { status.showMessage( Localization.lang("%0 entries found. To reduce server load, only %1 will be downloaded.", String.valueOf(hits), String.valueOf(PER_PAGE)), Localization.lang("Search %0", getTitle()), JOptionPane.INFORMATION_MESSAGE); } hits = getNumberOfHits(page, PAGE_RANGE_PATTERN, ACMPortalFetcher.MAX_HITS_PATTERN); parse(page, Math.min(hits, PER_PAGE), previews); for (Map.Entry<String, JLabel> entry : previews.entrySet()) { preview.addEntry(entry.getKey(), entry.getValue()); } return true; } catch (MalformedURLException e) { LOGGER.warn("Problem with ACM fetcher URL", e); } catch (ConnectException e) { status.showMessage(Localization.lang("Could not connect to %0", getTitle()), Localization.lang("Search %0", getTitle()), JOptionPane.ERROR_MESSAGE); LOGGER.warn("Problem with ACM connection", e); } catch (IOException e) { status.showMessage(e.getMessage(), Localization.lang("Search %0", getTitle()), JOptionPane.ERROR_MESSAGE); LOGGER.warn("Problem with ACM Portal", e); } return false; }
From source file:net.sf.jabref.importer.fetcher.MedlineFetcher.java
@Override public boolean processQuery(String query, ImportInspector iIDialog, OutputPrinter frameOP) { shouldContinue = true;//ww w . j ava 2 s .co m String cleanQuery = query.trim().replace(';', ','); if (cleanQuery.matches("\\d+[,\\d+]*")) { frameOP.setStatus(Localization.lang("Fetching Medline by id...")); List<BibEntry> bibs = fetchMedline(cleanQuery, frameOP); if (bibs.isEmpty()) { frameOP.showMessage(Localization.lang("No references found")); } for (BibEntry entry : bibs) { iIDialog.addEntry(entry); } return true; } if (!query.isEmpty()) { frameOP.setStatus(Localization.lang("Fetching Medline by term...")); String searchTerm = toSearchTerm(query); // get the ids from entrez SearchResult result = getIds(searchTerm, 0, 1); if (result.count == 0) { frameOP.showMessage(Localization.lang("No references found")); return false; } int numberToFetch = result.count; if (numberToFetch > MedlineFetcher.PACING) { while (true) { String strCount = JOptionPane.showInputDialog( Localization.lang("References found") + ": " + numberToFetch + " " + Localization.lang("Number of references to fetch?"), Integer.toString(numberToFetch)); if (strCount == null) { frameOP.setStatus(Localization.lang("%0 import canceled", "Medline")); return false; } try { numberToFetch = Integer.parseInt(strCount.trim()); break; } catch (NumberFormatException ex) { frameOP.showMessage(Localization.lang("Please enter a valid number")); } } } for (int i = 0; i < numberToFetch; i += MedlineFetcher.PACING) { if (!shouldContinue) { break; } int noToFetch = Math.min(MedlineFetcher.PACING, numberToFetch - i); // get the ids from entrez result = getIds(searchTerm, i, noToFetch); List<BibEntry> bibs = fetchMedline(result.ids, frameOP); for (BibEntry entry : bibs) { iIDialog.addEntry(entry); } iIDialog.setProgress(i + noToFetch, numberToFetch); } return true; } frameOP.showMessage( Localization.lang("Please enter a comma separated list of Medline IDs (numbers) or search terms."), Localization.lang("Input error"), JOptionPane.ERROR_MESSAGE); return false; }
From source file:uk.co.petertribble.jkstat.gui.KstatBaseChartFrame.java
/** * Saves the current chart as an image in png format. The user can select * the filename, and is asked to confirm the overwrite of an existing file. *///from w ww . ja v a 2 s.c om public void saveImage() { JFileChooser fc = new JFileChooser(); if (fc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) { File f = fc.getSelectedFile(); if (f.exists()) { int ok = JOptionPane.showConfirmDialog(this, KstatResources.getString("SAVEAS.OVERWRITE.TEXT") + " " + f.toString(), KstatResources.getString("SAVEAS.CONFIRM.TEXT"), JOptionPane.YES_NO_OPTION); if (ok != JOptionPane.YES_OPTION) { return; } } BufferedImage bi = kbc.getChart().createBufferedImage(500, 300); try { ImageIO.write(bi, "png", f); /* * According to the API docs this should throw an IOException * on error, but this doesn't seem to be the case. As a result * it's necessary to catch exceptions more generally. Even this * doesn't work properly, but at least we manage to convey the * message to the user that the write failed, even if the * error itself isn't handled. */ } catch (Exception ioe) { JOptionPane.showMessageDialog(this, ioe.toString(), KstatResources.getString("SAVEAS.ERROR.TEXT"), JOptionPane.ERROR_MESSAGE); } } }
From source file:org.pgptool.gui.ui.importkey.KeyImporterPm.java
private boolean loadKey(File[] filesToLoad) { try {/*from w w w . j a v a2 s . co m*/ Map<String, Throwable> exceptions = new HashMap<>(); List<Key> loadedKeys = loadKeysSafe(filesToLoad, exceptions); if (exceptions.size() > 0) { String msg = buildSummaryMessage("error.keysLoadedStatistics", loadedKeys.size(), exceptions); UiUtils.messageBox(null, msg, Messages.get("term.attention"), JOptionPane.ERROR_MESSAGE); } if (loadedKeys.size() > 0) { loadedKeys.sort(keySorterByNameAsc); keys.getList().addAll(loadedKeys); actionDoImport.setEnabled(true); return true; } } catch (Throwable t) { EntryPoint.reportExceptionToUser("exception.failedToReadKey", t); } return false; }
From source file:model.finance_management.Decision_Helper_Model.java
private CategoryDataset createDataset() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); String series1 = "Profit"; String series2 = "Goal"; String daily = "SELECT SUM(incomes_management.Amount), SUM(expenses_management.Amount),SUBSTRING(incomes_management.`Date Modified`,1,10) FROM incomes_management,expenses_management WHERE SUBSTRING(incomes_management.`Date Modified`,1,10)=SUBSTRING(expenses_management.`Date Modified`,1,10) GROUP BY SUBSTRING(incomes_management.`Date Modified`,1,10)"; String monthly = "SELECT SUM(incomes_management.Amount), SUM(expenses_management.Amount),SUBSTRING(incomes_management.`Date Modified`,1,7) FROM incomes_management,expenses_management WHERE SUBSTRING(incomes_management.`Date Modified`,1,7)=SUBSTRING(expenses_management.`Date Modified`,1,7) GROUP BY SUBSTRING(incomes_management.`Date Modified`,1,7)"; String annually = "SELECT SUM(incomes_management.Amount), SUM(expenses_management.Amount),SUBSTRING(incomes_management.`Date Modified`,1,4) FROM incomes_management,expenses_management WHERE SUBSTRING(incomes_management.`Date Modified`,1,4)=SUBSTRING(expenses_management.`Date Modified`,1,4) GROUP BY SUBSTRING(incomes_management.`Date Modified`,1,4)"; int DayGoal = Integer.parseInt(Decision_Helper_Frame.txtDailyProfitGoal.getText()); int MonthGoal = Integer.parseInt(Decision_Helper_Frame.txtMonthlyProfitGoal.getText()); int AnnualGoal = Integer.parseInt(Decision_Helper_Frame.txtAnnualProfitGoal.getText()); if (Decision_Helper_Frame.cmbTimePeriod.getSelectedItem().equals("Daily")) { try {/* w ww. ja va 2s . co m*/ pst = con.prepareStatement(daily); ResultSet rst = pst.executeQuery(); while (rst.next()) { String incomeamounts = rst.getString("SUM(incomes_management.Amount)"); String expenseamounts = rst.getString("SUM(expenses_management.Amount)"); String day = rst.getString("SUBSTRING(incomes_management.`Date Modified`,1,10)"); float incomevalue = Float.parseFloat(incomeamounts); float expensevalue = Float.parseFloat(expenseamounts); float profit = incomevalue - expensevalue; dataset.addValue(profit, series1, day); dataset.addValue(DayGoal, series2, day); } } catch (SQLException | NumberFormatException e) { JOptionPane.showMessageDialog(null, e, "Error", JOptionPane.ERROR_MESSAGE); } } else if (Decision_Helper_Frame.cmbTimePeriod.getSelectedItem().equals("Monthly")) { try { pst = con.prepareStatement(monthly); ResultSet rst = pst.executeQuery(); while (rst.next()) { String incomeamounts = rst.getString("SUM(incomes_management.Amount)"); String expenseamounts = rst.getString("SUM(expenses_management.Amount)"); String month = rst.getString("SUBSTRING(incomes_management.`Date Modified`,1,7)"); float incomevalue = Float.parseFloat(incomeamounts); float expensevalue = Float.parseFloat(expenseamounts); float profit = incomevalue - expensevalue; dataset.addValue(profit, series1, month); dataset.addValue(MonthGoal, series2, month); } } catch (SQLException | NumberFormatException e) { JOptionPane.showMessageDialog(null, e, "Error", JOptionPane.ERROR_MESSAGE); } } else if (Decision_Helper_Frame.cmbTimePeriod.getSelectedItem().equals("Annually")) { try { pst = con.prepareStatement(annually); ResultSet rst = pst.executeQuery(); while (rst.next()) { String incomeamounts = rst.getString("SUM(incomes_management.Amount)"); String expenseamounts = rst.getString("SUM(expenses_management.Amount)"); String year = rst.getString("SUBSTRING(incomes_management.`Date Modified`,1,4)"); float incomevalue = Float.parseFloat(incomeamounts); float expensevalue = Float.parseFloat(expenseamounts); float profit = incomevalue - expensevalue; dataset.addValue(profit, series1, year); dataset.addValue(AnnualGoal, series2, year); } } catch (SQLException | NumberFormatException e) { JOptionPane.showMessageDialog(null, e, "Error", JOptionPane.ERROR_MESSAGE); } } return dataset; }
From source file:com.jug.MoMA.java
/** * PROJECT MAIN//from w w w . ja v a 2s. co m * * @param args */ public static void main(final String[] args) { if (showIJ) new ImageJ(); // // ===== set look and feel ======================================================================== // try { // // Set cross-platform Java L&F (also called "Metal") // UIManager.setLookAndFeel( // UIManager.getCrossPlatformLookAndFeelClassName() ); // } catch ( final UnsupportedLookAndFeelException e ) { // // handle exception // } catch ( final ClassNotFoundException e ) { // // handle exception // } catch ( final InstantiationException e ) { // // handle exception // } catch ( final IllegalAccessException e ) { // // handle exception // } // ===== command line parsing ====================================================================== // create Options object & the parser final Options options = new Options(); final CommandLineParser parser = new BasicParser(); // defining command line options final Option help = new Option("help", "print this message"); final Option headless = new Option("h", "headless", false, "start without user interface (note: input-folder must be given!)"); headless.setRequired(false); final Option timeFirst = new Option("tmin", "min_time", true, "first time-point to be processed"); timeFirst.setRequired(false); final Option timeLast = new Option("tmax", "max_time", true, "last time-point to be processed"); timeLast.setRequired(false); final Option optRange = new Option("orange", "opt_range", true, "initial optimization range"); optRange.setRequired(false); final Option numChannelsOption = new Option("c", "channels", true, "number of channels to be loaded and analyzed."); numChannelsOption.setRequired(true); final Option minChannelIdxOption = new Option("cmin", "min_channel", true, "the smallest channel index (usually 0 or 1, default is 1)."); minChannelIdxOption.setRequired(false); final Option infolder = new Option("i", "infolder", true, "folder to read data from"); infolder.setRequired(false); final Option outfolder = new Option("o", "outfolder", true, "folder to write preprocessed data to (equals infolder if not given)"); outfolder.setRequired(false); final Option userProps = new Option("p", "props", true, "properties file to be loaded (mm.properties)"); userProps.setRequired(false); options.addOption(help); options.addOption(headless); options.addOption(numChannelsOption); options.addOption(minChannelIdxOption); options.addOption(timeFirst); options.addOption(timeLast); options.addOption(optRange); options.addOption(infolder); options.addOption(outfolder); options.addOption(userProps); // get the commands parsed CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (final ParseException e1) { final HelpFormatter formatter = new HelpFormatter(); formatter.printHelp( "... [-p props-file] -i in-folder [-o out-folder] -c <num-channels> [-cmin start-channel-ids] [-tmin idx] [-tmax idx] [-orange num-frames] [-headless]", "", options, "Error: " + e1.getMessage()); System.exit(0); } if (cmd.hasOption("help")) { final HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("... -i <in-folder> -o [out-folder] [-headless]", options); System.exit(0); } if (cmd.hasOption("h")) { System.out.println(">>> Starting MM in headless mode."); HEADLESS = true; if (!cmd.hasOption("i")) { final HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("Headless-mode requires option '-i <in-folder>'...", options); System.exit(0); } } File inputFolder = null; if (cmd.hasOption("i")) { inputFolder = new File(cmd.getOptionValue("i")); if (!inputFolder.isDirectory()) { System.out.println("Error: Input folder is not a directory!"); System.exit(2); } if (!inputFolder.canRead()) { System.out.println("Error: Input folder cannot be read!"); System.exit(2); } } File outputFolder = null; if (!cmd.hasOption("o")) { if (inputFolder == null) { System.out.println( "Error: Output folder would be set to a 'null' input folder! Please check your command line arguments..."); System.exit(3); } outputFolder = inputFolder; STATS_OUTPUT_PATH = outputFolder.getAbsolutePath(); } else { outputFolder = new File(cmd.getOptionValue("o")); if (!outputFolder.isDirectory()) { System.out.println("Error: Output folder is not a directory!"); System.exit(3); } if (!inputFolder.canWrite()) { System.out.println("Error: Output folder cannot be written to!"); System.exit(3); } STATS_OUTPUT_PATH = outputFolder.getAbsolutePath(); } fileUserProps = null; if (cmd.hasOption("p")) { fileUserProps = new File(cmd.getOptionValue("p")); } if (cmd.hasOption("cmin")) { minChannelIdx = Integer.parseInt(cmd.getOptionValue("cmin")); } if (cmd.hasOption("c")) { numChannels = Integer.parseInt(cmd.getOptionValue("c")); } if (cmd.hasOption("tmin")) { minTime = Integer.parseInt(cmd.getOptionValue("tmin")); } if (cmd.hasOption("tmax")) { maxTime = Integer.parseInt(cmd.getOptionValue("tmax")); } if (cmd.hasOption("orange")) { initOptRange = Integer.parseInt(cmd.getOptionValue("orange")); } // ******** CHECK GUROBI ********* CHECK GUROBI ********* CHECK GUROBI ********* final String jlp = System.getProperty("java.library.path"); // System.out.println( jlp ); try { new GRBEnv("MoMA_gurobi.log"); } catch (final GRBException e) { final String msgs = "Initial Gurobi test threw exception... check your Gruobi setup!\n\nJava library path: " + jlp; if (HEADLESS) { System.out.println(msgs); } else { JOptionPane.showMessageDialog(MoMA.guiFrame, msgs, "Gurobi Error?", JOptionPane.ERROR_MESSAGE); } e.printStackTrace(); System.exit(98); } catch (final UnsatisfiedLinkError ulr) { final String msgs = "Could initialize Gurobi.\n" + "You might not have installed Gurobi properly or you miss a valid license.\n" + "Please visit 'www.gurobi.com' for further information.\n\n" + ulr.getMessage() + "\nJava library path: " + jlp; if (HEADLESS) { System.out.println(msgs); } else { JOptionPane.showMessageDialog(MoMA.guiFrame, msgs, "Gurobi Error?", JOptionPane.ERROR_MESSAGE); ulr.printStackTrace(); } System.out.println("\n>>>>> Java library path: " + jlp + "\n"); System.exit(99); } // ******* END CHECK GUROBI **** END CHECK GUROBI **** END CHECK GUROBI ******** final MoMA main = new MoMA(); if (!HEADLESS) { guiFrame = new JFrame(); main.initMainWindow(guiFrame); } System.out.println("VERSION: " + VERSION_STRING); props = main.loadParams(); BGREM_TEMPLATE_XMIN = Integer .parseInt(props.getProperty("BGREM_TEMPLATE_XMIN", Integer.toString(BGREM_TEMPLATE_XMIN))); BGREM_TEMPLATE_XMAX = Integer .parseInt(props.getProperty("BGREM_TEMPLATE_XMAX", Integer.toString(BGREM_TEMPLATE_XMAX))); BGREM_X_OFFSET = Integer.parseInt(props.getProperty("BGREM_X_OFFSET", Integer.toString(BGREM_X_OFFSET))); GL_WIDTH_IN_PIXELS = Integer .parseInt(props.getProperty("GL_WIDTH_IN_PIXELS", Integer.toString(GL_WIDTH_IN_PIXELS))); MOTHER_CELL_BOTTOM_TRICK_MAX_PIXELS = Integer.parseInt(props.getProperty( "MOTHER_CELL_BOTTOM_TRICK_MAX_PIXELS", Integer.toString(MOTHER_CELL_BOTTOM_TRICK_MAX_PIXELS))); GL_FLUORESCENCE_COLLECTION_WIDTH_IN_PIXELS = Integer .parseInt(props.getProperty("GL_FLUORESCENCE_COLLECTION_WIDTH_IN_PIXELS", Integer.toString(GL_FLUORESCENCE_COLLECTION_WIDTH_IN_PIXELS))); GL_OFFSET_BOTTOM = Integer .parseInt(props.getProperty("GL_OFFSET_BOTTOM", Integer.toString(GL_OFFSET_BOTTOM))); if (GL_OFFSET_BOTTOM == -1) { GL_OFFSET_BOTTOM_AUTODETECT = true; } else { GL_OFFSET_BOTTOM_AUTODETECT = false; } GL_OFFSET_TOP = Integer.parseInt(props.getProperty("GL_OFFSET_TOP", Integer.toString(GL_OFFSET_TOP))); GL_OFFSET_LATERAL = Integer .parseInt(props.getProperty("GL_OFFSET_LATERAL", Integer.toString(GL_OFFSET_LATERAL))); MIN_CELL_LENGTH = Integer.parseInt(props.getProperty("MIN_CELL_LENGTH", Integer.toString(MIN_CELL_LENGTH))); MIN_GAP_CONTRAST = Float .parseFloat(props.getProperty("MIN_GAP_CONTRAST", Float.toString(MIN_GAP_CONTRAST))); SIGMA_PRE_SEGMENTATION_X = Float.parseFloat( props.getProperty("SIGMA_PRE_SEGMENTATION_X", Float.toString(SIGMA_PRE_SEGMENTATION_X))); SIGMA_PRE_SEGMENTATION_Y = Float.parseFloat( props.getProperty("SIGMA_PRE_SEGMENTATION_Y", Float.toString(SIGMA_PRE_SEGMENTATION_Y))); SIGMA_GL_DETECTION_X = Float .parseFloat(props.getProperty("SIGMA_GL_DETECTION_X", Float.toString(SIGMA_GL_DETECTION_X))); SIGMA_GL_DETECTION_Y = Float .parseFloat(props.getProperty("SIGMA_GL_DETECTION_Y", Float.toString(SIGMA_GL_DETECTION_Y))); SEGMENTATION_MIX_CT_INTO_PMFRF = Float.parseFloat(props.getProperty("SEGMENTATION_MIX_CT_INTO_PMFRF", Float.toString(SEGMENTATION_MIX_CT_INTO_PMFRF))); SEGMENTATION_CLASSIFIER_MODEL_FILE = props.getProperty("SEGMENTATION_CLASSIFIER_MODEL_FILE", SEGMENTATION_CLASSIFIER_MODEL_FILE); CELLSIZE_CLASSIFIER_MODEL_FILE = props.getProperty("CELLSIZE_CLASSIFIER_MODEL_FILE", CELLSIZE_CLASSIFIER_MODEL_FILE); DEFAULT_PATH = props.getProperty("DEFAULT_PATH", DEFAULT_PATH); GUROBI_TIME_LIMIT = Double .parseDouble(props.getProperty("GUROBI_TIME_LIMIT", Double.toString(GUROBI_TIME_LIMIT))); GUROBI_MAX_OPTIMALITY_GAP = Double.parseDouble( props.getProperty("GUROBI_MAX_OPTIMALITY_GAP", Double.toString(GUROBI_MAX_OPTIMALITY_GAP))); GUI_POS_X = Integer.parseInt(props.getProperty("GUI_POS_X", Integer.toString(DEFAULT_GUI_POS_X))); GUI_POS_Y = Integer.parseInt(props.getProperty("GUI_POS_Y", Integer.toString(DEFAULT_GUI_POS_X))); GUI_WIDTH = Integer.parseInt(props.getProperty("GUI_WIDTH", Integer.toString(GUI_WIDTH))); GUI_HEIGHT = Integer.parseInt(props.getProperty("GUI_HEIGHT", Integer.toString(GUI_HEIGHT))); GUI_CONSOLE_WIDTH = Integer .parseInt(props.getProperty("GUI_CONSOLE_WIDTH", Integer.toString(GUI_CONSOLE_WIDTH))); if (!HEADLESS) { // Iterate over all currently attached monitors and check if sceen // position is actually possible, // otherwise fall back to the DEFAULT values and ignore the ones // coming from the properties-file. boolean pos_ok = false; final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); final GraphicsDevice[] gs = ge.getScreenDevices(); for (int i = 0; i < gs.length; i++) { if (gs[i].getDefaultConfiguration().getBounds() .contains(new java.awt.Point(GUI_POS_X, GUI_POS_Y))) { pos_ok = true; } } // None of the screens contained the top-left window coordinates --> // fall back onto default values... if (!pos_ok) { GUI_POS_X = DEFAULT_GUI_POS_X; GUI_POS_Y = DEFAULT_GUI_POS_Y; } } String path = props.getProperty("import_path", System.getProperty("user.home")); if (inputFolder == null || inputFolder.equals("")) { inputFolder = main.showStartupDialog(guiFrame, path); } System.out.println("Default filename decoration = " + inputFolder.getName()); defaultFilenameDecoration = inputFolder.getName(); path = inputFolder.getAbsolutePath(); props.setProperty("import_path", path); GrowthLineSegmentationMagic.setClassifier(SEGMENTATION_CLASSIFIER_MODEL_FILE, ""); if (!HEADLESS) { // Setting up console window... main.initConsoleWindow(); main.showConsoleWindow(true); } // ------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------ final MoMAModel mmm = new MoMAModel(main); instance = main; try { main.processDataFromFolder(path, minTime, maxTime, minChannelIdx, numChannels); } catch (final Exception e) { e.printStackTrace(); System.exit(11); } // ------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------ // show loaded and annotated data if (showIJ) { new ImageJ(); ImageJFunctions.show(main.imgRaw, "Rotated & cropped raw data"); // ImageJFunctions.show( main.imgTemp, "Temporary" ); // ImageJFunctions.show( main.imgAnnotated, "Annotated ARGB data" ); // main.getCellSegmentedChannelImgs() // ImageJFunctions.show( main.imgClassified, "Classification" ); // ImageJFunctions.show( main.getCellSegmentedChannelImgs(), "Segmentation" ); } gui = new MoMAGui(mmm); if (!HEADLESS) { System.out.print("Build GUI..."); main.showConsoleWindow(false); // final JFrameSnapper snapper = new JFrameSnapper(); // snapper.addFrame( main.frameConsoleWindow ); // snapper.addFrame( guiFrame ); gui.setVisible(true); guiFrame.add(gui); guiFrame.setSize(GUI_WIDTH, GUI_HEIGHT); guiFrame.setLocation(GUI_POS_X, GUI_POS_Y); guiFrame.setVisible(true); // SwingUtilities.invokeLater( new Runnable() { // // @Override // public void run() { // snapper.snapFrames( main.frameConsoleWindow, guiFrame, JFrameSnapper.EAST ); // } // } ); System.out.println(" done!"); } else { // final String name = inputFolder.getName(); gui.exportHtmlOverview(); gui.exportDataFiles(); instance.saveParams(); System.exit(0); } }
From source file:display.containers.FileManager.java
public Container getPane() { //if (gui==null) { fileSystemView = FileSystemView.getFileSystemView(); desktop = Desktop.getDesktop(); JPanel detailView = new JPanel(new BorderLayout(3, 3)); //fileTableModel = new FileTableModel(); table = new JTable(); table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); table.setAutoCreateRowSorter(true);/* w w w .j ava 2s. c o m*/ table.setShowVerticalLines(false); table.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { if (e.getClickCount() >= 2) { Point p = e.getPoint(); int row = table.convertRowIndexToModel(table.rowAtPoint(p)); int column = table.convertColumnIndexToModel(table.columnAtPoint(p)); if (row >= 0 && column >= 0) { mouseDblClicked(row, column); } } } }); table.addKeyListener(new KeyListener() { @Override public void keyTyped(KeyEvent arg0) { } @Override public void keyReleased(KeyEvent arg0) { if (KeyEvent.VK_DELETE == arg0.getKeyCode()) { if (mode != 2) { parentFrame.setLock(true); parentFrame.getProgressBarPanel().setVisible(true); Thread t = new Thread(new Runnable() { @Override public void run() { try { deleteSelectedFiles(); } catch (IOException e) { JOptionPane.showMessageDialog(parentFrame, "Error during the deletion.", "Deletion error", JOptionPane.ERROR_MESSAGE); WindowManager.mwLogger.log(Level.SEVERE, "Error during the deletion.", e); } finally { parentFrame.setLock(false); refresh(); parentFrame.getProgressBarPanel().setVisible(false); } } }); t.start(); } else { if (UserProfile.CURRENT_USER.getLevel() == 3) { parentFrame.setLock(true); parentFrame.getProgressBarPanel().setVisible(true); Thread delThread = new Thread(new Runnable() { @Override public void run() { int[] rows = table.getSelectedRows(); int[] columns = table.getSelectedColumns(); for (int i = 0; i < rows.length; i++) { if (!continueAction) { continueAction = true; return; } int row = table.convertRowIndexToModel(rows[i]); try { deleteServerFile(row); } catch (Exception e) { WindowManager.mwLogger.log(Level.SEVERE, "Error during the deletion.", e); } } refresh(); parentFrame.setLock(false); parentFrame.getProgressBarPanel().setVisible(false); } }); delThread.start(); } } } } @Override public void keyPressed(KeyEvent arg0) { // TODO Auto-generated method stub } }); table.getSelectionModel().addListSelectionListener(listSelectionListener); JScrollPane tableScroll = new JScrollPane(table); Dimension d = tableScroll.getPreferredSize(); tableScroll.setPreferredSize(new Dimension((int) d.getWidth(), (int) d.getHeight() / 2)); detailView.add(tableScroll, BorderLayout.CENTER); // the File tree DefaultMutableTreeNode root = new DefaultMutableTreeNode(); treeModel = new DefaultTreeModel(root); table.getRowSorter().addRowSorterListener(new RowSorterListener() { @Override public void sorterChanged(RowSorterEvent e) { ((FileTableModel) table.getModel()).fireTableDataChanged(); } }); // show the file system roots. File[] roots = fileSystemView.getRoots(); for (File fileSystemRoot : roots) { DefaultMutableTreeNode node = new DefaultMutableTreeNode(fileSystemRoot); root.add(node); //showChildren(node); // File[] files = fileSystemView.getFiles(fileSystemRoot, true); for (File file : files) { if (file.isDirectory()) { node.add(new DefaultMutableTreeNode(file)); } } // } JScrollPane treeScroll = new JScrollPane(); Dimension preferredSize = treeScroll.getPreferredSize(); Dimension widePreferred = new Dimension(200, (int) preferredSize.getHeight()); treeScroll.setPreferredSize(widePreferred); JPanel fileView = new JPanel(new BorderLayout(3, 3)); detailView.add(fileView, BorderLayout.SOUTH); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treeScroll, detailView); JPanel simpleOutput = new JPanel(new BorderLayout(3, 3)); progressBar = new JProgressBar(); simpleOutput.add(progressBar, BorderLayout.EAST); progressBar.setVisible(false); showChildren(getCurrentDir().toPath()); //table.setDragEnabled(true); table.setColumnSelectionAllowed(false); // Menu popup Pmenu = new JPopupMenu(); changeProjectitem = new JMenuItem("Reassign"); renameProjectitem = new JMenuItem("Rename"); twitem = new JMenuItem("To workspace"); tlitem = new JMenuItem("To local"); processitem = new JMenuItem("Select for process"); switch (mode) { case 0: Pmenu.add(twitem); twitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { parentFrame.getBtnlocalTowork().doClick(); } }); break; case 1: Pmenu.add(tlitem); Pmenu.add(processitem); tlitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { parentFrame.getBtnWorkTolocal().doClick(); } }); processitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { SwingUtilities.invokeLater(new Runnable() { public void run() { // Recupere les lignes selectionnees int[] indices = table.getSelectedRows(); // On recupere les fichiers correspondants ArrayList<File> files = new ArrayList<File>(); for (int i = 0; i < indices.length; i++) { int row = table.convertRowIndexToModel(indices[i]); File fi = ((FileTableModel) table.getModel()).getFile(row); if (fi.isDirectory()) files.add(fi); } ImageProcessingFrame imf = new ImageProcessingFrame(files); } }); } }); break; case 2: if (UserProfile.CURRENT_USER.getLevel() == 3) { Pmenu.add(changeProjectitem); Pmenu.add(renameProjectitem); } Pmenu.add(twitem); twitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { parentFrame.getBtndistToWorkspace().doClick(); } }); Pmenu.add(tlitem); tlitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { parentFrame.getBtndistToLocal().doClick(); } }); break; } changeProjectitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { table.setEnabled(false); File from = ((FileTableModel) table.getModel()) .getFile(table.convertRowIndexToModel(table.getSelectedRows()[0])); ReassignProjectPanel reas = new ReassignProjectPanel(from.toPath()); // mode creation de liens Popup popup = PopupFactory.getSharedInstance().getPopup(WindowManager.MAINWINDOW, reas, (int) WindowManager.MAINWINDOW.getX() + 200, (int) WindowManager.MAINWINDOW.getY() + 150); reas.setPopupWindow(popup); popup.show(); table.setEnabled(true); } }); renameProjectitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { table.setEnabled(false); final File from = ((FileTableModel) table.getModel()) .getFile(table.convertRowIndexToModel(table.getSelectedRows()[0])); JDialog.setDefaultLookAndFeelDecorated(true); String s = (String) JOptionPane.showInputDialog(WindowManager.MAINWINDOW, "New project name ?", "Rename project", JOptionPane.PLAIN_MESSAGE, null, null, from.getName()); //If a string was returned, say so. if ((s != null) && (s.length() > 0)) { ProjectDAO pdao = new MySQLProjectDAO(); if (new File(from.getParent() + File.separator + s).exists()) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JDialog.setDefaultLookAndFeelDecorated(true); JOptionPane.showMessageDialog(WindowManager.MAINWINDOW, "Couldn't rename " + from.getName() + " (A file with this filename already exists)", "Renaming error", JOptionPane.ERROR_MESSAGE); } }); WindowManager.mwLogger.log(Level.SEVERE, "Error during file project renaming (" + from.getName() + "). [Duplication error]"); } else { try { boolean succeed = pdao.renameProject(from.getName(), s); if (!succeed) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JDialog.setDefaultLookAndFeelDecorated(true); JOptionPane.showMessageDialog(WindowManager.MAINWINDOW, "Couldn't rename " + from.getName() + " (no project with this name)", "Renaming error", JOptionPane.ERROR_MESSAGE); } }); } else { from.renameTo(new File(from.getParent() + File.separator + s)); // on renomme le repertoire nifti ou dicom correspondant si il existe switch (from.getParentFile().getName()) { case ServerInfo.NRI_ANALYSE_NAME: if (new File(from.getAbsolutePath().replaceAll(ServerInfo.NRI_ANALYSE_NAME, ServerInfo.NRI_DICOM_NAME)).exists()) try { Files.move(Paths.get(from.getAbsolutePath().replaceAll( ServerInfo.NRI_ANALYSE_NAME, ServerInfo.NRI_DICOM_NAME)), Paths.get(from.getParent().replaceAll( ServerInfo.NRI_ANALYSE_NAME, ServerInfo.NRI_DICOM_NAME) + File.separator + s)); } catch (IOException e) { e.printStackTrace(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JDialog.setDefaultLookAndFeelDecorated(true); JOptionPane.showMessageDialog(WindowManager.MAINWINDOW, "Couldn't rename " + from.getName() + " (error with file system)", "Renaming error", JOptionPane.ERROR_MESSAGE); } }); WindowManager.mwLogger.log(Level.SEVERE, "Error during file project renaming (" + from.getName() + ")", e); } //from.renameTo(new File(from.getParent().replaceAll(ServerInfo.NRI_ANALYSE_NAME, ServerInfo.NRI_DICOM_NAME)+File.separator+s)); break; case ServerInfo.NRI_DICOM_NAME: if (new File(from.getAbsolutePath().replaceAll(ServerInfo.NRI_DICOM_NAME, ServerInfo.NRI_ANALYSE_NAME)).exists()) try { Files.move(Paths.get(from.getAbsolutePath().replaceAll( ServerInfo.NRI_DICOM_NAME, ServerInfo.NRI_ANALYSE_NAME)), Paths.get(from.getParent().replaceAll(ServerInfo.NRI_DICOM_NAME, ServerInfo.NRI_ANALYSE_NAME) + File.separator + s)); } catch (IOException e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JDialog.setDefaultLookAndFeelDecorated(true); JOptionPane.showMessageDialog(WindowManager.MAINWINDOW, "Couldn't rename " + from.getName() + " (error with file system)", "Renaming error", JOptionPane.ERROR_MESSAGE); } }); e.printStackTrace(); WindowManager.mwLogger.log(Level.SEVERE, "Error during file project renaming (" + from.getName() + ")", e); } //from.renameTo(new File(from.getParent().replaceAll(ServerInfo.NRI_DICOM_NAME, ServerInfo.NRI_ANALYSE_NAME)+File.separator+s)); break; } refresh(); } } catch (final SQLException e) { WindowManager.mwLogger.log(Level.SEVERE, "Error during SQL project renaming", e); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JDialog.setDefaultLookAndFeelDecorated(true); JOptionPane.showMessageDialog(WindowManager.MAINWINDOW, "Exception : " + e.toString(), "Openning error", JOptionPane.ERROR_MESSAGE); } }); } } } table.setEnabled(true); } }); table.addMouseListener(new MouseListener() { public void mouseClicked(MouseEvent me) { } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent me) { if (me.getButton() == 3 && table.getSelectedRowCount() > 0) { int row = table.convertRowIndexToModel(table.rowAtPoint(me.getPoint())); changeProjectitem.setVisible(isPatient(((FileTableModel) table.getModel()).getFile(row))); renameProjectitem.setVisible(isProject(((FileTableModel) table.getModel()).getFile(row))); Pmenu.show(me.getComponent(), me.getX(), me.getY()); } } }); // //} return tableScroll; }