use of elemental.dom.Element in project che by eclipse.
the class AnnotationGroupImpl method buildIncludedElement.
private elemental.dom.Element buildIncludedElement(Annotation annotation, int offset) {
final elemental.dom.Element element = annotation.getImageElement();
final CSSStyleDeclaration style = element.getStyle();
int layer = annotation.getLayer();
style.setZIndex(layer);
style.setPosition(ABSOLUTE);
style.setTop("0");
style.setLeft("0");
style.setRight("0");
style.setBottom("0");
element.getDataset().setAt(MESSAGE_DATASET_NAME, annotation.getText());
element.getDataset().setAt(TYPE_DATASET_NAME, annotation.getType());
element.getDataset().setAt(LAYER_DATASET_NAME, Integer.toString(layer));
element.getDataset().setAt(OFFSET_DATASET_NAME, Integer.toString(offset));
return element;
}
use of elemental.dom.Element in project che by eclipse.
the class GutterAnnotationRenderer method removeAnnotationItem.
private void removeAnnotationItem(final AnnotationModelEvent event, final Annotation annotation) {
final Position position = event.getPositionOfRemovedAnnotation(annotation);
final TextPosition textPosition = this.document.getPositionFromIndex(position.getOffset());
final Element annotationItem = this.hasGutter.getGutterItem(textPosition.getLine(), ANNOTATION_GUTTER);
if (AnnotationGroupImpl.isAnnotation(annotationItem)) {
final AnnotationGroup group = AnnotationGroupImpl.create(annotationItem);
group.removeAnnotation(annotation, position.getOffset());
if (group.getAnnotationCount() != 0) {
return;
}
}
// else
this.hasGutter.removeGutterItem(textPosition.getLine(), ANNOTATION_GUTTER);
}
use of elemental.dom.Element in project che by eclipse.
the class FindActionViewImpl method showActions.
@Override
public void showActions(Map<Action, String> actions) {
this.actions = actions;
actionsContainer.getElement().setInnerHTML("");
TableElement itemHolder = Elements.createTableElement();
itemHolder.setClassName(css.items());
actionsContainer.getElement().appendChild(((com.google.gwt.dom.client.Element) itemHolder));
list = SimpleList.create((SimpleList.View) actionsContainer.getElement().cast(), (Element) actionsContainer.getElement(), itemHolder, resources.defaultSimpleListCss(), listItemRenderer, eventDelegate);
list.render(new ArrayList<>(actions.keySet()));
if (!actions.isEmpty()) {
list.getSelectionModel().setSelectedItem(0);
}
layoutPanel.setWidgetHidden(actionsPanel, false);
layoutPanel.setHeight("250px");
if (isVisible()) {
Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
@Override
public void execute() {
center();
}
});
}
}
use of elemental.dom.Element in project che by eclipse.
the class PopupWidget method addItem.
/**
* Add an item in the popup view.
* @param itemModel the data for the item
*/
public void addItem(final T itemModel) {
if (itemModel == null) {
return;
}
Element element = createItem(itemModel);
element.setTabIndex(1);
listElement.appendChild(element);
}
use of elemental.dom.Element in project che by eclipse.
the class PopupWidget method show.
/**
* Show the widget at the given document position.
* @param left the horizontal pixel position in the document
* @param top the vertical pixel position in the document
*/
public void show(final float left, final float top) {
if (!listElement.hasChildNodes()) {
Element emptyElement = Elements.createLiElement(popupResources.popupStyle().item());
emptyElement.setTextContent(getEmptyMessage());
listElement.appendChild(emptyElement);
return;
}
/* Reset popup dimensions and show. */
popupElement.getStyle().setLeft(left, PX);
popupElement.getStyle().setTop(top, PX);
popupElement.getStyle().setWidth("" + MIN_WIDTH + "px");
popupElement.getStyle().setHeight("" + MIN_HEIGHT + "px");
popupElement.getStyle().setOpacity(0);
Elements.getDocument().getBody().appendChild(popupElement);
Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
@Override
public void execute() {
popupElement.getStyle().setOpacity(1);
}
});
Elements.getDocument().addEventListener(Event.MOUSEDOWN, popupListener, false);
// does it fit inside the doc body?
// This does exactly the same thing for height/top and width/left
final Window window = Elements.getWindow();
final int winX = window.getInnerWidth();
final int winY = window.getInnerHeight();
ClientRect widgetRect = this.popupElement.getBoundingClientRect();
if (widgetRect.getBottom() > winY) {
// it doesn't fit
final float overflow = widgetRect.getBottom() - winY;
if (widgetRect.getHeight() - overflow > MIN_HEIGHT) {
// the widget can be shrunk to fit
this.popupElement.getStyle().setHeight(widgetRect.getHeight() - overflow, PX);
} else {
// we need to shrink AND move the widget up
this.popupElement.getStyle().setHeight(MIN_HEIGHT, PX);
final int newTop = Math.max(winY - MIN_HEIGHT, MIN_HEIGHT);
this.popupElement.getStyle().setTop(newTop, PX);
}
}
// bounding rect has changed
widgetRect = this.popupElement.getBoundingClientRect();
if (widgetRect.getRight() > winX) {
// it doesn't fit
final float overflow = widgetRect.getRight() - winX;
if (widgetRect.getWidth() - overflow > MIN_WIDTH) {
// the widget can be shrunk to fit
this.popupElement.getStyle().setWidth(widgetRect.getWidth() - overflow, PX);
} else {
// we need to shrink AND move the widget up
this.popupElement.getStyle().setWidth(MIN_WIDTH, PX);
final int newLeft = Math.max(winX - MIN_WIDTH, MIN_WIDTH);
this.popupElement.getStyle().setLeft(newLeft - MIN_WIDTH, PX);
}
}
if (needsFocus()) {
// save previous focus and set focus in popup
previousFocus = Elements.getDocument().getActiveElement();
listElement.getFirstElementChild().focus();
}
// add key event listener on popup
listElement.addEventListener(Event.KEYDOWN, keyboardListener, false);
}
Aggregations