List of usage examples for javax.swing JOptionPane OK_CANCEL_OPTION
int OK_CANCEL_OPTION
To view the source code for javax.swing JOptionPane OK_CANCEL_OPTION.
Click Source Link
showConfirmDialog
. From source file:ch.admin.hermes.etl.load.HermesETLApplication.java
/** * CommandLine parse und fehlende Argumente verlangen * @param args Args//from w w w . ja va 2 s . c o m * @throws ParseException */ private static void parseCommandLine(String[] args) throws Exception { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); // HACK um UTF-8 CharSet fuer alle Dateien zu setzen (http://stackoverflow.com/questions/361975/setting-the-default-java-character-encoding) System.setProperty("file.encoding", "UTF-8"); Field charset = Charset.class.getDeclaredField("defaultCharset"); charset.setAccessible(true); charset.set(null, null); // commandline Options - FremdsystemSite, Username und Password Options options = new Options(); options.addOption("s", true, "Zielsystem - URL"); options.addOption("u", true, "Zielsystem - Username"); options.addOption("p", true, "Zielsystem - Password"); CommandLineParser parser = new PosixParser(); CommandLine cmd = parser.parse(options, args); site = cmd.getOptionValue("s"); user = cmd.getOptionValue("u"); passwd = cmd.getOptionValue("p"); // restliche Argumente pruefen - sonst usage ausgeben String[] others = cmd.getArgs(); if (others.length >= 1 && (others[0].endsWith(".js") || others[0].endsWith(".ftl"))) script = others[0]; if (others.length >= 2 && others[1].endsWith(".xml")) model = others[1]; // Dialog mit allen Werten zusammenstellen JComboBox<String> scenarios = new JComboBox<String>(crawler.getScenarios()); JTextField tsite = new JTextField(45); tsite.setText(site); JTextField tuser = new JTextField(16); tuser.setText(user); JPasswordField tpasswd = new JPasswordField(16); tpasswd.setText(passwd); final JTextField tscript = new JTextField(45); tscript.setText(script); final JTextField tmodel = new JTextField(45); tmodel.setText(model); JPanel myPanel = new JPanel(new GridLayout(6, 2)); myPanel.add(new JLabel("Szenario (von http://www.hermes.admin.ch):")); myPanel.add(scenarios); myPanel.add(new JLabel("XML Model:")); myPanel.add(tmodel); JPanel pmodel = new JPanel(); pmodel.add(tmodel); JButton bmodel = new JButton("..."); pmodel.add(bmodel); bmodel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { model = getFile("Szenario XML Model", new String[] { "XML Model" }, new String[] { ".xml" }); if (model != null) tmodel.setText(model); } }); myPanel.add(pmodel); scenarios.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { try { Object o = e.getItem(); tmodel.setText(crawler.getModelURL(o.toString())); scenario = o.toString(); } catch (Exception e1) { } } }); // Script myPanel.add(new JLabel("Umwandlungs-Script:")); JPanel pscript = new JPanel(); pscript.add(tscript); JButton bscript = new JButton("..."); pscript.add(bscript); myPanel.add(pscript); bscript.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { script = getFile("JavaScript/Freemarker Umwandlungs-Script", new String[] { "JavaScript", "Freemarker" }, new String[] { ".js", ".ftl" }); if (script != null) tscript.setText(script); } }); // Zielsystem Angaben myPanel.add(new JLabel("Zielsystem URL:")); myPanel.add(tsite); myPanel.add(new JLabel("Zielsystem Benutzer:")); myPanel.add(tuser); myPanel.add(new JLabel("Zielsystem Password:")); myPanel.add(tpasswd); // Trick um Feld scenario und model zu setzen. if (scenarios.getItemCount() >= 8) scenarios.setSelectedIndex(8); // Dialog int result = JOptionPane.showConfirmDialog(null, myPanel, "HERMES 5 XML Model nach Fremdsystem/Format", JOptionPane.OK_CANCEL_OPTION); if (result == JOptionPane.OK_OPTION) { site = tsite.getText(); user = tuser.getText(); passwd = new String(tpasswd.getPassword()); model = tmodel.getText(); script = tscript.getText(); } else System.exit(1); if (model == null || script == null || script.trim().length() == 0) usage(); if (script.endsWith(".js")) if (site == null || user == null || passwd == null || user.trim().length() == 0 || passwd.trim().length() == 0) usage(); }
From source file:com.eviware.soapui.DefaultSoapUICore.java
protected Settings initSettings(String fileName) { // TODO Why try to load settings from current directory before using root? // This caused a bug in Eclipse: // https://sourceforge.net/tracker/?func=detail&atid=737763&aid=2620284&group_id=136013 File settingsFile = new File(fileName).exists() ? new File(fileName) : null; try {//from w w w. j a va2s . co m if (settingsFile == null) { settingsFile = new File(new File(getRoot()), DEFAULT_SETTINGS_FILE); if (!settingsFile.exists()) { settingsFile = new File(new File(System.getProperty("user.home", ".")), DEFAULT_SETTINGS_FILE); lastSettingsLoad = 0; } } else { settingsFile = new File(fileName); if (!settingsFile.getAbsolutePath().equals(this.settingsFile)) lastSettingsLoad = 0; } if (!settingsFile.exists()) { if (settingsDocument == null) { log.info("Creating new settings at [" + settingsFile.getAbsolutePath() + "]"); settingsDocument = SoapuiSettingsDocumentConfig.Factory.newInstance(); setInitialImport(true); } lastSettingsLoad = System.currentTimeMillis(); } else if (settingsFile.lastModified() > lastSettingsLoad) { settingsDocument = SoapuiSettingsDocumentConfig.Factory.parse(settingsFile); byte[] encryptedContent = settingsDocument.getSoapuiSettings().getEncryptedContent(); if (encryptedContent != null) { char[] password = null; if (this.password == null) { // swing element -!! uh! JPasswordField passwordField = new JPasswordField(); JLabel qLabel = new JLabel("Password"); JOptionPane.showConfirmDialog(null, new Object[] { qLabel, passwordField }, "Global Settings", JOptionPane.OK_CANCEL_OPTION); password = passwordField.getPassword(); } else { password = this.password.toCharArray(); } byte[] data = OpenSSL.decrypt("des3", password, encryptedContent); try { settingsDocument = SoapuiSettingsDocumentConfig.Factory.parse(new String(data, "UTF-8")); } catch (Exception e) { log.warn("Wrong password."); JOptionPane.showMessageDialog(null, "Wrong password, creating backup settings file [ " + settingsFile.getAbsolutePath() + ".bak.xml. ]\nSwitch to default settings.", "Error - Wrong Password", JOptionPane.ERROR_MESSAGE); settingsDocument.save(new File(settingsFile.getAbsolutePath() + ".bak.xml")); throw e; } } log.info("initialized soapui-settings from [" + settingsFile.getAbsolutePath() + "]"); lastSettingsLoad = settingsFile.lastModified(); if (settingsWatcher == null) { settingsWatcher = new SettingsWatcher(); SoapUI.getSoapUITimer().scheduleAtFixedRate(settingsWatcher, 10000, 10000); } } } catch (Exception e) { log.warn("Failed to load settings from [" + e.getMessage() + "], creating new"); settingsDocument = SoapuiSettingsDocumentConfig.Factory.newInstance(); lastSettingsLoad = 0; } if (settingsDocument.getSoapuiSettings() == null) { settingsDocument.addNewSoapuiSettings(); settings = new XmlBeansSettingsImpl(null, null, settingsDocument.getSoapuiSettings()); initDefaultSettings(settings); } else { settings = new XmlBeansSettingsImpl(null, null, settingsDocument.getSoapuiSettings()); } this.settingsFile = settingsFile.getAbsolutePath(); if (!settings.isSet(WsdlSettings.EXCLUDED_TYPES)) { StringList list = new StringList(); list.add("schema@http://www.w3.org/2001/XMLSchema"); settings.setString(WsdlSettings.EXCLUDED_TYPES, list.toXml()); } if (!settings.isSet(WebRecordingSettings.EXCLUDED_HEADERS)) { StringList list = new StringList(); list.add("Cookie"); list.add("Set-Cookie"); list.add("Referer"); list.add("Keep-Alive"); list.add("Connection"); list.add("Proxy-Connection"); list.add("Pragma"); list.add("Cache-Control"); list.add("Transfer-Encoding"); list.add("Date"); settings.setString(WebRecordingSettings.EXCLUDED_HEADERS, list.toXml()); } if (settings.getString(HttpSettings.HTTP_VERSION, HttpSettings.HTTP_VERSION_1_1) .equals(HttpSettings.HTTP_VERSION_0_9)) { settings.setString(HttpSettings.HTTP_VERSION, HttpSettings.HTTP_VERSION_1_1); } setIfNotSet(WsdlSettings.NAME_WITH_BINDING, true); setIfNotSet(WsdlSettings.NAME_WITH_BINDING, 500); setIfNotSet(HttpSettings.HTTP_VERSION, HttpSettings.HTTP_VERSION_1_1); setIfNotSet(HttpSettings.MAX_TOTAL_CONNECTIONS, 2000); setIfNotSet(HttpSettings.RESPONSE_COMPRESSION, true); setIfNotSet(HttpSettings.LEAVE_MOCKENGINE, true); setIfNotSet(UISettings.AUTO_SAVE_PROJECTS_ON_EXIT, true); setIfNotSet(UISettings.SHOW_DESCRIPTIONS, true); setIfNotSet(WsdlSettings.XML_GENERATION_ALWAYS_INCLUDE_OPTIONAL_ELEMENTS, true); setIfNotSet(WsaSettings.USE_DEFAULT_RELATES_TO, true); setIfNotSet(WsaSettings.USE_DEFAULT_RELATIONSHIP_TYPE, true); setIfNotSet(UISettings.SHOW_STARTUP_PAGE, true); setIfNotSet(UISettings.GC_INTERVAL, "60"); setIfNotSet(WsdlSettings.CACHE_WSDLS, true); setIfNotSet(WsdlSettings.PRETTY_PRINT_RESPONSE_MESSAGES, true); setIfNotSet(HttpSettings.RESPONSE_COMPRESSION, true); setIfNotSet(HttpSettings.INCLUDE_REQUEST_IN_TIME_TAKEN, true); setIfNotSet(HttpSettings.INCLUDE_RESPONSE_IN_TIME_TAKEN, true); setIfNotSet(HttpSettings.LEAVE_MOCKENGINE, true); setIfNotSet(UISettings.AUTO_SAVE_INTERVAL, "0"); setIfNotSet(UISettings.GC_INTERVAL, "60"); setIfNotSet(UISettings.SHOW_STARTUP_PAGE, true); setIfNotSet(WsaSettings.SOAP_ACTION_OVERRIDES_WSA_ACTION, false); setIfNotSet(WsaSettings.USE_DEFAULT_RELATIONSHIP_TYPE, true); setIfNotSet(WsaSettings.USE_DEFAULT_RELATES_TO, true); setIfNotSet(WsaSettings.OVERRIDE_EXISTING_HEADERS, false); setIfNotSet(WsaSettings.ENABLE_FOR_OPTIONAL, false); setIfNotSet(VersionUpdateSettings.AUTO_CHECK_VERSION_UPDATE, true); boolean setWsiDir = false; String wsiLocationString = settings.getString(WSISettings.WSI_LOCATION, null); if (StringUtils.isNullOrEmpty(wsiLocationString)) { setWsiDir = true; } else { File wsiFile = new File(wsiLocationString); if (!wsiFile.exists()) { setWsiDir = true; } } if (setWsiDir) { String wsiDir = System.getProperty("wsi.dir", new File(".").getAbsolutePath()); settings.setString(WSISettings.WSI_LOCATION, wsiDir); } HttpClientSupport.addSSLListener(settings); return settings; }
From source file:com.entertailion.java.fling.FlingFrame.java
public FlingFrame(String appId) { super();/*from w ww . ja va 2 s . c o m*/ this.appId = appId; rampClient = new RampClient(this); addWindowListener(this); simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); Locale locale = Locale.getDefault(); resourceBundle = ResourceBundle.getBundle("com/entertailion/java/fling/resources/resources", locale); setTitle(MessageFormat.format(resourceBundle.getString("fling.title"), Fling.VERSION)); JPanel listPane = new JPanel(); // show list of ChromeCast devices detected on the local network listPane.setLayout(new BoxLayout(listPane, BoxLayout.PAGE_AXIS)); JPanel devicePane = new JPanel(); devicePane.setLayout(new BoxLayout(devicePane, BoxLayout.LINE_AXIS)); deviceList = new JComboBox(); deviceList.addActionListener(this); devicePane.add(deviceList); URL url = ClassLoader.getSystemResource("com/entertailion/java/fling/resources/refresh.png"); ImageIcon icon = new ImageIcon(url, resourceBundle.getString("button.refresh")); refreshButton = new JButton(icon); refreshButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // refresh the list of devices if (deviceList.getItemCount() > 0) { deviceList.setSelectedIndex(0); } discoverDevices(); } }); refreshButton.setToolTipText(resourceBundle.getString("button.refresh")); devicePane.add(refreshButton); url = ClassLoader.getSystemResource("com/entertailion/java/fling/resources/settings.png"); icon = new ImageIcon(url, resourceBundle.getString("settings.title")); settingsButton = new JButton(icon); settingsButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JTextField transcodingExtensions = new JTextField(50); transcodingExtensions.setText(transcodingExtensionValues); JTextField transcodingParameters = new JTextField(50); transcodingParameters.setText(transcodingParameterValues); JPanel myPanel = new JPanel(new BorderLayout()); JPanel labelPanel = new JPanel(new GridLayout(3, 1)); JPanel fieldPanel = new JPanel(new GridLayout(3, 1)); myPanel.add(labelPanel, BorderLayout.WEST); myPanel.add(fieldPanel, BorderLayout.CENTER); labelPanel.add(new JLabel(resourceBundle.getString("transcoding.extensions"), JLabel.RIGHT)); fieldPanel.add(transcodingExtensions); labelPanel.add(new JLabel(resourceBundle.getString("transcoding.parameters"), JLabel.RIGHT)); fieldPanel.add(transcodingParameters); labelPanel.add(new JLabel(resourceBundle.getString("device.manual"), JLabel.RIGHT)); JPanel devicePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); final JComboBox manualDeviceList = new JComboBox(); if (manualServers.size() == 0) { manualDeviceList.setVisible(false); } else { for (DialServer dialServer : manualServers) { manualDeviceList.addItem(dialServer); } } devicePanel.add(manualDeviceList); JButton addButton = new JButton(resourceBundle.getString("device.manual.add")); addButton.setToolTipText(resourceBundle.getString("device.manual.add.tooltip")); addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JTextField name = new JTextField(); JTextField ipAddress = new JTextField(); Object[] message = { resourceBundle.getString("device.manual.name") + ":", name, resourceBundle.getString("device.manual.ipaddress") + ":", ipAddress }; int option = JOptionPane.showConfirmDialog(null, message, resourceBundle.getString("device.manual"), JOptionPane.OK_CANCEL_OPTION); if (option == JOptionPane.OK_OPTION) { try { manualServers.add( new DialServer(name.getText(), InetAddress.getByName(ipAddress.getText()))); Object selected = deviceList.getSelectedItem(); int selectedIndex = deviceList.getSelectedIndex(); deviceList.removeAllItems(); deviceList.addItem(resourceBundle.getString("devices.select")); for (DialServer dialServer : servers) { deviceList.addItem(dialServer); } for (DialServer dialServer : manualServers) { deviceList.addItem(dialServer); } deviceList.invalidate(); if (selectedIndex > 0) { deviceList.setSelectedItem(selected); } else { if (deviceList.getItemCount() == 2) { // Automatically select single device deviceList.setSelectedIndex(1); } } manualDeviceList.removeAllItems(); for (DialServer dialServer : manualServers) { manualDeviceList.addItem(dialServer); } manualDeviceList.setVisible(true); storeProperties(); } catch (UnknownHostException e1) { Log.e(LOG_TAG, "manual IP address", e1); JOptionPane.showMessageDialog(FlingFrame.this, resourceBundle.getString("device.manual.invalidip")); } } } }); devicePanel.add(addButton); JButton removeButton = new JButton(resourceBundle.getString("device.manual.remove")); removeButton.setToolTipText(resourceBundle.getString("device.manual.remove.tooltip")); removeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Object selected = manualDeviceList.getSelectedItem(); manualDeviceList.removeItem(selected); if (manualDeviceList.getItemCount() == 0) { manualDeviceList.setVisible(false); } deviceList.removeItem(selected); deviceList.invalidate(); manualServers.remove(selected); storeProperties(); } }); devicePanel.add(removeButton); fieldPanel.add(devicePanel); int result = JOptionPane.showConfirmDialog(FlingFrame.this, myPanel, resourceBundle.getString("settings.title"), JOptionPane.OK_CANCEL_OPTION); if (result == JOptionPane.OK_OPTION) { transcodingParameterValues = transcodingParameters.getText(); transcodingExtensionValues = transcodingExtensions.getText(); storeProperties(); } } }); settingsButton.setToolTipText(resourceBundle.getString("settings.title")); devicePane.add(settingsButton); listPane.add(devicePane); // TODO volume = new JSlider(JSlider.VERTICAL, 0, 100, 0); volume.setUI(new MySliderUI(volume)); volume.setMajorTickSpacing(25); // volume.setMinorTickSpacing(5); volume.setPaintTicks(true); volume.setEnabled(true); volume.setValue(100); volume.setToolTipText(resourceBundle.getString("volume.title")); volume.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSlider source = (JSlider) e.getSource(); if (!source.getValueIsAdjusting()) { int position = (int) source.getValue(); rampClient.volume(position / 100.0f); } } }); JPanel centerPanel = new JPanel(new BorderLayout()); // centerPanel.add(volume, BorderLayout.WEST); centerPanel.add(DragHereIcon.makeUI(this), BorderLayout.CENTER); listPane.add(centerPanel); scrubber = new JSlider(JSlider.HORIZONTAL, 0, 100, 0); scrubber.addChangeListener(this); scrubber.setMajorTickSpacing(25); scrubber.setMinorTickSpacing(5); scrubber.setPaintTicks(true); scrubber.setEnabled(false); listPane.add(scrubber); // panel of playback buttons JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); label = new JLabel("00:00:00"); buttonPane.add(label); url = ClassLoader.getSystemResource("com/entertailion/java/fling/resources/play.png"); icon = new ImageIcon(url, resourceBundle.getString("button.play")); playButton = new JButton(icon); playButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { rampClient.play(); } }); buttonPane.add(playButton); url = ClassLoader.getSystemResource("com/entertailion/java/fling/resources/pause.png"); icon = new ImageIcon(url, resourceBundle.getString("button.pause")); pauseButton = new JButton(icon); pauseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { rampClient.pause(); } }); buttonPane.add(pauseButton); url = ClassLoader.getSystemResource("com/entertailion/java/fling/resources/stop.png"); icon = new ImageIcon(url, resourceBundle.getString("button.stop")); stopButton = new JButton(icon); stopButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { rampClient.stop(); setDuration(0); scrubber.setValue(0); scrubber.setEnabled(false); } }); buttonPane.add(stopButton); listPane.add(buttonPane); getContentPane().add(listPane); createProgressDialog(); startWebserver(); discoverDevices(); }
From source file:com.smanempat.controller.ControllerClassification.java
public String[] processMining(JTextField textNumberOfK, JTable tablePreview, JLabel labelPesanError, JTable tableResult, JLabel labelSiswaIPA, JLabel labelSiswaIPS, JLabel labelKeterangan, JYearChooser jYearChooser1, JYearChooser jYearChooser2, JTabbedPane jTabbedPane1) { String numberValidate = textNumberOfK.getText(); ModelClassification modelClassification = new ModelClassification(); int rowCountModel = modelClassification.getRowCount(); int rowCountData = tablePreview.getRowCount(); System.out.println("Row Count Data : " + rowCountData); System.out.println("Row Count Model : " + rowCountModel); String[] knnValue = null;/*from w w w .j av a 2 s .c o m*/ /*Validasi Nilai Number of Nearest Neighbor*/ if (Pattern.matches("[0-9]+", numberValidate) == false && numberValidate.length() > 0) { labelPesanError.setText("Number of Nearest Neighbor tidak valid"); JOptionPane.showMessageDialog(null, "Number of Nearest Neighbor tidak valid!", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon("src/com/smanempat/image/fail.png")); textNumberOfK.requestFocus(); } else if (numberValidate.isEmpty()) { JOptionPane.showMessageDialog(null, "Number of Nearest Neighbor tidak boleh kosong!", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon("src/com/smanempat/image/fail.png")); labelPesanError.setText("Number of Nearest Neighbor tidak boleh kosong"); textNumberOfK.requestFocus(); } else if (Integer.parseInt(numberValidate) >= rowCountModel) { labelPesanError.setText("Number of Nearest Neighbor tidak boleh lebih dari " + rowCountModel + ""); JOptionPane.showMessageDialog(null, "Number of Nearest Neighbor tidak boleh lebih dari " + rowCountModel + " !", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon("src/com/smanempat/image/fail.png")); textNumberOfK.requestFocus(); } else { int confirm = 0; confirm = JOptionPane.showOptionDialog(null, "Yakin ingin memproses data?", "Proses Klasifikasi", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); if (confirm == JOptionPane.OK_OPTION) { int kValue = Integer.parseInt(textNumberOfK.getText()); String[][] modelValue = getModelValue(rowCountModel); double[][] dataValue = getDataValue(rowCountData, tablePreview); knnValue = getKNNValue(rowCountData, rowCountModel, modelValue, dataValue, kValue); showClassificationResult(tableResult, tablePreview, knnValue, rowCountData, labelSiswaIPA, labelSiswaIPS, labelKeterangan, jYearChooser1, jYearChooser2, kValue); jTabbedPane1.setSelectedIndex(1); } } return knnValue; }
From source file:be.fedict.eid.tsl.tool.TslTool.java
@Override public void actionPerformed(ActionEvent event) { String command = event.getActionCommand(); if (EXIT_ACTION_COMMAND.equals(command)) { System.exit(0);/*from ww w . j av a2 s . c o m*/ } else if (OPEN_ACTION_COMMAND.equals(command)) { JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogTitle("Open TSL"); int returnValue = fileChooser.showOpenDialog(this); if (returnValue == JFileChooser.APPROVE_OPTION) { displayTsl(fileChooser.getSelectedFile()); } } else if (ABOUT_ACTION_COMMAND.equals(command)) { JOptionPane.showMessageDialog(this, "eID TSL Tool\n" + "Copyright (C) 2009-2013 FedICT\n" + "http://code.google.com/p/eid-tsl/", "About", JOptionPane.INFORMATION_MESSAGE); } else if (CLOSE_ACTION_COMMAND.equals(command)) { if (this.activeTslInternalFrame.getTrustServiceList().hasChanged()) { int result = JOptionPane.showConfirmDialog(this, "TSL has been changed.\n" + "Save the TSL?", "Save", JOptionPane.YES_NO_CANCEL_OPTION); if (JOptionPane.CANCEL_OPTION == result) { return; } if (JOptionPane.YES_OPTION == result) { try { this.activeTslInternalFrame.save(); } catch (IOException e) { LOG.error("IO error: " + e.getMessage(), e); } } } try { this.activeTslInternalFrame.setClosed(true); } catch (PropertyVetoException e) { LOG.warn("property veto error: " + e.getMessage(), e); } } else if (SIGN_ACTION_COMMAND.equals(command)) { LOG.debug("sign"); TrustServiceList trustServiceList = this.activeTslInternalFrame.getTrustServiceList(); if (trustServiceList.hasSignature()) { int confirmResult = JOptionPane.showConfirmDialog(this, "TSL is already signed.\n" + "Resign the TSL?", "Resign", JOptionPane.OK_CANCEL_OPTION); if (JOptionPane.CANCEL_OPTION == confirmResult) { return; } } SignSelectPkcs11FinishablePanel pkcs11Panel = new SignSelectPkcs11FinishablePanel(); WizardDescriptor wizardDescriptor = new WizardDescriptor( new WizardDescriptor.Panel[] { new SignInitFinishablePanel(), pkcs11Panel, new SignSelectCertificatePanel(pkcs11Panel, trustServiceList), new SignFinishFinishablePanel() }); wizardDescriptor.setTitle("Sign TSL"); wizardDescriptor.putProperty("WizardPanel_autoWizardStyle", Boolean.TRUE); DialogDisplayer dialogDisplayer = DialogDisplayer.getDefault(); Dialog wizardDialog = dialogDisplayer.createDialog(wizardDescriptor); wizardDialog.setVisible(true); } else if (SAVE_ACTION_COMMAND.equals(command)) { LOG.debug("save"); try { this.activeTslInternalFrame.save(); this.saveMenuItem.setEnabled(false); } catch (IOException e) { LOG.debug("IO error: " + e.getMessage(), e); } } else if (SAVE_AS_ACTION_COMMAND.equals(command)) { LOG.debug("save as"); JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogTitle("Save As"); int result = fileChooser.showSaveDialog(this); if (JFileChooser.APPROVE_OPTION == result) { File tslFile = fileChooser.getSelectedFile(); if (tslFile.exists()) { int confirmResult = JOptionPane.showConfirmDialog(this, "File already exists.\n" + tslFile.getAbsolutePath() + "\n" + "Overwrite file?", "Overwrite", JOptionPane.OK_CANCEL_OPTION); if (JOptionPane.CANCEL_OPTION == confirmResult) { return; } } try { this.activeTslInternalFrame.saveAs(tslFile); } catch (IOException e) { LOG.debug("IO error: " + e.getMessage(), e); } this.saveMenuItem.setEnabled(false); } } else if (EXPORT_ACTION_COMMAND.equals(command)) { LOG.debug("export"); JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogTitle("Export to PDF"); int result = fileChooser.showSaveDialog(this); if (JFileChooser.APPROVE_OPTION == result) { File pdfFile = fileChooser.getSelectedFile(); if (pdfFile.exists()) { int confirmResult = JOptionPane.showConfirmDialog(this, "File already exists.\n" + pdfFile.getAbsolutePath() + "\n" + "Overwrite file?", "Overwrite", JOptionPane.OK_CANCEL_OPTION); if (JOptionPane.CANCEL_OPTION == confirmResult) { return; } } try { this.activeTslInternalFrame.export(pdfFile); } catch (IOException e) { LOG.debug("IO error: " + e.getMessage(), e); } } } else if ("TSL-BE-2010-T1".equals(command)) { TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2010, Trimester.FIRST); displayTsl("*TSL-BE-2010-T1.xml", trustServiceList); this.saveMenuItem.setEnabled(false); } else if ("TSL-BE-2010-T2".equals(command)) { TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2010, Trimester.SECOND); displayTsl("*TSL-BE-2010-T2.xml", trustServiceList); this.saveMenuItem.setEnabled(false); } else if ("TSL-BE-2010-T3".equals(command)) { TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2010, Trimester.THIRD); displayTsl("*TSL-BE-2010-T3.xml", trustServiceList); this.saveMenuItem.setEnabled(false); } else if ("TSL-BE-2011-T1".equals(command)) { TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2011, Trimester.FIRST); displayTsl("*TSL-BE-2011-T1.xml", trustServiceList); this.saveMenuItem.setEnabled(false); } else if ("TSL-BE-2011-T2".equals(command)) { TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2011, Trimester.SECOND); displayTsl("*TSL-BE-2011-T2.xml", trustServiceList); this.saveMenuItem.setEnabled(false); } else if ("TSL-BE-2011-T3".equals(command)) { TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2011, Trimester.THIRD); displayTsl("*TSL-BE-2011-T3.xml", trustServiceList); this.saveMenuItem.setEnabled(false); } else if ("TSL-BE-2012-T1".equals(command)) { TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2012, Trimester.FIRST); displayTsl("*TSL-BE-2012-T1.xml", trustServiceList); this.saveMenuItem.setEnabled(false); } else if ("TSL-BE-2012-T2".equals(command)) { TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2012, Trimester.SECOND); displayTsl("*TSL-BE-2012-T2.xml", trustServiceList); this.saveMenuItem.setEnabled(false); } else if ("TSL-BE-2012-T3".equals(command)) { TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2012, Trimester.THIRD); displayTsl("*TSL-BE-2012-T3.xml", trustServiceList); this.saveMenuItem.setEnabled(false); } else if ("TSL-BE-2013-T1".equals(command)) { TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2013, Trimester.FIRST); displayTsl("*TSL-BE-2013-T1.xml", trustServiceList); this.saveMenuItem.setEnabled(false); } else if ("TSL-BE-2013-T2".equals(command)) { TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2013, Trimester.SECOND); displayTsl("*TSL-BE-2013-T2.xml", trustServiceList); this.saveMenuItem.setEnabled(false); } else if ("TSL-BE-2013-T3".equals(command)) { TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2013, Trimester.THIRD); displayTsl("*TSL-BE-2013-T3.xml", trustServiceList); this.saveMenuItem.setEnabled(false); } else if ("TSL-BE-2014-T1".equals(command)) { TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2014, Trimester.FIRST); displayTsl("*TSL-BE-2014-T1.xml", trustServiceList); this.saveMenuItem.setEnabled(false); } else if ("TSL-BE-2014-T2".equals(command)) { TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2014, Trimester.SECOND); displayTsl("*TSL-BE-2014-T2.xml", trustServiceList); this.saveMenuItem.setEnabled(false); } else if ("TSL-BE-2014-T3".equals(command)) { TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2014, Trimester.THIRD); displayTsl("*TSL-BE-2014-T3.xml", trustServiceList); this.saveMenuItem.setEnabled(false); } else if ("TSL-BE-2015-T1".equals(command)) { TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2015, Trimester.FIRST); displayTsl("*TSL-BE-2015-T1.xml", trustServiceList); this.saveMenuItem.setEnabled(false); } else if ("TSL-BE-2015-T2".equals(command)) { TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2015, Trimester.SECOND); displayTsl("*TSL-BE-2015-T2.xml", trustServiceList); this.saveMenuItem.setEnabled(false); } else if ("TSL-BE-2015-T3".equals(command)) { TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2015, Trimester.THIRD); displayTsl("*TSL-BE-2015-T3.xml", trustServiceList); this.saveMenuItem.setEnabled(false); } }
From source file:de.whiledo.iliasdownloader2.swing.service.MainController.java
private void handleFirstStart() { if (!ServiceFunctions.getPropertiesFile().exists()) { JOptionPane.showMessageDialog(mainFrame, "Willkommen bei " + APP_NAME, "Willkommen", JOptionPane.INFORMATION_MESSAGE); JPanel panel = new JPanel(new BorderLayout()); panel.add(new JLabel("<html>Wenn Sie " + APP_NAME + " nutzen mchten, mssen Sie die folgende Punkte akzeptieren." + "<ul>" + "<li>This software is under the GNU GENERAL PUBLIC LICENSE Version 3.<br>" + "View https://github.com/kekru/ILIASDownloader2/blob/master/LICENSE for detailed information." + "</li>" + "<li>Dieses Programm wird Ihr Passwort nicht speichern</li>" + "<li>Dieses Programm wird Ihren Loginnamen und Ihr Passwort nur an den von Ihnen angegebenen Server senden</li>" + "<li>Ihr Passwort wird im Arbeitsspeicher dieses Computers <b>nicht</b> verschlsselt gespeichert.<br>Ein Schadprogramm knnte den Arbeitsspeicher auslesen und so an Ihre Logindaten gelangen.<br>Der Autor von " + APP_NAME + " bernimmt keine Verantwortung fr die Sicherheit Ihrer Logindaten</li>" + "<li>Im nchsten Schritt mssen Sie Ihren Ilias Server eingeben. Bitte achten Sie darauf, dass die Adresse mit 'https://' beginnt.<br>Das bewirkt eine gesicherte Verbindung zwischen " + APP_NAME + " und Ihrem Ilias Server</li>" + "<li>Die Nutzung und die Weitergabe von " + APP_NAME + " ist kostenlos.</li>" + "<li>Beim Programmstart wird auf Updates berprft. Dabei wird lediglich der Programmname an den Updateserver gesendet. Ihre Logindaten oder andere persnliche Daten werden nicht bertragen.<br>Wenn Sie die Updatefunktion ausschalten mchten, starten Sie das Programm mit dem Parameter '" + StartGui.NO_UPDATER + "'</li>" + "</ul>" + "</html>"), BorderLayout.NORTH); JButton licenseButton = new JButton("Open GNU GENERAL PUBLIC LICENSE Version 3"); licenseButton.addActionListener(new ActionListener() { @Override/*www.j a va 2 s.c o m*/ public void actionPerformed(ActionEvent e) { openWebsiteLicense(); } }); panel.add(licenseButton, BorderLayout.CENTER); JCheckBox checkboxAccept = new JCheckBox( "Ich akzeptiere die hier aufgefhrten Bedingungen/I accept these agreements."); checkboxAccept.setSelected(false); panel.add(checkboxAccept, BorderLayout.SOUTH); if (JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(mainFrame, panel, "Bedingungen", JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE) && checkboxAccept.isSelected()) { chooseServer(); } else { System.exit(0); } } }
From source file:com.floreantpos.ui.dialog.ManagerDialog.java
private void doShowServerTips(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnResetDrawerActionPerformed try {/*from w w w. j a v a 2 s . c om*/ setGlassPaneVisible(true); JPanel panel = new JPanel(new MigLayout()); List<User> users = UserDAO.getInstance().findAll(); JXDatePicker fromDatePicker = UiUtil.getCurrentMonthStart(); JXDatePicker toDatePicker = UiUtil.getCurrentMonthEnd(); panel.add(new JLabel(com.floreantpos.POSConstants.SELECT_USER + ":"), "grow"); //$NON-NLS-1$ //$NON-NLS-2$ JComboBox userCombo = new JComboBox(new ListComboBoxModel(users)); panel.add(userCombo, "grow, wrap"); //$NON-NLS-1$ panel.add(new JLabel(com.floreantpos.POSConstants.FROM + ":"), "grow"); //$NON-NLS-1$ //$NON-NLS-2$ panel.add(fromDatePicker, "wrap"); //$NON-NLS-1$ panel.add(new JLabel(com.floreantpos.POSConstants.TO_), "grow"); //$NON-NLS-1$ panel.add(toDatePicker); int option = JOptionPane.showOptionDialog(ManagerDialog.this, panel, com.floreantpos.POSConstants.SELECT_CRIETERIA, JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); if (option != JOptionPane.OK_OPTION) { return; } GratuityDAO gratuityDAO = new GratuityDAO(); TipsCashoutReport report = gratuityDAO.createReport(fromDatePicker.getDate(), toDatePicker.getDate(), (User) userCombo.getSelectedItem()); TipsCashoutReportDialog dialog = new TipsCashoutReportDialog(report); dialog.setSize(400, 600); dialog.open(); } catch (Exception e) { POSMessageDialog.showError(Application.getPosWindow(), com.floreantpos.POSConstants.ERROR_MESSAGE, e); } finally { setGlassPaneVisible(false); } }
From source file:unikn.dbis.univis.visualization.graph.plaf.VGraphUI.java
public VGraphUI() { VHintButton zoomIn = new VHintButton(VIcons.ZOOM_IN); menu.add(zoomIn);// ww w. java 2 s . c om zoomIn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VGraphCell cell = selectedCell; Object o = cell.getUserObject(); if (o != null && o instanceof VChartPanel) { VChartPanel chart = (VChartPanel) o; chart.zoomInBoth(0, 0); graph.repaint(); } } }); VHintButton zoomOut = new VHintButton(VIcons.ZOOM_OUT); menu.add(zoomOut); zoomOut.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VGraphCell cell = selectedCell; Object o = cell.getUserObject(); if (o != null && o instanceof VChartPanel) { VChartPanel chart = (VChartPanel) o; chart.zoomOutBoth(0, 0); graph.repaint(); } } }); VHintButton settings = new VHintButton(VIcons.APPLICATION_FORM_EDIT); menu.add(settings); settings.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VGraphCell cell = selectedCell; Object o = cell.getUserObject(); if (o != null && o instanceof VChartPanel) { VChartPanel chart = (VChartPanel) o; ChartEditor editor = ChartEditorManager.getChartEditor(chart.getChart()); int result = JOptionPane.showConfirmDialog(graph.getParent(), editor, "Chart_Properties", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (result == JOptionPane.OK_OPTION) { editor.updateChart(chart.getChart()); graph.repaint(); } } } }); VHintButton legend = new VHintButton(VIcons.BRICKS); menu.add(legend); legend.addActionListener(new ActionListener() { /** * Invoked when an action occurs. */ public void actionPerformed(ActionEvent e) { VGraphCell cell = selectedCell; Object o = cell.getUserObject(); if (o != null && o instanceof VChartPanel) { VChartPanel chart = (VChartPanel) o; VLegend legend = new VLegend(chart.getChart()); JPopupMenu menu = new JPopupMenu(); menu.add(legend); menu.show(graph, 0, 0); } } }); }
From source file:com.microsoftopentechnologies.intellij.helpers.AndroidStudioHelper.java
public static void deleteActivityTemplates(Object caller) throws IOException, InterruptedException { String[] cmd = null;/* www . j ava 2 s .c o m*/ String templatePath = URLDecoder .decode(ApplicationComponent.class.getResource("").getPath().replace("file:/", ""), "UTF-8"); templatePath = templatePath.replace("/", File.separator); templatePath = templatePath.substring(0, templatePath.indexOf(File.separator + "lib")); templatePath = templatePath + File.separator + "plugins" + File.separator + "android" + File.separator; templatePath = templatePath + "lib" + File.separator + "templates" + File.separator + "activities" + File.separator; String[] env = null; String tmpdir = getTempLocation(); BufferedInputStream bufferedInputStream = new BufferedInputStream( ServiceCodeReferenceHelper.getTemplateResource("ActivityTemplate.zip")); unZip(bufferedInputStream, tmpdir); if (System.getProperty("os.name").toLowerCase().startsWith("windows")) { try { VirtualFile mobileTemplate = LocalFileSystem.getInstance() .findFileByIoFile(new File(templatePath + mobileServicesTemplateName)); VirtualFile officeTemplate = LocalFileSystem.getInstance() .findFileByIoFile(new File(templatePath + officeTemplateName)); if (mobileTemplate != null) mobileTemplate.delete(caller); if (officeTemplate != null) officeTemplate.delete(caller); } catch (IOException ex) { PrintWriter printWriter = new PrintWriter(tmpdir + "\\script.bat"); printWriter.println("@echo off"); printWriter.println("del \"" + templatePath + mobileServicesTemplateName + "\" /Q /S"); printWriter.println("del \"" + templatePath + officeTemplateName + "\" /Q /S"); printWriter.flush(); printWriter.close(); String[] tmpcmd = { tmpdir + "\\elevate.exe", "script.bat", "1" }; cmd = tmpcmd; ArrayList<String> tempenvlist = new ArrayList<String>(); for (String envval : System.getenv().keySet()) tempenvlist.add(String.format("%s=%s", envval, System.getenv().get(envval))); tempenvlist.add("PRECOMPILE_STREAMLINE_FILES=1"); env = new String[tempenvlist.size()]; tempenvlist.toArray(env); Runtime rt = Runtime.getRuntime(); Process proc = rt.exec(cmd, env, new File(tmpdir)); proc.waitFor(); } } else if (System.getProperty("os.name").toLowerCase().startsWith("mac")) { VirtualFile mobileTemplate = LocalFileSystem.getInstance() .findFileByIoFile(new File(templatePath + mobileServicesTemplateName)); VirtualFile officeTemplate = LocalFileSystem.getInstance() .findFileByIoFile(new File(templatePath + officeTemplateName)); if (mobileTemplate != null && officeTemplate != null) { exec(new String[] { "osascript", "-e", "do shell script \"rm -r \\\"/" + templatePath + mobileServicesTemplateName + "\\\"\"", "-e", "do shell script \"rm -r \\\"/" + templatePath + officeTemplateName + "\\\"\"" }, tmpdir); } } else { try { VirtualFile mobileTemplate = LocalFileSystem.getInstance() .findFileByIoFile(new File(templatePath + mobileServicesTemplateName)); VirtualFile officeTemplate = LocalFileSystem.getInstance() .findFileByIoFile(new File(templatePath + officeTemplateName)); mobileTemplate.delete(caller); officeTemplate.delete(caller); } catch (IOException ex) { JPasswordField pf = new JPasswordField(); int okCxl = JOptionPane.showConfirmDialog(null, pf, "To copy Microsoft Services templates, the plugin needs your password:", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (okCxl == JOptionPane.OK_OPTION) { String password = new String(pf.getPassword()); exec(new String[] { "echo", password, "|", "sudo", "-S", "rm", "-r", tmpdir + mobileServicesTemplateName, templatePath + mobileServicesTemplateName }, tmpdir); exec(new String[] { "echo", password, "|", "sudo", "-S", "rm", "-r", tmpdir + officeTemplateName, templatePath + officeTemplateName }, tmpdir); } } } }
From source file:de.adv_online.aaa.katalogtool.KatalogDialog.java
public void initialise(Converter c, Options o, ShapeChangeResult r, String mdl) throws ShapeChangeAbortException { try {/*from w ww .ja v a 2 s . c o m*/ String msg = "Akzeptieren Sie die in der mit diesem Tool ausgelieferten Datei 'Lizenzbedingungen zur Nutzung von Softwareskripten.doc' beschriebenen Lizenzbedingungen?"; // Meldung if (msg != null) { Object[] options = { "Ja", "Nein" }; int val = JOptionPane.showOptionDialog(null, msg, "Confirmation", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]); if (val == 1) System.exit(0); } } catch (Exception e) { System.out.println("Fehler in Dialog: " + e.toString()); } options = o; File eapFile = new File(mdl); try { eap = eapFile.getCanonicalFile().getAbsolutePath(); } catch (IOException e) { eap = "ERROR.eap"; } converter = new Converter(options, r); result = r; modelTransformed = false; transformationRunning = false; StatusBoard.getStatusBoard().registerStatusReader(this); // frame setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); // panel newContentPane = new JPanel(new BorderLayout()); newContentPane.setOpaque(true); setContentPane(newContentPane); // target elements for (String label : targetLabels) { try { TargetGuiElements t = new TargetGuiElements(this, label); targetGuiElems.put(label, t); } catch (Exception e) { throw new ShapeChangeAbortException("Fatal error while creating dialog elements for target " + label + ".\nMessage: " + eap.toString() + "\nPlease check configuration file."); } } //JTabbedPane tabbedPane = new JTabbedPane(); //tabbedPane.addTab("Main options", createMainTab()); newContentPane.add(createMainTab(), BorderLayout.CENTER); statusBar = new StatusBar(); Box fileBox = Box.createVerticalBox(); fileBox.add(createStartPanel()); fileBox.add(statusBar); newContentPane.add(fileBox, BorderLayout.SOUTH); // frame size int height = 720; int width = 600; pack(); Insets fI = getInsets(); setSize(width + fI.right + fI.left, height + fI.top + fI.bottom); Dimension sD = Toolkit.getDefaultToolkit().getScreenSize(); setLocation((sD.width - width) / 2, (sD.height - height) / 2); this.setMinimumSize(new Dimension(width, height)); // frame closing WindowListener listener = new WindowAdapter() { public void windowClosing(WindowEvent w) { //JOptionPane.showMessageDialog(null, "Nein", "NO", JOptionPane.ERROR_MESSAGE); closeDialog(); } }; addWindowListener(listener); }