<commit_before>/*******************************************************************************
 * Copyright (c) 2012-2016 Codenvy, S.A.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   Codenvy, S.A. - initial API and implementation
 *******************************************************************************/
package org.eclipse.che.ide.extension.machine.client.processes.container;

import com.google.gwt.dom.client.DivElement;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Node;
import com.google.gwt.dom.client.NodeList;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.ResizeLayoutPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.SplitLayoutPanel;
import com.google.inject.Inject;
import com.google.inject.Singleton;

import org.eclipse.che.ide.api.parts.PartStackUIResources;
import org.eclipse.che.ide.api.parts.base.BaseView;
import org.eclipse.che.ide.api.parts.base.ToolButton;
import org.eclipse.che.ide.api.theme.Style;
import org.eclipse.che.ide.extension.machine.client.MachineLocalizationConstant;
import org.eclipse.che.ide.extension.machine.client.MachineResources;
import org.eclipse.che.ide.ui.FontAwesome;
import org.eclipse.che.ide.ui.Tooltip;
import org.eclipse.che.ide.ui.menu.PositionController;

/**
 * Implementation of {@link ConsolesContainerView}.
 *
 * @author <NAME>
 */
@Singleton
public class ConsolesContainerViewImpl extends BaseView<ConsolesContainerView.ActionDelegate> implements ConsolesContainerView {
    private final static String VERTICAL_DRAGGER_CLASS            = "gwt-SplitLayoutPanel-VDragger";
    private final static String HORIZONTAL_DRAGGER_CLASS          = "gwt-SplitLayoutPanel-HDragger";
    private final static String ACTIVE_STATE_TOOLBUTTON_ATTRIBUTE = "turnOn";

    private final MachineResources            machineResources;
    private final MachineLocalizationConstant localizationConstant;

    SplitLayoutPanel  splitLayoutPanel;
    ResizeLayoutPanel processesPanel;
    ResizeLayoutPanel terminalsPanel;
    ToolButton        splitVerticallyButton;
    ToolButton        splitHorizontallyButton;
    ToolButton        defaultModeButton;

    @Inject
    public ConsolesContainerViewImpl(PartStackUIResources partStackUIResources,
                                     MachineResources machineResources,
                                     MachineLocalizationConstant localizationConstant) {
        super(partStackUIResources);
        this.machineResources = machineResources;
        this.localizationConstant = localizationConstant;

        splitLayoutPanel = new SplitLayoutPanel(1);
        setContentWidget(splitLayoutPanel);

        processesPanel = new ResizeLayoutPanel();
        terminalsPanel = new ResizeLayoutPanel();
        splitLayoutPanel.add(processesPanel);

        addToolButtons();
        tuneSplitter();
        defaultModeButton.getElement().getFirstChildElement().setAttribute(ACTIVE_STATE_TOOLBUTTON_ATTRIBUTE, "");
    }

    private void addToolButtons() {
        String toolButtonStyle = machineResources.getCss().consolesActiveToolButton();
        splitVerticallyButton = new ToolButton(FontAwesome.COLUMNS);
        splitVerticallyButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                delegate.onSplitVerticallyClick();
            }
        });
        addToolButton(splitVerticallyButton);
        addToolTip(splitVerticallyButton, localizationConstant.consolesSplitVerticallyTooltip());
        splitVerticallyButton.getElement().getFirstChildElement().addClassName(toolButtonStyle);

        splitHorizontallyButton = new ToolButton(FontAwesome.MINUS_SQUARE_O);
        splitHorizontallyButton.getElement().getFirstChildElement().addClassName(toolButtonStyle);
        splitHorizontallyButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                delegate.onSplitHorizontallyClick();
            }
        });
        addToolButton(splitHorizontallyButton);
        addToolTip(splitHorizontallyButton, localizationConstant.consolesSplitHorizontallyTooltip());

        defaultModeButton = new ToolButton(FontAwesome.SQUARE_O);
        defaultModeButton.getElement().getFirstChildElement().addClassName(toolButtonStyle);
        defaultModeButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                delegate.onDefaultModeClick();
            }
        });
        addToolButton(defaultModeButton);
        addToolTip(defaultModeButton, localizationConstant.consolesDefaultModeTooltip());
    }

    private void addToolTip(ToolButton button, String tooltip) {
        if (button.getElement() instanceof elemental.dom.Element) {
            Tooltip.create((elemental.dom.Element)button.getElement(),
                           PositionController.VerticalAlign.BOTTOM, PositionController.HorizontalAlign.MIDDLE, tooltip);
        }
    }

    @Override
    public SimplePanel getProcessesContainer() {
        return processesPanel;
    }

    @Override
    public SimplePanel getTerminalsContainer() {
        return terminalsPanel;
    }

    @Override
    public void applyDefaultMode() {
        clear();
        splitLayoutPanel.add(processesPanel);<commit_msg>Add IDs for consoles button<commit_after>/*******************************************************************************
 * Copyright (c) 2012-2016 <NAME>.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   <NAME>. - initial API and implementation
 *******************************************************************************/
package org.eclipse.che.ide.extension.machine.client.processes.container;

import com.google.gwt.dom.client.DivElement;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Node;
import com.google.gwt.dom.client.NodeList;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.ResizeLayoutPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.SplitLayoutPanel;
import com.google.inject.Inject;
import com.google.inject.Singleton;

import org.eclipse.che.ide.api.parts.PartStackUIResources;
import org.eclipse.che.ide.api.parts.base.BaseView;
import org.eclipse.che.ide.api.parts.base.ToolButton;
import org.eclipse.che.ide.api.theme.Style;
import org.eclipse.che.ide.extension.machine.client.MachineLocalizationConstant;
import org.eclipse.che.ide.extension.machine.client.MachineResources;
import org.eclipse.che.ide.ui.FontAwesome;
import org.eclipse.che.ide.ui.Tooltip;
import org.eclipse.che.ide.ui.menu.PositionController;

/**
 * Implementation of {@link ConsolesContainerView}.
 *
 * @author <NAME>
 */
@Singleton
public class ConsolesContainerViewImpl extends BaseView<ConsolesContainerView.ActionDelegate> implements ConsolesContainerView {
    private final static String VERTICAL_DRAGGER_CLASS            = "gwt-SplitLayoutPanel-VDragger";
    private final static String HORIZONTAL_DRAGGER_CLASS          = "gwt-SplitLayoutPanel-HDragger";
    private final static String ACTIVE_STATE_TOOLBUTTON_ATTRIBUTE = "turnOn";

    private final MachineResources            machineResources;
    private final MachineLocalizationConstant localizationConstant;

    SplitLayoutPanel  splitLayoutPanel;
    ResizeLayoutPanel processesPanel;
    ResizeLayoutPanel terminalsPanel;
    ToolButton        splitVerticallyButton;
    ToolButton        splitHorizontallyButton;
    ToolButton        defaultModeButton;

    @Inject
    public ConsolesContainerViewImpl(PartStackUIResources partStackUIResources,
                                     MachineResources machineResources,
                                     MachineLocalizationConstant localizationConstant) {
        super(partStackUIResources);
        this.machineResources = machineResources;
        this.localizationConstant = localizationConstant;

        splitLayoutPanel = new SplitLayoutPanel(1);
        setContentWidget(splitLayoutPanel);

        processesPanel = new ResizeLayoutPanel();
        terminalsPanel = new ResizeLayoutPanel();
        splitLayoutPanel.add(processesPanel);

        addToolButtons();
        tuneSplitter();
        defaultModeButton.getElement().getFirstChildElement().setAttribute(ACTIVE_STATE_TOOLBUTTON_ATTRIBUTE, "");
        minimizeButton.ensureDebugId("consoles-minimizeButton");
    }

    private void addToolButtons() {
        String toolButtonStyle = machineResources.getCss().consolesActiveToolButton();
        splitVerticallyButton = new ToolButton(FontAwesome.COLUMNS);
        splitVerticallyButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                delegate.onSplitVerticallyClick();
            }
        });
        addToolButton(splitVerticallyButton);
        addToolTip(splitVerticallyButton, localizationConstant.consolesSplitVerticallyTooltip());
        splitVerticallyButton.getElement().getFirstChildElement().addClassName(toolButtonStyle);
        splitVerticallyButton.ensureDebugId("consoles-splitVerticallyButton");

        splitHorizontallyButton = new ToolButton(FontAwesome.MINUS_SQUARE_O);
        splitHorizontallyButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                delegate.onSplitHorizontallyClick();
            }
        });
        addToolButton(splitHorizontallyButton);
        addToolTip(splitHorizontallyButton, localizationConstant.consolesSplitHorizontallyTooltip());
        splitHorizontallyButton.getElement().getFirstChildElement().addClassName(toolButtonStyle);
        splitHorizontallyButton.ensureDebugId("consoles-splitHorizontallyButton");

        defaultModeButton = new ToolButton(FontAwesome.SQUARE_O);
        defaultModeButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                delegate.onDefaultModeClick();
            }
        });
        addToolButton(defaultModeButton);
        addToolTip(defaultModeButton, localizationConstant.consolesDefaultModeTooltip());
        defaultModeButton.getElement().getFirstChildElement().addClassName(toolButtonStyle);
        defaultModeButton.ensureDebugId("consoles-defaultModeButton");
    }

    private void addToolTip(ToolButton button, String tooltip) {
        if (button.getElement() instanceof elemental.dom.Element) {
            Tooltip.create((elemental.dom.Element)button.getElement(),
                           PositionController.VerticalAlign.BOTTOM, PositionController.HorizontalAlign.MIDDLE, tooltip);
        }
    }

    @Override
    public SimplePanel getProcessesContainer() {
        return processesPanel;
    }

    @Override
    public SimplePanel getTerminalsContainer() {
        return terminalsPanel;
    }

    @Override
    public void applyDefaultMode() {
        clear();
        splitLayoutPanel.add(processesPanel);
{'fraction_non_alphanumeric': 0.10975195378865103, 'fraction_numerical': 0.0022086306489976213, 'mean_word_length': 3.6662703131193024, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6040001', 'n_tokens_mistral': 3035, 'n_tokens_neox': 2962, 'n_words': 503}