Search in sources :

Example 1 with UriEditPanel

use of com.igormaznitsa.nbmindmap.nb.swing.UriEditPanel in project netbeans-mmd-plugin by raydac.

the class NbUtils method editURI.

@Nullable
public static MMapURI editURI(@Nullable Component parentComponent, @Nonnull final String title, @Nullable final MMapURI uri) {
    final UriEditPanel textEditor = new UriEditPanel(uri == null ? null : uri.asString(false, false));
    textEditor.doLayout();
    textEditor.setPreferredSize(new Dimension(450, textEditor.getPreferredSize().height));
    final NotifyDescriptor desc = new NotifyDescriptor.Confirmation(textEditor, title, NotifyDescriptor.OK_CANCEL_OPTION, NotifyDescriptor.PLAIN_MESSAGE);
    if (DialogDisplayer.getDefault().notify(desc) == NotifyDescriptor.OK_OPTION) {
        final String text = textEditor.getText();
        if (text.isEmpty()) {
            return EMPTY_URI;
        }
        try {
            return new MMapURI(text.trim());
        } catch (URISyntaxException ex) {
            msgError(parentComponent, String.format(java.util.ResourceBundle.getBundle("com/igormaznitsa/nbmindmap/i18n/Bundle").getString("NbUtils.errMsgIllegalURI"), text));
            return null;
        }
    } else {
        return null;
    }
}
Also used : NotifyDescriptor(org.openide.NotifyDescriptor) UriEditPanel(com.igormaznitsa.nbmindmap.nb.swing.UriEditPanel) Dimension(java.awt.Dimension) URISyntaxException(java.net.URISyntaxException) MMapURI(com.igormaznitsa.mindmap.model.MMapURI) Nullable(javax.annotation.Nullable)

Aggregations

MMapURI (com.igormaznitsa.mindmap.model.MMapURI)1 UriEditPanel (com.igormaznitsa.nbmindmap.nb.swing.UriEditPanel)1 Dimension (java.awt.Dimension)1 URISyntaxException (java.net.URISyntaxException)1 Nullable (javax.annotation.Nullable)1 NotifyDescriptor (org.openide.NotifyDescriptor)1