Command getConcurrentDeleteOnClose(final D document) { return () -> { enableMenus(false); removeDocument(document); deregisterDocument(document); }; }
/** * Checks whether a document has experienced a concurrent update by another user. If a concurrent update * is detected a {@link ConcurrentChangePopup} is shown allowing the user to choose whether to abort the * save, force the save or refresh the view with the latest version. If no concurrent update is detected * the document is persisted. * @param document */ protected void doSaveCheckForAndHandleConcurrentUpdate(final D document) { final ObservablePath.OnConcurrentUpdateEvent concurrentUpdateSessionInfo = document.getConcurrentUpdateSessionInfo(); if (concurrentUpdateSessionInfo != null) { showConcurrentUpdatePopup(document); } else { doSave(document); } }
/** * Enable/disable all menus associated with the MDI container, consisting of "Save", "Copy", * "Rename", "Delete", "Validate" and "VersionRecordManager" drop-down. Subclasses can override * this to customize their Menus. * @param enabled */ protected void enableMenus(final boolean enabled) { getSaveMenuItem().setEnabled(enabled); getVersionManagerMenuItem().setEnabled(enabled); enableMenuItem(enabled, MenuItems.COPY); enableMenuItem(enabled, MenuItems.RENAME); enableMenuItem(enabled, MenuItems.DELETE); enableMenuItem(enabled, MenuItems.VALIDATE); }
/** * Construct the default Menus, consisting of "Save", "Copy", "Rename", "Delete", * "Validate" and "VersionRecordManager" drop-down. Subclasses can override this * to customize their Menus. */ @Override public void makeMenuBar() { this.fileMenuBuilder.setLockSyncMenuStateHelper(new KieMultipleDocumentEditorLockSyncHelper(this)); if (canUpdateProject()) { fileMenuBuilder .addSave(getSaveMenuItem()) .addCopy(() -> getActiveDocument().getCurrentPath(), assetUpdateValidator) .addRename(() -> getActiveDocument().getLatestPath(), assetUpdateValidator) .addDelete(() -> getActiveDocument().getLatestPath(), assetUpdateValidator); } addDownloadMenuItem(fileMenuBuilder); this.menus = fileMenuBuilder .addValidate(() -> onValidate(getActiveDocument())) .addNewTopLevelMenu(getRegisteredDocumentsMenuItem()) .addNewTopLevelMenu(getVersionManagerMenuItem()) .build(); }
@Override public void registerDocument(final D document) { PortablePreconditions.checkNotNull("document", document); if (documents.contains(document)) { return; } documents.add(document); registeredDocumentsMenuBuilder.registerDocument(document); //Setup concurrent modification handlers final ObservablePath path = document.getLatestPath(); path.onRename(() -> refresh(document)); path.onConcurrentRename((info) -> doConcurrentRename(document, info)); path.onDelete(() -> { enableMenus(false); removeDocument(document); deregisterDocument(document); }); path.onConcurrentDelete((info) -> { doConcurrentDelete(document, info); }); path.onConcurrentUpdate((eventInfo) -> document.setConcurrentUpdateSessionInfo(eventInfo)); }
Command getConcurrentDeleteOnIgnoreCommand() { return () -> enableMenus(false); }
/** * Called by the "Save" MenuItem to save or restore the active document. If the active document * is read-only a check is made whether the active document is an older version; in which case * the active document is restored. If the active document is read-only and the latest version * the User is notified that the document is read-only and the save aborted. If the document * is not read-only a check is made for concurrent updates before persisting. */ protected void doSave() { final D document = getActiveDocument(); if (document == null) { return; } final boolean isReadOnly = document.isReadOnly(); if (isReadOnly) { if (versionRecordManager.isCurrentLatest()) { editorView.alertReadOnly(); } else { versionRecordManager.restoreToCurrentVersion(); } return; } doSaveCheckForAndHandleConcurrentUpdate(document); }
void showConcurrentUpdatePopup(final D document) { final ObservablePath.OnConcurrentUpdateEvent concurrentUpdateSessionInfo = document.getConcurrentUpdateSessionInfo(); newConcurrentUpdate(concurrentUpdateSessionInfo.getPath(), concurrentUpdateSessionInfo.getIdentity(), () -> doSave(document), () -> {/*nothing*/}, () -> { document.setConcurrentUpdateSessionInfo(null); refresh(document); }).show(); }
@Override public void onSuccess() { doSave(); }
protected void addDownloadMenuItem(final FileMenuBuilder menuBuilder) { menuBuilder.addNewTopLevelMenu(downloadMenuItem()); }
Command getConcurrentRenameOnIgnoreCommand() { return () -> enableMenus(false); }
void onRepositoryRemoved(final @Observes RepositoryRemovedEvent event) { Optional.ofNullable(workbenchContext) .flatMap(context -> context.getActiveWorkspaceProject()) .filter(proj -> event.getRepository() != null && proj.getRepository().equals(event.getRepository())) .ifPresent(repo -> enableMenus(false)); }
@Override protected void enableMenus(final boolean enabled) { super.enableMenus(enabled); getEditMenuItem().setEnabled(enabled); getViewMenuItem().setEnabled(enabled); getInsertMenuItem().setEnabled(enabled); getRadarMenuItem().setEnabled(enabled); }
@Override protected void enableMenus(final boolean enabled) { super.enableMenus(enabled); getEditMenuItem().setEnabled(enabled); getViewMenuItem().setEnabled(enabled); getInsertMenuItem().setEnabled(enabled); getRadarMenuItem().setEnabled(enabled); }