horazontal layout
This commit is contained in:
parent
20226d30fb
commit
f3a3166695
|
@ -1,4 +1,5 @@
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
lastWarOutDir=${webappDirectory}
|
lastWarOutDir=${webappDirectory}
|
||||||
|
launchConfigExternalUrlPrefix=
|
||||||
warSrcDir=src/main/webapp
|
warSrcDir=src/main/webapp
|
||||||
warSrcDirIsOutput=false
|
warSrcDirIsOutput=false
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -30,7 +30,7 @@
|
||||||
<!-- GWT 2.8 requires 1.8 -->
|
<!-- GWT 2.8 requires 1.8 -->
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
<gwt-material.version>2.1.1</gwt-material.version>
|
<gwt-material.version>2.0.1</gwt-material.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,49 @@
|
||||||
package org.gcube.portets.user.message_conversations.client.autocomplete;
|
package org.gcube.portets.user.message_conversations.client.autocomplete;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import com.google.gwt.dom.client.Document;
|
import com.google.gwt.dom.client.Document;
|
||||||
import com.google.gwt.event.dom.client.*;
|
import com.google.gwt.event.dom.client.BlurEvent;
|
||||||
import com.google.gwt.event.logical.shared.*;
|
import com.google.gwt.event.dom.client.BlurHandler;
|
||||||
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
|
import com.google.gwt.event.dom.client.FocusEvent;
|
||||||
|
import com.google.gwt.event.dom.client.FocusHandler;
|
||||||
|
import com.google.gwt.event.dom.client.KeyCodes;
|
||||||
|
import com.google.gwt.event.dom.client.KeyUpHandler;
|
||||||
|
import com.google.gwt.event.logical.shared.HasSelectionHandlers;
|
||||||
|
import com.google.gwt.event.logical.shared.SelectionEvent;
|
||||||
|
import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||||
|
import com.google.gwt.event.logical.shared.ValueChangeEvent;
|
||||||
|
import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
||||||
import com.google.gwt.event.shared.HandlerRegistration;
|
import com.google.gwt.event.shared.HandlerRegistration;
|
||||||
import com.google.gwt.user.client.DOM;
|
import com.google.gwt.user.client.DOM;
|
||||||
import com.google.gwt.user.client.ui.*;
|
import com.google.gwt.user.client.ui.FlowPanel;
|
||||||
|
import com.google.gwt.user.client.ui.SuggestBox;
|
||||||
|
import com.google.gwt.user.client.ui.SuggestOracle;
|
||||||
import com.google.gwt.user.client.ui.SuggestOracle.Suggestion;
|
import com.google.gwt.user.client.ui.SuggestOracle.Suggestion;
|
||||||
|
import com.google.gwt.user.client.ui.TextBox;
|
||||||
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
|
||||||
import gwt.material.design.addins.client.MaterialAddins;
|
import gwt.material.design.addins.client.MaterialAddins;
|
||||||
import gwt.material.design.addins.client.autocomplete.constants.AutocompleteType;
|
import gwt.material.design.addins.client.autocomplete.constants.AutocompleteType;
|
||||||
import gwt.material.design.addins.client.base.constants.AddinsCssName;
|
import gwt.material.design.addins.client.base.constants.AddinsCssName;
|
||||||
import gwt.material.design.client.MaterialDesignBase;
|
import gwt.material.design.client.MaterialDesignBase;
|
||||||
import gwt.material.design.client.base.*;
|
import gwt.material.design.client.base.AbstractValueWidget;
|
||||||
import gwt.material.design.client.base.mixin.*;
|
import gwt.material.design.client.base.HasPlaceholder;
|
||||||
|
import gwt.material.design.client.base.HasProgress;
|
||||||
|
import gwt.material.design.client.base.HasReadOnly;
|
||||||
|
import gwt.material.design.client.base.HasType;
|
||||||
|
import gwt.material.design.client.base.MaterialWidget;
|
||||||
|
import gwt.material.design.client.base.mixin.CssTypeMixin;
|
||||||
|
import gwt.material.design.client.base.mixin.FocusableMixin;
|
||||||
|
import gwt.material.design.client.base.mixin.ProgressMixin;
|
||||||
|
import gwt.material.design.client.base.mixin.ReadOnlyMixin;
|
||||||
import gwt.material.design.client.constants.CssName;
|
import gwt.material.design.client.constants.CssName;
|
||||||
import gwt.material.design.client.constants.IconType;
|
import gwt.material.design.client.constants.IconType;
|
||||||
import gwt.material.design.client.constants.ProgressType;
|
import gwt.material.design.client.constants.ProgressType;
|
||||||
|
@ -23,9 +54,6 @@ import gwt.material.design.client.ui.html.Label;
|
||||||
import gwt.material.design.client.ui.html.ListItem;
|
import gwt.material.design.client.ui.html.ListItem;
|
||||||
import gwt.material.design.client.ui.html.UnorderedList;
|
import gwt.material.design.client.ui.html.UnorderedList;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author kevzlou7979
|
* @author kevzlou7979
|
||||||
|
@ -283,7 +311,7 @@ public class MaterialAutoComplete extends AbstractValueWidget<List<? extends Sug
|
||||||
}
|
}
|
||||||
suggestionMap.clear();
|
suggestionMap.clear();
|
||||||
|
|
||||||
clearErrorText();
|
clearErrorOrSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -11,10 +11,13 @@ import org.gcube.portets.user.message_conversations.client.Utils;
|
||||||
import org.gcube.portets.user.message_conversations.client.ui.resources.MessagesResources;
|
import org.gcube.portets.user.message_conversations.client.ui.resources.MessagesResources;
|
||||||
import org.gcube.portets.user.message_conversations.shared.ConvMessage;
|
import org.gcube.portets.user.message_conversations.shared.ConvMessage;
|
||||||
import org.gcube.portets.user.message_conversations.shared.MessageUserModel;
|
import org.gcube.portets.user.message_conversations.shared.MessageUserModel;
|
||||||
import org.gcube.portlets.user.messages.client.ui.MessageDataSource;
|
|
||||||
import org.gcube.portlets.user.messages.client.ui.MessageItem;
|
|
||||||
|
|
||||||
|
import com.github.gwtbootstrap.client.ui.IconCell;
|
||||||
|
import com.github.gwtbootstrap.client.ui.constants.IconSize;
|
||||||
|
import com.google.gwt.cell.client.CheckboxCell;
|
||||||
|
import com.google.gwt.cell.client.TextCell;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.dom.client.Style.Unit;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* #%L
|
* #%L
|
||||||
|
@ -40,9 +43,16 @@ import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
import com.google.gwt.event.logical.shared.ResizeEvent;
|
import com.google.gwt.event.logical.shared.ResizeEvent;
|
||||||
import com.google.gwt.event.logical.shared.ResizeHandler;
|
import com.google.gwt.event.logical.shared.ResizeHandler;
|
||||||
|
import com.google.gwt.safehtml.shared.SafeHtmlUtils;
|
||||||
import com.google.gwt.uibinder.client.UiBinder;
|
import com.google.gwt.uibinder.client.UiBinder;
|
||||||
import com.google.gwt.uibinder.client.UiField;
|
import com.google.gwt.uibinder.client.UiField;
|
||||||
import com.google.gwt.uibinder.client.UiHandler;
|
import com.google.gwt.uibinder.client.UiHandler;
|
||||||
|
import com.google.gwt.user.cellview.client.CellTable;
|
||||||
|
import com.google.gwt.user.cellview.client.Column;
|
||||||
|
import com.google.gwt.user.cellview.client.RowStyles;
|
||||||
|
import com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler;
|
||||||
|
import com.google.gwt.user.cellview.client.HasKeyboardPagingPolicy.KeyboardPagingPolicy;
|
||||||
|
import com.google.gwt.user.cellview.client.HasKeyboardSelectionPolicy.KeyboardSelectionPolicy;
|
||||||
import com.google.gwt.user.client.Window;
|
import com.google.gwt.user.client.Window;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
import com.google.gwt.user.client.rpc.ServiceDefTarget;
|
import com.google.gwt.user.client.rpc.ServiceDefTarget;
|
||||||
|
@ -52,20 +62,22 @@ import com.google.gwt.user.client.ui.HTMLPanel;
|
||||||
import com.google.gwt.user.client.ui.RootPanel;
|
import com.google.gwt.user.client.ui.RootPanel;
|
||||||
import com.google.gwt.user.client.ui.ScrollPanel;
|
import com.google.gwt.user.client.ui.ScrollPanel;
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
import com.google.gwt.view.client.DefaultSelectionEventManager;
|
||||||
|
import com.google.gwt.view.client.MultiSelectionModel;
|
||||||
|
import com.google.gwt.view.client.SelectionModel;
|
||||||
|
|
||||||
import gwt.material.design.client.constants.IconType;
|
import gwt.material.design.client.constants.IconType;
|
||||||
import gwt.material.design.client.constants.Position;
|
import gwt.material.design.client.constants.Position;
|
||||||
|
import gwt.material.design.client.data.DataSource;
|
||||||
import gwt.material.design.client.ui.MaterialAnchorButton;
|
import gwt.material.design.client.ui.MaterialAnchorButton;
|
||||||
import gwt.material.design.client.ui.MaterialBadge;
|
import gwt.material.design.client.ui.MaterialBadge;
|
||||||
import gwt.material.design.client.ui.MaterialCollection;
|
|
||||||
import gwt.material.design.client.ui.MaterialFAB;
|
import gwt.material.design.client.ui.MaterialFAB;
|
||||||
import gwt.material.design.client.ui.MaterialLink;
|
import gwt.material.design.client.ui.MaterialLink;
|
||||||
import gwt.material.design.client.ui.MaterialProgress;
|
import gwt.material.design.client.ui.MaterialProgress;
|
||||||
import gwt.material.design.client.ui.MaterialRow;
|
|
||||||
import gwt.material.design.client.ui.MaterialToast;
|
import gwt.material.design.client.ui.MaterialToast;
|
||||||
import gwt.material.design.client.ui.animate.MaterialAnimation;
|
import gwt.material.design.client.ui.animate.MaterialAnimation;
|
||||||
import gwt.material.design.client.ui.animate.Transition;
|
import gwt.material.design.client.ui.animate.Transition;
|
||||||
import gwt.material.design.incubator.client.infinitescroll.data.LoadConfig;
|
|
||||||
/**
|
/**
|
||||||
* @author Massimiliano Assante, CNR-ISTI
|
* @author Massimiliano Assante, CNR-ISTI
|
||||||
*/
|
*/
|
||||||
|
@ -86,20 +98,28 @@ public class ApplicationView extends Composite {
|
||||||
|
|
||||||
|
|
||||||
@UiField ScrollPanel scrollerPanel;
|
@UiField ScrollPanel scrollerPanel;
|
||||||
@UiField MaterialRow rightPanel;
|
//@UiField MaterialRow rightPanel;
|
||||||
@UiField HTMLPanel htmlPanel;
|
@UiField HTMLPanel htmlPanel;
|
||||||
@UiField MaterialFAB FAB;
|
@UiField MaterialFAB FAB;
|
||||||
@UiField MaterialLink menu, newMessage, switcher;
|
@UiField MaterialLink menu, newMessage, switcher;
|
||||||
@UiField MaterialAnchorButton replyAll, reply, forward;
|
@UiField MaterialAnchorButton replyAll, reply, forward;
|
||||||
@UiField MaterialCollection messagesCollection;
|
@UiField MaterialProgress messageLoader;
|
||||||
@UiField MaterialProgress messageLoader, messagesLoader;
|
|
||||||
@UiField MaterialBadge badge;
|
@UiField MaterialBadge badge;
|
||||||
|
@UiField ShowMorePagerPanel pagerPanel;
|
||||||
|
|
||||||
|
CellTable<ConvMessage> sentCellList;
|
||||||
|
|
||||||
|
MessageProvider mp;
|
||||||
|
|
||||||
|
DataSource<ConvMessage> dataSource = new MessageDataSource(false, convService);
|
||||||
|
//InfiniteScrollView scrollView = new InfiniteScrollView(dataSource);
|
||||||
|
|
||||||
private ConvMessage currentSelected;
|
private ConvMessage currentSelected;
|
||||||
private DisplayMessage displayMessage;
|
private DisplayMessage displayMessage;
|
||||||
private WriteMessage newMessageDisplay;
|
private WriteMessage newMessageDisplay;
|
||||||
private boolean isSendTo = false;
|
private boolean isSendTo = false;
|
||||||
|
|
||||||
|
|
||||||
public ApplicationView(String... sendToUserNames) {
|
public ApplicationView(String... sendToUserNames) {
|
||||||
initWidget(uiBinder.createAndBindUi(this));
|
initWidget(uiBinder.createAndBindUi(this));
|
||||||
((ServiceDefTarget) convService).setServiceEntryPoint(Utils.getServiceEntryPoint());
|
((ServiceDefTarget) convService).setServiceEntryPoint(Utils.getServiceEntryPoint());
|
||||||
|
@ -128,27 +148,96 @@ public class ApplicationView extends Composite {
|
||||||
isSendTo = true;
|
isSendTo = true;
|
||||||
messageLoader.setVisible(false);
|
messageLoader.setVisible(false);
|
||||||
}
|
}
|
||||||
readUserMessages(false, isSendTo);
|
|
||||||
infiniteScrollBasic.setLoadConfig(new LoadConfig<>(0, 200));
|
GWT.log("application initialized");
|
||||||
infiniteScrollBasic.setDataSource(new MessageDataSource(false, convService));
|
|
||||||
infiniteScrollBasic.setRenderer(model -> createColumn(model));
|
sentCellList = new CellTable<ConvMessage>(ConvMessage.KEY_PROVIDER);
|
||||||
messageLoader.setVisible(false);
|
sentCellList.setPageSize(100);
|
||||||
infiniteScrollBasic.setVisible(true);
|
sentCellList.setKeyboardPagingPolicy(KeyboardPagingPolicy.INCREASE_RANGE);
|
||||||
|
sentCellList.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.BOUND_TO_SELECTION);
|
||||||
|
sentCellList.setWidth("100%", false);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
readUserMessages(false, isSendTo);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected MessageItem createColumn(ConvMessage m) {
|
/**
|
||||||
return new MessageItem(m , this, isSendTo);
|
* Add the columns to the table.
|
||||||
}
|
*/
|
||||||
|
private void initTableColumns(CellTable<ConvMessage> cellTable
|
||||||
|
,final SelectionModel<ConvMessage> selectionModel /*,
|
||||||
|
ListHandler<ConvMessage> sortHandler*/) {
|
||||||
|
// Checkbox column. This table will uses a checkbox column for selection.
|
||||||
|
// Alternatively, you can call cellTable.setSelectionEnabled(true) to enable
|
||||||
|
// mouse selection.
|
||||||
|
|
||||||
|
cellTable.setRowStyles(new RowStyles<ConvMessage>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getStyleNames(ConvMessage row, int rowIndex) {
|
||||||
|
if (row.isRead())
|
||||||
|
return "{style.read}";
|
||||||
|
else return "";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Column<ConvMessage, Boolean> checkColumn = new Column<ConvMessage, Boolean>(
|
||||||
|
new CheckboxCell(true, false)) {
|
||||||
|
@Override
|
||||||
|
public Boolean getValue(ConvMessage object) {
|
||||||
|
// Get the value from the selection model.
|
||||||
|
return selectionModel.isSelected(object);
|
||||||
|
//return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
cellTable.addColumn(checkColumn, SafeHtmlUtils.fromSafeConstant("</br>"));
|
||||||
|
cellTable.setColumnWidth(checkColumn, 80, Unit.PX);
|
||||||
|
|
||||||
}
|
// From.
|
||||||
|
Column<ConvMessage, String> fromColumn = new Column<ConvMessage, String>(
|
||||||
|
new TextCell()) {
|
||||||
|
@Override
|
||||||
|
public String getValue(ConvMessage object) {
|
||||||
|
return object.getOwner().getFullName();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
cellTable.addColumn(fromColumn, "From");
|
||||||
|
cellTable.setColumnWidth(fromColumn, 40, Unit.PCT);
|
||||||
|
|
||||||
|
// Subject.
|
||||||
|
Column<ConvMessage, String> subjectColumn = new Column<ConvMessage, String>(
|
||||||
|
new TextCell()) {
|
||||||
|
@Override
|
||||||
|
public String getValue(ConvMessage object) {
|
||||||
|
return object.getSubject();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
cellTable.addColumn(subjectColumn, "Subject");
|
||||||
|
cellTable.setColumnWidth(subjectColumn, 200, Unit.PCT);
|
||||||
|
|
||||||
|
// date.
|
||||||
|
Column<ConvMessage, String> dateColumn = new Column<ConvMessage, String>(
|
||||||
|
new TextCell()) {
|
||||||
|
@Override
|
||||||
|
public String getValue(ConvMessage object) {
|
||||||
|
return Utils.getFormatteDate(object.getDate());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
cellTable.addColumn(dateColumn, "Date");
|
||||||
|
cellTable.setColumnWidth(subjectColumn, 20, Unit.PCT);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param sent
|
* @param sent
|
||||||
*
|
*
|
||||||
|
**/
|
||||||
public void readUserMessages(final boolean sent, boolean isSendTo) {
|
public void readUserMessages(final boolean sent, boolean isSendTo) {
|
||||||
messagesLoader.setVisible(true);
|
|
||||||
convService.getMessages(sent, new AsyncCallback<ArrayList<ConvMessage>>() {
|
convService.getMessages(sent, new AsyncCallback<ArrayList<ConvMessage>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable arg0) {
|
public void onFailure(Throwable arg0) {
|
||||||
|
@ -158,55 +247,35 @@ public class ApplicationView extends Composite {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(ArrayList<ConvMessage> messages) {
|
public void onSuccess(ArrayList<ConvMessage> messages) {
|
||||||
if (messages != null) {
|
if (messages != null) {
|
||||||
showMessages(messages, sent);
|
totalMessages = messages.size();
|
||||||
if (!isSendTo) {
|
mp = new MessageProvider(messages);
|
||||||
if (messages.size() > 0)
|
mp.addDataDisplay(sentCellList);
|
||||||
readUserMessage(messages.get(0).getId(), sent);
|
|
||||||
else {
|
// Add a selection model so we can select cells.
|
||||||
writeWelcomeMessage();
|
final SelectionModel<ConvMessage> selectionModel = new MultiSelectionModel<ConvMessage>(ConvMessage.KEY_PROVIDER);
|
||||||
messageLoader.setVisible(false);
|
sentCellList.setSelectionModel(selectionModel,
|
||||||
}
|
DefaultSelectionEventManager.<ConvMessage> createCheckboxManager());
|
||||||
}
|
|
||||||
|
|
||||||
|
initTableColumns(sentCellList, selectionModel);
|
||||||
|
|
||||||
|
pagerPanel.setDisplay(sentCellList);
|
||||||
|
pagerPanel.setIncrementSize(50);
|
||||||
|
messageLoader.setVisible(false);
|
||||||
|
readUserMessage(mp.getDataProvider().getList().get(0).getId(), sent);
|
||||||
} else {
|
} else {
|
||||||
showErrorOccurred();
|
showErrorOccurred();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}*/
|
}
|
||||||
|
|
||||||
|
|
||||||
private void showErrorOccurred() {
|
private void showErrorOccurred() {
|
||||||
messagesCollection.clear();
|
//messagesCollection.clear();
|
||||||
messagesLoader.setVisible(false);
|
|
||||||
messageLoader.setVisible(false);
|
messageLoader.setVisible(false);
|
||||||
hideSidePanel();
|
hideSidePanel();
|
||||||
writeErrorMessage();
|
writeErrorMessage();
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param messages
|
|
||||||
* @param sent
|
|
||||||
*/
|
|
||||||
public void showMessages(ArrayList<ConvMessage> messages, boolean sent) {
|
|
||||||
messagesCollection.clear();
|
|
||||||
messagesLoader.setVisible(false);
|
|
||||||
messagesCollection.setVisible(true);
|
|
||||||
int scrollerHeight = Window.getClientHeight() - 100;
|
|
||||||
scrollerPanel.setHeight(scrollerHeight+"px");
|
|
||||||
for (ConvMessage convMessage : messages) {
|
|
||||||
messagesCollection.add(new MessageItem(convMessage, messagesCollection, this, sent));
|
|
||||||
if (! (sent || convMessage.isRead()))
|
|
||||||
unreadMessages++;
|
|
||||||
totalMessages++;
|
|
||||||
}
|
|
||||||
if (messages.size() > 0) {
|
|
||||||
MessageItem first = (MessageItem) messagesCollection.getChildrenList().get(0);
|
|
||||||
first.setSelected(true);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
|
||||||
updateBadge(sent);
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param sent
|
* @param sent
|
||||||
|
@ -261,7 +330,7 @@ public class ApplicationView extends Composite {
|
||||||
displayMessage(messageId, sent);
|
displayMessage(messageId, sent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayMessage(String messageId, final boolean sent) {
|
private void displayMessage(String messageId, final boolean sent) {
|
||||||
messageLoader.setColor(Utils.getRandomColor());
|
messageLoader.setColor(Utils.getRandomColor());
|
||||||
messageLoader.setVisible(true);
|
messageLoader.setVisible(true);
|
||||||
|
@ -285,7 +354,7 @@ public class ApplicationView extends Composite {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateBadge(boolean sent) {
|
private void updateBadge(boolean sent) {
|
||||||
String badgeText = totalMessages + (sent ? " sent" : " (" + unreadMessages + " unread" + ")");
|
String badgeText = totalMessages + (sent ? " sent" : " (" + unreadMessages + " unread" + ")");
|
||||||
if (unreadMessages == 0 && !sent)
|
if (unreadMessages == 0 && !sent)
|
||||||
|
@ -337,7 +406,7 @@ public class ApplicationView extends Composite {
|
||||||
private void displayNewOrReplyMessage() {
|
private void displayNewOrReplyMessage() {
|
||||||
WRITING_MESSAGE = true;
|
WRITING_MESSAGE = true;
|
||||||
FAB.setVisible(false);
|
FAB.setVisible(false);
|
||||||
messagesCollection.clearActive();
|
//messagesCollection.clearActive();
|
||||||
scrollerPanel.clear();
|
scrollerPanel.clear();
|
||||||
scrollerPanel.add(newMessageDisplay);
|
scrollerPanel.add(newMessageDisplay);
|
||||||
newMessageDisplay.setFocusOnUsersInput();
|
newMessageDisplay.setFocusOnUsersInput();
|
||||||
|
@ -398,7 +467,6 @@ public class ApplicationView extends Composite {
|
||||||
displayMessage.getMainPanel().setGrid("l8 m12 s12");
|
displayMessage.getMainPanel().setGrid("l8 m12 s12");
|
||||||
newMessageDisplay.getMainPanel().setLeft(350);
|
newMessageDisplay.getMainPanel().setLeft(350);
|
||||||
newMessageDisplay.getMainPanel().setGrid("l8 m12 s12");
|
newMessageDisplay.getMainPanel().setGrid("l8 m12 s12");
|
||||||
rightPanel.setLeft(0);
|
|
||||||
toggle = ! toggle;
|
toggle = ! toggle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -408,7 +476,6 @@ public class ApplicationView extends Composite {
|
||||||
newMessageDisplay.getMainPanel().setLeft(0);
|
newMessageDisplay.getMainPanel().setLeft(0);
|
||||||
newMessageDisplay.getMainPanel().setGrid("l12 s12 m12");
|
newMessageDisplay.getMainPanel().setGrid("l12 s12 m12");
|
||||||
|
|
||||||
rightPanel.setLeft(-350);
|
|
||||||
toggle = ! toggle;
|
toggle = ! toggle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -425,9 +492,9 @@ public class ApplicationView extends Composite {
|
||||||
FAB.setVisible(false);
|
FAB.setVisible(false);
|
||||||
displayMessage.showMessage(welcomeMessage);
|
displayMessage.showMessage(welcomeMessage);
|
||||||
welcomeMessage.setContent(MessagesResources.WELCOME_MESSAGE.substring(0, 102)+ " ...");
|
welcomeMessage.setContent(MessagesResources.WELCOME_MESSAGE.substring(0, 102)+ " ...");
|
||||||
MessageItem item = new MessageItem(welcomeMessage, messagesCollection, this, false);
|
MessageItem item = new MessageItem(welcomeMessage, false);
|
||||||
item.hideMessageMenu();
|
//item.hideMessageMenu();
|
||||||
messagesCollection.add(item);
|
//messagesCollection.add(item);
|
||||||
totalMessages++;
|
totalMessages++;
|
||||||
updateBadge(false);
|
updateBadge(false);
|
||||||
}
|
}
|
||||||
|
@ -441,9 +508,9 @@ public class ApplicationView extends Composite {
|
||||||
FAB.setVisible(false);
|
FAB.setVisible(false);
|
||||||
displayMessage.showMessage(welcomeMessage);
|
displayMessage.showMessage(welcomeMessage);
|
||||||
welcomeMessage.setContent(MessagesResources.ERROR_MESSAGE.substring(0, 102)+ " ...");
|
welcomeMessage.setContent(MessagesResources.ERROR_MESSAGE.substring(0, 102)+ " ...");
|
||||||
MessageItem item = new MessageItem(welcomeMessage, messagesCollection, this, false);
|
MessageItem item = new MessageItem(welcomeMessage, false);
|
||||||
item.hideMessageMenu();
|
//item.hideMessageMenu();
|
||||||
messagesCollection.add(item);
|
//messagesCollection.add(item);
|
||||||
totalMessages++;
|
totalMessages++;
|
||||||
updateBadge(false);
|
updateBadge(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
|
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
|
||||||
xmlns:g='urn:import:com.google.gwt.user.client.ui' xmlns:m="urn:import:gwt.material.design.client.ui"
|
xmlns:g='urn:import:com.google.gwt.user.client.ui'
|
||||||
|
xmlns:m="urn:import:gwt.material.design.client.ui"
|
||||||
xmlns:ma="urn:import:gwt.material.design.addins.client"
|
xmlns:ma="urn:import:gwt.material.design.addins.client"
|
||||||
xmlns:mc="urn:import:org.gcube.portets.user.message_conversations.client.autocomplete"
|
xmlns:mc="urn:import:org.gcube.portets.user.message_conversations.client.autocomplete"
|
||||||
xmlns:incubator="urn:import:gwt.material.design.incubator.client">
|
xmlns:s="urn:import:org.gcube.portets.user.message_conversations.client.ui">
|
||||||
|
|
||||||
<ui:style>
|
<ui:style>
|
||||||
.animation {
|
.animation {
|
||||||
|
@ -22,14 +23,17 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.marginTop {
|
.marginTop {
|
||||||
margin-top: 0px;
|
margin-top: 60px;
|
||||||
min-height: 850px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.overflowXHidden {
|
.overflowXHidden {
|
||||||
overflow-x: hidden !important; /* needed in windows */
|
overflow-x: hidden !important; /* needed in windows */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.read {
|
||||||
|
font-weight: bold; font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
.modalTitle {
|
.modalTitle {
|
||||||
font-size: 2em;
|
font-size: 2em;
|
||||||
}
|
}
|
||||||
|
@ -39,63 +43,61 @@
|
||||||
padding: 50px;
|
padding: 50px;
|
||||||
}
|
}
|
||||||
</ui:style>
|
</ui:style>
|
||||||
<g:HTMLPanel ui:field="htmlPanel">
|
<g:HTMLPanel ui:field="htmlPanel" >
|
||||||
<!-- TOP BAR -->
|
<!-- TOP BAR -->
|
||||||
<m:MaterialHeader ui:field="header">
|
<m:MaterialNavBar ui:field="navBar"
|
||||||
<m:MaterialNavBar ui:field="navBar" layoutPosition="FIXED"
|
layoutPosition="RELATIVE" addStyleNames="{style.topBar}" height="60"
|
||||||
addStyleNames="{style.topBar}" height="60" backgroundColor="WHITE">
|
backgroundColor="WHITE">
|
||||||
<m:MaterialNavSection float="LEFT" showOn="SHOW_ON_MED_DOWN">
|
<m:MaterialNavSection float="LEFT"
|
||||||
<m:MaterialLink iconType="MENU" iconColor="LIGHT_BLUE_DARKEN_2"
|
showOn="SHOW_ON_MED_DOWN">
|
||||||
paddingLeft="25" waves="DEFAULT" ui:field="menu" hideOn="HIDE_ON_MED_DOWN" />
|
<m:MaterialLink iconType="MENU"
|
||||||
<m:MaterialLink iconType="INBOX" textColor="LIGHT_BLUE_DARKEN_2"
|
iconColor="LIGHT_BLUE_DARKEN_2" paddingLeft="25" waves="DEFAULT"
|
||||||
ui:field="switcher" waves="DEFAULT" paddingLeft="25">
|
ui:field="menu" hideOn="HIDE_ON_MED_DOWN" />
|
||||||
<m:MaterialBadge text="22 unread" backgroundColor="LIGHT_BLUE_DARKEN_2"
|
<m:MaterialLink iconType="INBOX"
|
||||||
textColor="WHITE" circle="false" ui:field="badge" visible="false"
|
textColor="LIGHT_BLUE_DARKEN_2" ui:field="switcher"
|
||||||
|
waves="DEFAULT" paddingLeft="25">
|
||||||
|
<m:MaterialBadge text="22 unread"
|
||||||
|
backgroundColor="LIGHT_BLUE_DARKEN_2" textColor="WHITE"
|
||||||
|
circle="false" ui:field="badge" visible="false"
|
||||||
hideOn="HIDE_ON_MED_DOWN" />
|
hideOn="HIDE_ON_MED_DOWN" />
|
||||||
</m:MaterialLink>
|
</m:MaterialLink>
|
||||||
<m:MaterialLink ui:field="newMessage" text="New"
|
<m:MaterialLink ui:field="newMessage" text="New"
|
||||||
showOn="SHOW_ON_MED_DOWN" iconType="MESSAGE" textColor="LIGHT_BLUE_DARKEN_2"
|
showOn="SHOW_ON_MED_DOWN" iconType="MESSAGE"
|
||||||
waves="LIGHT" />
|
textColor="LIGHT_BLUE_DARKEN_2" waves="LIGHT" />
|
||||||
</m:MaterialNavSection>
|
</m:MaterialNavSection>
|
||||||
</m:MaterialNavBar>
|
</m:MaterialNavBar>
|
||||||
</m:MaterialHeader>
|
|
||||||
|
<div height='100%'>
|
||||||
|
|
||||||
|
<!-- SIDE PANEL -->
|
||||||
<!-- SIDE PANEL -->
|
<s:ShowMorePagerPanel ui:field='pagerPanel' addStyleNames="{style.overflowXHidden}" height="300px" />
|
||||||
<m:MaterialRow ui:field="rightPanel" overflow="AUTO"
|
|
||||||
depth="995" grid="l3 m3 s12" padding="0" backgroundColor="WHITE"
|
|
||||||
height="100%" layoutPosition="FIXED" top="60" left="0" width="350px"
|
|
||||||
addStyleNames="{style.animation} {style.borderRight}">
|
|
||||||
<!-- <m:MaterialProgress type="INDETERMINATE"
|
|
||||||
ui:field="messagesLoader" color="BLUE" /> -->
|
|
||||||
<incubator:infinitescroll.InfiniteScrollPanel
|
|
||||||
ui:field="infiniteScrollBasic" addStyleNames="{style.marginTop}"
|
|
||||||
overflow="AUTO" />
|
|
||||||
</m:MaterialRow>
|
|
||||||
|
|
||||||
<!-- MAIN WINDOW -->
|
|
||||||
<m:MaterialContainer fontSize="0.8em">
|
|
||||||
<m:MaterialRow layoutPosition="RELATIVE" grid="l8 s12 m12"
|
|
||||||
top="65">
|
|
||||||
<m:MaterialProgress type="INDETERMINATE"
|
|
||||||
ui:field="messageLoader" color="TEAL" />
|
|
||||||
<g:ScrollPanel height="600px" ui:field="scrollerPanel"
|
|
||||||
addStyleNames="{style.overflowXHidden}"></g:ScrollPanel>
|
|
||||||
</m:MaterialRow>
|
|
||||||
</m:MaterialContainer>
|
|
||||||
|
|
||||||
|
<!-- MAIN WINDOW -->
|
||||||
|
<m:MaterialContainer>
|
||||||
|
<m:MaterialRow fontSize="0.8em">
|
||||||
|
<m:MaterialProgress type="INDETERMINATE"
|
||||||
|
ui:field="messageLoader" color="TEAL" />
|
||||||
|
<g:ScrollPanel ui:field="scrollerPanel"
|
||||||
|
addStyleNames="{style.overflowXHidden}"></g:ScrollPanel>
|
||||||
|
</m:MaterialRow>
|
||||||
|
</m:MaterialContainer>
|
||||||
|
|
||||||
|
</div>
|
||||||
<!-- FAB -->
|
<!-- FAB -->
|
||||||
<m:MaterialFAB ui:field="FAB">
|
<m:MaterialFAB ui:field="FAB">
|
||||||
<m:MaterialButton type="FLOATING" backgroundColor="RED"
|
<m:MaterialButton type="FLOATING"
|
||||||
iconType="REPLY" size="LARGE" />
|
backgroundColor="RED" iconType="REPLY" size="LARGE" />
|
||||||
<m:MaterialFABList>
|
<m:MaterialFABList>
|
||||||
<m:MaterialAnchorButton type="FLOATING"
|
<m:MaterialAnchorButton type="FLOATING"
|
||||||
waves="LIGHT" backgroundColor="BLUE" ui:field="forward" iconType="FORWARD" />
|
waves="LIGHT" backgroundColor="BLUE" ui:field="forward"
|
||||||
|
iconType="FORWARD" />
|
||||||
<m:MaterialAnchorButton type="FLOATING"
|
<m:MaterialAnchorButton type="FLOATING"
|
||||||
waves="LIGHT" backgroundColor="AMBER" ui:field="replyAll" iconType="REPLY_ALL" />
|
waves="LIGHT" backgroundColor="AMBER" ui:field="replyAll"
|
||||||
|
iconType="REPLY_ALL" />
|
||||||
<m:MaterialAnchorButton type="FLOATING"
|
<m:MaterialAnchorButton type="FLOATING"
|
||||||
waves="LIGHT" backgroundColor="TEAL" ui:field="reply" iconType="REPLY" />
|
waves="LIGHT" backgroundColor="TEAL" ui:field="reply"
|
||||||
|
iconType="REPLY" />
|
||||||
</m:MaterialFABList>
|
</m:MaterialFABList>
|
||||||
</m:MaterialFAB>
|
</m:MaterialFAB>
|
||||||
</g:HTMLPanel>
|
</g:HTMLPanel>
|
||||||
|
|
|
@ -7,10 +7,11 @@ import org.gcube.portets.user.message_conversations.shared.MessagesWindow;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
|
||||||
import gwt.material.design.incubator.client.infinitescroll.data.DataSource;
|
import gwt.material.design.client.data.DataSource;
|
||||||
import gwt.material.design.incubator.client.infinitescroll.data.LoadCallback;
|
import gwt.material.design.client.data.loader.LoadCallback;
|
||||||
import gwt.material.design.incubator.client.infinitescroll.data.LoadConfig;
|
import gwt.material.design.client.data.loader.LoadConfig;
|
||||||
import gwt.material.design.incubator.client.infinitescroll.data.LoadResult;
|
import gwt.material.design.client.data.loader.LoadResult;
|
||||||
|
|
||||||
|
|
||||||
public class MessageDataSource implements DataSource<ConvMessage> {
|
public class MessageDataSource implements DataSource<ConvMessage> {
|
||||||
|
|
||||||
|
@ -23,6 +24,7 @@ public class MessageDataSource implements DataSource<ConvMessage> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(LoadConfig<ConvMessage> loadConfig, LoadCallback<ConvMessage> callback) {
|
public void load(LoadConfig<ConvMessage> loadConfig, LoadCallback<ConvMessage> callback) {
|
||||||
|
|
||||||
|
@ -30,7 +32,7 @@ public class MessageDataSource implements DataSource<ConvMessage> {
|
||||||
new AsyncCallback<MessagesWindow>() {
|
new AsyncCallback<MessagesWindow>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(MessagesWindow messages) {
|
public void onSuccess(MessagesWindow messages) {
|
||||||
callback.onSuccess(new LoadResult<ConvMessage>(messages.getMessages(), loadConfig.getOffset(), messages.getTotal()));
|
callback.onSuccess(new LoadResult<>(messages.getMessages(), loadConfig.getOffset(), messages.getTotal()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -41,4 +43,16 @@ public class MessageDataSource implements DataSource<ConvMessage> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean useRemoteSort() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ import com.google.gwt.user.client.ui.Composite;
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
|
||||||
import gwt.material.design.client.constants.Color;
|
import gwt.material.design.client.constants.Color;
|
||||||
import gwt.material.design.client.ui.MaterialCollection;
|
|
||||||
import gwt.material.design.client.ui.MaterialCollectionItem;
|
import gwt.material.design.client.ui.MaterialCollectionItem;
|
||||||
import gwt.material.design.client.ui.MaterialDropDown;
|
import gwt.material.design.client.ui.MaterialDropDown;
|
||||||
import gwt.material.design.client.ui.MaterialIcon;
|
import gwt.material.design.client.ui.MaterialIcon;
|
||||||
|
@ -43,8 +42,6 @@ public class MessageItem extends Composite {
|
||||||
|
|
||||||
private boolean deleteClicked = true;
|
private boolean deleteClicked = true;
|
||||||
|
|
||||||
private ApplicationView ap;
|
|
||||||
private MaterialCollection parentCollection;
|
|
||||||
private ConvMessage myMessage;
|
private ConvMessage myMessage;
|
||||||
private boolean sent;
|
private boolean sent;
|
||||||
|
|
||||||
|
@ -64,13 +61,12 @@ public class MessageItem extends Composite {
|
||||||
MessagesResources images = GWT.create(MessagesResources.class);
|
MessagesResources images = GWT.create(MessagesResources.class);
|
||||||
|
|
||||||
|
|
||||||
public MessageItem(final ConvMessage m, MaterialCollection parentCollection, ApplicationView ap, boolean sent) {
|
public MessageItem(final ConvMessage m, boolean sent) {
|
||||||
initWidget(uiBinder.createAndBindUi(this));
|
initWidget(uiBinder.createAndBindUi(this));
|
||||||
item.getElement().getStyle().setCursor(Cursor.POINTER);
|
item.getElement().getStyle().setCursor(Cursor.POINTER);
|
||||||
this.sent = sent;
|
this.sent = sent;
|
||||||
this.myMessage = m;
|
this.myMessage = m;
|
||||||
this.ap = ap;
|
//this.parentCollection = parentCollection;
|
||||||
this.parentCollection = parentCollection;
|
|
||||||
if (m.hasAttachments())
|
if (m.hasAttachments())
|
||||||
attachmentsIcon.setVisibility(Visibility.VISIBLE);
|
attachmentsIcon.setVisibility(Visibility.VISIBLE);
|
||||||
if (!sent && !m.isRead())
|
if (!sent && !m.isRead())
|
||||||
|
@ -128,7 +124,7 @@ public class MessageItem extends Composite {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
/*
|
||||||
deleteButton.addClickHandler(new ClickHandler() {
|
deleteButton.addClickHandler(new ClickHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(ClickEvent event) {
|
public void onClick(ClickEvent event) {
|
||||||
|
@ -145,26 +141,14 @@ public class MessageItem extends Composite {
|
||||||
new MaterialToast(()->{doDelete(m.getSubject());}, link).toast("Deleting Message ("+m.getSubject()+")");
|
new MaterialToast(()->{doDelete(m.getSubject());}, link).toast("Deleting Message ("+m.getSubject()+")");
|
||||||
item.setVisible(false);
|
item.setVisible(false);
|
||||||
}
|
}
|
||||||
});
|
}); */
|
||||||
dd.getElement().getStyle().setWidth(300, Unit.PX);
|
dd.getElement().getStyle().setWidth(300, Unit.PX);
|
||||||
String activator = "activate"+Random.nextInt();
|
String activator = "activate"+Random.nextInt();
|
||||||
dd.setActivator(activator);
|
dd.setActivator(activator);
|
||||||
messageActionIcon.setActivates(activator);
|
messageActionIcon.setActivates(activator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
@UiHandler("setUnreadButton")
|
|
||||||
void onSetUnread(ClickEvent e) {
|
|
||||||
e.stopPropagation();
|
|
||||||
if (myMessage.isRead()) {
|
|
||||||
ap.setMessageUnread(myMessage, this.sent);
|
|
||||||
myMessage.setRead(false);
|
|
||||||
item.addStyleName("unread-message");
|
|
||||||
} else {
|
|
||||||
Window.alert("Message is marked as unread already.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doDelete(String subject) {
|
private void doDelete(String subject) {
|
||||||
if (deleteClicked) {
|
if (deleteClicked) {
|
||||||
ap.deleteMessage(myMessage, this.sent);
|
ap.deleteMessage(myMessage, this.sent);
|
||||||
|
@ -172,7 +156,8 @@ public class MessageItem extends Composite {
|
||||||
else
|
else
|
||||||
deleteClicked = true;
|
deleteClicked = true;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
public void setSelected(boolean active) {
|
public void setSelected(boolean active) {
|
||||||
item.setBackgroundColor(Color.WHITE);
|
item.setBackgroundColor(Color.WHITE);
|
||||||
item.removeStyleName("unread-message");
|
item.removeStyleName("unread-message");
|
||||||
|
@ -180,22 +165,14 @@ public class MessageItem extends Composite {
|
||||||
myMessage.setRead(true);
|
myMessage.setRead(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
@UiHandler("item")
|
@UiHandler("item")
|
||||||
void onClickedMessage(ClickEvent e) {
|
void onClickedMessage(ClickEvent e) {
|
||||||
checkHideSideBarOnMobile();
|
checkHideSideBarOnMobile();
|
||||||
parentCollection.clearActive();
|
//parentCollection.clearActive();
|
||||||
ap.readUserMessage(myMessage.getId(), this.sent);
|
ap.readUserMessage(myMessage.getId(), this.sent);
|
||||||
setSelected(true);
|
setSelected(true);
|
||||||
myMessage.setRead(true);
|
myMessage.setRead(true);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
private void checkHideSideBarOnMobile() {
|
|
||||||
if (Utils.isMobile())
|
|
||||||
ap.hideSidePanel();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void hideMessageMenu() {
|
|
||||||
messageActionIcon.setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,79 @@
|
||||||
|
package org.gcube.portets.user.message_conversations.client.ui;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.portets.user.message_conversations.shared.ConvMessage;
|
||||||
|
|
||||||
|
import com.google.gwt.view.client.HasData;
|
||||||
|
import com.google.gwt.view.client.ListDataProvider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The data source for contact information used in the sample.
|
||||||
|
*/
|
||||||
|
public class MessageProvider {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The singleton instance of the database.
|
||||||
|
|
||||||
|
private static MessageProvider instance;
|
||||||
|
|
||||||
|
|
||||||
|
* Get the singleton instance of the contact database.
|
||||||
|
*
|
||||||
|
* @return the singleton instance
|
||||||
|
|
||||||
|
public static MessageProvider get() {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new MessageProvider();
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The provider that holds the list of contacts in the database.
|
||||||
|
*/
|
||||||
|
private ListDataProvider<ConvMessage> dataProvider = new ListDataProvider<ConvMessage>();
|
||||||
|
|
||||||
|
|
||||||
|
public MessageProvider(List<ConvMessage> messages) {
|
||||||
|
List<ConvMessage> contacts = dataProvider.getList();
|
||||||
|
contacts.addAll(messages);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new contact.
|
||||||
|
*
|
||||||
|
* @param contact the contact to add.
|
||||||
|
*/
|
||||||
|
public void addMessage(ConvMessage message) {
|
||||||
|
List<ConvMessage> contacts = dataProvider.getList();
|
||||||
|
// Remove the contact first so we don't add a duplicate.
|
||||||
|
contacts.remove(message);
|
||||||
|
contacts.add(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a display to the database. The current range of interest of the display
|
||||||
|
* will be populated with data.
|
||||||
|
*
|
||||||
|
* @param display a {@Link HasData}.
|
||||||
|
*/
|
||||||
|
public void addDataDisplay(HasData<ConvMessage> display) {
|
||||||
|
dataProvider.addDataDisplay(display);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public ListDataProvider<ConvMessage> getDataProvider() {
|
||||||
|
return dataProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refresh all displays.
|
||||||
|
*/
|
||||||
|
public void refreshDisplays() {
|
||||||
|
dataProvider.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,105 @@
|
||||||
|
package org.gcube.portets.user.message_conversations.client.ui;
|
||||||
|
|
||||||
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.event.dom.client.ScrollEvent;
|
||||||
|
import com.google.gwt.event.dom.client.ScrollHandler;
|
||||||
|
import com.google.gwt.user.cellview.client.AbstractPager;
|
||||||
|
import com.google.gwt.user.client.ui.ScrollPanel;
|
||||||
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
import com.google.gwt.view.client.HasRows;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A scrolling pager that automatically increases the range every time the
|
||||||
|
* scroll bar reaches the bottom.
|
||||||
|
*/
|
||||||
|
public class ShowMorePagerPanel extends AbstractPager {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default increment size.
|
||||||
|
*/
|
||||||
|
private static final int DEFAULT_INCREMENT = 20;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The increment size.
|
||||||
|
*/
|
||||||
|
private int incrementSize = DEFAULT_INCREMENT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The last scroll position.
|
||||||
|
*/
|
||||||
|
private int lastScrollPos = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The scrollable panel.
|
||||||
|
*/
|
||||||
|
private final ScrollPanel scrollable = new ScrollPanel();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a new {@link ShowMorePagerPanel}.
|
||||||
|
*/
|
||||||
|
public ShowMorePagerPanel() {
|
||||||
|
initWidget(scrollable);
|
||||||
|
|
||||||
|
// Do not let the scrollable take tab focus.
|
||||||
|
scrollable.getElement().setTabIndex(-1);
|
||||||
|
|
||||||
|
// Handle scroll events.
|
||||||
|
scrollable.addScrollHandler(new ScrollHandler() {
|
||||||
|
public void onScroll(ScrollEvent event) {
|
||||||
|
// If scrolling up, ignore the event.
|
||||||
|
int oldScrollPos = lastScrollPos;
|
||||||
|
lastScrollPos = scrollable.getVerticalScrollPosition();
|
||||||
|
if (oldScrollPos >= lastScrollPos) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
HasRows display = getDisplay();
|
||||||
|
if (display == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int maxScrollTop = scrollable.getWidget().getOffsetHeight()
|
||||||
|
- scrollable.getOffsetHeight();
|
||||||
|
if (lastScrollPos >= maxScrollTop) {
|
||||||
|
// We are near the end, so increase the page size.
|
||||||
|
int newPageSize = Math.min(
|
||||||
|
display.getVisibleRange().getLength() + incrementSize,
|
||||||
|
display.getRowCount());
|
||||||
|
display.setVisibleRange(0, newPageSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the number of rows by which the range is increased when the scrollbar
|
||||||
|
* reaches the bottom.
|
||||||
|
*
|
||||||
|
* @return the increment size
|
||||||
|
*/
|
||||||
|
public int getIncrementSize() {
|
||||||
|
return incrementSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDisplay(HasRows display) {
|
||||||
|
assert display instanceof Widget : "display must extend Widget";
|
||||||
|
scrollable.setWidget((Widget) display);
|
||||||
|
super.setDisplay(display);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the number of rows by which the range is increased when the scrollbar
|
||||||
|
* reaches the bottom.
|
||||||
|
*
|
||||||
|
* @param incrementSize the incremental number of rows
|
||||||
|
*/
|
||||||
|
public void setIncrementSize(int incrementSize) {
|
||||||
|
GWT.log("increment of "+ incrementSize);
|
||||||
|
this.incrementSize = incrementSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onRangeOrRowCountChanged() {
|
||||||
|
GWT.log("range changed ...");
|
||||||
|
}
|
||||||
|
}
|
|
@ -277,20 +277,20 @@ public class WriteMessage extends Composite {
|
||||||
@UiHandler("btnSendModal")
|
@UiHandler("btnSendModal")
|
||||||
void onSendMessage(ClickEvent e) {
|
void onSendMessage(ClickEvent e) {
|
||||||
if (getSelectedUsers().isEmpty()) {
|
if (getSelectedUsers().isEmpty()) {
|
||||||
acModal.setErrorText("Look empty to me");
|
acModal.setError("Look empty to me");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
acModal.reset();
|
acModal.reset();
|
||||||
}
|
}
|
||||||
if (txtBoxSubject.getText().isEmpty()) {
|
if (txtBoxSubject.getText().isEmpty()) {
|
||||||
txtBoxSubject.setErrorText("Subject is mandatory");
|
txtBoxSubject.setError("Subject is mandatory");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
txtBoxSubject.reset();
|
txtBoxSubject.reset();
|
||||||
}
|
}
|
||||||
if (txtArea.getText().isEmpty()) {
|
if (txtArea.getText().isEmpty()) {
|
||||||
txtArea.setErrorText("The body of the message is mandatory");
|
txtArea.setError("The body of the message is mandatory");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -149,12 +149,13 @@ public class FakeConvServiceImpl extends RemoteServiceServlet implements Message
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MessagesWindow getMessagesWindows(boolean sent, int limit, int offset) {
|
public MessagesWindow getMessagesWindows(boolean sent, int limit, int offset) {
|
||||||
|
_log.info("get Message Window called limit {} offset {}", limit, offset);
|
||||||
if (sent) {
|
if (sent) {
|
||||||
List<ConvMessage> messages = sentMessages.subList(0, messageSentNumberToTest);
|
List<ConvMessage> messages = sentMessages.subList(0, messageSentNumberToTest);
|
||||||
return new MessagesWindow(messages.size(), new ArrayList<>(sentMessages.subList(offset, limit)));
|
return new MessagesWindow(messages.size(), new ArrayList<>(messages.subList(offset, offset+limit)));
|
||||||
} else {
|
} else {
|
||||||
List<ConvMessage> messages = receivedMessages.subList(0, messageReceivedNumberToTest);
|
List<ConvMessage> messages = receivedMessages.subList(0, messageReceivedNumberToTest);
|
||||||
return new MessagesWindow(messages.size(), new ArrayList<>(receivedMessages.subList(offset, limit)));
|
return new MessagesWindow(messages.size(), new ArrayList<>(messages.subList(offset, offset+limit)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||||
|
import com.google.gwt.view.client.ProvidesKey;
|
||||||
|
|
||||||
|
|
||||||
public class ConvMessage implements IsSerializable{
|
public class ConvMessage implements IsSerializable{
|
||||||
|
@ -17,7 +18,15 @@ public class ConvMessage implements IsSerializable{
|
||||||
private boolean isRead;
|
private boolean isRead;
|
||||||
private ArrayList<FileModel> attachments;
|
private ArrayList<FileModel> attachments;
|
||||||
private boolean hasAttachments;
|
private boolean hasAttachments;
|
||||||
|
|
||||||
|
|
||||||
|
public static final ProvidesKey<ConvMessage> KEY_PROVIDER = new ProvidesKey<ConvMessage>() {
|
||||||
|
@Override
|
||||||
|
public Object getKey(ConvMessage item) {
|
||||||
|
return item == null ? null : item.getId();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public ConvMessage() {
|
public ConvMessage() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
@ -54,8 +63,8 @@ public class ConvMessage implements IsSerializable{
|
||||||
this.hasAttachments = hasAttachments;
|
this.hasAttachments = hasAttachments;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ConvMessage(String id, String subject, MessageUserModel owner, List<MessageUserModel> recipients, Date date,
|
public ConvMessage(String id, String subject, MessageUserModel owner, List<MessageUserModel> recipients, Date date,
|
||||||
String content, boolean isRead, boolean hasAttachments) {
|
String content, boolean isRead, boolean hasAttachments) {
|
||||||
super();
|
super();
|
||||||
|
@ -157,8 +166,30 @@ public class ConvMessage implements IsSerializable{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
ConvMessage other = (ConvMessage) obj;
|
||||||
|
if (id == null) {
|
||||||
|
if (other.id != null)
|
||||||
|
return false;
|
||||||
|
} else if (!id.equals(other.id))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
<!-- Inherit the core Web Toolkit stuff. -->
|
<!-- Inherit the core Web Toolkit stuff. -->
|
||||||
<inherits name='com.google.gwt.user.User' />
|
<inherits name='com.google.gwt.user.User' />
|
||||||
|
|
||||||
|
<inherits name="com.google.gwt.logging.Logging" />
|
||||||
<!-- Inherit the default GWT style sheet. You can change -->
|
<!-- Inherit the default GWT style sheet. You can change -->
|
||||||
<!-- the theme of your GWT application by uncommenting -->
|
<!-- the theme of your GWT application by uncommenting -->
|
||||||
<!-- any one of the following lines. -->
|
<!-- any one of the following lines. -->
|
||||||
|
@ -14,11 +15,6 @@
|
||||||
<!-- GWT Material -->
|
<!-- GWT Material -->
|
||||||
<inherits name="gwt.material.design.GwtMaterialWithJQueryDebug" />
|
<inherits name="gwt.material.design.GwtMaterialWithJQueryDebug" />
|
||||||
|
|
||||||
<inherits name="gwt.material.design.addins.GwtMaterialAddins"/>
|
|
||||||
<inherits name="gwt.material.design.incubator.AddinsIncubator"/>
|
|
||||||
<inherits name="gwt.material.design.GwtMaterialTable"/>
|
|
||||||
|
|
||||||
|
|
||||||
<!--Inherit the GCubeClientContext widget code -->
|
<!--Inherit the GCubeClientContext widget code -->
|
||||||
<inherits name='org.gcube.portal.clientcontext.GCubeClientContext' />
|
<inherits name='org.gcube.portal.clientcontext.GCubeClientContext' />
|
||||||
<inherits name="gwt.material.design.addins.GwtMaterialAddins" />
|
<inherits name="gwt.material.design.addins.GwtMaterialAddins" />
|
||||||
|
|
Loading…
Reference in New Issue