Search in sources :

Example 1 with UriEditPanel

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

the class IdeaUtils method editURI.

public static MMapURI editURI(final MindMapDocumentEditor editor, final String title, final MMapURI uri) {
    final UriEditPanel uriEditor = new UriEditPanel(uri == null ? null : uri.asString(false, false));
    uriEditor.doLayout();
    uriEditor.setPreferredSize(new Dimension(450, uriEditor.getPreferredSize().height));
    if (plainMessageOkCancel(editor.getProject(), title, uriEditor)) {
        final String text = uriEditor.getText();
        if (text.isEmpty()) {
            return EMPTY_URI;
        }
        try {
            if (!new URI(text).isAbsolute())
                throw new URISyntaxException(text, "URI is not absolute one");
            return new MMapURI(text.trim());
        } catch (URISyntaxException ex) {
            editor.getDialogProvider().msgError(null, String.format(BUNDLE.getString("NbUtils.errMsgIllegalURI"), text));
            return null;
        }
    } else {
        return null;
    }
}
Also used : UriEditPanel(com.igormaznitsa.ideamindmap.swing.UriEditPanel) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) MMapURI(com.igormaznitsa.mindmap.model.MMapURI) MMapURI(com.igormaznitsa.mindmap.model.MMapURI)

Aggregations

UriEditPanel (com.igormaznitsa.ideamindmap.swing.UriEditPanel)1 MMapURI (com.igormaznitsa.mindmap.model.MMapURI)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1