List of usage examples for javax.swing JOptionPane showInputDialog
public static String showInputDialog(Component parentComponent, Object message, Object initialSelectionValue)
parentComponent
. From source file:com.dfki.av.sudplan.ui.MainFrame.java
private void miSaveViewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miSaveViewActionPerformed String defaultName = "View " + viewID; String name = JOptionPane.showInputDialog(this, "Enter a name for the view", defaultName); if (name == null) { log.debug("Cancled JOptionPane."); return;//from ww w. j a v a 2s.c om } if (name.isEmpty()) { String msg = "Server URL is empty"; log.error(msg); name = defaultName; } WorldWindowGLCanvas worldWindow = wwPanel.getWwd(); View view = worldWindow.getView(); String xml = view.getRestorableState(); log.info(xml); final Position eyePosition = view.getEyePosition(); final Position centerPosition = view.getGlobe().computePositionFromPoint(view.getCenterPoint()); log.info("Saving view: eye({}), center({})", eyePosition.toString(), centerPosition.toString()); JMenuItem menuItem = new JMenuItem(new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { WorldWindowGLCanvas canvas = wwPanel.getWwd(); View view = canvas.getView(); view.setOrientation(eyePosition, centerPosition); canvas.redraw(); } }); menuItem.setText(name); mCustomViewPoints.add(menuItem); viewID++; }
From source file:com.mirth.connect.client.ui.ChannelPanel.java
public void importGroup(ChannelGroup importGroup, boolean showAlerts, boolean synchronous) { // First consolidate and import code template libraries Map<String, CodeTemplateLibrary> codeTemplateLibraryMap = new LinkedHashMap<String, CodeTemplateLibrary>(); Set<String> codeTemplateIds = new HashSet<String>(); for (Channel channel : importGroup.getChannels()) { if (channel.getCodeTemplateLibraries() != null) { for (CodeTemplateLibrary library : channel.getCodeTemplateLibraries()) { CodeTemplateLibrary matchingLibrary = codeTemplateLibraryMap.get(library.getId()); if (matchingLibrary != null) { for (CodeTemplate codeTemplate : library.getCodeTemplates()) { if (codeTemplateIds.add(codeTemplate.getId())) { matchingLibrary.getCodeTemplates().add(codeTemplate); }/* www. j a va 2 s . co m*/ } } else { matchingLibrary = library; codeTemplateLibraryMap.put(matchingLibrary.getId(), matchingLibrary); List<CodeTemplate> codeTemplates = new ArrayList<CodeTemplate>(); for (CodeTemplate codeTemplate : matchingLibrary.getCodeTemplates()) { if (codeTemplateIds.add(codeTemplate.getId())) { codeTemplates.add(codeTemplate); } } matchingLibrary.setCodeTemplates(codeTemplates); } // Combine the library enabled / disabled channel IDs matchingLibrary.getEnabledChannelIds().addAll(library.getEnabledChannelIds()); matchingLibrary.getEnabledChannelIds().add(channel.getId()); matchingLibrary.getDisabledChannelIds().addAll(library.getDisabledChannelIds()); matchingLibrary.getDisabledChannelIds().removeAll(matchingLibrary.getEnabledChannelIds()); } channel.getCodeTemplateLibraries().clear(); } } List<CodeTemplateLibrary> codeTemplateLibraries = new ArrayList<CodeTemplateLibrary>( codeTemplateLibraryMap.values()); parent.removeInvalidItems(codeTemplateLibraries, CodeTemplateLibrary.class); if (CollectionUtils.isNotEmpty(codeTemplateLibraries)) { boolean importLibraries; String importChannelCodeTemplateLibraries = Preferences.userNodeForPackage(Mirth.class) .get("importChannelCodeTemplateLibraries", null); if (importChannelCodeTemplateLibraries == null) { JCheckBox alwaysChooseCheckBox = new JCheckBox( "Always choose this option by default in the future (may be changed in the Administrator settings)"); Object[] params = new Object[] { "Group \"" + importGroup.getName() + "\" has code template libraries included with it. Would you like to import them?", alwaysChooseCheckBox }; int result = JOptionPane.showConfirmDialog(this, params, "Select an Option", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (result == JOptionPane.YES_OPTION || result == JOptionPane.NO_OPTION) { importLibraries = result == JOptionPane.YES_OPTION; if (alwaysChooseCheckBox.isSelected()) { Preferences.userNodeForPackage(Mirth.class).putBoolean("importChannelCodeTemplateLibraries", importLibraries); } } else { return; } } else { importLibraries = Boolean.parseBoolean(importChannelCodeTemplateLibraries); } if (importLibraries) { CodeTemplateImportDialog dialog = new CodeTemplateImportDialog(parent, codeTemplateLibraries, false, true); if (dialog.wasSaved()) { CodeTemplateLibrarySaveResult updateSummary = parent.codeTemplatePanel.attemptUpdate( dialog.getUpdatedLibraries(), new HashMap<String, CodeTemplateLibrary>(), dialog.getUpdatedCodeTemplates(), new HashMap<String, CodeTemplate>(), true, null, null); if (updateSummary == null || updateSummary.isOverrideNeeded() || !updateSummary.isLibrariesSuccess()) { return; } else { for (CodeTemplateUpdateResult result : updateSummary.getCodeTemplateResults().values()) { if (!result.isSuccess()) { return; } } } parent.codeTemplatePanel.doRefreshCodeTemplates(); } } } List<Channel> successfulChannels = new ArrayList<Channel>(); for (Channel channel : importGroup.getChannels()) { Channel importChannel = importChannel(channel, false, false); if (importChannel != null) { successfulChannels.add(importChannel); } } if (!StringUtils.equals(importGroup.getId(), ChannelGroup.DEFAULT_ID)) { ChannelTreeTableModel model = (ChannelTreeTableModel) channelTable.getTreeTableModel(); AbstractChannelTableNode importGroupNode = null; String groupName = importGroup.getName(); String tempId; try { tempId = parent.mirthClient.getGuid(); } catch (ClientException e) { tempId = UUID.randomUUID().toString(); } // Check to see that the channel name doesn't already exist. if (!checkGroupName(groupName)) { if (!parent.alertOption(parent, "Would you like to overwrite the existing group? Choose 'No' to create a new group.")) { importGroup.setRevision(0); do { groupName = JOptionPane.showInputDialog(this, "Please enter a new name for the group.", groupName); if (groupName == null) { return; } } while (!checkGroupName(groupName)); importGroup.setId(tempId); importGroup.setName(groupName); } else { MutableTreeTableNode root = (MutableTreeTableNode) model.getRoot(); for (Enumeration<? extends MutableTreeTableNode> groupNodes = root.children(); groupNodes .hasMoreElements();) { AbstractChannelTableNode groupNode = (AbstractChannelTableNode) groupNodes.nextElement(); if (StringUtils.equals(groupNode.getGroupStatus().getGroup().getName(), groupName)) { importGroupNode = groupNode; } } } } else { // Start the revision number over for a new channel group importGroup.setRevision(0); // If the channel name didn't already exist, make sure // the id doesn't exist either. if (!checkGroupId(importGroup.getId())) { importGroup.setId(tempId); } } Set<ChannelGroup> channelGroups = new HashSet<ChannelGroup>(); Set<String> removedChannelGroupIds = new HashSet<String>(groupStatuses.keySet()); removedChannelGroupIds.remove(ChannelGroup.DEFAULT_ID); MutableTreeTableNode root = (MutableTreeTableNode) channelTable.getTreeTableModel().getRoot(); if (root == null) { return; } for (Enumeration<? extends MutableTreeTableNode> groupNodes = root.children(); groupNodes .hasMoreElements();) { ChannelGroup group = ((AbstractChannelTableNode) groupNodes.nextElement()).getGroupStatus() .getGroup(); if (!StringUtils.equals(group.getId(), ChannelGroup.DEFAULT_ID)) { // If the current group is the one we're overwriting, merge the channels if (importGroupNode != null && StringUtils.equals(group.getId(), importGroupNode.getGroupStatus().getGroup().getId())) { group = importGroup; group.setRevision(importGroupNode.getGroupStatus().getGroup().getRevision()); Set<String> channelIds = new HashSet<String>(); for (Channel channel : group.getChannels()) { channelIds.add(channel.getId()); } // Add the imported channels for (Channel channel : successfulChannels) { channelIds.add(channel.getId()); } List<Channel> channels = new ArrayList<Channel>(); for (String channelId : channelIds) { channels.add(new Channel(channelId)); } group.setChannels(channels); } channelGroups.add(group); removedChannelGroupIds.remove(group.getId()); } } if (importGroupNode == null) { List<Channel> channels = new ArrayList<Channel>(); for (Channel channel : successfulChannels) { channels.add(new Channel(channel.getId())); } importGroup.setChannels(channels); channelGroups.add(importGroup); removedChannelGroupIds.remove(importGroup.getId()); } Set<String> channelIds = new HashSet<String>(); for (Channel channel : importGroup.getChannels()) { channelIds.add(channel.getId()); } for (ChannelGroup group : channelGroups) { if (group != importGroup) { for (Iterator<Channel> channels = group.getChannels().iterator(); channels.hasNext();) { if (!channelIds.add(channels.next().getId())) { channels.remove(); } } } } attemptUpdate(channelGroups, removedChannelGroupIds, false); } if (synchronous) { retrieveChannels(); updateModel(getCurrentTableState()); updateTasks(); parent.setSaveEnabled(false); } else { doRefreshChannels(); } }
From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.script.PainelScript.java
private void abreUrl() { String url;/*from w w w. j a va 2 s .co m*/ url = JOptionPane.showInputDialog(this, GERAL.DIGITE_ENDERECO, "http://"); PegarPaginaWEB ppw = new PegarPaginaWEB(); if (url != null) { try { String codHtml = ppw.getContent(url); TxtBuffer.setContentOriginal(codHtml, "0"); parentFrame.showPainelFerramentaScriptPArq(codHtml); EstadoSilvinha.setLinkAtual(url); } catch (HttpException e1) { JOptionPane.showMessageDialog(this, TradPainelAvaliacao.AVISO_NAO_CONECTOU, TradPainelAvaliacao.AVISO, JOptionPane.WARNING_MESSAGE); } catch (Exception e1) { JOptionPane.showMessageDialog(this, TradPainelAvaliacao.AVISO_VERIFIQUE_URL, TradPainelAvaliacao.AVISO, JOptionPane.WARNING_MESSAGE); } } }
From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.objeto.PainelObjeto.java
private void abreUrl() { String url;/*from w ww . j a v a 2 s .c o m*/ url = JOptionPane.showInputDialog(this, GERAL.DIGITE_ENDERECO, "http://"); PegarPaginaWEB ppw = new PegarPaginaWEB(); if (url != null) { try { String codHtml = ppw.getContent(url); TxtBuffer.setContentOriginal(codHtml, "0"); parentFrame.showPainelFerramentaDescricaoObjetosPArq(codHtml); EstadoSilvinha.setLinkAtual(url); } catch (HttpException e1) { JOptionPane.showMessageDialog(this, TradPainelAvaliacao.AVISO_NAO_CONECTOU, TradPainelAvaliacao.AVISO, JOptionPane.WARNING_MESSAGE); } catch (Exception e1) { JOptionPane.showMessageDialog(this, TradPainelAvaliacao.AVISO_VERIFIQUE_URL, TradPainelAvaliacao.AVISO, JOptionPane.WARNING_MESSAGE); } } }
From source file:com.mirth.connect.client.ui.ChannelPanel.java
public Channel importChannel(Channel importChannel, boolean showAlerts, boolean refreshStatuses) { boolean overwrite = false; try {/*from w ww. j a v a 2s . co m*/ String channelName = importChannel.getName(); String tempId = parent.mirthClient.getGuid(); // Check to see that the channel name doesn't already exist. if (!parent.checkChannelName(channelName, tempId)) { if (!parent.alertOption(parent, "Would you like to overwrite the existing channel? Choose 'No' to create a new channel.")) { importChannel.setRevision(0); do { channelName = JOptionPane.showInputDialog(this, "Please enter a new name for the channel.", channelName); if (channelName == null) { return null; } } while (!parent.checkChannelName(channelName, tempId)); importChannel.setName(channelName); setIdAndUpdateLibraries(importChannel, tempId); } else { overwrite = true; for (ChannelStatus channelStatus : channelStatuses.values()) { Channel channel = channelStatus.getChannel(); if (channel.getName().equalsIgnoreCase(channelName)) { // If overwriting, use the old revision number and id importChannel.setRevision(channel.getRevision()); setIdAndUpdateLibraries(importChannel, channel.getId()); } } } } else { // Start the revision number over for a new channel importChannel.setRevision(0); // If the channel name didn't already exist, make sure // the id doesn't exist either. if (!checkChannelId(importChannel.getId())) { setIdAndUpdateLibraries(importChannel, tempId); } } channelStatuses.put(importChannel.getId(), new ChannelStatus(importChannel)); parent.updateChannelTags(false); } catch (ClientException e) { parent.alertThrowable(parent, e); } // Import code templates / libraries if applicable parent.removeInvalidItems(importChannel.getCodeTemplateLibraries(), CodeTemplateLibrary.class); if (!(importChannel instanceof InvalidChannel) && !importChannel.getCodeTemplateLibraries().isEmpty()) { boolean importLibraries; String importChannelCodeTemplateLibraries = Preferences.userNodeForPackage(Mirth.class) .get("importChannelCodeTemplateLibraries", null); if (importChannelCodeTemplateLibraries == null) { JCheckBox alwaysChooseCheckBox = new JCheckBox( "Always choose this option by default in the future (may be changed in the Administrator settings)"); Object[] params = new Object[] { "Channel \"" + importChannel.getName() + "\" has code template libraries included with it. Would you like to import them?", alwaysChooseCheckBox }; int result = JOptionPane.showConfirmDialog(this, params, "Select an Option", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (result == JOptionPane.YES_OPTION || result == JOptionPane.NO_OPTION) { importLibraries = result == JOptionPane.YES_OPTION; if (alwaysChooseCheckBox.isSelected()) { Preferences.userNodeForPackage(Mirth.class).putBoolean("importChannelCodeTemplateLibraries", importLibraries); } } else { return null; } } else { importLibraries = Boolean.parseBoolean(importChannelCodeTemplateLibraries); } if (importLibraries) { CodeTemplateImportDialog dialog = new CodeTemplateImportDialog(parent, importChannel.getCodeTemplateLibraries(), false, true); if (dialog.wasSaved()) { CodeTemplateLibrarySaveResult updateSummary = parent.codeTemplatePanel.attemptUpdate( dialog.getUpdatedLibraries(), new HashMap<String, CodeTemplateLibrary>(), dialog.getUpdatedCodeTemplates(), new HashMap<String, CodeTemplate>(), true, null, null); if (updateSummary == null || updateSummary.isOverrideNeeded() || !updateSummary.isLibrariesSuccess()) { return null; } else { for (CodeTemplateUpdateResult result : updateSummary.getCodeTemplateResults().values()) { if (!result.isSuccess()) { return null; } } } parent.codeTemplatePanel.doRefreshCodeTemplates(); } } importChannel.getCodeTemplateLibraries().clear(); } if (CollectionUtils.isNotEmpty(importChannel.getDependentIds()) || CollectionUtils.isNotEmpty(importChannel.getDependencyIds())) { Set<ChannelDependency> channelDependencies = new HashSet<ChannelDependency>( getCachedChannelDependencies()); if (CollectionUtils.isNotEmpty(importChannel.getDependentIds())) { for (String dependentId : importChannel.getDependentIds()) { if (StringUtils.isNotBlank(dependentId) && !StringUtils.equals(dependentId, importChannel.getId())) { channelDependencies.add(new ChannelDependency(dependentId, importChannel.getId())); } } } if (CollectionUtils.isNotEmpty(importChannel.getDependencyIds())) { for (String dependencyId : importChannel.getDependencyIds()) { if (StringUtils.isNotBlank(dependencyId) && !StringUtils.equals(dependencyId, importChannel.getId())) { channelDependencies.add(new ChannelDependency(importChannel.getId(), dependencyId)); } } } if (!channelDependencies.equals(getCachedChannelDependencies())) { try { parent.mirthClient.setChannelDependencies(channelDependencies); } catch (ClientException e) { parent.alertThrowable(parent, e, "Unable to save channel dependencies."); } } importChannel.clearDependencies(); } // Update resource names parent.updateResourceNames(importChannel); /* * Update the channel if we're overwriting an imported channel, if we're not showing alerts * (dragging/dropping multiple channels), or if we're working with an invalid channel. */ if (overwrite || !showAlerts || importChannel instanceof InvalidChannel) { try { parent.updateChannel(importChannel, overwrite); if (importChannel instanceof InvalidChannel && showAlerts) { InvalidChannel invalidChannel = (InvalidChannel) importChannel; Throwable cause = invalidChannel.getCause(); parent.alertThrowable(parent, cause, "Channel \"" + importChannel.getName() + "\" is invalid. " + getMissingExtensions(invalidChannel) + " Original cause:\n" + cause.getMessage()); } } catch (Exception e) { channelStatuses.remove(importChannel.getId()); parent.updateChannelTags(false); parent.alertThrowable(parent, e); return null; } finally { if (refreshStatuses) { doRefreshChannels(); } } } if (showAlerts) { final Channel importChannelFinal = importChannel; final boolean overwriteFinal = overwrite; /* * MIRTH-2048 - This is a hack to fix the memory access error that only occurs on OS X. * The block of code that edits the channel needs to be invoked later so that the screen * does not change before the drag/drop action of a channel finishes. */ SwingUtilities.invokeLater(new Runnable() { @Override public void run() { try { parent.editChannel(importChannelFinal); parent.setSaveEnabled(!overwriteFinal); } catch (Exception e) { channelStatuses.remove(importChannelFinal.getId()); parent.updateChannelTags(false); parent.alertError(parent, "Channel had an unknown problem. Channel import aborted."); parent.channelEditPanel = new ChannelSetup(); parent.doShowChannel(); } } }); } return importChannel; }
From source file:com.mirth.connect.client.ui.ChannelPanel.java
public void doCloneChannel() { if (isSaveEnabled() && !promptSave(true)) { return;// w w w . j av a2 s . c o m } if (isGroupSelected()) { JOptionPane.showMessageDialog(parent, "This operation can only be performed on channels."); return; } List<Channel> selectedChannels = getSelectedChannels(); if (selectedChannels.size() > 1) { JOptionPane.showMessageDialog(parent, "This operation can only be performed on a single channel."); return; } Channel channel = selectedChannels.get(0); if (channel instanceof InvalidChannel) { InvalidChannel invalidChannel = (InvalidChannel) channel; Throwable cause = invalidChannel.getCause(); parent.alertThrowable(parent, cause, "Channel \"" + channel.getName() + "\" is invalid and cannot be cloned. " + getMissingExtensions(invalidChannel) + "Original cause:\n" + cause.getMessage()); return; } try { channel = (Channel) SerializationUtils.clone(channel); } catch (SerializationException e) { parent.alertThrowable(parent, e); return; } try { channel.setRevision(0); channel.setId(parent.mirthClient.getGuid()); } catch (ClientException e) { parent.alertThrowable(parent, e); } String channelName = channel.getName(); do { channelName = JOptionPane.showInputDialog(this, "Please enter a new name for the channel.", channelName); if (channelName == null) { return; } } while (!parent.checkChannelName(channelName, channel.getId())); channel.setName(channelName); channelStatuses.put(channel.getId(), new ChannelStatus(channel)); parent.updateChannelTags(false); parent.editChannel(channel); parent.setSaveEnabled(true); }
From source file:com.mirth.connect.client.ui.Frame.java
public void importAlert(String alertXML, boolean showAlerts) { ObjectXMLSerializer serializer = ObjectXMLSerializer.getInstance(); List<AlertModel> alertList; try {//from w ww. ja va2 s . co m alertList = (List<AlertModel>) serializer.deserializeList( alertXML.replaceAll("\\&\\#x0D;\\n", "\n").replaceAll("\\&\\#x0D;", "\n"), AlertModel.class); } catch (Exception e) { if (showAlerts) { alertThrowable(this, e, "Invalid alert file:\n" + e.getMessage()); } return; } removeInvalidItems(alertList, AlertModel.class); for (AlertModel importAlert : alertList) { try { String alertName = importAlert.getName(); String tempId = mirthClient.getGuid(); // Check to see that the alert name doesn't already exist. if (!checkAlertName(alertName)) { if (!alertOption(this, "Would you like to overwrite the existing alert? Choose 'No' to create a new alert.")) { do { alertName = JOptionPane.showInputDialog(this, "Please enter a new name for the channel.", alertName); if (alertName == null) { return; } } while (!checkAlertName(alertName)); importAlert.setName(alertName); importAlert.setId(tempId); } else { for (Entry<String, String> entry : alertPanel.getAlertNames().entrySet()) { String id = entry.getKey(); String name = entry.getValue(); if (name.equalsIgnoreCase(alertName)) { // If overwriting, use the old id importAlert.setId(id); } } } } mirthClient.updateAlert(importAlert); } catch (Exception e) { alertThrowable(this, e, "Error importing alert:\n" + e.getMessage()); } } doRefreshAlerts(true); }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositMain.java
public String getInput(String header, String message, String defaultInput) { return JOptionPane.showInputDialog(this, message, defaultInput); }
From source file:org.broad.igv.track.TrackMenuUtils.java
/** * Return popup menu with items applicable to feature tracks * * @return//from ww w . jav a 2 s. c o m */ private static void addFeatureItems(JPopupMenu featurePopupMenu, final Collection<Track> tracks, TrackClickEvent te) { addDisplayModeItems(tracks, featurePopupMenu); if (tracks.size() == 1) { Track t = tracks.iterator().next(); Feature f = t.getFeatureAtMousePosition(te); if (f != null) { featurePopupMenu.addSeparator(); // If we are over an exon, copy its sequence instead of the entire feature. if (f instanceof IGVFeature) { double position = te.getChromosomePosition(); Collection<Exon> exons = ((IGVFeature) f).getExons(); if (exons != null) { for (Exon exon : exons) { if (position > exon.getStart() && position < exon.getEnd()) { f = exon; break; } } } } featurePopupMenu.add(getCopyDetailsItem(f, te)); featurePopupMenu.add(getCopySequenceItem(f)); } } featurePopupMenu.addSeparator(); featurePopupMenu.add(getChangeFeatureWindow(tracks)); //---------------------// //Track analysis if (Globals.toolsMenuEnabled && tracks.size() >= 2) { JMenuItem item = new JMenuItem("Create Overlap Track"); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String newName = JOptionPane.showInputDialog(IGV.getMainFrame(), "Enter overlap track name: ", "Overlaps"); if (newName == null || newName.trim() == "") { return; } CombinedFeatureSource source = new CombinedFeatureSource(tracks, CombinedFeatureSource.Operation.MULTIINTER); Track newTrack = new FeatureTrack("", newName, source); IGV.getInstance().getTrackPanel(IGV.FEATURE_PANEL_NAME).addTrack(newTrack); IGV.getInstance().repaint(); } }); item.setEnabled(CombinedFeatureSource.checkBEDToolsPathValid()); featurePopupMenu.add(item); } //--------------------// }
From source file:org.broad.igv.track.TrackMenuUtils.java
public static void renameTrack(final Collection<Track> selectedTracks) { if (selectedTracks.isEmpty()) { return;//from w ww .ja va 2 s . c o m } Track t = selectedTracks.iterator().next(); String newName = JOptionPane.showInputDialog(IGV.getMainFrame(), "Enter new name: ", t.getName()); if (newName == null || newName.trim() == "") { return; } t.setName(newName); refresh(); }