public void appendToConsole(String text) { console.setText(console.getText() + text); if (console.getText().length() > 0) { console.setCursorPos(console.getText().length() - 1); console.getElement().setScrollTop(console.getElement().getScrollHeight()); } }
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 StatusPage() { msg = GWT.create(StatusMessages.class); setPageTitle(msg.title().asString()); initWidget(uiBinder.createAndBindUi(this)); container.getElement().setId("update-statut"); status.getElement().setAttribute("x-webkit-speech", "x-webkit-speech"); status.getElement().setAttribute("speech", "speech"); }
@Inject public ZipImporterPageViewImpl( ProjectImporterResource resource, ZipImporterPageViewImplUiBinder uiBinder) { style = resource.zipImporterPageStyle(); style.ensureInjected(); initWidget(uiBinder.createAndBindUi(this)); projectName.getElement().setAttribute("maxlength", "32"); projectDescription.getElement().setAttribute("maxlength", "256"); }
private TextArea createClipboardTextArea() { final TextArea pasteArea = new TextArea(); pasteArea.setPixelSize(0, 0); Style style = pasteArea.getElement().getStyle(); style.setPosition(Style.Position.FIXED); RootPanel.get().add(pasteArea); pasteArea.setFocus(true); return pasteArea; }
/** * Load CodeMirror library into editor. TODO: Switching off CodeMirror support will be removed in * Q2 2016. Targeting for R8. */ private void loadCodeMirrorForHeaders() { if (SyncAdapter.codeMirrorHeaders) { tabContent.addClassName("codeMirror"); if (headersCodeMirror != null) { headersCodeMirror.refresh(); return; } CodeMirrorOptions opt = CodeMirrorOptions.create(); opt.setMode("message/http"); // opt.setTheme("headers"); opt.setAutoClearEmptyLines(true); opt.setLineWrapping(true); CodeMirrorKeyMap extraKey = CodeMirrorKeyMap.create(); extraKey.add("Ctrl-Space", "autocompleteHeaders"); opt.setExtraKeys(extraKey); setHeadersEditor(); if (!(headersData == null || headersData.isEmpty())) { opt.setValue(headersData); } headersCodeMirror = CodeMirror.fromTextArea( headersRawInput.getElement(), opt, new CodeMirrorChangeHandler() { @Override public void onChage() { headersData = headersCodeMirror.getValue(); headersRawInput.setValue(headersData); Log.info("Code mirror change fired actually now::" + headersData); } }); setHeadersEditorCallback(headersCodeMirror.getInstance()); headersCodeMirror.refresh(); // RestClient.fixChromeLayout(); } else { if (headersCodeMirror != null) { headersCodeMirror.toTextArea(); headersCodeMirror = null; } tabContent.removeClassName("codeMirror"); } }
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); }
protected void handleTextAreaClick( FlowPanel flowPanel, DoubleClickEvent event, TextArea critReftextArea, ScrollPanel scrollPanel) { int textAreaCount = flowPanel.getWidgetCount(); String idString = critReftextArea.getText(); int idStart = idString.indexOf("<id"); int idEnd = idString.indexOf("/>", idStart); idString = idString.substring(idStart, idEnd + "/>".length()); String extension = idString.substring(idString.indexOf("extension")); extension = extension.substring(0, extension.indexOf("root")); extension = extension.trim(); String root = idString.substring(idString.indexOf("root")); root = root.substring(0, root.indexOf("/>")); root = root.trim(); for (int i = 0; i < textAreaCount; i++) { TextArea textArea = (TextArea) flowPanel.getWidget(i); if (textArea.getStyleName().indexOf("entry_background") == -1) { continue; } String text = textArea.getText(); if (text.indexOf(root) > -1 && text.indexOf(extension) > -1) { DOM.scrollIntoView(textArea.getElement()); break; } } System.out.println("Done."); }
/** Activate the control. */ public void activate() { this.clear(); this.setVisible(true); Widget avatar = new AvatarWidget( Session.getInstance().getCurrentPerson().getId(), Session.getInstance().getCurrentPerson().getAvatarId(), EntityType.PERSON, Size.VerySmall, Background.White); avatar.addStyleName("avatar"); this.add(avatar); FlowPanel body = new FlowPanel(); body.addStyleName("body"); commentBox = new TextArea(); body.add(commentBox); commentBox.setFocus(true); countDown = new Label(Integer.toString(MAXLENGTH)); countDown.addStyleName("characters-remaining"); body.add(countDown); post = new Hyperlink("post", History.getToken()); post.addStyleName("post-button"); post.addStyleName("inactive"); final Label warning = new Label(); warning.addStyleName("warning 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("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( new ActionRequestImpl<CommentDTO>("postActivityCommentAction", comment), new AsyncCallback<CommentDTO>() { /* implement the async call back methods */ public void onFailure(final Throwable caught) {} public void onSuccess(final CommentDTO result) { Session.getInstance() .getEventBus() .notifyObservers(new CommentAddedEvent(result, messageId)); } }); } } }); body.add(post); 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.addKeyPressHandler( new KeyPressHandler() { public void onKeyPress(final KeyPressEvent event) { if (event.getCharCode() == KeyCodes.KEY_ESCAPE) { unActivate(); } } }); commentBox.addKeyUpHandler( new KeyUpHandler() { public void onKeyUp(final KeyUpEvent event) { onCommentChanges(); } }); commentBox.addChangeHandler( new ChangeHandler() { public void onChange(final ChangeEvent event) { onCommentChanges(); } }); }
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(); } }); }
@Override public void onLoad() { editor = initialize(feralTextArea.getElement()); }
public static TextArea getTextArea() { TextArea t = new TextArea(); t.setStyleName(Constants.CSS_NORMAL_TEXT); t.getElement().getStyle().setProperty("resize", "none"); return t; }
public Widget draw() { // show only part of title titleWidget.setText(Utils.getStrippedStringWithEllipsis(publication.getTitle())); // MAIN PANEL ScrollPanel sp = new ScrollPanel(); sp.addStyleName("perun-tableScrollPanel"); VerticalPanel vp = new VerticalPanel(); vp.addStyleName("perun-table"); sp.add(vp); // resize perun table to correct size on screen session.getUiElements().resizePerunTable(sp, 350, this); // content final FlexTable ft = new FlexTable(); ft.setStyleName("inputFormFlexTable"); if (publication.getLocked() == false) { ft.setHTML(1, 0, "Id / Origin:"); ft.setHTML(2, 0, "Title:"); ft.setHTML(3, 0, "Year:"); ft.setHTML(4, 0, "Category:"); ft.setHTML(5, 0, "Rank:"); ft.setHTML(6, 0, "ISBN / ISSN:"); ft.setHTML(7, 0, "DOI:"); ft.setHTML(8, 0, "Full cite:"); ft.setHTML(9, 0, "Created by:"); ft.setHTML(10, 0, "Created date:"); for (int i = 0; i < ft.getRowCount(); i++) { ft.getFlexCellFormatter().setStyleName(i, 0, "itemName"); } ft.getFlexCellFormatter().setWidth(1, 0, "100px"); final ListBoxWithObjects<Category> listbox = new ListBoxWithObjects<Category>(); // fill listbox JsonCallbackEvents events = new JsonCallbackEvents() { public void onFinished(JavaScriptObject jso) { for (Category cat : JsonUtils.<Category>jsoAsList(jso)) { listbox.addItem(cat); // if right, selected if (publication.getCategoryId() == cat.getId()) { listbox.setSelected(cat, true); } } } }; FindAllCategories categories = new FindAllCategories(events); categories.retrieveData(); final TextBox rank = new TextBox(); rank.setWidth("30px"); rank.setMaxLength(4); rank.setText(String.valueOf(publication.getRank())); final TextBox title = new TextBox(); title.setMaxLength(1024); title.setText(publication.getTitle()); title.setWidth("500px"); final TextBox year = new TextBox(); year.setText(String.valueOf(publication.getYear())); year.setMaxLength(4); year.setWidth("30px"); final TextBox isbn = new TextBox(); isbn.setText(publication.getIsbn()); isbn.setMaxLength(32); final TextBox doi = new TextBox(); doi.setText(publication.getDoi()); doi.setMaxLength(256); final TextArea main = new TextArea(); main.setText(publication.getMain()); main.setSize("500px", "70px"); // set max length main.getElement().setAttribute("maxlength", "4000"); ft.setHTML( 1, 1, publication.getId() + " / <Strong>Ext. Id: </strong>" + publication.getExternalId() + " <Strong>System: </strong>" + publication.getPublicationSystemName()); ft.setWidget(2, 1, title); ft.setWidget(3, 1, year); ft.setWidget(4, 1, listbox); if (session.isPerunAdmin()) { // only perunadmin can change rank ft.setWidget(5, 1, rank); } else { ft.setHTML(5, 1, "" + publication.getRank()); } ft.setWidget(6, 1, isbn); ft.setWidget(7, 1, doi); ft.setWidget(8, 1, main); ft.setHTML(9, 1, String.valueOf(publication.getCreatedBy())); ft.setHTML( 10, 1, DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_MEDIUM) .format(new Date((long) publication.getCreatedDate()))); // update button final CustomButton change = TabMenu.getPredefinedButton(ButtonType.SAVE, "Save changes in publication details"); change.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { Publication pub = JsonUtils.clone(publication).cast(); if (!JsonUtils.checkParseInt(year.getText())) { JsonUtils.cantParseIntConfirm("YEAR", year.getText()); } else { pub.setYear(Integer.parseInt(year.getText())); } if (session.isPerunAdmin()) { pub.setRank(Double.parseDouble(rank.getText())); } pub.setCategoryId(listbox.getSelectedObject().getId()); pub.setTitle(title.getText()); pub.setMain(main.getText()); pub.setIsbn(isbn.getText()); pub.setDoi(doi.getText()); UpdatePublication upCall = new UpdatePublication( JsonCallbackEvents.disableButtonEvents( change, new JsonCallbackEvents() { public void onFinished(JavaScriptObject jso) { // refresh page content Publication p = jso.cast(); publication = p; draw(); } })); upCall.updatePublication(pub); } }); ft.setWidget(0, 0, change); } else { ft.getFlexCellFormatter().setColSpan(0, 0, 2); ft.setWidget( 0, 0, new HTML( new Image(SmallIcons.INSTANCE.lockIcon()) + " <strong>Publication is locked. Ask administrator to perform any changes for you at [email protected].</strong>")); ft.setHTML(1, 0, "Id / Origin:"); ft.setHTML(2, 0, "Title:"); ft.setHTML(3, 0, "Year:"); ft.setHTML(4, 0, "Category:"); ft.setHTML(5, 0, "Rank:"); ft.setHTML(6, 0, "ISBN / ISSN:"); ft.setHTML(7, 0, "DOI:"); ft.setHTML(8, 0, "Full cite:"); ft.setHTML(9, 0, "Created by:"); ft.setHTML(10, 0, "Created date:"); for (int i = 0; i < ft.getRowCount(); i++) { ft.getFlexCellFormatter().setStyleName(i, 0, "itemName"); } ft.getFlexCellFormatter().setWidth(1, 0, "100px"); ft.setHTML( 1, 1, publication.getId() + " / <Strong>Ext. Id: </strong>" + publication.getExternalId() + " <Strong>System: </strong>" + publication.getPublicationSystemName()); ft.setHTML(2, 1, publication.getTitle()); ft.setHTML(3, 1, String.valueOf(publication.getYear())); ft.setHTML(4, 1, publication.getCategoryName()); ft.setHTML(5, 1, String.valueOf(publication.getRank()) + " (default is 0)"); ft.setHTML(6, 1, publication.getIsbn()); ft.setHTML(7, 1, publication.getDoi()); ft.setHTML(8, 1, publication.getMain()); ft.setHTML(9, 1, String.valueOf(publication.getCreatedBy())); ft.setHTML( 10, 1, DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_MEDIUM) .format(new Date((long) publication.getCreatedDate()))); } // LOCK / UNLOCK button for PerunAdmin if (session.isPerunAdmin()) { final CustomButton lock; if (publication.getLocked()) { lock = new CustomButton( "Unlock", "Allow editing of publication details (for users).", SmallIcons.INSTANCE.lockOpenIcon()); ft.setWidget(0, 0, lock); ft.getFlexCellFormatter().setColSpan(0, 0, 1); ft.setWidget( 0, 1, new HTML(new Image(SmallIcons.INSTANCE.lockIcon()) + " Publication is locked.")); } else { lock = new CustomButton( "Lock", "Deny editing of publication details (for users).", SmallIcons.INSTANCE.lockIcon()); ft.setWidget(0, 1, lock); } lock.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { UpdatePublication upCall = new UpdatePublication( JsonCallbackEvents.disableButtonEvents( lock, new JsonCallbackEvents() { public void onFinished(JavaScriptObject jso) { // refresh page content Publication p = jso.cast(); publication = p; draw(); } })); Publication p = JsonUtils.clone(publication).cast(); p.setLocked(!publication.getLocked()); upCall.updatePublication(p); } }); } DisclosurePanel dp = new DisclosurePanel(); dp.setWidth("100%"); dp.setContent(ft); dp.setOpen(true); FlexTable detailsHeader = new FlexTable(); detailsHeader.setWidget(0, 0, new Image(LargeIcons.INSTANCE.bookIcon())); detailsHeader.setHTML(0, 1, "<h3>Details</h3>"); dp.setHeader(detailsHeader); vp.add(dp); vp.add(loadAuthorsSubTab()); vp.add(loadThanksSubTab()); this.contentWidget.setWidget(sp); return getWidget(); }