List of usage examples for java.awt Cursor WAIT_CURSOR
int WAIT_CURSOR
To view the source code for java.awt Cursor WAIT_CURSOR.
Click Source Link
From source file:biz.wolschon.finance.jgnucash.actions.ToolPluginMenuAction.java
@Override public void actionPerformed(final ActionEvent e) { try {/*from w ww .j a v a 2 s . co m*/ GnucashWritableFile wModel = myJGnucashEditor.getWritableModel(); if (wModel == null) { JOptionPane.showMessageDialog(myJGnucashEditor, "No open file.", "Please open a gnucash-file first!", JOptionPane.WARNING_MESSAGE); return; } // Activate plug-in that declares extension. myJGnucashEditor.getPluginManager().activatePlugin(ext.getDeclaringPluginDescriptor().getId()); // Get plug-in class loader. ClassLoader classLoader = myJGnucashEditor.getPluginManager() .getPluginClassLoader(ext.getDeclaringPluginDescriptor()); // Load Tool class. Class toolCls = classLoader.loadClass(ext.getParameter("class").valueAsString()); // Create Tool instance. Object o = toolCls.newInstance(); if (!(o instanceof ToolPlugin)) { LOGGER.error("Plugin '" + pluginName + "' does not implement ToolPlugin-interface."); JOptionPane.showMessageDialog(myJGnucashEditor, "Error", "Plugin '" + pluginName + "' does not implement ToolPlugin-interface.", JOptionPane.ERROR_MESSAGE); return; } ToolPlugin importer = (ToolPlugin) o; try { myJGnucashEditor.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); GnucashWritableAccount selectedAccount = (GnucashWritableAccount) myJGnucashEditor .getSelectedAccount(); String message = importer.runTool(wModel, selectedAccount); if (message != null && message.length() > 0) { JOptionPane.showMessageDialog(myJGnucashEditor, "Tool OK", "The tool-use was a success:\n" + message, JOptionPane.INFORMATION_MESSAGE); } } catch (Exception e1) { LOGGER.error("Tool-use via Plugin '" + pluginName + "' failed.", e1); JOptionPane .showMessageDialog( myJGnucashEditor, "Error", "Tool-use via Plugin '" + pluginName + "' failed.\n" + "[" + e1.getClass().getName() + "]: " + e1.getMessage(), JOptionPane.ERROR_MESSAGE); } finally { myJGnucashEditor.setCursor(Cursor.getDefaultCursor()); } } catch (Exception e1) { LOGGER.error("Could not activate requested Tool-plugin '" + pluginName + "'.", e1); JOptionPane .showMessageDialog( myJGnucashEditor, "Error", "Could not activate requested Tool-plugin '" + pluginName + "'.\n" + "[" + e1.getClass().getName() + "]: " + e1.getMessage(), JOptionPane.ERROR_MESSAGE); } }
From source file:org.jtheque.ui.utils.windows.WindowState.java
@Override public void startWait() { installWaitUIIfNecessary();/*from w w w . ja va2 s . c o m*/ content.setUI(waitUI); waitUI.setLocked(true); window.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); }
From source file:biz.wolschon.finance.jgnucash.actions.ImportPluginMenuAction.java
@Override public void actionPerformed(final ActionEvent e) { try {//www . j av a 2 s . co m GnucashWritableFile wModel = myJGnucashEditor.getWritableModel(); if (wModel == null) { JOptionPane.showMessageDialog(myJGnucashEditor, "No open file.", "Please open a gnucash-file first!", JOptionPane.WARNING_MESSAGE); return; } // Activate plug-in that declares extension. myJGnucashEditor.getPluginManager().activatePlugin(ext.getDeclaringPluginDescriptor().getId()); // Get plug-in class loader. ClassLoader classLoader = myJGnucashEditor.getPluginManager() .getPluginClassLoader(ext.getDeclaringPluginDescriptor()); // Load Tool class. Class toolCls = classLoader.loadClass(ext.getParameter("class").valueAsString()); // Create Tool instance. Object o = toolCls.newInstance(); if (!(o instanceof ImporterPlugin)) { LOGGER.error("Plugin '" + pluginName + "' does not implement ImporterPlugin-interface."); JOptionPane.showMessageDialog(myJGnucashEditor, "Error", "Plugin '" + pluginName + "' does not implement ImporterPlugin-interface.", JOptionPane.ERROR_MESSAGE); return; } ImporterPlugin importer = (ImporterPlugin) o; try { myJGnucashEditor.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); GnucashWritableAccount selectedAccount = (GnucashWritableAccount) myJGnucashEditor .getSelectedAccount(); String message = importer.runImport(wModel, selectedAccount); if (message != null && message.length() > 0) { JOptionPane.showMessageDialog(myJGnucashEditor, "Import OK", "The import was a success:\n" + message, JOptionPane.INFORMATION_MESSAGE); } } catch (Exception e1) { LOGGER.error("Import via Plugin '" + pluginName + "' failed.", e1); JOptionPane .showMessageDialog( myJGnucashEditor, "Error", "Import via Plugin '" + pluginName + "' failed.\n" + "[" + e1.getClass().getName() + "]: " + e1.getMessage(), JOptionPane.ERROR_MESSAGE); } finally { myJGnucashEditor.setCursor(Cursor.getDefaultCursor()); } } catch (Exception e1) { LOGGER.error("Could not activate requested import-plugin '" + pluginName + "'.", e1); JOptionPane .showMessageDialog( myJGnucashEditor, "Error", "Could not activate requested import-plugin '" + pluginName + "'.\n" + "[" + e1.getClass().getName() + "]: " + e1.getMessage(), JOptionPane.ERROR_MESSAGE); } }
From source file:EditorPaneExample10A.java
public EditorPaneExample10A() { super("JEditorPane Example 10 - using getIterator"); pane = new JEditorPane(); pane.setEditable(false); // Read-only getContentPane().add(new JScrollPane(pane), "Center"); // Build the panel of controls JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.gridwidth = 1;//from w ww. j a va 2 s . c o m c.gridheight = 1; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.NONE; c.weightx = 0.0; c.weighty = 0.0; JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT); panel.add(urlLabel, c); JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT); c.gridy = 1; panel.add(loadingLabel, c); JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT); c.gridy = 2; panel.add(typeLabel, c); c.gridy = 3; panel.add(new JLabel(LOAD_TIME), c); c.gridy = 4; c.gridwidth = 2; c.weightx = 1.0; c.anchor = GridBagConstraints.WEST; onlineLoad = new JCheckBox("Online Load"); panel.add(onlineLoad, c); onlineLoad.setSelected(true); onlineLoad.setForeground(typeLabel.getForeground()); c.gridx = 1; c.gridy = 0; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; urlCombo = new JComboBox(); panel.add(urlCombo, c); urlCombo.setEditable(true); loadingState = new JLabel(spaces, JLabel.LEFT); loadingState.setForeground(Color.black); c.gridy = 1; panel.add(loadingState, c); loadedType = new JLabel(spaces, JLabel.LEFT); loadedType.setForeground(Color.black); c.gridy = 2; panel.add(loadedType, c); timeLabel = new JLabel(""); c.gridy = 3; panel.add(timeLabel, c); getContentPane().add(panel, "South"); // Change page based on combo selection urlCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (populatingCombo == true) { return; } Object selection = urlCombo.getSelectedItem(); try { // Check if the new page and the old // page are the same. URL url; if (selection instanceof URL) { url = (URL) selection; } else { url = new URL((String) selection); } URL loadedURL = pane.getPage(); if (loadedURL != null && loadedURL.sameFile(url)) { return; } // Try to display the page urlCombo.setEnabled(false); // Disable input urlCombo.paintImmediately(0, 0, urlCombo.getSize().width, urlCombo.getSize().height); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); // Busy cursor loadingState.setText("Loading..."); loadingState.paintImmediately(0, 0, loadingState.getSize().width, loadingState.getSize().height); loadedType.setText(""); loadedType.paintImmediately(0, 0, loadedType.getSize().width, loadedType.getSize().height); timeLabel.setText(""); timeLabel.paintImmediately(0, 0, timeLabel.getSize().width, timeLabel.getSize().height); startTime = System.currentTimeMillis(); // Choose the loading method if (onlineLoad.isSelected()) { // Usual load via setPage pane.setPage(url); loadedType.setText(pane.getContentType()); } else { pane.setContentType("text/html"); loadedType.setText(pane.getContentType()); if (loader == null) { loader = new HTMLDocumentLoader(); } HTMLDocument doc = loader.loadDocument(url); loadComplete(); pane.setDocument(doc); displayLoadTime(); populateCombo(findLinks(doc, null)); enableInput(); } } catch (Exception e) { System.out.println(e); JOptionPane.showMessageDialog(pane, new String[] { "Unable to open file", selection.toString() }, "File Open Error", JOptionPane.ERROR_MESSAGE); loadingState.setText("Failed"); enableInput(); } } }); // Listen for page load to complete pane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("page")) { loadComplete(); displayLoadTime(); populateCombo(findLinks(pane.getDocument(), null)); enableInput(); } } }); }
From source file:org.kepler.gui.kar.ActorUploaderAction.java
/** * Invoked when an action occurs.// w w w .j ava 2 s .c o m * *@param e * ActionEvent */ public void actionPerformed(ActionEvent e) { super.actionPerformed(e); ExportActorArchiveAction eaaa = new ExportActorArchiveAction(_parent); eaaa.useTempFile = true; _parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); eaaa.actionPerformed(e); _parent.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); // ComponentEntity object; // SaveKAR sk = eaaa.getSaveKAR(); // // ArrayList<ComponentEntity> components = sk.getSaveInitiatorList(); // if (components.size() == 1) { // object = components.get(0); // } else { // return; // } // // ComponentUploader uploader = new ComponentUploader(_parent); // uploader.upload(sk.getFile(), object); }
From source file:components.ProgressBarDemo.java
/** * Invoked when the user presses the start button. *///w w w . j a va2 s. com public void actionPerformed(ActionEvent evt) { startButton.setEnabled(false); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); //Instances of javax.swing.SwingWorker are not reusuable, so //we create new instances as needed. task = new Task(); task.addPropertyChangeListener(this); task.execute(); }
From source file:org.photovault.swingui.ExportSelectedAction.java
@SuppressWarnings(value = "unchecked") public void actionPerformed(ActionEvent ev) { File exportFile = null;/* ww w .j av a 2s . c o m*/ if (view.getSelectedCount() > 1) { exportFile = new File("image_$n.jpg"); } else { exportFile = new File("image.jpg"); } ExportDlg dlg = new ExportDlg(null, true); dlg.setFilename(exportFile.getAbsolutePath()); int retval = dlg.showDialog(); if (retval == ExportDlg.EXPORT_OPTION) { Container c = view.getTopLevelAncestor(); Cursor oldCursor = c.getCursor(); c.setCursor(new Cursor(Cursor.WAIT_CURSOR)); String exportFileTmpl = dlg.getFilename(); int exportWidth = dlg.getImgWidth(); int exportHeight = dlg.getImgHeight(); Collection selection = view.getSelection(); PhotoInfo[] exportPhotos = (PhotoInfo[]) selection.toArray(new PhotoInfo[selection.size()]); ExportProducer exporter = null; if (selection != null) { if (selection.size() > 1) { // Ensure that the numbering order is the same is in current view // TODO: sort the exported photos Comparator comp = view.ctrl.getPhotoComparator(); if (comp != null) { Arrays.sort(exportPhotos, comp); } String format = getSequenceFnameFormat(exportFileTmpl); BrowserWindow w = null; exporter = new ExportProducer(this, exportPhotos, format, exportWidth, exportHeight); setEnabled(false); } else { Iterator iter = selection.iterator(); if (iter.hasNext()) { PhotoInfo[] photos = new PhotoInfo[1]; photos[0] = (PhotoInfo) iter.next(); exporter = new ExportProducer(this, photos, exportFileTmpl, exportWidth, exportHeight); } } SwingWorkerTaskScheduler sched = (SwingWorkerTaskScheduler) Photovault.getInstance() .getTaskScheduler(); sched.registerTaskProducer(exporter, TaskPriority.EXPORT_IMAGE); } c.setCursor(oldCursor); } }
From source file:edu.ku.brc.specify.tasks.subpane.wb.SGRResultsForForm.java
public void refresh() { if (currentIndex < 0) return;//from ww w. j a v a 2s . com removeAll(); repaint(); if (!sgrPlugin.isReady()) { showMessage("SGR_NO_MATCHER"); return; } setCursor(new Cursor(Cursor.WAIT_CURSOR)); new SwingWorker<MatchResults, Void>() { private int index = currentIndex; @Override protected MatchResults doInBackground() throws Exception { int modelIndex = workbenchPaneSS.getSpreadSheet().convertRowIndexToModel(index); WorkbenchRow row = workbench.getRow(modelIndex); return isEmpty(row) ? null : sgrPlugin.doQuery(row); } @Override protected void done() { // if we changed indexes in the meantime, don't show this result. if (index != currentIndex) return; //removeAll(); try { results = get(); } catch (CancellationException e) { return; } catch (InterruptedException e) { return; } catch (ExecutionException e) { sgrFailed(e); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); return; } setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); if (results == null || results.matches.size() < 1) { showMessage("SGR_NO_RESULTS"); return; } float maxScore = sgrPlugin.getColorizer().getMaxScore(); if (maxScore == 0.0f) maxScore = 22.0f; StringBuilder columns = new StringBuilder("right:max(50dlu;p)"); for (Match result : results) { columns.append(", 4dlu, 150dlu:grow"); } String[] fields = columnOrdering.getFields(); StringBuilder rows = new StringBuilder(); for (int i = 0; i < fields.length - 1; i++) { rows.append("p, 4dlu,"); } rows.append("p"); FormLayout layout = new FormLayout(columns.toString(), rows.toString()); PanelBuilder builder = new PanelBuilder(layout, SGRResultsForForm.this); CellConstraints cc = new CellConstraints(); int y = 1; for (String heading : columnOrdering.getHeadings()) { builder.addLabel(heading + ":", cc.xy(1, y)); y += 2; } int x = 3; for (Match result : results) { y = 1; for (String field : fields) { String value; Color color; if (field.equals("id")) { value = result.match.id; color = SGRColors.colorForScore(result.score, maxScore); } else if (field.equals("score")) { value = String.format("%1$.2f", result.score); color = SGRColors.colorForScore(result.score, maxScore); } else { value = StringUtils.join(result.match.getFieldValues(field).toArray(), "; "); Float fieldContribution = result.fieldScoreContributions().get(field); color = SGRColors.colorForScore(result.score, maxScore, fieldContribution); } JTextField textField = new JTextField(value); textField.setBackground(color); textField.setEditable(false); textField.setCaretPosition(0); builder.add(textField, cc.xy(x, y)); y += 2; } x += 2; } getParent().validate(); } }.execute(); UsageTracker.incrUsageCount("SGR.MatchRow"); }
From source file:StocksTable5.java
public void retrieveData() { SimpleDateFormat frm = new SimpleDateFormat("MM/dd/yyyy"); String currentDate = frm.format(m_data.m_date); String result = (String) JOptionPane.showInputDialog(this, "Please enter date in form mm/dd/yyyy:", "Input", JOptionPane.INFORMATION_MESSAGE, null, null, currentDate); if (result == null) return;//from w w w .ja va 2s . c o m java.util.Date date = null; try { date = frm.parse(result); } catch (java.text.ParseException ex) { date = null; } if (date == null) { JOptionPane.showMessageDialog(this, result + " is not a valid date", "Warning", JOptionPane.WARNING_MESSAGE); return; } setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); switch (m_data.retrieveData(date)) { case 0: // Ok with data m_title.setText(m_data.getTitle()); m_table.tableChanged(new TableModelEvent(m_data)); m_table.repaint(); break; case 1: // No data JOptionPane.showMessageDialog(this, "No data found for " + result, "Warning", JOptionPane.WARNING_MESSAGE); break; case -1: // Error JOptionPane.showMessageDialog(this, "Error retrieving data", "Warning", JOptionPane.WARNING_MESSAGE); break; } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); }
From source file:AST.DesignPatternDetection.java
private void btRunActionPerformed(ActionEvent e) throws FileNotFoundException, IOException, InterruptedException { if (tfProjectName.getText().equals("") || tfProjectName.getText().equals(null)) { JOptionPane.showMessageDialog(null, "You have to enter the Project's name!"); return;/*from ww w . jav a 2s . c o m*/ } overlap = ""; programPath = ""; Cursor hourglassCursor = new Cursor(Cursor.WAIT_CURSOR); setCursor(hourglassCursor); //Baslangic parametreleri, mutlaka gir... Boolean sourceCodeGraph = true; Boolean sourceCodeGraphDetail = true; Boolean designPatternGraph = true; Boolean OnlyTerminalCommands = true; String designpatternName = cbSelectionDP.getSelectedItem().toString(); String projectName = tfProjectName.getText(); Double threshold = Double.parseDouble((tfThreshold.getText())); if (chbOverlap.isSelected() == true) { overlap = " -overlap "; } else { overlap = ""; } if (chbInnerClass.isSelected() == true) { includeInnerClasses = "Yes"; } else { includeInnerClasses = "No"; } programPath = tfProgramPath.getText(); //create "project" directory String directoryNameProject = programPath + "/Projects/" + projectName + "/"; File directoryProject = new File(String.valueOf(directoryNameProject)); if (!directoryProject.exists()) { directoryProject.mkdir(); } //create "source" directory String directoryName = programPath + "/Projects/" + projectName + "/source/"; File directory = new File(String.valueOf(directoryName)); if (!directory.exists()) { directory.mkdir(); } else { FileUtils.deleteDirectory(new File(directoryName)); directory.mkdir(); } //create "inputs" directory String directoryName2 = programPath + "/Projects/" + projectName + "/inputs/"; File directory2 = new File(String.valueOf(directoryName2)); if (!directory2.exists()) { directory2.mkdir(); } //create "outputs" directory String directoryName3 = programPath + "/Projects/" + projectName + "/outputs/"; File directory3 = new File(String.valueOf(directoryName3)); if (!directory3.exists()) { directory3.mkdir(); } //create "batch" directory String directoryName4 = programPath + "/Projects/" + projectName + "/batch/"; File directory4 = new File(String.valueOf(directoryName4)); if (!directory4.exists()) { directory4.mkdir(); } else { FileUtils.deleteDirectory(new File(directoryName4)); directory4.mkdir(); } //create "designpatternName+inputs" directory String directoryName5 = programPath + "/Projects/" + projectName + "/inputs/" + designpatternName + "_inputs/"; File directory5 = new File(String.valueOf(directoryName5)); if (!directory5.exists()) { directory5.mkdir(); } else { FileUtils.deleteDirectory(new File(directoryName5)); directory5.mkdir(); } //create "designpatternName+outputs" directory String directoryName6 = programPath + "/Projects/" + projectName + "/outputs/" + designpatternName + "_outputs/"; File directory6 = new File(String.valueOf(directoryName6)); if (!directory6.exists()) { directory6.mkdir(); } else { FileUtils.deleteDirectory(new File(directoryName6)); directory6.mkdir(); } File dir = new File(tfPath.getText()); FileWalker fw = new FileWalker(); List<String> directoryListing = new ArrayList<String>(); directoryListing.clear(); directoryListing = fw.displayDirectoryContents(dir); // File[] directoryListing = dir.listFiles(); //1. visit if (directoryListing != null) { for (String child : directoryListing) { if (child.toString().contains(".java") && !child.toString().contains("package-info")) { System.out.println(child); ANTLRInputStream input = new ANTLRInputStream(new FileInputStream(child)); // we'll parse this file JavaLexer lexer = new JavaLexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); JavaParser parser = new JavaParser(tokens); ParseTree tree = parser.compilationUnit(); // see the grammar MyVisitorBase visitorbase = new MyVisitorBase(); // extends JavaBaseVisitor<Void> // and overrides the methods // you're interested visitorbase.visit(tree); } } } else { JOptionPane.showMessageDialog(null, "Could not find the path..."); return; } //2. visit if (directoryListing != null) { for (String child : directoryListing) { if (child.toString().contains(".java") && !child.toString().contains("package-info")) { //System.out.println(child); ANTLRInputStream input = new ANTLRInputStream(new FileInputStream(child)); // we'll parse this file JavaLexer lexer = new JavaLexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); JavaParser parser = new JavaParser(tokens); ParseTree tree = parser.compilationUnit(); // see the grammar MyVisitor visitor = new MyVisitor(); // extends JavaBaseVisitor<Void> // and overrides the methods // you're interested visitor.includeInnerClasses = includeInnerClasses; visitor.modifiersSet(); visitor.visit(tree); } } } //3.visit if (directoryListing != null) { for (String child : directoryListing) { if (child.toString().contains(".java") && !child.toString().contains("package-info")) { //System.out.println(child); ANTLRInputStream input = new ANTLRInputStream(new FileInputStream(child)); // we'll parse this file JavaLexer lexer = new JavaLexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); JavaParser parser = new JavaParser(tokens); ParseTree tree = parser.compilationUnit(); // see the grammar MyVisitor2 visitor2 = new MyVisitor2(); visitor2.modifiersSet(); visitor2.visit(tree); } } } try { Proba p = new Proba(); p.start(sourceCodeGraph, sourceCodeGraphDetail, designPatternGraph, designpatternName, OnlyTerminalCommands, projectName, threshold, overlap, programPath); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } taInfo.setText("----------" + designpatternName + " PATTERN (" + projectName + ")-------------" + "\n"); taInfo.append("1. Project's classes ASTs created." + "\n"); taInfo.append( "2. After treewalk of ASTs, Graph Model is created.(/Projects/" + projectName + "/source)" + "\n"); taInfo.append("3. Pool of Desing Pattern Templates is created.(/Projects/" + projectName + "/inputs/" + designpatternName + "_inputs)" + "\n"); taInfo.append("4. Heuristic function of shell script file is created.(/Projects/" + projectName + "/batch)" + "\n"); //p.start2(); Cursor normalCursor = new Cursor(Cursor.DEFAULT_CURSOR); setCursor(normalCursor); vertices.clear(); dugumler.clear(); methods.clear(); JOptionPane.showMessageDialog(null, "Graph Model is successfully completed!"); }