<commit_before>/*
 * ProActive Parallel Suite(TM):
 * The Open Source library for parallel and distributed
 * Workflows & Scheduling, Orchestration, Cloud Automation
 * and Big Data Analysis on Enterprise Grids & Clouds.
 *
 * Copyright (c) 2007 - 2017 ActiveEon
 * Contact: <EMAIL>
 *
 * This library is free software: you can redistribute it and/or
 * modify it under the terms of the GNU Affero General Public License
 * as published by the Free Software Foundation: version 3 of
 * the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 * If needed, contact us to obtain a release under GPL Version 2 or 3
 * or a different license than the AGPL.
 */
package org.ow2.proactive_grid_cloud_portal.rm.client;

import org.ow2.proactive_grid_cloud_portal.common.client.AboutWindow;
import org.ow2.proactive_grid_cloud_portal.common.client.CredentialsWindow;
import org.ow2.proactive_grid_cloud_portal.common.client.Images;
import org.ow2.proactive_grid_cloud_portal.common.client.ImagesUnbundled;
import org.ow2.proactive_grid_cloud_portal.common.client.Listeners.LogListener;
import org.ow2.proactive_grid_cloud_portal.common.client.LogWindow;
import org.ow2.proactive_grid_cloud_portal.common.client.ToolButtonsRender;
import org.ow2.proactive_grid_cloud_portal.common.client.model.LogModel;
import org.ow2.proactive_grid_cloud_portal.common.client.model.LoginModel;
import org.ow2.proactive_grid_cloud_portal.common.shared.Config;
import org.ow2.proactive_grid_cloud_portal.rm.shared.RMConfig;

import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.visualization.client.VisualizationUtils;
import com.google.gwt.visualization.client.visualizations.corechart.CoreChart;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.types.VerticalAlignment;
import com.smartgwt.client.types.VisibilityMode;
import com.smartgwt.client.util.BooleanCallback;
import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.Img;
import com.smartgwt.client.widgets.ImgButton;
import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.events.DrawEvent;
import com.smartgwt.client.widgets.events.DrawHandler;
import com.smartgwt.client.widgets.events.ResizedEvent;
import com.smartgwt.client.widgets.events.ResizedHandler;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.CheckboxItem;
import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.LayoutSpacer;
import com.smartgwt.client.widgets.layout.SectionStack;
import com.smartgwt.client.widgets.layout.SectionStackSection;
import com.smartgwt.client.widgets.layout.VLayout;
import com.smartgwt.client.widgets.menu.Menu;
import com.smartgwt.client.widgets.menu.MenuItem;
import com.smartgwt.client.widgets.menu.MenuItemSeparator;
import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
import com.smartgwt.client.widgets.tab.Tab;
import com.smartgwt.client.widgets.tab.TabSet;
import com.smartgwt.client.widgets.toolbar.ToolStrip;
import com.smartgwt.client.widgets.toolbar.ToolStripButton;
import com.smartgwt.client.widgets.toolbar.ToolStripMenuButton;


/**
 * Page shown when an user is logged
 * 
 * 
 * 
 * 
 * @author mschnoor
 *
 */
public class RMPage implements LogListener {

    private static final int EXPAND_COLLAPSE_SECTION_LABEL_WIDTH = 80;

    private RMController controller = null;

    /** parent of all widgets held by this page */
    private Canvas rootLayout = null;

    /** displays all logs received from the event dispatcher */
    private LogWindow logWindow = null;

    /** about this app */
    private AboutWindow aboutWindow = null;

    /** client settings */
    private SettingsWindow settingsWindow = null;

    /** create and download credentials files */
    private CredentialsWindow credentialsWindow = null;

    /** create node sources */
    private NSCreationWindow nsWindow = null;

    /** node launcher window */
    private AddNodeWindow addNodeWindow = null;

    /** top pane : textual list of nodes */
    private TreeView treeView = null;

    /** bot left pane : selected node info */
    private InfoView infoView = null;

    /** bot left pane : selected node monitoring */
    private MonitoringView monitoringView = null;

    /** bot right pane : graphical list of nodes */
    private CompactView compactView = null;

    /** bot left pane : node count */
    private StatisticsView statsView = null;

    private ScriptConsoleView scriptConsoleView = null;

    /** bot right : graphs */
    private RMStatsView rmStatsView = null;

    /** displayed when critical log events occur */
    private ToolStripButton errorButton = null;

    private long lastCriticalMessage = 0;

    // Logo strip properties
    private int logoStripHeight = 40;

    private String logoStripBackgroundColor = "#fafafa";

    private String logoStripBorder = "0px";

    private ToolButtonsRender toolButtonsRender = new ToolButtonsRender();

    RMPage(RMController controller) {
        this.controller = controller;
        LogModel.getInstance().addLogListener(this);

        buildAndShow();
    }

    private void buildAndShow() {
        VLayout rl = new VLayout();
        this.rootLayout = rl;
        rl.setWidth100();
        rl.setHeight100();
        rl.setBackgroundColor("#fafafa");

        this.aboutWindow = new AboutWindow();
        this.addNodeWindow = new AddNodeWindow();
        this.settingsWindow = new SettingsWindow(controller);
        this.credentialsWindow = new CredentialsWindow();

        final Canvas header = buildTools();
        HorizontalPanel panel = new HorizontalPanel();
        panel.setWidth("100%");
        panel.setHeight("3px");
        panel.add(new HTML("<hr color=\"#f47930\" />"));

        Canvas topPane = buildTopPane();
        topPane.setWidth100();
        topPane.setHeight100();
        Canvas botPane = buildBotPane();
        botPane.setWidth100();
        botPane.setHeight100();

        SectionStackSection topSection = new SectionStackSection();
        topSection.setTitle("Nodes");
        topSection.setExpanded(true);
        topSection.setItems(topPane);

        ImgButton expandButton = new ImgButton();
        expandButton.setWidth(16);
        expandButton.setHeight(16);
        expandButton.setSrc(Images.instance.expand_16().getSafeUri().asString());
        expandButton.setTooltip("Expand all items");
        expandButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                RMPage.this.treeView.expandAll();
            }
        });<commit_msg>Remove extra white space below the orange line<commit_after>/*
 * ProActive Parallel Suite(TM):
 * The Open Source library for parallel and distributed
 * Workflows & Scheduling, Orchestration, Cloud Automation
 * and Big Data Analysis on Enterprise Grids & Clouds.
 *
 * Copyright (c) 2007 - 2017 ActiveEon
 * Contact: <EMAIL>
 *
 * This library is free software: you can redistribute it and/or
 * modify it under the terms of the GNU Affero General Public License
 * as published by the Free Software Foundation: version 3 of
 * the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 * If needed, contact us to obtain a release under GPL Version 2 or 3
 * or a different license than the AGPL.
 */
package org.ow2.proactive_grid_cloud_portal.rm.client;

import org.ow2.proactive_grid_cloud_portal.common.client.AboutWindow;
import org.ow2.proactive_grid_cloud_portal.common.client.CredentialsWindow;
import org.ow2.proactive_grid_cloud_portal.common.client.Images;
import org.ow2.proactive_grid_cloud_portal.common.client.ImagesUnbundled;
import org.ow2.proactive_grid_cloud_portal.common.client.Listeners.LogListener;
import org.ow2.proactive_grid_cloud_portal.common.client.LogWindow;
import org.ow2.proactive_grid_cloud_portal.common.client.ToolButtonsRender;
import org.ow2.proactive_grid_cloud_portal.common.client.model.LogModel;
import org.ow2.proactive_grid_cloud_portal.common.client.model.LoginModel;
import org.ow2.proactive_grid_cloud_portal.common.shared.Config;
import org.ow2.proactive_grid_cloud_portal.rm.shared.RMConfig;

import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.visualization.client.VisualizationUtils;
import com.google.gwt.visualization.client.visualizations.corechart.CoreChart;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.types.VerticalAlignment;
import com.smartgwt.client.types.VisibilityMode;
import com.smartgwt.client.util.BooleanCallback;
import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.Img;
import com.smartgwt.client.widgets.ImgButton;
import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.events.DrawEvent;
import com.smartgwt.client.widgets.events.DrawHandler;
import com.smartgwt.client.widgets.events.ResizedEvent;
import com.smartgwt.client.widgets.events.ResizedHandler;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.CheckboxItem;
import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.LayoutSpacer;
import com.smartgwt.client.widgets.layout.SectionStack;
import com.smartgwt.client.widgets.layout.SectionStackSection;
import com.smartgwt.client.widgets.layout.VLayout;
import com.smartgwt.client.widgets.menu.Menu;
import com.smartgwt.client.widgets.menu.MenuItem;
import com.smartgwt.client.widgets.menu.MenuItemSeparator;
import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
import com.smartgwt.client.widgets.tab.Tab;
import com.smartgwt.client.widgets.tab.TabSet;
import com.smartgwt.client.widgets.toolbar.ToolStrip;
import com.smartgwt.client.widgets.toolbar.ToolStripButton;
import com.smartgwt.client.widgets.toolbar.ToolStripMenuButton;


/**
 * Page shown when an user is logged
 * 
 * 
 * 
 * 
 * @author mschnoor
 *
 */
public class RMPage implements LogListener {

    private static final int EXPAND_COLLAPSE_SECTION_LABEL_WIDTH = 80;

    private RMController controller = null;

    /** parent of all widgets held by this page */
    private Canvas rootLayout = null;

    /** displays all logs received from the event dispatcher */
    private LogWindow logWindow = null;

    /** about this app */
    private AboutWindow aboutWindow = null;

    /** client settings */
    private SettingsWindow settingsWindow = null;

    /** create and download credentials files */
    private CredentialsWindow credentialsWindow = null;

    /** create node sources */
    private NSCreationWindow nsWindow = null;

    /** node launcher window */
    private AddNodeWindow addNodeWindow = null;

    /** top pane : textual list of nodes */
    private TreeView treeView = null;

    /** bot left pane : selected node info */
    private InfoView infoView = null;

    /** bot left pane : selected node monitoring */
    private MonitoringView monitoringView = null;

    /** bot right pane : graphical list of nodes */
    private CompactView compactView = null;

    /** bot left pane : node count */
    private StatisticsView statsView = null;

    private ScriptConsoleView scriptConsoleView = null;

    /** bot right : graphs */
    private RMStatsView rmStatsView = null;

    /** displayed when critical log events occur */
    private ToolStripButton errorButton = null;

    private long lastCriticalMessage = 0;

    // Logo strip properties
    private int logoStripHeight = 40;

    private String logoStripBackgroundColor = "#fafafa";

    private String logoStripBorder = "0px";

    private ToolButtonsRender toolButtonsRender = new ToolButtonsRender();

    RMPage(RMController controller) {
        this.controller = controller;
        LogModel.getInstance().addLogListener(this);

        buildAndShow();
    }

    private void buildAndShow() {
        VLayout rl = new VLayout();
        this.rootLayout = rl;
        rl.setWidth100();
        rl.setHeight100();
        rl.setBackgroundColor("#fafafa");

        this.aboutWindow = new AboutWindow();
        this.addNodeWindow = new AddNodeWindow();
        this.settingsWindow = new SettingsWindow(controller);
        this.credentialsWindow = new CredentialsWindow();

        final Canvas header = buildTools();
        HorizontalPanel panel = new HorizontalPanel();
        panel.setWidth("100%");
        panel.setHeight("3px");
        panel.getElement().getStyle().setBackgroundColor("#f47930");
        panel.getElement().getStyle().setPadding(-1, Unit.PX);

        Canvas topPane = buildTopPane();
        topPane.setWidth100();
        topPane.setHeight100();
        Canvas botPane = buildBotPane();
        botPane.setWidth100();
        botPane.setHeight100();

        SectionStackSection topSection = new SectionStackSection();
        topSection.setTitle("Nodes");
        topSection.setExpanded(true);
        topSection.setItems(topPane);

        ImgButton expandButton = new ImgButton();
        expandButton.setWidth(16);
        expandButton.setHeight(16);
        expandButton.setSrc(Images.instance.expand_16().getSafeUri().asString());
        expandButton.setTooltip("Expand all items");
        expandButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                RMPage.this.treeView.expandAll();
            }
        });
{'fraction_non_alphanumeric': 0.09569569569569569, 'fraction_numerical': 0.008341675008341674, 'mean_word_length': 3.9377265238879735, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '5015610', 'n_tokens_mistral': 4428, 'n_tokens_neox': 4221, 'n_words': 1019}