Author: cziegeler
Date: Tue Dec 29 14:15:31 2009
New Revision: 894394
URL: http://svn.apache.org/viewvc?rev=894394&view=rev
Log:
Just code cleanup - no functional changes.
Modified:
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/ExplorerConstants.java
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/ExplorerImages.java
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/ExplorerPageTemplate.java
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/SlingExplorerApplication.java
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/sling/SessionInfo.java
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/sling/Sling.java
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/widgets/grid/ExplorerGrid.java
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/widgets/grid/resource/ResourceGrids.java
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/widgets/tree/resource/ResourceTree.java
Modified:
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/ExplorerConstants.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/ExplorerConstants.java?rev=894394&r1=894393&r2=894394&view=diff
==============================================================================
---
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/ExplorerConstants.java
(original)
+++
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/ExplorerConstants.java
Tue Dec 29 14:15:31 2009
@@ -24,35 +24,30 @@
public interface ExplorerConstants extends Constants {
+ String CONTENT_ROOT = "/";
+ String JSON_TREE_REQUEST_EXTENSION = ".explorer.tree-node.json";
- public static final String CONTENT_ROOT = "/";
- public static final String JSON_TREE_REQUEST_EXTENSION =
".explorer.tree-node.json";
+ String JSON_CHILDREN_REQUEST_EXTENSION = ".explorer.children.json";
+ String PROPERTY = "property";
+ String RESOURCE = "resource";
- public static final String JSON_CHILDREN_REQUEST_EXTENSION =
".explorer.children.json";
- public static final String PROPERTY = "property";
- public static final String RESOURCE = "resource";
+ String SLING_HOMEPAGE = "http://sling.apache.org";
+ String SLING_DOCUMENTATION = SLING_HOMEPAGE + "/documentation";
- public static final String SLING_HOMEPAGE = "http://sling.apache.org";
- public static final String SLING_DOCUMENTATION = SLING_HOMEPAGE +
"/documentation";
+ /**
+ * Descriptions to translate
+ * (see the ExplorerConstants.properties & associted files)
+ *
+ */
+ String mainTitle();
+ String mainSubTitle();
- /**
- * Descriptions to translate
- * (see the ExplorerConstants.properties & associted files)
- *
- */
- String mainTitle();
-
- String mainSubTitle();
-
- String slingHomePage();
-
- String rootItemDescription();
-
- String propertiesDescripton();
-
- String subResourcesDescription();
+ String slingHomePage();
+ String rootItemDescription();
+ String propertiesDescripton();
+ String subResourcesDescription();
}
Modified:
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/ExplorerImages.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/ExplorerImages.java?rev=894394&r1=894393&r2=894394&view=diff
==============================================================================
---
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/ExplorerImages.java
(original)
+++
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/ExplorerImages.java
Tue Dec 29 14:15:31 2009
@@ -26,10 +26,6 @@
*/
public interface ExplorerImages extends ImageBundle {
-
@Resource("org/apache/sling/explorer/Sling.png")
AbstractImagePrototype explorerLogo();
-
-
-
}
\ No newline at end of file
Modified:
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/ExplorerPageTemplate.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/ExplorerPageTemplate.java?rev=894394&r1=894393&r2=894394&view=diff
==============================================================================
---
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/ExplorerPageTemplate.java
(original)
+++
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/ExplorerPageTemplate.java
Tue Dec 29 14:15:31 2009
@@ -33,144 +33,131 @@
import com.google.gwt.user.client.ui.HTMLTable.RowFormatter;
/**
- * Page template composed of a Top Panel & a main panel
- * The Top panel can contain logo, title & links
- *
+ * Page template composed of a Top Panel & a main panel
+ * The Top panel can contain logo, title & links
+ *
* The main panel can contain any kind of panels or widgets
- *
+ *
*/
public class ExplorerPageTemplate extends Composite {
+ /**
+ * The base style name.
+ */
+ public static final String DEFAULT_STYLE_NAME = "Application";
+
+ /**
+ * The panel that contains the menu and content.
+ */
+ private HorizontalPanel mainPanel;
+
+ /**
+ * The panel that holds the main links.
+ */
+ private HorizontalPanel linksPanel;
+
+ /**
+ * The panel that contains the title widget and links.
+ */
+ private FlexTable topPanel;
+
+ /**
+ * Constructor.
+ */
+ public ExplorerPageTemplate() {
+ // Setup the main layout widget
+ FlowPanel layout = new FlowPanel();
+ initWidget(layout);
+
+ // Setup the top panel with the title and links
+ createTopPanel();
+ layout.add(topPanel);
+
+ // Add the main menu
+ mainPanel = new HorizontalPanel();
+ mainPanel.setSize("100%","100%");
+
+ mainPanel.setSpacing(0);
+ mainPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
+ layout.add(mainPanel);
+ }
+
+ /**
+ * Add a link to the top of the page.
+ *
+ * @param link the widget to add to the mainLinks
+ */
+ public void addLink(Widget link) {
+ if (linksPanel.getWidgetCount() > 0) {
+ linksPanel.add(new HTML(" | "));
+ }
+ linksPanel.add(link);
+ }
+
+ /**
+ * @return the {...@link Widget} used as the title
+ */
+ public Widget getTitleWidget() {
+ return topPanel.getWidget(0, 0);
+ }
- /**
- * The base style name.
- */
- public static final String DEFAULT_STYLE_NAME = "Application";
-
- /**
- * The panel that contains the menu and content.
- */
- private HorizontalPanel mainPanel;
-
-
- /**
- * The panel that holds the main links.
- */
- private HorizontalPanel linksPanel;
-
-
- /**
- * The panel that contains the title widget and links.
- */
- private FlexTable topPanel;
-
- /**
- * Constructor.
- */
- public ExplorerPageTemplate()
- {
-
- // Setup the main layout widget
- FlowPanel layout = new FlowPanel();
- initWidget(layout);
-
- // Setup the top panel with the title and links
- createTopPanel();
- layout.add(topPanel);
-
- // Add the main menu
- mainPanel = new HorizontalPanel();
- mainPanel.setSize("100%","100%");
-
- mainPanel.setSpacing(0);
- mainPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
- layout.add(mainPanel);
-
-
- }
-
- /**
- * Add a link to the top of the page.
- *
- * @param link the widget to add to the mainLinks
- */
- public void addLink(Widget link) {
- if (linksPanel.getWidgetCount() > 0) {
- linksPanel.add(new HTML(" | "));
- }
- linksPanel.add(link);
- }
-
-
- /**
- * @return the {...@link Widget} used as the title
- */
- public Widget getTitleWidget() {
- return topPanel.getWidget(0, 0);
- }
-
-
- /**
- * Set the {...@link Widget} to display in the content area.
- *
- * @param content the content widget
- */
- public void setMainWidget(Widget content)
- {
- mainPanel.add(content);
- }
-
-
- /**
- * Set the {...@link Widget} to use as the title bar.
- *
- * @param title the title widget
- */
- public void setTitleWidget(Widget title) {
- topPanel.setWidget(1, 0, title);
-
- }
-
-
- /**
- * Create the panel at the top of the page that contains the title and links.
- */
- private void createTopPanel() {
- boolean isRTL = LocaleInfo.getCurrentLocale().isRTL();
- topPanel = new FlexTable();
- topPanel.setCellPadding(0);
- topPanel.setCellSpacing(0);
- topPanel.setStyleName(DEFAULT_STYLE_NAME + "-top");
- FlexCellFormatter formatter = topPanel.getFlexCellFormatter();
-
- // Setup the links cell
- linksPanel = new HorizontalPanel();
- topPanel.setWidget(0, 0, linksPanel);
- formatter.setStyleName(0, 0, DEFAULT_STYLE_NAME + "-links");
- if (isRTL) {
- formatter.setHorizontalAlignment(0, 0,
HasHorizontalAlignment.ALIGN_LEFT);
- } else {
- formatter.setHorizontalAlignment(0, 0,
HasHorizontalAlignment.ALIGN_RIGHT);
- }
- formatter.setColSpan(0, 0, 2);
-
- // Setup the title cell
- setTitleWidget(null);
- formatter.setStyleName(1, 0, DEFAULT_STYLE_NAME + "-title");
-
- formatter.setStyleName(1, 1, DEFAULT_STYLE_NAME + "-options");
- if (isRTL) {
- formatter.setHorizontalAlignment(1, 1,
HasHorizontalAlignment.ALIGN_LEFT);
- } else {
- formatter.setHorizontalAlignment(1, 1,
HasHorizontalAlignment.ALIGN_RIGHT);
- }
-
- RowFormatter rowFormatter = topPanel.getRowFormatter();
-
- // Align the content to the top
- topPanel.getRowFormatter().setVerticalAlign(0,
- HasVerticalAlignment.ALIGN_TOP);
- topPanel.getRowFormatter().setVerticalAlign(1,
- HasVerticalAlignment.ALIGN_TOP);
- }
+ /**
+ * Set the {...@link Widget} to display in the content area.
+ *
+ * @param content the content widget
+ */
+ public void setMainWidget(Widget content) {
+ mainPanel.add(content);
+ }
+
+ /**
+ * Set the {...@link Widget} to use as the title bar.
+ *
+ * @param title the title widget
+ */
+ public void setTitleWidget(Widget title) {
+ topPanel.setWidget(1, 0, title);
+ }
+
+ /**
+ * Create the panel at the top of the page that contains the title and
links.
+ */
+ private void createTopPanel() {
+ boolean isRTL = LocaleInfo.getCurrentLocale().isRTL();
+ topPanel = new FlexTable();
+ topPanel.setCellPadding(0);
+ topPanel.setCellSpacing(0);
+ topPanel.setStyleName(DEFAULT_STYLE_NAME + "-top");
+ FlexCellFormatter formatter = topPanel.getFlexCellFormatter();
+
+ // Setup the links cell
+ linksPanel = new HorizontalPanel();
+ topPanel.setWidget(0, 0, linksPanel);
+ formatter.setStyleName(0, 0, DEFAULT_STYLE_NAME + "-links");
+ if (isRTL) {
+ formatter.setHorizontalAlignment(0, 0,
HasHorizontalAlignment.ALIGN_LEFT);
+ } else {
+ formatter.setHorizontalAlignment(0, 0,
HasHorizontalAlignment.ALIGN_RIGHT);
+ }
+ formatter.setColSpan(0, 0, 2);
+
+ // Setup the title cell
+ setTitleWidget(null);
+ formatter.setStyleName(1, 0, DEFAULT_STYLE_NAME + "-title");
+
+ formatter.setStyleName(1, 1, DEFAULT_STYLE_NAME + "-options");
+ if (isRTL) {
+ formatter.setHorizontalAlignment(1, 1,
HasHorizontalAlignment.ALIGN_LEFT);
+ } else {
+ formatter.setHorizontalAlignment(1, 1,
HasHorizontalAlignment.ALIGN_RIGHT);
+ }
+
+ RowFormatter rowFormatter = topPanel.getRowFormatter();
+
+ // Align the content to the top
+ rowFormatter.setVerticalAlign(0,
+ HasVerticalAlignment.ALIGN_TOP);
+ rowFormatter.setVerticalAlign(1,
+ HasVerticalAlignment.ALIGN_TOP);
+ }
}
Modified:
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/SlingExplorerApplication.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/SlingExplorerApplication.java?rev=894394&r1=894393&r2=894394&view=diff
==============================================================================
---
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/SlingExplorerApplication.java
(original)
+++
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/SlingExplorerApplication.java
Tue Dec 29 14:15:31 2009
@@ -23,7 +23,6 @@
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
-import com.google.gwt.user.client.ui.DecoratorPanel;
import com.google.gwt.user.client.ui.DisclosurePanel;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTML;
@@ -38,103 +37,91 @@
*/
public class SlingExplorerApplication implements EntryPoint {
- public static final ExplorerImages images = (ExplorerImages)
GWT.create(ExplorerImages.class);
-
- ExplorerConstants constants = (ExplorerConstants)
GWT.create(ExplorerConstants.class);
-
- private ExplorerPageTemplate explorerPage = new ExplorerPageTemplate();
-
- private ResourceTree resourceTree;
- private ResourceGrids resourceGrid;
-
- /**
- * This is the entry point method.
- */
- public void onModuleLoad() {
-
-
-
-
- // Create the Sling explorer page
- setupTitlePanel(constants);
- setupMainLinks(constants);
-
- //init explorer widgets
- resourceGrid = new ResourceGrids();
- resourceTree = new ResourceTree(resourceGrid);
-
- RootPanel.get().add(explorerPage);
- explorerPage.setMainWidget(createExplorerPanel());
-
- // Populate the root level of the explorer tree
- resourceTree.populate();
-
- }
-
-
- private Widget createExplorerPanel() {
-
+ public static final ExplorerImages images = (ExplorerImages)
GWT.create(ExplorerImages.class);
+
+ ExplorerConstants constants = (ExplorerConstants)
GWT.create(ExplorerConstants.class);
+
+ private ExplorerPageTemplate explorerPage = new ExplorerPageTemplate();
+
+ private ResourceTree resourceTree;
+ private ResourceGrids resourceGrid;
+
+ /**
+ * This is the entry point method.
+ */
+ public void onModuleLoad() {
+ // Create the Sling explorer page
+ setupTitlePanel(constants);
+ setupMainLinks(constants);
+
+ //init explorer widgets
+ resourceGrid = new ResourceGrids();
+ resourceTree = new ResourceTree(resourceGrid);
+
+ RootPanel.get().add(explorerPage);
+ explorerPage.setMainWidget(createExplorerPanel());
+
+ // Populate the root level of the explorer tree
+ resourceTree.populate();
+ }
+
+ private Widget createExplorerPanel() {
HorizontalSplitPanel explorerPanel = new HorizontalSplitPanel();
explorerPanel.setSize("100%", "100%");
explorerPanel.setSplitPosition("20%");
-
-
+
+
DisclosurePanel propertiesPanel = new
DisclosurePanel(constants.propertiesDescripton(),true);
propertiesPanel.add(resourceGrid.getPropertyGrid());
propertiesPanel.setStyleName("application-DisclosurePanel");
-
+
DisclosurePanel nodeChildrenPanel = new
DisclosurePanel(constants.subResourcesDescription(),true);
nodeChildrenPanel.add(resourceGrid.getResourceChildrenGrid());
nodeChildrenPanel.setStyleName("application-DisclosurePanel");
-
+
propertiesPanel.setAnimationEnabled(true);
nodeChildrenPanel.setAnimationEnabled(true);
-
-
+
+
FlexTable layout = new FlexTable();
layout.setCellSpacing(6);
layout.setWidget(0, 0, propertiesPanel);
layout.setWidget(1, 0, nodeChildrenPanel);
-
+
explorerPanel.setRightWidget(layout);
explorerPanel.setLeftWidget(resourceTree);
-
+
return explorerPanel;
}
-
- /**
- * Create the main links at the top of the application.
- *
- * @param constants the constants with text
- */
- private void setupMainLinks(ExplorerConstants constants) {
- // Link to Sling Homepage
- explorerPage.addLink(new HTML("<a href=\"" +
ExplorerConstants.SLING_HOMEPAGE + "\">"
- + constants.slingHomePage() + "</a>"));
- }
-
-
-
- /**
- * Create the title bar at the top of the application.
- *
- * @param constants the constant values to use
- */
- private void setupTitlePanel(ExplorerConstants constants) {
-
- // Get the title from the internationalized constants
- String pageTitle = "<h1>" + constants.mainTitle() + "</h1><h2>"
- + constants.mainSubTitle() + "</h2>";
-
- // Add the title and some images to the title bar
- HorizontalPanel titlePanel = new HorizontalPanel();
- titlePanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
- titlePanel.add(images.explorerLogo().createImage());
- titlePanel.add(new HTML(pageTitle));
- explorerPage.setTitleWidget(titlePanel);
- }
-
+ /**
+ * Create the main links at the top of the application.
+ *
+ * @param constants the constants with text
+ */
+ private void setupMainLinks(ExplorerConstants constants) {
+ // Link to Sling Homepage
+ explorerPage.addLink(new HTML("<a href=\"" +
ExplorerConstants.SLING_HOMEPAGE + "\">"
+ + constants.slingHomePage() + "</a>"));
+ }
+
+ /**
+ * Create the title bar at the top of the application.
+ *
+ * @param constants the constant values to use
+ */
+ private void setupTitlePanel(ExplorerConstants constants) {
+ // Get the title from the internationalized constants
+ String pageTitle = "<h1>" + constants.mainTitle() + "</h1><h2>"
+ + constants.mainSubTitle() + "</h2>";
+
+ // Add the title and some images to the title bar
+ HorizontalPanel titlePanel = new HorizontalPanel();
+ titlePanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
+ titlePanel.add(images.explorerLogo().createImage());
+ titlePanel.add(new HTML(pageTitle));
+ explorerPage.setTitleWidget(titlePanel);
+ }
}
Modified:
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/sling/SessionInfo.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/sling/SessionInfo.java?rev=894394&r1=894393&r2=894394&view=diff
==============================================================================
---
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/sling/SessionInfo.java
(original)
+++
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/sling/SessionInfo.java
Tue Dec 29 14:15:31 2009
@@ -18,29 +18,29 @@
*/
package org.apache.sling.explorer.client.sling;
-public class SessionInfo
-{
- private String user = "Not Connected";
+public class SessionInfo {
+
+ private String user = "Not Connected";
private String workspace = "Default";
-
public SessionInfo(String user, String workspace) {
this.user = user;
this.workspace = workspace;
}
-
+
public String getUser() {
return user;
}
+
public void setUser(String user) {
this.user = user;
}
+
public String getWorkspace() {
return workspace;
}
+
public void setWorkspace(String workspace) {
this.workspace = workspace;
- }
-
-
+ }
}
Modified:
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/sling/Sling.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/sling/Sling.java?rev=894394&r1=894393&r2=894394&view=diff
==============================================================================
---
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/sling/Sling.java
(original)
+++
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/sling/Sling.java
Tue Dec 29 14:15:31 2009
@@ -33,41 +33,38 @@
import com.google.gwt.json.client.JSONValue;
import com.google.gwt.user.client.ui.HTML;
-public class Sling
-{
- public static String SESSION_INFO_URL =
"/system/sling/info.sessionInfo.json";
- private static String USER_ID = "userID";
- private static String WORKSPACE = "workspace";
-
+public class Sling {
+ public static String SESSION_INFO_URL =
"/system/sling/info.sessionInfo.json";
+ private static String USER_ID = "userID";
+ private static String WORKSPACE = "workspace";
- public void retrieveSessionInfo(HTML sessionInfoUI)
- {
+ public void retrieveSessionInfo(HTML sessionInfoUI) {
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET,
SESSION_INFO_URL);
try {
builder.sendRequest(null, new
JsonTreeRequestCallback(sessionInfoUI));
GWT.log("send request end", null);
-
+
} catch (RequestException e) {
-
+
GWT.log("Couldn't retrieve User Information", e);
-
+
}
}
-
+
/**
* This class is used as a request callback object for receiving the
json
* structure provided by Sling. The json structure contains information
on the current session
- *
- *
+ *
+ *
*/
private class JsonTreeRequestCallback implements RequestCallback {
-
- HTML sessionInfoUI;
-
+
+ HTML sessionInfoUI;
+
public JsonTreeRequestCallback(HTML sessionInfoUI) {
- this.sessionInfoUI = sessionInfoUI;
+ this.sessionInfoUI = sessionInfoUI;
}
public void onError(Request request, Throwable exception) {
@@ -85,7 +82,7 @@
}
private SessionInfo getSessionInfo(Response response) {
-
+
try {
// parse the response text into JSON
JSONValue jsonValue =
JSONParser.parse(response.getText());
@@ -94,23 +91,15 @@
if (jsonObject != null) {
GWT.log("send request get value end",
null);
return new
SessionInfo(jsonObject.get(USER_ID).toString(),
jsonObject.get(WORKSPACE).toString());
-
- } else {
- throw new JSONException(
- "Invalid Json structure
when retrieve the Sling nodes");
- }
+
+ }
+ throw new JSONException(
+ "Invalid Json structure when
retrieve the Sling nodes");
} catch (JSONException e) {
GWT.log("Could not parse JSON", e);
throw new JSONException("Invalid Json structure
when retrieve the Sling nodes");
-
+
}
}
-
-
- };
-
-
-
-
-
+ };
}
Modified:
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/widgets/grid/ExplorerGrid.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/widgets/grid/ExplorerGrid.java?rev=894394&r1=894393&r2=894394&view=diff
==============================================================================
---
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/widgets/grid/ExplorerGrid.java
(original)
+++
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/widgets/grid/ExplorerGrid.java
Tue Dec 29 14:15:31 2009
@@ -18,30 +18,27 @@
*/
package org.apache.sling.explorer.client.widgets.grid;
-import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTMLTable;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
/**
- *
+ *
* Reusable Grid that can be used in the Sling Explorer
- *
+ *
* Right now, the Grid is based on the GWT FlexTable widget
- *
- *
+ *
+ *
*/
public class ExplorerGrid extends FlexTable {
-
public ExplorerGrid() {
super();
setStyleName("application-FlexTable");
- getRowFormatter().addStyleName(0,
"application-FlexTable-ColumnLabel");
-
- }
+ getRowFormatter().addStyleName(0,
"application-FlexTable-ColumnLabel");
+ }
public void addRow(Integer rowIndex, Object[] cellObjects) {
@@ -49,13 +46,13 @@
for (int cell = 0; cell < cellObjects.length; cell++) {
Widget widget = createCellWidget(cellObjects[cell]);
setWidget(rowIndex, cell, widget);
-
+
if (cell==0)
getCellFormatter().addStyleName(rowIndex,
cell,"application-FlexTable-Cell-first");
else
getCellFormatter().addStyleName(rowIndex,
cell,"application-FlexTable-Cell");
-
-
+
+
if ((rowIndex % 2) != 0) {
rf.addStyleName(rowIndex,
"application-FlexTable-OddRow");
} else {
@@ -63,9 +60,8 @@
}
}
}
-
- public void AddHeader(Object[] cellObjects)
- {
+
+ public void AddHeader(Object[] cellObjects) {
for (int cell = 0; cell < cellObjects.length; cell++) {
Widget widget = createCellWidget(cellObjects[cell]);
setWidget(0, cell, widget);
@@ -73,7 +69,6 @@
}
}
-
private Widget createCellWidget(Object cellObject) {
Widget widget = null;
@@ -84,5 +79,4 @@
return widget;
}
-
}
Modified:
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/widgets/grid/resource/ResourceGrids.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/widgets/grid/resource/ResourceGrids.java?rev=894394&r1=894393&r2=894394&view=diff
==============================================================================
---
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/widgets/grid/resource/ResourceGrids.java
(original)
+++
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/widgets/grid/resource/ResourceGrids.java
Tue Dec 29 14:15:31 2009
@@ -36,36 +36,31 @@
import com.google.gwt.user.client.ui.FlexTable;
/**
- *
- * A ResourcesGrids display information on a resources
- * It is composed of 2 different Grids.
- * One for the resource properties & another one for the resource children.
+ *
+ * A ResourcesGrids display information on a resources
+ * It is composed of 2 different Grids.
+ * One for the resource properties & another one for the resource children.
*
*/
public class ResourceGrids {
-
+
private ExplorerGrid propertyGrid = new ExplorerGrid();
- private ExplorerGrid resourceGrid = new ExplorerGrid();
-
- private ExplorerConstants constants;
-
- public ResourceGrids()
- {
+ private ExplorerGrid resourceGrid = new ExplorerGrid();
+
+ public ResourceGrids() {
super();
- constants = (ExplorerConstants)
GWT.create(ExplorerConstants.class);
-
// Add the Header to the property grid
Object[] cols = new Object[4];
-
+
// TODO : Change the hardcoded labels
cols[0] = "Name";
cols[1] = "Type";
cols[2] = "Value";
cols[3] = "Multi";
-
+
propertyGrid.AddHeader(cols);
-
+
// Add the Header to the Subnode grid
// TODO : Change the hardcoded labels
cols = new Object[2];
@@ -75,26 +70,24 @@
}
private void removeAllRowsInGrids() {
-
- int rowCount = propertyGrid.getRowCount();
- // Loop from i=1 because we don't remove the grid label
+
+ int rowCount = propertyGrid.getRowCount();
+ // Loop from i=1 because we don't remove the grid label
for (int i=rowCount-1; i>0; i-- )
{
propertyGrid.removeRow(i);
}
-
- rowCount = resourceGrid.getRowCount();
- // Loop from i=1 because we don't remove the grid label
+
+ rowCount = resourceGrid.getRowCount();
+ // Loop from i=1 because we don't remove the grid label
for (int i=rowCount-1; i>0; i-- )
{
resourceGrid.removeRow(i);
}
-
+
}
public void populate(String url) {
-
-
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET,
url + ExplorerConstants.JSON_CHILDREN_REQUEST_EXTENSION);
try {
@@ -109,19 +102,15 @@
return propertyGrid;
}
-
public FlexTable getResourceChildrenGrid() {
return resourceGrid;
}
-
private class JsonGridCallback implements RequestCallback {
private ResourceGrids grid;
-
public JsonGridCallback(ResourceGrids grid) {
this.grid = grid;
-
}
public void onError(Request request, Throwable exception) {
@@ -132,9 +121,9 @@
if (200 == response.getStatusCode()) {
grid.removeAllRowsInGrids();
addProperties(response);
-
+
} else {
- GWT.log("ResourceGrids - Couldn't retrieve JSON
for request - status code :"
+ GWT.log("ResourceGrids - Couldn't retrieve JSON
for request - status code :"
+ response.getStatusCode() + "
- "
+ response.getText(), null);
}
@@ -162,18 +151,18 @@
}
private void addProperty(JSONObject jsonObject, int index) {
-
+
Item item = new
Item(jsonObject.get("itemType").isString().stringValue(),
jsonObject.get("multi").isBoolean().booleanValue(),
-
jsonObject.get("name").isString().stringValue(),
-
jsonObject.get("type").isString().stringValue(),
+
jsonObject.get("name").isString().stringValue(),
+
jsonObject.get("type").isString().stringValue(),
jsonObject.get("value").isString().stringValue());
-
+
if
(item.getItemType().equals(ExplorerConstants.PROPERTY))
addToPropertyGrid(propertyGrid, item);
- else
+ else
addToChildrenResourceGrid(resourceGrid, item);
-
+
}
private void addToPropertyGrid( ExplorerGrid grid, Item item) {
@@ -182,36 +171,33 @@
cols[1] = item.getType();
cols[2] = item.getValue();
cols[3] = item.isMutli().toString();
-
+
grid.addRow(grid.getRowCount(), cols);
}
-
+
private void addToChildrenResourceGrid( ExplorerGrid grid, Item
item) {
-
+
Object[] cols = new Object[2];
cols[0] = item.getName();
cols[1] = item.getType();
-
+
grid.addRow(grid.getRowCount(), cols);
}
};
-
+
/**
- * User object used for the treeview items (resource children or
resource properties).
- *
+ * User object used for the treeview items (resource children or
resource properties).
+ *
*/
private class Item {
private String name;
private String type;
private String value;
- private Boolean mutli;
+ private Boolean mutli;
private String itemType;
-
-
-
-
+
public Item(String itemType, Boolean mutli, String name, String
type,
String value) {
super();
@@ -221,37 +207,21 @@
this.type = type;
this.value = value;
}
-
+
public String getName() {
return name;
}
- public void setName(String name) {
- this.name = name;
- }
public String getType() {
return type;
}
- public void setType(String type) {
- this.type = type;
- }
public String getValue() {
return value;
}
- public void setValue(String value) {
- this.value = value;
- }
public Boolean isMutli() {
return mutli;
}
- public void setMutli(Boolean mutli) {
- this.mutli = mutli;
- }
public String getItemType() {
return itemType;
}
- public void setItemType(String itemType) {
- this.itemType = itemType;
- }
}
-
}
Modified:
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/widgets/tree/resource/ResourceTree.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/widgets/tree/resource/ResourceTree.java?rev=894394&r1=894393&r2=894394&view=diff
==============================================================================
---
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/widgets/tree/resource/ResourceTree.java
(original)
+++
sling/trunk/contrib/explorers/gwt/src/main/java/org/apache/sling/explorer/client/widgets/tree/resource/ResourceTree.java
Tue Dec 29 14:15:31 2009
@@ -18,10 +18,7 @@
*/
package org.apache.sling.explorer.client.widgets.tree.resource;
-
-
import org.apache.sling.explorer.client.ExplorerConstants;
-import org.apache.sling.explorer.client.sling.SessionInfo;
import org.apache.sling.explorer.client.widgets.grid.resource.ResourceGrids;
import com.google.gwt.core.client.GWT;
@@ -45,20 +42,20 @@
public class ResourceTree extends Tree {
- private TreeItem root;
- private ResourceGrids properties;
- private ExplorerConstants constants;
-
+ private TreeItem root;
+ private ResourceGrids properties;
+ private ExplorerConstants constants;
+
public ResourceTree(ResourceGrids properties) {
this();
this.properties = properties;
// Create the constants
constants = (ExplorerConstants) GWT.create(ExplorerConstants.class);
}
-
+
public ResourceTree() {
super();
-
+
// Add an open handler to have a lazy loading treeview
addOpenHandler(new OpenHandler<TreeItem>() {
public void onOpen(OpenEvent<TreeItem> event) {
@@ -72,11 +69,11 @@
item.getChild(0).remove();
}
-
+
}
});
-
+
// Add a selection handler to refresh the property & resource
grids
addSelectionHandler(new SelectionHandler<TreeItem> (){
@@ -85,38 +82,29 @@
Node node = (Node)
event.getSelectedItem().getUserObject();
if (properties != null)
properties.populate(node.id);
-
+
}
-
-
- });
-
+
+ });
}
public void populate() {
-
root = new TreeItem(constants.rootItemDescription());
-
// try {
-//
+//
// SessionInfo info = (SessionInfo)
Class.forName("org.apache.sling.explorer.client.sling.SessionInfo").newInstance();
-//
+//
// root = new TreeItem(info.getUser());
// }
// catch(Exception ex) {
// return;
// }
-
-
addItem(root);
-
this.loadChildren(root,
URL.encode(ExplorerConstants.CONTENT_ROOT +
ExplorerConstants.JSON_TREE_REQUEST_EXTENSION));
-
- if (properties != null)
- properties.populate(ExplorerConstants.CONTENT_ROOT );
-
-
+ if (properties != null) {
+ properties.populate(ExplorerConstants.CONTENT_ROOT );
+ }
}
private void loadChildren(final TreeItem treeItem, final String url) {
@@ -136,8 +124,8 @@
* This class is used as a request callback object for receiving the
json
* structure provided by Sling. The json structure contains the node
* children that we have to display in the tree
- *
- *
+ *
+ *
*/
private class JsonTreeRequestCallback implements RequestCallback {
private TreeItem treeItem;
@@ -203,7 +191,7 @@
/**
* User object used for the treeview items. It contains information on
the
* associated node
- *
+ *
*/
private class Node {
@@ -229,9 +217,5 @@
public boolean isLeaf() {
return leaf;
}
-
}
-
-
-
}