List of usage examples for javax.swing JOptionPane showInputDialog
public static String showInputDialog(Component parentComponent, Object message) throws HeadlessException
parentComponent
. From source file:clienteescritorio.MainFrame.java
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed MotorDeEmails.prepararMotor();//w w w . j a v a2 s . co m java.sql.Date fecha = new java.sql.Date(new Date().getTime()); String mensaje = "Solicit la grfica generada a la fecha presente\n\r Muchas gracias por utilizar nuestro servicio" + "Att: Ariel Adauta Garca Presidente de la Empresa de articulos :)"; String nuevoCorreo = JOptionPane.showInputDialog(rootPane, "Est apunto de enviarse el correo a :" + correoUsuario + "\nSi desea enviarlo a otro correo escriba en la caja de texto, si no, presione aceptar."); if (!nuevoCorreo.equals("")) { MotorDeEmails.setTo(nuevoCorreo); } else { MotorDeEmails.setTo(correoUsuario); nuevoCorreo = correoUsuario; } boolean res = MotorDeEmails.enviarEmailconArchivo("Grfica " + fecha, mensaje, directorio + imagenGrafica); if (res) { JOptionPane.showMessageDialog(rootPane, "Se envio correctamente al correo " + nuevoCorreo); } else JOptionPane.showMessageDialog(rootPane, "No se pudo enviar la grfica al correo " + correoUsuario); }
From source file:clienteescritorio.MainFrame.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed MotorDeEmails.prepararMotor();/*from w ww . j av a2 s .c o m*/ java.sql.Date fecha = new java.sql.Date(new Date().getTime()); String mensaje = "Solicit el reporte. Muchas gracias por utilizar nuestro servicio\n" + "Att: Ariel Adauta Garca Presidente de la Empresa de articulos :)"; String nuevoCorreo = JOptionPane.showInputDialog(rootPane, "Est apunto de enviarse el correo a :" + correoUsuario + "\nSi desea enviarlo a otro correo escriba en la caja de texto, si no, presione aceptar."); if (!nuevoCorreo.equals("")) { MotorDeEmails.setTo(nuevoCorreo); } else { MotorDeEmails.setTo(correoUsuario); nuevoCorreo = correoUsuario; } boolean res = pdf.pdfTest.generarPDFReporte(metodosRemotos); if (res == false) { JOptionPane.showMessageDialog(rootPane, "Ocurri un error al generar el PDF "); return; } res = MotorDeEmails.enviarEmailconArchivo("Grfica " + fecha, mensaje, directorioReporte); if (res) { JOptionPane.showMessageDialog(rootPane, "Se envio correctamente al correo " + nuevoCorreo); } else JOptionPane.showMessageDialog(rootPane, "No se pudo enviar la grfica al correo " + correoUsuario); }
From source file:com.intuit.tank.tools.script.ScriptFilterRunner.java
/** * /*from w w w.j av a2 s . c o m*/ */ protected void storeScript(boolean saveAs) { ConfiguredLanguage language = (ConfiguredLanguage) languageSelector.getSelectedItem(); if (saveAs || currentExternalScript == null) { String retVal = JOptionPane.showInputDialog("Script Name: ", "<Script Name>"); if (retVal != null) { retVal = retVal + "." + language.getDefaultExtension(); currentExternalScript = new ExternalScriptTO(); currentExternalScript.setName(retVal); currentExternalScript.setCreator(""); } else { return; } } else { currentExternalScript.setName(FilenameUtils.getBaseName(currentExternalScript.getName()) + "." + language.getDefaultExtension()); } currentExternalScript.setScript(scriptEditorTA.getText()); currentExternalScript = scriptServiceClient.saveOrUpdateExternalScript(currentExternalScript); }
From source file:de.fhg.igd.mapviewer.server.file.FileTiler.java
/** * Ask the user for an image file for that a tiled map shall be created *///w w w.ja v a2 s . c o m public void run() { JFileChooser fileChooser = new JFileChooser(); // load current dir fileChooser.setCurrentDirectory( new File(pref.get(PREF_DIR, fileChooser.getCurrentDirectory().getAbsolutePath()))); // open int returnVal = fileChooser.showOpenDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { // save current dir pref.put(PREF_DIR, fileChooser.getCurrentDirectory().getAbsolutePath()); // get file File imageFile = fileChooser.getSelectedFile(); // get image dimension Dimension size = getSize(imageFile); log.info("Image size: " + size); // ask for min tile size int minTileSize = 0; while (minTileSize <= 0) { try { minTileSize = Integer.parseInt( JOptionPane.showInputDialog("Minimal tile size", String.valueOf(DEF_MIN_TILE_SIZE))); } catch (Exception e) { minTileSize = 0; } } // determine min map width int width = size.width; while (width / 2 > minTileSize && width % 2 == 0) { width = width / 2; } int minMapWidth = width; // min map width log.info("Minimal map width: " + minMapWidth); // determine min map height int height = size.height; while (height / 2 > minTileSize && height % 2 == 0) { height = height / 2; // min map height } int minMapHeight = height; log.info("Minimal map height: " + minMapHeight); // ask for min map size int minMapSize = 0; while (minMapSize <= 0) { try { minMapSize = Integer.parseInt( JOptionPane.showInputDialog("Minimal map size", String.valueOf(DEF_MIN_MAP_SIZE))); } catch (Exception e) { minMapSize = 0; } } // determine zoom levels int zoomLevels = 1; width = size.width; height = size.height; while (width % 2 == 0 && height % 2 == 0 && width / 2 >= Math.max(minMapWidth, minMapSize) && height / 2 >= Math.max(minMapHeight, minMapSize)) { zoomLevels++; width = width / 2; height = height / 2; } log.info("Number of zoom levels: " + zoomLevels); // determine tile width width = minMapWidth; int tileWidth = minMapWidth; for (int i = 3; i < Math.sqrt(minMapWidth) && width > minTileSize;) { tileWidth = width; if (width % i == 0) { width = width / i; } else i++; } // determine tile height height = minMapHeight; int tileHeight = minMapHeight; for (int i = 3; i < Math.sqrt(minMapHeight) && height > minTileSize;) { tileHeight = height; if (height % i == 0) { height = height / i; } else i++; } // create tiles for each zoom level if (JOptionPane.showConfirmDialog(null, "Create tiles (" + tileWidth + "x" + tileHeight + ") for " + zoomLevels + " zoom levels?", "Create tiles", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { int currentWidth = size.width; int currentHeight = size.height; File currentImage = imageFile; Properties properties = new Properties(); properties.setProperty(PROP_TILE_WIDTH, String.valueOf(tileWidth)); properties.setProperty(PROP_TILE_HEIGHT, String.valueOf(tileHeight)); properties.setProperty(PROP_ZOOM_LEVELS, String.valueOf(zoomLevels)); List<File> files = new ArrayList<File>(); for (int i = 0; i < zoomLevels; i++) { int mapWidth = currentWidth / tileWidth; int mapHeight = currentHeight / tileHeight; log.info("Creating tiles for zoom level " + i); log.info("Map width: " + currentWidth + " pixels, " + mapWidth + " tiles"); log.info("Map height: " + currentHeight + " pixels, " + mapHeight + " tiles"); // create tiles tile(currentImage, TILE_FILE_PREFIX + i + TILE_FILE_SEPARATOR + "%d", TILE_FILE_EXTENSION, tileWidth, tileHeight); // add files to list for (int num = 0; num < mapWidth * mapHeight; num++) { files.add(new File(imageFile.getParentFile().getAbsolutePath() + File.separator + TILE_FILE_PREFIX + i + TILE_FILE_SEPARATOR + num + TILE_FILE_EXTENSION)); } // store map width and height at current zoom properties.setProperty(PROP_MAP_WIDTH + i, String.valueOf(mapWidth)); properties.setProperty(PROP_MAP_HEIGHT + i, String.valueOf(mapHeight)); // create image for next zoom level currentWidth /= 2; currentHeight /= 2; // create temp image file name File nextImage = suffixFile(imageFile, i + 1); // resize image convert(currentImage, nextImage, currentWidth, currentHeight, 100); // delete previous temp file if (!currentImage.equals(imageFile)) { if (!currentImage.delete()) { log.warn("Error deleting " + imageFile.getAbsolutePath()); } } currentImage = nextImage; } // delete previous temp file if (!currentImage.equals(imageFile)) { if (!currentImage.delete()) { log.warn("Error deleting " + imageFile.getAbsolutePath()); } } // write properties file File propertiesFile = new File( imageFile.getParentFile().getAbsolutePath() + File.separator + MAP_PROPERTIES_FILE); try { FileWriter propertiesWriter = new FileWriter(propertiesFile); try { properties.store(propertiesWriter, "Map generated from " + imageFile.getName()); // add properties file to list files.add(propertiesFile); } finally { propertiesWriter.close(); } } catch (IOException e) { log.error("Error writing map properties file", e); } // add a converter properties file String convProperties = askForPath(fileChooser, new ExactFileFilter(CONVERTER_PROPERTIES_FILE), "Select a converter properties file"); File convFile = null; if (convProperties != null) { convFile = new File(convProperties); files.add(convFile); } // create jar file log.info("Creating jar archive..."); if (createJarArchive(replaceExtension(imageFile, MAP_ARCHIVE_EXTENSION), files)) { log.info("Archive successfully created, deleting tiles..."); // don't delete converter properties if (convFile != null) files.remove(files.size() - 1); // delete files for (File file : files) { if (!file.delete()) { log.warn("Error deleting " + file.getAbsolutePath()); } } } log.info("Fin."); } } }
From source file:eu.europa.ec.markt.dss.applet.view.validationpolicy.EditView.java
private void valueLeafActionEdit(final MouseEvent mouseEvent, final TreePath selectedPath, final XmlDomAdapterNode clickedItem, final JTree tree) { final JPopupMenu popup = new JPopupMenu(); // Basic type : edit final JMenuItem menuItem = new JMenuItem(ResourceUtils.getI18n("EDIT")); menuItem.addActionListener(new ActionListener() { @Override//from w ww . j ava2s . c o m public void actionPerformed(ActionEvent actionEvent) { final String newValue = JOptionPane.showInputDialog(ResourceUtils.getI18n("EDIT"), clickedItem.node.getNodeValue()); if (newValue != null) { try { if (clickedItem.node instanceof Attr) { ((Attr) clickedItem.node).setValue(newValue); } else { clickedItem.node.setNodeValue(newValue); } //clickedItem.setNewValue(newValue); } catch (NumberFormatException e) { showErrorMessage(newValue, tree); } validationPolicyTreeModel.fireTreeChanged(selectedPath); } } }); popup.add(menuItem); popup.show(tree, mouseEvent.getX(), mouseEvent.getY()); }
From source file:coolmap.application.widget.impl.WidgetUserGroup.java
private void createNewGroup(ArrayList<VNode> nodes) { if (nodes.isEmpty()) { Messenger.showWarningMessage("Could not create new node group.\nNo nodes were selected.", "Selection error"); return;/*from www .ja va 2 s . c om*/ } String groupName = JOptionPane.showInputDialog(CoolMapMaster.getCMainFrame(), "Name for new node group."); if (groupName == null || groupName.length() == 0) { groupName = "Untitled"; } int counter = 0; String name = groupName; while (nodeGroups.containsKey(name)) { counter++; name = groupName + "_" + counter; } groupName = name; Color c = UI.randomColor(); ArrayList<VNode> groupNodes = new ArrayList<VNode>(); for (VNode node : nodes) { VNode copy = node.duplicate(); copy.setParentNode(null); //remove parent! copy.setViewColor(c); nodeGroups.put(groupName, copy); } if (!nodeColor.containsKey(groupName)) { nodeColor.put(groupName, c); } updateTable(); }
From source file:org.yccheok.jstock.gui.charting.ChartJDialog.java
/** * Build menu items for TA.//from ww w . j a v a2 s .co m */ private void buildTAMenuItems() { final int[] days = { 14, 28, 50, 100, 200 }; final MACD.Period[] macd_periods = { MACD.Period.newInstance(12, 26, 9) }; // day_keys, week_keys and month_keys should be having same length as // days. final String[] day_keys = { "ChartJDialog_14Days", "ChartJDialog_28Days", "ChartJDialog_50Days", "ChartJDialog_100Days", "ChartJDialog_200Days" }; final String[] week_keys = { "ChartJDialog_14Weeks", "ChartJDialog_28Weeks", "ChartJDialog_50Weeks", "ChartJDialog_100Weeks", "ChartJDialog_200Weeks" }; final String[] month_keys = { "ChartJDialog_14Months", "ChartJDialog_28Months", "ChartJDialog_50Months", "ChartJDialog_100Months", "ChartJDialog_200Months" }; assert (days.length == day_keys.length); assert (days.length == week_keys.length); assert (days.length == week_keys.length); // macd_day_keys, macd_week_keys and macd_month_keys should be having // same length as macd_periods. final String[] macd_day_keys = { "ChartJDialog_12_26_9Days" }; final String[] macd_week_keys = { "ChartJDialog_12_26_9Weeks" }; final String[] macd_month_keys = { "ChartJDialog_12_26_9Months" }; assert (macd_periods.length == macd_day_keys.length); assert (macd_periods.length == macd_week_keys.length); assert (macd_periods.length == macd_month_keys.length); String[] keys = null; String[] macd_keys = null; if (this.getCurrentInterval() == Interval.Daily) { keys = day_keys; macd_keys = macd_day_keys; } else if (this.getCurrentInterval() == Interval.Weekly) { keys = week_keys; macd_keys = macd_week_keys; } else if (this.getCurrentInterval() == Interval.Monthly) { keys = month_keys; macd_keys = macd_month_keys; } else { assert (false); } final TA[] tas = TA.values(); final String[] ta_keys = { "ChartJDialog_SMA", "ChartJDialog_EMA", "ChartJDialog_MACD", "ChartJDialog_RSI", "ChartJDialog_MFI", "ChartJDialog_CCI" }; final String[] ta_tip_keys = { "ChartJDialog_SimpleMovingAverage", "ChartJDialog_ExponentialMovingAverage", "ChartJDialog_MovingAverageConvergenceDivergence", "ChartJDialog_RelativeStrengthIndex", "ChartJDialog_MoneyFlowIndex", "ChartJDialog_CommodityChannelIndex" }; final String[] custom_message_keys = { "info_message_please_enter_number_of_days_for_SMA", "info_message_please_enter_number_of_days_for_EMA", "dummy", "info_message_please_enter_number_of_days_for_RSI", "info_message_please_enter_number_of_days_for_MFI", "info_message_please_enter_number_of_days_for_CCI" }; final Map<TA, Set<Object>> m = new EnumMap<TA, Set<Object>>(TA.class); final int taExSize = JStock.instance().getChartJDialogOptions().getTAExSize(); for (int i = 0; i < taExSize; i++) { final TAEx taEx = JStock.instance().getChartJDialogOptions().getTAEx(i); if (m.containsKey(taEx.getTA()) == false) { m.put(taEx.getTA(), new HashSet<Object>()); } m.get(taEx.getTA()).add(taEx.getParameter()); } for (int i = 0, length = tas.length; i < length; i++) { final TA ta = tas[i]; javax.swing.JMenu menu = new javax.swing.JMenu(); menu.setText(GUIBundle.getString(ta_keys[i])); // NOI18N menu.setToolTipText(GUIBundle.getString(ta_tip_keys[i])); // NOI18N if (ta == TA.MACD) { for (int j = 0, length2 = macd_periods.length; j < length2; j++) { final int _j = j; final javax.swing.JCheckBoxMenuItem item = new javax.swing.JCheckBoxMenuItem(); item.setText(GUIBundle.getString(macd_keys[j])); if (m.containsKey(ta)) { if (m.get(ta).contains(macd_periods[_j])) { item.setSelected(true); } } item.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { if (ta == TA.MACD) { updateMACD(macd_periods[_j], item.isSelected()); } } }); menu.add(item); } } else { for (int j = 0, length2 = days.length; j < length2; j++) { final int _j = j; final javax.swing.JCheckBoxMenuItem item = new javax.swing.JCheckBoxMenuItem(); item.setText(GUIBundle.getString(keys[j])); // NOI18N if (m.containsKey(ta)) { if (m.get(ta).contains(days[_j])) { item.setSelected(true); } } item.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { if (ta == TA.SMA) { updateSMA(days[_j], item.isSelected()); } else if (ta == TA.EMA) { updateEMA(days[_j], item.isSelected()); } else if (ta == TA.MFI) { updateMFI(days[_j], item.isSelected()); } else if (ta == TA.RSI) { updateRSI(days[_j], item.isSelected()); } else if (ta == TA.CCI) { updateCCI(days[_j], item.isSelected()); } } }); menu.add(item); } // for } // if (ta == TA.MACD) menu.add(new javax.swing.JSeparator()); javax.swing.JMenuItem item = new javax.swing.JMenuItem(); item.setText(GUIBundle.getString("ChartJDialog_Custom...")); // NOI18N final int _i = i; item.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { if (ta == TA.MACD) { showMACDCustomDialog(); } else { do { final String days_string = JOptionPane.showInputDialog(ChartJDialog.this, MessagesBundle.getString(custom_message_keys[_i])); if (days_string == null) { return; } try { final int days = Integer.parseInt(days_string); if (days <= 0) { JOptionPane.showMessageDialog(ChartJDialog.this, MessagesBundle.getString("info_message_number_of_days_required"), MessagesBundle.getString("info_title_number_of_days_required"), JOptionPane.WARNING_MESSAGE); continue; } ChartJDialog.this.updateTA(ta, days, true); return; } catch (java.lang.NumberFormatException exp) { log.error(null, exp); JOptionPane.showMessageDialog(ChartJDialog.this, MessagesBundle.getString("info_message_number_of_days_required"), MessagesBundle.getString("info_title_number_of_days_required"), JOptionPane.WARNING_MESSAGE); continue; } } while (true); } } }); menu.add(item); // TEMP DISABLE MACD // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! if (ta != TA.MACD) { this.jMenu2.add(menu); } } // for this.jMenu2.add(new javax.swing.JSeparator()); javax.swing.JMenuItem item = new javax.swing.JMenuItem(); item.setText(GUIBundle.getString("ChartJDialog_ClearAll")); // NOI18N item.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { ChartJDialog.this.clearAll(); } }); this.jMenu2.add(item); }
From source file:de.evaluationtool.gui.EvaluationFrameActionListener.java
private void changeLoadLimit() { try {/* w w w.ja v a 2 s.c o m*/ String input = JOptionPane.showInputDialog("Change the load limit to (0 means unlimited)", frame.getLoadLimit()); if (input == null) return; frame.setLoadLimit(Integer.valueOf(input)); FileUtils.writeStringToFile(frame.loadLimitFile, String.valueOf(frame.getLoadLimit())); } catch (NumberFormatException e) { changeLoadLimit(); } catch (IOException e) { JOptionPane.showConfirmDialog(frame, e); } }
From source file:de.evaluationtool.gui.EvaluationFrameActionListener.java
private void changeAutoEvalDistance() { try {//from w w w . ja v a 2s.c o m String input = JOptionPane.showInputDialog("Change the auto eval distance to ", frame.getAutoEvalDistance()); if (input == null) return; frame.setAutoEvalDistance(Integer.valueOf(input)); FileUtils.writeStringToFile(frame.autoEvalDistanceFile, String.valueOf(frame.getAutoEvalDistance())); } catch (NumberFormatException e) { changeLoadLimit(); } catch (IOException e) { JOptionPane.showConfirmDialog(frame, e); } }
From source file:com.jsystem.j2autoit.AutoItAgent.java
private static void createAndShowGUI() { //Check the SystemTray support if (!SystemTray.isSupported()) { Log.error("SystemTray is not supported\n"); return;/*from w ww . j a v a 2 s .co m*/ } final PopupMenu popup = new PopupMenu(); final TrayIcon trayIcon = new TrayIcon(createImage("images/jsystem_ico.gif", "tray icon")); final SystemTray tray = SystemTray.getSystemTray(); // Create a popup menu components final MenuItem aboutItem = new MenuItem("About"); final MenuItem startAgentItem = new MenuItem("Start J2AutoIt Agent"); final MenuItem stopAgentItem = new MenuItem("Stop J2AutoIt Agent"); final MenuItem exitItem = new MenuItem("Exit"); final MenuItem changePortItem = new MenuItem("Setting J2AutoIt Port"); final MenuItem deleteTemporaryFilesItem = new MenuItem("Delete J2AutoIt Script"); final MenuItem temporaryHistoryFilesItem = new MenuItem("History Size"); final MenuItem displayLogFile = new MenuItem("Log"); final MenuItem forceShutDownTimeOutItem = new MenuItem("Force ShutDown TimeOut"); final MenuItem writeConfigurationToFile = new MenuItem("Save Configuration To File"); final CheckboxMenuItem debugModeItem = new CheckboxMenuItem("Debug Mode", isDebug); final CheckboxMenuItem forceAutoItShutDownItem = new CheckboxMenuItem("Force AutoIt Script ShutDown", isForceAutoItShutDown); final CheckboxMenuItem autoDeleteHistoryItem = new CheckboxMenuItem("Auto Delete History", isAutoDeleteFiles); final CheckboxMenuItem useAutoScreenShot = new CheckboxMenuItem("Auto Screenshot", isUseScreenShot); //Add components to popup menu popup.add(aboutItem); popup.add(writeConfigurationToFile); popup.addSeparator(); popup.add(forceAutoItShutDownItem); popup.add(forceShutDownTimeOutItem); popup.addSeparator(); popup.add(debugModeItem); popup.add(displayLogFile); popup.add(useAutoScreenShot); popup.addSeparator(); popup.add(autoDeleteHistoryItem); popup.add(deleteTemporaryFilesItem); popup.add(temporaryHistoryFilesItem); popup.addSeparator(); popup.add(changePortItem); popup.addSeparator(); popup.add(startAgentItem); popup.add(stopAgentItem); popup.addSeparator(); popup.add(exitItem); trayIcon.setToolTip("J2AutoIt Agent"); trayIcon.setImageAutoSize(true); trayIcon.setPopupMenu(popup); final DisplayLogFile displayLog = new DisplayLogFile(); try { tray.add(trayIcon); } catch (AWTException e) { Log.error("TrayIcon could not be added.\n"); return; } trayIcon.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } @Override public void mousePressed(MouseEvent e) { startAgentItem.setEnabled(!serverState); stopAgentItem.setEnabled(serverState); deleteTemporaryFilesItem.setEnabled(isDebug && HistoryFile.containEntries()); autoDeleteHistoryItem.setEnabled(isDebug); temporaryHistoryFilesItem.setEnabled(isDebug && isAutoDeleteFiles); displayLogFile.setEnabled(isDebug); forceShutDownTimeOutItem.setEnabled(isForceAutoItShutDown); } @Override public void mouseReleased(MouseEvent e) { } }); writeConfigurationToFile.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { AutoItProperties.DEBUG_MODE_KEY.setValue(isDebug.toString()); AutoItProperties.AUTO_DELETE_TEMPORARY_SCRIPT_FILE_KEY.setValue(isAutoDeleteFiles.toString()); AutoItProperties.AUTO_IT_SCRIPT_HISTORY_SIZE_KEY.setValue(DEFAULT_HistorySize.toString()); AutoItProperties.FORCE_AUTO_IT_PROCESS_SHUTDOWN_KEY.setValue(isForceAutoItShutDown.toString()); AutoItProperties.AGENT_PORT_KEY.setValue(webServicePort.toString()); AutoItProperties.SERVER_UP_ON_INIT_KEY.setValue(serverState.toString()); if (!AutoItProperties.savePropertiesFileSafely()) { Log.error("Fail to save properties file"); } } }); debugModeItem.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { isDebug = (e.getStateChange() == ItemEvent.SELECTED); deleteTemporaryFilesItem.setEnabled(isDebug && HistoryFile.containEntries()); Log.infoLog("Keeping the temp file is " + (isDebug ? "en" : "dis") + "able\n"); trayIcon.displayMessage((isDebug ? "Debug" : "Normal") + " Mode", "The system will " + (isDebug ? "not " : "") + "delete \nthe temporary autoIt scripts." + (isDebug ? "\nSee log file for more info." : ""), MessageType.INFO); } }); useAutoScreenShot.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { isUseScreenShot = (e.getStateChange() == ItemEvent.SELECTED); Log.infoLog("Auto screenshot is " + (isUseScreenShot ? "" : "in") + "active\n"); } }); forceAutoItShutDownItem.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { isForceAutoItShutDown = (e.getStateChange() == ItemEvent.SELECTED); Log.infoLog((isForceAutoItShutDown ? "Force" : "Soft") + " AutoIt Script ShutDown\n"); trayIcon.displayMessage("AutoIt Script Termination", (isForceAutoItShutDown ? "Hard shutdown" : "Soft shutdown"), MessageType.INFO); } }); autoDeleteHistoryItem.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { isAutoDeleteFiles = (e.getStateChange() == ItemEvent.SELECTED); Log.infoLog((isAutoDeleteFiles ? "Auto" : "Manual") + " AutoIt Script Deletion\n"); trayIcon.displayMessage("AutoIt Script Deletion", (isAutoDeleteFiles ? "Auto" : "Manual") + " Mode", MessageType.INFO); if (isAutoDeleteFiles) { HistoryFile.init(); } else { HistoryFile.close(); } } }); forceShutDownTimeOutItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { String timeOutAsString = JOptionPane.showInputDialog( "Please Insert Force ShutDown TimeOut (in seconds)", String.valueOf(shutDownTimeOut / 1000)); try { shutDownTimeOut = 1000 * Long.parseLong(timeOutAsString); } catch (Exception e2) { } Log.infoLog("Setting the force shutdown time out to : " + (shutDownTimeOut / 1000) + " seconds.\n"); } }); displayLogFile.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { try { displayLog.reBuild(Log.getCurrentLogs()); displayLog.actionPerformed(actionEvent); } catch (Exception e2) { } } }); temporaryHistoryFilesItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { String historySize = JOptionPane.showInputDialog("Please Insert History AutoIt Script Files", String.valueOf(HistoryFile.getHistory_Size())); try { int temp = Integer.parseInt(historySize); if (temp > 0) { if (HistoryFile.getHistory_Size() != temp) { HistoryFile.setHistory_Size(temp); Log.infoLog("The history files size is " + historySize + NEW_LINE); } } else { Log.warning("Illegal History Size: " + historySize + NEW_LINE); } } catch (Exception exception) { Log.throwableLog(exception.getMessage(), exception); } } }); deleteTemporaryFilesItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { HistoryFile.forceDeleteAll(); } }); startAgentItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { runWebServer(); } }); stopAgentItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { shutDownWebServer(); } }); aboutItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { JOptionPane.showMessageDialog(null, "J2AutoIt Agent By JSystem And Aqua Software"); } }); changePortItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { String portAsString = JOptionPane.showInputDialog("Please Insert new Port", String.valueOf(webServicePort)); if (portAsString != null) { try { int temp = Integer.parseInt(portAsString); if (temp > 1000) { if (temp != webServicePort) { webServicePort = temp; shutDownWebServer(); startAutoItWebServer(webServicePort); runWebServer(); } } else { Log.warning("Port number should be greater then 1000\n"); } } catch (Exception exception) { Log.error("Illegal port number\n"); return; } } } }); exitItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { tray.remove(trayIcon); shutDownWebServer(); Log.info("Exiting from J2AutoIt Agent\n"); System.exit(0); } }); }