List of usage examples for javax.swing JTextField setToolTipText
@BeanProperty(bound = false, preferred = true, description = "The text to display in a tool tip.") public void setToolTipText(String text)
From source file:com.xtructure.xevolution.gui.components.CollectArgsDialog.java
/** * Creates a new {@link CollectArgsDialog} * /* w ww .jav a 2 s. c o m*/ * @param frame * the parent JFrame for the new {@link CollectArgsDialog} * @param statusBar * the {@link StatusBar} to update (can be null) * @param title * the title of the new {@link CollectArgsDialog} * @param xOptions * the {@link Collection} of {@link XOption}s for which to * collect user input */ public CollectArgsDialog(JFrame frame, final StatusBar statusBar, String title, final Collection<XOption<?>> xOptions) { super(frame, title, true); argComponents = new ArrayList<JComponent>(); final CollectArgsDialog dialog = this; JPanel panel = new JPanel(new GridBagLayout()); getContentPane().add(panel); GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(3, 3, 3, 3); c.fill = GridBagConstraints.BOTH; int row = 0; for (XOption<?> xOption : xOptions) { if (xOption.getName() == null) { continue; } if (xOption.hasArg()) { JLabel label = new JLabel(xOption.getName()); JTextField textField = new JTextField(); textField.setName(xOption.getOpt()); textField.setToolTipText(xOption.getDescription()); argComponents.add(textField); c.gridx = 0; c.gridy = row; panel.add(label, c); c.gridx = 1; c.gridy = row; panel.add(textField, c); } else { JCheckBox checkBox = new JCheckBox(xOption.getName()); checkBox.setName(xOption.getOpt()); checkBox.setToolTipText(xOption.getDescription()); argComponents.add(checkBox); c.gridx = 0; c.gridy = row; panel.add(checkBox, c); } row++; } JPanel buttonPanel = new JPanel(); c.gridx = 1; c.gridy = row; panel.add(buttonPanel, c); JButton okButton = new JButton(new AbstractAction("OK") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { dialog.setVisible(false); if (statusBar != null) { statusBar.setMessage("building args..."); } ArrayList<String> args = new ArrayList<String>(); for (JComponent component : argComponents) { if (component instanceof JCheckBox) { JCheckBox checkbox = (JCheckBox) component; String opt = checkbox.getName(); if (checkbox.isSelected()) { args.add("-" + opt); } } if (component instanceof JTextField) { JTextField textField = (JTextField) component; String opt = textField.getName(); String text = textField.getText().trim(); if (!text.isEmpty()) { args.add("-" + opt); args.add("\"" + text + "\""); } } } if (statusBar != null) { statusBar.setMessage("parsing args..."); } try { Options options = new Options(); for (XOption<?> xOpt : xOptions) { options.addOption(xOpt); } XOption.parseArgs(options, args.toArray(new String[0])); dialog.success = true; } catch (ParseException e1) { e1.printStackTrace(); dialog.success = false; } if (statusBar != null) { statusBar.clearMessage(); } } }); buttonPanel.add(okButton); getRootPane().setDefaultButton(okButton); buttonPanel.add(new JButton(new AbstractAction("Cancel") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { dialog.setVisible(false); if (statusBar != null) { statusBar.clearMessage(); } } })); pack(); setLocationRelativeTo(frame); setVisible(true); }
From source file:com.intel.stl.ui.common.view.ComponentFactory.java
public static void setNumberInputVerifier(JTextField field) { // Add the input verifier field.setInputVerifier(new InputVerifier() { @Override// w ww . j a v a 2 s. c o m public boolean verify(JComponent input) { JTextField field = (JTextField) input; String txt = field.getText(); if (txt.isEmpty()) { field.setToolTipText(UILabels.STL50084_CANT_BE_BLANK.getDescription()); input.setBackground(UIConstants.INTEL_LIGHT_RED); return false; } try { Utils.toLong(txt); input.setBackground(UIConstants.INTEL_WHITE); return true; } catch (Exception e) { field.setToolTipText(UILabels.STL50085_MUST_BE_NUMERIC.getDescription()); input.setBackground(UIConstants.INTEL_LIGHT_RED); } return false; } }); }
From source file:net.pandoragames.far.ui.swing.dialog.SettingsDialog.java
private void init() { this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); this.setLayout(new BoxLayout(this.getContentPane(), BoxLayout.Y_AXIS)); this.setResizable(false); JPanel basePanel = new JPanel(); basePanel.setLayout(new BoxLayout(basePanel, BoxLayout.Y_AXIS)); basePanel.setBorder(/*from ww w . j a v a2 s. co m*/ BorderFactory.createEmptyBorder(0, SwingConfig.PADDING, SwingConfig.PADDING, SwingConfig.PADDING)); registerCloseWindowKeyListener(basePanel); // sink for error messages MessageLabel errorField = new MessageLabel(); errorField.setMinimumSize(new Dimension(100, swingConfig.getStandardComponentHight())); errorField.setBorder(BorderFactory.createEmptyBorder(1, SwingConfig.PADDING, 2, SwingConfig.PADDING)); TwoComponentsPanel lineError = new TwoComponentsPanel(errorField, Box.createRigidArea(new Dimension(1, swingConfig.getStandardComponentHight()))); lineError.setAlignmentX(Component.LEFT_ALIGNMENT); basePanel.add(lineError); // character set JLabel labelCharset = new JLabel(swingConfig.getLocalizer().localize("label.default-characterset")); labelCharset.setAlignmentX(Component.LEFT_ALIGNMENT); basePanel.add(labelCharset); JComboBox listCharset = new JComboBox(swingConfig.getCharsetList().toArray()); listCharset.setAlignmentX(Component.LEFT_ALIGNMENT); listCharset.setSelectedItem(swingConfig.getDefaultCharset()); listCharset.setEditable(true); listCharset.setMaximumSize( new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, swingConfig.getStandardComponentHight())); listCharset.addActionListener(new CharacterSetListener(errorField)); listCharset.setEditor(new CharacterSetEditor(errorField)); basePanel.add(listCharset); basePanel.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING))); // select the group selector JPanel selectorPanel = new JPanel(); selectorPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); selectorPanel.setAlignmentX(Component.LEFT_ALIGNMENT); // linePattern.setAlignmentX( Component.LEFT_ALIGNMENT ); JLabel labelSelector = new JLabel(swingConfig.getLocalizer().localize("label.group-ref-indicator")); selectorPanel.add(labelSelector); JComboBox selectorBox = new JComboBox(FARConfig.GROUPREFINDICATORLIST); selectorBox.setSelectedItem(Character.toString(groupReference)); selectorBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { JComboBox cbox = (JComboBox) event.getSource(); String indicator = (String) cbox.getSelectedItem(); groupReference = indicator.charAt(0); } }); selectorPanel.add(selectorBox); basePanel.add(selectorPanel); basePanel.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING))); // checkbox DO BACKUP JCheckBox doBackupFlag = new JCheckBox(swingConfig.getLocalizer().localize("label.create-backup")); doBackupFlag.setAlignmentX(Component.LEFT_ALIGNMENT); doBackupFlag.setHorizontalTextPosition(SwingConstants.LEADING); doBackupFlag.setSelected(replaceForm.isDoBackup()); doBackupFlag.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent event) { doBackup = ItemEvent.SELECTED == event.getStateChange(); backupFlagEvent = event; } }); basePanel.add(doBackupFlag); JTextField backupDirPathTextField = new JTextField(); backupDirPathTextField.setPreferredSize( new Dimension(SwingConfig.COMPONENT_WIDTH, swingConfig.getStandardComponentHight())); backupDirPathTextField.setMaximumSize( new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, swingConfig.getStandardComponentHight())); backupDirPathTextField.setText(backupDirectory.getPath()); backupDirPathTextField.setToolTipText(backupDirectory.getPath()); backupDirPathTextField.setEditable(false); JButton openBaseDirFileChooserButton = new JButton(swingConfig.getLocalizer().localize("button.browse")); BrowseButtonListener backupDirButtonListener = new BrowseButtonListener(backupDirPathTextField, new BackUpDirectoryRepository(swingConfig, findForm, replaceForm, errorField), swingConfig.getLocalizer().localize("label.choose-backup-directory")); openBaseDirFileChooserButton.addActionListener(backupDirButtonListener); TwoComponentsPanel lineBaseDir = new TwoComponentsPanel(backupDirPathTextField, openBaseDirFileChooserButton); lineBaseDir.setAlignmentX(Component.LEFT_ALIGNMENT); basePanel.add(lineBaseDir); basePanel.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING))); JPanel fileInfoPanel = new JPanel(); fileInfoPanel .setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), swingConfig.getLocalizer().localize("label.default-file-info"))); fileInfoPanel.setAlignmentX(Component.LEFT_ALIGNMENT); fileInfoPanel.setLayout(new BoxLayout(fileInfoPanel, BoxLayout.Y_AXIS)); JLabel fileInfoLabel = new JLabel(swingConfig.getLocalizer().localize("message.displayed-in-info-column")); fileInfoLabel.setAlignmentX(Component.LEFT_ALIGNMENT); fileInfoPanel.add(fileInfoLabel); fileInfoPanel.add(Box.createHorizontalGlue()); JRadioButton nothingRadio = new JRadioButton(swingConfig.getLocalizer().localize("label.nothing")); nothingRadio.setAlignmentX(Component.LEFT_ALIGNMENT); nothingRadio.setActionCommand(SwingConfig.DefaultFileInfo.NOTHING.name()); nothingRadio.setSelected(swingConfig.getDefaultFileInfo() == SwingConfig.DefaultFileInfo.NOTHING); fileInfoOptions.add(nothingRadio); fileInfoPanel.add(nothingRadio); JRadioButton readOnlyRadio = new JRadioButton( swingConfig.getLocalizer().localize("label.read-only-warning")); readOnlyRadio.setAlignmentX(Component.LEFT_ALIGNMENT); readOnlyRadio.setActionCommand(SwingConfig.DefaultFileInfo.READONLY.name()); readOnlyRadio.setSelected(swingConfig.getDefaultFileInfo() == SwingConfig.DefaultFileInfo.READONLY); fileInfoOptions.add(readOnlyRadio); fileInfoPanel.add(readOnlyRadio); JRadioButton sizeRadio = new JRadioButton(swingConfig.getLocalizer().localize("label.filesize")); sizeRadio.setAlignmentX(Component.LEFT_ALIGNMENT); sizeRadio.setActionCommand(SwingConfig.DefaultFileInfo.SIZE.name()); sizeRadio.setSelected(swingConfig.getDefaultFileInfo() == SwingConfig.DefaultFileInfo.SIZE); fileInfoOptions.add(sizeRadio); fileInfoPanel.add(sizeRadio); JCheckBox showPlainBytesFlag = new JCheckBox( " " + swingConfig.getLocalizer().localize("label.show-plain-bytes")); showPlainBytesFlag.setAlignmentX(Component.LEFT_ALIGNMENT); showPlainBytesFlag.setHorizontalTextPosition(SwingConstants.LEADING); showPlainBytesFlag.setSelected(swingConfig.isShowPlainBytes()); showPlainBytesFlag.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent event) { showBytes = ItemEvent.SELECTED == event.getStateChange(); } }); fileInfoPanel.add(showPlainBytesFlag); JRadioButton lastModifiedRadio = new JRadioButton( swingConfig.getLocalizer().localize("label.last-modified")); lastModifiedRadio.setAlignmentX(Component.LEFT_ALIGNMENT); lastModifiedRadio.setActionCommand(SwingConfig.DefaultFileInfo.LAST_MODIFIED.name()); lastModifiedRadio .setSelected(swingConfig.getDefaultFileInfo() == SwingConfig.DefaultFileInfo.LAST_MODIFIED); fileInfoOptions.add(lastModifiedRadio); fileInfoPanel.add(lastModifiedRadio); basePanel.add(fileInfoPanel); // buttons JPanel buttonPannel = new JPanel(); buttonPannel.setAlignmentX(Component.LEFT_ALIGNMENT); buttonPannel.setLayout(new FlowLayout(FlowLayout.TRAILING)); // cancel JButton cancelButton = new JButton(swingConfig.getLocalizer().localize("button.cancel")); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { SettingsDialog.this.dispose(); } }); buttonPannel.add(cancelButton); // save JButton saveButton = new JButton(swingConfig.getLocalizer().localize("button.save")); saveButton.addActionListener(new SaveButtonListener()); buttonPannel.add(saveButton); this.getRootPane().setDefaultButton(saveButton); this.add(basePanel); this.add(buttonPannel); placeOnScreen(swingConfig.getScreenCenter()); }
From source file:eu.crisis_economics.abm.dashboard.Page_Parameters.java
@SuppressWarnings("unchecked") private JComponent initializeJComponentForParameter(final String strValue, final ParameterInfo info) throws ModelInformationException { JComponent field = null;/* ww w . j av a2s .c o m*/ if (info.isBoolean()) { field = new JCheckBox(); boolean value = Boolean.parseBoolean(strValue); ((JCheckBox) field).setSelected(value); } else if (info.isEnum() || info instanceof MasonChooserParameterInfo) { Object[] elements = null; if (info.isEnum()) { final Class<Enum<?>> type = (Class<Enum<?>>) info.getJavaType(); elements = type.getEnumConstants(); } else { final MasonChooserParameterInfo chooserInfo = (MasonChooserParameterInfo) info; elements = chooserInfo.getValidStrings(); } final JComboBox list = new JComboBox(elements); if (info.isEnum()) { try { @SuppressWarnings("rawtypes") final Object value = Enum.valueOf((Class<? extends Enum>) info.getJavaType(), strValue); list.setSelectedItem(value); } catch (final IllegalArgumentException e) { throw new ModelInformationException(e.getMessage() + " for parameter: " + info.getName() + "."); } } else { try { final int value = Integer.parseInt(strValue); list.setSelectedIndex(value); } catch (final NumberFormatException e) { throw new ModelInformationException( "Invalid value for parameter " + info.getName() + " (not a number)."); } } field = list; } else if (info.isFile()) { field = new JPanel(); final JTextField textField = new JTextField(); if (!strValue.isEmpty()) { final File file = new File(strValue); textField.setText(file.getName()); textField.setToolTipText(file.getAbsolutePath()); } field.add(textField); } else if (info instanceof MasonIntervalParameterInfo) { field = new JPanel(); final JTextField textField = new JTextField(strValue); field.add(textField); } else { field = new JTextField(strValue); } return field; }
From source file:eu.crisis_economics.abm.dashboard.Page_Parameters.java
@SuppressWarnings("unchecked") private List<ParameterInfo> createAndDisplayAParameterPanel( final List<ai.aitia.meme.paramsweep.batch.param.ParameterInfo<?>> batchParameters, final String title, final SubmodelInfo parent, final boolean submodelSelectionWithoutNotify, final IModelHandler currentModelHandler) { final List<ParameterMetaData> metadata = new LinkedList<ParameterMetaData>(), unknownFields = new ArrayList<ParameterMetaData>(); for (final ai.aitia.meme.paramsweep.batch.param.ParameterInfo<?> record : batchParameters) { final String parameterName = record.getName(), fieldName = StringUtils.uncapitalize(parameterName); Class<?> modelComponentType = parent == null ? currentModelHandler.getModelClass() : parent.getActualType(); while (true) { try { final Field field = modelComponentType.getDeclaredField(fieldName); final ParameterMetaData datum = new ParameterMetaData(); for (final Annotation element : field.getAnnotations()) { if (element.annotationType().getName() != Layout.class.getName()) // Proxies continue; final Class<? extends Annotation> type = element.annotationType(); datum.verboseDescription = (String) type.getMethod("VerboseDescription").invoke(element); datum.banner = (String) type.getMethod("Title").invoke(element); datum.fieldName = (String) " " + type.getMethod("FieldName").invoke(element); datum.imageFileName = (String) type.getMethod("Image").invoke(element); datum.layoutOrder = (Double) type.getMethod("Order").invoke(element); }/*from ww w . j av a 2 s . co m*/ datum.parameter = record; if (datum.fieldName.trim().isEmpty()) datum.fieldName = parameterName.replaceAll("([A-Z])", " $1"); metadata.add(datum); break; } catch (final SecurityException e) { } catch (final NoSuchFieldException e) { } catch (final IllegalArgumentException e) { } catch (final IllegalAccessException e) { } catch (final InvocationTargetException e) { } catch (final NoSuchMethodException e) { } modelComponentType = modelComponentType.getSuperclass(); if (modelComponentType == null) { ParameterMetaData.createAndRegisterUnknown(fieldName, record, unknownFields); break; } } } Collections.sort(metadata); for (int i = unknownFields.size() - 1; i >= 0; --i) metadata.add(0, unknownFields.get(i)); // initialize single run form final DefaultFormBuilder formBuilder = FormsUtils.build("p ~ p:g", ""); appendMinimumWidthHintToPresentation(formBuilder, 550); if (parent == null) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { numberOfTurnsField.grabFocus(); } }); appendBannerToPresentation(formBuilder, "General Parameters"); appendTextToPresentation(formBuilder, "Global parameters affecting the entire simulation"); formBuilder.append(NUMBER_OF_TURNS_LABEL_TEXT, numberOfTurnsField); formBuilder.append(NUMBER_OF_TIMESTEPS_TO_IGNORE_LABEL_TEXT, numberTimestepsIgnored); appendCheckBoxFieldToPresentation(formBuilder, UPDATE_CHARTS_LABEL_TEXT, onLineChartsCheckBox); appendCheckBoxFieldToPresentation(formBuilder, DISPLAY_ADVANCED_CHARTS_LABEL_TEXT, advancedChartsCheckBox); } appendBannerToPresentation(formBuilder, title); final DefaultMutableTreeNode parentNode = (parent == null) ? parameterValueComponentTree : findParameterInfoNode(parent, false); final List<ParameterInfo> info = new ArrayList<ParameterInfo>(); // Search for a @ConfigurationComponent annotation { String headerText = "", imagePath = ""; final Class<?> parentType = parent == null ? currentModelHandler.getModelClass() : parent.getActualType(); for (final Annotation element : parentType.getAnnotations()) { // Proxies if (element.annotationType().getName() != ConfigurationComponent.class.getName()) continue; boolean doBreak = false; try { try { headerText = (String) element.annotationType().getMethod("Description").invoke(element); if (headerText.startsWith("#")) { headerText = (String) parent.getActualType().getMethod(headerText.substring(1)) .invoke(parent.getInstance()); } doBreak = true; } catch (IllegalArgumentException e) { } catch (SecurityException e) { } catch (IllegalAccessException e) { } catch (InvocationTargetException e) { } catch (NoSuchMethodException e) { } } catch (final Exception e) { } try { imagePath = (String) element.annotationType().getMethod("ImagePath").invoke(element); doBreak = true; } catch (IllegalArgumentException e) { } catch (SecurityException e) { } catch (IllegalAccessException e) { } catch (InvocationTargetException e) { } catch (NoSuchMethodException e) { } if (doBreak) break; } if (!headerText.isEmpty()) appendHeaderTextToPresentation(formBuilder, headerText); if (!imagePath.isEmpty()) appendImageToPresentation(formBuilder, imagePath); } if (metadata.isEmpty()) { // No fields to display. appendTextToPresentation(formBuilder, "No configuration is required for this module."); } else { for (final ParameterMetaData record : metadata) { final ai.aitia.meme.paramsweep.batch.param.ParameterInfo<?> batchParameterInfo = record.parameter; if (!record.banner.isEmpty()) appendBannerToPresentation(formBuilder, record.banner); if (!record.imageFileName.isEmpty()) appendImageToPresentation(formBuilder, record.imageFileName); appendTextToPresentation(formBuilder, record.verboseDescription); final ParameterInfo parameterInfo = InfoConverter.parameterInfo2ParameterInfo(batchParameterInfo); if (parent != null && parameterInfo instanceof ISubmodelGUIInfo) { // sgi.setParentValue(parent.getActualType()); } final JComponent field; final DefaultMutableTreeNode oldNode = findParameterInfoNode(parameterInfo, true); Pair<ParameterInfo, JComponent> userData = null; JComponent oldField = null; if (oldNode != null) { userData = (Pair<ParameterInfo, JComponent>) oldNode.getUserObject(); oldField = userData.getSecond(); } if (parameterInfo.isBoolean()) { field = new JCheckBox(); boolean value = oldField != null ? ((JCheckBox) oldField).isSelected() : ((Boolean) batchParameterInfo.getDefaultValue()).booleanValue(); ((JCheckBox) field).setSelected(value); } else if (parameterInfo.isEnum() || parameterInfo instanceof MasonChooserParameterInfo) { Object[] elements = null; if (parameterInfo.isEnum()) { final Class<Enum<?>> type = (Class<Enum<?>>) parameterInfo.getJavaType(); elements = type.getEnumConstants(); } else { final MasonChooserParameterInfo chooserInfo = (MasonChooserParameterInfo) parameterInfo; elements = chooserInfo.getValidStrings(); } final JComboBox list = new JComboBox(elements); if (parameterInfo.isEnum()) { final Object value = oldField != null ? ((JComboBox) oldField).getSelectedItem() : parameterInfo.getValue(); list.setSelectedItem(value); } else { final int value = oldField != null ? ((JComboBox) oldField).getSelectedIndex() : (Integer) parameterInfo.getValue(); list.setSelectedIndex(value); } field = list; } else if (parameterInfo instanceof SubmodelInfo) { final SubmodelInfo submodelInfo = (SubmodelInfo) parameterInfo; final Object[] elements = new Object[] { "Loading class information..." }; final JComboBox list = new JComboBox(elements); // field = list; final Object value = oldField != null ? ((JComboBox) ((JPanel) oldField).getComponent(0)).getSelectedItem() : new ClassElement(submodelInfo.getActualType(), null); new ClassCollector(this, list, submodelInfo, value, submodelSelectionWithoutNotify).execute(); final JButton rightButton = new JButton(); rightButton.setOpaque(false); rightButton.setRolloverEnabled(true); rightButton.setIcon(SHOW_SUBMODEL_ICON); rightButton.setRolloverIcon(SHOW_SUBMODEL_ICON_RO); rightButton.setDisabledIcon(SHOW_SUBMODEL_ICON_DIS); rightButton.setBorder(null); rightButton.setToolTipText("Display submodel parameters"); rightButton.setActionCommand(ACTIONCOMMAND_SHOW_SUBMODEL); rightButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (parameterInfo instanceof SubmodelInfo) { SubmodelInfo submodelInfo = (SubmodelInfo) parameterInfo; int level = 0; showHideSubparameters(list, submodelInfo); List<String> components = new ArrayList<String>(); components.add(submodelInfo.getName()); while (submodelInfo.getParent() != null) { submodelInfo = submodelInfo.getParent(); components.add(submodelInfo.getName()); level++; } Collections.reverse(components); final String[] breadcrumbText = components.toArray(new String[components.size()]); for (int i = 0; i < breadcrumbText.length; ++i) breadcrumbText[i] = breadcrumbText[i].replaceAll("([A-Z])", " $1"); breadcrumb.setPath( currentModelHandler.getModelClassSimpleName().replaceAll("([A-Z])", " $1"), breadcrumbText); Style.apply(breadcrumb, dashboard.getCssStyle()); // reset all buttons that are nested deeper than this to default color for (int i = submodelButtons.size() - 1; i >= level; i--) { JButton button = submodelButtons.get(i); button.setIcon(SHOW_SUBMODEL_ICON); submodelButtons.remove(i); } rightButton.setIcon(SHOW_SUBMODEL_ICON_RO); submodelButtons.add(rightButton); } } }); field = new JPanel(new BorderLayout()); field.add(list, BorderLayout.CENTER); field.add(rightButton, BorderLayout.EAST); } else if (File.class.isAssignableFrom(parameterInfo.getJavaType())) { field = new JPanel(new BorderLayout()); String oldName = ""; String oldPath = ""; if (oldField != null) { final JTextField oldTextField = (JTextField) oldField.getComponent(0); oldName = oldTextField.getText(); oldPath = oldTextField.getToolTipText(); } else if (parameterInfo.getValue() != null) { final File file = (File) parameterInfo.getValue(); oldName = file.getName(); oldPath = file.getAbsolutePath(); } final JTextField textField = new JTextField(oldName); textField.setToolTipText(oldPath); textField.setInputVerifier(new InputVerifier() { @Override public boolean verify(final JComponent input) { final JTextField inputField = (JTextField) input; if (inputField.getText() == null || inputField.getText().isEmpty()) { final File file = new File(""); inputField.setToolTipText(file.getAbsolutePath()); hideError(); return true; } final File oldFile = new File(inputField.getToolTipText()); if (oldFile.exists() && oldFile.getName().equals(inputField.getText().trim())) { hideError(); return true; } inputField.setToolTipText(""); final File file = new File(inputField.getText().trim()); if (file.exists()) { inputField.setToolTipText(file.getAbsolutePath()); inputField.setText(file.getName()); hideError(); return true; } else { final PopupFactory popupFactory = PopupFactory.getSharedInstance(); final Point locationOnScreen = inputField.getLocationOnScreen(); final JLabel message = new JLabel("Please specify an existing file!"); message.setBorder(new LineBorder(Color.RED, 2, true)); if (errorPopup != null) errorPopup.hide(); errorPopup = popupFactory.getPopup(inputField, message, locationOnScreen.x - 10, locationOnScreen.y - 30); errorPopup.show(); return false; } } }); final JButton browseButton = new JButton(BROWSE_BUTTON_TEXT); browseButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final JFileChooser fileDialog = new JFileChooser( !"".equals(textField.getToolTipText()) ? textField.getToolTipText() : currentDirectory); if (!"".equals(textField.getToolTipText())) fileDialog.setSelectedFile(new File(textField.getToolTipText())); int dialogResult = fileDialog.showOpenDialog(dashboard); if (dialogResult == JFileChooser.APPROVE_OPTION) { final File selectedFile = fileDialog.getSelectedFile(); if (selectedFile != null) { currentDirectory = selectedFile.getAbsoluteFile().getParent(); textField.setText(selectedFile.getName()); textField.setToolTipText(selectedFile.getAbsolutePath()); } } } }); field.add(textField, BorderLayout.CENTER); field.add(browseButton, BorderLayout.EAST); } else if (parameterInfo instanceof MasonIntervalParameterInfo) { final MasonIntervalParameterInfo intervalInfo = (MasonIntervalParameterInfo) parameterInfo; field = new JPanel(new BorderLayout()); String oldValueStr = String.valueOf(parameterInfo.getValue()); if (oldField != null) { final JTextField oldTextField = (JTextField) oldField.getComponent(0); oldValueStr = oldTextField.getText(); } final JTextField textField = new JTextField(oldValueStr); PercentJSlider tempSlider = null; if (intervalInfo.isDoubleInterval()) tempSlider = new PercentJSlider(intervalInfo.getIntervalMin().doubleValue(), intervalInfo.getIntervalMax().doubleValue(), Double.parseDouble(oldValueStr)); else tempSlider = new PercentJSlider(intervalInfo.getIntervalMin().longValue(), intervalInfo.getIntervalMax().longValue(), Long.parseLong(oldValueStr)); final PercentJSlider slider = tempSlider; slider.setMajorTickSpacing(100); slider.setMinorTickSpacing(10); slider.setPaintTicks(true); slider.setPaintLabels(true); slider.addChangeListener(new ChangeListener() { public void stateChanged(final ChangeEvent _) { if (slider.hasFocus()) { final String value = intervalInfo.isDoubleInterval() ? String.valueOf(slider.getDoubleValue()) : String.valueOf(slider.getLongValue()); textField.setText(value); slider.setToolTipText(value); } } }); textField.setInputVerifier(new InputVerifier() { public boolean verify(JComponent input) { final JTextField inputField = (JTextField) input; try { hideError(); final String valueStr = inputField.getText().trim(); if (intervalInfo.isDoubleInterval()) { final double value = Double.parseDouble(valueStr); if (intervalInfo.isValidValue(valueStr)) { slider.setValue(value); return true; } else showError( "Please specify a value between " + intervalInfo.getIntervalMin() + " and " + intervalInfo.getIntervalMax() + ".", inputField); return false; } else { final long value = Long.parseLong(valueStr); if (intervalInfo.isValidValue(valueStr)) { slider.setValue(value); return true; } else { showError("Please specify an integer value between " + intervalInfo.getIntervalMin() + " and " + intervalInfo.getIntervalMax() + ".", inputField); return false; } } } catch (final NumberFormatException _) { final String message = "The specified value is not a" + (intervalInfo.isDoubleInterval() ? "" : "n integer") + " number."; showError(message, inputField); return false; } } }); textField.getDocument().addDocumentListener(new DocumentListener() { // private Popup errorPopup; public void removeUpdate(final DocumentEvent _) { textFieldChanged(); } public void insertUpdate(final DocumentEvent _) { textFieldChanged(); } public void changedUpdate(final DocumentEvent _) { textFieldChanged(); } private void textFieldChanged() { if (!textField.hasFocus()) { hideError(); return; } try { hideError(); final String valueStr = textField.getText().trim(); if (intervalInfo.isDoubleInterval()) { final double value = Double.parseDouble(valueStr); if (intervalInfo.isValidValue(valueStr)) slider.setValue(value); else showError("Please specify a value between " + intervalInfo.getIntervalMin() + " and " + intervalInfo.getIntervalMax() + ".", textField); } else { final long value = Long.parseLong(valueStr); if (intervalInfo.isValidValue(valueStr)) slider.setValue(value); else showError("Please specify an integer value between " + intervalInfo.getIntervalMin() + " and " + intervalInfo.getIntervalMax() + ".", textField); } } catch (final NumberFormatException _) { final String message = "The specified value is not a" + (intervalInfo.isDoubleInterval() ? "" : "n integer") + " number."; showError(message, textField); } } }); field.add(textField, BorderLayout.CENTER); field.add(slider, BorderLayout.SOUTH); } else { final Object value = oldField != null ? ((JTextField) oldField).getText() : parameterInfo.getValue(); field = new JTextField(value.toString()); ((JTextField) field).addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { wizard.clickDefaultButton(); } }); } final JLabel parameterLabel = new JLabel(record.fieldName); final String description = parameterInfo.getDescription(); if (description != null && !description.isEmpty()) { parameterLabel.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(final MouseEvent e) { final DescriptionPopupFactory popupFactory = DescriptionPopupFactory.getInstance(); final Popup parameterDescriptionPopup = popupFactory.getPopup(parameterLabel, description, dashboard.getCssStyle()); parameterDescriptionPopup.show(); } }); } if (oldNode != null) userData.setSecond(field); else { final Pair<ParameterInfo, JComponent> pair = new Pair<ParameterInfo, JComponent>(parameterInfo, field); final DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(pair); parentNode.add(newNode); } if (field instanceof JCheckBox) { parameterLabel .setText("<html><div style=\"margin-bottom: 4pt; margin-top: 6pt; margin-left: 4pt\">" + parameterLabel.getText() + "</div></html>"); formBuilder.append(parameterLabel, field); // appendCheckBoxFieldToPresentation( // formBuilder, parameterLabel.getText(), (JCheckBox) field); } else { formBuilder.append(parameterLabel, field); final CellConstraints constraints = formBuilder.getLayout().getConstraints(parameterLabel); constraints.vAlign = CellConstraints.TOP; constraints.insets = new Insets(5, 0, 0, 0); formBuilder.getLayout().setConstraints(parameterLabel, constraints); } // prepare the parameterInfo for the param sweeps parameterInfo.setRuns(0); parameterInfo.setDefinitionType(ParameterInfo.CONST_DEF); parameterInfo.setValue(batchParameterInfo.getDefaultValue()); info.add(parameterInfo); } } appendVerticalSpaceToPresentation(formBuilder); final JPanel panel = formBuilder.getPanel(); singleRunParametersPanel.add(panel); if (singleRunParametersPanel.getComponentCount() > 1) { panel.setBorder( BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0, 1, 0, 0, Color.GRAY), BorderFactory.createEmptyBorder(0, 5, 0, 5))); } else { panel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); } Style.apply(panel, dashboard.getCssStyle()); return info; }
From source file:ome.formats.importer.gui.GuiCommonElements.java
/** * Add a new Text Field/*from ww w . j a va2 s . c om*/ * * @param container - parent container * @param name - name of text field * @param initialValue - initial value of text field * @param mnemonic - mnemonic key * @param tooltip - tool tip for field * @param suffix - suffix text for field * @param labelWidth - label width * @param placement - TableLayout placement * @param debug - turn on/off red debug borders * @return JTextField */ public static JTextField addTextField(Container container, String name, String initialValue, int mnemonic, String tooltip, String suffix, double labelWidth, String placement, boolean debug) { double[][] size = null; JPanel panel = new JPanel(); panel.setOpaque(false); if (suffix.equals("")) size = new double[][] { { labelWidth, TableLayout.FILL }, { 30 } }; else size = new double[][] { { labelWidth, TableLayout.FILL, TableLayout.PREFERRED }, { 30 } }; TableLayout layout = new TableLayout(size); panel.setLayout(layout); JLabel label = new JLabel(name); label.setDisplayedMnemonic(mnemonic); JTextField result = new JTextField(20); label.setLabelFor(result); label.setOpaque(false); result.setToolTipText(tooltip); if (initialValue != null) result.setText(initialValue); panel.add(label, "0, 0, r, c"); panel.add(result, "1, 0, f, c"); if (suffix.length() != 0) { JLabel suffixLabel = new JLabel(" " + suffix); panel.add(suffixLabel, "2,0, l, c"); } if (debug == true) panel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red), panel.getBorder())); container.add(panel, placement); return result; }
From source file:op.controlling.PnlControlling.java
private JPanel createContentPanel4Pain() { JPanel pnlContent = new JPanel(new VerticalLayout()); JPanel pnlPainDossier = new JPanel(new BorderLayout()); final JButton btnBVActivities = GUITools.createHyperlinkButton("opde.controlling.orga.paindossier", null, null);/* w w w . j a v a 2 s.c om*/ int monthsBack; try { monthsBack = Integer.parseInt(OPDE.getProps().getProperty("opde.controlling::paindossiermonthsback")); } catch (NumberFormatException nfe) { monthsBack = 1; } final JTextField txtPainMonthsBack = GUITools.createIntegerTextField(1, 52, monthsBack); txtPainMonthsBack.setToolTipText(SYSTools.xx("misc.msg.monthsback")); btnBVActivities.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OPDE.getMainframe().setBlocked(true); SwingWorker worker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { SYSPropsTools.storeProp("opde.controlling::paindossiermonthsback", txtPainMonthsBack.getText(), OPDE.getLogin().getUser()); SYSFilesTools.print(ControllingTools.getPainDossierAsHTML( new LocalDate().minusMonths(Integer.parseInt(txtPainMonthsBack.getText())), new LocalDate(), progressClosure), false); return null; } @Override protected void done() { OPDE.getDisplayManager().setProgressBarMessage(null); OPDE.getMainframe().setBlocked(false); } }; worker.execute(); } }); pnlPainDossier.add(btnBVActivities, BorderLayout.WEST); pnlPainDossier.add(txtPainMonthsBack, BorderLayout.EAST); pnlContent.add(pnlPainDossier); return pnlContent; }
From source file:op.controlling.PnlControlling.java
private JPanel createContentPanel4Fall() { JPanel pnlContent = new JPanel(new VerticalLayout()); /***//from www.ja v a2 s .c o m * _____ _ _ _ * | ___|_ _| | |___ / \ _ __ ___ _ __ _ _ _ __ ___ ___ _ _ ___ * | |_ / _` | | / __| / _ \ | '_ \ / _ \| '_ \| | | | '_ ` _ \ / _ \| | | / __| * | _| (_| | | \__ \ / ___ \| | | | (_) | | | | |_| | | | | | | (_) | |_| \__ \ * |_| \__,_|_|_|___/ /_/ \_\_| |_|\___/|_| |_|\__, |_| |_| |_|\___/ \__,_|___/ * |___/ */ JPanel pnlFallsAnon = new JPanel(new BorderLayout()); final JButton btnFallsAnon = GUITools.createHyperlinkButton("opde.controlling.nursing.falls.anonymous", null, null); int fallsMonthsBack; try { fallsMonthsBack = Integer.parseInt(OPDE.getProps().getProperty("opde.controlling::fallsMonthsBack")); } catch (NumberFormatException nfe) { fallsMonthsBack = 7; } final JTextField txtFallsMonthsBack = GUITools.createIntegerTextField(1, 120, fallsMonthsBack); txtFallsMonthsBack.setToolTipText(SYSTools.xx("misc.msg.monthsback")); btnFallsAnon.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OPDE.getMainframe().setBlocked(true); SwingWorker worker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { SYSPropsTools.storeProp("opde.controlling::fallsMonthsBack", txtFallsMonthsBack.getText(), OPDE.getLogin().getUser()); SYSFilesTools.print(ResInfoTools.getFallsAnonymous( Integer.parseInt(txtFallsMonthsBack.getText()), progressClosure), false); return null; } @Override protected void done() { OPDE.getDisplayManager().setProgressBarMessage(null); OPDE.getMainframe().setBlocked(false); } }; worker.execute(); } }); pnlFallsAnon.add(btnFallsAnon, BorderLayout.WEST); pnlFallsAnon.add(txtFallsMonthsBack, BorderLayout.EAST); pnlContent.add(pnlFallsAnon); /*** * _____ _ _ _ ____ _ _ _ * | ___|_ _| | |___ | |__ _ _| _ \ ___ ___(_) __| | ___ _ __ | |_ * | |_ / _` | | / __| | '_ \| | | | |_) / _ \/ __| |/ _` |/ _ \ '_ \| __| * | _| (_| | | \__ \ | |_) | |_| | _ < __/\__ \ | (_| | __/ | | | |_ * |_| \__,_|_|_|___/ |_.__/ \__, |_| \_\___||___/_|\__,_|\___|_| |_|\__| * |___/ */ JPanel pnlFallsRes = new JPanel(new BorderLayout()); final JButton btnFallsRes = GUITools.createHyperlinkButton("opde.controlling.nursing.falls.byResident", null, null); int fallsResMonthsBack; try { fallsResMonthsBack = Integer .parseInt(OPDE.getProps().getProperty("opde.controlling::fallsResMonthsBack")); } catch (NumberFormatException nfe) { fallsResMonthsBack = 7; } final JTextField txtResFallsMonthsBack = GUITools.createIntegerTextField(1, 120, fallsResMonthsBack); txtResFallsMonthsBack.setToolTipText(SYSTools.xx("misc.msg.monthsback")); btnFallsRes.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OPDE.getMainframe().setBlocked(true); SwingWorker worker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { SYSPropsTools.storeProp("opde.controlling::fallsResMonthsBack", txtResFallsMonthsBack.getText(), OPDE.getLogin().getUser()); SYSFilesTools.print(ResInfoTools.getFallsByResidents( Integer.parseInt(txtResFallsMonthsBack.getText()), progressClosure), false); return null; } @Override protected void done() { OPDE.getDisplayManager().setProgressBarMessage(null); OPDE.getMainframe().setBlocked(false); } }; worker.execute(); } }); pnlFallsRes.add(btnFallsRes, BorderLayout.WEST); pnlFallsRes.add(txtResFallsMonthsBack, BorderLayout.EAST); pnlContent.add(pnlFallsRes); /*** * _____ _ _ ___ _ _ _ * | ___|_ _| | |___|_ _|_ __ __| (_) ___ __ _| |_ ___ _ __ * | |_ / _` | | / __|| || '_ \ / _` | |/ __/ _` | __/ _ \| '__| * | _| (_| | | \__ \| || | | | (_| | | (_| (_| | || (_) | | * |_| \__,_|_|_|___/___|_| |_|\__,_|_|\___\__,_|\__\___/|_| * */ JPanel pnlFallsIndicator = new JPanel(new BorderLayout()); final JButton btnFallsIndicator = GUITools .createHyperlinkButton("opde.controlling.nursing.fallsindicators.byMonth", null, null); int fallsIndicatorBack; try { fallsIndicatorBack = Integer .parseInt(OPDE.getProps().getProperty("opde.controlling::fallsIndicatorMonthsBack")); } catch (NumberFormatException nfe) { fallsIndicatorBack = 7; } final JTextField txtFallsIndicatorsMonthsBack = GUITools.createIntegerTextField(1, 120, fallsIndicatorBack); txtFallsIndicatorsMonthsBack.setToolTipText(SYSTools.xx("misc.msg.monthsback")); btnFallsIndicator.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OPDE.getMainframe().setBlocked(true); SwingWorker worker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { SYSPropsTools.storeProp("opde.controlling::fallsIndicatorMonthsBack", txtFallsIndicatorsMonthsBack.getText(), OPDE.getLogin().getUser()); return ResInfoTools.getFallsIndicatorsByMonth( Integer.parseInt(txtFallsIndicatorsMonthsBack.getText()), progressClosure); } @Override protected void done() { try { SYSFilesTools.print(get().toString(), true); } catch (ExecutionException ee) { OPDE.fatal(ee); } catch (InterruptedException ie) { // nop } OPDE.getDisplayManager().setProgressBarMessage(null); OPDE.getMainframe().setBlocked(false); } }; worker.execute(); } }); pnlFallsIndicator.add(btnFallsIndicator, BorderLayout.WEST); pnlFallsIndicator.add(txtFallsIndicatorsMonthsBack, BorderLayout.EAST); pnlContent.add(pnlFallsIndicator); return pnlContent; }
From source file:op.controlling.PnlControlling.java
private JPanel createContentPanel4Orga() { JPanel pnlContent = new JPanel(new VerticalLayout()); /***//from w w w. j a va 2 s . c o m * ______ ___ _ _ _ _ _ * | __ ) \ / / \ ___| |_(_)_ _(_) |_(_) ___ ___ * | _ \\ \ / / _ \ / __| __| \ \ / / | __| |/ _ \/ __| * | |_) |\ V / ___ \ (__| |_| |\ V /| | |_| | __/\__ \ * |____/ \_/_/ \_\___|\__|_| \_/ |_|\__|_|\___||___/ * */ JPanel pnlBV = new JPanel(new BorderLayout()); final JButton btnBVActivities = GUITools.createHyperlinkButton("opde.controlling.orga.bvactivities", null, null); int bvWeeksBack; try { bvWeeksBack = Integer.parseInt(OPDE.getProps().getProperty("opde.controlling::bvactivitiesWeeksBack")); } catch (NumberFormatException nfe) { bvWeeksBack = 7; } final JTextField txtBVWeeksBack = GUITools.createIntegerTextField(1, 52, bvWeeksBack); txtBVWeeksBack.setToolTipText(SYSTools.xx("misc.msg.weeksback")); btnBVActivities.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OPDE.getMainframe().setBlocked(true); SwingWorker worker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { SYSPropsTools.storeProp("opde.controlling::bvactivitiesWeeksBack", txtBVWeeksBack.getText(), OPDE.getLogin().getUser()); SYSFilesTools.print(NReportTools.getBVActivites( new LocalDate().minusWeeks(Integer.parseInt(txtBVWeeksBack.getText())), progressClosure), false); return null; } @Override protected void done() { OPDE.getDisplayManager().setProgressBarMessage(null); OPDE.getMainframe().setBlocked(false); } }; worker.execute(); } }); pnlBV.add(btnBVActivities, BorderLayout.WEST); pnlBV.add(txtBVWeeksBack, BorderLayout.EAST); pnlContent.add(pnlBV); /*** * _ _ _ * ___ ___ _ __ ___ _ __ | | __ _(_)_ __ | |_ ___ * / __/ _ \| '_ ` _ \| '_ \| |/ _` | | '_ \| __/ __| * | (_| (_) | | | | | | |_) | | (_| | | | | | |_\__ \ * \___\___/|_| |_| |_| .__/|_|\__,_|_|_| |_|\__|___/ * |_| */ JPanel pnlComplaints = new JPanel(new BorderLayout()); final JButton btnComplaints = GUITools.createHyperlinkButton("opde.controlling.orga.complaints", null, null); int complaintsMonthBack; try { complaintsMonthBack = Integer .parseInt(OPDE.getProps().getProperty("opde.controlling::complaintsMonthBack")); } catch (NumberFormatException nfe) { complaintsMonthBack = 7; } final JTextField txtComplaintsMonthsBack = GUITools.createIntegerTextField(1, 12, complaintsMonthBack); txtComplaintsMonthsBack.setToolTipText(SYSTools.xx("misc.msg.monthsback")); btnComplaints.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OPDE.getMainframe().setBlocked(true); SwingWorker worker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { SYSPropsTools.storeProp("opde.controlling::complaintsMonthBack", txtComplaintsMonthsBack.getText(), OPDE.getLogin().getUser()); int monthsback = Integer.parseInt(txtComplaintsMonthsBack.getText()); String content = QProcessTools.getComplaintsAnalysis(monthsback, progressClosure); content += NReportTools.getComplaints( new LocalDate().minusMonths(monthsback).dayOfMonth().withMinimumValue(), progressClosure); SYSFilesTools.print(content, false); return null; } @Override protected void done() { OPDE.getDisplayManager().setProgressBarMessage(null); OPDE.getMainframe().setBlocked(false); } }; worker.execute(); } }); pnlComplaints.add(btnComplaints, BorderLayout.WEST); pnlComplaints.add(txtComplaintsMonthsBack, BorderLayout.EAST); pnlContent.add(pnlComplaints); // ResInfoTypeTools.TYPE_NURSING_INSURANCE JPanel pnlInsuranceGrade = new JPanel(new BorderLayout()); final JButton btnIG = GUITools.createHyperlinkButton("misc.msg.InsuranceGrades", null, null); btnIG.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OPDE.getMainframe().setBlocked(true); SwingWorker worker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { String content = SYSConst.html_h1("misc.msg.InsuranceGrades"); String ul = ""; for (Resident resident : ResidentTools.getAllActive()) { if (resident.getAdminonly() == ResidentTools.NORMAL) { ul += SYSConst.html_li(SYSConst.html_bold(ResidentTools.getLabelText(resident))); ResInfo insurance = ResInfoTools.getLastResinfo(resident, ResInfoTypeTools.TYPE_NURSING_INSURANCE); String ins = ""; if (insurance == null) { ins = SYSTools.xx("misc.msg.noentryyet"); } else { Properties props = load(insurance.getProperties()); String grade = SYSTools.xx("ninsurance.grade." + props.getProperty("grade")); ins = grade + (props.getProperty("grade").equals("assigned") ? ": " + props.getProperty("result") : ""); } ul += SYSConst.html_ul(SYSConst.html_li(ins)); } } content += SYSConst.html_ul(ul); SYSFilesTools.print(content, false); return null; } @Override protected void done() { OPDE.getDisplayManager().setProgressBarMessage(null); OPDE.getMainframe().setBlocked(false); } }; worker.execute(); } }); pnlInsuranceGrade.add(btnIG, BorderLayout.WEST); pnlContent.add(pnlInsuranceGrade); return pnlContent; }
From source file:op.controlling.PnlControlling.java
private JPanel createContentPanel4Nursing() { JPanel pnlContent = new JPanel(new VerticalLayout()); /***/*from w ww . ja v a 2s . co m*/ * __ __ _ * \ \ / /__ _ _ _ __ __| |___ * \ \ /\ / / _ \| | | | '_ \ / _` / __| * \ V V / (_) | |_| | | | | (_| \__ \ * \_/\_/ \___/ \__,_|_| |_|\__,_|___/ * */ JPanel pnlWounds = new JPanel(new BorderLayout()); final JButton btnWounds = GUITools.createHyperlinkButton("opde.controlling.nursing.wounds", null, null); int woundsMonthsBack; try { woundsMonthsBack = Integer.parseInt(OPDE.getProps().getProperty("opde.controlling::woundsMonthsBack")); } catch (NumberFormatException nfe) { woundsMonthsBack = 7; } final JTextField txtWoundsMonthsBack = GUITools.createIntegerTextField(1, 12, woundsMonthsBack); txtWoundsMonthsBack.setToolTipText(SYSTools.xx("misc.msg.monthsback")); btnWounds.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OPDE.getMainframe().setBlocked(true); SwingWorker worker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { SYSPropsTools.storeProp("opde.controlling::woundsMonthsBack", txtWoundsMonthsBack.getText(), OPDE.getLogin().getUser()); SYSFilesTools.print( getWounds(Integer.parseInt(txtWoundsMonthsBack.getText()), progressClosure), false); return null; } @Override protected void done() { OPDE.getDisplayManager().setProgressBarMessage(null); OPDE.getMainframe().setBlocked(false); } }; worker.execute(); } }); pnlWounds.add(btnWounds, BorderLayout.WEST); pnlWounds.add(txtWoundsMonthsBack, BorderLayout.EAST); pnlContent.add(pnlWounds); /*** * ____ _ _ _____ _ * / ___| ___ ___(_) __ _| | |_ _(_)_ __ ___ ___ ___ * \___ \ / _ \ / __| |/ _` | | | | | | '_ ` _ \ / _ \/ __| * ___) | (_) | (__| | (_| | | | | | | | | | | | __/\__ \ * |____/ \___/ \___|_|\__,_|_| |_| |_|_| |_| |_|\___||___/ * */ JPanel pblSocialTimes = new JPanel(new BorderLayout()); final JButton btnSocialTimes = GUITools.createHyperlinkButton("opde.controlling.nursing.social", null, null); final JComboBox cmbSocialTimes = new JComboBox( SYSCalendar.createMonthList(new LocalDate().minusYears(1), new LocalDate())); btnSocialTimes.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OPDE.getMainframe().setBlocked(true); SwingWorker worker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { LocalDate month = (LocalDate) cmbSocialTimes.getSelectedItem(); SYSFilesTools.print(NReportTools.getTimes4SocialReports(month, progressClosure), false); return null; } @Override protected void done() { OPDE.getDisplayManager().setProgressBarMessage(null); OPDE.getMainframe().setBlocked(false); } }; worker.execute(); } }); cmbSocialTimes.setRenderer(new ListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { return new DefaultListCellRenderer().getListCellRendererComponent(list, monthFormatter.format(((LocalDate) value).toDate()), index, isSelected, cellHasFocus); } }); cmbSocialTimes.setSelectedIndex(cmbSocialTimes.getItemCount() - 2); pblSocialTimes.add(btnSocialTimes, BorderLayout.WEST); pblSocialTimes.add(cmbSocialTimes, BorderLayout.EAST); pnlContent.add(pblSocialTimes); return pnlContent; }