Search in sources :

Example 1 with Event

use of com.google.gwt.user.client.Event in project che by eclipse.

the class EditDebugConfigurationsViewImpl method renderCategoryHeader.

private SpanElement renderCategoryHeader(final String categoryTitle) {
    SpanElement categoryHeaderElement = Document.get().createSpanElement();
    categoryHeaderElement.setClassName(editConfigurationsResources.getCss().categoryHeader());
    SpanElement iconElement = Document.get().createSpanElement();
    categoryHeaderElement.appendChild(iconElement);
    SpanElement textElement = Document.get().createSpanElement();
    categoryHeaderElement.appendChild(textElement);
    DebugConfigurationType currentDebugConfigurationType = getTypeById(categoryTitle);
    textElement.setInnerText(currentDebugConfigurationType != null ? currentDebugConfigurationType.getDisplayName() : categoryTitle);
    SpanElement buttonElement = Document.get().createSpanElement();
    buttonElement.appendChild(editConfigurationsResources.addConfigurationButton().getSvg().getElement());
    categoryHeaderElement.appendChild(buttonElement);
    Event.sinkEvents(buttonElement, Event.ONCLICK);
    Event.setEventListener(buttonElement, new EventListener() {

        @Override
        public void onBrowserEvent(Event event) {
            if (Event.ONCLICK == event.getTypeInt()) {
                event.stopPropagation();
                namePanel.setVisible(true);
                selectedType = getTypeById(categoryTitle);
                delegate.onAddClicked();
                resetFilter();
            }
        }
    });
    Icon icon = iconRegistry.getIconIfExist(categoryTitle + ".debug.configuration.type.icon");
    if (icon != null) {
        final SVGImage iconSVG = icon.getSVGImage();
        if (iconSVG != null) {
            iconElement.appendChild(iconSVG.getElement());
            return categoryHeaderElement;
        }
    }
    return categoryHeaderElement;
}
Also used : SpanElement(com.google.gwt.dom.client.SpanElement) KeyUpEvent(com.google.gwt.event.dom.client.KeyUpEvent) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Event(com.google.gwt.user.client.Event) BlurEvent(com.google.gwt.event.dom.client.BlurEvent) KeyDownEvent(com.google.gwt.event.dom.client.KeyDownEvent) KeyboardEvent(elemental.events.KeyboardEvent) EventListener(com.google.gwt.user.client.EventListener) Icon(org.eclipse.che.ide.api.icon.Icon) DebugConfigurationType(org.eclipse.che.ide.api.debug.DebugConfigurationType) SVGImage(org.vectomatic.dom.svg.ui.SVGImage)

Example 2 with Event

use of com.google.gwt.user.client.Event in project che by eclipse.

the class EditDebugConfigurationsViewImpl method renderSubElementButtons.

private SpanElement renderSubElementButtons() {
    final SpanElement categorySubElement = Document.get().createSpanElement();
    categorySubElement.setClassName(editConfigurationsResources.getCss().buttonArea());
    final SpanElement removeConfigurationButtonElement = Document.get().createSpanElement();
    categorySubElement.appendChild(removeConfigurationButtonElement);
    removeConfigurationButtonElement.appendChild(this.editConfigurationsResources.removeConfigurationButton().getSvg().getElement());
    Event.sinkEvents(removeConfigurationButtonElement, Event.ONCLICK);
    Event.setEventListener(removeConfigurationButtonElement, new EventListener() {

        @Override
        public void onBrowserEvent(Event event) {
            if (Event.ONCLICK == event.getTypeInt()) {
                event.stopPropagation();
                setSelectedConfiguration(selectedConfiguration);
                delegate.onRemoveClicked(selectedConfiguration);
            }
        }
    });
    final SpanElement duplicateConfigurationButton = Document.get().createSpanElement();
    categorySubElement.appendChild(duplicateConfigurationButton);
    duplicateConfigurationButton.appendChild(this.editConfigurationsResources.duplicateConfigurationButton().getSvg().getElement());
    Event.sinkEvents(duplicateConfigurationButton, Event.ONCLICK);
    Event.setEventListener(duplicateConfigurationButton, new EventListener() {

        @Override
        public void onBrowserEvent(Event event) {
            if (Event.ONCLICK == event.getTypeInt()) {
                event.stopPropagation();
                delegate.onDuplicateClicked();
            }
        }
    });
    return categorySubElement;
}
Also used : SpanElement(com.google.gwt.dom.client.SpanElement) KeyUpEvent(com.google.gwt.event.dom.client.KeyUpEvent) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Event(com.google.gwt.user.client.Event) BlurEvent(com.google.gwt.event.dom.client.BlurEvent) KeyDownEvent(com.google.gwt.event.dom.client.KeyDownEvent) KeyboardEvent(elemental.events.KeyboardEvent) EventListener(com.google.gwt.user.client.EventListener)

Example 3 with Event

use of com.google.gwt.user.client.Event in project che by eclipse.

the class EditCommandsViewImpl method createCommandButtons.

/** Creates and returns buttons for duplicating and removing command. */
private SpanElement createCommandButtons() {
    final SpanElement removeCommandButton = Document.get().createSpanElement();
    removeCommandButton.appendChild(commandResources.removeCommandButton().getSvg().getElement());
    Event.sinkEvents(removeCommandButton, Event.ONCLICK);
    Event.setEventListener(removeCommandButton, new EventListener() {

        @Override
        public void onBrowserEvent(Event event) {
            if (Event.ONCLICK == event.getTypeInt()) {
                event.stopPropagation();
                onCommandSelected(selectedCommand);
                delegate.onRemoveClicked();
            }
        }
    });
    final SpanElement duplicateCommandButton = Document.get().createSpanElement();
    duplicateCommandButton.appendChild(commandResources.duplicateCommandButton().getSvg().getElement());
    Event.sinkEvents(duplicateCommandButton, Event.ONCLICK);
    Event.setEventListener(duplicateCommandButton, new EventListener() {

        @Override
        public void onBrowserEvent(Event event) {
            if (Event.ONCLICK == event.getTypeInt()) {
                event.stopPropagation();
                delegate.onDuplicateClicked();
            }
        }
    });
    final SpanElement buttonsPanel = Document.get().createSpanElement();
    buttonsPanel.setClassName(commandResources.getCss().buttonArea());
    buttonsPanel.appendChild(removeCommandButton);
    buttonsPanel.appendChild(duplicateCommandButton);
    return buttonsPanel;
}
Also used : SpanElement(com.google.gwt.dom.client.SpanElement) KeyUpEvent(com.google.gwt.event.dom.client.KeyUpEvent) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Event(com.google.gwt.user.client.Event) BlurEvent(com.google.gwt.event.dom.client.BlurEvent) KeyDownEvent(com.google.gwt.event.dom.client.KeyDownEvent) KeyboardEvent(elemental.events.KeyboardEvent) EventListener(com.google.gwt.user.client.EventListener)

Example 4 with Event

use of com.google.gwt.user.client.Event in project che by eclipse.

the class EditCommandsViewImpl method createCategoryHeaderForCommandType.

private SpanElement createCategoryHeaderForCommandType(final String commandTypeId) {
    final SpanElement categoryHeaderElement = Document.get().createSpanElement();
    categoryHeaderElement.setClassName(commandResources.getCss().categoryHeader());
    final SpanElement iconElement = Document.get().createSpanElement();
    categoryHeaderElement.appendChild(iconElement);
    final SpanElement nameElement = Document.get().createSpanElement();
    categoryHeaderElement.appendChild(nameElement);
    final CommandType currentCommandType = getTypeById(commandTypeId);
    nameElement.setInnerText(currentCommandType != null ? currentCommandType.getDisplayName() : commandTypeId);
    final SpanElement buttonElement = Document.get().createSpanElement();
    buttonElement.appendChild(commandResources.addCommandButton().getSvg().getElement());
    categoryHeaderElement.appendChild(buttonElement);
    Event.sinkEvents(buttonElement, Event.ONCLICK);
    Event.setEventListener(buttonElement, new EventListener() {

        @Override
        public void onBrowserEvent(Event event) {
            if (Event.ONCLICK == event.getTypeInt()) {
                event.stopPropagation();
                namePanel.setVisible(true);
                previewUrlPanel.setVisible(true);
                selectedType = commandTypeId;
                delegate.onAddClicked();
                resetFilter();
            }
        }
    });
    final Icon icon = iconRegistry.getIconIfExist(commandTypeId + ".commands.category.icon");
    if (icon != null) {
        final SVGImage iconSVG = icon.getSVGImage();
        if (iconSVG != null) {
            iconElement.appendChild(iconSVG.getElement());
            return categoryHeaderElement;
        }
    }
    return categoryHeaderElement;
}
Also used : SpanElement(com.google.gwt.dom.client.SpanElement) CommandType(org.eclipse.che.ide.api.command.CommandType) KeyUpEvent(com.google.gwt.event.dom.client.KeyUpEvent) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Event(com.google.gwt.user.client.Event) BlurEvent(com.google.gwt.event.dom.client.BlurEvent) KeyDownEvent(com.google.gwt.event.dom.client.KeyDownEvent) KeyboardEvent(elemental.events.KeyboardEvent) EventListener(com.google.gwt.user.client.EventListener) Icon(org.eclipse.che.ide.api.icon.Icon) SVGImage(org.vectomatic.dom.svg.ui.SVGImage)

Example 5 with Event

use of com.google.gwt.user.client.Event in project rstudio by rstudio.

the class ChunkContextToolbar method initChangeChunkEngine.

@SuppressWarnings("unused")
private void initChangeChunkEngine(String engine) {
    chunkTypeLabel_.setText(engine);
    DOM.sinkEvents(chunkTypePanel_.getElement(), Event.ONCLICK);
    DOM.setEventListener(chunkTypePanel_.getElement(), new EventListener() {

        @Override
        public void onBrowserEvent(Event event) {
            if (DOM.eventGetType(event) == Event.ONCLICK) {
                Commands commands = RStudioGinjector.INSTANCE.getCommands();
                String engineLabel = chunkTypeLabel_.getText();
                final ToolbarPopupMenu switchChunksMenu = new ToolbarPopupMenu();
                if (engineLabel != "r") {
                    switchChunksMenu.addItem(createMenuItemForType(commands.switchToChunkR(), "r"));
                    switchChunksMenu.addSeparator();
                }
                if (!BrowseCap.isWindowsDesktop() && engineLabel != "bash") {
                    switchChunksMenu.addItem(createMenuItemForType(commands.switchToChunkBash(), "bash"));
                }
                if (engineLabel != "python") {
                    switchChunksMenu.addItem(createMenuItemForType(commands.switchToChunkPython(), "python"));
                }
                if (engineLabel != "rcpp") {
                    switchChunksMenu.addItem(createMenuItemForType(commands.switchToChunkRCPP(), "rcpp"));
                }
                if (engineLabel != "sql") {
                    switchChunksMenu.addItem(createMenuItemForType(commands.switchToChunkSQL(), "sql"));
                }
                if (engineLabel != "stan") {
                    switchChunksMenu.addItem(createMenuItemForType(commands.switchToChunkStan(), "stan"));
                }
                switchChunksMenu.setPopupPositionAndShow(new PositionCallback() {

                    @Override
                    public void setPosition(int offsetWidth, int offsetHeight) {
                        switchChunksMenu.setPopupPosition(chunkTypePanel_.getAbsoluteLeft() + chunkTypePanel_.getOffsetWidth() - offsetWidth + 15, chunkTypePanel_.getAbsoluteTop() + chunkTypePanel_.getOffsetHeight());
                    }
                });
            }
        }
    });
}
Also used : ToolbarPopupMenu(org.rstudio.core.client.widget.ToolbarPopupMenu) PositionCallback(com.google.gwt.user.client.ui.PopupPanel.PositionCallback) Commands(org.rstudio.studio.client.workbench.commands.Commands) Event(com.google.gwt.user.client.Event) EventListener(com.google.gwt.user.client.EventListener)

Aggregations

Event (com.google.gwt.user.client.Event)31 EventListener (com.google.gwt.user.client.EventListener)12 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)10 ColumnSortEvent (com.google.gwt.user.cellview.client.ColumnSortEvent)7 SpanElement (com.google.gwt.dom.client.SpanElement)5 KeyDownEvent (com.google.gwt.event.dom.client.KeyDownEvent)5 KeyboardEvent (elemental.events.KeyboardEvent)5 BlurEvent (com.google.gwt.event.dom.client.BlurEvent)4 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)4 KeyUpEvent (com.google.gwt.event.dom.client.KeyUpEvent)4 Test (org.junit.Test)4 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)3 KeyPressEvent (com.google.gwt.event.dom.client.KeyPressEvent)3 ValueChangeEvent (com.google.gwt.event.logical.shared.ValueChangeEvent)3 PositionCallback (com.google.gwt.user.client.ui.PopupPanel.PositionCallback)3 PatchMethod (com.googlecode.gwt.test.patchers.PatchMethod)3 ImageResource2x (org.rstudio.core.client.resources.ImageResource2x)3 ToolbarPopupMenu (org.rstudio.core.client.widget.ToolbarPopupMenu)3 OnEditEnabler (com.google.gerrit.client.ui.OnEditEnabler)2 Element (com.google.gwt.dom.client.Element)2