List of usage examples for java.awt Cursor getPredefinedCursor
public static Cursor getPredefinedCursor(int type)
From source file:net.schweerelos.parrot.ui.GraphViewComponent.java
@Override public void setModel(ParrotModel model) { removeAll();/* www . j a v a 2 s . com*/ if (model == null) { maybeSaveLayout(); layout = null; vv.setGraphLayout(null); return; } if (!(model instanceof GraphParrotModel)) { throw new IllegalArgumentException("model must be a graph model"); } this.model = model; graph = ((GraphParrotModel) model).asGraph(); popup = new NodeWrapperPopupMenu(SwingUtilities.getRoot(this), model); model.addParrotModelListener(new ParrotModelListener() { @Override public void highlightsChanged() { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { vv.fireStateChanged(); vv.repaint(); } }); } @Override public void restrictionsChanged(final Collection<NodeWrapper> currentlyHidden) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { includePredicate.setCurrentlyHidden(currentlyHidden); vv.repaint(); } }); } @Override public void modelBusy() { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { synchronized (GraphViewComponent.this.model) { if (!GraphViewComponent.this.model.isBusy()) { return; } vv.setEnabled(false); view.setEnabled(false); GraphViewComponent.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); view.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); vv.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); } } }); } @Override public void modelIdle() { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { synchronized (GraphViewComponent.this.model) { if (GraphViewComponent.this.model.isBusy()) { return; } view.setEnabled(true); vv.setEnabled(true); GraphViewComponent.this.setCursor(Cursor.getDefaultCursor()); view.setCursor(Cursor.getDefaultCursor()); vv.setCursor(Cursor.getDefaultCursor()); } } }); } }); layout = new NodeWrapperPersistentLayoutImpl(new KKLayout<NodeWrapper, NodeWrapper>(graph)); layout.setSize(new Dimension(880, 600)); String layoutFilename = getLayoutFilename(); try { if (new File(layoutFilename).canRead()) { ((PersistentLayout<NodeWrapper, NodeWrapper>) layout).restore(layoutFilename); } } catch (IOException e) { // TODO #1 Auto-generated catch block e.printStackTrace(); } catch (ClassNotFoundException e) { // TODO #1 Auto-generated catch block e.printStackTrace(); } vv.setGraphLayout(layout); GraphZoomScrollPane pane = new GraphZoomScrollPane(vv); ModeToggle modeToggle = new ModeToggle(mouse); pane.setCorner(modeToggle); add(pane, CONTENT_CONSTRAINTS); view = pane; }
From source file:com.signalcollect.sna.visualization.SignalCollectSNATopComponent.java
/** * Runs a Signal/Collect SNA method when the "Run" button is clicked * * @param evt//from www. ja v a 2 s .co m */ private void runMetricButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_runMetricButtonActionPerformed try { mainPanel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); if (jTextArea1.getText() == null) { throw new IllegalArgumentException("No file was chosen!\nPlease choose a valid .gml file"); } if (!jTextArea1.getText().contains(".gml")) { throw new IllegalArgumentException( "The chosen file doesn't have the right format!\nPlease choose a valid .gml file"); } String actualMetric = metricDropDown.getSelectedItem().toString(); if (actualMetric.equals("Degree")) { scgc = new DegreeSignalCollectGephiConnectorImpl(fileName); scgc.executeGraph(); metricValuesTextPane.setText(setMetricText(scgc.getAverage(), scgc.getAll())); } else if (actualMetric.equals("PageRank")) { scgc = new PageRankSignalCollectGephiConnectorImpl(fileName); scgc.executeGraph(); metricValuesTextPane.setText(setMetricText(scgc.getAverage(), scgc.getAll())); } else if (actualMetric.equals("Betweenness")) { scgc = new BetweennessSignalCollectGephiConnectorImpl(fileName); scgc.executeGraph(); metricValuesTextPane.setText(setMetricText(scgc.getAverage(), scgc.getAll())); } else if (actualMetric.equals("Closeness")) { scgc = new ClosenessSignalCollectGephiConnectorImpl(fileName); scgc.executeGraph(); metricValuesTextPane.setText(setMetricText(scgc.getAverage(), scgc.getAll())); } else if (actualMetric.equals("Local Cluster Coefficient")) { scgc = new LocalClusterCoefficientSignalCollectGephiConnectorImpl(fileName); scgc.executeGraph(); metricValuesTextPane.setText(setMetricText(scgc.getAverage(), scgc.getAll())); } else if (actualMetric.equals("Triad Census")) { scgc = new TriadCensusSignalCollectGephiConnectorImpl(fileName); scgc.executeGraph(); metricValuesTextPane.setText(setTriadCensusText(scgc.getAll())); } else { throw new IllegalArgumentException("invalid Signal/Collect metric chosen!\nPlease try again"); } Dimension dim = new Dimension(750, 450); metricResultFrame.setMinimumSize(dim); metricResultFrame.pack(); metricValuesTextPane.setVisible(true); metricValuesScrollPane.setVisible(true); metricResultFrame.setVisible(true); } catch (IllegalArgumentException exception) { messageFrame = new JFrame(); JOptionPane.showMessageDialog(messageFrame, exception.getMessage(), "Signal/Collect Error", JOptionPane.ERROR_MESSAGE); } catch (Exception exception) { messageFrame = new JFrame(); exception.printStackTrace(); JOptionPane.showMessageDialog(messageFrame, "Technical exception happened (" + exception.getCause() + ")", "Signal/Collect Error", JOptionPane.ERROR_MESSAGE); } finally { mainPanel.setCursor(Cursor.getDefaultCursor()); } }
From source file:com.netscape.admin.certsrv.Console.java
public Console(String adminURL, String localAdminURL, String language, String host, String uid, String passwd) { Vector<String> recentURLs = new Vector<>(); String lastUsedURL;/*from w ww . jav a2s.co m*/ common_init(language); String userid = uid; String password = passwd; if (userid == null) { userid = _preferences.getString(PREFERENCE_UID); } lastUsedURL = _preferences.getString(PREFERENCE_URL); if (lastUsedURL != null) { recentURLs.addElement(lastUsedURL); if (adminURL == null) { adminURL = lastUsedURL; } } if (adminURL == null) { adminURL = localAdminURL; } for (int count = 1; count < MAX_RECENT_URLS; count++) { String temp; temp = _preferences.getString(PREFERENCE_URL + Integer.toString(count)); if (temp != null && temp.length() > 0) recentURLs.addElement(temp); } _frame = new JFrame(); // Set the icon image so that login dialog will inherit it _frame.setIconImage(new RemoteImage("com/netscape/management/client/images/logo16.gif").getImage()); ModalDialogUtil.setWindowLocation(_frame); //enable server auth UtilConsoleGlobals.setServerAuthEnabled(true); _splashScreen = new com.netscape.management.client.console.SplashScreen(_frame); _splashScreen.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); if (_showSplashScreen) _splashScreen.showWindow(); boolean fSecondTry = false; while (true) { LoginDialog dialog = null; _splashScreen.setStatusText(_resource.getString("splash", "PleaseLogin")); _splashScreen.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); if ((adminURL == null) || (userid == null) || (password == null) || (fSecondTry)) { dialog = new LoginDialog(_frame, userid, adminURL, recentURLs); Dimension paneSize = dialog.getSize(); Dimension screenSize = dialog.getToolkit().getScreenSize(); int centerX = (screenSize.width - paneSize.width) / 2; int centerY = (screenSize.height - paneSize.height) / 2; int x = _preferences.getInt(PREFERENCE_X, centerX); int y = _preferences.getInt(PREFERENCE_Y, centerY); UtilConsoleGlobals.setAdminURL(adminURL); UtilConsoleGlobals.setAdminHelpURL(adminURL); dialog.setInitialLocation(x, y); _splashScreen.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); dialog.showModal(); if (dialog.isCancel()) System.exit(0); _splashScreen.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); userid = dialog.getUsername(); adminURL = dialog.getURL(); if (!adminURL.startsWith("http://") && !adminURL.startsWith("https://")) adminURL = "http://" + adminURL; password = dialog.getPassword(); } fSecondTry = true; UtilConsoleGlobals.setAdminURL(adminURL); UtilConsoleGlobals.setAdminHelpURL(adminURL); _consoleAdminURL = adminURL; _splashScreen.setStatusText( MessageFormat.format(_resource.getString("splash", "authenticate"), new Object[] { userid })); if (authenticate_user(adminURL, _info, userid, password)) { _splashScreen.setStatusText(_resource.getString("splash", "initializing")); /** * Initialize ldap. In the case config DS is down, the user can restart * the DS from the Console. The Console will need to re-authenticate * the user if that's the case. */ int ldapInitResult = LDAPinitialization(_info); if (ldapInitResult == LDAP_INIT_FAILED) { Debug.println("Console: LDAPinitialization() failed."); System.exit(1); } else if (ldapInitResult == LDAP_INIT_DS_RESTART) { Debug.println("Console: LDAPinitialization() DS restarted."); // Need to re-authenticate the user _splashScreen.setStatusText(MessageFormat.format(_resource.getString("splash", "authenticate"), new Object[] { userid })); if (authenticate_user(adminURL, _info, userid, password)) { _splashScreen.setStatusText(_resource.getString("splash", "initializing")); if (LDAPinitialization(_info) == LDAP_INIT_FAILED) { Debug.println("Console: LDAPinitialization() failed."); System.exit(1); } } else { continue; // Autentication faled, try again } } else if (ldapInitResult == LDAP_INIT_BIND_FAIL) { continue; } boolean rememberUserid = _preferences.getBoolean(PREFERENCE_REMEMBER_UID, true); if (rememberUserid) { _preferences.set(PREFERENCE_UID, userid); _preferences.set(PREFERENCE_URL, adminURL); String recentlyUsedURL; int count = 1; Enumeration<String> urlEnum = recentURLs.elements(); while (urlEnum.hasMoreElements()) { recentlyUsedURL = urlEnum.nextElement(); if (!recentlyUsedURL.equals(adminURL)) _preferences.set(PREFERENCE_URL + Integer.toString(count++), recentlyUsedURL); } for (; count < MAX_RECENT_URLS; count++) { _preferences.remove(PREFERENCE_URL + Integer.toString(count)); } if (dialog != null) { Point p = dialog.getLocation(); _preferences.set(PREFERENCE_X, p.x); _preferences.set(PREFERENCE_Y, p.y); dialog.dispose(); dialog = null; } _preferences.save(); } initialize(_info); if (host == null) { Framework framework = createTopologyFrame(); UtilConsoleGlobals.setRootFrame(framework.getJFrame()); } else { // popup the per server configuration UI // first get the java class name createPerInstanceUI(host); } _frame.dispose(); _splashScreen.dispose(); com.netscape.management.client.console.SplashScreen.removeInstance(); _splashScreen = null; break; } } }
From source file:org.kepler.gui.kar.ImportModuleDependenciesAction.java
/** Check the dependencies and ask the user how to proceed. */ public ImportChoice checkDependencies() { ConfigurationManager cman = ConfigurationManager.getInstance(); ConfigurationProperty cprop = cman.getProperty(KARFile.KARFILE_CONFIG_PROP_MODULE); ConfigurationProperty KARComplianceProp = cprop.getProperty(KARFile.KAR_COMPLIANCE_PROPERTY_NAME); String KARCompliance = KARComplianceProp.getValue(); final ArrayList<String> dependencies = new ArrayList<String>(); try {/*from w w w .ja v a 2 s . c o m*/ if (_dependencies != null) { // dependencies were given dependencies.addAll(_dependencies); } else if (_archiveFile != null) { // kar file was given KARFile karFile = null; try { karFile = new KARFile(_archiveFile); dependencies.addAll(karFile.getModuleDependencies()); } finally { if (karFile != null) { karFile.close(); } } } else { // karxml was given dependencies.addAll(_karXml.getModuleDependencies()); } } catch (Exception ex) { ex.printStackTrace(); } //ModuleTree moduleTree = ModuleTree.instance(); //String currentModList = formattedCurrentModuleList(moduleTree); boolean dependencyMissingFullVersion = !(ModuleDependencyUtil .isDependencyVersioningInfoComplete(dependencies)); LinkedHashMap<String, Version> unsatisfiedDependencies = ModuleDependencyUtil .getUnsatisfiedDependencies(dependencies); String keplerRestartMessage = null; String unableToOpenOrExportInStrictKARComplianceMessage = null; String manualActionRequired = null; String unSats = formattedUnsatisfiedDependencies(unsatisfiedDependencies); final List<String> unSatsAsList = new ArrayList<String>(unsatisfiedDependencies.keySet()); String formattedDependencies = formatDependencies(dependencies); String htmlBGColor = "#" + Integer.toHexString(UIManager.getColor("OptionPane.background").getRGB() & 0x00ffffff); //XXX augment if additional strictness levels added if (KARCompliance.equals(KARFile.KAR_COMPLIANCE_STRICT)) { if (dependencyMissingFullVersion) { if (_exportMode) { unableToOpenOrExportInStrictKARComplianceMessage = "<html><body bgcolor=\"" + htmlBGColor + "\">This KAR " + "lacks complete versioning information in its module-dependency list:<strong>" + formattedDependencies + "</strong><br><br>You must change your KAR opening compliance " + "preference to Relaxed before trying to export this KAR.<br><br>" + "You can Force Export, but some artifacts may not be included in the KAR.</body></html>"; } else { unableToOpenOrExportInStrictKARComplianceMessage = "<html><body bgcolor=\"" + htmlBGColor + "\">This KAR " + "lacks complete versioning information in its module-dependency list:<strong>" + formattedDependencies + "</strong><br><br>You must change your KAR opening compliance " + "preference to Relaxed before trying to open this KAR.<br><br>" + "You can attempt a Force Open, but this may cause unexpected errors.</body></html>"; } } else { if (!unsatisfiedDependencies.isEmpty()) { if (_exportMode) { keplerRestartMessage = "<html><body bgcolor=\"" + htmlBGColor + "\">Your KAR opening compliance preference is set to Strict. To export this KAR in<br>" + "Strict mode you must restart Kepler with these additional module(s):<strong>" + unSats + "</strong><br><br>Would you like to download (if necessary) and restart Kepler using these modules now?" + "<br><br><strong>WARNING: All unsaved work will be lost, and auto-updating turned off if it's on<br>" + "(re-enable using the Tools=>Module Manager...)</strong><br><br>" + "You can Force Export, but some artifacts may not be included in the KAR.</body></html>"; } else { keplerRestartMessage = "<html><body bgcolor=\"" + htmlBGColor + "\">Your KAR opening compliance preference is set to Strict. To open this KAR in<br>" + "Strict mode you must restart Kepler with these additional module(s):<strong>" + unSats + "</strong><br><br>Would you like to download (if necessary) and restart Kepler using these modules now?" + "<br><br><strong>WARNING: All unsaved work will be lost, and auto-updating turned off if it's on<br>" + "(re-enable using the Tools=>Module Manager...)</strong><br><br>" + "You can attempt a Force Open, but this may cause unexpected errors.</body></html>"; } } else { if (_exportMode) { keplerRestartMessage = "<html><body bgcolor=\"" + htmlBGColor + "\">Your KAR opening compliance preference is set to Strict. To export this KAR in<br>" + "Strict mode you must restart Kepler using this module set in this order:<strong>" + formattedDependencies + "</strong><br><br>Would you like to restart Kepler using these modules now?" + "<br><br><strong>WARNING: All unsaved work will be lost, and auto-updating turned off if it's on<br>" + "(re-enable using the Tools=>Module Manager...)</strong><br><br>" + "You can Force Export, but some artifacts may not be included in the KAR.</body></html>"; } else { keplerRestartMessage = "<html><body bgcolor=\"" + htmlBGColor + "\">Your KAR opening compliance preference is set to Strict. To open this KAR in<br>" + "Strict mode you must restart Kepler using this module set in this order:<strong>" + formattedDependencies + "</strong><br><br>Would you like to restart Kepler using these modules now?" + "<br><br><strong>WARNING: All unsaved work will be lost, and auto-updating turned off if it's on<br>" + "(re-enable using the Tools=>Module Manager...)</strong><br><br>" + "You can attempt a Force Open, but this may cause unexpected errors.</body></html>"; } } } } else if (KARCompliance.equals(KARFile.KAR_COMPLIANCE_RELAXED)) { if (dependencyMissingFullVersion) { // if there's a dependency missing full version info, situation should be either 1) a 2.0 kar, in which case // it lacks the full mod dep list and so user must use MM, or 2) it's a 2.1 kar created from an svn // checkout of kepler, in which case, the power user should use the build system to // change to unreleased versions of a suite containing the required modules as necessary if (_exportMode) { manualActionRequired = "<html><body bgcolor=\"" + htmlBGColor + "\">This KAR " + "requires the following unsatisfied module dependencies that lack complete versioning information:<strong>" + unSats + "</strong><br><br>Please use the Module Manager or build system to change to a suite that uses these modules.</strong>" + "<br><br>You can Force Export, but some artifacts may not be included in the KAR.</body></html>"; } else { manualActionRequired = "<html><body bgcolor=\"" + htmlBGColor + "\">This KAR " + "requires the following unsatisfied module dependencies that lack complete versioning information:<strong>" + unSats + "</strong><br><br>Please use the Module Manager or build system to change to a suite that uses these modules.</strong>" + "<br><br>You can attempt a Force Open, but this may cause unexpected errors.</body></html>"; } } else { if (!unsatisfiedDependencies.isEmpty()) { if (_exportMode) { keplerRestartMessage = "<html><body bgcolor=\"" + htmlBGColor + "\">This KAR requires you restart Kepler with these " + "additional module(s):<strong>" + unSats + "</strong><br><br>Would you like to " + "download (if necessary) and restart Kepler using these modules now?" + "<br><br><strong>WARNING: All unsaved work will be lost</strong><br><br>" + "You can Force Export, but some artifacts may not be included in the KAR.</body></html>"; } else { keplerRestartMessage = "<html><body bgcolor=\"" + htmlBGColor + "\">This KAR requires you restart Kepler with these " + "additional module(s):<strong>" + unSats + "</strong><br><br>Would you like to " + "download (if necessary) and restart Kepler using these modules now?" + "<br><br><strong>WARNING: All unsaved work will be lost</strong><br><br>" + "You can attempt a Force Open, but this may cause unexpected errors.</body></html>"; } } else { //THIS SHOULDN'T HAPPEN log.error( "ImportModuleDependenciesAction WARNING unsatisfiedDependencies is empty, this shouldn't happen, but is non fatal"); if (_exportMode) { keplerRestartMessage = "<html><body bgcolor=\"" + htmlBGColor + "\">This KAR requires you restart Kepler with these " + "module(s):<strong>" + formattedDependencies + "</strong><br><br>Would you like to " + "restart Kepler using these modules now?" + "<br><br><strong>WARNING: All unsaved work will be lost</strong><br><br>" + "You can Force Export, but some artifacts may not be included in the KAR.</body></html>"; } else { keplerRestartMessage = "<html><body bgcolor=\"" + htmlBGColor + "\">This KAR requires you restart Kepler with these " + "module(s):<strong>" + formattedDependencies + "</strong><br><br>Would you like to " + "restart Kepler using these modules now?" + "<br><br><strong>WARNING: All unsaved work will be lost</strong><br><br>" + "You can attempt a Force Open, but this may cause unexpected errors.</body></html>"; } } } } String[] optionsOkForceopen = { "OK", "Force Open" }; String[] optionsOkForceexport = { "OK", "Force Export" }; String[] optionsYesNoForceopen = { "Yes", "No", "Force Open" }; String[] optionsYesNoForceexport = { "Yes", "No", "Force Export" }; if (unableToOpenOrExportInStrictKARComplianceMessage != null) { JLabel label = new JLabel(unableToOpenOrExportInStrictKARComplianceMessage); if (_exportMode) { int choice = JOptionPane.showOptionDialog(parent, label, "Unable to export in Strict mode", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, optionsOkForceexport, optionsOkForceexport[0]); if (optionsOkForceexport[choice].equals("Force Export")) { return ImportChoice.FORCE_EXPORT; } } else { int choice = JOptionPane.showOptionDialog(parent, label, "Unable to open in Strict mode", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, optionsOkForceopen, optionsOkForceopen[0]); if (optionsOkForceopen[choice].equals("Force Open")) { return ImportChoice.FORCE_OPEN; } } return ImportChoice.DO_NOTHING; } if (manualActionRequired != null) { JLabel label = new JLabel(manualActionRequired); if (_exportMode) { int choice = JOptionPane.showOptionDialog(parent, label, "Use Module Manager", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, optionsOkForceexport, optionsOkForceexport[0]); if (optionsOkForceexport[choice].equals("Force Export")) { return ImportChoice.FORCE_EXPORT; } } else { int choice = JOptionPane.showOptionDialog(parent, label, "Use Module Manager", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, optionsOkForceopen, optionsOkForceopen[0]); if (optionsOkForceopen[choice].equals("Force Open")) { return ImportChoice.FORCE_OPEN; } } return ImportChoice.DO_NOTHING; } JLabel label = new JLabel(keplerRestartMessage); if (_exportMode) { int choice = JOptionPane.showOptionDialog(parent, label, "Confirm Kepler Restart", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, optionsYesNoForceexport, optionsYesNoForceexport[1]); if (optionsYesNoForceexport[choice] == "No") { // user doesn't want to download. return ImportChoice.DO_NOTHING; } else if (optionsYesNoForceexport[choice].equals("Force Export")) { return ImportChoice.FORCE_EXPORT; } } else { int choice = JOptionPane.showOptionDialog(parent, label, "Confirm Kepler Restart", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, optionsYesNoForceopen, optionsYesNoForceopen[1]); if (optionsYesNoForceopen[choice] == "No") { // user doesn't want to download. return ImportChoice.DO_NOTHING; } else if (optionsYesNoForceopen[choice].equals("Force Open")) { return ImportChoice.FORCE_OPEN; } } parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() { @Override public Void doInBackground() throws Exception { try { //download needed modules ModuleDownloader downloader = new ModuleDownloader(); ModuleDownloadProgressMonitor mdpm = new ModuleDownloadProgressMonitor(parent); downloader.addListener(mdpm); if (!unSatsAsList.isEmpty()) { downloader.downloadModules(unSatsAsList); } else { // this shouldn't happen, but if it does, resorting // to downloading all dependencies should be a safe bet log.error("ImportModuleDependenciesAction WARNING unSatsAsList is empty, " + "this shouldn't happen, but is non fatal"); downloader.downloadModules(dependencies); } //rewrite modules.txt ModulesTxt modulesTxt = ModulesTxt.instance(); modulesTxt.clear(); for (String dependency : dependencies) { //System.out.println("ImportModuleDependency doInBackground modulesTxt.add("+dependency+")"); modulesTxt.add(dependency); } modulesTxt.write(); //delete and write "unknown" to current-suite.txt CurrentSuiteTxt.delete(); CurrentSuiteTxt.setName("unknown"); // if KARCompliance is Strict, user is restarting w/ specific versions of modules // and we don't want them to potentially auto update on restart to available patches turnOffAutoUpdatesIfStrictMode(); //restart Kepler using new modules spawnNewKeplerAndQuitCurrent(); return null; } catch (Exception ex) { ex.printStackTrace(); JOptionPane.showMessageDialog(parent, "Error downloading module: " + ex.getMessage()); return null; } } @Override protected void done() { //never reached. } }; worker.execute(); parent.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); return ImportChoice.DOWNLOADING_AND_RESTARTING; }
From source file:org.omegat.gui.main.ProjectUICommands.java
public static void projectSave() { UIThreadsUtil.mustBeSwingThread();/*from www. ja v a 2 s . co m*/ if (!Core.getProject().isProjectLoaded()) { return; } // commit the current entry first Core.getEditor().commitAndLeave(); new SwingWorker<Object, Void>() { protected Object doInBackground() throws Exception { IMainWindow mainWindow = Core.getMainWindow(); Cursor hourglassCursor = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR); Cursor oldCursor = mainWindow.getCursor(); mainWindow.setCursor(hourglassCursor); mainWindow.showStatusMessageRB("MW_STATUS_SAVING"); Core.executeExclusively(true, () -> Core.getProject().saveProject(true)); mainWindow.showStatusMessageRB("MW_STATUS_SAVED"); mainWindow.setCursor(oldCursor); return null; } protected void done() { try { get(); } catch (Exception ex) { processSwingWorkerException(ex, "PP_ERROR_UNABLE_TO_READ_PROJECT_FILE"); } } }.execute(); }
From source file:rod_design_compute.ShowPanel.java
private void formMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseMoved // TODO add your handling code here: if (parent.getStatus() == parent.FOCUS) { this.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); choosePoint = null;// ww w . j a v a 2 s . c o m chooseRod = null; for (int i = 0; i < parent.arrayRodGroup.size(); i++) { if (choosePoint != null || chooseRod != null) break; chooseIndex = i; switch (parent.arrayRodGroup.get(i).getType()) { case RodGroup.SR: SR sr = (SR) (parent.arrayRodGroup.get(i)); if (distance(evt.getX(), evt.getY(), sr.getPointA()) < minDistance) choosePoint = sr.getPointA(); else if (distance(evt.getX(), evt.getY(), sr.getPointB()) < minDistance) choosePoint = sr.getPointB(); else if (sr.flag == true && distance(evt.getX(), evt.getY(), sr.getPointE()) < minDistance) choosePoint = sr.getPointE(); else if (distance(evt.getX(), evt.getY(), sr.getPointA(), sr.getPointB()) < minDistance) { chooseRod = sr.getL_dangan(); chooseRodPoint1 = sr.getPointA(); chooseRodPoint2 = sr.getPointB(); } break; case RodGroup.RRR: RRR rrr = (RRR) (parent.arrayRodGroup.get(i)); if (distance(evt.getX(), evt.getY(), rrr.getPointB()) < minDistance) choosePoint = rrr.getPointB(); else if (distance(evt.getX(), evt.getY(), rrr.getPointC()) < minDistance) choosePoint = rrr.getPointC(); else if (distance(evt.getX(), evt.getY(), rrr.getPointD()) < minDistance) choosePoint = rrr.getPointD(); else if ((rrr.flag2 == true || rrr.flag3 == true) && distance(evt.getX(), evt.getY(), rrr.getPointE()) < minDistance) choosePoint = rrr.getPointE(); else if (distance(evt.getX(), evt.getY(), rrr.getPointB(), rrr.getPointC()) < minDistance) { chooseRod = rrr.getrodL2(); chooseRodPoint1 = rrr.getPointB(); chooseRodPoint2 = rrr.getPointC(); } else if (distance(evt.getX(), evt.getY(), rrr.getPointC(), rrr.getPointD()) < minDistance) { chooseRod = rrr.getrodL3(); chooseRodPoint1 = rrr.getPointC(); chooseRodPoint2 = rrr.getPointD(); } break; case RodGroup.RRP: RRP rrp = (RRP) (parent.arrayRodGroup.get(i)); if (distance(evt.getX(), evt.getY(), rrp.getPointB()) < minDistance) choosePoint = rrp.getPointB(); else if (distance(evt.getX(), evt.getY(), rrp.getPointC()) < minDistance) choosePoint = rrp.getPointC(); else if (distance(evt.getX(), evt.getY(), rrp.getPointB(), rrp.getPointC()) < minDistance) { chooseRod = rrp.getrodL2(); chooseRodPoint1 = rrp.getPointB(); chooseRodPoint2 = rrp.getPointC(); } break; default: break; } } repaint(); } else this.setCursor(Cursor.getDefaultCursor()); }
From source file:net.sf.firemox.clickable.target.card.VirtualCard.java
public void mousePressed(MouseEvent e) { if (card.getParent() instanceof MZone) { card.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); ((MZone) card.getParent()).startDragAndDrop(card, e.getPoint()); }/*from w w w . java 2 s . c om*/ }
From source file:op.care.values.PnlValues.java
private JPanel createContentPanel4Year(final ResValueTypes vtype, final int year) { final String keyYears = vtype.getID() + ".xtypes." + Integer.toString(year) + ".year"; java.util.List<ResValue> myValues; synchronized (mapType2Values) { if (!mapType2Values.containsKey(keyYears)) { mapType2Values.put(keyYears, ResValueTools.getResValues(resident, vtype, year)); }// w w w . jav a2s. c o m if (mapType2Values.get(keyYears).isEmpty()) { JLabel lbl = new JLabel(SYSTools.xx("misc.msg.novalue")); JPanel pnl = new JPanel(); pnl.add(lbl); return pnl; } myValues = mapType2Values.get(keyYears); } JPanel pnlYear = new JPanel(new VerticalLayout()); pnlYear.setOpaque(false); for (final ResValue resValue : myValues) { String title = "<html><table border=\"0\">" + "<tr>" + "<td width=\"200\" align=\"left\">" + DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.SHORT).format(resValue.getPit()) + " [" + resValue.getID() + "]</td>" + "<td width=\"340\" align=\"left\">" + ResValueTools.getValueAsHTML(resValue) + "</td>" + "<td width=\"200\" align=\"left\">" + resValue.getUser().getFullname() + "</td>" + "</tr>" + "</table>" + "</html>"; final DefaultCPTitle pnlTitle = new DefaultCPTitle(title, null); pnlTitle.getMain().setBackground(GUITools.blend(vtype.getColor(), Color.WHITE, 0.1f)); pnlTitle.getMain().setOpaque(true); if (resValue.isObsolete()) { pnlTitle.getAdditionalIconPanel().add(new JLabel(SYSConst.icon22eraser)); } if (resValue.isReplacement()) { pnlTitle.getAdditionalIconPanel().add(new JLabel(SYSConst.icon22edited)); } if (!resValue.getText().trim().isEmpty()) { pnlTitle.getAdditionalIconPanel().add(new JLabel(SYSConst.icon22info)); } if (pnlTitle.getAdditionalIconPanel().getComponentCount() > 0) { pnlTitle.getButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { GUITools.showPopup( GUITools.getHTMLPopup(pnlTitle.getButton(), ResValueTools.getInfoAsHTML(resValue)), SwingConstants.NORTH); } }); } if (!resValue.getAttachedFilesConnections().isEmpty()) { /*** * _ _ _____ _ _ * | |__ | |_ _ __ | ___(_) | ___ ___ * | '_ \| __| '_ \| |_ | | |/ _ \/ __| * | |_) | |_| | | | _| | | | __/\__ \ * |_.__/ \__|_| |_|_| |_|_|\___||___/ * */ final JButton btnFiles = new JButton( Integer.toString(resValue.getAttachedFilesConnections().size()), SYSConst.icon22greenStar); btnFiles.setToolTipText(SYSTools.xx("misc.btnfiles.tooltip")); btnFiles.setForeground(Color.BLUE); btnFiles.setHorizontalTextPosition(SwingUtilities.CENTER); btnFiles.setFont(SYSConst.ARIAL18BOLD); btnFiles.setPressedIcon(SYSConst.icon22Pressed); btnFiles.setAlignmentX(Component.RIGHT_ALIGNMENT); btnFiles.setAlignmentY(Component.TOP_ALIGNMENT); btnFiles.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnFiles.setContentAreaFilled(false); btnFiles.setBorder(null); btnFiles.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgFiles(resValue, new Closure() { @Override public void execute(Object o) { EntityManager em = OPDE.createEM(); final ResValue myValue = em.find(ResValue.class, resValue.getID()); em.close(); synchronized (mapType2Values) { mapType2Values.get(keyYears).remove(resValue); mapType2Values.get(keyYears).add(myValue); Collections.sort(mapType2Values.get(keyYears)); } createCP4Year(vtype, year); buildPanel(); } }); } }); btnFiles.setEnabled(OPDE.isFTPworking()); pnlTitle.getRight().add(btnFiles); } if (!resValue.getAttachedProcessConnections().isEmpty()) { /*** * _ _ ____ * | |__ | |_ _ __ | _ \ _ __ ___ ___ ___ ___ ___ * | '_ \| __| '_ \| |_) | '__/ _ \ / __/ _ \/ __/ __| * | |_) | |_| | | | __/| | | (_) | (_| __/\__ \__ \ * |_.__/ \__|_| |_|_| |_| \___/ \___\___||___/___/ * */ final JButton btnProcess = new JButton( Integer.toString(resValue.getAttachedProcessConnections().size()), SYSConst.icon22redStar); btnProcess.setToolTipText(SYSTools.xx("misc.btnprocess.tooltip")); btnProcess.setForeground(Color.YELLOW); btnProcess.setHorizontalTextPosition(SwingUtilities.CENTER); btnProcess.setFont(SYSConst.ARIAL18BOLD); btnProcess.setPressedIcon(SYSConst.icon22Pressed); btnProcess.setAlignmentX(Component.RIGHT_ALIGNMENT); btnProcess.setAlignmentY(Component.TOP_ALIGNMENT); btnProcess.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnProcess.setContentAreaFilled(false); btnProcess.setBorder(null); btnProcess.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgProcessAssign(resValue, new Closure() { @Override public void execute(Object o) { if (o == null) { return; } Pair<ArrayList<QProcess>, ArrayList<QProcess>> result = (Pair<ArrayList<QProcess>, ArrayList<QProcess>>) o; ArrayList<QProcess> assigned = result.getFirst(); ArrayList<QProcess> unassigned = result.getSecond(); EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); ResValue myValue = em.merge(resValue); em.lock(myValue, LockModeType.OPTIMISTIC_FORCE_INCREMENT); ArrayList<SYSVAL2PROCESS> attached = new ArrayList<SYSVAL2PROCESS>( resValue.getAttachedProcessConnections()); for (SYSVAL2PROCESS linkObject : attached) { if (unassigned.contains(linkObject.getQProcess())) { linkObject.getQProcess().getAttachedNReportConnections() .remove(linkObject); linkObject.getResValue().getAttachedProcessConnections() .remove(linkObject); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_REMOVE_ELEMENT) + ": " + myValue.getTitle() + " ID: " + myValue.getID(), PReportTools.PREPORT_TYPE_REMOVE_ELEMENT, linkObject.getQProcess())); em.remove(linkObject); } } attached.clear(); for (QProcess qProcess : assigned) { java.util.List<QProcessElement> listElements = qProcess.getElements(); if (!listElements.contains(myValue)) { QProcess myQProcess = em.merge(qProcess); SYSVAL2PROCESS myLinkObject = em .merge(new SYSVAL2PROCESS(myQProcess, myValue)); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_ASSIGN_ELEMENT) + ": " + myValue.getTitle() + " ID: " + myValue.getID(), PReportTools.PREPORT_TYPE_ASSIGN_ELEMENT, myQProcess)); qProcess.getAttachedResValueConnections().add(myLinkObject); myValue.getAttachedProcessConnections().add(myLinkObject); } } em.getTransaction().commit(); synchronized (mapType2Values) { mapType2Values.get(keyYears).remove(resValue); mapType2Values.get(keyYears).add(myValue); Collections.sort(mapType2Values.get(keyYears)); } createCP4Year(vtype, year); buildPanel(); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (RollbackException ole) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } }); } }); btnProcess.setEnabled(OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)); pnlTitle.getRight().add(btnProcess); } /*** * __ __ * | \/ | ___ _ __ _ _ * | |\/| |/ _ \ '_ \| | | | * | | | | __/ | | | |_| | * |_| |_|\___|_| |_|\__,_| * */ final JButton btnMenu = new JButton(SYSConst.icon22menu); btnMenu.setPressedIcon(SYSConst.icon22Pressed); btnMenu.setAlignmentX(Component.RIGHT_ALIGNMENT); btnMenu.setAlignmentY(Component.TOP_ALIGNMENT); btnMenu.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnMenu.setContentAreaFilled(false); btnMenu.setBorder(null); btnMenu.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JidePopup popup = new JidePopup(); popup.setMovable(false); popup.getContentPane().setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS)); popup.setOwner(btnMenu); popup.removeExcludedComponent(btnMenu); JPanel pnl = getMenu(resValue); popup.getContentPane().add(pnl); popup.setDefaultFocusComponent(pnl); GUITools.showPopup(popup, SwingConstants.WEST); } }); btnMenu.setEnabled(!resValue.isObsolete()); pnlTitle.getRight().add(btnMenu); pnlYear.add(pnlTitle.getMain()); synchronized (linemap) { linemap.put(resValue, pnlTitle.getMain()); } } return pnlYear; }
From source file:com.sshtools.sshterm.SshTermSessionPanel.java
/** * *///from w w w. ja v a2 s . c o m public void printScreen() { try { PrinterJob job = PrinterJob.getPrinterJob(); job.setPrintable(terminal, pageFormat); if (job.printDialog()) { setCursor(Cursor.getPredefinedCursor(3)); job.print(); setCursor(Cursor.getPredefinedCursor(0)); } } catch (PrinterException pe) { JOptionPane.showMessageDialog(this, pe.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } }
From source file:de.juwimm.cms.content.panel.PanDocuments.java
private void upload(String prosa, Integer unit, Integer viewComponentId, Integer documentId) { this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); JFileChooser fc = new JFileChooser(); int ff = fc.getChoosableFileFilters().length; FileFilter[] fft = fc.getChoosableFileFilters(); for (int i = 0; i < ff; i++) { fc.removeChoosableFileFilter(fft[i]); }/*w w w.j av a 2 s . c o m*/ fc.addChoosableFileFilter(new DocumentFilter()); fc.setAccessory(new ImagePreview(fc)); fc.setDialogTitle(prosa); fc.setMultiSelectionEnabled(true); fc.setCurrentDirectory(Constants.LAST_LOCAL_UPLOAD_DIR); int returnVal = fc.showDialog(this, Messages.getString("panel.content.documents.addDocument")); if (returnVal == JFileChooser.APPROVE_OPTION) { File[] files = fc.getSelectedFiles(); uploadFiles(files, unit, viewComponentId, documentId); Constants.LAST_LOCAL_UPLOAD_DIR = fc.getCurrentDirectory(); } this.setCursor(Cursor.getDefaultCursor()); }