Author: dongxu Date: Thu Sep 12 03:46:10 2013 New Revision: 1522245 URL: http://svn.apache.org/r1522245 Log: adjust folder list's css style, try to dynamically load folder icons
Added: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/res/CellTree.css james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/res/TreeResources.java Modified: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/FolderListView.java james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/FoldersTreeViewModel.java james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/HupaLayout.ui.xml Modified: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/FolderListView.java URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/FolderListView.java?rev=1522245&r1=1522244&r2=1522245&view=diff ============================================================================== --- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/FolderListView.java (original) +++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/FolderListView.java Thu Sep 12 03:46:10 2013 @@ -210,6 +210,7 @@ public class FolderListView extends Comp ======= ======= import org.apache.hupa.client.activity.FolderListActivity; +import org.apache.hupa.client.ui.res.TreeResources; >>>>>>> integrate all of the views to their corresponding activities and >>>>>>> mappers import com.google.gwt.core.client.GWT; @@ -228,7 +229,7 @@ public class FolderListView extends Comp @Inject public FolderListView(final FoldersTreeViewModel viewModel, final EventBus eventBus) { - CellTree.Resources res = GWT.create(CellTree.BasicResources.class); + CellTree.Resources res = GWT.create(TreeResources.class); cellTree = new CellTree(viewModel, null, res); cellTree.setAnimationEnabled(true); initWidget(binder.createAndBindUi(this)); Modified: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/FoldersTreeViewModel.java URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/FoldersTreeViewModel.java?rev=1522245&r1=1522244&r2=1522245&view=diff ============================================================================== --- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/FoldersTreeViewModel.java (original) +++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/FoldersTreeViewModel.java Thu Sep 12 03:46:10 2013 @@ -22,13 +22,21 @@ package org.apache.hupa.client.ui; import java.util.List; import org.apache.hupa.client.rf.HupaRequestFactory; +import org.apache.hupa.client.ui.res.TreeResources; import org.apache.hupa.shared.domain.ImapFolder; import org.apache.hupa.shared.domain.User; import org.apache.hupa.shared.events.LoadMessagesEvent; import com.google.gwt.cell.client.AbstractCell; +import com.google.gwt.core.shared.GWT; import com.google.gwt.event.shared.EventBus; +import com.google.gwt.resources.client.ClientBundle; +import com.google.gwt.resources.client.ImageResource; +import com.google.gwt.resources.client.ClientBundle.Source; import com.google.gwt.safehtml.shared.SafeHtmlBuilder; +import com.google.gwt.user.client.ui.AbstractImagePrototype; +import com.google.gwt.user.client.ui.Image; +import com.google.gwt.user.client.ui.impl.ClippedImagePrototype; import com.google.gwt.view.client.AsyncDataProvider; import com.google.gwt.view.client.HasData; import com.google.gwt.view.client.ProvidesKey; @@ -44,6 +52,7 @@ public class FoldersTreeViewModel implem protected User user; @Inject protected HupaRequestFactory rf; @Inject protected EventBus eventBus; + private static TreeResources images; public FoldersTreeViewModel() { @@ -58,6 +67,9 @@ public class FoldersTreeViewModel implem selectionModel.getSelectedObject())); } }); + if (images == null) { + images = GWT.create(TreeResources.class); + } } private final SingleSelectionModel<ImapFolder> selectionModel = new SingleSelectionModel<ImapFolder>( @@ -72,18 +84,48 @@ public class FoldersTreeViewModel implem * Get the {@link NodeInfo} that provides the children of the specified * value. */ + // @Override + // public <T> NodeInfo<?> getNodeInfo(T value) { + // return new DefaultNodeInfo<ImapFolder>(new ImapFolderListDataProvider( + // (ImapFolder) value), new ImapFolderCell(images.listicons()) { + // @Override + // public void render(Context context, ImapFolder value, + // SafeHtmlBuilder sb) { + // if (value != null) { + // sb.appendEscaped(value.getName()); + // } + // } + // }, selectionModel, null); + // } @Override public <T> NodeInfo<?> getNodeInfo(T value) { return new DefaultNodeInfo<ImapFolder>(new ImapFolderListDataProvider( - (ImapFolder) value), new AbstractCell<ImapFolder>() { - @Override - public void render(Context context, ImapFolder value, - SafeHtmlBuilder sb) { - if (value != null) { - sb.appendEscaped(value.getName()); - } + (ImapFolder) value), new ImapFolderCell(images.listicons()), + selectionModel, null); + } + + /** + * The cell used to render categories. + */ + private static class ImapFolderCell extends AbstractCell<ImapFolder> { + private final ImageResource image; + + public ImapFolderCell(ImageResource image) { + this.image = image; + } + + @Override + public void render(com.google.gwt.cell.client.Cell.Context context, + ImapFolder value, SafeHtmlBuilder sb) { + if (value != null) { + AbstractImagePrototype imagePrototype = new ClippedImagePrototype( + image.getSafeUri(), -6, 213, 24, 24); + sb.appendHtmlConstant(imagePrototype.getHTML()).appendEscaped( + " "); + sb.appendEscaped(value.getName()); } - }, selectionModel, null); + + } } private class ImapFolderListDataProvider extends @@ -95,10 +137,10 @@ public class FoldersTreeViewModel implem ImapFolder folder; - @Override - public void addDataDisplay(HasData<ImapFolder> display) { - super.addDataDisplay(display); - } + @Override + public void addDataDisplay(HasData<ImapFolder> display) { + super.addDataDisplay(display); + } @Override protected void onRangeChanged(HasData<ImapFolder> display) { @@ -106,13 +148,14 @@ public class FoldersTreeViewModel implem .fire(new Receiver<List<ImapFolder>>() { @Override public void onSuccess(List<ImapFolder> response) { - System.out.println("list of folders-"+response); + System.out.println("list of folders-" + response); if (response == null || response.size() == 0) { updateRowCount(-1, true); } else { updateRowData(0, response); } } + @Override public void onFailure(ServerFailure error) { if (error.isFatal()) { Modified: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/HupaLayout.ui.xml URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/HupaLayout.ui.xml?rev=1522245&r1=1522244&r2=1522245&view=diff ============================================================================== --- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/HupaLayout.ui.xml (original) +++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/HupaLayout.ui.xml Thu Sep 12 03:46:10 2013 @@ -38,6 +38,7 @@ top: 0; left: 0; width: 100%; + min-width: 144px; bottom: 0; overflow-x: hidden; overflow-y: auto; Added: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/res/CellTree.css URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/res/CellTree.css?rev=1522245&view=auto ============================================================================== --- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/res/CellTree.css (added) +++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/res/CellTree.css Thu Sep 12 03:46:10 2013 @@ -0,0 +1,85 @@ +.cellTreeWidget { + display: block; + margin: 0; + padding: 0; + min-width:144px; +} + +.cellTreeEmptyMessage { + +} + +.cellTreeItem { + cursor: default; +} + +.cellTreeItemImage { + +} + +.cellTreeItemImageValue { + +} + +.cellTreeItemValue { + padding-left: 20px; + padding-right: 36px; + text-align: left; + text-decoration: none; + text-overflow: ellipsis; + text-shadow: rgb(255, 255, 255) 0px 1px 1px; + white-space: nowrap; +} + +/* +div:focus { outline: none; } +*/ +.cellTreeKeyboardSelectedItem { /* background-color: #ffff00; */ + +} + +.cellTreeOpenItem { + +} + +.cellTreeTopItem { + font-weight: bold; + color: #4b4a4a; +} + +.cellTreeTopItemImage { + +} + +@sprite .cellTreeTopItemImageValue { + height: 17px; + width: auto; + overflow-x: hidden; + gwt-image: 'listicons'; + background-position: 6px -213px; + padding: 6px 8px 2px 8px; + border-bottom-color: #bbd3da; + border-bottom-left-radius: 0px; + border-bottom-right-radius: 0px; + border-bottom-style: solid; + border-bottom-width: 1px; + border-top-color: #fff; + border-top-left-radius: 4px; + border-top-right-radius: 4px; + border-top-style: solid; + border-top-width: 1px; +} + +:focus { + outline: 0; +} + +.cellTreeSelectedItem { + background-color: #c7e3ef; + color: #004458; + height: auto; + overflow-x: hidden; +} + +.cellTreeShowMoreButton { +} \ No newline at end of file Added: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/res/TreeResources.java URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/res/TreeResources.java?rev=1522245&view=auto ============================================================================== --- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/res/TreeResources.java (added) +++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/res/TreeResources.java Thu Sep 12 03:46:10 2013 @@ -0,0 +1,31 @@ +/**************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one * + * or more contributor license agreements. See the NOTICE file * + * distributed with this work for additional information * + * regarding copyright ownership. The ASF licenses this file * + * to you under the Apache License, Version 2.0 (the * + * "License"); you may not use this file except in compliance * + * with the License. You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, * + * software distributed under the License is distributed on an * + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * + * KIND, either express or implied. See the License for the * + * specific language governing permissions and limitations * + * under the License. * + ****************************************************************/ + +package org.apache.hupa.client.ui.res; + +import com.google.gwt.resources.client.ImageResource; +import com.google.gwt.user.cellview.client.CellTree; + +public interface TreeResources extends CellTree.Resources { + @Source("CellTree.css") + public CellTree.Style cellTreeStyle(); + + @Source("listicons.png") + public ImageResource listicons(); +} --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org