public WorkItemDefinitionEditor() { textArea.setWidth("100%"); textArea.setVisibleLines(25); textArea.setStyleName(WorkItemsEditorResources.INSTANCE.CSS().defaultTextArea()); textArea.getElement().setAttribute("spellcheck", "false"); textArea.addChangeHandler( new ChangeHandler() { public void onChange(ChangeEvent event) { isDirty = true; } }); textArea.addKeyDownHandler( new KeyDownHandler() { public void onKeyDown(KeyDownEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_TAB) { event.preventDefault(); event.stopPropagation(); int pos = textArea.getCursorPos(); insertText("\t"); textArea.setCursorPos(pos + 1); textArea.cancelKey(); textArea.setFocus(true); } } }); initWidget(textArea); }
public DefaultRuleContentWidget(RuleAsset a, int visibleLines) { asset = a; data = (RuleContentText) asset.getContent(); if (data.content == null) { data.content = ""; } text = new TextArea(); text.setWidth("100%"); text.setVisibleLines((visibleLines == -1) ? 16 : visibleLines); text.setText(data.content); text.getElement().setAttribute("spellcheck", "false"); // NON-NLS text.setStyleName("default-text-Area"); // NON-NLS text.addChangeHandler( new ChangeHandler() { public void onChange(ChangeEvent event) { data.content = text.getText(); makeDirty(); } }); text.addKeyDownHandler( new KeyDownHandler() { public void onKeyDown(KeyDownEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_TAB) { int pos = text.getCursorPos(); insertText("\t"); text.setCursorPos(pos + 1); text.cancelKey(); text.setFocus(true); } } }); initWidget(text); }
public WorkitemDefinitionEditor(RuleAsset a, int visibleLines) { asset = a; data = (RuleContentText) asset.getContent(); if (data.content == null) { data.content = "Empty!"; } Grid layout = new Grid(1, 2); WorkitemDefinitionElementsBrowser browser = new WorkitemDefinitionElementsBrowser( new WorkitemDefinitionElementSelectedListener() { public void onElementSelected(String elementName, String pasteValue) { insertText(pasteValue, true); } }); layout.setWidget(0, 0, browser); text = new TextArea(); text.setWidth("100%"); text.setVisibleLines((visibleLines == -1) ? 25 : visibleLines); text.setText(data.content); text.getElement().setAttribute("spellcheck", "false"); // NON-NLS text.setStyleName("default-text-Area"); // NON-NLS text.addChangeHandler( new ChangeHandler() { public void onChange(ChangeEvent event) { data.content = text.getText(); makeDirty(); } }); text.addKeyDownHandler( new KeyDownHandler() { public void onKeyDown(KeyDownEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_TAB) { event.preventDefault(); event.stopPropagation(); int pos = text.getCursorPos(); insertText("\t", false); text.setCursorPos(pos + 1); text.cancelKey(); text.setFocus(true); } } }); layout.setWidget(0, 1, text); layout.getColumnFormatter().setWidth(0, "10%"); layout.getColumnFormatter().setWidth(1, "90%"); layout .getCellFormatter() .setAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_TOP); layout .getCellFormatter() .setAlignment(0, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_TOP); layout.setWidth("95%"); initWidget(layout); }
/** Activate the control. */ public void activate() { clear(); this.setVisible(true); Widget avatar = new AvatarWidget( Session.getInstance().getCurrentPerson().getAvatarId(), EntityType.PERSON, Size.VerySmall); avatar.addStyleName(StaticResourceBundle.INSTANCE.coreCss().avatar()); this.add(avatar); FlowPanel body = new FlowPanel(); body.addStyleName(StaticResourceBundle.INSTANCE.coreCss().body()); SimplePanel boxWrapper = new SimplePanel(); boxWrapper.addStyleName(StaticResourceBundle.INSTANCE.coreCss().boxWrapper()); commentBox = new ExtendedTextArea(true); boxWrapper.add(commentBox); body.add(boxWrapper); commentBox.setFocus(true); countDown = new Label(Integer.toString(MAXLENGTH)); countDown.addStyleName(StaticResourceBundle.INSTANCE.coreCss().charactersRemaining()); body.add(countDown); post = new PushButton("post"); post.addStyleName(StaticResourceBundle.INSTANCE.coreCss().postButton()); post.addStyleName(StaticResourceBundle.INSTANCE.coreCss().inactive()); body.add(post); final Label warning = new Label(); warning.addStyleName(StaticResourceBundle.INSTANCE.coreCss().warning()); warning.addStyleName(StaticResourceBundle.INSTANCE.coreCss().hidden()); body.add(warning); Session.getInstance() .getEventBus() .addObserver( GotSystemSettingsResponseEvent.class, new Observer<GotSystemSettingsResponseEvent>() { public void update(final GotSystemSettingsResponseEvent event) { String text = event.getResponse().getContentWarningText(); if (text != null && !text.isEmpty()) { warning.removeStyleName(StaticResourceBundle.INSTANCE.coreCss().hidden()); warning.setText(text); } } }); SystemSettingsModel.getInstance().fetch(null, true); post.addClickHandler( new ClickHandler() { public void onClick(final ClickEvent event) { fullCollapse = false; if (!inactive) { unActivate(); CommentDTO comment = new CommentDTO(); comment.setBody(commentBox.getText()); comment.setActivityId(messageId); Session.getInstance() .getActionProcessor() .makeRequest( "postActivityCommentAction", comment, new AsyncCallback<CommentDTO>() { /* implement the async call back methods */ public void onFailure(final Throwable caught) {} public void onSuccess(final CommentDTO result) { ActivityModel.getInstance().clearCache(); Session.getInstance() .getEventBus() .notifyObservers(new CommentAddedEvent(result, messageId)); } }); } } }); this.add(body); commentBox.setFocus(true); nativeSetFocus(commentBox.getElement()); commentBox.addBlurHandler( new BlurHandler() { public void onBlur(final BlurEvent arg0) { TimerFactory timerFactory = new TimerFactory(); timerFactory.runTimer( BLUR_DELAY, new TimerHandler() { public void run() { if (commentBox.getText().length() == 0) { unActivate(); } } }); } }); commentBox.addKeyDownHandler( new KeyDownHandler() { public void onKeyDown(final KeyDownEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) { unActivate(); } else if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER && event.isControlKeyDown()) { post.getElement() .dispatchEvent( Document.get().createClickEvent(1, 0, 0, 0, 0, false, false, false, false)); event.preventDefault(); event.stopPropagation(); } } }); commentBox.addKeyUpHandler( new KeyUpHandler() { public void onKeyUp(final KeyUpEvent event) { onCommentChanges(); } }); commentBox.addValueChangeHandler( new ValueChangeHandler<String>() { public void onValueChange(final ValueChangeEvent<String> inArg0) { onCommentChanges(); } }); commentBox.addChangeHandler( new ChangeHandler() { public void onChange(final ChangeEvent event) { onCommentChanges(); } }); }