@Override public void init(final LockTarget lockTarget) { this.lockTarget = lockTarget; final ParameterizedCommand<LockInfo> command = new ParameterizedCommand<LockInfo>() { @Override public void execute(final LockInfo lockInfo) { if (!lockRequestPending && !unlockRequestPending) { updateLockInfo(lockInfo); } } }; lockService.retrieveLockInfo(lockTarget.getPath(), command); }
private void reload() { lockTarget.getReloadRunnable().run(); }
private Widget getLockTargetWidget() { final IsWidget isWidget = lockTarget.getWidget(); if (isWidget instanceof Widget) { return ((Widget) isWidget); } return isWidget.asWidget(); }
protected void setupDefaultPessimisticLockManager() { if (lockManager == null) { lockManager = lockManagerProvider.get(); final Runnable reloadRunnable = new Runnable() { @Override public void run() { onStartup(path, getPlace()); } }; final TitleProvider titleProvider = new TitleProvider() { @Override public String getTitle() { AbstractWorkbenchEditorActivity activity = AbstractWorkbenchEditorActivity.this; return (activity.open) ? activity.getTitle() : ""; } }; lockManager.init(new LockTarget(path, getWidget(), getPlace(), titleProvider, reloadRunnable)); } }
public static ChangeTitleWidgetEvent create(final LockTarget lockTarget, final LockInfo lockInfo, final User user) { final String lockedBy = lockInfo.lockedBy(); if (user.getIdentifier().equals(lockedBy)) { lockImage.setTitle(WorkbenchConstants.INSTANCE.lockOwnedHint()); } else { lockImage.setTitle(WorkbenchConstants.INSTANCE.lockHint() + " " + lockedBy); } return new ChangeTitleWidgetEvent(lockTarget.getPlace(), lockTarget.getTitle(), (lockInfo.isLocked()) ? lockImage : null); } }
private void handleLockFailure(final LockInfo lockInfo) { if (lockInfo != null) { updateLockInfo(lockInfo); lockNotification.fire(new NotificationEvent(WorkbenchConstants.INSTANCE.lockedMessage(lockInfo.lockedBy()), NotificationEvent.NotificationType.INFO, true, lockTarget.getPlace(), 20)); } else { lockNotification.fire(new NotificationEvent(WorkbenchConstants.INSTANCE.lockError(), NotificationEvent.NotificationType.ERROR, true, lockTarget.getPlace(), 20)); } // Delay reloading slightly in case we're dealing with a flood of events if (reloadTimer == null) { reloadTimer = new Timer() { public void run() { reload(); } }; } if (!reloadTimer.isRunning()) { reloadTimer.schedule(250); } }
void initialiseLockManager() { lockManager.init(new LockTarget(editorPath, view.asWidget(), editorPlaceRequest, () -> editorPath.getFileName() + " - " + resourceType.getDescription(), () -> {/*nothing*/})); }
void initialiseLockManager() { lockManager.init(new LockTarget(editorPath, view.asWidget(), editorPlaceRequest, () -> editorPath.getFileName() + " - " + resourceType.getDescription(), () -> {/*nothing*/})); }
void onSaveInProgress(@Observes SaveInProgressEvent evt) { if (lockTarget != null && evt.getPath().equals(lockTarget.getPath())) { releaseLock(); } }
@Override public void run() { target.getReloadRunnable().run(); }
void initialiseLockManager() { lockManager.init(new LockTarget(currentPath, parent.getView().asWidget(), placeRequest, () -> currentPath.getFileName() + " - " + resourceType.getDescription(), () -> {/*Nothing*/}), parent); }
void onResourceAdded(@Observes ResourceAddedEvent res) { if (lockTarget != null && res.getPath().equals(lockTarget.getPath())) { releaseLock(); } }
@Override public void run() { target.getReloadRunnable().run(); }
void initialiseLockManager() { lockManager.init(new LockTarget(currentPath, parent.getView().asWidget(), placeRequest, () -> currentPath.getFileName() + " - " + resourceType.getDescription(), () -> {/*Nothing*/}), parent); }
void onRenameInProgress(@Observes RenameInProgressEvent event) { if (getLockTarget() != null && event.getPath().equals(lockTarget.getPath())) { releaseLock(); } }
target = new LockTarget(path, widget, new DefaultPlaceRequest("mockPlace"),
void onResourceUpdated(@Observes ResourceUpdatedEvent res) { if (lockTarget != null && res.getPath().equals(lockTarget.getPath())) { if (!res.getSessionInfo().getIdentity().equals(user)) { reload(); } releaseLock(); } }
target = new LockTarget(path, widget, new DefaultPlaceRequest("mockPlace"),
private void releaseLockInternal() { if (isLockedByCurrentUser() && !unlockRequestPending) { unlockRequestPending = true; ParameterizedCommand<LockResult> command = new ParameterizedCommand<LockResult>() { @Override public void execute(final LockResult result) { updateLockInfo(result.getLockInfo()); if (result.isSuccess()) { if (closeHandler != null) { closeHandler.removeHandler(); } } unlockRequestPending = false; } }; lockService.releaseLock(lockTarget.getPath(), command); } }