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
No related branches found
No related tags found
No related merge requests found
......@@ -107,7 +107,7 @@ public class ProjectsBean {
// Inform the user
GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_INFO, this.globalPropertiesBean.getMsgProjectCreated());
// Update the list of the "calling" bean
currentProjectOverviewBean.updateLists();
currentProjectOverviewBean.updateAvailableProjects();
} catch (final IOException ex) {
ProjectsBean.LOG.error("An error occured while creating the project.", ex);
GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_ERROR, "An error occured while creating the project.");
......@@ -129,7 +129,7 @@ public class ProjectsBean {
// Inform the user
GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_INFO, this.globalPropertiesBean.getMsgProjectDeleted());
// Update the list of the "calling" bean
currentProjectOverviewBean.updateLists();
currentProjectOverviewBean.updateAvailableProjects();
} catch (final IOException ex) {
ProjectsBean.LOG.error("An error occured while removing the project.", ex);
GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_ERROR, "An error occured while removing the project.");
......@@ -162,7 +162,7 @@ public class ProjectsBean {
// Inform the user
GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_INFO, this.globalPropertiesBean.getMsgProjectCreated());
// Update the list of the "calling" bean
currentProjectOverviewBean.updateLists();
currentProjectOverviewBean.updateAvailableProjects();
} catch (final IOException ex) {
ProjectsBean.LOG.error("An error occured while creating the project.", ex);
GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_ERROR, "An error occured while creating the project.");
......@@ -198,7 +198,7 @@ public class ProjectsBean {
// Inform the user
GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_INFO, "Project imported.");
// Update the list of the "calling" bean
currentProjectOverviewBean.updateLists();
currentProjectOverviewBean.updateAvailableProjects();
} catch (final IOException ex) {
ProjectsBean.LOG.error("An error occured while importing the project.", ex);
GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_ERROR, "An error occured while importing the project.");
......
......@@ -17,9 +17,6 @@
package kieker.webgui.web.beans.view;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
......@@ -38,7 +35,6 @@ import org.springframework.context.annotation.Scope;
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
* 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 {
private static final Log LOG = LogFactory.getLog(CurrentControllerBean.class);
private final List<String> logEntries = new ArrayList<String>();
private String projectName;
@Autowired
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>
*/
......@@ -82,10 +78,10 @@ public class CurrentControllerBean {
this.projectService.startAnalysis(this.projectName);
} catch (final InvalidAnalysisStateException 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) {
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 {
}
} catch (final InvalidAnalysisStateException 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) {
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 {
this.projectService.initializeAnalysis(this.projectName, this.projectService.getClassLoader(this.projectName, this)); // NOPMD (ClassLoader)
} catch (final InvalidAnalysisStateException 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) {
CurrentControllerBean.LOG.info("The project does not exist.", ex);
this.addLogEntry(ex);
this.addLogEntry("The project does not exist.");
} catch (final IOException 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) {
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 {
this.projectService.cleanAnalysis(this.projectName);
} catch (final ProjectNotExistingException ex) {
CurrentControllerBean.LOG.info("The project does not exist.", ex);
this.addLogEntry(ex);
this.addLogEntry("The project does not exist.");
} catch (final InvalidAnalysisStateException 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 {
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.
*
......
......@@ -20,6 +20,7 @@ import java.util.Collections;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.context.FacesContext;
import kieker.webgui.web.beans.application.ProjectsBean;
......@@ -41,54 +42,56 @@ import org.springframework.stereotype.Component;
@Scope("view")
public class CurrentProjectOverviewBean {
private List<String> projects = Collections.emptyList();
private String projectName;
private List<String> availableProjects;
private String selectedProjectName;
@Autowired
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() {
// 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
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
* The select event.
*/
public void onRowSelect(final SelectEvent event) {
public void rowSelectHandler(final SelectEvent event) {
this.setProjectName((String) event.getObject());
}
/**
* Updates the list containing the available projects name.
* Updates the list with the available availableProjects.
*/
public void updateLists() {
this.projects = this.projectsBean.getProjects();
public void updateAvailableProjects() {
this.availableProjects = this.projectsBean.getProjects();
}
public String getProjectName() {
return this.projectName;
public List<String> getProjects() {
return this.availableProjects;
}
public void setProjectName(final String projectName) {
this.projectName = projectName;
public String getProjectName() {
return this.selectedProjectName;
}
public List<String> getProjects() {
return this.projects;
public void setProjectName(final String projectName) {
this.selectedProjectName = projectName;
}
}
@charset "UTF-8";
\ No newline at end of file
@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 @@
<p:tab title="#{localizedMessages.analysisEditor}">
<h:panelGrid columns="2" cellpadding="10" columnClasses="rightAlignedColumn, normalColumn">
<h:outputText value="#{localizedMessages.toolPalette}:"/>
<p:selectOneMenu style="width: 100%">
<p:selectOneMenu style="width: 100%" disabled="true">
<f:selectItem itemLabel="#{localizedMessages.lists}"/>
</p:selectOneMenu>
......
......@@ -42,22 +42,25 @@
<ui:define name="centerContent">
<p:tabView id="tabView" style="height: 99%" >
<p:tab title="#{localizedControllerPageMessages.personalLog}" >
<h:form id="currentViewLog">
<ui:repeat value="#{currentControllerBean.viewLog}" var="entry" varStatus="stat">
<h:outputText value="#{entry}"/><ui:fragment rendered="#{not stat.last}"><br/><br/></ui:fragment>
</ui:repeat>
<h:panelGrid columns="2" columnClasses="col1 , col2" cellpadding="5" style="width: 99%; height: 100%">
<p:panel style="width: 100%; height:100%" header="#{localizedControllerPageMessages.personalLog}" >
<h:form id="currentViewLog" style="width: 100%">
<p:dataList value="#{currentControllerBean.viewLog}" var="logEntry">
#{logEntry}
</p:dataList>
</h:form>
</p:tab>
<p:tab title="#{localizedControllerPageMessages.analysisControllerLog}">
<h:form id="analysisControllerLog">
<ui:repeat value="#{currentControllerBean.analysisLog}" var="entry" varStatus="stat">
<h:outputText value="#{entry}"/><ui:fragment rendered="#{not stat.last}"><br/><br/></ui:fragment>
</ui:repeat>
</p:panel>
<p:panel style="width: 100%; height:100%" header="#{localizedControllerPageMessages.analysisControllerLog}" collapsed="true">
<h:form id="analysisControllerLog" style="width: 100%">
<p:dataList value="#{currentControllerBean.analysisLog}" var="logEntry">
#{logEntry}
</p:dataList>
</h:form>
</p:tab>
</p:tabView>
</p:panel>
</h:panelGrid>
</ui:define>
<ui:define name="furtherLayoutUnits">
......@@ -66,16 +69,16 @@
<h:form id="controllerForm">
<div align="center">
<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>
<p:poll interval="1" update=":ledsForm :tabView:analysisControllerLog"/>
<p:poll interval="1" update=":ledsForm :analysisControllerLog"/>
</div>
</h:form>
</p:layoutUnit>
......
......@@ -33,7 +33,7 @@
<p:menuitem styleClass="element-with-whitespace" icon="ui-icon-importProject" value=" #{localizedProjectOverviewMessages.importProject}" onclick="importProjectDialog.show()" ajax="true"/>
<p:separator/>
</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:menuitem styleClass="element-with-whitespace" icon="ui-icon-settings" value=" #{localizedMessages.settings}" onclick="settingsDlg.show()" ajax="true"/>
</p:submenu>
......@@ -43,7 +43,7 @@
<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">
<!-- 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:commandLink id="dynaButton" value="#{project}"/>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment