Example usage for com.vaadin.ui Embedded Embedded

List of usage examples for com.vaadin.ui Embedded Embedded

Introduction

In this page you can find the example usage for com.vaadin.ui Embedded Embedded.

Prototype

public Embedded(String caption, Resource source) 

Source Link

Document

Creates a new Embedded object whose contents is loaded from given resource.

Usage

From source file:com.ribas.andrei.vaadin.OpenWindowApplication.java

License:Open Source License

private void createSubWindow(String subWindowMessage, boolean modal) {

    if (subWindow == null) {

        Embedded iframe = new Embedded(null, OpenWindowApplication.this.getStreamSource());
        iframe.setType(Embedded.TYPE_BROWSER);
        iframe.setWidth("100%");
        iframe.setHeight("100%");

        createSubWindow(subWindowMessage, modal, iframe);

    } else if (subWindow.getParent() != null) {
        mainWindow.showNotification("SubWindow is already open");
    }//from   w  w w  . j  a  va2  s. c  om

}

From source file:com.scsb.crpro.MessageBox.java

License:Apache License

/**
 * Similar to {@link #MessageBox(Window, String, Icon, String, Alignment, ButtonConfig...)},
 * but the message component is defined explicitly. The component can be even a composite
 * of a layout manager and manager further Vaadin components.
 * /*  w  w  w .  j  a va  2s.  com*/
 * @param messageComponent a Vaadin component
 */
public MessageBox(String dialogWidth, String dialogHeight, String dialogCaption, Icon dialogIcon,
        Component messageComponent, Alignment buttonsAlignment, ButtonConfig... buttonConfigs) {
    super();
    setResizable(false);
    setClosable(false);
    setSizeUndefined();
    setWidth(dialogWidth);
    //setHeight(dialogHeight);
    setCaption(dialogCaption);

    GridLayout mainLayout = new GridLayout(2, 2);
    mainLayout.setMargin(true);
    mainLayout.setSpacing(true);
    mainLayout.setSizeUndefined();
    mainLayout.setWidth(GRID_DEFAULT_WIDTH1);

    // Add Content
    messageComponent.setSizeUndefined();
    messageComponent.setWidth(GRID_DEFAULT_WIDTH2);
    if (dialogIcon == null || Icon.NONE.equals(dialogIcon)) {
        mainLayout.addComponent(messageComponent, 0, 0, 1, 0);
        mainLayout.setRowExpandRatio(0, 1.0f);
        mainLayout.setColumnExpandRatio(0, 1.0f);
    } else {
        mainLayout.addComponent(messageComponent, 1, 0);
        mainLayout.setRowExpandRatio(0, 1.0f);
        mainLayout.setColumnExpandRatio(1, 1.0f);

        Embedded icon = null;
        switch (dialogIcon) {
        case QUESTION:
            icon = new Embedded(null, new ThemeResource("images/question.png"));
            break;
        case INFO:
            icon = new Embedded(null, new ThemeResource("images/info.png"));
            break;
        case WARN:
            icon = new Embedded(null, new ThemeResource("images/warn.png"));
            break;
        case ERROR:
            icon = new Embedded(null, new ThemeResource("images/error.png"));
            break;
        }
        mainLayout.addComponent(icon, 0, 0);
        icon.setWidth(ICON_DEFAULT_SIZE);
        icon.setHeight(ICON_DEFAULT_SIZE);
    }

    // Add Buttons
    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    mainLayout.addComponent(buttonLayout, 0, 1, 1, 1);
    mainLayout.setComponentAlignment(buttonLayout, buttonsAlignment);
    for (ButtonConfig buttonConfig : buttonConfigs) {
        Button button = new Button(buttonConfig.getCaption(),
                new ButtonClickListener(buttonConfig.getButtonType()));
        if (buttonConfig.getWidth() != null) {
            button.setWidth(buttonConfig.getWidth());
        }
        if (buttonConfig.getOptionalResource() != null) {
            button.setIcon(buttonConfig.getOptionalResource());
        } else {
            Resource icon = null;
            switch (buttonConfig.getButtonType()) {
            case ABORT:
                icon = new ThemeResource("images/famfamfam/cross.png");
                break;
            case CANCEL:
                icon = new ThemeResource("images/famfamfam/cross.png");
                break;
            case CLOSE:
                icon = new ThemeResource("images/famfamfam/door.png");
                break;
            case HELP:
                icon = new ThemeResource("images/famfamfam/lightbulb.png");
                break;
            case OK:
                icon = new ThemeResource("images/famfamfam/tick.png");
                break;
            case YES:
                icon = new ThemeResource("images/famfamfam/tick.png");
                break;
            case NO:
                icon = new ThemeResource("images/famfamfam/cross.png");
                break;
            case SAVE:
                icon = new ThemeResource("images/famfamfam/disk.png");
                break;
            case RETRY:
                icon = new ThemeResource("images/famfamfam/arrow_refresh.png");
                break;
            case IGNORE:
                icon = new ThemeResource("images/famfamfam/lightning_go.png");
                break;
            }
            button.setIcon(icon);
        }
        buttonLayout.addComponent(button);
    }

    setContent(mainLayout);
}

From source file:com.scsb.vaadin.composite.MessageBox.java

License:Apache License

/**
 * Similar to {@link #MessageBox(Window, String, Icon, String, Alignment, ButtonConfig...)},
 * but the message component is defined explicitly. The component can be even a composite
 * of a layout manager and manager further Vaadin components.
 * //from   w  w  w.j a  va 2s .c  om
 * @param messageComponent a Vaadin component
 */
public MessageBox(String dialogWidth, String dialogHeight, String dialogCaption, Icon dialogIcon,
        Component messageComponent, Alignment buttonsAlignment, ButtonConfig... buttonConfigs) {
    super();
    setResizable(false);
    setClosable(false);
    setSizeUndefined();
    setWidth(dialogWidth);
    //setHeight(dialogHeight);
    setCaption(dialogCaption);

    GridLayout mainLayout = new GridLayout(2, 2);
    mainLayout.setMargin(true);
    mainLayout.setSpacing(true);
    mainLayout.setSizeUndefined();
    mainLayout.setWidth(GRID_DEFAULT_WIDTH1);

    // Add Content
    messageComponent.setSizeUndefined();
    messageComponent.setWidth(GRID_DEFAULT_WIDTH2);
    if (dialogIcon == null || Icon.NONE.equals(dialogIcon)) {
        mainLayout.addComponent(messageComponent, 0, 0, 1, 0);
        mainLayout.setRowExpandRatio(0, 1.0f);
        mainLayout.setColumnExpandRatio(0, 1.0f);
    } else {
        mainLayout.addComponent(messageComponent, 1, 0);
        mainLayout.setRowExpandRatio(0, 1.0f);
        mainLayout.setColumnExpandRatio(1, 1.0f);

        Embedded icon = null;
        switch (dialogIcon) {
        case QUESTION:
            icon = new Embedded(null, new ThemeResource("./images/question.png"));
            break;
        case INFO:
            icon = new Embedded(null, new ThemeResource("./images/info.png"));
            break;
        case WARN:
            icon = new Embedded(null, new ThemeResource("./images/warn.png"));
            break;
        case ERROR:
            icon = new Embedded(null, new ThemeResource("./images/error.png"));
            break;
        }
        mainLayout.addComponent(icon, 0, 0);
        icon.setWidth(ICON_DEFAULT_SIZE);
        icon.setHeight(ICON_DEFAULT_SIZE);
    }

    // Add Buttons
    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    mainLayout.addComponent(buttonLayout, 0, 1, 1, 1);
    mainLayout.setComponentAlignment(buttonLayout, buttonsAlignment);
    for (ButtonConfig buttonConfig : buttonConfigs) {
        Button button = new Button(buttonConfig.getCaption(),
                new ButtonClickListener(buttonConfig.getButtonType()));
        if (buttonConfig.getWidth() != null) {
            button.setWidth(buttonConfig.getWidth());
        }
        if (buttonConfig.getOptionalResource() != null) {
            button.setIcon(buttonConfig.getOptionalResource());
        } else {
            Resource icon = null;
            switch (buttonConfig.getButtonType()) {
            case ABORT:
                icon = new ThemeResource("images/famfamfam/cross.png");
                break;
            case CANCEL:
                icon = new ThemeResource("images/famfamfam/cross.png");
                break;
            case CLOSE:
                icon = new ThemeResource("images/famfamfam/door.png");
                break;
            case HELP:
                icon = new ThemeResource("images/famfamfam/lightbulb.png");
                break;
            case OK:
                icon = new ThemeResource("images/famfamfam/tick.png");
                break;
            case YES:
                icon = new ThemeResource("images/famfamfam/tick.png");
                break;
            case NO:
                icon = new ThemeResource("images/famfamfam/cross.png");
                break;
            case SAVE:
                icon = new ThemeResource("images/famfamfam/disk.png");
                break;
            case RETRY:
                icon = new ThemeResource("images/famfamfam/arrow_refresh.png");
                break;
            case IGNORE:
                icon = new ThemeResource("images/famfamfam/lightning_go.png");
                break;
            }
            button.setIcon(icon);
        }
        buttonLayout.addComponent(button);
    }

    setContent(mainLayout);
}

From source file:com.selzlein.lojavirtual.vaadin.page.TodoListView.java

License:Open Source License

@SuppressWarnings("serial")
private void createView() {
    final LspsUI ui = (LspsUI) getUI();

    setTitle(ui.getMessage(TITLE));/*from  w  w  w.j a  va2 s  .  c  o m*/

    VerticalLayout layout = new VerticalLayout();
    setContent(layout);

    table = new Table();
    table.setSizeFull();
    table.setSelectable(true);
    table.setMultiSelectMode(MultiSelectMode.SIMPLE);
    table.setSortEnabled(false);
    table.setColumnReorderingAllowed(true);
    table.setColumnCollapsingAllowed(true);

    table.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            final Object sel = event.getProperty().getValue();
            if (sel instanceof Set) {
                selection = (Set<Long>) sel;
            } else if (sel instanceof Long) {
                selection = Collections.singleton((Long) sel);
            } else {
                selection = Collections.emptySet();
            }

            //enable todo actions only if the sel is non-empty
            actionBtn.setEnabled(selection.size() > 0);
        }
    });
    table.addItemClickListener(new ItemClickListener() {

        @Override
        public void itemClick(ItemClickEvent event) {
            if (table.isMultiSelect()) {
                return; //don't do anything if in selection mode
            }
            if (event.getButton() != MouseButton.LEFT || event.isDoubleClick()) {
                return; //ignore right-clicks
            }

            final Item item = event.getItem();
            final Long todoId = (Long) item.getItemProperty("id").getValue();
            try {
                ((LspsUI) getUI()).openTodo(todoId);
            } catch (Exception e) {
                Utils.log(e, "could not open to-do " + todoId, log);
                final LspsUI ui = (LspsUI) getUI();
                ui.showErrorMessage("app.unknownErrorOccurred", e); //todo.openFailed?
            }
        }
    });

    table.setContainerDataSource(container);

    Object[] defaultColumns = new Object[] { "title", "notes", "priority", "authorization", "modelInstanceId",
            "issuedDate" };
    //load table settings
    String settings = ui.getUser().getSettingString(SETTINGS_KEY, null);
    if (settings == null) {
        table.setVisibleColumns(defaultColumns);
        originalSettings = getColumnSettings();
    } else {
        originalSettings = settings;
        try {
            applyTableSettings(settings);
        } catch (Exception e) {
            table.setVisibleColumns(defaultColumns);
            Utils.log(e, "could not load todo list settings", log);
        }
    }

    table.setColumnHeader("title", ui.getMessage("todo.title"));
    table.setColumnHeader("notes", ui.getMessage("todo.notes"));
    table.setColumnHeader("priority", ui.getMessage("todo.priority"));
    table.setColumnHeader("authorization", ui.getMessage("todo.authorizationShort"));
    table.setColumnHeader("modelInstanceId", ui.getMessage("todo.process"));
    table.setColumnHeader("issuedDate", ui.getMessage("todo.issued"));

    table.setColumnAlignment("modelInstanceId", Table.Align.CENTER);
    if (table.getItemIds().size() > 0) {
        table.setColumnExpandRatio("title", 2);
        table.setColumnExpandRatio("notes", 1);
    }

    //localize todo titles
    table.addGeneratedColumn("title", new ColumnGenerator() {

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            @SuppressWarnings("unchecked")
            BeanItem<Todo> item = (BeanItem<Todo>) source.getItem(itemId);
            return ui.localizeEngineText(item.getBean().getTitle());
        }
    });

    //show icons for authorization
    table.addGeneratedColumn("authorization", new ColumnGenerator() {

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            @SuppressWarnings("unchecked")
            BeanItem<Todo> item = (BeanItem<Todo>) source.getItem(itemId);
            String icon;
            String text;
            switch (item.getBean().getAuthorization()) {
            case INITIAL_PERFORMER:
                icon = "auth_performer.gif";
                text = ui.getMessage("todo.authorizationPerformer");
                break;
            case DELEGATE:
                icon = "auth_delegate.gif";
                text = ui.getMessage("todo.authorizationDelegate");
                break;
            case SUBSTITUTE:
                icon = "auth_substitute.gif";
                text = ui.getMessage("todo.authorizationSubstitute");
                break;
            case NOT_PERMITTED:
            default:
                icon = "auth_unknown.gif";
                text = ui.getMessage("todo.authorizationUnknown");
                break;
            }
            Embedded authIcon = new Embedded(null, new ThemeResource("../icons/" + icon));
            authIcon.setDescription(text);

            if (item.getBean().getAllocatedTo() != null) {
                HorizontalLayout layout = new HorizontalLayout();
                layout.setSpacing(true);

                layout.addComponent(authIcon);

                Embedded lockedIcon = new Embedded(null, new ThemeResource("../icons/lock.gif"));
                lockedIcon.setDescription(
                        ui.getMessage("todo.lockedBy", item.getBean().getAllocatedToFullName()));
                layout.addComponent(lockedIcon);
                return layout;
            } else {
                return authIcon;
            }
        }
    });

    //format date
    final SimpleDateFormat df = new SimpleDateFormat(ui.getMessage("app.dateTimeFormat"));
    table.addGeneratedColumn("issuedDate", new ColumnGenerator() {

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            @SuppressWarnings("unchecked")
            BeanItem<Todo> item = (BeanItem<Todo>) source.getItem(itemId);
            return df.format(item.getBean().getIssuedDate());
        }
    });

    layout.addComponent(table);
    layout.setExpandRatio(table, 1);
}

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

License:Open Source License

/**
 * Instantiates a new chart preview layout.
 *
 * @param userChart the user chart// www . j  a va2 s . c o m
 * @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.//from  w ww .j  av  a 2s .co  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//w ww. j  a v a2  s .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.//from   ww w. j  ava2s .  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./*from  w  ww .j  av a2 s. com*/
 *
 * @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.//ww  w  .  j  av a  2 s  .  c  o m
 *
 * @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);
}