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

Continued with the upload-functionality.

parent 1a262727
Branches
Tags
No related merge requests found
...@@ -9,6 +9,7 @@ import javax.faces.bean.ManagedBean; ...@@ -9,6 +9,7 @@ import javax.faces.bean.ManagedBean;
import kieker.analysis.model.analysisMetaModel.MIDependency; import kieker.analysis.model.analysisMetaModel.MIDependency;
import kieker.analysis.model.analysisMetaModel.impl.MAnalysisMetaModelFactory; import kieker.analysis.model.analysisMetaModel.impl.MAnalysisMetaModelFactory;
import kieker.webgui.common.FileManager; import kieker.webgui.common.FileManager;
import org.primefaces.model.UploadedFile;
@ManagedBean @ManagedBean
@ApplicationScoped @ApplicationScoped
...@@ -25,4 +26,16 @@ public class AvailableDependenciesBean { ...@@ -25,4 +26,16 @@ public class AvailableDependenciesBean {
public List<MIDependency> getDependencies() { public List<MIDependency> getDependencies() {
return dependencies; return dependencies;
} }
public void upload(final UploadedFile file) {
FileManager.getInstance().uploadDependency(file);
this.dependencies.clear();
this.dependencies.addAll(FileManager.getInstance().loadAllDependencies());
}
public void delete(final MIDependency dependency) {
FileManager.getInstance().deleteDependency(dependency);
this.dependencies.clear();
this.dependencies.addAll(FileManager.getInstance().loadAllDependencies());
}
} }
...@@ -28,8 +28,6 @@ public class DependencyUploadController { ...@@ -28,8 +28,6 @@ public class DependencyUploadController {
} }
public void upload() { public void upload() {
FacesMessage msg = new FacesMessage("Succesful", file.getFileName() + " is uploaded."); FileManager.getInstance().uploadDependency(file);
FacesContext.getCurrentInstance().addMessage(null, msg);
// FileManager.getInstance().uploadDependency(file);
} }
} }
...@@ -6,6 +6,7 @@ import java.io.IOException; ...@@ -6,6 +6,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import org.primefaces.model.UploadedFile; import org.primefaces.model.UploadedFile;
...@@ -172,7 +173,6 @@ public final class FileManager { ...@@ -172,7 +173,6 @@ public final class FileManager {
* @return true iff the file has been uploaded successfully. * @return true iff the file has been uploaded successfully.
*/ */
public boolean uploadDependency(final UploadedFile file) { public boolean uploadDependency(final UploadedFile file) {
System.out.println(file);
final File depFile = new File(LIB_DIR, file.getFileName()); final File depFile = new File(LIB_DIR, file.getFileName());
InputStream in = null; InputStream in = null;
...@@ -245,4 +245,11 @@ public final class FileManager { ...@@ -245,4 +245,11 @@ public final class FileManager {
return resultList; return resultList;
} }
public void deleteDependency(final MIDependency dependency) {
File file = new File(dependency.getFilePath());
if (file.isFile()) {
file.delete();
}
}
} }
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
http://ocpsoft.com/xml/ns/prettyfaces/ocpsoft-pretty-faces-3.3.2.xsd"> http://ocpsoft.com/xml/ns/prettyfaces/ocpsoft-pretty-faces-3.3.2.xsd">
<url-mapping id="home"> <url-mapping id="home">
<pattern value="/Kieker.WebGUI" /> <pattern value="/Kieker.WebGUI/main" />
<view-id value="/faces/main.xhtml" /> <view-id value="/faces/main.xhtml" />
</url-mapping> </url-mapping>
... ...
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<f:view contentType="text/html"> <f:view contentType="text/html">
<h:head> <h:head>
<title>Kieker.WebGUI</title> <title>Kieker.WebGUI</title>
<link rel="stylesheet" type="text/css" href="main.css" /> <link rel="stylesheet" type="text/css" href="../main.css" />
</h:head> </h:head>
<h:body> <h:body>
... ...
......
...@@ -8,6 +8,19 @@ ...@@ -8,6 +8,19 @@
font-size: 5px; font-size: 5px;
} }
.ui-layout-center {
font-size: 15px;
}
.ui-layout-north {
font-size: 15px;
}
.ui-layout-south {
font-size: 15px;
}
.ui-datatable { .ui-datatable {
font-size: 15px; font-size: 15px;
} }
... ...
......
...@@ -10,42 +10,26 @@ ...@@ -10,42 +10,26 @@
<title>Kieker.WebGUI - Dependencies</title> <title>Kieker.WebGUI - Dependencies</title>
<link rel="stylesheet" type="text/css" href="../manageDependencies.css" /> <link rel="stylesheet" type="text/css" href="../manageDependencies.css" />
</h:head> </h:head>
<h:body> <h:body>
<p:layout fullPage="true">
<p:layoutUnit header="Navigation" position="north" collapsible="true" resizable="true">
<!-- The control panel to get back. --> <!-- The control panel to get back. -->
<p:panel>
<h:form> <h:form>
<p:commandButton icon="ui-icon-circle-arrow-w" value="Mainmenu"/> Click
</h:form> <p:commandLink ajax="false" action="/main">
</p:panel> <h:outputText value="here" />
</p:commandLink>
<p:spacer height="20px"/> to get back to the main menu.
<!-- This is the form for the uploading. -->
<p:panel header="Upload Dependencies">
<h:outputText value="Currently only *.jar-Dependencies can be uploaded. The maximal file size is limited to 100 [MiByte]." />
<br />
<br />
<h:form enctype="multipart/form-data">
<p:fileUpload value="#{dependencyUploadController.file}"
allowTypes="/(\.|\/)(jar)$/"
sizeLimit="104857600"
mode="simple" />
<br />
<br />
<p:commandButton value="Upload" ajax="true"
actionListener="#{dependencyUploadController.upload}" />
</h:form> </h:form>
</p:panel> </p:layoutUnit>
<p:spacer height="20px"/>
<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>
<p:dataTable id="currentDependencies" value="#{availableDependenciesBean.dependencies}" var="dependency" paginator="true" rows="10" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="5,10,15"> <p:dataTable id="currentDependencies" value="#{availableDependenciesBean.dependencies}" var="dependency" paginator="true" rows="10" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" >
<f:facet name="header">
Currently available Dependencies
</f:facet>
<p:column> <p:column>
<f:facet name="header"> <f:facet name="header">
Filename Filename
...@@ -59,20 +43,42 @@ ...@@ -59,20 +43,42 @@
<f:facet name="header"> <f:facet name="header">
Size Size
</f:facet> </f:facet>
<center> <div align="center">
<h:outputText value="#{dependency}" > <h:outputText value="#{dependency}" >
<f:converter converterId="kieker.webgui.converter.MIDependencyToIntConverter" /> <f:converter converterId="kieker.webgui.converter.MIDependencyToIntConverter" />
</h:outputText> </h:outputText>
</center> </div>
</p:column> </p:column>
<p:column style="width:40px"> <p:column style="width:40px">
<center> <div align="center">
<p:commandButton icon="ui-icon-trash" title="Delete"/> <p:commandButton icon="ui-icon-trash" title="Delete" action="{availableDependenciesBean(dependency)}"/>
</center> </div>
</p:column> </p:column>
</p:dataTable> </p:dataTable>
</h:form> </h:form>
</p:layoutUnit>
<p:layoutUnit header="Upload Dependencies" position="south" collapsible="true" resizable="true">
<!-- This is the form for the uploading. -->
<h:outputText value="Currently only *.jar-Dependencies can be uploaded. The maximal file size is limited to 100 [MiByte]." />
<br />
<br />
<h:form enctype="multipart/form-data">
<p:fileUpload value="#{dependencyUploadController.file}"
allowTypes="/(\.|\/)(jar)$/"
sizeLimit="104857600"
mode="simple" />
<p:spacer width ="50px" height="0px"/>
<p:commandLink ajax="false" actionListener="#{dependencyUploadController.upload}">
<h:outputText value="Upload File" />
</p:commandLink>
</h:form>
</p:layoutUnit>
</p:layout>
</h:body> </h:body>
</f:view> </f:view>
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment