From b132a356449e2c96a965e3ac634cd07085f6fb7a Mon Sep 17 00:00:00 2001 From: Nils Christian Ehmke <nie@informatik.uni-kiel.de> Date: Fri, 27 Jul 2012 21:48:46 +0200 Subject: [PATCH] Moved the logic of the force-save into the normal save. --- .../session/CurrentAnalysisEditorBean.java | 3 +++ .../src/main/webapp/AnalysisEditor.xhtml | 5 +++-- .../main/webapp/dialogs/forceSaveDialog.xhtml | 22 +++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 Kieker.WebGUI/src/main/webapp/dialogs/forceSaveDialog.xhtml diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentAnalysisEditorBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentAnalysisEditorBean.java index 45254fd7..b14a5b11 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentAnalysisEditorBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentAnalysisEditorBean.java @@ -70,6 +70,7 @@ import kieker.webgui.common.PluginFinder; import kieker.webgui.common.exception.LibraryAlreadyExistingException; import kieker.webgui.common.exception.NewerProjectException; +import org.primefaces.context.RequestContext; import org.primefaces.event.FileUploadEvent; import org.primefaces.model.DefaultTreeNode; import org.primefaces.model.TreeNode; @@ -553,6 +554,8 @@ public final class CurrentAnalysisEditorBean { } catch (final NewerProjectException ex) { CurrentAnalysisEditorBean.LOG.info("The project has been modified externally in the meanwhile.", ex); CurrentAnalysisEditorBean.showMessage(FacesMessage.SEVERITY_WARN, "The project has been modified externally in the meanwhile."); + // Give the user the possibility to force-save the project + RequestContext.getCurrentInstance().execute("forceSaveDlg.show()"); } } } diff --git a/Kieker.WebGUI/src/main/webapp/AnalysisEditor.xhtml b/Kieker.WebGUI/src/main/webapp/AnalysisEditor.xhtml index 42ff17ec..df9737f3 100644 --- a/Kieker.WebGUI/src/main/webapp/AnalysisEditor.xhtml +++ b/Kieker.WebGUI/src/main/webapp/AnalysisEditor.xhtml @@ -46,8 +46,7 @@ <p:menubar> <p:submenu label="File"> <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-disk" value=" Save Project" update=":messages" ajax="true" action="#{currentAnalysisEditorBean.saveProject(false)}" disabled="#{empty currentAnalysisEditorBean.project}"/> - <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-disk" value=" Save Project As" update=":messages" ajax="true" disabled="#{empty currentAnalysisEditorBean.project}"/> - <p:menuitem styleClass="element-with-whitespace Force-Save-Project-Button" icon="ui-icon-alert" value=" Force Save Project" update=":messages" ajax="true" action="#{currentAnalysisEditorBean.saveProject(true)}" disabled="#{empty currentAnalysisEditorBean.project}"/> + <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-disk" value=" Save Project As" update=":messages" ajax="true" disabled="#{true or empty currentAnalysisEditorBean.project}"/> <p:separator /> <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-refresh" value=" Reload Project" ajax="true" disabled="#{empty currentAnalysisEditorBean.project or true}" /> <p:separator/> @@ -210,5 +209,7 @@ <ui:include src="dialogs/connectionDialog.xhtml" /> <ui:include src="dialogs/manageLibrariesDialog.xhtml" /> + + <ui:include src="dialogs/forceSaveDialog.xhtml" /> </h:body> </html> \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/webapp/dialogs/forceSaveDialog.xhtml b/Kieker.WebGUI/src/main/webapp/dialogs/forceSaveDialog.xhtml new file mode 100644 index 00000000..678ff5c3 --- /dev/null +++ b/Kieker.WebGUI/src/main/webapp/dialogs/forceSaveDialog.xhtml @@ -0,0 +1,22 @@ +<ui:composition + xmlns="http://www.w3.org/1999/xhtml" + xmlns:h="http://java.sun.com/jsf/html" + xmlns:ui="http://java.sun.com/jsf/facelets" + xmlns:f="http://java.sun.com/jsf/core" + xmlns:p="http://primefaces.org/ui"> + + <p:dialog header="Save Project" resizable="false" modal="true" + widgetVar="forceSaveDlg" id="forceSaveDialog"> + <h:form> + <div style="text-align: center"> + <h:outputText value="The project has been modified externally in the meanwhile. Do you want to overwrite the changes?" /> + </div> + <hr/> + <div style="text-align: right"> + <p:commandButton value="Yes" action="#{currentAnalysisEditorBean.saveProject(true)}" oncomplete="forceSaveDlg.hide()" update=":messages" /> + <p:spacer width="10px" height="10" /> + <p:commandButton value="Cancel" onclick="forceSaveDlg.hide()" /> + </div> + </h:form> + </p:dialog> +</ui:composition> \ No newline at end of file -- GitLab