Search in sources :

Example 11 with SVGImage

use of org.vectomatic.dom.svg.ui.SVGImage 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 12 with SVGImage

use of org.vectomatic.dom.svg.ui.SVGImage in project che by eclipse.

the class RadioButtonGroup method addButton.

/**
     * Adds the new button to the group.
     *
     * @param label
     *         button's label
     * @param title
     *         button's tooltip
     * @param icon
     *         button's icon
     * @param clickHandler
     *         click handler
     */
public void addButton(String label, String title, @Nullable SVGResource icon, ClickHandler clickHandler) {
    final RadioButton radioButton = new RadioButton(GROUP_NAME, label);
    radioButton.setTitle(title);
    radioButton.setStyleName(resources.getCSS().button());
    radioButton.addClickHandler(clickHandler);
    final Node child = radioButton.getElement().getLastChild();
    if (icon != null) {
        final SVGImage svgImage = new SVGImage(icon);
        child.insertFirst(svgImage.getElement());
    }
    mainPanel.add(radioButton);
    buttons.add(radioButton);
}
Also used : Node(com.google.gwt.dom.client.Node) RadioButton(com.google.gwt.user.client.ui.RadioButton) SVGImage(org.vectomatic.dom.svg.ui.SVGImage)

Example 13 with SVGImage

use of org.vectomatic.dom.svg.ui.SVGImage in project che by eclipse.

the class PopupMenu method redraw.

/** Render Popup Menu component. */
private void redraw() {
    String idPrefix = itemIdPrefix;
    if (idPrefix == null) {
        idPrefix = "";
    } else {
        idPrefix += "/";
    }
    table = new PopupMenuTable();
    table.setStyleName(POPUP_RESOURCES.popup().popupMenuTable());
    table.setCellPadding(0);
    table.setCellSpacing(0);
    for (int i = 0; i < list.size(); i++) {
        Action menuItem = list.get(i);
        if (menuItem instanceof Separator) {
            final String separatorText = ((Separator) menuItem).getText();
            if (separatorText == null) {
                table.getCellFormatter().setStyleName(i, 0, POPUP_RESOURCES.popup().popupMenuDelimiter());
            } else {
                table.setWidget(i, 0, new Label(separatorText));
                table.getCellFormatter().setStyleName(i, 0, POPUP_RESOURCES.popup().popupMenuTextDelimiter());
            }
            table.getFlexCellFormatter().setColSpan(i, 0, hasCheckedItems ? 5 : 4);
        } else {
            Presentation presentation = presentationFactory.getPresentation(menuItem);
            if (presentation.getImageResource() != null) {
                Image image = new Image(presentation.getImageResource());
                table.setWidget(i, 0, image);
            } else if (presentation.getSVGResource() != null) {
                SVGImage image = new SVGImage(presentation.getSVGResource());
                table.setWidget(i, 0, image);
            } else if (presentation.getHTMLResource() != null) {
                table.setHTML(i, 0, presentation.getHTMLResource());
            }
            table.getCellFormatter().setStyleName(i, 0, presentation.isEnabled() ? POPUP_RESOURCES.popup().popupMenuIconField() : POPUP_RESOURCES.popup().popupMenuIconFieldDisabled());
            int work = 1;
            if (hasCheckedItems) {
                if (menuItem instanceof ToggleAction) {
                    ToggleAction toggleAction = (ToggleAction) menuItem;
                    ActionEvent e = new ActionEvent(presentationFactory.getPresentation(toggleAction), actionManager, managerProvider.get());
                    if (toggleAction.isSelected(e)) {
                        // Temporary solution
                        table.setHTML(i, work, "<i class=\"fa fa-check\"></i>");
                    }
                    table.getCellFormatter().setStyleName(i, work, presentation.isEnabled() ? POPUP_RESOURCES.popup().popupMenuCheckField() : POPUP_RESOURCES.popup().popupMenuCheckFieldDisabled());
                } else {
                    table.setHTML(i, work, "");
                }
                work++;
            }
            table.setHTML(i, work, "<nobr id=\"" + idPrefix + presentation.getText() + "\">" + presentation.getText() + "</nobr>");
            table.getCellFormatter().setStyleName(i, work, presentation.isEnabled() ? POPUP_RESOURCES.popup().popupMenuTitleField() : POPUP_RESOURCES.popup().popupMenuTitleFieldDisabled());
            if (showTooltips) {
                Tooltip.create((elemental.dom.Element) table.getCellFormatter().getElement(i, work), BOTTOM, MIDDLE, presentation.getText());
            }
            work++;
            String hotKey = KeyMapUtil.getShortcutText(keyBindingAgent.getKeyBinding(actionManager.getId(menuItem)));
            if (hotKey == null) {
                hotKey = "&nbsp;";
            } else {
                hotKey = "<nobr>&nbsp;" + hotKey + "&nbsp;</nobr>";
            }
            table.setHTML(i, work, hotKey);
            table.getCellFormatter().setStyleName(i, work, presentation.isEnabled() ? POPUP_RESOURCES.popup().popupMenuHotKeyField() : POPUP_RESOURCES.popup().popupMenuHotKeyFieldDisabled());
            work++;
            if (menuItem instanceof ActionGroup && !(((ActionGroup) menuItem).canBePerformed() && !Utils.hasVisibleChildren((ActionGroup) menuItem, presentationFactory, actionManager, managerProvider.get()))) {
                table.setWidget(i, work, new SVGImage(POPUP_RESOURCES.subMenu()));
                table.getCellFormatter().setStyleName(i, work, presentation.isEnabled() ? POPUP_RESOURCES.popup().popupMenuSubMenuField() : POPUP_RESOURCES.popup().popupMenuSubMenuFieldDisabled());
            } else {
                table.getCellFormatter().setStyleName(i, work, presentation.isEnabled() ? POPUP_RESOURCES.popup().popupMenuSubMenuField() : POPUP_RESOURCES.popup().popupMenuSubMenuFieldDisabled());
            }
            work++;
            table.getRowFormatter().getElement(i).setAttribute("item-index", Integer.toString(i));
            table.getRowFormatter().getElement(i).setAttribute("item-enabled", Boolean.toString(presentation.isEnabled()));
            String actionId = actionManager.getId(menuItem);
            String debugId;
            if (actionId == null) {
                debugId = idPrefix + menuItem.getTemplatePresentation().getText();
            } else {
                debugId = idPrefix + actionId;
            }
            UIObject.ensureDebugId(table.getRowFormatter().getElement(i), debugId);
        }
    }
    popupMenuPanel.add(table);
}
Also used : ToggleAction(org.eclipse.che.ide.api.action.ToggleAction) Action(org.eclipse.che.ide.api.action.Action) ActionEvent(org.eclipse.che.ide.api.action.ActionEvent) Label(com.google.gwt.user.client.ui.Label) Presentation(org.eclipse.che.ide.api.action.Presentation) Image(com.google.gwt.user.client.ui.Image) SVGImage(org.vectomatic.dom.svg.ui.SVGImage) SVGImage(org.vectomatic.dom.svg.ui.SVGImage) ActionGroup(org.eclipse.che.ide.api.action.ActionGroup) ToggleAction(org.eclipse.che.ide.api.action.ToggleAction) Separator(org.eclipse.che.ide.api.action.Separator)

Example 14 with SVGImage

use of org.vectomatic.dom.svg.ui.SVGImage in project che by eclipse.

the class ActionButton method renderImage.

/** Redraw icon. */
private void renderImage() {
    panel.clear();
    if (presentation.getImageResource() != null) {
        Image img = new Image(presentation.getImageResource());
        img.setStyleName(toolbarResources.toolbar().iconButtonIcon());
        panel.add(img);
    } else if (presentation.getSVGResource() != null) {
        SVGImage image = new SVGImage(presentation.getSVGResource());
        image.getElement().setAttribute("class", toolbarResources.toolbar().iconButtonIcon());
        panel.add(image);
    } else if (presentation.getHTMLResource() != null) {
        FlowPanel icon = new FlowPanel();
        icon.setStyleName(toolbarResources.toolbar().iconButtonIcon());
        FlowPanel inner = new FlowPanel();
        inner.setStyleName(toolbarResources.toolbar().iconButtonIconInner());
        inner.getElement().setInnerHTML(presentation.getHTMLResource());
        icon.add(inner);
        panel.add(inner);
    }
}
Also used : FlowPanel(com.google.gwt.user.client.ui.FlowPanel) Image(com.google.gwt.user.client.ui.Image) SVGImage(org.vectomatic.dom.svg.ui.SVGImage) SVGImage(org.vectomatic.dom.svg.ui.SVGImage)

Example 15 with SVGImage

use of org.vectomatic.dom.svg.ui.SVGImage in project che by eclipse.

the class BaseView method addMaximizeButton.

/**
     * Adds maximize part button.
     */
private void addMaximizeButton() {
    SVGImage maximize = new SVGImage(resources.maximizePart());
    maximize.getElement().setAttribute("name", "workBenchIconMaximize");
    ToolButton maximizeButton = new ToolButton(maximize);
    maximizeButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            onToggleMaximize();
        }
    });
    addToolButton(maximizeButton);
    if (maximizeButton.getElement() instanceof elemental.dom.Element) {
        Tooltip.create((elemental.dom.Element) maximizeButton.getElement(), PositionController.VerticalAlign.BOTTOM, PositionController.HorizontalAlign.MIDDLE, "Maximize panel");
    }
}
Also used : DoubleClickHandler(com.google.gwt.event.dom.client.DoubleClickHandler) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) DoubleClickEvent(com.google.gwt.event.dom.client.DoubleClickEvent) SVGImage(org.vectomatic.dom.svg.ui.SVGImage)

Aggregations

SVGImage (org.vectomatic.dom.svg.ui.SVGImage)22 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)6 SpanElement (elemental.html.SpanElement)6 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)4 Element (elemental.dom.Element)4 SVGResource (org.vectomatic.dom.svg.ui.SVGResource)4 SpanElement (com.google.gwt.dom.client.SpanElement)3 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)3 Image (com.google.gwt.user.client.ui.Image)3 Event (elemental.events.Event)3 EventListener (elemental.events.EventListener)3 DivElement (elemental.html.DivElement)3 Icon (org.eclipse.che.ide.api.icon.Icon)3 TreeNodeElement (org.eclipse.che.ide.ui.tree.TreeNodeElement)3 BlurEvent (com.google.gwt.event.dom.client.BlurEvent)2 DoubleClickEvent (com.google.gwt.event.dom.client.DoubleClickEvent)2 DoubleClickHandler (com.google.gwt.event.dom.client.DoubleClickHandler)2 KeyDownEvent (com.google.gwt.event.dom.client.KeyDownEvent)2 KeyUpEvent (com.google.gwt.event.dom.client.KeyUpEvent)2 Event (com.google.gwt.user.client.Event)2