List of usage examples for javax.swing JCheckBox isSelected
public boolean isSelected()
From source file:jp.massbank.spectrumsearch.SearchPage.java
/** * ?/*from w ww . java2 s . c o m*/ * ??????? * ????[Cookie][]????? * ??1??????????????? */ private void initInstInfo() { instCheck = new LinkedHashMap<String, JCheckBox>(); isInstCheck = new HashMap<String, Boolean>(); instGroup = instInfo.getTypeGroup(); // Cookie?Cookie???? List<String> valueGetList = Arrays.asList(SystemProperties.getInstance().getDefaultInstanceTypeList()); // ArrayList<String> valueGetList = cm.getCookie(COOKIE_INST); List<String> valueSetList = new ArrayList<String>(); boolean checked = false; LOGGER.info("instInfo.getTypeGroup().size() -> " + instGroup.size()); for (Entry<String, List<String>> entry : instGroup.entrySet()) { // for (Iterator i=instGroup.keySet().iterator(); i.hasNext(); ) { // String key = (String)i.next(); // List<String> list = instGroup.get(key); // LOGGER.info("instGroup.get( "+key+" ).size() -> " + list.size()); List<String> list = entry.getValue(); for (String val : list) { // for ( int j = 0; j < list.size(); j++ ) { // String val = list.get(j); JCheckBox chkBox; // Cookie??? if (valueGetList.size() != 0) { if (valueGetList.contains(val)) { chkBox = new JCheckBox(val, true); checked = true; } else { chkBox = new JCheckBox(val, false); } } else { if (isDefaultInst(val)) { // ?? chkBox = new JCheckBox(val, true); checked = true; valueSetList.add(val); } else { chkBox = new JCheckBox(val, false); } } instCheck.put(val, chkBox); isInstCheck.put(val, chkBox.isSelected()); } } // ???????? if (instCheck.size() == 0 && isInstCheck.size() == 0) { JOptionPane.showMessageDialog(null, "Instrument Type is not registered in the database.", "Error", JOptionPane.ERROR_MESSAGE); return; } // ????????1????????????? if (!checked) { for (Iterator i = instCheck.keySet().iterator(); i.hasNext();) { String key = (String) i.next(); ((JCheckBox) instCheck.get(key)).setSelected(true); isInstCheck.put(key, true); valueSetList.add(key); } } // ????Cookie??????Cookie? if (valueGetList.size() == 0) { SystemProperties.setDefaultInstanceTypeList(valueSetList); // cm.setCookie(COOKIE_INST, valueSetList); } }
From source file:com.mirth.connect.client.ui.ChannelPanel.java
private boolean handleExportGroups(List<ChannelGroup> groups) { // Populate list of groups with full channels for (ChannelGroup group : groups) { List<Channel> channels = new ArrayList<Channel>(); for (Channel channel : group.getChannels()) { ChannelStatus channelStatus = this.channelStatuses.get(channel.getId()); if (channelStatus != null) { channels.add(channelStatus.getChannel()); }//from ww w .ja v a2 s. com } group.setChannels(channels); } try { // Add code template libraries to channels if necessary if (groupHasLinkedCodeTemplates(groups)) { boolean addLibraries; String exportChannelCodeTemplateLibraries = Preferences.userNodeForPackage(Mirth.class) .get("exportChannelCodeTemplateLibraries", null); if (exportChannelCodeTemplateLibraries == 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[] { "<html>One or more channels has code template libraries linked to them.<br/>Do you wish to include these libraries in each respective channel export?</html>", 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) { addLibraries = result == JOptionPane.YES_OPTION; if (alwaysChooseCheckBox.isSelected()) { Preferences.userNodeForPackage(Mirth.class) .putBoolean("exportChannelCodeTemplateLibraries", addLibraries); } } else { return false; } } else { addLibraries = Boolean.parseBoolean(exportChannelCodeTemplateLibraries); } if (addLibraries) { for (ChannelGroup group : groups) { for (Channel channel : group.getChannels()) { addCodeTemplateLibrariesToChannel(channel); } } } } // Update resource names for (ChannelGroup group : groups) { for (Channel channel : group.getChannels()) { addDependenciesToChannel(channel); parent.updateResourceNames(channel); } } if (groups.size() == 1) { return exportGroup(groups.iterator().next()); } else { return exportGroups(groups); } } finally { // Reset the libraries on the cached channels for (ChannelGroup group : groups) { for (Channel channel : group.getChannels()) { channel.getCodeTemplateLibraries().clear(); channel.clearDependencies(); } } } }
From source file:com.mirth.connect.client.ui.ChannelPanel.java
private void exportChannels(List<Channel> channelList) { if (channelHasLinkedCodeTemplates(channelList)) { boolean addLibraries; String exportChannelCodeTemplateLibraries = Preferences.userNodeForPackage(Mirth.class) .get("exportChannelCodeTemplateLibraries", null); if (exportChannelCodeTemplateLibraries == 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[] { "<html>One or more channels has code template libraries linked to them.<br/>Do you wish to include these libraries in each respective channel export?</html>", 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) { addLibraries = result == JOptionPane.YES_OPTION; if (alwaysChooseCheckBox.isSelected()) { Preferences.userNodeForPackage(Mirth.class).putBoolean("exportChannelCodeTemplateLibraries", addLibraries); }// w w w. j a v a 2 s .c o m } else { return; } } else { addLibraries = Boolean.parseBoolean(exportChannelCodeTemplateLibraries); } if (addLibraries) { for (Channel channel : channelList) { addCodeTemplateLibrariesToChannel(channel); } } } for (Channel channel : channelList) { addDependenciesToChannel(channel); } JFileChooser exportFileChooser = new JFileChooser(); exportFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); File currentDir = new File(Frame.userPreferences.get("currentDirectory", "")); if (currentDir.exists()) { exportFileChooser.setCurrentDirectory(currentDir); } int returnVal = exportFileChooser.showSaveDialog(this); File exportFile = null; File exportDirectory = null; String exportPath = "/"; if (returnVal == JFileChooser.APPROVE_OPTION) { Frame.userPreferences.put("currentDirectory", exportFileChooser.getCurrentDirectory().getPath()); int exportCollisionCount = 0; exportDirectory = exportFileChooser.getSelectedFile(); exportPath = exportDirectory.getAbsolutePath(); for (Channel channel : channelList) { exportFile = new File(exportPath + "/" + channel.getName() + ".xml"); if (exportFile.exists()) { exportCollisionCount++; } // Update resource names parent.updateResourceNames(channel); } try { int exportCount = 0; boolean overwriteAll = false; boolean skipAll = false; for (int i = 0, size = channelList.size(); i < size; i++) { Channel channel = channelList.get(i); exportFile = new File(exportPath + "/" + channel.getName() + ".xml"); boolean fileExists = exportFile.exists(); if (fileExists) { if (!overwriteAll && !skipAll) { if (exportCollisionCount == 1) { if (!parent.alertOption(parent, "The file " + channel.getName() + ".xml already exists. Would you like to overwrite it?")) { continue; } } else { ConflictOption conflictStatus = parent.alertConflict(parent, "<html>The file " + channel.getName() + ".xml already exists.<br>Would you like to overwrite it?</html>", exportCollisionCount); if (conflictStatus == ConflictOption.YES_APPLY_ALL) { overwriteAll = true; } else if (conflictStatus == ConflictOption.NO) { exportCollisionCount--; continue; } else if (conflictStatus == ConflictOption.NO_APPLY_ALL) { skipAll = true; continue; } } } exportCollisionCount--; } if (!fileExists || !skipAll) { String channelXML = ObjectXMLSerializer.getInstance().serialize(channel); FileUtils.writeStringToFile(exportFile, channelXML, UIConstants.CHARSET); exportCount++; } } if (exportCount > 0) { parent.alertInformation(parent, exportCount + " files were written successfully to " + exportPath + "."); } } catch (IOException ex) { parent.alertError(parent, "File could not be written."); } } // Reset the libraries on the cached channels for (Channel channel : channelList) { channel.getCodeTemplateLibraries().clear(); channel.clearDependencies(); } }
From source file:com.mirth.connect.client.ui.ChannelPanel.java
public Channel importChannel(Channel importChannel, boolean showAlerts, boolean refreshStatuses) { boolean overwrite = false; try {/*from www . ja va2s . c o 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 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); }/* w w w .j a va 2s . 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:com.marginallyclever.makelangelo.MainGUI.java
protected boolean ChooseImageConversionOptions(boolean isDXF) { final JDialog driver = new JDialog(mainframe, translator.get("ConversionOptions"), true); driver.setLayout(new GridBagLayout()); final String[] choices = machineConfiguration.getKnownMachineNames(); final JComboBox<String> machine_choice = new JComboBox<String>(choices); machine_choice.setSelectedIndex(machineConfiguration.getCurrentMachineIndex()); final JSlider input_paper_margin = new JSlider(JSlider.HORIZONTAL, 0, 50, 100 - (int) (machineConfiguration.paper_margin * 100)); input_paper_margin.setMajorTickSpacing(10); input_paper_margin.setMinorTickSpacing(5); input_paper_margin.setPaintTicks(false); input_paper_margin.setPaintLabels(true); //final JCheckBox allow_metrics = new JCheckBox(String.valueOf("I want to add the distance drawn to the // total")); //allow_metrics.setSelected(allowMetrics); final JCheckBox reverse_h = new JCheckBox(translator.get("FlipForGlass")); reverse_h.setSelected(machineConfiguration.reverseForGlass); final JButton cancel = new JButton(translator.get("Cancel")); final JButton save = new JButton(translator.get("Start")); String[] filter_names = new String[image_converters.size()]; Iterator<Filter> fit = image_converters.iterator(); int i = 0;/*from w w w. j ava2 s . c om*/ while (fit.hasNext()) { Filter f = fit.next(); filter_names[i++] = f.GetName(); } final JComboBox<String> input_draw_style = new JComboBox<String>(filter_names); input_draw_style.setSelectedIndex(GetDrawStyle()); GridBagConstraints c = new GridBagConstraints(); //c.gridwidth=4; c.gridx=0; c.gridy=0; driver.add(allow_metrics,c); int y = 0; c.anchor = GridBagConstraints.EAST; c.gridwidth = 1; c.gridx = 0; c.gridy = y; driver.add(new JLabel(translator.get("MenuLoadMachineConfig")), c); c.anchor = GridBagConstraints.WEST; c.gridwidth = 2; c.gridx = 1; c.gridy = y++; driver.add(machine_choice, c); if (!isDXF) { c.anchor = GridBagConstraints.EAST; c.gridwidth = 1; c.gridx = 0; c.gridy = y; driver.add(new JLabel(translator.get("ConversionStyle")), c); c.anchor = GridBagConstraints.WEST; c.gridwidth = 3; c.gridx = 1; c.gridy = y++; driver.add(input_draw_style, c); } c.anchor = GridBagConstraints.EAST; c.gridwidth = 1; c.gridx = 0; c.gridy = y; driver.add(new JLabel(translator.get("PaperMargin")), c); c.anchor = GridBagConstraints.WEST; c.gridwidth = 3; c.gridx = 1; c.gridy = y++; driver.add(input_paper_margin, c); c.anchor = GridBagConstraints.WEST; c.gridwidth = 1; c.gridx = 1; c.gridy = y++; driver.add(reverse_h, c); c.anchor = GridBagConstraints.EAST; c.gridwidth = 1; c.gridx = 2; c.gridy = y; driver.add(save, c); c.anchor = GridBagConstraints.WEST; c.gridwidth = 1; c.gridx = 3; c.gridy = y++; driver.add(cancel, c); startConvertingNow = false; ActionListener driveButtons = new ActionListener() { public void actionPerformed(ActionEvent e) { Object subject = e.getSource(); if (subject == save) { long new_uid = Long.parseLong(choices[machine_choice.getSelectedIndex()]); machineConfiguration.LoadConfig(new_uid); SetDrawStyle(input_draw_style.getSelectedIndex()); machineConfiguration.paper_margin = (100 - input_paper_margin.getValue()) * 0.01; machineConfiguration.reverseForGlass = reverse_h.isSelected(); machineConfiguration.SaveConfig(); // if we aren't connected, don't show the new if (connectionToRobot != null && !connectionToRobot.isRobotConfirmed()) { // Force update of graphics layout. previewPane.updateMachineConfig(); // update window title mainframe.setTitle( translator.get("TitlePrefix") + Long.toString(machineConfiguration.robot_uid) + translator.get("TitleNotConnected")); } startConvertingNow = true; driver.dispose(); } if (subject == cancel) { driver.dispose(); } } }; save.addActionListener(driveButtons); cancel.addActionListener(driveButtons); driver.getRootPane().setDefaultButton(save); driver.pack(); driver.setVisible(true); return startConvertingNow; }
From source file:com.mirth.connect.client.ui.Frame.java
/** * Alerts the user with a conflict resolution dialog *///w ww.j a v a 2s. co m public ConflictOption alertConflict(Component parentComponent, String message, int count) { final JCheckBox conflictCheckbox = new JCheckBox( "Do this for the next " + String.valueOf(count - 1) + " conflicts"); conflictCheckbox.setSelected(false); Object[] params = { message, conflictCheckbox }; int jOption = JOptionPane.showConfirmDialog(getVisibleComponent(parentComponent), params, "Select an Option", JOptionPane.YES_NO_OPTION); boolean isSelected = conflictCheckbox.isSelected(); ConflictOption conflictOption = null; if (jOption == JOptionPane.YES_OPTION) { if (isSelected) { conflictOption = ConflictOption.YES_APPLY_ALL; } else { conflictOption = ConflictOption.YES; } } else { if (isSelected || jOption == -1) { conflictOption = ConflictOption.NO_APPLY_ALL; } else { conflictOption = ConflictOption.NO; } } return conflictOption; }
From source file:com.declarativa.interprolog.gui.Ini2.java
private void graphComponents() throws IOException { Forest<String, Integer> forest = new DelegateForest<>(); ObservableGraph g = new ObservableGraph(new BalloonLayoutDemo().createTree(forest)); Layout layout = new BalloonLayout(forest); //Layout layout = new TreeLayout(forest, 70, 70); final BaseJungScene scene = new SceneImpl(g, layout); jLayeredPane1.setLayout(new BorderLayout()); //jf.setLayout(new BorderLayout()); jLayeredPane1.add(new JScrollPane(scene.createView()), BorderLayout.CENTER); //jf.add(new JScrollPane(scene.createView()), BorderLayout.CENTER); JToolBar bar = new JToolBar(); bar.setMargin(new Insets(5, 5, 5, 5)); bar.setLayout(new FlowLayout(5)); DefaultComboBoxModel<Layout> mdl = new DefaultComboBoxModel<>(); mdl.addElement(new KKLayout(g)); mdl.addElement(layout);//from ww w. j a v a2s . c o m mdl.addElement(new BalloonLayout(forest)); mdl.addElement(new RadialTreeLayout(forest)); mdl.addElement(new CircleLayout(g)); mdl.addElement(new FRLayout(g)); mdl.addElement(new FRLayout2(g)); mdl.addElement(new ISOMLayout(g)); mdl.addElement(new SpringLayout(g)); mdl.addElement(new SpringLayout2(g)); mdl.addElement(new DAGLayout(g)); mdl.addElement(new XLayout(g)); mdl.setSelectedItem(layout); final JCheckBox checkbox = new JCheckBox("Animate iterative layouts"); scene.setLayoutAnimationFramesPerSecond(48); final JComboBox<Layout> layouts = new JComboBox(mdl); layouts.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln, boolean bln1) { o = o.getClass().getSimpleName(); return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates. } }); bar.add(new JLabel(" Layout Type")); bar.add(layouts); layouts.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { Layout layout = (Layout) layouts.getSelectedItem(); // These two layouts implement IterativeContext, but they do // not evolve toward anything, they just randomly rearrange // themselves. So disable animation for these. if (layout instanceof ISOMLayout || layout instanceof DAGLayout) { checkbox.setSelected(false); } scene.setGraphLayout(layout, true); } }); bar.add(new JLabel(" Connection Shape")); DefaultComboBoxModel<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapes = new DefaultComboBoxModel<>(); shapes.addElement(new EdgeShape.QuadCurve<String, Number>()); shapes.addElement(new EdgeShape.BentLine<String, Number>()); shapes.addElement(new EdgeShape.CubicCurve<String, Number>()); shapes.addElement(new EdgeShape.Line<String, Number>()); shapes.addElement(new EdgeShape.Box<String, Number>()); shapes.addElement(new EdgeShape.Orthogonal<String, Number>()); shapes.addElement(new EdgeShape.Wedge<String, Number>(10)); final JComboBox<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapesBox = new JComboBox<>( shapes); shapesBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { Transformer<Context<Graph<String, Number>, Number>, Shape> xform = (Transformer<Context<Graph<String, Number>, Number>, Shape>) shapesBox .getSelectedItem(); scene.setConnectionEdgeShape(xform); } }); shapesBox.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln, boolean bln1) { o = o.getClass().getSimpleName(); return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates. } }); shapesBox.setSelectedItem(new EdgeShape.QuadCurve<>()); bar.add(shapesBox); //jf.add(bar, BorderLayout.NORTH); bar.add(new MinSizePanel(scene.createSatelliteView())); bar.setFloatable(false); bar.setRollover(true); final JLabel selectionLabel = new JLabel("<html> </html>"); System.out.println("LOOKUP IS " + scene.getLookup()); Lookup.Result<String> selectedNodes = scene.getLookup().lookupResult(String.class); LookupListener listener = new LookupListener() { @Override public void resultChanged(LookupEvent le) { System.out.println("RES CHANGED"); Lookup.Result<String> res = (Lookup.Result<String>) le.getSource(); StringBuilder sb = new StringBuilder("<html>"); List<String> l = new ArrayList<>(res.allInstances()); Collections.sort(l); for (String s : l) { if (sb.length() != 0) { sb.append(", "); } sb.append(s); } sb.append("</html>"); selectionLabel.setText(sb.toString()); System.out.println("LOOKUP EVENT " + sb); } }; selectedNodes.addLookupListener(listener); selectedNodes.allInstances(); bar.add(selectionLabel); checkbox.setSelected(true); checkbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { scene.setAnimateIterativeLayouts(checkbox.isSelected()); } }); bar.add(checkbox); jLayeredPane3.setLayout(new BorderLayout()); jLayeredPane3.add(bar); // jf.setSize(jf.getGraphicsConfiguration().getBounds().width - 120, 700); // jf.setSize(new Dimension(1280, 720)); // jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); this.addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent we) { scene.relayout(true); scene.validate(); } }); }
From source file:com.declarativa.interprolog.gui.Ini3.java
private void graphComponents() throws IOException { Forest<String, Integer> forest = new DelegateForest<>(); ObservableGraph g = new ObservableGraph(new BalloonLayoutDemo().createTree(forest)); Layout layout = new BalloonLayout(forest); //Layout layout = new TreeLayout(forest, 70, 70); final BaseJungScene scene = new SceneImpl(g, layout); jLayeredPane1.setLayout(new BorderLayout()); //jf.setLayout(new BorderLayout()); jLayeredPane1.add(new JScrollPane(scene.createView()), BorderLayout.CENTER); //jf.add(new JScrollPane(scene.createView()), BorderLayout.CENTER); JToolBar bar = new JToolBar(); bar.setMargin(new Insets(5, 5, 5, 5)); bar.setLayout(new FlowLayout(5)); DefaultComboBoxModel<Layout> mdl = new DefaultComboBoxModel<>(); mdl.addElement(new KKLayout(g)); mdl.addElement(layout);/* ww w. j av a 2 s. c om*/ mdl.addElement(new BalloonLayout(forest)); mdl.addElement(new RadialTreeLayout(forest)); mdl.addElement(new CircleLayout(g)); mdl.addElement(new FRLayout(g)); mdl.addElement(new FRLayout2(g)); mdl.addElement(new ISOMLayout(g)); mdl.addElement(new SpringLayout(g)); mdl.addElement(new SpringLayout2(g)); mdl.addElement(new DAGLayout(g)); mdl.addElement(new XLayout(g)); mdl.setSelectedItem(layout); final JCheckBox checkbox = new JCheckBox("Animate iterative layouts"); scene.setLayoutAnimationFramesPerSecond(48); final JComboBox<Layout> layouts = new JComboBox(mdl); layouts.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln, boolean bln1) { o = o.getClass().getSimpleName(); return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates. } }); bar.add(new JLabel(" Layout Type")); bar.add(layouts); layouts.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { Layout layout = (Layout) layouts.getSelectedItem(); // These two layouts implement IterativeContext, but they do // not evolve toward anything, they just randomly rearrange // themselves. So disable animation for these. if (layout instanceof ISOMLayout || layout instanceof DAGLayout) { checkbox.setSelected(false); } scene.setGraphLayout(layout, true); } }); bar.add(new JLabel(" Connection Shape")); DefaultComboBoxModel<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapes = new DefaultComboBoxModel<>(); shapes.addElement(new EdgeShape.QuadCurve<String, Number>()); shapes.addElement(new EdgeShape.BentLine<String, Number>()); shapes.addElement(new EdgeShape.CubicCurve<String, Number>()); shapes.addElement(new EdgeShape.Line<String, Number>()); shapes.addElement(new EdgeShape.Box<String, Number>()); shapes.addElement(new EdgeShape.Orthogonal<String, Number>()); shapes.addElement(new EdgeShape.Wedge<String, Number>(10)); final JComboBox<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapesBox = new JComboBox<>( shapes); shapesBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { Transformer<Context<Graph<String, Number>, Number>, Shape> xform = (Transformer<Context<Graph<String, Number>, Number>, Shape>) shapesBox .getSelectedItem(); scene.setConnectionEdgeShape(xform); } }); shapesBox.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln, boolean bln1) { o = o.getClass().getSimpleName(); return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates. } }); shapesBox.setSelectedItem(new EdgeShape.QuadCurve<>()); bar.add(shapesBox); //jf.add(bar, BorderLayout.NORTH); bar.add(new MinSizePanel(scene.createSatelliteView())); bar.setFloatable(false); bar.setRollover(true); final JLabel selectionLabel = new JLabel("<html> </html>"); System.out.println("LOOKUP IS " + scene.getLookup()); Lookup.Result<String> selectedNodes = scene.getLookup().lookupResult(String.class); LookupListener listener = new LookupListener() { @Override public void resultChanged(LookupEvent le) { System.out.println("RES CHANGED"); Lookup.Result<String> res = (Lookup.Result<String>) le.getSource(); StringBuilder sb = new StringBuilder("<html>"); List<String> l = new ArrayList<>(res.allInstances()); Collections.sort(l); for (String s : l) { if (sb.length() != 0) { sb.append(", "); } sb.append(s); } sb.append("</html>"); selectionLabel.setText(sb.toString()); System.out.println("LOOKUP EVENT " + sb); } }; selectedNodes.addLookupListener(listener); selectedNodes.allInstances(); bar.add(selectionLabel); checkbox.setSelected(true); checkbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { scene.setAnimateIterativeLayouts(checkbox.isSelected()); } }); bar.add(checkbox); jLayeredPane3.setLayout(new BorderLayout()); jLayeredPane3.add(bar); // jf.setSize(jf.getGraphicsConfiguration().getBounds().width - 120, 700); // jf.setSize(new Dimension(1280, 720)); // jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); this.addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent we) { scene.relayout(true); scene.validate(); } }); }
From source file:org.cds06.speleograph.graph.GraphEditor.java
/** * Creates a modal dialog by specifying the attached {@link GraphPanel}. * <p>Please look at {@link javax.swing.JDialog#JDialog()} to see defaults params applied to this Dialog.</p> *//* w w w .j av a 2 s . co m*/ public GraphEditor(GraphPanel panel) { super((Frame) SwingUtilities.windowForComponent(panel), true); Validate.notNull(panel); this.graphPanel = panel; KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); mainPanel.registerKeyboardAction(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setVisible(false); } }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); setContentPane(mainPanel); mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); this.setTitle(I18nSupport.translate("menus.graph.graphEditor")); { // This section use FormLayout which is an external layout for Java, consult the doc before edit the // following lines ! final FormLayout layout = new FormLayout( "right:max(40dlu;p), 4dlu, p:grow, 4dlu, p, 4dlu, p:grow, 4dlu, p", //NON-NLS "p,4dlu,p,4dlu,p,4dlu,p,4dlu,p" //NON-NLS ); PanelBuilder builder = new PanelBuilder(layout); final JLabel colorLabel = new JLabel(); final JTextField titleForGraph = new JTextField( graphPanel.getChart().getTitle() != null ? graphPanel.getChart().getTitle().getText() : ""); final JLabel colorXYPlotLabel = new JLabel(); final JLabel colorGridLabel = new JLabel(); final JCheckBox showLegendCheckBox = new JCheckBox("Afficher la lgende", graphPanel.getChart().getLegend().isVisible()); { builder.addLabel("Titre :", "1,1"); builder.add(titleForGraph, "3,1,7,1"); } { builder.addLabel(I18nSupport.translate("menus.graph.graphEditor.backgroundColor"), "1,3"); colorLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); colorLabel.setText(" "); colorLabel.setBackground((Color) graphPanel.getChart().getBackgroundPaint()); colorLabel.setOpaque(true); colorLabel.setEnabled(false); final JButton edit = new JButton(I18nSupport.translate("menus.graph.graphEditor.edit")); edit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Color c = JColorChooser.showDialog(GraphEditor.this, I18nSupport.translate("menus.graph.graphEditor.selectColor"), colorLabel.getBackground()); if (c != null) { colorLabel.setBackground(c); } } }); builder.add(colorLabel, "3,3,5,1"); builder.add(edit, "9,3"); } final XYPlot xyPlot = graphPanel.getChart().getXYPlot(); { builder.addLabel(I18nSupport.translate("menus.graph.graphEditor.graphColor"), "1,5"); colorXYPlotLabel.setText(" "); colorXYPlotLabel.setOpaque(true); colorXYPlotLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); colorXYPlotLabel.setBackground((Color) xyPlot.getBackgroundPaint()); colorXYPlotLabel.setEnabled(false); final JButton edit = new JButton(I18nSupport.translate("menus.graph.graphEditor.edit")); edit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Color c = JColorChooser.showDialog(GraphEditor.this, I18nSupport.translate("menus.graph.graphEditor.selectColor"), colorXYPlotLabel.getBackground()); if (c != null) { colorXYPlotLabel.setBackground(c); } } }); builder.add(colorXYPlotLabel, "3,5,5,1"); builder.add(edit, "9,5"); } { builder.addLabel(I18nSupport.translate("menus.graph.graphEditor.gridColor"), "1,7"); colorGridLabel.setOpaque(true); colorGridLabel.setText(" "); colorGridLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); colorGridLabel.setBackground((Color) xyPlot.getRangeGridlinePaint()); colorGridLabel.setEnabled(false); final JButton edit = new JButton(I18nSupport.translate("menus.graph.graphEditor.edit")); edit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Color c = JColorChooser.showDialog(GraphEditor.this, I18nSupport.translate("menus.graph.graphEditor.selectColor"), colorGridLabel.getBackground()); if (c != null) { colorGridLabel.setBackground(c); } } }); builder.add(colorGridLabel, "3,7,5,1"); builder.add(edit, "9,7"); } { builder.add(showLegendCheckBox, "1,9,9,1"); } mainPanel.add(builder.build(), BorderLayout.CENTER); ButtonBarBuilder buttonBarBuilder = new ButtonBarBuilder(); buttonBarBuilder.addGlue(); buttonBarBuilder.addButton(new AbstractAction() { { putValue(NAME, I18nSupport.translate("cancel")); } @Override public void actionPerformed(ActionEvent e) { GraphEditor.this.setVisible(false); } }); buttonBarBuilder.addButton(new AbstractAction() { { putValue(NAME, I18nSupport.translate("ok")); } @Override public void actionPerformed(ActionEvent e) { if (titleForGraph.getText().isEmpty()) graphPanel.getChart().setTitle((String) null); else graphPanel.getChart().setTitle(titleForGraph.getText()); { Color c = colorGridLabel.getBackground(); xyPlot.setRangeGridlinePaint(c); xyPlot.setRangeMinorGridlinePaint(c); xyPlot.setDomainGridlinePaint(c); xyPlot.setDomainMinorGridlinePaint(c); } graphPanel.getChart().setBackgroundPaint(colorLabel.getBackground()); xyPlot.setBackgroundPaint(colorXYPlotLabel.getBackground()); graphPanel.getChart().getLegend().setVisible(showLegendCheckBox.isSelected()); GraphEditor.this.setVisible(false); } }); mainPanel.add(buttonBarBuilder.build(), BorderLayout.SOUTH); } pack(); Dimension d = this.getPreferredSize(); this.setSize(new Dimension(d.width + 20, d.height)); setResizable(false); }