List of usage examples for javax.swing JOptionPane showConfirmDialog
public static int showConfirmDialog(Component parentComponent, Object message, String title, int optionType, int messageType) throws HeadlessException
optionType
parameter, where the messageType
parameter determines the icon to display. From source file:com.stefanbrenner.droplet.ui.DevicePanel.java
/** * Create the panel.//from w w w . j a va 2 s. co m */ public DevicePanel(final JComponent parent, final IDroplet droplet, final T device) { this.parent = parent; setDevice(device); setLayout(new BorderLayout(0, 5)); setBorder(BorderFactory.createLineBorder(Color.BLACK)); setBackground(DropletColors.getBackgroundColor(device)); BeanAdapter<T> adapter = new BeanAdapter<T>(device, true); // device name textfield txtName = BasicComponentFactory.createTextField(adapter.getValueModel(IDevice.PROPERTY_NAME)); txtName.setHorizontalAlignment(SwingConstants.CENTER); txtName.setColumns(1); txtName.setToolTipText(device.getName()); adapter.addBeanPropertyChangeListener(IDevice.PROPERTY_NAME, new PropertyChangeListener() { @Override public void propertyChange(final PropertyChangeEvent event) { txtName.setToolTipText(device.getName()); } }); add(txtName, BorderLayout.NORTH); // actions panel with scroll pane actionsPanel = new JPanel(); actionsPanel.setLayout(new BoxLayout(actionsPanel, BoxLayout.Y_AXIS)); actionsPanel.setBackground(getBackground()); JScrollPane scrollPane = new JScrollPane(actionsPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); // resize vertical scrollbar scrollPane.getVerticalScrollBar().putClientProperty("JComponent.sizeVariant", "mini"); //$NON-NLS-1$ //$NON-NLS-2$ SwingUtilities.updateComponentTreeUI(scrollPane); // we need no border scrollPane.setBorder(BorderFactory.createEmptyBorder()); add(scrollPane, BorderLayout.CENTER); { JPanel panel = new JPanel(); panel.setLayout(new GridLayout(0, 1)); createAddButton(panel); // remove button JButton btnRemove = new JButton(Messages.getString("ActionDevicePanel.removeDevice")); //$NON-NLS-1$ btnRemove.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent action) { int retVal = JOptionPane.showConfirmDialog(DevicePanel.this, Messages.getString("ActionDevicePanel.removeDevice") + " '" + device.getName() + "'?", //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ StringUtils.EMPTY, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (retVal == JOptionPane.YES_OPTION) { droplet.removeDevice(device); } } }); btnRemove.setFocusable(false); panel.add(btnRemove); add(panel, BorderLayout.SOUTH); } }
From source file:org.jfree.chart.demo.DrawStringDemo.java
private void displayFontDialog() { FontChooserPanel fontchooserpanel = new FontChooserPanel(drawStringPanel1.getFont()); int i = JOptionPane.showConfirmDialog(this, fontchooserpanel, "Font Selection", 2, -1); if (i == 0) { drawStringPanel1.setFont(fontchooserpanel.getSelectedFont()); drawStringPanel2.setFont(fontchooserpanel.getSelectedFont()); }//from w w w .ja va 2 s . c o m }
From source file:SimpleAuthenticator.java
protected PasswordAuthentication getPasswordAuthentication() { // given a prompt? String prompt = getRequestingPrompt(); if (prompt == null) prompt = "Please login..."; // protocol/*from w w w . j av a 2 s . c o m*/ String protocol = getRequestingProtocol(); if (protocol == null) protocol = "Unknown protocol"; // get the host String host = null; InetAddress inet = getRequestingSite(); if (inet != null) host = inet.getHostName(); if (host == null) host = "Unknown host"; // port String port = ""; int portnum = getRequestingPort(); if (portnum != -1) port = ", port " + portnum + " "; // Build the info string String info = "Connecting to " + protocol + " mail service on host " + host + port; //JPanel d = new JPanel(); // XXX - for some reason using a JPanel here causes JOptionPane // to display incorrectly, so we workaround the problem using // an anonymous JComponent. JComponent d = new JComponent() { }; GridBagLayout gb = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); d.setLayout(gb); c.insets = new Insets(2, 2, 2, 2); c.anchor = GridBagConstraints.WEST; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 0.0; d.add(constrain(new JLabel(info), gb, c)); d.add(constrain(new JLabel(prompt), gb, c)); c.gridwidth = 1; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.NONE; c.weightx = 0.0; d.add(constrain(new JLabel("Username:"), gb, c)); c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1.0; String user = getDefaultUserName(); JTextField username = new JTextField(user, 20); d.add(constrain(username, gb, c)); c.gridwidth = 1; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.EAST; c.weightx = 0.0; d.add(constrain(new JLabel("Password:"), gb, c)); c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1.0; JPasswordField password = new JPasswordField("", 20); d.add(constrain(password, gb, c)); // XXX - following doesn't work if (user != null && user.length() > 0) password.requestFocus(); else username.requestFocus(); int result = JOptionPane.showConfirmDialog(frame, d, "Login", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (result == JOptionPane.OK_OPTION) return new PasswordAuthentication(username.getText(), password.getText()); else return null; }
From source file:gdt.jgui.entity.bookmark.JBookmarksEditor.java
/** * Get context menu./* w w w . j av a 2s . co m*/ * @return the context menu. */ @Override public JMenu getContextMenu() { menu = super.getContextMenu(); mia = null; int cnt = menu.getItemCount(); if (cnt > 0) { mia = new JMenuItem[cnt]; for (int i = 0; i < cnt; i++) mia[i] = menu.getItem(i); } menu.addMenuListener(new MenuListener() { @Override public void menuSelected(MenuEvent e) { // System.out.println("BookmarksEditor:getConextMenu:menu selected"); menu.removeAll(); if (mia != null) { for (JMenuItem mi : mia) menu.add(mi); } if (hasSelectedItems()) { menu.addSeparator(); JMenuItem copyItem = new JMenuItem("Copy"); copyItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { copy(); } }); menu.add(copyItem); JMenuItem deleteItem = new JMenuItem("Delete"); deleteItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { int response = JOptionPane.showConfirmDialog(console.getContentPanel(), "Delete ?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { String[] sa = JBookmarksEditor.this.listSelectedItems(); if (sa == null) return; String bookmarkKey$; Entigrator entigrator = console.getEntigrator(entihome$); Sack entity = entigrator.getEntityAtKey(entityKey$); for (String aSa : sa) { bookmarkKey$ = Locator.getProperty(aSa, BOOKMARK_KEY); if (bookmarkKey$ == null) continue; entity.removeElementItem("jbookmark", bookmarkKey$); } entigrator.save(entity); JConsoleHandler.execute(console, getLocator()); } } catch (Exception ee) { LOGGER.severe(ee.toString()); } } }); menu.add(deleteItem); } if (hasToPaste()) { JMenuItem pasteItem = new JMenuItem("Paste"); pasteItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { paste(); } }); menu.add(pasteItem); } } @Override public void menuDeselected(MenuEvent e) { } @Override public void menuCanceled(MenuEvent e) { } }); return menu; }
From source file:calendarexportplugin.exporter.GoogleExporter.java
public boolean exportPrograms(Program[] programs, CalendarExportSettings settings, AbstractPluginProgramFormating formatting) { try {/* w w w .j a v a2 s . c om*/ boolean uploadedItems = false; mPassword = IOUtilities.xorDecode(settings.getExporterProperty(PASSWORD), 345903).trim(); if (!settings.getExporterProperty(STORE_PASSWORD, false)) { if (!showLoginDialog(settings)) { return false; } } if (!settings.getExporterProperty(STORE_SETTINGS, false)) { if (!showCalendarSettings(settings)) { return false; } } GoogleService myService = new GoogleService("cl", "tvbrowser-tvbrowsercalenderplugin-" + CalendarExportPlugin.getInstance().getInfo().getVersion().toString()); myService.setUserCredentials(settings.getExporterProperty(USERNAME).trim(), mPassword); URL postUrl = new URL("http://www.google.com/calendar/feeds/" + settings.getExporterProperty(SELECTED_CALENDAR) + "/private/full"); SimpleDateFormat formatDay = new SimpleDateFormat("yyyy-MM-dd"); formatDay.setTimeZone(TimeZone.getTimeZone("GMT")); SimpleDateFormat formatTime = new SimpleDateFormat("HH:mm:ss"); formatTime.setTimeZone(TimeZone.getTimeZone("GMT")); ParamParser parser = new ParamParser(); for (Program program : programs) { final String title = parser.analyse(formatting.getTitleValue(), program); // First step: search for event in calendar boolean createEvent = true; CalendarEventEntry entry = findEntryForProgram(myService, postUrl, title, program); if (entry != null) { int ret = JOptionPane.showConfirmDialog(null, mLocalizer.msg("alreadyAvailable", "already available", program.getTitle()), mLocalizer.msg("title", "Add event?"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (ret != JOptionPane.YES_OPTION) { createEvent = false; } } // add event to calendar if (createEvent) { EventEntry myEntry = new EventEntry(); myEntry.setTitle(new PlainTextConstruct(title)); String desc = parser.analyse(formatting.getContentValue(), program); myEntry.setContent(new PlainTextConstruct(desc)); Calendar c = CalendarToolbox.getStartAsCalendar(program); DateTime startTime = new DateTime(c.getTime(), c.getTimeZone()); c = CalendarToolbox.getEndAsCalendar(program); DateTime endTime = new DateTime(c.getTime(), c.getTimeZone()); When eventTimes = new When(); eventTimes.setStartTime(startTime); eventTimes.setEndTime(endTime); myEntry.addTime(eventTimes); if (settings.getExporterProperty(REMINDER, false)) { int reminderMinutes = 0; try { reminderMinutes = settings.getExporterProperty(REMINDER_MINUTES, 0); } catch (NumberFormatException e) { e.printStackTrace(); } if (settings.getExporterProperty(REMINDER_ALERT, false)) { addReminder(myEntry, reminderMinutes, Reminder.Method.ALERT); } if (settings.getExporterProperty(REMINDER_EMAIL, false)) { addReminder(myEntry, reminderMinutes, Reminder.Method.EMAIL); } if (settings.getExporterProperty(REMINDER_SMS, false)) { addReminder(myEntry, reminderMinutes, Reminder.Method.SMS); } } if (settings.isShowBusy()) { myEntry.setTransparency(BaseEventEntry.Transparency.OPAQUE); } else { myEntry.setTransparency(BaseEventEntry.Transparency.TRANSPARENT); } // Send the request and receive the response: myService.insert(postUrl, myEntry); uploadedItems = true; } } if (uploadedItems) { JOptionPane.showMessageDialog(CalendarExportPlugin.getInstance().getBestParentFrame(), mLocalizer.msg("exportDone", "Google Export done."), mLocalizer.msg("export", "Export"), JOptionPane.INFORMATION_MESSAGE); } return true; } catch (AuthenticationException e) { ErrorHandler.handle(mLocalizer.msg("loginFailure", "Problems during login to Service.\nMaybe bad username or password?"), e); settings.setExporterProperty(STORE_PASSWORD, false); } catch (Exception e) { ErrorHandler.handle(mLocalizer.msg("commError", "Error while communicating with Google!"), e); } return false; }
From source file:com.microsoftopentechnologies.intellij.helpers.AndroidStudioHelper.java
public static void newActivityTemplateManager() throws IOException, InterruptedException { String[] cmd = null;//from w ww . j a v a 2 s . c om 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; if (!new File(templatePath + mobileServicesTemplateName).exists()) { String tmpdir = getTempLocation(); BufferedInputStream bufferedInputStream = new BufferedInputStream( ServiceCodeReferenceHelper.getTemplateResource("ActivityTemplate.zip")); unZip(bufferedInputStream, tmpdir); if (System.getProperty("os.name").toLowerCase().startsWith("windows")) { try { copyFolder(new File(tmpdir + mobileServicesTemplateName), new File(templatePath + mobileServicesTemplateName)); copyFolder(new File(tmpdir + officeTemplateName), new File(templatePath + officeTemplateName)); } catch (IOException ex) { PrintWriter printWriter = new PrintWriter(tmpdir + "\\script.bat"); printWriter.println("@echo off"); printWriter.println("md \"" + templatePath + mobileServicesTemplateName + "\""); printWriter.println("md \"" + templatePath + officeTemplateName + "\""); printWriter.println("xcopy \"" + tmpdir + mobileServicesTemplateName + "\" \"" + templatePath + mobileServicesTemplateName + "\" /s /i /Y"); printWriter.println("xcopy \"" + tmpdir + officeTemplateName + "\" \"" + templatePath + officeTemplateName + "\" /s /i /Y"); 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(); //wait for elevate command to finish Thread.sleep(3000); if (!new File(templatePath + mobileServicesTemplateName).exists()) UIHelper.showException( "Error copying template files. Please refer to documentation to copy manually.", new Exception()); } } else { if (System.getProperty("os.name").toLowerCase().startsWith("mac")) { String[] strings = { "osascript", // "-e", // "do shell script \"mkdir -p \\\"/" + templatePath + mobileServicesTemplateName + "\\\"\"", // "-e", // "do shell script \"mkdir -p \\\"/" + templatePath + officeTemplateName + "\\\"\"", "-e", "do shell script \"cp -Rp \\\"" + tmpdir + mobileServicesTemplateName + "\\\" \\\"/" + templatePath + "\\\"\"", "-e", "do shell script \"cp -Rp \\\"" + tmpdir + officeTemplateName + "\\\" \\\"/" + templatePath + "\\\"\"" }; exec(strings, tmpdir); } else { try { copyFolder(new File(tmpdir + mobileServicesTemplateName), new File(templatePath + mobileServicesTemplateName)); copyFolder(new File(tmpdir + officeTemplateName), new File(templatePath + officeTemplateName)); } 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", "cp", "-Rp", tmpdir + mobileServicesTemplateName, templatePath + mobileServicesTemplateName }, tmpdir); exec(new String[] { "echo", password, "|", "sudo", "-S", "cp", "-Rp", tmpdir + officeTemplateName, templatePath + officeTemplateName }, tmpdir); } } } } } }
From source file:com.sshtools.shift.FileTransferDialog.java
/** * Creates a new FileTransferDialog object. * * @param frame/*from www. ja v a 2 s . c o m*/ * @param title * @param fileCount */ /*public FileTransferDialog(Frame frame, String title) { this(frame, title, op.getNewFiles().size() + op.getUpdatedFiles().size()); this.op = op; }*/ public FileTransferDialog(Frame frame, String title, int fileCount) { super("0% Complete - " + title); this.setIconImage(ShiftSessionPanel.FILE_BROWSER_ICON.getImage()); this.title = title; try { jbInit(); pack(); } catch (Exception ex) { ex.printStackTrace(); } this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { if (cancelled || completed) { setVisible(false); } else { if (JOptionPane.showConfirmDialog(FileTransferDialog.this, "Cancel the file operation(s)?", "Close Window", JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE) == JOptionPane.YES_OPTION) { cancelOperation(); hide(); } } } }); }
From source file:ca.uviccscu.lp.server.main.ShutdownListener.java
@Override public void windowClosing(WindowEvent e) { if (Shared.hashInProgress) { JOptionPane.showMessageDialog(null, "Closing not allowed - stop or finish hashing first!", "Hash in progress!", JOptionPane.WARNING_MESSAGE); } else {/*from ww w . j ava2 s .com*/ SwingWorker worker = new SwingWorker<Void, Void>() { @Override public Void doInBackground() { try { int ans1 = JOptionPane.showConfirmDialog(null, "Are you sure you want to shutdown? " + "Clients will switch to passive mode until restarted.", "Confirmation", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (ans1 == JOptionPane.OK_OPTION) { l.debug("MainFrame window closing requested"); MainFrame.lockInterface(); MainFrame.setReportingActive(); MainFrame.updateTask("Shutting down", true); MainFrame.updateProgressBar(0, 0, 0, "Shutting down settings manager!", true, true); l.trace("Shutting down settings manager and saving session"); int ans2 = JOptionPane.showConfirmDialog(null, "Do you want to save the games list", "Save confirmation", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (ans2 == JOptionPane.OK_OPTION) { SettingsManager.showSaveSettingsDialog(); } SettingsManager.shutdown(); l.trace("OK"); l.trace("Stopping net manager"); MainFrame.updateProgressBar(0, 0, 0, "Shutting down net manager!", true, true); ServerNetManager.shutdown(); l.trace("OK"); l.trace("Shutting down tracker manager - might have errors here!"); MainFrame.updateProgressBar(0, 0, 0, "Shutting down azureus - might take a while!", true, true); //Errors due to Azureus stupid shutdown thread killing routine(see AzureusCoreImpl) //Basically it kills all other threads it doesnt recognise on JVM and then terminates //Not designed to work with other application, and so it also kills the shutdown thread = BAD //Library modified to prevent system shutdown, but exceptions still coming - irrelevant TrackerManager.shutdown(); Thread.yield(); l.trace("OK"); Thread.yield(); Thread.sleep(5000); while (!Shared.azShutdownDone) { try { l.trace("Awaiting az shutdown"); Thread.sleep(500); } catch (InterruptedException ex) { l.error("Az shutdown monitor interrupted", ex); } } MainFrame.updateProgressBar(0, 0, 0, "Cleaning temporary files - might take a while!", true, true); File f = new File(Shared.workingDirectory); /* //delete until files unlocked or timeout if (!deleteFolder(f, true, 3000, 15000)) { l.trace("Advanced file deletion measures required"); releaseLocks(); deleteFolder(f, false, 0, 0); //Advanced thread killing, stolen from azureus...except now it kills itself l.error("Delete timeout - attempting threadicide"); l.trace("Starting thread killing"); //First kill azureus SM - allows to do whatever we want with threads l.trace("Removed SM"); System.setSecurityManager(null); // ThreadGroup tg = Thread.currentThread().getThreadGroup(); while (tg.getParent() != null) { tg = tg.getParent(); } Thread[] threads = new Thread[tg.activeCount() + 1024]; tg.enumerate(threads, true); //VERY BAD WAY TO STOP THREAD BUT NO CHOICE - need to release the file locks for (int i = 0; i < threads.length; i++) { Thread th = threads[i]; if (th != null && th != Thread.currentThread() && AEThread2.isOurThread(th)) { l.trace("Stopping " + th.getName()); try { th.stop(); l.trace("ok"); } catch (SecurityException e) { l.trace("Stop vetoed by SM", e); } } } // deleteFolder(f, false, 0, 0); l.error("Trying to stop more threads, list:"); //List remaining threads ThreadGroup tg2 = Thread.currentThread().getThreadGroup(); while (tg2.getParent() != null) { tg2 = tg2.getParent(); } //Object o = new Object(); //o.notifyAll(); Thread[] threads2 = new Thread[tg2.activeCount() + 1024]; tg2.enumerate(threads2, true); //VERY BAD WAY TO STOP THREAD BUT NO CHOICE - need to release the file locks for (int i = 0; i < threads2.length; i++) { Thread th = threads2[i]; if (th != null) { l.trace("Have thread: " + th.getName()); if (th != null && th != Thread.currentThread() && (AEThread2.isOurThread(th) || isAzThread(th))) { l.trace("Stopping " + th.getName()); try { th.stop(); l.trace("ok"); } catch (SecurityException e) { l.trace("Stop vetoed by SM", e); } } } } try { Utils.cleanupDir(); l.trace("OK"); } catch (IOException e) { l.trace("Cleaning failed after more thread cleanup", e); Thread.yield(); } threadCleanup(f); l.error("Last resort - scheduling delete on JVM exit - might FAIL, CHECK MANUALLY"); try { FileUtils.forceDeleteOnExit(f); } catch (IOException iOException) { l.fatal("All delete attempts failed - clean manually"); } } File test = new File("C:\\AZTest\\AZ\\logs\\debug_1.log"); test.deleteOnExit(); try { Thread.sleep(30000); } catch (InterruptedException ex) { java.util.logging.Logger.getLogger(ShutdownListener.class.getName()).log(Level.SEVERE, null, ex); } * */ threadReadout(); try { Utils.cleanupDir(); l.trace("OK"); } catch (IOException e) { l.trace("Cleaning failed - expected due to stupid Azureus file lock", e); Thread.yield(); } System.exit(0); return null; } else { return null; } } catch (Exception ex) { l.fatal("Exception during shutdown!!!", ex); //just end it System.exit(4); return null; } } }; worker.execute(); } }
From source file:gdt.jgui.entity.JEntityStructurePanel.java
/** * The default constructor./*from ww w. j ava 2 s. co m*/ */ public JEntityStructurePanel() { setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); scrollPane = new JScrollPane(); add(scrollPane); popup = new JPopupMenu(); popup.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { popup.removeAll(); JMenuItem facetsItem = new JMenuItem("Facets"); popup.add(facetsItem); facetsItem.setHorizontalTextPosition(JMenuItem.RIGHT); facetsItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // System.out.println("EntityStructurePanel:renderer:component locator$="+nodeLocator$); JEntityFacetPanel efp = new JEntityFacetPanel(); String efpLocator$ = efp.getLocator(); Properties locator = Locator.toProperties(selection$); String entihome$ = locator.getProperty(Entigrator.ENTIHOME); String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); efpLocator$ = Locator.append(efpLocator$, Entigrator.ENTIHOME, entihome$); efpLocator$ = Locator.append(efpLocator$, EntityHandler.ENTITY_KEY, entityKey$); JConsoleHandler.execute(console, efpLocator$); } }); JMenuItem copyItem = new JMenuItem("Copy"); popup.add(copyItem); copyItem.setHorizontalTextPosition(JMenuItem.RIGHT); copyItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { console.clipboard.clear(); String locator$ = (String) node.getUserObject(); if (locator$ != null) console.clipboard.putString(locator$); } }); if (!isFirst) { popup.addSeparator(); JMenuItem excludeItem = new JMenuItem("Exclude"); popup.add(excludeItem); excludeItem.setHorizontalTextPosition(JMenuItem.RIGHT); excludeItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int response = JOptionPane.showConfirmDialog(console.getContentPanel(), "Exclude ?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { try { Properties locator = Locator.toProperties(selection$); String entihome$ = locator.getProperty(Entigrator.ENTIHOME); String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); Entigrator entigrator = console.getEntigrator(entihome$); Sack component = entigrator.getEntityAtKey(entityKey$); String[] sa = entigrator.ent_listContainers(component); if (sa != null) { Sack container; for (String aSa : sa) { container = entigrator.getEntityAtKey(aSa); if (container != null) entigrator.col_breakRelation(container, component); } } JConsoleHandler.execute(console, JEntityStructurePanel.this.locator$); } catch (Exception ee) { Logger.getLogger(JEntityStructurePanel.class.getName()).info(ee.toString()); } } } }); JMenuItem deleteItem = new JMenuItem("Delete"); popup.add(deleteItem); deleteItem.setHorizontalTextPosition(JMenuItem.RIGHT); deleteItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int response = JOptionPane.showConfirmDialog(console.getContentPanel(), "Delete ?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { try { Properties locator = Locator.toProperties(selection$); String entihome$ = locator.getProperty(Entigrator.ENTIHOME); String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); Entigrator entigrator = console.getEntigrator(entihome$); Sack component = entigrator.getEntityAtKey(entityKey$); entigrator.deleteEntity(component); JConsoleHandler.execute(console, JEntityStructurePanel.this.locator$); } catch (Exception ee) { Logger.getLogger(JEntityStructurePanel.class.getName()).info(ee.toString()); } } } }); } if (hasToInclude()) { popup.addSeparator(); JMenuItem includeItem = new JMenuItem("Include"); popup.add(includeItem); includeItem.setHorizontalTextPosition(JMenuItem.RIGHT); includeItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { include(); JConsoleHandler.execute(console, JEntityStructurePanel.this.locator$); } }); } } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { } @Override public void popupMenuCanceled(PopupMenuEvent e) { // TODO Auto-generated method stub } }); }
From source file:com.frostwire.gui.updates.UpdateMediator.java
public void showUpdateMessage() { if (latestMsg == null) { return;/*from ww w.j a v a 2s .co m*/ } int result = JOptionPane.showConfirmDialog(null, latestMsg.getMessageInstallerReady(), I18n.tr("Update"), JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE); if (result == JOptionPane.YES_OPTION) { startUpdate(); } }