Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added MAX_TEXT_LENGTH_ACTIVITY, ..._COMMENT constants

  • Loading branch information...
commit f90979c6d17d2782e9c1aa7c97e2548ab3f0b33c 1 parent 9958f4c
@sdrieling authored
View
4 ChangeLog
@@ -0,0 +1,4 @@
+2011-07-14 Sven Drieling
+
+ * Added character count for share, update activity and post comment with
+ red label and error requester if the text is too long.
View
2  src/main/java/org/onesocialweb/gwt/client/OswClient.java
@@ -45,6 +45,8 @@
import com.google.gwt.user.client.Window.Location;
public class OswClient {
+ public static final int MAX_TEXT_LENGTH_ACTIVITY = 256;
+ public static final int MAX_TEXT_LENGTH_COMMENT = 256;
// internationalization
private UserInterfaceText uiText = (UserInterfaceText) GWT.create(UserInterfaceText.class);
View
3  src/main/java/org/onesocialweb/gwt/client/i18n/UserInterfaceMessages.java
@@ -29,5 +29,6 @@
String YouHaveNConnections(int connections);
String WelcomeToServer(String servername);
-
+ // instructions
+ String MaxTextLength(int maxLength);
}
View
2  src/main/java/org/onesocialweb/gwt/client/i18n/UserInterfaceMessages.properties
@@ -5,3 +5,5 @@ ListedAsTags = Listed as: {0}
YouHaveNConnections = You have {0} connection(s)
WelcomeToServer = Welcome to {0}
+# instructions
+MaxTextLength = Maximum length of text is {0} characters.
View
1  src/main/java/org/onesocialweb/gwt/client/i18n/UserInterfaceText.java
@@ -164,7 +164,6 @@
String NoFollowers();
String NoFollowing();
String EmptyUpdate();
- String MaxTextSize();
String RegistrationSuccess();
String PleaseLogin();
String NoStatusUpdates();
View
1  src/main/java/org/onesocialweb/gwt/client/i18n/UserInterfaceText.properties
@@ -128,7 +128,6 @@ AddOrRemovePerson = Add or remove person from your lists below.
IdentityFixed = Please note that this identity cannot be changed.
SetLanguage = Choose your preferred language below. This will be stored in your browser and the page will reload. \n You may need to login again.
EmptyUpdate = Is that really all you have to say? Please try again!
-MaxTextSize = Maximum length of text is 255 characters.
# notifications
FetchingProfile = Fetching the profile
View
9 src/main/java/org/onesocialweb/gwt/client/ui/widget/compose/CommentPanel.java
@@ -24,6 +24,7 @@
import org.onesocialweb.gwt.client.OswClient;
import org.onesocialweb.gwt.client.handler.PictureHandler;
+import org.onesocialweb.gwt.client.i18n.UserInterfaceMessages;
import org.onesocialweb.gwt.client.i18n.UserInterfaceText;
import org.onesocialweb.gwt.client.task.DefaultTaskInfo;
import org.onesocialweb.gwt.client.task.TaskInfo.Status;
@@ -63,6 +64,7 @@
// internationalization
private UserInterfaceText uiText = (UserInterfaceText) GWT.create(UserInterfaceText.class);
+ private UserInterfaceMessages uiMessages = (UserInterfaceMessages) GWT.create(UserInterfaceMessages.class);
public static final String EVERYONE = "Everyone";
@@ -75,6 +77,7 @@
ActivityActor actor=null;
public CommentPanel() {
+ textareaUpdate.setMaxTextLength(OswClient.MAX_TEXT_LENGTH_COMMENT);
}
@@ -214,11 +217,11 @@ public void onClick(ClickEvent event) {
}
private void postComment() {
- if (textareaUpdate.getText().length() > 255) {
+ if (textareaUpdate.getText().length() > OswClient.MAX_TEXT_LENGTH_COMMENT) {
AlertDialog
.getInstance()
.showDialog(
- uiText.MaxTextSize(),
+ uiMessages.MaxTextLength(OswClient.MAX_TEXT_LENGTH_COMMENT),
uiText.TextTooLong());
return;
}
@@ -330,7 +333,7 @@ public void onSuccess(Profile result) {
private /*final*/ RepliesPanel<ActivityEntry> replies = new RepliesPanel<ActivityEntry>();
private final Label attachment = new Label("Add:");
- private final Label charCount = new Label("0/255");
+ private final Label charCount = new Label("0/" + OswClient.MAX_TEXT_LENGTH_COMMENT);
private final Button buttonUpdate = new Button(uiText.PostComment());
private final TextareaUpdate textareaUpdate = new TextareaUpdate(charCount);
private boolean localComment = false;
View
10 src/main/java/org/onesocialweb/gwt/client/ui/widget/compose/EditActivityPanel.java
@@ -18,6 +18,8 @@
*/
package org.onesocialweb.gwt.client.ui.widget.compose;
+import org.onesocialweb.gwt.client.OswClient;
+import org.onesocialweb.gwt.client.i18n.UserInterfaceMessages;
import org.onesocialweb.gwt.client.i18n.UserInterfaceText;
import org.onesocialweb.gwt.client.task.DefaultTaskInfo;
import org.onesocialweb.gwt.client.task.TaskInfo.Status;
@@ -47,6 +49,7 @@
// internationalization
private UserInterfaceText uiText = (UserInterfaceText) GWT.create(UserInterfaceText.class);
+ private UserInterfaceMessages uiMessages = (UserInterfaceMessages) GWT.create(UserInterfaceMessages.class);
private final ComponentHelper componentHelper = new ComponentHelper();
private final InternalComponentListener componentListener = new InternalComponentListener();
@@ -54,6 +57,7 @@
public EditActivityPanel(ActivityItemView aiv) {
this.view = aiv;
+ textareaUpdate.setMaxTextLength(OswClient.MAX_TEXT_LENGTH_ACTIVITY);
}
public void compose() {
@@ -125,11 +129,11 @@ public void prepareUpdate() {
}
private void updateActivity() {
- if (textareaUpdate.getText().length() > 255) {
+ if (textareaUpdate.getText().length() > OswClient.MAX_TEXT_LENGTH_ACTIVITY) {
AlertDialog
.getInstance()
.showDialog(
- uiText.MaxTextSize(),
+ uiMessages.MaxTextLength(OswClient.MAX_TEXT_LENGTH_ACTIVITY),
uiText.TextTooLong());
return;
}
@@ -201,7 +205,7 @@ private boolean hasText(String text){
private final FlowPanel statusPanel = new FlowPanel();
private final FlowPanel flow = new FlowPanel();
- private final Label charCount = new Label("0/255");
+ private final Label charCount = new Label("0/" + OswClient.MAX_TEXT_LENGTH_ACTIVITY);
private final Button buttonUpdate = new Button(uiText.Update());
private final TextareaUpdate textareaUpdate = new TextareaUpdate(charCount);
View
11 src/main/java/org/onesocialweb/gwt/client/ui/widget/compose/NewActivityPanel.java
@@ -20,6 +20,7 @@
import org.onesocialweb.gwt.client.OswClient;
import org.onesocialweb.gwt.client.handler.PictureHandler;
+import org.onesocialweb.gwt.client.i18n.UserInterfaceMessages;
import org.onesocialweb.gwt.client.i18n.UserInterfaceText;
import org.onesocialweb.gwt.client.task.DefaultTaskInfo;
import org.onesocialweb.gwt.client.task.TaskMonitor;
@@ -55,7 +56,8 @@
// internationalization
private UserInterfaceText uiText = (UserInterfaceText) GWT.create(UserInterfaceText.class);
-
+ private UserInterfaceMessages uiMessages = (UserInterfaceMessages) GWT.create(UserInterfaceMessages.class);
+
private final ListModel<ActivityObject> pictureAttachments = new ListModel<ActivityObject>();
private final ComponentHelper componentHelper = new ComponentHelper();
@@ -64,6 +66,7 @@
public NewActivityPanel() {
composePanel();
+ textareaUpdate.setMaxTextLength(OswClient.MAX_TEXT_LENGTH_ACTIVITY);
}
public void reset() {
@@ -108,11 +111,11 @@ private void postStatusUpdate() {
return;
}
- if (textareaUpdate.getText().length() > 255) {
+ if (textareaUpdate.getText().length() > OswClient.MAX_TEXT_LENGTH_ACTIVITY) {
AlertDialog
.getInstance()
.showDialog(
- uiText.MaxTextSize(),
+ uiMessages.MaxTextLength(OswClient.MAX_TEXT_LENGTH_ACTIVITY),
uiText.TextTooLong());
return;
}
@@ -277,7 +280,7 @@ public void onClick(ClickEvent event) {
private final FlowPanel attachmentsPanel = new FlowPanel();
private final FlowPanel flow = new FlowPanel();
private final Label attachment = new Label(uiText.Add());
- private final Label charCount = new Label("0/255");
+ private final Label charCount = new Label("0/" + OswClient.MAX_TEXT_LENGTH_ACTIVITY);
private final Button buttonUpdate = new Button(uiText.Share());
private final TextareaUpdate textareaUpdate = new TextareaUpdate(charCount);
View
11 src/main/java/org/onesocialweb/gwt/client/ui/widget/compose/TextareaUpdate.java
@@ -16,6 +16,8 @@
*/
package org.onesocialweb.gwt.client.ui.widget.compose;
+import org.onesocialweb.gwt.client.OswClient;
+
import com.google.gwt.event.dom.client.KeyPressEvent;
import com.google.gwt.event.dom.client.KeyPressHandler;
import com.google.gwt.event.dom.client.KeyUpEvent;
@@ -28,6 +30,7 @@
protected TextArea update = new TextArea();
protected Label charCount = null;
+ protected int maxTextLength = 0;
// private SuggestBox suggest = new SuggestBox();
@@ -72,8 +75,8 @@ public void onKeyUp(KeyUpEvent event) {
public void updateCharCount() {
if(null != charCount) {
- charCount.setText(getText().length() + "/255");
- if(getText().length() > 255) {
+ charCount.setText(getText().length() + "/" + maxTextLength);
+ if(getText().length() > maxTextLength) {
charCount.addStyleName("errorLabel");
} else {
charCount.removeStyleName("errorLabel");
@@ -90,4 +93,8 @@ public String getText() {
return update.getText();
}
+ public void setMaxTextLength(int length) {
+ maxTextLength = length;
+ }
+
}
Please sign in to comment.
Something went wrong with that request. Please try again.