use of com.igormaznitsa.mindmap.model.MMapURI 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;
}
}
use of com.igormaznitsa.mindmap.model.MMapURI in project netbeans-mmd-plugin by raydac.
the class PsiExtraFileReference method retargetToFile.
public void retargetToFile(final PsiFileSystemItem file) {
final MMapURI oldUri = extraFile.getMMapURI();
try {
final MMapURI newUri = RefactoringUtils.makeNewMMapUri(extraFile.getProject(), oldUri, file.getVirtualFile());
final String packedNewMindMap = RefactoringUtils.replaceMMUriToNewFile(extraFile, oldUri, newUri);
final PsiFile containingFile = extraFile.getContainingFile();
final Document document = FileDocumentManager.getInstance().getDocument(containingFile.getVirtualFile());
CommandProcessor.getInstance().executeCommand(containingFile.getProject(), new Runnable() {
@Override
public void run() {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
final String packedMindMap = packedNewMindMap;
document.setText(packedMindMap);
FileDocumentManager.getInstance().saveDocument(document);
}
});
}
}, null, null, document);
extraFile.setMMapURI(newUri);
} catch (IOException ex) {
throw new IncorrectOperationException("Can't update links in mind map", (Throwable) ex);
}
}
Aggregations