james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From don...@apache.org
Subject svn commit: r1522404 - /james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/LabelPropertiesView.java
Date Thu, 12 Sep 2013 04:51:11 GMT
Author: dongxu
Date: Thu Sep 12 04:51:11 2013
New Revision: 1522404

URL: http://svn.apache.org/r1522404
Log:
fixed issue#77, the reason is that the arguement passed to server was not the selected value
in the list box

Modified:
    james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/LabelPropertiesView.java

Modified: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/LabelPropertiesView.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/LabelPropertiesView.java?rev=1522404&r1=1522403&r2=1522404&view=diff
==============================================================================
--- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/LabelPropertiesView.java
(original)
+++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/LabelPropertiesView.java
Thu Sep 12 04:51:11 2013
@@ -106,6 +106,7 @@ public class LabelPropertiesView extends
 	@Inject HupaController hc;
 	@Inject EventBus eventBus;
 <<<<<<< HEAD
+<<<<<<< HEAD
 
 =======
 	
@@ -185,9 +186,18 @@ public class LabelPropertiesView extends
 >>>>>>> make add of label setting work in backend
 	@UiField Button save;
 	
+=======
+
+	@UiField TextBox name;
+	private String path;
+	
+	@UiField ListBox parent;
+	@UiField Button save;
+
+>>>>>>> fixed issue#77, the reason is that the arguement passed to server
was not the selected value in the list box
 	@UiField VerticalPanel propContainer;
 	@UiField CaptionPanel information;
-	
+
 	private int state;
 
 	ImapFolder folder;
@@ -210,38 +220,38 @@ public class LabelPropertiesView extends
 =======
 	void handleSave(ClickEvent e) {
 		hc.showTopLoading("Saving...");
-		if(state == LabelListActivity.Displayable.CASCADE_TYPE_RENAME){
+		if (state == LabelListActivity.Displayable.CASCADE_TYPE_RENAME) {
 			RenameFolderRequest req = rf.renameFolderRequest();
 			RenameFolderAction action = req.create(RenameFolderAction.class);
 			final ImapFolder f = req.create(ImapFolder.class);
 			f.setFullName(folder.getFullName());
 			action.setFolder(f);
-			action.setNewName(name.getText());
+			action.setNewName(parent.getValue(parent.getSelectedIndex()) + "/" + name.getText());
 			req.rename(action).fire(new Receiver<GenericResult>() {
 				@Override
 				public void onSuccess(GenericResult response) {
 					hc.hideTopLoading();
 					eventBus.fireEvent(new RefreshLabelListEvent());
-					hc.showNotice("The label \"" + f.getFullName() + "\" has been renamed to "+name.getText(),
10000);
+					hc.showNotice("The label \"" + f.getFullName() + "\" has been renamed to " + name.getText(),
10000);
 				}
 				@Override
 				public void onFailure(ServerFailure error) {
 					hc.hideTopLoading();
 					hc.showNotice(error.getMessage(), 10000);
 				}
-			});	
-		} else if (state == LabelListActivity.Displayable.CASCADE_TYPE_ADD){
+			});
+		} else if (state == LabelListActivity.Displayable.CASCADE_TYPE_ADD) {
 			CreateFolderRequest req = rf.createFolderRequest();
 			CreateFolderAction action = req.create(CreateFolderAction.class);
 			final ImapFolder f = req.create(ImapFolder.class);
-			f.setFullName(folder.getFullName()+"/"+name.getText());
+			f.setFullName(path + "/" + name.getText());
 			action.setFolder(f);
-			req.create(action).fire(new Receiver<GenericResult>(){
+			req.create(action).fire(new Receiver<GenericResult>() {
 				@Override
 				public void onSuccess(GenericResult response) {
 					hc.hideTopLoading();
 					eventBus.fireEvent(new RefreshLabelListEvent());
-					hc.showNotice("The label \"" + f.getFullName() + "\" was created.", 10000);
+					hc.showNotice("The label \"" + f.getName() + "\" was created.", 10000);
 				}
 				@Override
 				public void onFailure(ServerFailure error) {
@@ -249,7 +259,7 @@ public class LabelPropertiesView extends
 					hc.showNotice(error.getMessage(), 10000);
 				}
 			});
-			
+
 		}
 >>>>>>> make add of label setting work in backend
 	}
@@ -274,17 +284,25 @@ public class LabelPropertiesView extends
 			makeParentList(labelNode, true, wholeList);
 			name.setText("");
 <<<<<<< HEAD
+<<<<<<< HEAD
 			path = labelNode.getPath();
 =======
 >>>>>>> make add of label setting work in backend
+=======
+			path = labelNode.getPath();
+>>>>>>> fixed issue#77, the reason is that the arguement passed to server
was not the selected value in the list box
 			information.setVisible(false);
 			break;
 		case LabelListActivity.Displayable.CASCADE_TYPE_RENAME:
 			name.setText(labelNode.getName());
 <<<<<<< HEAD
+<<<<<<< HEAD
 			path = labelNode.getPath();
 =======
 >>>>>>> make add of label setting work in backend
+=======
+			path = labelNode.getPath();
+>>>>>>> fixed issue#77, the reason is that the arguement passed to server
was not the selected value in the list box
 			makeParentList(labelNode, false, wholeList);
 			information.setVisible(true);
 			break;
@@ -346,15 +364,37 @@ public class LabelPropertiesView extends
 		parent.clear();
 		parent.addItem("---", "root");
 		for (LabelNode folderNode : wholeList) {
-			parent.addItem(folderNode.getName(), folderNode.getPath());
+			if (isItself(labelNode, isParent, folderNode) || isItsDecendant(labelNode, isParent, folderNode))
{
+				continue;
+			}
+			parent.addItem(folderNode.getNameForDisplay().replace("&nbsp;&nbsp;", ". "), folderNode.getPath());
 		}
 <<<<<<< HEAD
+<<<<<<< HEAD
 		_parent.setSelectedIndex(list.indexOf(labelNode.getParent()));
 >>>>>>> add rename RF to label setting feature
 =======
+=======
+
+>>>>>>> fixed issue#77, the reason is that the arguement passed to server
was not the selected value in the list box
 		int parentIndex = wholeList.indexOf(isParent ? labelNode : labelNode.getParent());
 		parent.setSelectedIndex(parentIndex < 0 ? 0 : parentIndex + 1);
 	}
+	private boolean isItself(LabelNode labelNode, boolean isParent, LabelNode folderNode) {
+		return !isParent && labelNode.compareTo(folderNode) == 0;
+	}
+	private boolean isItsDecendant(LabelNode labelNode, boolean isParent, LabelNode folderNode)
{
+		return !isParent && isKinship(labelNode, folderNode);
+	}
+
+	private boolean isKinship(LabelNode labelNode, LabelNode folderNode) {
+		if(folderNode == null){
+			return false;
+		}
+		if (labelNode.compareTo(folderNode.getParent()) == 0)
+			return true;
+		return isKinship(labelNode, folderNode.getParent());
+	}
 	@Override
 	public HasClickHandlers getSave() {
 		return save;



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message