[Yanel-commits] rev 42531 -
public/yanel/contributions/ajax-components/src/lookup-tree/java/org/wyona/yanel/navigation/gwt/lookuptree/client
simon at wyona.com
simon at wyona.com
Fri Apr 24 14:52:07 CEST 2009
Author: simon
Date: 2009-04-24 14:52:07 +0200 (Fri, 24 Apr 2009)
New Revision: 42531
Added:
public/yanel/contributions/ajax-components/src/lookup-tree/java/org/wyona/yanel/navigation/gwt/lookuptree/client/LookupCreateFolderPanel.java
Modified:
public/yanel/contributions/ajax-components/src/lookup-tree/java/org/wyona/yanel/navigation/gwt/lookuptree/client/LookupTree.java
Log:
implemented create folder
display current path.
Added: public/yanel/contributions/ajax-components/src/lookup-tree/java/org/wyona/yanel/navigation/gwt/lookuptree/client/LookupCreateFolderPanel.java
===================================================================
--- public/yanel/contributions/ajax-components/src/lookup-tree/java/org/wyona/yanel/navigation/gwt/lookuptree/client/LookupCreateFolderPanel.java (rev 0)
+++ public/yanel/contributions/ajax-components/src/lookup-tree/java/org/wyona/yanel/navigation/gwt/lookuptree/client/LookupCreateFolderPanel.java 2009-04-24 12:52:07 UTC (rev 42531)
@@ -0,0 +1,97 @@
+package org.wyona.yanel.navigation.gwt.lookuptree.client;
+
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.ClickListener;
+import com.google.gwt.user.client.ui.FileUpload;
+import com.google.gwt.user.client.ui.FormHandler;
+import com.google.gwt.user.client.ui.FormPanel;
+import com.google.gwt.user.client.ui.FormSubmitCompleteEvent;
+import com.google.gwt.user.client.ui.FormSubmitEvent;
+import com.google.gwt.user.client.ui.Hidden;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.TextBox;
+import com.google.gwt.user.client.ui.Widget;
+import com.gwtext.client.widgets.Window;
+import com.gwtext.client.widgets.layout.FitLayout;
+
+class LookupCreatFolderPanel extends FormPanel {
+ private Hidden savePath = new Hidden();
+ private String currentPath = "/";
+ private LookupGrid grid;
+ public LookupCreatFolderPanel(String actionUrl, String submitLabel, String defaultFolderName){
+ final FormPanel form = this;
+ form.setMethod(FormPanel.METHOD_POST);
+ final HorizontalPanel formHolder = new HorizontalPanel();
+
+ Hidden resourceType = new Hidden();
+ resourceType.setName("resource-type");
+ resourceType.setValue("http://www.wyona.org/yanel/resource/1.0::directory");
+
+ savePath.setName("lookin");
+ savePath.setValue(currentPath);
+
+ Hidden saveParameter = new Hidden();
+ saveParameter.setName("save");
+ saveParameter.setValue("save");
+
+ TextBox FolderName = new TextBox();
+ FolderName.setName("create-name");
+ FolderName.setText(defaultFolderName);
+
+ formHolder.add(resourceType);
+ formHolder.add(savePath);
+ formHolder.add(saveParameter);
+ formHolder.add(FolderName);
+// formHolder.add(upload);
+
+ form.add(formHolder);
+ form.setAction(actionUrl);
+
+ // Add a 'submit' button.
+ formHolder.add(new Button(submitLabel, new ClickListener() {
+ public void onClick(Widget sender) {
+ form.submit();
+ }
+ }));
+
+ // Add an event handler to the form.
+ form.addFormHandler(new FormHandler() {
+ public void onSubmit(FormSubmitEvent event) {
+ // This event is fired just before the form is submitted. We can take
+ // this opportunity to perform validation.
+ savePath.setValue(currentPath);
+ }
+
+ public void onSubmitComplete(FormSubmitCompleteEvent event) {
+ // When the form submission is successfully completed, this event is
+ // fired. Assuming the service returned a response of type text/html,
+ // we can get the result text here (see the FormPanel documentation for
+ // further explanation).
+ final Window window = new Window();
+ window.setTitle("Window Panel");
+ window.setMaximizable(true);
+ window.setResizable(true);
+ window.setLayout(new FitLayout());
+ window.setWidth(200);
+ window.setHeight(200);
+ window.setModal(false);
+ window.setAutoScroll(true);
+ window.setHtml(event.getResults());
+ window.show();
+ grid.updateData();
+ }
+ });
+ }
+
+ public String getCurrentPath() {
+ return currentPath;
+ }
+
+ public void setCurrentPath(String currentPath) {
+ this.currentPath = currentPath;
+ }
+
+ public void setGrid(LookupGrid grid) {
+ this.grid = grid;
+ }
+}
\ No newline at end of file
Modified: public/yanel/contributions/ajax-components/src/lookup-tree/java/org/wyona/yanel/navigation/gwt/lookuptree/client/LookupTree.java
===================================================================
--- public/yanel/contributions/ajax-components/src/lookup-tree/java/org/wyona/yanel/navigation/gwt/lookuptree/client/LookupTree.java 2009-04-24 12:19:55 UTC (rev 42530)
+++ public/yanel/contributions/ajax-components/src/lookup-tree/java/org/wyona/yanel/navigation/gwt/lookuptree/client/LookupTree.java 2009-04-24 12:52:07 UTC (rev 42531)
@@ -2,8 +2,10 @@
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.i18n.client.Dictionary;
+import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.FormPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.gwtext.client.core.EventObject;
@@ -30,8 +32,12 @@
private String requestParameterType = "";
private String actionUrl = "";
private String submitLabel = "submit";
+ private String createFolderNameDefault = "New Folder";
+ private String createFolderSubmitLabel = "create new Folder";
private String currentPath = "/";
+ private String currentPathLabelString = "Path: ";
private boolean showUpload = true;
+ private boolean showCreateFolder = true;
public void onModuleLoad() {
@@ -48,8 +54,12 @@
lookupHook = dict.get("lookup-hook");
requestParameterType = dict.get("lookup-request-paramter-type");
actionUrl = dict.get("lookup-upload-action-url");
+ createFolderNameDefault = dict.get("lookup-create-folder-name-default");
+ createFolderSubmitLabel = dict.get("lookup-create-folder-submit-label");
submitLabel = dict.get("lookup-upload-submit-button-label");
+ currentPathLabelString = dict.get("lookup-current-path-label");
showUpload = new Boolean(dict.get("lookup-upload-enabled")).booleanValue();
+ showCreateFolder = new Boolean(dict.get("lookup-create-folder-enabled")).booleanValue();
} catch (java.util.MissingResourceException e) {
// just use default values
}
@@ -72,6 +82,8 @@
});
+ final Label currentPathLabel = new Label(this.currentPathLabelString + currentPath);
+
ResizableConfig config = new ResizableConfig();
config.setHandles(Resizable.SOUTH_EAST);
@@ -83,6 +95,10 @@
}
});
+ final LookupCreatFolderPanel createFolderPanel = new LookupCreatFolderPanel(actionUrl, createFolderSubmitLabel, createFolderNameDefault);
+ createFolderPanel.setHeight("30px");
+ createFolderPanel.setGrid(grid);
+
final LookupUploadPanel form = new LookupUploadPanel(actionUrl, submitLabel);
form.setGrid(grid);
final VerticalPanel verticalPanel = new VerticalPanel();
@@ -103,6 +119,8 @@
grid.setCurrentPath(currentPath);
grid.updateData();
form.setCurrentPath(currentPath);
+ createFolderPanel.setCurrentPath(currentPath);
+ currentPathLabel.setText(currentPathLabelString + currentPath);
}
});
@@ -117,8 +135,16 @@
final HorizontalPanel horizontalPanel = new HorizontalPanel();
+ final VerticalPanel gridAndPathPanel = new VerticalPanel();
+
horizontalPanel.add(treePanel);
- horizontalPanel.add(grid);
+ gridAndPathPanel.add(currentPathLabel);
+ gridAndPathPanel.add(grid);
+ if(showCreateFolder) {
+ verticalPanel.add(createFolderPanel);
+ }
+ horizontalPanel.add(gridAndPathPanel);
+
verticalPanel.add(horizontalPanel);
panel.add(verticalPanel);
RootPanel.get(lookupHook).add(panel);
More information about the Yanel-commits
mailing list