List of usage examples for com.vaadin.client UIDL getStringAttribute
public String getStringAttribute(String name)
From source file:org.eclipse.hawkbit.ui.dd.client.criteria.ViewClientCriterion.java
License:Open Source License
/** * Hides the highlighted drop target hints. * * @param configuration//from ww w .java 2s.c om * for the accept criterion to retrieve the drop target hints. */ // Exception squid:S1166 - Hide origin exception // Exception squid:S2221 - This code is trans-coded to JavaScript, hence // Exception semantics changes @SuppressWarnings({ "squid:S1166", "squid:S2221" }) void hideDropTargetHints(final UIDL configuration) { final int totalDropTargetHintsCount = configuration.getIntAttribute(DROP_AREA_CONFIG_COUNT); for (int dropAreaIndex = 0; dropAreaIndex < totalDropTargetHintsCount; dropAreaIndex++) { try { final String dropArea = configuration.getStringAttribute(DROP_AREA_CONFIG + dropAreaIndex); final Element hideHintFor = Document.get().getElementById(dropArea); if (hideHintFor != null) { hideHintFor.removeClassName(ViewComponentClientCriterion.HINT_AREA_STYLE); } } catch (final Exception e) { // log and continue LOGGER.log(Level.SEVERE, "Error highlighting valid drop targets: " + e.getLocalizedMessage()); } } }
From source file:org.eclipse.hawkbit.ui.dd.client.criteria.ViewComponentClientCriterion.java
License:Open Source License
/** * Checks if this accept criterion is responsible for the current drag * source. Therefore the current drag source id has to start with the drag * source id-prefix configured for the criterion. * * @param drag/* w w w .j a v a2s .c o m*/ * the current drag event holding the context. * @param configuration * for the accept criterion to retrieve the configured drag * source id-prefix. * @return <code>true</code> if the criterion is responsible for the current * drag source, otherwise <code>false</code>. */ // Exception squid:S1166 - Hide origin exception // Exception squid:S2221 - This code is trans-coded to JavaScript, hence // Exception semantics changes @SuppressWarnings({ "squid:S1166", "squid:S2221" }) boolean isValidDragSource(final VDragEvent drag, final UIDL configuration) { try { final String dragSource = drag.getTransferable().getDragSource().getWidget().getElement().getId(); final String dragSourcePrefix = configuration.getStringAttribute(DRAG_SOURCE); if (dragSource.startsWith(dragSourcePrefix)) { return true; } } catch (final Exception e) { // log and continue LOGGER.log(Level.SEVERE, "Error verifying drag source: " + e.getLocalizedMessage()); } return false; }
From source file:org.eclipse.hawkbit.ui.dd.client.criteria.ViewComponentClientCriterion.java
License:Open Source License
/** * Highlights the valid drop targets configured for the criterion. * * @param configuration// w ww. j a v a2s . c o m * for the accept criterion to retrieve the configured drop hint * areas. */ // Exception squid:S1166 - Hide origin exception // Exception squid:S2221 - This code is trans-coded to JavaScript, hence // Exception semantics changes // Exception squid:S2629 - not supported by GWT @SuppressWarnings({ "squid:S1166", "squid:S2221", "squid:S2629" }) void showDropTargetHints(final UIDL configuration) { final int dropAreaCount = configuration.getIntAttribute(DROP_AREA_COUNT); for (int dropAreaIndex = 0; dropAreaIndex < dropAreaCount; dropAreaIndex++) { try { final String dropArea = configuration.getStringAttribute(DROP_AREA + dropAreaIndex); LOGGER.log(Level.FINE, "Hint Area: " + dropArea); final Element showHintFor = Document.get().getElementById(dropArea); if (showHintFor != null) { showHintFor.addClassName(HINT_AREA_STYLE); } } catch (final Exception e) { // log and continue LOGGER.log(Level.SEVERE, "Error highlighting drop targets: " + e.getLocalizedMessage()); } } }
From source file:org.eclipse.hawkbit.ui.dd.client.criteria.ViewComponentClientCriterion.java
License:Open Source License
/** * Checks if the current drop location is a valid drop target for the * criterion. Therefore the current drop location id has to start with one * of the drop target id-prefixes configured for the criterion. * * @param configuration//from w w w . ja v a2s . c o m * for the accept criterion to retrieve the configured drop * target id-prefixes. * @return <code>true</code> if the current drop location is a valid drop * target for the criterion, otherwise <code>false</code>. */ // Exception squid:S1166 - Hide origin exception // Exception squid:S2221 - This code is trans-coded to JavaScript, hence // Exception semantics changes // Exception squid:S2629 - not supported by GWT @SuppressWarnings({ "squid:S1166", "squid:S2221", "squid:S2629" }) boolean isValidDropTarget(final UIDL configuration) { try { final String dropTarget = VDragAndDropManager.get().getCurrentDropHandler().getConnector().getWidget() .getElement().getId(); final int dropTargetCount = configuration.getIntAttribute(DROP_TARGET_COUNT); for (int dropTargetIndex = 0; dropTargetIndex < dropTargetCount; dropTargetIndex++) { final String dropTargetPrefix = configuration.getStringAttribute(DROP_TARGET + dropTargetIndex); LOGGER.log(Level.FINE, "Drop Target: " + dropTargetPrefix); if (dropTarget.startsWith(dropTargetPrefix)) { return true; } } } catch (final Exception e) { // log and continue LOGGER.log(Level.SEVERE, "Error verifying drop target: " + e.getLocalizedMessage()); } return false; }
From source file:org.tepi.filtertable.gwt.client.ui.VFilterTreeTable.java
License:Apache License
/** * Icons rendered into first actual column in TreeTable, not to row header * cell//from ww w.j a v a 2 s. com */ @Override protected String buildCaptionHtmlSnippet(UIDL uidl) { if (uidl.getTag().equals("column")) { return super.buildCaptionHtmlSnippet(uidl); } else { String s = uidl.getStringAttribute("caption"); return s; } }
From source file:org.vaadin.alump.ckeditor.client.VCKEditorTextField.java
License:Apache License
/** * Called whenever an update is received from the server *//* w w w .java 2s . com*/ @Override public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { clientToServer = client; paintableId = uidl.getId(); boolean needsDataUpdate = false; boolean needsProtectedBodyUpdate = false; boolean readOnlyModeChanged = false; // This call should be made first. // It handles sizes, captions, tooltips, etc. automatically. // If clientToServer.updateComponent returns true there have been no changes // and we do not need to update anything. if (clientToServer.updateComponent(this, uidl, true)) { return; } if (!resizeListenerInPlace) { LayoutManager.get(client).addElementResizeListener(getElement(), new ElementResizeListener() { @Override public void onElementResize(ElementResizeEvent e) { doResize(); } }); resizeListenerInPlace = true; } if (uidl.hasAttribute(ATTR_IMMEDIATE)) { immediate = uidl.getBooleanAttribute(ATTR_IMMEDIATE); } if (uidl.hasAttribute(ATTR_READONLY)) { boolean newReadOnly = uidl.getBooleanAttribute(ATTR_READONLY); readOnlyModeChanged = newReadOnly != readOnly; readOnly = newReadOnly; } if (uidl.hasAttribute(ATTR_VIEW_WITHOUT_EDITOR)) { viewWithoutEditor = uidl.getBooleanAttribute(ATTR_VIEW_WITHOUT_EDITOR); } if (uidl.hasAttribute(ATTR_PROTECTED_BODY)) { boolean state = uidl.getBooleanAttribute(ATTR_PROTECTED_BODY); if (protectedBody != state) { protectedBody = state; needsProtectedBodyUpdate = true; } } if (uidl.hasVariable(VAR_TEXT)) { String data = uidl.getStringVariable(VAR_TEXT); if (ckEditor != null) dataBeforeEdit = ckEditor.getData(); needsDataUpdate = !data.equals(dataBeforeEdit); dataBeforeEdit = data; } // Save the client side identifier (paintable id) for the widget if (!paintableId.equals(getElement().getId())) { getElement().setId(paintableId); } if (viewWithoutEditor) { if (ckEditor != null) { // may update the data and change to viewWithoutEditor at the same time if (!needsDataUpdate) { dataBeforeEdit = ckEditor.getData(); } ckEditor.destroy(true); ckEditorIsReady = false; ckEditor = null; } getElement().setInnerHTML(dataBeforeEdit); } else if (ckEditor == null) { getElement().setInnerHTML(""); // in case we put contents in there while in viewWithoutEditor mode final String inPageConfig = uidl.hasAttribute(ATTR_INPAGECONFIG) ? uidl.getStringAttribute(ATTR_INPAGECONFIG) : null; writerIndentationChars = uidl.hasAttribute(ATTR_WRITER_INDENTATIONCHARS) ? uidl.getStringAttribute(ATTR_WRITER_INDENTATIONCHARS) : null; if (uidl.hasAttribute(ATTR_FOCUS)) { setFocus(uidl.getBooleanAttribute(ATTR_FOCUS)); } // See if we have any writer rules int i = 0; while (true) { if (!uidl.hasAttribute(ATTR_WRITERRULES_TAGNAME + i)) { break; } // Save the rules until our instance is ready String tagName = uidl.getStringAttribute(ATTR_WRITERRULES_TAGNAME + i); String jsRule = uidl.getStringAttribute(ATTR_WRITERRULES_JSRULE + i); if (writerRules == null) { writerRules = new HashMap<String, String>(); } writerRules.put(tagName, jsRule); ++i; } // See if we have any keystrokes i = 0; while (true) { if (!uidl.hasAttribute(ATTR_KEYSTROKES_KEYSTROKE + i)) { break; } // Save the keystrokes until our instance is ready int keystroke = uidl.getIntAttribute(ATTR_KEYSTROKES_KEYSTROKE + i); String command = uidl.getStringAttribute(ATTR_KEYSTROKES_COMMAND + i); if (keystrokeMappings == null) { keystrokeMappings = new HashMap<Integer, String>(); } keystrokeMappings.put(keystroke, command); ++i; } // See if we have any protected source regexs i = 0; while (true) { if (!uidl.hasAttribute(ATTR_PROTECTED_SOURCE + i)) { break; } // Save the regex until our instance is ready String regex = uidl.getStringAttribute(ATTR_PROTECTED_SOURCE + i); if (protectedSourceList == null) { protectedSourceList = new LinkedList<String>(); } protectedSourceList.add(regex); ++i; } ScheduledCommand scE = new ScheduledCommand() { @Override public void execute() { ckEditor = (CKEditor) CKEditorService.loadEditor(paintableId, VCKEditorTextField.this, inPageConfig, VCKEditorTextField.super.getOffsetWidth(), VCKEditorTextField.super.getOffsetHeight()); } }; CKEditorService.loadLibrary(scE); // editor data and some options are set when the instance is ready.... } else if (ckEditorIsReady) { if (needsDataUpdate) { ckEditor.setData(dataBeforeEdit); } if (needsProtectedBodyUpdate) { ckEditor.protectBody(protectedBody); } if (uidl.hasAttribute(ATTR_INSERT_HTML)) { ckEditor.insertHtml(uidl.getStringAttribute(ATTR_INSERT_HTML)); } if (uidl.hasAttribute(ATTR_INSERT_TEXT)) { ckEditor.insertText(uidl.getStringAttribute(ATTR_INSERT_TEXT)); } if (uidl.hasAttribute(ATTR_FOCUS)) { setFocus(uidl.getBooleanAttribute(ATTR_FOCUS)); } if (readOnlyModeChanged) { ckEditor.setReadOnly(readOnly); } } }
From source file:org.vaadin.tepi.listbuilder.widgetset.client.ui.VListBuilder.java
License:Apache License
void updateCaptions(UIDL uidl) { String leftCaption = (uidl.hasAttribute(ATTRIBUTE_LEFT_CAPTION) ? uidl.getStringAttribute(ATTRIBUTE_LEFT_CAPTION) : null);/*from w ww . ja v a 2s . c o m*/ String rightCaption = (uidl.hasAttribute(ATTRIBUTE_RIGHT_CAPTION) ? uidl.getStringAttribute(ATTRIBUTE_RIGHT_CAPTION) : null); /* Column caption styles */ if (uidl.hasAttribute("leftColumnCaptionStyle")) { leftColumnCaptionStyle = uidl.getStringAttribute("leftColumnCaptionStyle"); } else { leftColumnCaptionStyle = null; } if (uidl.hasAttribute("rightColumnCaptionStyle")) { rightColumnCaptionStyle = uidl.getStringAttribute("rightColumnCaptionStyle"); } else { rightColumnCaptionStyle = null; } boolean hasCaptions = (leftCaption != null || rightCaption != null); if (leftCaption == null) { removeOptionsCaption(); } else { getOptionsCaption().setText(leftCaption); if (leftColumnCaptionStyle != null) { getOptionsCaption().setStyleName(leftColumnCaptionStyle); getOptionsCaption().addStyleName(CLASSNAME + "-caption-left"); } else { getOptionsCaption().setStyleName(CLASSNAME + "-caption-left"); } } if (rightCaption == null) { removeSelectionsCaption(); } else { getSelectionsCaption().setText(rightCaption); if (rightColumnCaptionStyle != null) { getSelectionsCaption().setStyleName(rightColumnCaptionStyle); getSelectionsCaption().addStyleName(CLASSNAME + "-caption-right"); } else { getSelectionsCaption().setStyleName(CLASSNAME + "-caption-right"); } } captionWrapper.setVisible(hasCaptions); }
From source file:org.vaadin.tepi.listbuilder.widgetset.client.ui.VListBuilder.java
License:Apache License
void buildOptions(UIDL uidl) { final boolean enabled = !isDisabled() && !isReadonly(); options.setEnabled(enabled);/*from w ww . j ava 2 s .c o m*/ selections.setEnabled(enabled); add.setEnabled(enabled); remove.setEnabled(enabled); options.clear(); selections.clear(); originalOrder.clear(); HashMap<String, String> capts = new HashMap<String, String>(); for (final Iterator<?> i = uidl.getChildIterator(); i.hasNext();) { final UIDL optionUidl = (UIDL) i.next(); if (optionUidl.hasAttribute("selected")) { capts.put(optionUidl.getStringAttribute("key"), optionUidl.getStringAttribute("caption")); } else { options.addItem(optionUidl.getStringAttribute("caption"), optionUidl.getStringAttribute("key")); } originalOrder.add(optionUidl.getStringAttribute("key")); } for (String key : selectedKeys) { selections.addItem(capts.get(key), key); } if (getRows() > 0) { options.setVisibleItemCount(getRows()); selections.setVisibleItemCount(getRows()); } }
From source file:org.vaadin.tltv.multiscrolltable.client.ui.HeaderPanel.java
License:Apache License
private ColumnPanel updateContentByGroupUidl(UIDL uidl, int level, int index, ColumnPanel prevColumn, ColumnPanel group) {//from w w w . j a v a 2 s.co m if (uidl == null) { return null; } String caption = uidl.getStringAttribute(VCustomScrollTable.ATTR_CAPTION); ColumnPanel p = getColumnPanel(level, index, prevColumn, group); updateGroupElement(p); p.getLabel().setText(caption); boolean updateColSpan = false; int childs = uidl.getChildCount(); if (childs <= 0) { return p; } int cellCount = p.getFirstChildIndex(); if (reConstruct) { // When reconstructing, p.getFirstChildIndex() value is not updated // yet. try { cellCount = content.getCellCount(level + 1); } catch (IndexOutOfBoundsException e) { cellCount = 0; } } ColumnPanel prev = null; for (int i = 0; i < childs; i++) { UIDL subUidl = uidl.getChildUIDL(i); if (subUidl.getTag().equals(VCustomScrollTable.TAG_COLUMN)) { prev = updateContentByColumnUidl(subUidl, level + 1, cellCount + i, prev, p); updateColSpan = reConstruct; } else if (subUidl.getTag().equals(VCustomScrollTable.TAG_COLUMNGROUP)) { prev = updateContentByGroupUidl(subUidl, level + 1, i, prev, p); } } if (updateColSpan) { // This needs to be called only for the "leaf" panels. p.setColSpan(childs); } return p; }
From source file:org.vaadin.tltv.multiscrolltable.client.ui.HeaderPanel.java
License:Apache License
private ColumnPanel updateContentByColumnUidl(UIDL uidl, int level, int index, ColumnPanel prev, ColumnPanel group) {// www. j a v a 2 s .c o m String caption = uidl.getStringAttribute(VCustomScrollTable.ATTR_CAPTION); ColumnPanel p = getColumnPanel(level, index, prev, group); updateColumnElement(p); p.getLabel().setText(caption); return p; }