public void actionPerformed(final ActionEvent e) { final PromptDialog dlg = new PromptDialog("Rename", "Name", panel.getTitle(), PromptDialog.TYPE.TEXTFIELD); dlg.show(); if (dlg.IsOK()) { try { panel.setTitle(dlg.getValue("Name")); } catch (Exception ex) { Dialogs.showError(ex.getMessage()); } } } });
protected void onOK() { ok = true; hide(); }
public PromptDialog(final String title, final Descriptor[] descriptorList) { super(SnapApp.getDefault().getMainFrame(), title, ModalDialog.ID_OK_CANCEL, null); final JPanel content = GridBagUtils.createPanel(); final GridBagConstraints gbc = DialogUtils.createGridBagConstraints(); gbc.insets.right = 4; gbc.insets.top = 2; for(Descriptor descriptor : descriptorList) { final JComponent prompt = addComponent(content, gbc, descriptor.label, descriptor.defaultValue, descriptor.type); componentMap.put(descriptor.label, prompt); gbc.gridy++; } getJDialog().setMinimumSize(new Dimension(400, 100)); setContent(content); }
/** * Call description dialog */ private void OnInfo() { final PromptDialog dlg = new PromptDialog("Graph Description", "Description", graphEx.getGraphDescription(), PromptDialog.TYPE.TEXTAREA); dlg.show(); if (dlg.IsOK()) { try { graphEx.setGraphDescription(dlg.getValue("Description")); } catch (Exception ex) { Dialogs.showError(ex.getMessage()); } } }
private static void promptForCredentials() { final PromptDialog dlg = new PromptDialog(CopernicusProductQuery.COPERNICUS_HOST, new PromptDialog.Descriptor[] { new PromptDialog.Descriptor("User name:", "", PromptDialog.TYPE.TEXTFIELD), new PromptDialog.Descriptor("Password:", "", PromptDialog.TYPE.PASSWORD) }); dlg.show(); if (dlg.IsOK()) { try { final String user = dlg.getValue("User name:"); final String password = dlg.getValue("Password:"); Credentials.instance().put(CopernicusProductQuery.COPERNICUS_HOST, user, password); } catch (Exception ex) { Dialogs.showError(ex.getMessage()); } } }
@Override public void actionPerformed(final ActionEvent event) { final PromptDialog dlg = new PromptDialog("Search Metadata", "Value", "", PromptDialog.TYPE.TEXTFIELD); dlg.show(); if (dlg.IsOK()) { try { final String value = dlg.getValue("Value").toUpperCase(); final MetadataElement resultElem = new MetadataElement("Search result (" + value + ')'); final boolean isModified = product.isModified(); final MetadataElement root = product.getMetadataRoot(); resultElem.setOwner(product); searchMetadataValue(resultElem, root, value); product.setModified(isModified); if (resultElem.getNumElements() > 0 || resultElem.getNumAttributes() > 0) { SearchMetadataAction.openMetadataWindow(resultElem); } else { // no attributes found Dialogs.showError("Search Metadata", value + " not found in the Metadata"); } } catch (Exception ex) { Dialogs.showError(ex.getMessage()); } } }
@Override public void actionPerformed(final ActionEvent event) { final PromptDialog dlg = new PromptDialog("Search Metadata", "Item Name", "", PromptDialog.TYPE.TEXTFIELD); dlg.show(); if (dlg.IsOK()) { try { final String tag = dlg.getValue("Item Name").toUpperCase(); final MetadataElement resultElem = new MetadataElement("Search result (" + tag + ')'); final boolean isModified = product.isModified(); final MetadataElement root = product.getMetadataRoot(); resultElem.setOwner(product); searchMetadata(resultElem, root, tag); product.setModified(isModified); if (resultElem.getNumElements() > 0 || resultElem.getNumAttributes() > 0) { openMetadataWindow(resultElem); } else { // no attributes found Dialogs.showError("Search Metadata", tag + " not found in the Metadata"); } } catch (Exception ex) { Dialogs.showError(ex.getMessage()); } } }