List of usage examples for com.google.gwt.dom.client Style setPosition
public void setPosition(Position value)
From source file:org.nsesa.editor.gwt.core.client.ui.document.sourcefile.marker.MarkerViewImpl.java
License:EUPL
@Override public FocusWidget addMarker(final double top, final String color) { int height = getOffsetHeight(); double v = height * top; LOG.info("Drawing marker at " + (int) v); Anchor marker = new Anchor("<div></div>", true); mainPanel.add(marker);/*from w w w . j av a2 s. co m*/ final Style style = marker.getElement().getFirstChildElement().getStyle(); style.setPosition(Style.Position.ABSOLUTE); style.setTop((int) v, Style.Unit.PX); style.setWidth(100, Style.Unit.PCT); style.setHeight(5, Style.Unit.PX); style.setBorderWidth(1.0, Style.Unit.PX); style.setBackgroundColor(color); return marker; }
From source file:org.opencms.ade.containerpage.client.CmsContainerpageDNDController.java
License:Open Source License
/** * Sets styles of helper elements, appends the to the drop target and puts them into a drag info bean.<p> * // w w w. ja v a2 s . co m * @param dragHelper the drag helper element * @param placeholder the placeholder element * @param target the drop target * @param handler the drag and drop handler */ private void prepareDragInfo(Element dragHelper, Element placeholder, I_CmsDropTarget target, CmsDNDHandler handler) { target.getElement().appendChild(dragHelper); // preparing helper styles int width = CmsDomUtil.getCurrentStyleInt(dragHelper, CmsDomUtil.Style.width); Style style = dragHelper.getStyle(); style.setPosition(Position.ABSOLUTE); style.setMargin(0, Unit.PX); style.setWidth(width, Unit.PX); style.setZIndex(I_CmsLayoutBundle.INSTANCE.constants().css().zIndexDND()); dragHelper.addClassName(I_CmsLayoutBundle.INSTANCE.dragdropCss().dragging()); dragHelper.addClassName(org.opencms.gwt.client.ui.css.I_CmsLayoutBundle.INSTANCE.generalCss().shadow()); if (!CmsDomUtil.hasBackgroundImage(dragHelper)) { dragHelper.getStyle().setBackgroundColor(CmsDomUtil.getEffectiveBackgroundColor(dragHelper)); } if (!CmsDomUtil.hasBorder(dragHelper)) { dragHelper.addClassName(I_CmsLayoutBundle.INSTANCE.dragdropCss().dragElementBorder()); } style.setDisplay(Display.NONE); String positioning = CmsDomUtil.getCurrentStyle(target.getElement(), org.opencms.gwt.client.util.CmsDomUtil.Style.position); // set target relative, if not absolute or fixed if (!Position.ABSOLUTE.getCssName().equals(positioning) && !Position.FIXED.getCssName().equals(positioning)) { target.getElement().getStyle().setPosition(Position.RELATIVE); } setMinHeight(target); m_dragInfos.put(target, new DragInfo(dragHelper, placeholder, width - 15, handler.getCursorOffsetY())); handler.addTarget(target); // adding drag handle Element button = DOM.createDiv(); button.appendChild((new Image(I_CmsImageBundle.INSTANCE.icons().moveIconActive())).getElement()); button.addClassName(I_CmsLayoutBundle.INSTANCE.dragdropCss().dragHandle()); dragHelper.appendChild(button); }
From source file:org.opencms.ade.containerpage.client.CmsContainerpageHandler.java
License:Open Source License
/** * Shows a page overlay preventing user actions.<p> *//* w w w . ja v a 2 s. co m*/ public void showPageOverlay() { if (m_overlay == null) { m_overlay = new SimplePanel(); m_overlay.setStyleName(I_CmsLayoutBundle.INSTANCE.dialogCss().popupOverlay()); Style style = m_overlay.getElement().getStyle(); style.setWidth(100, Unit.PCT); style.setHeight(100, Unit.PCT); style.setPosition(Position.FIXED); } RootPanel.get().add(m_overlay); }
From source file:org.opencms.ade.containerpage.client.ui.CmsContainerPageElement.java
License:Open Source License
/** * @see org.opencms.gwt.client.dnd.I_CmsDraggable#getDragHelper(org.opencms.gwt.client.dnd.I_CmsDropTarget) *///ww w . j av a 2s . co m public Element getDragHelper(I_CmsDropTarget target) { Element helper = CmsDomUtil.clone(getElement()); target.getElement().appendChild(helper); // preparing helper styles String width = CmsDomUtil.getCurrentStyle(helper, CmsDomUtil.Style.width); Style style = helper.getStyle(); style.setPosition(Position.ABSOLUTE); style.setMargin(0, Unit.PX); style.setProperty(CmsDomUtil.Style.width.name(), width); style.setZIndex(I_CmsLayoutBundle.INSTANCE.constants().css().zIndexDND()); helper.addClassName(I_CmsLayoutBundle.INSTANCE.dragdropCss().dragging()); helper.addClassName(org.opencms.gwt.client.ui.css.I_CmsLayoutBundle.INSTANCE.generalCss().shadow()); if (!CmsDomUtil.hasBackground(helper)) { helper.addClassName(I_CmsLayoutBundle.INSTANCE.dragdropCss().dragElementBackground()); } if (!CmsDomUtil.hasBorder(helper)) { helper.addClassName(I_CmsLayoutBundle.INSTANCE.dragdropCss().dragElementBorder()); } return helper; }
From source file:org.opencms.ade.containerpage.client.ui.CmsGroupcontainerEditor.java
License:Open Source License
/** * Constructor.<p>/*from w w w . j ava 2 s .c o m*/ * * @param groupContainer the group-container * @param controller the container-page controller * @param handler the container-page handler */ private CmsGroupcontainerEditor(CmsGroupContainerElementPanel groupContainer, CmsContainerpageController controller, CmsContainerpageHandler handler) { m_controller = controller; m_editorWidget = uiBinder.createAndBindUi(this); initWidget(m_editorWidget); m_overlayDiv.getStyle().setZIndex(I_CmsLayoutBundle.INSTANCE.constants().css().zIndexHighlighting()); m_labelDescription.setText(Messages.get().key(Messages.GUI_GROUPCONTAINER_LABEL_DESCRIPTION_0)); m_labelTitle.setText(Messages.get().key(Messages.GUI_GROUPCONTAINER_LABEL_TITLE_0)); m_editorId = HTMLPanel.createUniqueId(); m_editorWidget.getElement().setId(m_editorId); m_groupContainer = groupContainer; m_backUpElements = new ArrayList<CmsContainerPageElementPanel>(); Iterator<Widget> it = m_groupContainer.iterator(); while (it.hasNext()) { Widget w = it.next(); if (w instanceof CmsContainerPageElementPanel) { m_backUpElements.add((CmsContainerPageElementPanel) w); } } m_parentContainer = (CmsContainerPageContainer) m_groupContainer.getParentTarget(); m_groupContainerPosition = CmsPositionBean.generatePositionInfo(m_groupContainer); m_editingPlaceholder = createPlaceholder(m_groupContainer.getElement()); m_groupContainer.setEditingPlaceholder(m_editingPlaceholder); m_groupContainer.setEditingMarker(m_containerMarker); m_indexPosition = m_parentContainer.getWidgetIndex(m_groupContainer); // inserting placeholder element m_parentContainer.getElement().insertBefore(m_editingPlaceholder, m_groupContainer.getElement()); m_editorWidget.add(m_groupContainer, m_editorId); Style style = m_groupContainer.getElement().getStyle(); style.setPosition(Position.ABSOLUTE); style.setLeft(m_groupContainerPosition.getLeft(), Unit.PX); style.setTop(m_groupContainerPosition.getTop(), Unit.PX); style.setWidth(m_groupContainerPosition.getWidth(), Unit.PX); style.setZIndex(I_CmsLayoutBundle.INSTANCE.constants().css().zIndexGroupContainer()); m_containerMarker.getStyle().setLeft(m_groupContainerPosition.getLeft() - 3, Unit.PX); m_containerMarker.getStyle().setTop(m_groupContainerPosition.getTop() - 4, Unit.PX); m_containerMarker.getStyle().setWidth(m_groupContainerPosition.getWidth() + 4, Unit.PX); m_containerMarker.getStyle().setHeight(m_groupContainerPosition.getHeight() + 4, Unit.PX); m_groupContainer.getElementOptionBar().setVisible(false); m_groupContainer.getElementOptionBar() .removeStyleName(I_CmsToolbarButtonLayoutBundle.INSTANCE.toolbarButtonCss().cmsHovering()); RootPanel.get().addStyleName(I_CmsLayoutBundle.INSTANCE.containerpageCss().groupcontainerEditing()); // Loading data of all contained elements including group-container element m_controller.getElements(getElementIds(), new I_CmsSimpleCallback<Map<String, CmsContainerElementData>>() { public void execute(Map<String, CmsContainerElementData> arg) { setGroupContainerData(arg); } }); }
From source file:org.opencms.ade.containerpage.client.ui.groupeditor.A_CmsGroupEditor.java
License:Open Source License
/** * Constructor.<p>/* w w w . ja v a2 s . c o m*/ * * @param groupContainer the group-container * @param controller the container-page controller * @param handler the container-page handler */ protected A_CmsGroupEditor(CmsGroupContainerElementPanel groupContainer, CmsContainerpageController controller, CmsContainerpageHandler handler) { m_controller = controller; m_handler = handler; m_editorWidget = uiBinder.createAndBindUi(this); initWidget(m_editorWidget); m_editorId = HTMLPanel.createUniqueId(); m_editorWidget.getElement().setId(m_editorId); m_groupContainer = groupContainer; m_backUpElements = new ArrayList<CmsContainerPageElementPanel>(); Iterator<Widget> it = m_groupContainer.iterator(); while (it.hasNext()) { Widget w = it.next(); if (w instanceof CmsContainerPageElementPanel) { m_backUpElements.add((CmsContainerPageElementPanel) w); } } m_parentContainer = (CmsContainerPageContainer) m_groupContainer.getParentTarget(); m_groupContainerPosition = CmsPositionBean.getBoundingClientRect(m_groupContainer.getElement()); m_editingPlaceholder = createPlaceholder(m_groupContainer.getElement()); m_groupContainer.setEditingPlaceholder(m_editingPlaceholder); m_groupContainer.setEditingMarker(m_containerMarker); m_indexPosition = m_parentContainer.getWidgetIndex(m_groupContainer); // inserting placeholder element m_parentContainer.getElement().insertBefore(m_editingPlaceholder, m_groupContainer.getElement()); m_editorWidget.add(m_groupContainer, m_editorId); Style style = m_groupContainer.getElement().getStyle(); style.setPosition(Position.ABSOLUTE); style.setLeft(m_groupContainerPosition.getLeft(), Unit.PX); style.setTop(m_groupContainerPosition.getTop(), Unit.PX); style.setWidth(m_groupContainerPosition.getWidth(), Unit.PX); style.setZIndex(I_CmsLayoutBundle.INSTANCE.constants().css().zIndexGroupContainer()); m_containerMarker.getStyle().setLeft(m_groupContainerPosition.getLeft() - 3, Unit.PX); m_containerMarker.getStyle().setTop(m_groupContainerPosition.getTop() - 4, Unit.PX); m_containerMarker.getStyle().setWidth(m_groupContainerPosition.getWidth() + 4, Unit.PX); m_containerMarker.getStyle().setHeight(m_groupContainerPosition.getHeight() + 4, Unit.PX); m_containerMarker.getStyle() .setBackgroundColor(CmsDomUtil.getEffectiveBackgroundColor(m_parentContainer.getElement())); m_groupContainer.getElementOptionBar().setVisible(false); m_groupContainer.getElementOptionBar() .removeStyleName(I_CmsToolbarButtonLayoutBundle.INSTANCE.toolbarButtonCss().cmsHovering()); RootPanel.get().addStyleName(I_CmsLayoutBundle.INSTANCE.containerpageCss().groupcontainerEditing()); addInputFields(); m_editorDialog = new CmsPopup(); addButtons(); if (m_saveButton != null) { m_saveButton.disable(Messages.get().key(Messages.GUI_GROUPCONTAINER_LOADING_DATA_0)); } m_editorDialog.setGlassEnabled(false); m_editorDialog.setModal(false); m_editorDialog.addDialogClose(new Command() { /** * @see com.google.gwt.user.client.Command#execute() */ public void execute() { cancelEdit(); } }); }
From source file:org.opencms.ade.contenteditor.client.CmsContentEditor.java
License:Open Source License
/** * Bypasses a focus bug in IE which can happen if the user opens the HTML code editor from the WYSIWYG editor.<p> * * The next time they open the editor form from the same container page, the user may be unable to focus on any input * fields. To prevent this, we create a dummy input field outside the visible screen region and focus it when opening * the editor./*www.j ava 2 s . c om*/ */ public void fixFocus() { TextBox invisibleTextBox = new TextBox(); Style style = invisibleTextBox.getElement().getStyle(); style.setPosition(Position.FIXED); style.setLeft(-99999, Unit.PX); style.setTop(-99999, Unit.PX); m_basePanel.add(invisibleTextBox); // base panel is already attached at this point, so we can just set the focus invisibleTextBox.setFocus(true); }
From source file:org.opencms.gwt.client.ui.input.CmsGalleryField.java
License:Open Source License
/** * Internal method which opens the gallery dialog.<p> *//* w w w . ja v a 2s .co m*/ protected void openGalleryDialog() { String title = org.opencms.gwt.client.Messages.get() .key(org.opencms.gwt.client.Messages.GUI_GALLERY_SELECT_DIALOG_TITLE_0); final CmsFramePopup popup = new CmsFramePopup(title, buildGalleryUrl()); popup.setCloseHandler(new Runnable() { public void run() { m_textbox.setGhostMode(false); } }); popup.setId(m_id); popup.getFrame().setSize("700px", "490px"); popup.center(); CmsPushButton button = new CmsPushButton(I_CmsImageBundle.INSTANCE.style().closeIcon()); Style style = button.getElement().getStyle(); style.setRight(4, Unit.PX); style.setTop(0, Unit.PX); style.setPosition(Position.ABSOLUTE); style.setCursor(Cursor.POINTER); button.addClickHandler(new ClickHandler() { /** * @see com.google.gwt.event.dom.client.ClickHandler#onClick(com.google.gwt.event.dom.client.ClickEvent) */ public void onClick(ClickEvent event) { popup.hide(); } }); popup.insertFront(button); }
From source file:org.opencms.gwt.client.util.CmsDebugLog.java
License:Open Source License
/** * Constructor.<p>//from ww w. ja v a2s.c om */ @SuppressWarnings("unused") private CmsDebugLog() { if (!DEBUG) { return; } m_html = new HTML(); initWidget(m_html); Style style = getElement().getStyle(); style.setWidth(200, Unit.PX); style.setHeight(500, Unit.PX); style.setPadding(10, Unit.PX); style.setOverflow(Overflow.AUTO); style.setBorderStyle(BorderStyle.SOLID); style.setBorderColor(I_CmsLayoutBundle.INSTANCE.constants().css().borderColor()); style.setBorderWidth(1, Unit.PX); style.setPosition(Position.FIXED); style.setTop(50, Unit.PX); style.setRight(50, Unit.PX); style.setBackgroundColor(I_CmsLayoutBundle.INSTANCE.constants().css().backgroundColorDialog()); style.setZIndex(10); }
From source file:org.opencms.gwt.client.util.CmsTextMetrics.java
License:Open Source License
/** * Binds this text metrics instance to an element from which to copy existing * CSS styles that can affect the size of the rendered text.<p> * //from w w w . j av a 2s . c o m * @param element the element * @param attributes the attributes to bind */ protected void bind(Element element, CmsDomUtil.Style... attributes) { if (m_elem == null) { // create playground m_elem = DOM.createDiv(); Style style = m_elem.getStyle(); style.setVisibility(Style.Visibility.HIDDEN); style.setPosition(Style.Position.ABSOLUTE); style.setLeft(-5000, Style.Unit.PX); style.setTop(-5000, Style.Unit.PX); } // copy all relevant CSS properties Style style = m_elem.getStyle(); for (CmsDomUtil.Style attr : attributes) { String attrName = attr.toString(); style.setProperty(attrName, CmsDomUtil.getCurrentStyle(element, attr)); } // append playground RootPanel.getBodyElement().appendChild(m_elem); }