}
}
public void editBookmarkReq(final BookmarkManagerWin mWin) {
final LocalBookmarkPropWin win = new LocalBookmarkPropWin(Display.getCurrent().getActiveShell());
final BookmarkItem bookmark = mWin.getSelectedBookmark();
if (bookmark == null) {
UXMessages.getInstance().showWarningMessage("You must select bookmark to be able edit it!");
return;
}
win.setURI(bookmark.getUri().toString());
win.setName(bookmark.getName());
win.setSelectedFolder(bookmark.getFolder());
win.setSaveAction(new UXAbstractAction() {
@Override
public void doAction() {
// Create an old bookmark object for transaction.
BookmarkItem oldBookmark = new BookmarkItem();
oldBookmark.setName(bookmark.getName());
oldBookmark.setUri(bookmark.getUri());
oldBookmark.setNrOfLines(bookmark.getNrOfLines());
oldBookmark.setAutoOpen(bookmark.isAutoOpen());
oldBookmark.setFolder(bookmark.getFolder());
bookmark.setName(win.getName());
bookmark.setNrOfLines(10);
BookmarkFolder folder = win.getSelectedFolder();
if (folder == null) {
UXMessages.getInstance()
.showWarningMessage("Please select a folder where the bookmark will be stored!");
return;
}
bookmark.getFolder().removeBookmark(bookmark);
bookmark.setFolder(win.getSelectedFolder());
try {
bookmark.setUri(new URI(win.getURI()));
BookmarkService.instance().update(bookmark);
bookmark.getFolder().addBookmark(bookmark);
} catch (Exception e) {
e.printStackTrace();
UXMessages.getInstance().showWarningMessage(e);
bookmark.setName(oldBookmark.getName());
bookmark.setUri(oldBookmark.getUri());
bookmark.setNrOfLines(oldBookmark.getNrOfLines());
bookmark.setAutoOpen(oldBookmark.isAutoOpen());
bookmark.setFolder(oldBookmark.getFolder());
bookmark.getFolder().addBookmark(bookmark);
return;
}
win.close();