Author: dongxu Date: Sun Jul 27 07:47:50 2014 New Revision: 1613760 URL: http://svn.apache.org/r1613760 Log: scrub code
Modified: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/activity/ContactsListActivity.java james/hupa/trunk/client/src/main/java/org/apache/hupa/client/activity/LabelListActivity.java james/hupa/trunk/client/src/main/java/org/apache/hupa/client/activity/TopBarActivity.java james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/AddressListView.java james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/MessageContentView.java james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/MessageListView.java Modified: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/activity/ContactsListActivity.java URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/activity/ContactsListActivity.java?rev=1613760&r1=1613759&r2=1613760&view=diff ============================================================================== --- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/activity/ContactsListActivity.java (original) +++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/activity/ContactsListActivity.java Sun Jul 27 07:47:50 2014 @@ -46,8 +46,6 @@ public class ContactsListActivity extend @Inject private HupaController hupaController; @Inject private Displayable display; - @Inject private LabelPropertiesActivity.Displayable labelProperties; - @Override public void start(AcceptsOneWidget container, EventBus eventBus) { Modified: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/activity/LabelListActivity.java URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/activity/LabelListActivity.java?rev=1613760&r1=1613759&r2=1613760&view=diff ============================================================================== --- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/activity/LabelListActivity.java (original) +++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/activity/LabelListActivity.java Sun Jul 27 07:47:50 2014 @@ -46,8 +46,6 @@ public class LabelListActivity extends A @Inject private HupaController hupaController; @Inject private Displayable display; - @Inject private LabelPropertiesActivity.Displayable labelProperties; - @Override public void start(AcceptsOneWidget container, EventBus eventBus) { Modified: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/activity/TopBarActivity.java URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/activity/TopBarActivity.java?rev=1613760&r1=1613759&r2=1613760&view=diff ============================================================================== --- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/activity/TopBarActivity.java (original) +++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/activity/TopBarActivity.java Sun Jul 27 07:47:50 2014 @@ -20,9 +20,7 @@ package org.apache.hupa.client.activity; import org.apache.hupa.client.HupaController; -import org.apache.hupa.client.place.DefaultPlace; import org.apache.hupa.client.rf.LogoutUserRequest; -import org.apache.hupa.client.ui.LoginLayoutable; import org.apache.hupa.shared.domain.LogoutUserResult; import org.apache.hupa.shared.events.LogoutEvent; @@ -31,12 +29,10 @@ import com.google.gwt.event.dom.client.C import com.google.gwt.event.dom.client.HasClickHandlers; import com.google.gwt.event.shared.EventBus; import com.google.gwt.uibinder.client.UiField; -import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.AcceptsOneWidget; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.IsWidget; -import com.google.gwt.user.client.ui.RootLayoutPanel; import com.google.inject.Inject; import com.google.web.bindery.requestfactory.shared.Receiver; import com.google.web.bindery.requestfactory.shared.ServerFailure; @@ -44,7 +40,6 @@ import com.google.web.bindery.requestfac public class TopBarActivity extends AppBaseActivity { @Inject private Displayable display; - @Inject private LoginLayoutable loginLayout; @UiField protected HTMLPanel userLabel; Modified: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/AddressListView.java URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/AddressListView.java?rev=1613760&r1=1613759&r2=1613760&view=diff ============================================================================== --- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/AddressListView.java (original) +++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/AddressListView.java Sun Jul 27 07:47:50 2014 @@ -21,8 +21,6 @@ package org.apache.hupa.client.ui; import java.util.ArrayList; import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import org.apache.hupa.client.activity.AddressListActivity; import org.apache.hupa.client.activity.MessageListActivity; @@ -31,8 +29,6 @@ import org.apache.hupa.shared.events.Add import com.google.gwt.cell.client.AbstractCell; import com.google.gwt.core.client.GWT; import com.google.gwt.event.shared.EventBus; -import com.google.gwt.regexp.shared.MatchResult; -import com.google.gwt.regexp.shared.RegExp; import com.google.gwt.safehtml.shared.SafeHtmlBuilder; import com.google.gwt.storage.client.Storage; import com.google.gwt.uibinder.client.UiBinder; @@ -48,134 +44,133 @@ import com.google.gwt.view.client.Select import com.google.gwt.view.client.SingleSelectionModel; import com.google.inject.Inject; -public class AddressListView extends Composite implements AddressListActivity.Displayable { +public class AddressListView extends Composite implements + AddressListActivity.Displayable { - @Inject EventBus eventBus; + @Inject + EventBus eventBus; - @UiField SimplePanel thisView; + @UiField + SimplePanel thisView; - private static final String EMAIL_PATTERN = "\\<(.+?)\\>"; + private CellList<AddressNode> addrList; + private ListDataProvider<AddressNode> dataProvider = new ListDataProvider<AddressNode>(); + + public interface Resources extends CellList.Resources { + + Resources INSTANCE = GWT.create(Resources.class); + + @Source("res/CssLabelListView.css") + public CellList.Style cellListStyle(); + } + + public final SingleSelectionModel<AddressNode> selectionModel = new SingleSelectionModel<AddressNode>( + new ProvidesKey<AddressNode>() { + @Override + public Object getKey(AddressNode item) { + return item == null ? null : item.getEmail(); + } + }); + + class AddressCell extends AbstractCell<AddressNode> { + public AddressCell(String... consumedEvents) { + super(consumedEvents); + } + + @Override + public void render(Context context, AddressNode value, + SafeHtmlBuilder sb) { + if (value != null) { + sb.appendEscaped(value.getEmail()); + } + } + } + + public static final ProvidesKey<AddressNode> KEY_PROVIDER = new ProvidesKey<AddressNode>() { + @Override + public Object getKey(AddressNode item) { + return item == null ? null : item.getEmail(); + } + }; + + public static class AddressNode { + private String name; + private String email; + + public AddressNode(String name, String email) { + super(); + this.name = name; + this.email = email; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + } + + public AddressListView() { + initWidget(binder.createAndBindUi(this)); + dataProvider.setList(getContactsFromCache()); + + addrList = new CellList<AddressNode>(new AddressCell(), + Resources.INSTANCE, KEY_PROVIDER); + addrList.setKeyboardPagingPolicy(KeyboardPagingPolicy.INCREASE_RANGE); + addrList.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.BOUND_TO_SELECTION); + // default page size -> max int value + addrList.setPageSize(Integer.MAX_VALUE); + addrList.setSelectionModel(selectionModel); + + selectionModel + .addSelectionChangeHandler(new SelectionChangeEvent.Handler() { + public void onSelectionChange(SelectionChangeEvent event) { + eventBus.fireEvent(new AddressClickEvent(selectionModel + .getSelectedObject().getEmail())); + } + }); + dataProvider.addDataDisplay(addrList); + thisView.setWidget(addrList); + } + + List<AddressNode> getContactsFromCache() { + String[] contacts = null; + Storage contactStore = Storage.getLocalStorageIfSupported(); + if (contactStore != null) { + String contactsString = contactStore + .getItem(MessageListActivity.CONTACTS_STORE); + System.out.println(contactsString); + if (contactsString != null) + contacts = contactsString.replace("[", "").replace("]", "") + .trim().split(","); + } + List<AddressNode> addrs = new ArrayList<AddressNode>(); + if (contacts == null || contacts.length == 0) { + return null; + } + + for (String contact : contacts) { + addrs.add(new AddressNode(contact, contact)); + } - private CellList<AddressNode> addrList; - private ListDataProvider<AddressNode> dataProvider = new ListDataProvider<AddressNode>(); - - public interface Resources extends CellList.Resources { - - Resources INSTANCE = GWT.create(Resources.class); - - @Source("res/CssLabelListView.css") - public CellList.Style cellListStyle(); - } - - public final SingleSelectionModel<AddressNode> selectionModel = new SingleSelectionModel<AddressNode>( - new ProvidesKey<AddressNode>() { - @Override - public Object getKey(AddressNode item) { - return item == null ? null : item.getEmail(); - } - }); - - class AddressCell extends AbstractCell<AddressNode> { - public AddressCell(String... consumedEvents) { - super(consumedEvents); - } - @Override - public void render(Context context, AddressNode value, SafeHtmlBuilder sb) { - if (value != null) { - sb.appendEscaped(value.getEmail()); - } - } - } - - public static final ProvidesKey<AddressNode> KEY_PROVIDER = new ProvidesKey<AddressNode>() { - @Override - public Object getKey(AddressNode item) { - return item == null ? null : item.getEmail(); - } - }; - - public static class AddressNode { - private String name; - private String email; - - public AddressNode(String name, String email) { - super(); - this.name = name; - this.email = email; - } - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - public String getEmail() { - return email; - } - public void setEmail(String email) { - this.email = email; - } - - } - - public AddressListView() { - initWidget(binder.createAndBindUi(this)); - dataProvider.setList(getContactsFromCache()); - - addrList = new CellList<AddressNode>(new AddressCell(), Resources.INSTANCE, KEY_PROVIDER); - addrList.setKeyboardPagingPolicy(KeyboardPagingPolicy.INCREASE_RANGE); - addrList.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.BOUND_TO_SELECTION); - // default page size -> max int value - addrList.setPageSize(Integer.MAX_VALUE); - addrList.setSelectionModel(selectionModel); - - selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { - public void onSelectionChange(SelectionChangeEvent event) { - eventBus.fireEvent(new AddressClickEvent(selectionModel.getSelectedObject().getEmail())); - } - }); - dataProvider.addDataDisplay(addrList); - thisView.setWidget(addrList); - } - - - List<AddressNode> getContactsFromCache() { - String[] contacts = null; - Storage contactStore = Storage.getLocalStorageIfSupported(); - if (contactStore != null) { - String contactsString = contactStore.getItem(MessageListActivity.CONTACTS_STORE); - System.out.println(contactsString); - if (contactsString != null) - contacts = contactsString.replace("[", "").replace("]", "").trim().split(","); - } - List<AddressNode> addrs = new ArrayList<AddressNode>(); - if (contacts == null || contacts.length == 0) { - return null; - } - - - // Compile and use regular expression -// RegExp regExp = RegExp.compile(EMAIL_PATTERN); - for (String contact : contacts) { - addrs.add(new AddressNode(contact, contact)); -// MatchResult matcher = regExp.exec(contact); -// boolean matchFound = (matcher != null); // equivalent to regExp.test(inputStr); -// if (matchFound) { -// // Get all groups for this match -// for (int i=0; i<=matcher.getGroupCount(); i++) { -// String groupStr = matcher.getGroup(i); -// addrs.add(new AddressNode(contact, groupStr == null?contact:groupStr.substring(1, groupStr.length()-1))); -// } -// } - } + return addrs; - return addrs; + } - } + interface Binder extends UiBinder<SimplePanel, AddressListView> { + } - interface Binder extends UiBinder<SimplePanel, AddressListView> { - } - - private static Binder binder = GWT.create(Binder.class); + private static Binder binder = GWT.create(Binder.class); } Modified: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/MessageContentView.java URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/MessageContentView.java?rev=1613760&r1=1613759&r2=1613760&view=diff ============================================================================== --- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/MessageContentView.java (original) +++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/MessageContentView.java Sun Jul 27 07:47:50 2014 @@ -43,7 +43,6 @@ import com.google.gwt.user.client.ui.Doc import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HasHTML; -import com.google.gwt.user.client.ui.HasText; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.RootPanel; @@ -111,7 +110,8 @@ public class MessageContentView extends link.setTitle(name); link.setStyleName(HupaCSS.C_hyperlink); link.addClickHandler(new ClickHandler() { - public void onClick(ClickEvent event) { + @SuppressWarnings("deprecation") + public void onClick(ClickEvent event) { String url = getUrl(messageAttachment, folder, uid, false); if (downloadIframe == null) Window.open(url, "_blank", ""); Modified: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/MessageListView.java URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/MessageListView.java?rev=1613760&r1=1613759&r2=1613760&view=diff ============================================================================== --- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/MessageListView.java (original) +++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/MessageListView.java Sun Jul 27 07:47:50 2014 @@ -27,7 +27,6 @@ import org.apache.hupa.client.activity.M import org.apache.hupa.client.ui.MessagesCellTable.MessageListDataProvider; import org.apache.hupa.shared.domain.Message; -import com.google.gwt.core.client.Duration; import com.google.gwt.core.client.GWT; import com.google.gwt.event.shared.EventBus; import com.google.gwt.uibinder.client.UiBinder; --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org