List of usage examples for javax.swing JButton setEnabled
public void setEnabled(boolean b)
From source file:com.ibm.issw.odc.gui.BPMArgumentsPanel.java
/** * Create a panel containing the add and delete buttons. * * @return a GUI panel containing the buttons *///from w w w .j a va 2 s . c om private JPanel makeButtonPanel() { JButton showDetail = new JButton(JMeterUtils.getResString("detail")); // $NON-NLS-1$ showDetail.setActionCommand(DETAIL); showDetail.setEnabled(true); add = new JButton(JMeterUtils.getResString("add")); // $NON-NLS-1$ add.setActionCommand(ADD); add.setEnabled(true); /** A button for adding new arguments to the table from the clipboard. */ JButton addFromClipboard = new JButton(JMeterUtils.getResString("add_from_clipboard")); // $NON-NLS-1$ addFromClipboard.setActionCommand(ADD_FROM_CLIPBOARD); addFromClipboard.setEnabled(true); delete = new JButton(JMeterUtils.getResString("delete")); // $NON-NLS-1$ delete.setActionCommand(DELETE); if (enableUpDown) { up = new JButton(JMeterUtils.getResString("up")); // $NON-NLS-1$ up.setActionCommand(UP); down = new JButton(JMeterUtils.getResString("down")); // $NON-NLS-1$ down.setActionCommand(DOWN); } checkDeleteStatus(); JPanel buttonPanel = new JPanel(); buttonPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10)); if (this.background != null) { buttonPanel.setBackground(this.background); } showDetail.addActionListener(this); add.addActionListener(this); addFromClipboard.addActionListener(this); delete.addActionListener(this); buttonPanel.add(showDetail); buttonPanel.add(add); buttonPanel.add(addFromClipboard); buttonPanel.add(delete); if (enableUpDown) { up.addActionListener(this); down.addActionListener(this); buttonPanel.add(up); buttonPanel.add(down); } return buttonPanel; }
From source file:ConfigFiles.java
public JPanel addPanel(String title, String description, final JTextField textfield, String fieldtext, int Y, boolean withbutton, ActionListener actionlistener) { JPanel p1 = new JPanel(); p1.setBackground(Color.WHITE); TitledBorder border = BorderFactory.createTitledBorder(title); border.setTitleFont(new Font("Arial", Font.PLAIN, 14)); border.setBorder(BorderFactory.createLineBorder(new Color(150, 150, 150), 1)); p1.setBorder(border);// www. j a va 2s.c o m p1.setLayout(new BoxLayout(p1, BoxLayout.Y_AXIS)); p1.setBounds(80, Y, 800, 75); paths.add(p1); JTextArea tcpath = new JTextArea(description); tcpath.setWrapStyleWord(true); tcpath.setLineWrap(true); tcpath.setEditable(false); tcpath.setCursor(null); tcpath.setOpaque(false); tcpath.setFocusable(false); tcpath.setFont(new Font("Arial", Font.PLAIN, 12)); tcpath.setBackground(getBackground()); tcpath.setMaximumSize(new Dimension(170, 22)); tcpath.setPreferredSize(new Dimension(170, 22)); tcpath.setBorder(null); JPanel p11 = new JPanel(); p11.setBackground(Color.WHITE); p11.setLayout(new GridLayout()); p11.add(tcpath); p11.setMaximumSize(new Dimension(700, 18)); p11.setPreferredSize(new Dimension(700, 18)); textfield.setMaximumSize(new Dimension(340, 27)); textfield.setPreferredSize(new Dimension(340, 27)); textfield.setText(fieldtext); JButton b = null; if (withbutton) { b = new JButton("..."); if (!PermissionValidator.canChangeFWM()) { b.setEnabled(false); } b.setMaximumSize(new Dimension(50, 20)); b.setPreferredSize(new Dimension(50, 20)); if (actionlistener == null) { b.addActionListener(new AbstractAction() { public void actionPerformed(ActionEvent ev) { Container c; if (RunnerRepository.container != null) c = RunnerRepository.container.getParent(); else c = RunnerRepository.window; try { new MySftpBrowser(RunnerRepository.host, RunnerRepository.user, RunnerRepository.password, textfield, c, false); } catch (Exception e) { System.out.println("There was a problem in opening sftp browser!"); e.printStackTrace(); } } }); } else { b.addActionListener(actionlistener); b.setText("Save"); b.setMaximumSize(new Dimension(70, 20)); b.setPreferredSize(new Dimension(70, 20)); } } JPanel p12 = new JPanel(); p12.setBackground(Color.WHITE); p12.add(textfield); if (withbutton) p12.add(b); p12.setMaximumSize(new Dimension(700, 32)); p12.setPreferredSize(new Dimension(700, 32)); p1.add(p11); p1.add(p12); return p12; }
From source file:es.emergya.ui.gis.popups.SaveGPXDialog.java
private SaveGPXDialog(final List<Layer> capas) { super("Consulta de Posiciones GPS"); setResizable(false);/* w ww . j av a 2s . c om*/ setAlwaysOnTop(true); try { setIconImage(((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getFrame() .getIconImage()); } catch (Throwable e) { LOG.error("There is no icon image", e); } this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); JPanel dialogo = new JPanel(new BorderLayout()); dialogo.setBackground(Color.WHITE); dialogo.setBorder(new EmptyBorder(10, 10, 10, 10)); JPanel central = new JPanel(new FlowLayout()); central.setOpaque(false); final JTextField nombre = new JTextField(15); nombre.setEditable(false); central.add(nombre); final JButton button = new JButton("Examinar...", LogicConstants.getIcon("button_nuevo")); central.add(button); final JButton aceptar = new JButton("Guardar", LogicConstants.getIcon("button_save")); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JFileChooser fileChooser = new JFileChooser(); if (fileChooser.showSaveDialog(SaveGPXDialog.this) == JFileChooser.APPROVE_OPTION) { nombre.setText(fileChooser.getSelectedFile().getAbsolutePath()); aceptar.setEnabled(true); } } }); dialogo.add(central, BorderLayout.CENTER); JPanel botones = new JPanel(new FlowLayout()); botones.setOpaque(false); aceptar.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String base_url = nombre.getText() + "_"; for (Layer layer : capas) { if (layer instanceof GpxLayer) { GpxLayer gpxLayer = (GpxLayer) layer; File f = new File(base_url + gpxLayer.name + ".gpx"); boolean sobreescribir = !f.exists(); try { while (!sobreescribir) { String original = f.getCanonicalPath(); f = checkFileOverwritten(nombre, f); sobreescribir = !f.exists() || original.equals(f.getCanonicalPath()); } } catch (NullPointerException t) { log.debug("Cancelando creacion de fichero: " + t); sobreescribir = false; } catch (Throwable t) { log.error("Error comprobando la sobreescritura", t); sobreescribir = false; } if (sobreescribir) { try { f.createNewFile(); } catch (IOException e1) { log.error(e1, e1); } if (!(f.isFile() && f.canWrite())) JOptionPane.showMessageDialog(SaveGPXDialog.this, "No tengo permiso para escribir en " + f.getAbsolutePath()); else { try { OutputStream out = new FileOutputStream(f); GpxWriter writer = new GpxWriter(out); writer.write(gpxLayer.data); out.close(); } catch (Throwable t) { log.error("Error al escribir el gpx", t); JOptionPane.showMessageDialog(SaveGPXDialog.this, "Ocurri un error al escribir en " + f.getAbsolutePath()); } } } else log.error("Por errores anteriores no se escribio el fichero"); } else log.error("Una de las capas no era gpx: " + layer.name); } SaveGPXDialog.this.dispose(); } private File checkFileOverwritten(final JTextField nombre, File f) throws Exception { String nueva = JOptionPane.showInputDialog(nombre, i18n.getString("savegpxdialog.overwrite"), "Sobreescribir archivo", JOptionPane.QUESTION_MESSAGE, null, null, f.getCanonicalPath()) .toString(); log.debug("Nueva ruta: " + nueva); return new File(nueva); } }); JButton cancelar = new JButton("Cancelar", LogicConstants.getIcon("button_cancel")); cancelar.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SaveGPXDialog.this.dispose(); } }); aceptar.setEnabled(false); botones.add(aceptar); botones.add(cancelar); dialogo.add(botones, BorderLayout.SOUTH); add(dialogo); setPreferredSize(new Dimension(300, 200)); pack(); int x; int y; Container myParent; try { myParent = ((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getFrame() .getContentPane(); java.awt.Point topLeft = myParent.getLocationOnScreen(); Dimension parentSize = myParent.getSize(); Dimension mySize = getSize(); if (parentSize.width > mySize.width) x = ((parentSize.width - mySize.width) / 2) + topLeft.x; else x = topLeft.x; if (parentSize.height > mySize.height) y = ((parentSize.height - mySize.height) / 2) + topLeft.y; else y = topLeft.y; setLocation(x, y); } catch (Throwable e1) { LOG.error("There is no basic window!", e1); } this.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { nombre.setText(""); nombre.repaint(); } @Override public void windowClosing(WindowEvent e) { nombre.setText(""); nombre.repaint(); } }); }
From source file:org.streamspinner.harmonica.application.CQGraphTerminal.java
public void actionPerformed(ActionEvent e) { JButton jb = ((JButton) e.getSource()); if (jb.getText().equals("o^")) { try {/*from w w w .j a va 2 s . c o m*/ StreamSpinnerConnection = new DefaultCQRowSet(); StreamSpinnerConnection.setUrl("//" + url + "/StreamSpinnerServer"); StreamSpinnerConnection.setCommand(getJTextArea().getText()); StreamSpinnerConnection.addCQRowSetListener(this); StreamSpinnerConnection.start(); jb.setEnabled(false); getJButton1().setEnabled(false); } catch (CQException ce) { ce.printStackTrace(); } } else if (jb.getText().equals("Q?")) { show_open_hamql_dialog(); } }
From source file:net.sf.taverna.t2.workbench.views.results.processor.RenderedProcessorResultComponent.java
/** * Update the component based on the node selected from the * ResultViewComponent tree.// w ww . j av a 2s .com */ public void updateResult() { if (recognisedRenderersForMimeType == null) recognisedRenderersForMimeType = new ArrayList<>(); if (otherRenderers == null) otherRenderers = new ArrayList<>(); ProcessorResultTreeNode result = (ProcessorResultTreeNode) node; // Reference to the result data path = result.getReference(); // Enable the combo box renderersComboBox.setEnabled(true); /* * Update the 'save result' buttons appropriately as the result node had * changed */ for (int i = 0; i < saveButtonsPanel.getComponents().length; i++) { JButton saveButton = (JButton) saveButtonsPanel.getComponent(i); SaveIndividualResultSPI action = (SaveIndividualResultSPI) (saveButton.getAction()); // Update the action with the new result reference action.setResultReference(path); saveButton.setEnabled(true); } if (DataBundles.isValue(path) || DataBundles.isReference(path)) { // Enable refresh button refreshButton.setEnabled(true); List<MimeType> mimeTypes = new ArrayList<>(); try (InputStream inputstream = RendererUtils.getInputStream(path)) { mimeTypes.addAll(getMimeTypes(inputstream)); } catch (IOException e) { logger.warn("Error getting mimetype", e); } if (mimeTypes.isEmpty()) { // If MIME types is empty - add "plain/text" MIME type mimeTypes.add(new MimeType("text/plain")); } else if (mimeTypes.size() == 1 && mimeTypes.get(0).toString().equals("chemical/x-fasta")) { /* * If MIME type is recognised as "chemical/x-fasta" only then * this might be an error from MIME magic (i.e., sometimes it * recognises stuff that is not "chemical/x-fasta" as * "chemical/x-fasta" and then Seq Vista renderer is used that * causes errors) - make sure we also add the renderers for * "text/plain" and "text/xml" as it is most probably just * normal xml text and push the "chemical/x-fasta" to the bottom * of the list. */ mimeTypes.add(0, new MimeType("text/plain")); mimeTypes.add(1, new MimeType("text/xml")); } for (MimeType mimeType : mimeTypes) for (Renderer renderer : rendererRegistry.getRenderersForMimeType(mimeType.toString())) if (!recognisedRenderersForMimeType.contains(renderer)) recognisedRenderersForMimeType.add(renderer); // if there are no renderers then force text/plain if (recognisedRenderersForMimeType.isEmpty()) recognisedRenderersForMimeType = rendererRegistry.getRenderersForMimeType("text/plain"); /* * Add all other available renderers that are not recognised to be * able to handle the MIME type of the result */ otherRenderers = rendererRegistry.getRenderers(); otherRenderers.removeAll(recognisedRenderersForMimeType); mimeList = new String[recognisedRenderersForMimeType.size() + otherRenderers.size()]; rendererList = new ArrayList<>(); /* * First add the ones that can handle the MIME type of the result * item */ for (int i = 0; i < recognisedRenderersForMimeType.size(); i++) { mimeList[i] = recognisedRenderersForMimeType.get(i).getType(); rendererList.add(recognisedRenderersForMimeType.get(i)); } // Then add the other renderers just in case for (int i = 0; i < otherRenderers.size(); i++) { mimeList[recognisedRenderersForMimeType.size() + i] = otherRenderers.get(i).getType(); rendererList.add(otherRenderers.get(i)); } renderersComboBox.setModel(new DefaultComboBoxModel<>(mimeList)); if (mimeList.length > 0) { int index = 0; // Find the index of the current MIME type for this output port. for (int i = 0; i < mimeList.length; i++) if (mimeList[i].equals(lastUsedMIMEtype)) { index = i; break; } int previousindex = renderersComboBox.getSelectedIndex(); renderersComboBox.setSelectedIndex(index); /* * force rendering as setSelectedIndex will not fire an * itemstatechanged event if previousindex == index and we still * need render the result as we may have switched from a * different result item in a result list but the renderer index * stayed the same */ if (previousindex == index) renderResult(); // draw the rendered result component } } else if (DataBundles.isError(path)) { // Disable refresh button refreshButton.setEnabled(false); @SuppressWarnings("unused") ErrorDocument errorDocument; try { errorDocument = DataBundles.getError(path); } catch (IOException e) { logger.warn("Error getting the error document", e); } // Reset the renderers as we have an error item recognisedRenderersForMimeType = null; otherRenderers = null; DefaultMutableTreeNode root = new DefaultMutableTreeNode("Error Trace"); // TODO handle error documents // ResultsUtils.buildErrorDocumentTree(root, errorDocument, referenceService); JTree errorTree = new JTree(root); errorTree.setCellRenderer(new DefaultTreeCellRenderer() { @Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { Component renderer = null; if (value instanceof DefaultMutableTreeNode) { Object userObject = ((DefaultMutableTreeNode) value).getUserObject(); if (userObject instanceof ErrorDocument) renderer = getErrorDocumentRenderer(tree, selected, expanded, leaf, row, hasFocus, (ErrorDocument) userObject); } if (renderer == null) renderer = super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); if (renderer instanceof JLabel) { JLabel label = (JLabel) renderer; label.setIcon(null); } return renderer; } private Component getErrorDocumentRenderer(JTree tree, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus, ErrorDocument errorDocument) { return super.getTreeCellRendererComponent(tree, "<html>" + escapeHtml(errorDocument.getMessage()) + "</html>", selected, expanded, leaf, row, hasFocus); } }); renderersComboBox.setModel(new DefaultComboBoxModel<>(new String[] { ERROR_DOCUMENT })); renderedResultPanel.removeAll(); renderedResultPanel.add(errorTree, CENTER); repaint(); } }
From source file:cool.pandora.modeller.ui.jpanel.base.SaveBagFrame.java
private JPanel createComponents() { final Border border = new EmptyBorder(5, 5, 5, 5); final TitlePane titlePane = new TitlePane(); initStandardCommands();//w w w.ja v a 2 s. c om final JPanel pageControl = new JPanel(new BorderLayout()); final JPanel titlePaneContainer = new JPanel(new BorderLayout()); titlePane.setTitle(bagView.getPropertyMessage("SaveBagFrame.title")); titlePane.setMessage(new DefaultMessage(bagView.getPropertyMessage("Define the Bag " + "settings"))); titlePaneContainer.add(titlePane.getControl()); titlePaneContainer.add(new JSeparator(), BorderLayout.SOUTH); pageControl.add(titlePaneContainer, BorderLayout.NORTH); final JPanel contentPane = new JPanel(); // TODO: Add bag name field // TODO: Add save name file selection button final JLabel location = new JLabel("Save in:"); final JButton browseButton = new JButton(getMessage("bag.button.browse")); browseButton.addActionListener(new SaveBagAsHandler()); browseButton.setEnabled(true); browseButton.setToolTipText(getMessage("bag.button.browse.help")); final DefaultBag bag = bagView.getBag(); if (bag != null) { bagNameField = new JTextField(bag.getName()); bagNameField.setCaretPosition(bag.getName().length()); bagNameField.setEditable(false); bagNameField.setEnabled(false); } // Holey bag control final JLabel holeyLabel = new JLabel(bagView.getPropertyMessage("bag.label.isholey")); holeyLabel.setToolTipText(bagView.getPropertyMessage("bag.isholey.help")); final JCheckBox holeyCheckbox = new JCheckBox(bagView.getPropertyMessage("bag.checkbox" + ".isholey")); holeyCheckbox.setBorder(border); holeyCheckbox.addActionListener(new HoleyBagHandler()); holeyCheckbox.setToolTipText(bagView.getPropertyMessage("bag.isholey.help")); urlLabel = new JLabel(bagView.getPropertyMessage("baseURL.label")); urlLabel.setToolTipText(bagView.getPropertyMessage("baseURL.description")); urlField = new JTextField(""); try { assert bag != null; urlField.setText(bag.getFetch().getBaseURL()); } catch (Exception e) { log.error("Failed to set url label", e); } urlField.setEnabled(false); // TODO: Add format label final JLabel serializeLabel; serializeLabel = new JLabel(getMessage("bag.label.ispackage")); serializeLabel.setToolTipText(getMessage("bag.serializetype.help")); // TODO: Add format selection panel noneButton = new JRadioButton(getMessage("bag.serializetype.none")); noneButton.setEnabled(true); final AbstractAction serializeListener = new SerializeBagHandler(); noneButton.addActionListener(serializeListener); noneButton.setToolTipText(getMessage("bag.serializetype.none.help")); zipButton = new JRadioButton(getMessage("bag.serializetype.zip")); zipButton.setEnabled(true); zipButton.addActionListener(serializeListener); zipButton.setToolTipText(getMessage("bag.serializetype.zip.help")); /* * tarButton = new JRadioButton(getMessage("bag.serializetype.tar")); * tarButton.setEnabled(true); * tarButton.addActionListener(serializeListener); * tarButton.setToolTipText(getMessage("bag.serializetype.tar.help")); * * tarGzButton = new JRadioButton(getMessage("bag.serializetype.targz")); * tarGzButton.setEnabled(true); * tarGzButton.addActionListener(serializeListener); * tarGzButton.setToolTipText(getMessage("bag.serializetype.targz.help")); * * tarBz2Button = new JRadioButton(getMessage("bag.serializetype.tarbz2")); * tarBz2Button.setEnabled(true); * tarBz2Button.addActionListener(serializeListener); * tarBz2Button.setToolTipText(getMessage("bag.serializetype.tarbz2.help")); */ short mode = 2; if (bag != null) { mode = bag.getSerialMode(); } if (mode == DefaultBag.NO_MODE) { this.noneButton.setEnabled(true); } else if (mode == DefaultBag.ZIP_MODE) { this.zipButton.setEnabled(true); } else { this.noneButton.setEnabled(true); } final ButtonGroup serializeGroup = new ButtonGroup(); serializeGroup.add(noneButton); serializeGroup.add(zipButton); // serializeGroup.add(tarButton); // serializeGroup.add(tarGzButton); // serializeGroup.add(tarBz2Button); final JPanel serializeGroupPanel = new JPanel(new FlowLayout()); serializeGroupPanel.add(serializeLabel); serializeGroupPanel.add(noneButton); serializeGroupPanel.add(zipButton); // serializeGroupPanel.add(tarButton); // serializeGroupPanel.add(tarGzButton); // serializeGroupPanel.add(tarBz2Button); serializeGroupPanel.setBorder(border); serializeGroupPanel.setEnabled(true); serializeGroupPanel.setToolTipText(bagView.getPropertyMessage("bag.serializetype.help")); final JLabel tagLabel = new JLabel(getMessage("bag.label.istag")); tagLabel.setToolTipText(getMessage("bag.label.istag.help")); final JCheckBox isTagCheckbox = new JCheckBox(); isTagCheckbox.setBorder(border); isTagCheckbox.addActionListener(new TagManifestHandler()); isTagCheckbox.setToolTipText(getMessage("bag.checkbox.istag.help")); final JLabel tagAlgorithmLabel = new JLabel(getMessage("bag.label.tagalgorithm")); tagAlgorithmLabel.setToolTipText(getMessage("bag.label.tagalgorithm.help")); final ArrayList<String> listModel = new ArrayList<>(); for (final Algorithm algorithm : Algorithm.values()) { listModel.add(algorithm.bagItAlgorithm); } final JComboBox<String> tagAlgorithmList = new JComboBox<>(listModel.toArray(new String[listModel.size()])); tagAlgorithmList.setName(getMessage("bag.tagalgorithmlist")); tagAlgorithmList.addActionListener(new TagAlgorithmListHandler()); tagAlgorithmList.setToolTipText(getMessage("bag.tagalgorithmlist.help")); final JLabel payloadLabel = new JLabel(getMessage("bag.label.ispayload")); payloadLabel.setToolTipText(getMessage("bag.ispayload.help")); final JCheckBox isPayloadCheckbox = new JCheckBox(); isPayloadCheckbox.setBorder(border); isPayloadCheckbox.addActionListener(new PayloadManifestHandler()); isPayloadCheckbox.setToolTipText(getMessage("bag.ispayload.help")); final JLabel payAlgorithmLabel = new JLabel(bagView.getPropertyMessage("bag.label" + ".payalgorithm")); payAlgorithmLabel.setToolTipText(getMessage("bag.payalgorithm.help")); final JComboBox<String> payAlgorithmList = new JComboBox<String>( listModel.toArray(new String[listModel.size()])); payAlgorithmList.setName(getMessage("bag.payalgorithmlist")); payAlgorithmList.addActionListener(new PayAlgorithmListHandler()); payAlgorithmList.setToolTipText(getMessage("bag.payalgorithmlist.help")); //only if bag is not null if (bag != null) { final String fileName = bag.getName(); bagNameField = new JTextField(fileName); bagNameField.setCaretPosition(fileName.length()); holeyCheckbox.setSelected(bag.isHoley()); urlLabel.setEnabled(bag.isHoley()); isTagCheckbox.setSelected(bag.isBuildTagManifest()); tagAlgorithmList.setSelectedItem(bag.getTagManifestAlgorithm()); isPayloadCheckbox.setSelected(bag.isBuildPayloadManifest()); payAlgorithmList.setSelectedItem(bag.getPayloadManifestAlgorithm()); } final GridBagLayout layout = new GridBagLayout(); final GridBagConstraints glbc = new GridBagConstraints(); final JPanel panel = new JPanel(layout); panel.setBorder(new EmptyBorder(10, 10, 10, 10)); int row = 0; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); layout.setConstraints(location, glbc); panel.add(location); buildConstraints(glbc, 2, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.EAST); glbc.ipadx = 5; layout.setConstraints(browseButton, glbc); glbc.ipadx = 0; panel.add(browseButton); buildConstraints(glbc, 1, row, 1, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); glbc.ipadx = 5; layout.setConstraints(bagNameField, glbc); glbc.ipadx = 0; panel.add(bagNameField); row++; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); layout.setConstraints(holeyLabel, glbc); panel.add(holeyLabel); buildConstraints(glbc, 1, row, 1, 1, 80, 50, GridBagConstraints.WEST, GridBagConstraints.WEST); layout.setConstraints(holeyCheckbox, glbc); panel.add(holeyCheckbox); row++; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); layout.setConstraints(urlLabel, glbc); panel.add(urlLabel); buildConstraints(glbc, 1, row, 1, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); layout.setConstraints(urlField, glbc); panel.add(urlField); row++; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); layout.setConstraints(serializeLabel, glbc); panel.add(serializeLabel); buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); layout.setConstraints(serializeGroupPanel, glbc); panel.add(serializeGroupPanel); row++; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); layout.setConstraints(tagLabel, glbc); panel.add(tagLabel); buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); layout.setConstraints(isTagCheckbox, glbc); panel.add(isTagCheckbox); row++; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); layout.setConstraints(tagAlgorithmLabel, glbc); panel.add(tagAlgorithmLabel); buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); layout.setConstraints(tagAlgorithmList, glbc); panel.add(tagAlgorithmList); row++; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); layout.setConstraints(payloadLabel, glbc); panel.add(payloadLabel); buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); layout.setConstraints(isPayloadCheckbox, glbc); panel.add(isPayloadCheckbox); row++; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); layout.setConstraints(payAlgorithmLabel, glbc); panel.add(payAlgorithmLabel); buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); layout.setConstraints(payAlgorithmList, glbc); panel.add(payAlgorithmList); row++; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); GuiStandardUtils.attachDialogBorder(contentPane); pageControl.add(panel); final JComponent buttonBar = createButtonBar(); pageControl.add(buttonBar, BorderLayout.SOUTH); this.pack(); return pageControl; }
From source file:net.sf.taverna.t2.workbench.views.results.workflow.RenderedResultComponent.java
/** * Update the component based on the node selected from the * ResultViewComponent tree.//from w ww .jav a 2 s. com */ public void updateResult() { if (recognisedRenderersForMimeType == null) recognisedRenderersForMimeType = new ArrayList<>(); if (otherRenderers == null) otherRenderers = new ArrayList<>(); // Enable the combo box renderersComboBox.setEnabled(true); /* * Update the 'save result' buttons appropriately as the result node had * changed */ for (int i = 0; i < saveButtonsPanel.getComponents().length; i++) { JButton saveButton = (JButton) saveButtonsPanel.getComponent(i); SaveIndividualResultSPI action = (SaveIndividualResultSPI) saveButton.getAction(); // Update the action with the new result reference action.setResultReference(path); saveButton.setEnabled(true); } if (DataBundles.isValue(path) || DataBundles.isReference(path)) { // Enable refresh button refreshButton.setEnabled(true); List<MimeType> mimeTypes = new ArrayList<>(); try (InputStream inputstream = getInputStream(path)) { mimeTypes.addAll(getMimeTypes(inputstream)); } catch (IOException e) { logger.warn("Error getting mimetype", e); } if (mimeTypes.isEmpty()) // If MIME types is empty - add "plain/text" MIME type mimeTypes.add(new MimeType("text/plain")); else if (mimeTypes.size() == 1 && mimeTypes.get(0).toString().equals("chemical/x-fasta")) { /* * If MIME type is recognised as "chemical/x-fasta" only then * this might be an error from MIME magic (i.e., sometimes it * recognises stuff that is not "chemical/x-fasta" as * "chemical/x-fasta" and then Seq Vista renderer is used that * causes errors) - make sure we also add the renderers for * "text/plain" and "text/xml" as it is most probably just * normal xml text and push the "chemical/x-fasta" to the bottom * of the list. */ mimeTypes.add(0, new MimeType("text/plain")); mimeTypes.add(1, new MimeType("text/xml")); } for (MimeType mimeType : mimeTypes) { List<Renderer> renderersList = rendererRegistry.getRenderersForMimeType(mimeType.toString()); for (Renderer renderer : renderersList) if (!recognisedRenderersForMimeType.contains(renderer)) recognisedRenderersForMimeType.add(renderer); } // if there are no renderers then force text/plain if (recognisedRenderersForMimeType.isEmpty()) recognisedRenderersForMimeType = rendererRegistry.getRenderersForMimeType("text/plain"); /* * Add all other available renderers that are not recognised to be * able to handle the MIME type of the result */ otherRenderers = new ArrayList<>(rendererRegistry.getRenderers()); otherRenderers.removeAll(recognisedRenderersForMimeType); mimeList = new String[recognisedRenderersForMimeType.size() + otherRenderers.size()]; rendererList = new ArrayList<>(); /* * First add the ones that can handle the MIME type of the result * item */ for (int i = 0; i < recognisedRenderersForMimeType.size(); i++) { mimeList[i] = recognisedRenderersForMimeType.get(i).getType(); rendererList.add(recognisedRenderersForMimeType.get(i)); } // Then add the other renderers just in case for (int i = 0; i < otherRenderers.size(); i++) { mimeList[recognisedRenderersForMimeType.size() + i] = otherRenderers.get(i).getType(); rendererList.add(otherRenderers.get(i)); } renderersComboBox.setModel(new DefaultComboBoxModel<String>(mimeList)); if (mimeList.length > 0) { int index = 0; // Find the index of the current MIME type for this output port. for (int i = 0; i < mimeList.length; i++) if (mimeList[i].equals(lastUsedMIMEtype)) { index = i; break; } int previousindex = renderersComboBox.getSelectedIndex(); renderersComboBox.setSelectedIndex(index); /* * force rendering as setSelectedIndex will not fire an * itemstatechanged event if previousindex == index and we still * need render the result as we may have switched from a * different result item in a result list but the renderer index * stayed the same */ if (previousindex == index) renderResult(); // draw the rendered result component } } else if (DataBundles.isError(path)) { // Disable refresh button refreshButton.setEnabled(false); // Hide wrap text check box - only works for actual data wrapTextCheckBox.setVisible(false); // Reset the renderers as we have an error item recognisedRenderersForMimeType = null; otherRenderers = null; DefaultMutableTreeNode root = new DefaultMutableTreeNode("Error Trace"); try { ErrorDocument errorDocument = DataBundles.getError(path); try { buildErrorDocumentTree(root, errorDocument); } catch (IOException e) { logger.warn("Error building error document tree", e); } } catch (IOException e) { logger.warn("Error getting the error document", e); } JTree errorTree = new JTree(root); errorTree.setCellRenderer(new DefaultTreeCellRenderer() { @Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { Component renderer = null; if (value instanceof DefaultMutableTreeNode) { DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) value; Object userObject = treeNode.getUserObject(); if (userObject instanceof ErrorDocument) renderer = renderErrorDocument(tree, selected, expanded, leaf, row, hasFocus, (ErrorDocument) userObject); } if (renderer == null) renderer = super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); if (renderer instanceof JLabel) { JLabel label = (JLabel) renderer; label.setIcon(null); } return renderer; } private Component renderErrorDocument(JTree tree, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus, ErrorDocument errorDocument) { return super.getTreeCellRendererComponent(tree, "<html>" + escapeHtml(errorDocument.getMessage()) + "</html>", selected, expanded, leaf, row, hasFocus); } }); renderersComboBox.setModel(new DefaultComboBoxModel<>(new String[] { ERROR_DOCUMENT })); renderedResultPanel.removeAll(); renderedResultPanel.add(errorTree, CENTER); repaint(); } }
From source file:edu.ku.brc.specify.tasks.subpane.LabelsPane.java
/** * Set the text to the label (create the label if it doesn't exist) * @param msg the message to be displayed *//*from w ww.j av a 2 s. c om*/ public void setLabelText(final String msg) { if (label == null) { removeAll(); CellConstraints cc = new CellConstraints(); PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g,p,2px,p,f:p:g", "f:p:g, p, f:p:g"), this);//$NON-NLS-1$ //$NON-NLS-2$ JButton moreBtn = createIconBtn("InfoIcon", IconManager.IconSize.Std16, null, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { showErrorMsgs(); } }); label = createLabel("", SwingConstants.CENTER); pb.add(label, cc.xy(2, 2)); pb.add(moreBtn, cc.xy(4, 2)); moreBtn.setEnabled(true); } if (progressBarPanel != null) { remove(progressBarPanel); } SwingUtilities.invokeLater(new Runnable() { public void run() { label.setText(msg); invalidate(); doLayout(); repaint(); } }); }
From source file:com.diversityarrays.kdxplore.curate.SampleEntryPanel.java
/** * @param show/*from ww w .j a va2 s. c o m*/ */ private void updateStatsControls(boolean showStats) { if (!SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { updateStatsControls(showStats); } }); return; } if (showStats) { repopulatingStatsControls = true; try { doRepopulateStatsControls(); } finally { repopulatingStatsControls = false; } statisticsControls.setVisible(true); } else { statisticsControls.setVisible(false); for (JButton btn : statButtonByStatType.values()) { btn.setEnabled(false); } for (Component component : statComponentByStatType.values()) { component.setEnabled(false); } } this.repaint(); this.updateUI(); }
From source file:main.UIController.java
/************* TO GREGORIAN *************/ public void updateDayComboImladris() { UI window = this.getUi(); JComboBox yen = window.getYen(); JTextField loa = window.getLoa(); JComboBox period = window.getPeriod(); JComboBox day = window.getDayOfLoa(); JButton convert = window.getToGregorian(); JTextPane result = window.getResGregorian(); int yenNum = yen.getSelectedIndex() + 1; String value = loa.getText(); if (!value.isEmpty()) { try {/*w w w . j a v a2 s .c o m*/ int loaNum = Integer.parseInt(value); if (loaNum > 0 && loaNum <= 144) { int periodNum = period.getSelectedIndex() + 1; if (periodNum == ImladrisCalendar.YESTARE || periodNum == ImladrisCalendar.METTARE) { day.setEnabled(false); day.setModel(new DefaultComboBoxModel()); convert.setEnabled(true); result.setText(""); } else { int daySel = 0; if (day.isEnabled()) { daySel = day.getSelectedIndex() + 1; } ArrayList<Integer> days = ImladrisInfo.getInstance().getDaysArray(yenNum, loaNum, periodNum); day.setModel(new DefaultComboBoxModel(days.toArray())); if (daySel > 0 && daySel <= days.size()) { day.setSelectedIndex(daySel - 1); } day.setEnabled(true); convert.setEnabled(true); result.setText(""); } } else { day.setEnabled(false); convert.setEnabled(false); day.setModel(new DefaultComboBoxModel()); result.setText(""); } } catch (NumberFormatException e) { day.setEnabled(false); convert.setEnabled(false); day.setModel(new DefaultComboBoxModel()); result.setText(""); } } else { day.setEnabled(false); convert.setEnabled(false); day.setModel(new DefaultComboBoxModel()); result.setText(""); } }