/** * Create workspace selection action workspace selection action. * * @param workspaceName * the workspace name * @param workspaceViewDescriptor * the workspace view descriptor * @return the workspace selection action */ protected WorkspaceSelectionAction<E, F, G> createWorkspaceSelectionAction(String workspaceName, IViewDescriptor workspaceViewDescriptor) { WorkspaceSelectionAction<E, F, G> workspaceSelectionAction = new WorkspaceSelectionAction<>(); workspaceSelectionAction.setWorkspaceName(workspaceName); workspaceSelectionAction.setName(workspaceViewDescriptor.getName()); workspaceSelectionAction.setDescription(workspaceViewDescriptor.getDescription()); workspaceSelectionAction.setIcon(workspaceViewDescriptor.getIcon()); return workspaceSelectionAction; }
@Override public boolean execute(IActionHandler actionHandler, Map<String, Object> context) { return getController(context).stop(); } };
/** * Check before exiting. * 1/ Traverse module to check that no pending changes need to be forwarded * 2/ Traverse asynchronous executor to check that none if them are still alive * @param context * The context. * @return the i18n message to display or null */ protected String checkBeforeExitFrontAction(IActionHandler actionHandler, Map<String, Object> context) { StringBuilder sb = new StringBuilder(); if (hasDirtyModules(actionHandler, context)) { sb.append(getTranslationProvider(context).getTranslation( "module.content.dirty.message", getLocale(context))); } if (hasAliveAsynchronousExecutors(actionHandler, context)) { if (sb.length()>0) { sb.append("<br/>"); } sb.append(getTranslationProvider(context).getTranslation( "asynchronous.tasks.alive.message", getLocale(context))); } return sb.length()==0 ? null : sb.toString(); }
/** * Stops the frontend controller. * <p> * {@inheritDoc} */ @Override public boolean execute(IActionHandler actionHandler, Map<String, Object> context) { String checkBeforeExitMsg = checkBeforeExitFrontAction(actionHandler, context); if (checkBeforeExitMsg!=null) { checkBeforeExitMsg = "<html>" + checkBeforeExitMsg + "<br><br>" + getTranslationProvider(context).getTranslation("exit.question.message", getLocale(context)) + "</html>"; getController(context).popupYesNo( getSourceComponent(context), getTranslationProvider(context).getTranslation("module.content.dirty.title", getLocale(context)), getIconFactory(context).getQuestionIconImageURL(), checkBeforeExitMsg, actualExitAction, null, context); } else { return actualExitAction.execute(actionHandler, context); } return false; }
/** * Creates the exit action. * * @return the exit action. */ @Override public IDisplayableAction getExitAction() { if (exitAction == null) { ExitAction<E, F, G> action = new ExitAction<>(); action.setName("quit.name"); action.setDescription("quit.description"); action.setIconImageURL(getViewFactory().getIconFactory().getCancelIconImageURL()); exitAction = action; } return exitAction; }
if (getCheckCurrentModuleDirtyStateAction() != null) { getCheckCurrentModuleDirtyStateAction().execute(actionHandler, context); for (String workspaceName : getController(context).getWorkspaceNames()) { Workspace ws = getController(context).getWorkspace(workspaceName); List<Module> modules = ws.getModules(); if (modules != null) { for (Module m : modules) { if (isDirtyInDepth(m)) { hasDirtyModules = true; break;
/** * Traverse asynchronous executor to check that none are still alive * @param actionHandler * the action handler this action has been told to execute by. It may * be used to post another action execution upon completion of this * one. * @param context * the execution context. The action should update it depending on * its result. * @return true if one or more module is dirty. */ protected boolean hasAliveAsynchronousExecutors(IActionHandler actionHandler, Map<String, Object> context) { return !getBackendController(context).getRunningExecutors().isEmpty(); }
/** * Displays the workspace. * <p> * {@inheritDoc} */ @Override public boolean execute(IActionHandler actionHandler, Map<String, Object> context) { if (forceReselection) { getController(context).displayWorkspace(null); } getController(context).displayWorkspace(workspaceName); return super.execute(actionHandler, context); }
private boolean isDirtyInDepth(Module module) { if (module.isDirty()) { return true; } List<Module> subModules = module.getSubModules(); if (subModules != null) { for (Module subModule : subModules) { if (isDirtyInDepth(subModule)) { return true; } } } return false; }
@Override protected WorkspaceSelectionAction<RComponent, RIcon, RAction> createWorkspaceSelectionAction(String workspaceName, IViewDescriptor workspaceViewDescriptor) { WorkspaceSelectionAction<RComponent, RIcon, RAction> workspaceSelectionAction = super .createWorkspaceSelectionAction(workspaceName, workspaceViewDescriptor); workspaceSelectionAction.setForceReselection(getClientType() == EClientType.MOBILE_HTML5_PHONE); return workspaceSelectionAction; } }