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

Checkstyle; Corrected some bugs; Continued with the uploading-functionality

parent d8e0dd4a
No related branches found
No related tags found
No related merge requests found
Showing
with 254 additions and 13 deletions
...@@ -36,22 +36,51 @@ public class AvailableDependenciesBean { ...@@ -36,22 +36,51 @@ public class AvailableDependenciesBean {
private final List<MIDependency> dependencies; private final List<MIDependency> dependencies;
/**
* Creates a new instance of this class.
*/
public AvailableDependenciesBean() { public AvailableDependenciesBean() {
this.dependencies = FileManager.getInstance().loadAllDependencies(); this.dependencies = FileManager.getInstance().loadAllDependencies();
} }
/**
* Delivers the currently available dependencies as a list.
*
* @return All available dependencies.
*/
public List<MIDependency> getDependencies() { public List<MIDependency> getDependencies() {
return this.dependencies; return this.dependencies;
} }
public void upload(final UploadedFile file) { /**
* Tries to upload a given file as a new dependency. If the dependency does already exist, it will be overwritten.
*
* @param file
* The file to be uploaded.
*/
public void uploadDependency(final UploadedFile file) {
final MIDependency dependency = FileManager.getInstance().uploadDependency(file); final MIDependency dependency = FileManager.getInstance().uploadDependency(file);
if (dependency != null) { if (dependency != null) {
/*
* Is is possible that we already have a dependency with the same name and have to remove it first.
*/
for (final MIDependency dep : this.dependencies) {
if (dep.getFilePath().equals(dependency.getFilePath())) {
this.dependencies.remove(dep);
break;
}
}
this.dependencies.add(dependency); this.dependencies.add(dependency);
} }
} }
public void delete(final MIDependency dependency) { /**
* Tries to delete a given dependency.
*
* @param dependency
* The dependency to be removed.
*/
public void deleteDependency(final MIDependency dependency) {
final boolean result = FileManager.getInstance().deleteDependency(dependency); final boolean result = FileManager.getInstance().deleteDependency(dependency);
if (result) { if (result) {
this.dependencies.remove(dependency); this.dependencies.remove(dependency);
......
...@@ -45,11 +45,21 @@ public class AvailableProjectsBean { ...@@ -45,11 +45,21 @@ public class AvailableProjectsBean {
private final List<MIProject> projects; private final List<MIProject> projects;
private final MAnalysisMetaModelFactory factory; private final MAnalysisMetaModelFactory factory;
/**
* Creates a new instance of this class.
*/
public AvailableProjectsBean() { public AvailableProjectsBean() {
this.projects = FileManager.getInstance().loadAllProjects(); this.projects = FileManager.getInstance().loadAllProjects();
this.factory = new MAnalysisMetaModelFactory(); this.factory = new MAnalysisMetaModelFactory();
} }
/**
* Uses the given name to create a new project. If a project with the same
* name does already exist, nothing happens.
*
* @param projectName
* The name of the new project.
*/
public synchronized void addProject(final String projectName) { public synchronized void addProject(final String projectName) {
/* /*
* Create a new project. * Create a new project.
...@@ -68,7 +78,7 @@ public class AvailableProjectsBean { ...@@ -68,7 +78,7 @@ public class AvailableProjectsBean {
final FacesContext context = FacesContext.getCurrentInstance(); final FacesContext context = FacesContext.getCurrentInstance();
final SelectedProjectBean bean = context.getApplication().evaluateExpressionGet(context, "#{selectedProjectBean}", final SelectedProjectBean bean = context.getApplication().evaluateExpressionGet(context, "#{selectedProjectBean}",
SelectedProjectBean.class); SelectedProjectBean.class);
if (bean.getMainProject() == null) { if (bean != null && bean.getMainProject() == null) {
bean.setMainProject(project); bean.setMainProject(project);
} }
...@@ -76,7 +86,11 @@ public class AvailableProjectsBean { ...@@ -76,7 +86,11 @@ public class AvailableProjectsBean {
} }
} }
@SuppressWarnings("unused") /**
* Delivers the currently available projects as a tree root.
*
* @returns The root of the currently available projects.
*/
public synchronized TreeNode getProjectsRoot() { public synchronized TreeNode getProjectsRoot() {
final TreeNode root = new DefaultTreeNode("Root", null); final TreeNode root = new DefaultTreeNode("Root", null);
......
/***************************************************************************
* Copyright 2012 by
* + Christian-Albrechts-University of Kiel
* + Department of Computer Science
* + Software Engineering Group
* and others.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/
/**
* This package contains all beans with application scope.
*/
package kieker.webgui.beans.application;
...@@ -34,6 +34,9 @@ public class SelectedDependenciesBean { ...@@ -34,6 +34,9 @@ public class SelectedDependenciesBean {
private DualListModel<String> dependencies; private DualListModel<String> dependencies;
/**
* Creates a new instance of this class.
*/
public SelectedDependenciesBean() { public SelectedDependenciesBean() {
final List<String> source = new ArrayList<String>(); final List<String> source = new ArrayList<String>();
final List<String> target = new ArrayList<String>(); final List<String> target = new ArrayList<String>();
...@@ -44,10 +47,21 @@ public class SelectedDependenciesBean { ...@@ -44,10 +47,21 @@ public class SelectedDependenciesBean {
this.dependencies = new DualListModel<String>(source, target); this.dependencies = new DualListModel<String>(source, target);
} }
/**
* Delivers the stored dependencies within this bean.
*
* @return The dependencies dual model.
*/
public DualListModel<String> getDependencies() { public DualListModel<String> getDependencies() {
return this.dependencies; return this.dependencies;
} }
/**
* Sets the dependencies to be stored within this bean to a new value.
*
* @param dependencies
* The new dependencies dual model.
*/
public void setDependencies(final DualListModel<String> dependencies) { public void setDependencies(final DualListModel<String> dependencies) {
this.dependencies = dependencies; this.dependencies = dependencies;
} }
......
/***************************************************************************
* Copyright 2012 by
* + Christian-Albrechts-University of Kiel
* + Department of Computer Science
* + Software Engineering Group
* and others.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/
/**
* This package contains all beans with request scope.
*/
package kieker.webgui.beans.request;
...@@ -22,8 +22,9 @@ package kieker.webgui.beans.session; ...@@ -22,8 +22,9 @@ package kieker.webgui.beans.session;
import javax.faces.bean.ManagedBean; import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped; import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import kieker.webgui.common.FileManager; import kieker.webgui.beans.application.AvailableDependenciesBean;
import org.primefaces.model.UploadedFile; import org.primefaces.model.UploadedFile;
...@@ -42,15 +43,36 @@ public class DependencyUploadController { ...@@ -42,15 +43,36 @@ public class DependencyUploadController {
*/ */
public DependencyUploadController() {} public DependencyUploadController() {}
/**
* Delivers the instance stored within this bean.
*
* @return The currently stored value within this bean.
*/
public UploadedFile getFile() { public UploadedFile getFile() {
return this.file; return this.file;
} }
/**
* Sets the new value of the bean.
*
* @param file
* The file instance to be stored within this bean.
*/
public void setFile(final UploadedFile file) { public void setFile(final UploadedFile file) {
this.file = file; this.file = file;
} }
/**
* Tries to upload the currently stored value within this bean.
*/
public void upload() { public void upload() {
FileManager.getInstance().uploadDependency(this.file); if (this.file != null) {
final FacesContext context = FacesContext.getCurrentInstance();
final AvailableDependenciesBean bean = context.getApplication().evaluateExpressionGet(context, "#{availableDependenciesBean}",
AvailableDependenciesBean.class);
if (bean != null) {
bean.uploadDependency(this.file);
}
}
} }
} }
...@@ -24,6 +24,7 @@ import javax.faces.bean.SessionScoped; ...@@ -24,6 +24,7 @@ import javax.faces.bean.SessionScoped;
import kieker.analysis.model.analysisMetaModel.MIProject; import kieker.analysis.model.analysisMetaModel.MIProject;
import org.primefaces.event.NodeSelectEvent;
import org.primefaces.model.DefaultTreeNode; import org.primefaces.model.DefaultTreeNode;
import org.primefaces.model.TreeNode; import org.primefaces.model.TreeNode;
...@@ -82,6 +83,10 @@ public class SelectedProjectBean { ...@@ -82,6 +83,10 @@ public class SelectedProjectBean {
return this.selectedNode; return this.selectedNode;
} }
public void onNodeSelect(final NodeSelectEvent event) {
this.setSelectedNode(event.getTreeNode());
}
public void setSelectedNode(final TreeNode selectedNode) { public void setSelectedNode(final TreeNode selectedNode) {
this.selectedNode = selectedNode; this.selectedNode = selectedNode;
if (selectedNode != null && selectedNode.getData() instanceof MIProject) { if (selectedNode != null && selectedNode.getData() instanceof MIProject) {
...@@ -91,6 +96,15 @@ public class SelectedProjectBean { ...@@ -91,6 +96,15 @@ public class SelectedProjectBean {
} }
} }
/**
* Delivers the "font weight" (whether the font is bold or normal) for a
* given project. This can be especially be used to mark a selected main
* project.
*
* @param project
* The project to be checked.
* @return "bold" if the given project is the current main project, "normal" otherwise.
*/
public String getFontWeight(final MIProject project) { public String getFontWeight(final MIProject project) {
if (project == this.mainProject) { if (project == this.mainProject) {
return "bold"; return "bold";
......
/***************************************************************************
* Copyright 2012 by
* + Christian-Albrechts-University of Kiel
* + Department of Computer Science
* + Software Engineering Group
* and others.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/
/**
* This package contains all beans with session scope.
*/
package kieker.webgui.beans.session;
...@@ -59,11 +59,17 @@ public final class FileManager { ...@@ -59,11 +59,17 @@ public final class FileManager {
private static final FileManager INSTANCE = new FileManager(); private static final FileManager INSTANCE = new FileManager();
private final MAnalysisMetaModelFactory factory; private final MAnalysisMetaModelFactory factory;
/**
* Creates a new instance of this class.
*/
private FileManager() { private FileManager() {
this.checkAndCreateDirectories(); this.checkAndCreateDirectories();
this.factory = new MAnalysisMetaModelFactory(); this.factory = new MAnalysisMetaModelFactory();
} }
/**
* Checks whether all directories are available and creates them if necessary.
*/
private synchronized void checkAndCreateDirectories() { private synchronized void checkAndCreateDirectories() {
/* /*
* Make sure that the directories exist and create them if necessary. * Make sure that the directories exist and create them if necessary.
...@@ -129,7 +135,6 @@ public final class FileManager { ...@@ -129,7 +135,6 @@ public final class FileManager {
*/ */
public synchronized boolean saveNewProject(final MIProject project) { public synchronized boolean saveNewProject(final MIProject project) {
final String projectName = project.getName(); final String projectName = project.getName();
final File dirProject = new File(FileManager.PROJECT_DIR + File.separator + projectName); final File dirProject = new File(FileManager.PROJECT_DIR + File.separator + projectName);
/* /*
...@@ -250,6 +255,11 @@ public final class FileManager { ...@@ -250,6 +255,11 @@ public final class FileManager {
return FileManager.INSTANCE; return FileManager.INSTANCE;
} }
/**
* This method tries to load all available dependencies from the file system.
*
* @return A list containing all available dependencies. If there are no files, an empty list will be returned.
*/
public List<MIDependency> loadAllDependencies() { public List<MIDependency> loadAllDependencies() {
final List<MIDependency> resultList = new ArrayList<MIDependency>(); final List<MIDependency> resultList = new ArrayList<MIDependency>();
/* /*
...@@ -271,6 +281,13 @@ public final class FileManager { ...@@ -271,6 +281,13 @@ public final class FileManager {
return resultList; return resultList;
} }
/**
* Tries to delete a given dependency.
*
* @param dependency
* The dependency to be removed.
* @return true iff the dependency exists and the removal was succesful.
*/
public boolean deleteDependency(final MIDependency dependency) { public boolean deleteDependency(final MIDependency dependency) {
final File file = new File(dependency.getFilePath()); final File file = new File(dependency.getFilePath());
if (file.isFile()) { if (file.isFile()) {
......
/***************************************************************************
* Copyright 2012 by
* + Christian-Albrechts-University of Kiel
* + Department of Computer Science
* + Software Engineering Group
* and others.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/
/**
* This package contains all classes with general and common purpose.
*/
package kieker.webgui.common;
/***************************************************************************
* Copyright 2012 by
* + Christian-Albrechts-University of Kiel
* + Department of Computer Science
* + Software Engineering Group
* and others.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/
/**
* This package contains all converters used within the project.
*/
package kieker.webgui.converter;
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<h:body> <h:body>
<!-- This is the layout for the whole page. --> <!-- This is the layout for the whole page. -->
<p:layout fullPage="true"> <p:layout id="layout" fullPage="true">
<!-- ******************************************************************************** --> <!-- ******************************************************************************** -->
<!-- This is the top unit within the layout and is used for the menu bar. --> <!-- This is the top unit within the layout and is used for the menu bar. -->
...@@ -34,7 +34,9 @@ ...@@ -34,7 +34,9 @@
<!-- This is the submenu for the current project, for example if someone doesn't want to use the context menu within the browser. --> <!-- This is the submenu for the current project, for example if someone doesn't want to use the context menu within the browser. -->
<p:submenu label="Current Project"> <p:submenu label="Current Project">
<p:menuitem value="Save Project" ajax="true" /> <p:menuitem value="Save Project" ajax="true" />
<p:menuitem value="Set as Main Project" ajax="true" /> <p:menuitem value="Set as Main Project" ajax="true"
action="#{selectedProjectBean.setMainProject(selectedProjectBean.getSelectedProject())}"
update="projectsForm" />
<p:separator /> <p:separator />
<p:menuitem value="Delete Project" ajax="true" /> <p:menuitem value="Delete Project" ajax="true" />
...@@ -57,12 +59,13 @@ ...@@ -57,12 +59,13 @@
<!-- ******************************************************************************** --> <!-- ******************************************************************************** -->
<!-- The following layout is at the left side of the page and shows the available projects. --> <!-- The following layout is at the left side of the page and shows the available projects. -->
<p:layoutUnit header="Projects" collapsible="true" position="west" <p:layoutUnit id="projectsLayout" header="Projects" collapsible="true" position="west"
size="200" resizable="true" minSize="100"> size="200" resizable="true" minSize="100">
<h:form id="projectsForm"> <h:form id="projectsForm">
<p:tree selection="#{selectedProjectBean.selectedNode}" <p:tree selection="#{selectedProjectBean.selectedNode}"
id="projectsTree" selectionMode="single" style="width: auto" id="projectsTree" selectionMode="single" style="width: auto"
value="#{availableProjectsBean.projectsRoot}" var="node"> value="#{availableProjectsBean.projectsRoot}" var="node">
<p:ajax event="select" listener="#{selectedProjectBean.onNodeSelect}"/>
<p:treeNode type="project"> <p:treeNode type="project">
<h:outputText <h:outputText
style="font-weight: #{selectedProjectBean.getFontWeight(node)}" style="font-weight: #{selectedProjectBean.getFontWeight(node)}"
...@@ -198,6 +201,7 @@ ...@@ -198,6 +201,7 @@
<br /> <br /> <br /> <br />
<p:commandButton value="Ok" <p:commandButton value="Ok"
action="#{availableProjectsBean.addProject(stringBean.string)}" action="#{availableProjectsBean.addProject(stringBean.string)}"
update="projectsForm"
oncomplete="newProjectDialog.hide()" /> oncomplete="newProjectDialog.hide()" />
<p:spacer width="100" height="10" /> <p:spacer width="100" height="10" />
<p:commandButton value="Cancel" onclick="newProjectDialog.hide()" /> <p:commandButton value="Cancel" onclick="newProjectDialog.hide()" />
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
<p:layoutUnit header="Currently available Dependencies" position="center" > <p:layoutUnit header="Currently available Dependencies" position="center" >
<!-- This form shows the currently available dependencies. --> <!-- This form shows the currently available dependencies. -->
<h:form> <h:form id="currentDependenciesForm">
<p:dataTable id="currentDependencies" value="#{availableDependenciesBean.dependencies}" var="dependency" paginator="true" rows="10" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" > <p:dataTable id="currentDependencies" value="#{availableDependenciesBean.dependencies}" var="dependency" paginator="true" rows="10" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" >
<p:column> <p:column>
...@@ -50,9 +50,12 @@ ...@@ -50,9 +50,12 @@
</div> </div>
</p:column> </p:column>
<p:column style="width:40px"> <p:column style="width:40px">
<f:facet name="header">
</f:facet>
<div align="center"> <div align="center">
<p:commandButton icon="ui-icon-trash" title="Delete" action="{availableDependenciesBean(dependency)}"/> <p:commandButton ajax="true" update="currentDependenciesForm" icon="ui-icon-trash" title="Delete"
action="#{availableDependenciesBean.deleteDependency(dependency)}"/>
</div> </div>
</p:column> </p:column>
</p:dataTable> </p:dataTable>
......
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