Example usage for com.vaadin.server ThemeResource ThemeResource

List of usage examples for com.vaadin.server ThemeResource ThemeResource

Introduction

In this page you can find the example usage for com.vaadin.server ThemeResource ThemeResource.

Prototype

public ThemeResource(String resourceId) 

Source Link

Document

Creates a resource.

Usage

From source file:com.skysql.manager.ui.ChartPreviewLayout.java

License:Open Source License

/**
 * Instantiates a new chart preview layout.
 *
 * @param userChart the user chart/*w ww. j  a va  2s  .  com*/
 * @param time the time
 * @param interval the interval
 */
public ChartPreviewLayout(final UserChart userChart, String time, String interval) {
    this.userChart = userChart;
    this.time = time;
    this.interval = interval;

    addStyleName("ChartPreviewLayout");
    setSpacing(true);
    setMargin(true);

    HorizontalLayout formDescription = new HorizontalLayout();
    formDescription.setSpacing(true);

    Embedded info = new Embedded(null, new ThemeResource("img/info.png"));
    info.addStyleName("infoButton");
    String infoText = "<table border=0 cellspacing=3 cellpadding=0 summary=\"\">\n"
            + "     <tr bgcolor=\"#ccccff\">" + "         <th align=left>Field"
            + "         <th align=left>Description" + "     <tr>" + "         <td><code>Title</code>"
            + "         <td>Name of the Chart" + "     <tr bgcolor=\"#eeeeff\">"
            + "         <td><code>Description</code>" + "         <td>Description of the Chart " + "     <tr>"
            + "         <td nowrap><code>Measurement Unit</code>"
            + "         <td>Unit of measurement for the data returned by the monitor, used as caption for the vertical axis of the chart"
            + "     <tr bgcolor=\"#eeeeff\">" + "         <td><code>Type</code>"
            + "         <td>Chart type (LineChart, AreaChart)" + "     <tr>"
            + "         <td><code>Points</code>" + "         <td>Number of data points displayed";
    infoText += " </table>" + " </blockquote>";
    info.setDescription(infoText);
    formDescription.addComponent(info);

    final Label monitorsLabel = new Label("Display as Chart");
    monitorsLabel.setStyleName("dialogLabel");
    formDescription.addComponent(monitorsLabel);
    formDescription.setComponentAlignment(monitorsLabel, Alignment.MIDDLE_LEFT);

    addComponent(formDescription);
    setComponentAlignment(formDescription, Alignment.TOP_CENTER);

    HorizontalLayout chartInfo = new HorizontalLayout();
    chartInfo.setSpacing(true);
    addComponent(chartInfo);
    setComponentAlignment(chartInfo, Alignment.MIDDLE_CENTER);

    FormLayout formLayout = new FormLayout();
    chartInfo.addComponent(formLayout);

    chartName = new TextField("Title");
    chartName.setImmediate(true);
    formLayout.addComponent(chartName);

    chartDescription = new TextField("Description");
    chartDescription.setWidth("25em");
    chartDescription.setImmediate(true);
    formLayout.addComponent(chartDescription);

    chartUnit = new TextField("Measurement Unit");
    chartUnit.setImmediate(true);
    formLayout.addComponent(chartUnit);

    chartSelectType = new NativeSelect("Type");
    chartSelectType.setImmediate(true);
    for (UserChart.ChartType type : UserChart.ChartType.values()) {
        chartSelectType.addItem(type.name());
    }
    chartSelectType.setNullSelectionAllowed(false);
    formLayout.addComponent(chartSelectType);

    selectCount = new NativeSelect("Points");
    selectCount.setImmediate(true);
    for (int points : UserChart.chartPoints()) {
        selectCount.addItem(points);
        selectCount.setItemCaption(points, String.valueOf(points));
    }
    selectCount.setNullSelectionAllowed(false);
    formLayout.addComponent(selectCount);

    updateChartInfo(userChart.getName(), userChart.getDescription(), userChart.getUnit(), userChart.getType(),
            userChart.getPoints());

    chartName.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void valueChange(ValueChangeEvent event) {

            String chartName = (String) (event.getProperty()).getValue();
            userChart.setName(chartName);
            refreshChart();

        }
    });

    chartDescription.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void valueChange(ValueChangeEvent event) {

            String value = (String) (event.getProperty()).getValue();
            userChart.setDescription(value);
            refreshChart();

        }
    });

    chartUnit.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void valueChange(ValueChangeEvent event) {

            String value = (String) (event.getProperty()).getValue();
            userChart.setUnit(value);
            refreshChart();

        }
    });

    chartSelectType.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void valueChange(ValueChangeEvent event) {

            String value = (String) (event.getProperty()).getValue();
            userChart.setType(value);
            refreshChart();

        }
    });

    selectCount.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void valueChange(ValueChangeEvent event) {

            int points = (Integer) (event.getProperty()).getValue();
            userChart.setPoints(points);
            refreshChart();

        }
    });

    chartLayout = drawChart();
    addComponent(chartLayout);

}

From source file:com.skysql.manager.ui.ChartsDialog.java

License:Open Source License

/**
 * Instantiates a new charts dialog./*  www . j av a 2 s . c o m*/
 *
 * @param chartsLayout the charts layout
 * @param chartButton the chart button
 */
public ChartsDialog(final ChartsLayout chartsLayout, final ChartButton chartButton) {

    this.chartButton = chartButton;
    this.chartsLayout = chartsLayout;

    dialogWindow = new ModalWindow("Monitors to Chart mapping", "775px");

    HorizontalLayout wrapper = new HorizontalLayout();
    //wrapper.setWidth("100%");
    wrapper.setMargin(true);

    UI.getCurrent().addWindow(dialogWindow);

    newUserChart = (chartButton != null) ? new UserChart((UserChart) chartButton.getData()) : newUserChart();

    ArrayList<String> monitorIDs = newUserChart.getMonitorIDs();
    MonitorsLayout monitorsLayout = new MonitorsLayout(monitorIDs);
    wrapper.addComponent(monitorsLayout);

    VerticalLayout separator = new VerticalLayout();
    separator.setSizeFull();
    Embedded rightArrow = new Embedded(null, new ThemeResource("img/right_arrow.png"));
    separator.addComponent(rightArrow);
    separator.setComponentAlignment(rightArrow, Alignment.MIDDLE_CENTER);
    wrapper.addComponent(separator);

    ChartPreviewLayout chartPreviewLayout = new ChartPreviewLayout(newUserChart, chartsLayout.getTime(),
            chartsLayout.getInterval());
    wrapper.addComponent(chartPreviewLayout);
    monitorsLayout.addChartPreview(chartPreviewLayout);

    HorizontalLayout buttonsBar = new HorizontalLayout();
    buttonsBar.setStyleName("buttonsBar");
    buttonsBar.setSizeFull();
    buttonsBar.setSpacing(true);
    buttonsBar.setMargin(true);
    buttonsBar.setHeight("49px");

    Label filler = new Label();
    buttonsBar.addComponent(filler);
    buttonsBar.setExpandRatio(filler, 1.0f);

    Button cancelButton = new Button("Cancel");
    buttonsBar.addComponent(cancelButton);
    buttonsBar.setComponentAlignment(cancelButton, Alignment.MIDDLE_RIGHT);

    cancelButton.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void buttonClick(ClickEvent event) {
            dialogWindow.close();
        }
    });

    Button okButton = new Button(chartButton != null ? "Save Changes" : "Add Chart");
    okButton.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void buttonClick(ClickEvent event) {
            try {
                ChartButton newChartButton = new ChartButton(newUserChart);
                newChartButton.setChartsLayout(chartsLayout);
                newChartButton.setEditable(true);
                if (chartButton != null) {
                    chartsLayout.replaceComponent(chartButton, newChartButton);
                } else {
                    chartsLayout.addComponent(newChartButton);
                }

            } catch (Exception e) {
                ManagerUI.error(e.getMessage());
            }

            dialogWindow.close();
        }
    });
    buttonsBar.addComponent(okButton);
    buttonsBar.setComponentAlignment(okButton, Alignment.MIDDLE_RIGHT);

    VerticalLayout windowLayout = (VerticalLayout) dialogWindow.getContent();
    windowLayout.setSpacing(false);
    windowLayout.setMargin(false);
    windowLayout.addComponent(wrapper);
    windowLayout.addComponent(buttonsBar);

}

From source file:com.skysql.manager.ui.components.ChartButton.java

License:Open Source License

/**
 * Make the chart editable or not//from   w w  w .  j a  va  2s . c  o  m
 *
 * @param editable the new editable
 */
public void setEditable(boolean editable) {
    isEditable = editable;

    if (editable) {
        chart.setEnabled(false);

        addStyleName("draggable");

        draggable = new Label("Click and drag to reorder.\n  Double-click to edit.", ContentMode.PREFORMATTED);
        draggable.addStyleName("draggableLabel");
        layout.addComponent(draggable);

        editButton = new Embedded(null, new ThemeResource("img/edit.png"));
        editButton.addStyleName("editChart");
        editButton.setDescription("Edit Chart");
        editButton.setData(this);
        layout.addComponent(editButton);
        editButton.addClickListener(new MouseEvents.ClickListener() {
            private static final long serialVersionUID = 0x4C656F6E6172646FL;

            public void click(ClickEvent event) {
                new ChartsDialog(chartsLayout, thisButton);
            }
        });

        deleteButton = new Embedded(null, new ThemeResource("img/delete.png"));
        deleteButton.addStyleName("deleteChart");
        deleteButton.setDescription("Delete Chart");
        deleteButton.setData(this);
        layout.addComponent(deleteButton);
        deleteButton.addClickListener(new MouseEvents.ClickListener() {
            private static final long serialVersionUID = 0x4C656F6E6172646FL;

            public void click(ClickEvent event) {
                chartsLayout.deleteChart(thisButton);
            }
        });

    } else {
        chart.setEnabled(true);

        setStyleName(getStyleName().replace("draggable", ""));

        if (layout != null) {
            if (draggable != null) {
                layout.removeComponent(draggable);
            }
            if (editButton != null) {
                layout.removeComponent(editButton);
            }
            if (deleteButton != null) {
                layout.removeComponent(deleteButton);
            }
        }
        draggable = null;
        editButton = null;
        deleteButton = null;

    }
}

From source file:com.skysql.manager.ui.components.ComponentButton.java

License:Open Source License

/**
 * Instantiates a new component button.//  w  w w . jav a 2  s  .c  o  m
 *
 * @param componentInfo the component info
 */
public ComponentButton(ClusterComponent componentInfo) {
    thisButton = this;
    this.componentInfo = componentInfo;

    addStyleName("componentButton");

    componentInfo.setButton(this);
    setData(componentInfo);

    setHeight(COMPONENT_HEIGHT + 4, Unit.PIXELS);
    float componentWidth = (componentInfo.getType() == ClusterComponent.CCType.system) ? SYSTEM_WIDTH
            : NODE_WIDTH;
    setWidth(componentWidth + 8, Unit.PIXELS);

    imageLayout = new VerticalLayout();
    imageLayout.setHeight(COMPONENT_HEIGHT + 4, Unit.PIXELS);
    imageLayout.setWidth(componentWidth, Unit.PIXELS);
    //imageLayout.setMargin(new MarginInfo(true, true, false, true));
    imageLayout.setImmediate(true);

    if (componentInfo.getParentID() != null) {
        String icon = null;
        switch (componentInfo.getType()) {
        case system:
            icon = "system";
            break;

        case node:
            icon = NodeStates.getNodeIcon(componentInfo.getSystemType(), componentInfo.getState());
            break;

        default:
            // unknown component type
            break;
        }
        imageLayout.addStyleName(icon);
        //imageLayout.addStyleName(componentInfo.getType().toString());

        commandLabel = new Label();
        commandLabel.setSizeUndefined();
        imageLayout.addComponent(commandLabel);
        imageLayout.setComponentAlignment(commandLabel, Alignment.TOP_LEFT);
        //imageLayout.setExpandRatio(commandLabel, 1.0f);
        //            NodeInfo nodeInfo = (NodeInfo) componentInfo;
        //            TaskRecord taskRecord = nodeInfo.getTask();
        //            setCommandLabel(taskRecord);

        Label padding = new Label("");
        imageLayout.addComponent(padding);
        imageLayout.setComponentAlignment(padding, Alignment.MIDDLE_CENTER);

        HorizontalLayout iconsStrip = new HorizontalLayout();
        iconsStrip.addStyleName("componentInfo");
        iconsStrip.setWidth(componentInfo.getType() == ClusterComponent.CCType.node ? "60px" : "76px");
        imageLayout.addComponent(iconsStrip);
        imageLayout.setComponentAlignment(iconsStrip, Alignment.MIDDLE_CENTER);

        info = new Embedded(null, new ThemeResource("img/info.png"));
        iconsStrip.addComponent(info);
        iconsStrip.setComponentAlignment(info, Alignment.MIDDLE_LEFT);

        alert = new Embedded();
        alert.setVisible(false);
        iconsStrip.addComponent(alert);
        iconsStrip.setComponentAlignment(alert, Alignment.MIDDLE_RIGHT);

        nameLabel = new Label(componentInfo.getName());
        nameLabel.setStyleName("componentName");
        nameLabel.setSizeUndefined();
        imageLayout.addComponent(nameLabel);
        imageLayout.setComponentAlignment(nameLabel, Alignment.BOTTOM_CENTER);

    }
    addComponent(imageLayout);
    setComponentAlignment(imageLayout, Alignment.TOP_CENTER);
    setExpandRatio(imageLayout, 1.0f);

}

From source file:com.skysql.manager.ui.components.ComponentButton.java

License:Open Source License

/**
 * Sets the editable.// ww w . j a v a  2  s.  c o  m
 *
 * @param editable the new editable
 */
public void setEditable(boolean editable) {
    if (editable && !this.isEditable) {
        imageLayout.setEnabled(false);

        String componentType;
        switch (componentInfo.getType()) {
        case system:
            componentType = "System";
            break;
        case node:
            componentType = "Node";
            break;
        default:
            componentType = "Unknown Component";
            break;
        }

        editButton = new Embedded(null, new ThemeResource("img/edit.png"));
        editButton.addStyleName("edit" + componentType);
        editButton.setDescription("Edit " + componentType);
        editButton.setData(this);
        addComponent(editButton);
        editButton.addClickListener(new MouseEvents.ClickListener() {
            private static final long serialVersionUID = 0x4C656F6E6172646FL;

            public void click(ClickEvent event) {
                new ComponentDialog((ClusterComponent) thisButton.getData(), thisButton);
            }
        });

        deleteButton = new Embedded(null, new ThemeResource("img/delete.png"));
        deleteButton.addStyleName("delete" + componentType);
        deleteButton.setDescription("Delete " + componentType);
        deleteButton.setData(this);
        addComponent(deleteButton);
        deleteButton.addClickListener(new MouseEvents.ClickListener() {
            private static final long serialVersionUID = 0x4C656F6E6172646FL;

            public void click(ClickEvent event) {
                deleteComponent((ClusterComponent) thisButton.getData());
            }
        });

    } else if (!editable && this.isEditable) {
        imageLayout.setEnabled(true);

        if (editButton != null) {
            removeComponent(editButton);
            editButton = null;
        }

        if (deleteButton != null) {
            removeComponent(deleteButton);
            deleteButton = null;
        }
    }

    this.isEditable = editable;
}

From source file:com.skysql.manager.ui.components.ScriptingProgressLayout.java

License:Open Source License

/**
 * Sets the error info.//w w w . ja v a  2  s. com
 *
 * @param msg the new error info
 */
public void setErrorInfo(String msg) {
    Embedded info = new Embedded(null, new ThemeResource("img/alert.png"));
    info.addStyleName("infoButton");
    info.setDescription(msg);
    resultLayout.addComponent(info);
    resultLayout.setComponentAlignment(info, Alignment.MIDDLE_CENTER);
}

From source file:com.skysql.manager.ui.components.ScriptingProgressLayout.java

License:Open Source License

/**
 * Builds the progress.//from w ww  .ja v  a  2s.  c om
 *
 * @param taskRecord the task record
 * @param command the command
 * @param steps the steps
 */
public void buildProgress(TaskRecord taskRecord, String command, String steps) {

    VaadinSession session = getSession();
    if (session == null) {
        session = VaadinSession.getCurrent();
    }

    if (observerMode) {
        // String userName = Users.getUserNames().get(taskRecord.getUser());
        String userID = taskRecord.getUserID();
        UserInfo userInfo = (UserInfo) session.getAttribute(UserInfo.class);
        DateConversion dateConversion = session.getAttribute(DateConversion.class);
        setTitle(command + " was started on " + dateConversion.adjust(taskRecord.getStart()) + " by " + userID);
    } else {
        setTitle(command);
    }

    String[] stepIDs;
    try {
        stepIDs = steps.split(",");
    } catch (NullPointerException npe) {
        stepIDs = new String[] {};
    }
    totalSteps = stepIDs.length;
    primitives = new String[totalSteps];
    taskImages = new Embedded[totalSteps];

    // add steps icons
    progressIconsLayout.removeAllComponents();
    for (int index = 0; index < totalSteps; index++) {
        String stepID = stepIDs[index].trim();
        String description = Steps.getDescription(stepID);

        VerticalLayout stepLayout = new VerticalLayout();
        progressIconsLayout.addComponent(stepLayout);
        stepLayout.addStyleName("stepIcons");
        Label name = new Label(stepID);
        stepLayout.addComponent(name);
        stepLayout.setComponentAlignment(name, Alignment.MIDDLE_CENTER);
        Embedded image = new Embedded(null, new ThemeResource("img/scripting/pending.png"));
        image.setImmediate(true);
        image.setDescription(description);
        stepLayout.addComponent(image);
        primitives[index] = stepID;
        taskImages[index] = image;

    }

    setProgress("");

}

From source file:com.skysql.manager.ui.components.ScriptingProgressLayout.java

License:Open Source License

/**
 * Asynch refresh.// w w  w.  ja  va2  s.  c o m
 *
 * @param updaterThread the updater thread
 */
private void asynchRefresh(final UpdaterThread updaterThread) {

    VaadinSession session = getSession();
    if (session == null) {
        session = VaadinSession.getCurrent();
    }

    ManagerUI managerUI = session.getAttribute(ManagerUI.class);

    managerUI.access(new Runnable() {
        @Override
        public void run() {
            // Here the UI is locked and can be updated

            VaadinSession session = getSession();
            if (session == null) {
                session = VaadinSession.getCurrent();
            }

            ManagerUI.log(this.getClass().getName() + " access run(): ");

            DateConversion dateConversion = session.getAttribute(DateConversion.class);

            String stateString;
            if ((stateString = taskRecord.getState()) == null) {
                return; // we're waiting for something to happen
            }
            CommandStates.States state = CommandStates.States.valueOf(stateString);
            setResult(CommandStates.getDescriptions().get(state.name()));

            String indexString;
            if ((indexString = taskRecord.getIndex()) == null) {
                return; // we're waiting for something to happen
            }
            int index = (state == States.done) ? totalSteps - 1 : Integer.parseInt(indexString) - 1;

            while (lastProgressIndex < index) {
                taskImages[lastProgressIndex].setSource(new ThemeResource("img/scripting/past.png"));
                lastProgressIndex++;
            }

            if (index >= 0) {
                switch (state) {
                case running:
                    taskImages[index].setSource(new ThemeResource("img/scripting/active.png"));
                    setProgress(taskImages[index].getDescription());
                    break;
                case done:
                    taskImages[index].setSource(new ThemeResource("img/scripting/past.png/"));
                    break;
                case error:
                case missing:
                    taskImages[index].setSource(new ThemeResource("img/scripting/error.png"));
                    break;
                case cancelled:
                case stopped:
                    taskImages[index].setSource(new ThemeResource("img/scripting/error.png"));
                    break;
                default:
                    break;
                }
            }

            setResult(CommandStates.getDescriptions().get(state.name()));

            switch (state) {
            case running:
                break;
            case error:
            case missing:
                setErrorInfo(taskRecord.getError());
            case done:
            case cancelled:
            case stopped:
            default:
                runningTask.close();
                break;

            }
        }
    });

}

From source file:com.skysql.manager.ui.ErrorDialog.java

License:Open Source License

/**
 * Instantiates a new error dialog./*from  www .  ja v  a  2  s.  c  o  m*/
 *
 * @param e the exception
 * @param humanizedError the humanized error
 */
public ErrorDialog(Exception e, String humanizedError) {

    if (e != null) {
        ManagerUI.error(e.getMessage());
    }

    dialogWindow = new ModalWindow("An Error has occurred", "775px");
    dialogWindow.setHeight("340px");
    dialogWindow.addCloseListener(this);
    UI current = UI.getCurrent();
    if (current.getContent() == null) {
        current.setContent(new ErrorView(Notification.Type.ERROR_MESSAGE, null));
    }
    current.addWindow(dialogWindow);

    HorizontalLayout wrapper = new HorizontalLayout();
    wrapper.setSizeFull();
    wrapper.setMargin(true);

    VerticalLayout iconLayout = new VerticalLayout();
    iconLayout.setWidth("100px");
    wrapper.addComponent(iconLayout);
    Embedded image = new Embedded(null, new ThemeResource("img/error.png"));
    iconLayout.addComponent(image);

    VerticalLayout textLayout = new VerticalLayout();
    textLayout.setHeight("100%");
    textLayout.setSpacing(true);
    wrapper.addComponent(textLayout);
    wrapper.setExpandRatio(textLayout, 1.0f);

    if (humanizedError != null || e != null) {
        String error = (humanizedError != null) ? humanizedError : e.toString();
        ManagerUI.error(error);
        Label label = new Label(error, ContentMode.HTML);
        label.addStyleName("warning");
        textLayout.addComponent(label);
        textLayout.setComponentAlignment(label, Alignment.TOP_CENTER);
    }

    if (e != null) {
        TextArea stackTrace = new TextArea("Error Log");
        stackTrace.setSizeFull();
        StringWriter sw = new StringWriter();
        e.printStackTrace(new PrintWriter(sw));
        stackTrace.setValue(sw.toString());
        textLayout.addComponent(stackTrace);
        textLayout.setComponentAlignment(stackTrace, Alignment.TOP_LEFT);
        textLayout.setExpandRatio(stackTrace, 1.0f);
    }

    HorizontalLayout buttonsBar = new HorizontalLayout();
    buttonsBar.setStyleName("buttonsBar");
    buttonsBar.setSizeFull();
    buttonsBar.setSpacing(true);
    buttonsBar.setMargin(true);
    buttonsBar.setHeight("49px");

    Label filler = new Label();
    buttonsBar.addComponent(filler);
    buttonsBar.setExpandRatio(filler, 1.0f);

    Button cancelButton = new Button("Close");
    buttonsBar.addComponent(cancelButton);
    buttonsBar.setComponentAlignment(cancelButton, Alignment.MIDDLE_RIGHT);

    cancelButton.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void buttonClick(ClickEvent event) {
            dialogWindow.close();
            //UI.getCurrent().close();
        }
    });

    Button okButton = new Button("Send Error");
    okButton.setEnabled(false);
    okButton.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void buttonClick(ClickEvent event) {
            dialogWindow.close();
        }
    });
    buttonsBar.addComponent(okButton);
    buttonsBar.setComponentAlignment(okButton, Alignment.MIDDLE_RIGHT);

    VerticalLayout windowLayout = (VerticalLayout) dialogWindow.getContent();
    windowLayout.setHeight("100%");
    windowLayout.setSpacing(false);
    windowLayout.setMargin(false);
    windowLayout.addComponent(wrapper);
    windowLayout.setExpandRatio(wrapper, 1.0f);
    windowLayout.addComponent(buttonsBar);

}

From source file:com.skysql.manager.ui.ErrorView.java

License:Open Source License

/**
 * Instantiates a new error view./*from  w  ww  .  j  a v a2  s.  co m*/
 *
 * @param type the notification type
 * @param errorMsg the error msg
 */
public ErrorView(Type type, String errorMsg) {

    addStyleName("loginView");
    setSizeFull();
    setMargin(true);
    setSpacing(true);

    if (errorMsg != null) {
        Notification.show(errorMsg, type);
    }

    Embedded logo = new Embedded(null, new ThemeResource("img/productlogo.png"));
    addComponent(logo);
    setComponentAlignment(logo, Alignment.TOP_CENTER);

    if (type == Notification.Type.ERROR_MESSAGE) {
        Label refreshLabel = new Label("To try again, please refresh/reload the current page.");
        refreshLabel.setSizeUndefined();
        refreshLabel.addStyleName("instructions");
        addComponent(refreshLabel);
        setComponentAlignment(refreshLabel, Alignment.TOP_CENTER);
    }
}