Skip to content
Snippets Groups Projects
Commit 722d3407 authored by Nils Christian Ehmke's avatar Nils Christian Ehmke
Browse files

Refactoring and further development of the controller page.

parent e5467854
Branches
Tags
No related merge requests found
...@@ -107,7 +107,7 @@ public class ProjectsBean { ...@@ -107,7 +107,7 @@ public class ProjectsBean {
// Inform the user // Inform the user
GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_INFO, this.globalPropertiesBean.getMsgProjectCreated()); GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_INFO, this.globalPropertiesBean.getMsgProjectCreated());
// Update the list of the "calling" bean // Update the list of the "calling" bean
currentProjectOverviewBean.updateLists(); currentProjectOverviewBean.updateAvailableProjects();
} catch (final IOException ex) { } catch (final IOException ex) {
ProjectsBean.LOG.error("An error occured while creating the project.", ex); ProjectsBean.LOG.error("An error occured while creating the project.", ex);
GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_ERROR, "An error occured while creating the project."); GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_ERROR, "An error occured while creating the project.");
...@@ -129,7 +129,7 @@ public class ProjectsBean { ...@@ -129,7 +129,7 @@ public class ProjectsBean {
// Inform the user // Inform the user
GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_INFO, this.globalPropertiesBean.getMsgProjectDeleted()); GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_INFO, this.globalPropertiesBean.getMsgProjectDeleted());
// Update the list of the "calling" bean // Update the list of the "calling" bean
currentProjectOverviewBean.updateLists(); currentProjectOverviewBean.updateAvailableProjects();
} catch (final IOException ex) { } catch (final IOException ex) {
ProjectsBean.LOG.error("An error occured while removing the project.", ex); ProjectsBean.LOG.error("An error occured while removing the project.", ex);
GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_ERROR, "An error occured while removing the project."); GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_ERROR, "An error occured while removing the project.");
...@@ -162,7 +162,7 @@ public class ProjectsBean { ...@@ -162,7 +162,7 @@ public class ProjectsBean {
// Inform the user // Inform the user
GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_INFO, this.globalPropertiesBean.getMsgProjectCreated()); GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_INFO, this.globalPropertiesBean.getMsgProjectCreated());
// Update the list of the "calling" bean // Update the list of the "calling" bean
currentProjectOverviewBean.updateLists(); currentProjectOverviewBean.updateAvailableProjects();
} catch (final IOException ex) { } catch (final IOException ex) {
ProjectsBean.LOG.error("An error occured while creating the project.", ex); ProjectsBean.LOG.error("An error occured while creating the project.", ex);
GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_ERROR, "An error occured while creating the project."); GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_ERROR, "An error occured while creating the project.");
...@@ -198,7 +198,7 @@ public class ProjectsBean { ...@@ -198,7 +198,7 @@ public class ProjectsBean {
// Inform the user // Inform the user
GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_INFO, "Project imported."); GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_INFO, "Project imported.");
// Update the list of the "calling" bean // Update the list of the "calling" bean
currentProjectOverviewBean.updateLists(); currentProjectOverviewBean.updateAvailableProjects();
} catch (final IOException ex) { } catch (final IOException ex) {
ProjectsBean.LOG.error("An error occured while importing the project.", ex); ProjectsBean.LOG.error("An error occured while importing the project.", ex);
GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_ERROR, "An error occured while importing the project."); GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_ERROR, "An error occured while importing the project.");
... ...
......
...@@ -17,9 +17,6 @@ ...@@ -17,9 +17,6 @@
package kieker.webgui.web.beans.view; package kieker.webgui.web.beans.view;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
...@@ -38,7 +35,6 @@ import org.springframework.context.annotation.Scope; ...@@ -38,7 +35,6 @@ import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/** /**
* /**
* The {@link CurrentControllerBean} contains the necessary data behind an instance of the analysis controller. The class is a Spring managed bean with view scope to * The {@link CurrentControllerBean} contains the necessary data behind an instance of the analysis controller. The class is a Spring managed bean with view scope to
* make sure that one user (even in one session) can open multiple projects at a time without causing any problems. * make sure that one user (even in one session) can open multiple projects at a time without causing any problems.
* *
...@@ -51,11 +47,11 @@ public class CurrentControllerBean { ...@@ -51,11 +47,11 @@ public class CurrentControllerBean {
private static final Log LOG = LogFactory.getLog(CurrentControllerBean.class); private static final Log LOG = LogFactory.getLog(CurrentControllerBean.class);
private final List<String> logEntries = new ArrayList<String>(); private final List<String> logEntries = new ArrayList<String>();
private String projectName;
@Autowired @Autowired
private IProjectService projectService; private IProjectService projectService;
private String projectName;
/** /**
* Creates a new instance of this class. <b>Do not use this constructor. This bean is Spring managed.</b> * Creates a new instance of this class. <b>Do not use this constructor. This bean is Spring managed.</b>
*/ */
...@@ -82,10 +78,10 @@ public class CurrentControllerBean { ...@@ -82,10 +78,10 @@ public class CurrentControllerBean {
this.projectService.startAnalysis(this.projectName); this.projectService.startAnalysis(this.projectName);
} catch (final InvalidAnalysisStateException ex) { } catch (final InvalidAnalysisStateException ex) {
CurrentControllerBean.LOG.info("The analysis has already been started.", ex); CurrentControllerBean.LOG.info("The analysis has already been started.", ex);
this.addLogEntry(ex); this.addLogEntry("The analysis has already been started.");
} catch (final ProjectNotExistingException ex) { } catch (final ProjectNotExistingException ex) {
CurrentControllerBean.LOG.info("The project does not exist.", ex); CurrentControllerBean.LOG.info("The project does not exist.", ex);
this.addLogEntry(ex); this.addLogEntry("The project does not exist.");
} }
} }
...@@ -101,10 +97,10 @@ public class CurrentControllerBean { ...@@ -101,10 +97,10 @@ public class CurrentControllerBean {
} }
} catch (final InvalidAnalysisStateException ex) { } catch (final InvalidAnalysisStateException ex) {
CurrentControllerBean.LOG.info("The analysis has not been started yet.", ex); CurrentControllerBean.LOG.info("The analysis has not been started yet.", ex);
this.addLogEntry(ex); this.addLogEntry("The analysis has not been started yet.");
} catch (final ProjectNotExistingException ex) { } catch (final ProjectNotExistingException ex) {
CurrentControllerBean.LOG.info("The project does not exist.", ex); CurrentControllerBean.LOG.info("The project does not exist.", ex);
this.addLogEntry(ex); this.addLogEntry("The project does not exist.");
} }
} }
...@@ -117,16 +113,16 @@ public class CurrentControllerBean { ...@@ -117,16 +113,16 @@ public class CurrentControllerBean {
this.projectService.initializeAnalysis(this.projectName, this.projectService.getClassLoader(this.projectName, this)); // NOPMD (ClassLoader) this.projectService.initializeAnalysis(this.projectName, this.projectService.getClassLoader(this.projectName, this)); // NOPMD (ClassLoader)
} catch (final InvalidAnalysisStateException ex) { } catch (final InvalidAnalysisStateException ex) {
CurrentControllerBean.LOG.error("The analysis has already been instantiated.", ex); CurrentControllerBean.LOG.error("The analysis has already been instantiated.", ex);
this.addLogEntry(ex); this.addLogEntry("The analysis has already been instantiated.");
} catch (final ProjectNotExistingException ex) { } catch (final ProjectNotExistingException ex) {
CurrentControllerBean.LOG.info("The project does not exist.", ex); CurrentControllerBean.LOG.info("The project does not exist.", ex);
this.addLogEntry(ex); this.addLogEntry("The project does not exist.");
} catch (final IOException ex) { } catch (final IOException ex) {
CurrentControllerBean.LOG.info("An error occured during the initialization.", ex); CurrentControllerBean.LOG.info("An error occured during the initialization.", ex);
this.addLogEntry(ex); this.addLogEntry("An error occured during the initialization.");
} catch (final AnalysisInitializationException ex) { } catch (final AnalysisInitializationException ex) {
CurrentControllerBean.LOG.info("An error occured during the initialization.", ex); CurrentControllerBean.LOG.info("An error occured during the initialization.", ex);
this.addLogEntry(ex); this.addLogEntry("An error occured during the initialization.");
} }
} }
...@@ -139,10 +135,10 @@ public class CurrentControllerBean { ...@@ -139,10 +135,10 @@ public class CurrentControllerBean {
this.projectService.cleanAnalysis(this.projectName); this.projectService.cleanAnalysis(this.projectName);
} catch (final ProjectNotExistingException ex) { } catch (final ProjectNotExistingException ex) {
CurrentControllerBean.LOG.info("The project does not exist.", ex); CurrentControllerBean.LOG.info("The project does not exist.", ex);
this.addLogEntry(ex); this.addLogEntry("The project does not exist.");
} catch (final InvalidAnalysisStateException ex) { } catch (final InvalidAnalysisStateException ex) {
CurrentControllerBean.LOG.error("The analysis has not been instantiated yet.", ex); CurrentControllerBean.LOG.error("The analysis has not been instantiated yet.", ex);
this.addLogEntry(ex); this.addLogEntry("The analysis has not been instantiated yet.");
} }
} }
...@@ -247,19 +243,6 @@ public class CurrentControllerBean { ...@@ -247,19 +243,6 @@ public class CurrentControllerBean {
return this.logEntries; return this.logEntries;
} }
/**
* Adds the element to the log.
*
* @param cause
* The element to be added.
*/
private void addLogEntry(final Throwable cause) {
final Writer result = new StringWriter();
final PrintWriter printWriter = new PrintWriter(result);
cause.printStackTrace(printWriter);
this.addLogEntry(result.toString());
}
/** /**
* Adds the element (with the current time) to the log. * Adds the element (with the current time) to the log.
* *
... ...
......
...@@ -20,6 +20,7 @@ import java.util.Collections; ...@@ -20,6 +20,7 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.faces.context.FacesContext;
import kieker.webgui.web.beans.application.ProjectsBean; import kieker.webgui.web.beans.application.ProjectsBean;
...@@ -41,54 +42,56 @@ import org.springframework.stereotype.Component; ...@@ -41,54 +42,56 @@ import org.springframework.stereotype.Component;
@Scope("view") @Scope("view")
public class CurrentProjectOverviewBean { public class CurrentProjectOverviewBean {
private List<String> projects = Collections.emptyList(); private List<String> availableProjects;
private String projectName; private String selectedProjectName;
@Autowired @Autowired
private ProjectsBean projectsBean; private ProjectsBean projectsBean;
/** /**
* Default constructor. <b>Do not call this constructor manually. It will only be accessed by Spring.</b> * Creates a new instance of this class. <b>Do not use this constructor. This bean is Spring managed.</b>
*/ */
public CurrentProjectOverviewBean() { public CurrentProjectOverviewBean() {
// No code necessary this.availableProjects = Collections.emptyList();
} }
/** /**
* This method should only be called automatically by Spring to update the projects list. * This method initializes the bean. <b>Do not call this method manually. It will only be accessed by Spring.</b>
*/ */
@PostConstruct @PostConstruct
protected void initialialize() { protected void initialialize() {
this.updateLists(); // Make sure that the initialization will only be done for the init request.
if (!FacesContext.getCurrentInstance().isPostback()) {
this.updateAvailableProjects();
}
} }
/** /**
* This is the event listener used to select a row instantaneously. * This is the event handler used to select a row instantaneously.
* *
* @param event * @param event
* The select event. * The select event.
*/ */
public void onRowSelect(final SelectEvent event) { public void rowSelectHandler(final SelectEvent event) {
this.setProjectName((String) event.getObject()); this.setProjectName((String) event.getObject());
} }
/** /**
* Updates the list containing the available projects name. * Updates the list with the available availableProjects.
*/ */
public void updateLists() { public void updateAvailableProjects() {
this.projects = this.projectsBean.getProjects(); this.availableProjects = this.projectsBean.getProjects();
} }
public String getProjectName() { public List<String> getProjects() {
return this.projectName; return this.availableProjects;
} }
public void setProjectName(final String projectName) { public String getProjectName() {
this.projectName = projectName; return this.selectedProjectName;
} }
public List<String> getProjects() { public void setProjectName(final String projectName) {
return this.projects; this.selectedProjectName = projectName;
} }
} }
@charset "UTF-8"; @charset "UTF-8";
/* This is necessary to remove the border from the datalist */
.ui-datalist * {
border : 0px !important;
}
.col1 {
width: 50% !important;
}
.col2 {
width: 50% !important;
}
\ No newline at end of file
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<p:tab title="#{localizedMessages.analysisEditor}"> <p:tab title="#{localizedMessages.analysisEditor}">
<h:panelGrid columns="2" cellpadding="10" columnClasses="rightAlignedColumn, normalColumn"> <h:panelGrid columns="2" cellpadding="10" columnClasses="rightAlignedColumn, normalColumn">
<h:outputText value="#{localizedMessages.toolPalette}:"/> <h:outputText value="#{localizedMessages.toolPalette}:"/>
<p:selectOneMenu style="width: 100%"> <p:selectOneMenu style="width: 100%" disabled="true">
<f:selectItem itemLabel="#{localizedMessages.lists}"/> <f:selectItem itemLabel="#{localizedMessages.lists}"/>
</p:selectOneMenu> </p:selectOneMenu>
... ...
......
...@@ -42,22 +42,25 @@ ...@@ -42,22 +42,25 @@
<ui:define name="centerContent"> <ui:define name="centerContent">
<p:tabView id="tabView" style="height: 99%" > <h:panelGrid columns="2" columnClasses="col1 , col2" cellpadding="5" style="width: 99%; height: 100%">
<p:tab title="#{localizedControllerPageMessages.personalLog}" >
<h:form id="currentViewLog"> <p:panel style="width: 100%; height:100%" header="#{localizedControllerPageMessages.personalLog}" >
<ui:repeat value="#{currentControllerBean.viewLog}" var="entry" varStatus="stat"> <h:form id="currentViewLog" style="width: 100%">
<h:outputText value="#{entry}"/><ui:fragment rendered="#{not stat.last}"><br/><br/></ui:fragment> <p:dataList value="#{currentControllerBean.viewLog}" var="logEntry">
</ui:repeat> #{logEntry}
</p:dataList>
</h:form> </h:form>
</p:tab> </p:panel>
<p:tab title="#{localizedControllerPageMessages.analysisControllerLog}">
<h:form id="analysisControllerLog"> <p:panel style="width: 100%; height:100%" header="#{localizedControllerPageMessages.analysisControllerLog}" collapsed="true">
<ui:repeat value="#{currentControllerBean.analysisLog}" var="entry" varStatus="stat"> <h:form id="analysisControllerLog" style="width: 100%">
<h:outputText value="#{entry}"/><ui:fragment rendered="#{not stat.last}"><br/><br/></ui:fragment> <p:dataList value="#{currentControllerBean.analysisLog}" var="logEntry">
</ui:repeat> #{logEntry}
</p:dataList>
</h:form> </h:form>
</p:tab> </p:panel>
</p:tabView> </h:panelGrid>
</ui:define> </ui:define>
<ui:define name="furtherLayoutUnits"> <ui:define name="furtherLayoutUnits">
...@@ -66,16 +69,16 @@ ...@@ -66,16 +69,16 @@
<h:form id="controllerForm"> <h:form id="controllerForm">
<div align="center"> <div align="center">
<h:panelGrid columns="4" cellpadding="15"> <h:panelGrid columns="4" cellpadding="15">
<p:commandButton value="#{localizedControllerPageMessages.analysisControllerInstantiateAnalysisController}" action="#{currentControllerBean.instantiateAnalysis()}" update=":messages :tabView:currentViewLog" disabled="#{empty currentControllerBean.projectName}"/> <p:commandButton value="#{localizedControllerPageMessages.analysisControllerInstantiateAnalysisController}" action="#{currentControllerBean.instantiateAnalysis()}" update=":messages :currentViewLog" disabled="#{empty currentControllerBean.projectName}"/>
<p:commandButton value="#{localizedControllerPageMessages.analysisControllerCleaAnalysisController}" action="#{currentControllerBean.cleanAnalysis()}" update=":messages :tabView:currentViewLog" disabled="#{empty currentControllerBean.projectName}"/> <p:commandButton value="#{localizedControllerPageMessages.analysisControllerCleaAnalysisController}" action="#{currentControllerBean.cleanAnalysis()}" update=":messages :currentViewLog" disabled="#{empty currentControllerBean.projectName}"/>
<p:commandButton value="#{localizedControllerPageMessages.analysisControllerStartAnalysis}" action="#{currentControllerBean.startAnalysis()}" update=":messages :tabView:currentViewLog" disabled="#{empty currentControllerBean.projectName}"/> <p:commandButton value="#{localizedControllerPageMessages.analysisControllerStartAnalysis}" action="#{currentControllerBean.startAnalysis()}" update=":messages :currentViewLog" disabled="#{empty currentControllerBean.projectName}"/>
<p:commandButton value="#{localizedControllerPageMessages.analysisControllerStopAnalysis}" action="#{currentControllerBean.stopAnalysis()}" update=":messages :tabView:currentViewLog" disabled="#{empty currentControllerBean.projectName}"/> <p:commandButton value="#{localizedControllerPageMessages.analysisControllerStopAnalysis}" action="#{currentControllerBean.stopAnalysis()}" update=":messages :currentViewLog" disabled="#{empty currentControllerBean.projectName}"/>
</h:panelGrid> </h:panelGrid>
<p:poll interval="1" update=":ledsForm :tabView:analysisControllerLog"/> <p:poll interval="1" update=":ledsForm :analysisControllerLog"/>
</div> </div>
</h:form> </h:form>
</p:layoutUnit> </p:layoutUnit>
... ...
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
<p:menuitem styleClass="element-with-whitespace" icon="ui-icon-importProject" value=" #{localizedProjectOverviewMessages.importProject}" onclick="importProjectDialog.show()" ajax="true"/> <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-importProject" value=" #{localizedProjectOverviewMessages.importProject}" onclick="importProjectDialog.show()" ajax="true"/>
<p:separator/> <p:separator/>
</c:if> </c:if>
<p:menuitem styleClass="element-with-whitespace" icon="ui-icon-reload" value=" #{localizedProjectOverviewMessages.refreshProjectsList}" update=":projectsListForm" action="#{currentProjectOverviewBean.updateLists()}" ajax="true"/> <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-reload" value=" #{localizedProjectOverviewMessages.refreshProjectsList}" update=":projectsListForm" action="#{currentProjectOverviewBean.updateAvailableProjects()}" ajax="true"/>
<p:separator/> <p:separator/>
<p:menuitem styleClass="element-with-whitespace" icon="ui-icon-settings" value=" #{localizedMessages.settings}" onclick="settingsDlg.show()" ajax="true"/> <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-settings" value=" #{localizedMessages.settings}" onclick="settingsDlg.show()" ajax="true"/>
</p:submenu> </p:submenu>
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
<h:form id="projectsListForm"> <h:form id="projectsListForm">
<p:dataTable emptyMessage="#{localizedMessages.noRecordsFound}" rows="15" paginator="true" paginatorPosition="both" var="project" rowsPerPageTemplate="5,10,15,25,50" value="#{currentProjectOverviewBean.projects}" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" selection="#{currentProjectOverviewBean.projectName}" rowKey="#{project}" selectionMode="single"> <p:dataTable emptyMessage="#{localizedMessages.noRecordsFound}" rows="15" paginator="true" paginatorPosition="both" var="project" rowsPerPageTemplate="5,10,15,25,50" value="#{currentProjectOverviewBean.projects}" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" selection="#{currentProjectOverviewBean.projectName}" rowKey="#{project}" selectionMode="single">
<!-- Makes sure that rows are selected instantaneously. --> <!-- Makes sure that rows are selected instantaneously. -->
<p:ajax event="rowSelect" listener="#{currentProjectOverviewBean.onRowSelect}" update=":menuForm" /> <p:ajax event="rowSelect" listener="#{currentProjectOverviewBean.rowSelectHandler}" update=":menuForm" />
<p:column headerText="#{localizedProjectOverviewMessages.projectName}" id="modelHeader" sortBy="#{project}"> <p:column headerText="#{localizedProjectOverviewMessages.projectName}" id="modelHeader" sortBy="#{project}">
<p:commandLink id="dynaButton" value="#{project}"/> <p:commandLink id="dynaButton" value="#{project}"/>
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment