Massimiliano Assante 2017-09-21 15:47:50 +00:00
parent cec5260381
commit 0a312f0849
3 changed files with 12 additions and 7 deletions

View File

@ -12,6 +12,7 @@ import com.google.gwt.user.client.ui.RootPanel;
*/
public class MessageConversations implements EntryPoint {
public static final String DIV_CONTAINER_ID = "create-users-container";
public static final String ARTIFACT_ID = "messages";
/**
* Create a remote service proxy to talk to the server-side Greeting service.
*/
@ -23,7 +24,7 @@ public class MessageConversations implements EntryPoint {
* This is the entry point method.
*/
public void onModuleLoad() {
((ServiceDefTarget) convService).setServiceEntryPoint("/delegate/message-conversations");
((ServiceDefTarget) convService).setServiceEntryPoint(Utils.getServiceEntryPoint());
ap = new ApplicationView();
RootPanel.get(DIV_CONTAINER_ID).add(ap);
ap.readUserMessages(false);

View File

@ -12,7 +12,11 @@ import gwt.material.design.client.constants.Color;
public class Utils {
public static DateTimeFormat fmCurrentYear = DateTimeFormat.getFormat("MMM d H:mm");
public static DateTimeFormat fmPastYears = DateTimeFormat.getFormat("MMM d H:mm ''yy");
public static String getServiceEntryPoint() {
return "/delegate/"+MessageConversations.ARTIFACT_ID;
}
public static Color getRandomColor() {
Color toReturn = Color.values()[Random.nextInt(Color.values().length)];
while (toReturn.name().startsWith("WHITE") ||
@ -25,13 +29,13 @@ public class Utils {
}
return toReturn;
}
public static boolean isMobile() {
int screenWidth = RootPanel.get(MessageConversations.DIV_CONTAINER_ID).getOffsetWidth();
return (screenWidth <= 768);
}
@SuppressWarnings("deprecation")
public static String getFormatteDate(Date date) {
Date now = new Date();
@ -47,5 +51,5 @@ public class Utils {
return(now.getYear() == date.getYear()) ? fmCurrentYear.format(date) : fmPastYears.format(date);
}
}
}

View File

@ -97,7 +97,7 @@ public class ApplicationView extends Composite {
public ApplicationView() {
initWidget(uiBinder.createAndBindUi(this));
((ServiceDefTarget) convService).setServiceEntryPoint("/delegate/message-conversations");
((ServiceDefTarget) convService).setServiceEntryPoint(Utils.getServiceEntryPoint());
displayMessage = new DisplayMessage(convService, this);
newMessageDisplay = new WriteMessage(convService, this);
Window.addResizeHandler(new ResizeHandler() {