Search in sources :

Example 6 with Event

use of elemental.events.Event in project che by eclipse.

the class SimpleList method attachEventHandlers.

private void attachEventHandlers() {
    getView().addEventListener(Event.CLICK, new EventListener() {

        @Override
        public void handleEvent(Event evt) {
            Element listItemElem = CssUtils.getAncestorOrSelfWithClassName((Element) evt.getTarget(), css.listItem());
            if (listItemElem == null) {
                Log.warn(SimpleList.class, "Unable to find an ancestor that was a list item for a click on: ", evt.getTarget());
                return;
            }
            ListItem<M> listItem = ListItem.cast(listItemElem);
            eventDelegate.onListItemClicked(listItem, listItem.getData());
        }
    }, false);
    getView().addEventListener(Event.DBLCLICK, new EventListener() {

        @Override
        public void handleEvent(Event evt) {
            Element listItemElem = CssUtils.getAncestorOrSelfWithClassName((Element) evt.getTarget(), css.listItem());
            if (listItemElem == null) {
                Log.warn(SimpleList.class, "Unable to find an ancestor that was a list item for a click on: ", evt.getTarget());
                return;
            }
            ListItem<M> listItem = ListItem.cast(listItemElem);
            eventDelegate.onListItemDoubleClicked(listItem, listItem.getData());
        }
    }, false);
}
Also used : JsElement(elemental.js.dom.JsElement) Element(elemental.dom.Element) Event(elemental.events.Event) EventListener(elemental.events.EventListener)

Example 7 with Event

use of elemental.events.Event in project che by eclipse.

the class NoImplementationWidget method createItem.

@Override
public Element createItem(final Type itemModel) {
    final Element element = Elements.createLiElement(popupResources.popupStyle().item());
    final Element iconElement = Elements.createDivElement(popupResources.popupStyle().icon());
    int flag = itemModel.getFlags();
    if (flag == -1) {
        element.setInnerText(getEmptyMessage());
        return element;
    }
    SVGImage svgImage = getSvgImage(flag);
    iconElement.appendChild((Node) svgImage.getElement());
    element.appendChild(iconElement);
    element.appendChild(createTitleOfElement(itemModel));
    final EventListener validateListener = new EventListener() {

        @Override
        public void handleEvent(final Event evt) {
            openImplementationPresenter.actionPerformed(itemModel);
            hide();
        }
    };
    element.addEventListener(Event.DBLCLICK, validateListener, false);
    element.addEventListener(CUSTOM_EVT_TYPE_VALIDATE, validateListener, false);
    return element;
}
Also used : Element(elemental.dom.Element) SpanElement(elemental.html.SpanElement) Event(elemental.events.Event) CustomEvent(elemental.events.CustomEvent) EventListener(elemental.events.EventListener) SVGImage(org.vectomatic.dom.svg.ui.SVGImage)

Example 8 with Event

use of elemental.events.Event in project che by eclipse.

the class GutterAnnotationRenderer method addAnnotationItem.

private void addAnnotationItem(final AnnotationModel model, final Annotation annotation) {
    final Position position = model.getPosition(annotation);
    if (position == null) {
        Log.warn(GutterAnnotationRenderer.class, "No position for annotation " + annotation);
        return;
    }
    final TextPosition textPosition = this.document.getPositionFromIndex(position.getOffset());
    final Element annotationItem = this.hasGutter.getGutterItem(textPosition.getLine(), ANNOTATION_GUTTER);
    AnnotationGroup annotationGroup;
    if (!AnnotationGroupImpl.isAnnotation(annotationItem)) {
        LOG.fine("Create new annotation group for line " + textPosition.getLine());
        final AnnotationGroup newGroup = AnnotationGroupImpl.create();
        newGroup.getElement().addEventListener(Event.MOUSEOVER, new EventListener() {

            @Override
            public void handleEvent(final Event evt) {
                showToolTip(newGroup, textPosition.getLine());
            }
        }, false);
        this.hasGutter.addGutterItem(textPosition.getLine(), ANNOTATION_GUTTER, newGroup.getElement());
        annotationGroup = newGroup;
    } else {
        LOG.fine("Reuse annotation group for line " + textPosition.getLine());
        annotationGroup = AnnotationGroupImpl.create(annotationItem);
    }
    annotationGroup.addAnnotation(annotation, position.getOffset());
}
Also used : TextPosition(org.eclipse.che.ide.api.editor.text.TextPosition) Position(org.eclipse.che.ide.api.editor.text.Position) TextPosition(org.eclipse.che.ide.api.editor.text.TextPosition) Element(elemental.dom.Element) Event(elemental.events.Event) EventListener(elemental.events.EventListener)

Example 9 with Event

use of elemental.events.Event in project che by eclipse.

the class EmptyEditorsPanel method renderAction.

private Node renderAction(String title, final Action action) {
    final Presentation presentation = presentationFactory.getPresentation(action);
    Element divElement = Elements.createDivElement(style.listElement());
    divElement.addEventListener("click", new EventListener() {

        @Override
        public void handleEvent(Event evt) {
            ActionEvent event = new ActionEvent(presentation, actionManager, perspectiveManagerProvider.get());
            action.actionPerformed(event);
        }
    }, true);
    divElement.getStyle().setCursor("pointer");
    divElement.getStyle().setColor(Style.getOutputLinkColor());
    Element label = Elements.createDivElement(style.actionLabel());
    label.setInnerText(title);
    divElement.appendChild(label);
    String hotKey = KeyMapUtil.getShortcutText(keyBindingAgent.getKeyBinding(actionManager.getId(action)));
    if (hotKey == null) {
        hotKey = "&nbsp;";
    } else {
        hotKey = "<nobr>&nbsp;" + hotKey + "&nbsp;</nobr>";
    }
    SpanElement hotKeyElement = Elements.createSpanElement(style.hotKey());
    hotKeyElement.setInnerHTML(hotKey);
    divElement.appendChild(hotKeyElement);
    return divElement;
}
Also used : SpanElement(elemental.html.SpanElement) ActionEvent(org.eclipse.che.ide.api.action.ActionEvent) Element(elemental.dom.Element) DivElement(com.google.gwt.dom.client.DivElement) LIElement(elemental.html.LIElement) SpanElement(elemental.html.SpanElement) ActionEvent(org.eclipse.che.ide.api.action.ActionEvent) ResourceChangedEvent(org.eclipse.che.ide.api.resources.ResourceChangedEvent) Event(elemental.events.Event) EventListener(elemental.events.EventListener) Presentation(org.eclipse.che.ide.api.action.Presentation)

Example 10 with Event

use of elemental.events.Event in project che by eclipse.

the class ProcessTreeRenderer method createMachineElement.

private SpanElement createMachineElement(final ProcessTreeNode node) {
    final MachineEntity machine = (MachineEntity) node.getData();
    final String machineId = machine.getId();
    final MachineConfig machineConfig = machine.getConfig();
    final String machineCategory = machineConfig.isDev() ? locale.devMachineCategory() : machineConfig.getType();
    SpanElement root = Elements.createSpanElement();
    root.appendChild(createMachineLabel(machineCategory));
    Element statusElement = Elements.createSpanElement(resources.getCss().machineStatus());
    root.appendChild(statusElement);
    if (node.isRunning()) {
        statusElement.appendChild(Elements.createDivElement(resources.getCss().machineStatusRunning()));
    } else {
        statusElement.appendChild(Elements.createDivElement(resources.getCss().machineStatusPausedLeft()));
        statusElement.appendChild(Elements.createDivElement(resources.getCss().machineStatusPausedRight()));
    }
    Tooltip.create(statusElement, BOTTOM, MIDDLE, locale.viewMachineRunningTooltip());
    /***************************************************************************
         *
         * New terminal button
         *
         ***************************************************************************/
    if (node.isRunning() && node.hasTerminalAgent()) {
        SpanElement newTerminalButton = Elements.createSpanElement(resources.getCss().newTerminalButton());
        newTerminalButton.appendChild((Node) new SVGImage(resources.addTerminalIcon()).getElement());
        root.appendChild(newTerminalButton);
        Tooltip.create(newTerminalButton, BOTTOM, MIDDLE, locale.viewNewTerminalTooltip());
        newTerminalButton.addEventListener(Event.CLICK, new EventListener() {

            @Override
            public void handleEvent(Event event) {
                event.stopPropagation();
                event.preventDefault();
                if (addTerminalClickHandler != null) {
                    addTerminalClickHandler.onAddTerminalClick(machineId);
                }
            }
        }, true);
        /**
             * This listener cancels mouse events on '+' button and prevents the jitter of the selection in the tree.
             */
        EventListener blockMouseListener = new EventListener() {

            @Override
            public void handleEvent(Event event) {
                event.stopPropagation();
                event.preventDefault();
            }
        };
        /**
             * Prevent jitter when pressing mouse on '+' button.
             */
        newTerminalButton.addEventListener(Event.MOUSEDOWN, blockMouseListener, true);
        newTerminalButton.addEventListener(Event.MOUSEUP, blockMouseListener, true);
        newTerminalButton.addEventListener(Event.CLICK, blockMouseListener, true);
        newTerminalButton.addEventListener(Event.DBLCLICK, blockMouseListener, true);
    }
    /***************************************************************************
         *
         * SSH button
         *
         ***************************************************************************/
    if (node.isRunning() && node.hasSSHAgent()) {
        SpanElement sshButton = Elements.createSpanElement(resources.getCss().sshButton());
        sshButton.setTextContent("SSH");
        root.appendChild(sshButton);
        sshButton.addEventListener(Event.CLICK, new EventListener() {

            @Override
            public void handleEvent(Event event) {
                if (previewSshClickHandler != null) {
                    previewSshClickHandler.onPreviewSshClick(machineId);
                }
            }
        }, true);
        Tooltip.create(sshButton, BOTTOM, MIDDLE, locale.connectViaSSH());
    }
    Element monitorsElement = Elements.createSpanElement(resources.getCss().machineMonitors());
    root.appendChild(monitorsElement);
    Node monitorNode = (Node) machineMonitors.getMonitorWidget(machineId, this).getElement();
    monitorsElement.appendChild(monitorNode);
    Element nameElement = Elements.createSpanElement(resources.getCss().nameLabel());
    nameElement.setTextContent(machineConfig.getName());
    Tooltip.create(nameElement, BOTTOM, MIDDLE, machineConfig.getName());
    root.appendChild(nameElement);
    return root;
}
Also used : MachineEntity(org.eclipse.che.ide.api.machine.MachineEntity) SpanElement(elemental.html.SpanElement) MachineConfig(org.eclipse.che.api.core.model.machine.MachineConfig) DivElement(elemental.html.DivElement) TreeNodeElement(org.eclipse.che.ide.ui.tree.TreeNodeElement) Element(elemental.dom.Element) SpanElement(elemental.html.SpanElement) Node(elemental.dom.Node) Event(elemental.events.Event) EventListener(elemental.events.EventListener) SVGImage(org.vectomatic.dom.svg.ui.SVGImage)

Aggregations

Event (elemental.events.Event)11 EventListener (elemental.events.EventListener)11 Element (elemental.dom.Element)8 SpanElement (elemental.html.SpanElement)7 Node (elemental.dom.Node)3 CustomEvent (elemental.events.CustomEvent)3 SVGImage (org.vectomatic.dom.svg.ui.SVGImage)3 EventTarget (elemental.events.EventTarget)2 MouseEvent (elemental.events.MouseEvent)2 DivElement (elemental.html.DivElement)2 Completion (org.eclipse.che.ide.api.editor.codeassist.Completion)2 CompletionProposal (org.eclipse.che.ide.api.editor.codeassist.CompletionProposal)2 LinearRange (org.eclipse.che.ide.api.editor.text.LinearRange)2 HandlesUndoRedo (org.eclipse.che.ide.api.editor.texteditor.HandlesUndoRedo)2 UndoableEditor (org.eclipse.che.ide.api.editor.texteditor.UndoableEditor)2 Scheduler (com.google.gwt.core.client.Scheduler)1 DivElement (com.google.gwt.dom.client.DivElement)1 Style (com.google.gwt.dom.client.Style)1 KeyCodes (com.google.gwt.event.dom.client.KeyCodes)1 Timer (com.google.gwt.user.client.Timer)1