[jboss-cvs] JBoss Profiler SVN: r570 - in branches/JBossProfiler2: src/etc and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Oct 28 15:16:46 EDT 2009
Author: jesper.pedersen
Date: 2009-10-28 15:16:46 -0400 (Wed, 28 Oct 2009)
New Revision: 570
Modified:
branches/JBossProfiler2/.classpath
branches/JBossProfiler2/src/etc/faces-config.xml
branches/JBossProfiler2/src/main/org/jboss/profiler/client/web/BasicOptBean.java
branches/JBossProfiler2/src/main/www/index.xhtml
branches/JBossProfiler2/src/main/www/snapshotoperations.xhtml
Log:
[JBPROFILER-97] snapshotoperations.xhtml now functional
Modified: branches/JBossProfiler2/.classpath
===================================================================
--- branches/JBossProfiler2/.classpath 2009-10-28 17:05:08 UTC (rev 569)
+++ branches/JBossProfiler2/.classpath 2009-10-28 19:16:46 UTC (rev 570)
@@ -25,5 +25,6 @@
<classpathentry kind="var" path="ANT_HOME/lib/ant.jar"/>
<classpathentry kind="var" path="ANT_HOME"/>
<classpathentry kind="lib" path="lib/junit-4.4.jar"/>
+ <classpathentry kind="lib" path="lib/commons-io.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified: branches/JBossProfiler2/src/etc/faces-config.xml
===================================================================
--- branches/JBossProfiler2/src/etc/faces-config.xml 2009-10-28 17:05:08 UTC (rev 569)
+++ branches/JBossProfiler2/src/etc/faces-config.xml 2009-10-28 19:16:46 UTC (rev 570)
@@ -113,5 +113,12 @@
<to-view-id>/setup.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
+
+ <navigation-rule>
+ <navigation-case>
+ <from-outcome>go_snapshots</from-outcome>
+ <to-view-id>/snapshotoperations.xhtml</to-view-id>
+ </navigation-case>
+ </navigation-rule>
</faces-config>
Modified: branches/JBossProfiler2/src/main/org/jboss/profiler/client/web/BasicOptBean.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/client/web/BasicOptBean.java 2009-10-28 17:05:08 UTC (rev 569)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/client/web/BasicOptBean.java 2009-10-28 19:16:46 UTC (rev 570)
@@ -28,13 +28,17 @@
import org.jboss.profiler.shared.Visibility;
import java.io.File;
-import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
+import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
+import javax.servlet.http.HttpServletResponse;
+import org.apache.commons.io.FileUtils;
+
/**
* @author Huijuan Shao <hjshao at hitachi.cn>
*/
@@ -46,16 +50,14 @@
private String addClass = "";
private String visibility;
-
+
// private String removeClass="org.apache.jsp.*";
private String removeClass = "";
- private String selectSnapshot;
+ private String selectedSnapshot;
private String saveSnapshotName;
- private boolean panelShows = false;
-
private String saveEcho = "";
private String protocol = "socket";
@@ -70,20 +72,14 @@
private String plugin = "org.jboss.profiler.plugins.Hibernate";
- private String path = LoadSnapshotBean.class.getResource("/").getFile() +
- "../../files/";
-
private List<String> interceptClassList = new ArrayList<String>();
- private static List<Snapshot> snapshotsList = new ArrayList<Snapshot>();
+ private List<Snapshot> snapshotsList = new ArrayList<Snapshot>();
private org.jboss.remoting.InvokerLocator locator;
private org.jboss.remoting.Client remotingClient;
-
private Boolean connectionSuccessful;
-
-
/**
* Get latest opts
* @return The value
@@ -178,7 +174,7 @@
* Get snapshot list
* @return The value
*/
- public static List<Snapshot> getSnapshotsList()
+ public List<Snapshot> getSnapshotsList()
{
return snapshotsList;
}
@@ -187,27 +183,27 @@
* Set snapshot list
* @param snapshotsList The value
*/
- public static void setSnapshotsList(ArrayList<Snapshot> snapshotsList)
+ public void setSnapshotsList(ArrayList<Snapshot> snapshotsList)
{
- BasicOptBean.snapshotsList = snapshotsList;
+ this.snapshotsList = snapshotsList;
}
/**
* Get select snapshot
* @return The value
*/
- public String getSelectSnapshot()
+ public String getSelectedSnapshot()
{
- return selectSnapshot;
+ return selectedSnapshot;
}
/**
* Set select snapshot
- * @param selectSnapshot The value
+ * @param selectedSnapshot The value
*/
- public void setSelectSnapshot(String selectSnapshot)
+ public void setSelectedSnapshot(String selectedSnapshot)
{
- this.selectSnapshot = selectSnapshot;
+ this.selectedSnapshot = selectedSnapshot;
}
/**
@@ -246,25 +242,9 @@
BasicOptBean.digThreshold = digThreshold;
}
- /**
- * Is panels shown
- * @return The value
- */
- public boolean isPanelShows()
- {
- return panelShows;
- }
+
/**
- * Set panels shown
- * @param panelShows The value
- */
- public void setPanelShows(boolean panelShows)
- {
- this.panelShows = panelShows;
- }
-
- /**
* Get save echo
* @return The value
*/
@@ -395,10 +375,8 @@
Snapshot snapshot = (Snapshot)remotingClient.invoke(cmd);
if (snapshot != null)
{
- // SnapshotUtil su = new SnapshotUtil(new Double(threshold).doubleValue());
- BasicOptBean.snapshotsList.add(snapshot);
+ snapshotsList.add(snapshot);
}
-
remotingClient.disconnect();
}
@@ -421,7 +399,7 @@
this.snapshotsList.clear();
remotingClient.disconnect();
- this.setPanelShows(false);
+ selectedSnapshot = null;
}
/**
@@ -429,59 +407,67 @@
* @return all the snapshots string from the agent side
* @throws Throwable If an error occurs
*/
- public String[] getSnapshots() throws Throwable
+ public List<String> getSnapshots() throws Throwable
{
locator = new org.jboss.remoting.InvokerLocator(this.protocol +
- "://" + this.host + ":" + this.port);
+ "://" + this.host + ":" + this.port);
+
remotingClient = new org.jboss.remoting.Client(locator);
remotingClient.connect();
Command cmd = new Command(CommandType.LIST_SNAPSHOTS);
String[] snapshots = (String[])remotingClient.invoke(cmd);
remotingClient.disconnect();
- return snapshots;
+
+ return Arrays.asList(snapshots);
}
- /**
- * Select snapshot action
- */
- public void selectSnapshotAction()
- {
- this.setPanelShows(true);
- }
/**
- * Select save snapshot action
+ * sends the snapshot file to browser
* @throws Throwable If an error occurs
*/
- public void selectSaveSnapshotAction() throws Throwable
+ public void saveSnapshot() throws Throwable
{
- String[] snapshots = this.getSnapshots();
- int k = 0;
- for (int i = 0; i < snapshots.length; i++)
- {
- if (snapshots[i].equals(this.selectSnapshot))
- k = i;
- }
- Snapshot selectSnapshot1 = (Snapshot)this.snapshotsList.get(k);
+
+
+ Snapshot snapshot = snapshotsList.get(getSnapshots().indexOf(selectedSnapshot));
+
+ File fileToSend = new File(SnapshotHelper.getName(snapshot));
+
try
{
- if (this.saveSnapshotName == null ||
- this.saveSnapshotName.trim().equals(""))
- SnapshotHelper.save(selectSnapshot1, new File(path +
- SnapshotHelper.getName(selectSnapshot1) + ".jps"));
- else
- SnapshotHelper.save(selectSnapshot1, new File(path +
- this.saveSnapshotName));
-
- this.saveEcho = "snapshot " +
- this.saveSnapshotName + " is just saved!";
+ SnapshotHelper.save(snapshot, fileToSend);
+
+ this.saveSnapshotName = this.saveSnapshotName == null || this.saveSnapshotName.trim().length() == 0 ?
+ fileToSend.getName() : this.saveSnapshotName;
+
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
+ response.setHeader("Content-disposition", "attachment; filename=" + this.saveSnapshotName + ".jps");
+ response.setContentType("application/zip");
+
+ response.getOutputStream().write(FileUtils.readFileToByteArray(fileToSend));
+ response.flushBuffer();
+ response.getOutputStream().close();
+ facesContext.responseComplete();
+
this.saveSnapshotName = "";
}
- catch (IOException e)
+ finally
{
- e.printStackTrace();
+ fileToSend.delete();
}
+
}
+ /**
+ * selects a snapshot
+ */
+ public void selectSnapshot()
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ selectedSnapshot = (String)facesContext.getApplication()
+ .getVariableResolver().resolveVariable(facesContext, "snapshot");
+ }
/**
* Get visibilities
Modified: branches/JBossProfiler2/src/main/www/index.xhtml
===================================================================
--- branches/JBossProfiler2/src/main/www/index.xhtml 2009-10-28 17:05:08 UTC (rev 569)
+++ branches/JBossProfiler2/src/main/www/index.xhtml 2009-10-28 19:16:46 UTC (rev 570)
@@ -24,10 +24,15 @@
<h:commandLink value="Setup" action="go_setup"/>
</h:panelGrid>
<h:panelGrid columns="1" width="100%">
- Profiler
+ <f:subview>
+ Profiler
+ <h:commandLink value="Start" action="#{basicOptBean.clickStart}"/>
+ /
+ <h:commandLink value="Stop" action="#{basicOptBean.clickStop}"/>
+ </f:subview>
</h:panelGrid>
<h:panelGrid columns="1" width="100%">
- Snapshots
+ <h:commandLink value="Snapshots" action="go_snapshots"/>
</h:panelGrid>
<h:panelGrid columns="1" width="100%">
Modified: branches/JBossProfiler2/src/main/www/snapshotoperations.xhtml
===================================================================
--- branches/JBossProfiler2/src/main/www/snapshotoperations.xhtml 2009-10-28 17:05:08 UTC (rev 569)
+++ branches/JBossProfiler2/src/main/www/snapshotoperations.xhtml 2009-10-28 19:16:46 UTC (rev 570)
@@ -6,69 +6,53 @@
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
- <ui:composition template="/template/serveropttemplate.xhtml">
- <ui:define name="optContent">
- <h:form>
- <h:commandLink action="${basicOptBean.takeSnapshot}"> Take Snapshot
- <a4j:support event="onclick" reRender="listSnapshotRegion"></a4j:support>
- </h:commandLink>
+ <ui:composition template="/template/template.xhtml">
+ <ui:define name="mainContent">
+ <a4j:form>
+ <a4j:commandLink value="Take Snapshot" action="${basicOptBean.takeSnapshot}" reRender="listSnapshotPanel"/>
<p>
</p>
- <h:commandLink action="${basicOptBean.clearSnapshot}"> Clear Snapshots
- <a4j:support event="onclick" reRender="listSnapshotRegion"></a4j:support>
- </h:commandLink>
+ <a4j:commandLink value="Clear Snapshots" action="${basicOptBean.clearSnapshot}" reRender="listSnapshotPanel"/>
<p></p>
- </h:form>
- <a4j:region id="listSnapshotRegion">
- <a4j:form id="listSnapshotForm" ajaxSubmit="true" rendered="true">
- <a4j:outputPanel id="listSnapshotPanel" layout="block">
- <h:outputText value="All the snapshots are listed here"/>
- <h:form>
- <rich:panel>
- <rich:datascroller align="left" for="snapshotsTable" maxPages="20" reRender="sc2" id="sc1"/>
- <rich:spacer height="30"/>
- <rich:dataTable id="snapshotsTable" rows="10" value="#{basicOptBean.snapshots}" var="snapshot" width="500px" columnClasses="center" onRowMouseOver="this.style.backgroundColor='#F1F1F1'" onRowMouseOut="this.style.backgroundColor='#FFFFFF'">
- <f:facet name="label">
- <h:outputText value="Snapshot start time --> stop time"/>
- </f:facet>
-
- <rich:column style="width:500px" sortBy="#{snapshot}" onclick="document.location.href='./snapshotoperations.xhtml'">
- <h:outputText value="#{snapshot}"/>
- <rich:toolTip direction="top-right" showDelay="500">
- <span style="white-space:nowrap"> Click to choose one snapshot for save!<br/></span>
- </rich:toolTip>
- </rich:column>
-
- <a4j:support event="onRowClick" action="#{basicOptBean.selectSnapshotAction}" reRender="listSnapshotPanel,savePanel,selectedOutput">
- <a4j:actionparam name="selected" value="#{snapshot}" assignTo="#{basicOptBean.selectSnapshot}">
- </a4j:actionparam>
- </a4j:support>
- </rich:dataTable>
- </rich:panel>
-
+
+ <a4j:outputPanel id="listSnapshotPanel" layout="block">
+ <h:outputText value="All the snapshots are listed here"/>
+ <rich:panel>
+ <rich:datascroller align="left" for="snapshotsTable" maxPages="20" reRender="sc2" id="sc1"/>
<rich:spacer height="30"/>
- <rich:panel id="savePanel" rendered="#{basicOptBean.panelShows}">
- <h:outputText id="selectedOutput" value="the selected snapshot is No.#{basicOptBean.selectSnapshot}"/>
- <p></p>
- <h:outputText value="Input the snapshot name. If it's blank, the name based on time is generated."/>
- <rich:spacer width="50" height="20" title="Here is a spacer..."/>
- <br/>
- <h:inputText id="inputSaveName" value="#{basicOptBean.saveSnapshotName}"/>
- <rich:spacer width="50" height="20" title="Here is a spacer..."/>
- <br/>
- <br/>
-
- <a4j:commandButton id="savebutton" value="Save" action="#{basicOptBean.selectSaveSnapshotAction}" reRender="inputSaveName,saveEcho">
- <rich:componentControl for="saveSnapshotPanel" attachTo="savebutton" operation="hide" event="onclick"/>
- </a4j:commandButton>
- <p>
- </p>
- <h:outputText id="saveEcho" value="#{basicOptBean.saveEcho}"/>
- </rich:panel>
- </h:form>
- </a4j:outputPanel>
- </a4j:form>
- </a4j:region>
+ <rich:dataTable id="snapshotsTable" rows="10" value="#{basicOptBean.snapshots}" var="snapshot" width="500px" columnClasses="center" onRowMouseOver="this.style.backgroundColor='#F1F1F1'" onRowMouseOut="this.style.backgroundColor='#FFFFFF'">
+
+ <rich:column style="width:500px" sortBy="#{snapshot}">
+ <a4j:commandLink value="#{snapshot}" reRender="selectedSnapshotSection,snapshotsTable" action="#{basicOptBean.selectSnapshot}"/>
+ <rich:toolTip direction="top-right" showDelay="500">
+ <span style="white-space:nowrap"> Click to choose one snapshot for save!<br/></span>
+ </rich:toolTip>
+ </rich:column>
+
+ </rich:dataTable>
+ </rich:panel>
+ </a4j:outputPanel>
+ <rich:spacer height="30"/>
+ <a4j:outputPanel id="selectedSnapshotSection" layout="block">
+ <rich:panel id="savePanel" rendered="#{!empty basicOptBean.selectedSnapshot}">
+ <h:outputText id="selectedOutput" value="the selected snapshot is No.#{basicOptBean.selectedSnapshot}"/>
+ <p></p>
+ <h:outputText value="Input the snapshot name. If it's blank, the name based on time is generated."/>
+ <rich:spacer width="50" height="20" title="Here is a spacer..."/>
+ <br/>
+ <h:inputText id="inputSaveName" value="#{basicOptBean.saveSnapshotName}"/>
+ <rich:spacer width="50" height="20" title="Here is a spacer..."/>
+ <br/>
+ <br/>
+
+ <h:commandButton id="savebutton" value="Save" action="#{basicOptBean.saveSnapshot}" reRender="inputSaveName,saveEcho"/>
+ <p>
+ </p>
+ <h:outputText id="saveEcho" value="#{basicOptBean.saveEcho}"/>
+ </rich:panel>
+ </a4j:outputPanel>
+
+ </a4j:form>
</ui:define>
</ui:composition>
</html>
More information about the jboss-cvs-commits
mailing list