Example usage for com.vaadin.ui GridLayout addComponent

List of usage examples for com.vaadin.ui GridLayout addComponent

Introduction

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

Prototype

public void addComponent(Component component, int column1, int row1, int column2, int row2)
        throws OverlapsException, OutOfBoundsException 

Source Link

Document

Adds a component to the grid in the specified area.

Usage

From source file:org.ikasan.dashboard.ui.mappingconfiguration.window.NewClientWindow.java

License:BSD License

/**
 * Helper method to initialise this object.
 *//*w ww.  j  av a 2 s.c o  m*/
protected void init() {
    this.setStyleName("dashboard");
    this.setModal(true);
    this.setWidth(800, Unit.PIXELS);
    this.setHeight(180, Unit.PIXELS);

    PropertysetItem item = new PropertysetItem();
    item.addItemProperty(NewClientFieldGroup.NAME, new ObjectProperty<String>(""));
    item.addItemProperty(NewClientFieldGroup.KEY_LOCATION_QUERY_PROCESSOR_TYPE, new ObjectProperty<String>(
            "org.ikasan.mapping.keyQueryProcessor.impl.XPathKeyLocationQueryProcessor"));

    GridLayout form = new GridLayout(2, 4);
    form.setWidth(100, Unit.PERCENTAGE);
    form.setMargin(true);
    form.setSpacing(true);

    Label newClientLabel = new Label("New Mapping Configuration Client");
    newClientLabel.setStyleName(ValoTheme.LABEL_HUGE);
    form.addComponent(newClientLabel, 0, 0, 1, 0);

    Label nameLabel = new Label("Name:");
    nameLabel.setSizeUndefined();
    form.addComponent(nameLabel, 0, 1);
    form.setComponentAlignment(nameLabel, Alignment.MIDDLE_RIGHT);

    nameField.addValidator(new StringLengthValidator("The name must not be blank!", 1, 256, true));
    nameField.setValidationVisible(false);
    nameField.setStyleName("ikasan");
    form.addComponent(nameField, 1, 1);

    Label keyLocationLabel = new Label("Key Location Query Processor Type:");
    keyLocationLabel.setSizeUndefined();
    form.addComponent(keyLocationLabel, 0, 2);
    form.setComponentAlignment(keyLocationLabel, Alignment.MIDDLE_RIGHT);

    TextField keyLocationQueryProcessorTypeField = new TextField();
    keyLocationQueryProcessorTypeField.setStyleName("ikasan");
    keyLocationQueryProcessorTypeField.setWidth(500, Unit.PIXELS);
    form.addComponent(keyLocationQueryProcessorTypeField, 1, 2);

    final NewClientFieldGroup binder = new NewClientFieldGroup(item, this.refreshGroup,
            this.mappingConfigurationService, this.systemEventService);
    binder.bind(nameField, "name");
    binder.bind(keyLocationQueryProcessorTypeField, "keyLocationQueryProcessorType");

    keyLocationQueryProcessorTypeField.setReadOnly(true);

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

    Button saveButton = new Button("Save");
    saveButton.setStyleName(ValoTheme.BUTTON_SMALL);
    saveButton.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            try {
                nameField.validate();
            } catch (InvalidValueException e) {
                nameField.setValidationVisible(true);
                return;
            }

            try {
                binder.commit();
                UI.getCurrent().getNavigator().navigateTo("emptyPanel");

                nameField.setValue("");

                Notification.show("New Mapping Configuration Client Successfully Created!");
                saveRequiredMonitor.setSaveRequired(false);

                close();
            } catch (CommitException e) {
                Notification.show("An error has occurred saving a new client: " + e.getMessage());
            }
        }
    });
    buttons.addComponent(saveButton);

    Button cancelButton = new Button("Cancel");
    cancelButton.setStyleName(ValoTheme.BUTTON_SMALL);
    cancelButton.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            UI.getCurrent().getNavigator().navigateTo("emptyPanel");
            binder.discard();
            saveRequiredMonitor.setSaveRequired(false);

            close();
        }
    });
    buttons.addComponent(cancelButton);

    form.addComponent(buttons, 0, 3, 1, 3);
    form.setComponentAlignment(buttons, Alignment.MIDDLE_CENTER);
    this.setContent(form);
}

From source file:org.ikasan.dashboard.ui.mappingconfiguration.window.NewMappingConfigurationContextWindow.java

License:BSD License

/**
 * Helper method to initialise this object.
 *//*from   w w  w .j  a v  a 2s.  c o m*/
protected void init() {
    this.setStyleName("dashboard");
    this.setModal(true);
    this.setWidth(500, Unit.PIXELS);
    this.setHeight(250, Unit.PIXELS);

    PropertysetItem item = new PropertysetItem();
    item.addItemProperty(NewContextFieldGroup.NAME, new ObjectProperty<String>(""));
    item.addItemProperty(NewContextFieldGroup.DESCRIPTION, new ObjectProperty<String>(""));

    GridLayout form = new GridLayout(2, 4);
    form.setColumnExpandRatio(0, .15f);
    form.setColumnExpandRatio(1, .85f);
    form.setWidth(100, Unit.PERCENTAGE);
    form.setMargin(true);
    form.setSpacing(true);

    Label newTypeLabel = new Label("New Mapping Configuration Context");
    newTypeLabel.setStyleName(ValoTheme.LABEL_HUGE);
    form.addComponent(newTypeLabel, 0, 0, 1, 0);

    Label nameLabel = new Label("Name:");
    nameLabel.setSizeUndefined();
    form.addComponent(nameLabel, 0, 1);
    form.setComponentAlignment(nameLabel, Alignment.MIDDLE_RIGHT);

    nameField.setStyleName("ikasan");
    nameField.addValidator(new StringLengthValidator("The name must not be blank!", 1, 256, true));
    nameField.setValidationVisible(false);
    nameField.setWidth(70, Unit.PERCENTAGE);
    form.addComponent(nameField, 1, 1);

    Label descriptionLabel = new Label("Description:");
    descriptionLabel.setSizeUndefined();
    form.addComponent(descriptionLabel, 0, 2);
    form.setComponentAlignment(descriptionLabel, Alignment.TOP_RIGHT);

    descriptionField.setStyleName("ikasan");
    descriptionField
            .addValidator(new StringLengthValidator("The description must not be blank!", 1, 256, true));
    descriptionField.setValidationVisible(false);
    descriptionField.setWidth(90, Unit.PERCENTAGE);
    descriptionField.setRows(5);

    form.addComponent(descriptionField, 1, 2);

    final NewContextFieldGroup binder = new NewContextFieldGroup(item, this.refreshGroup,
            this.mappingConfigurationService, this.systemEventService);
    binder.bind(nameField, NewContextFieldGroup.NAME);
    binder.bind(descriptionField, NewContextFieldGroup.DESCRIPTION);

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

    Button saveButton = new Button("Save");
    saveButton.setStyleName(ValoTheme.BUTTON_SMALL);
    saveButton.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            try {
                nameField.validate();
                descriptionField.validate();
            } catch (InvalidValueException e) {
                nameField.setValidationVisible(true);
                descriptionField.setValidationVisible(true);
                return;
            }

            try {
                binder.commit();
                UI.getCurrent().getNavigator().navigateTo("emptyPanel");
                nameField.setValue("");
                descriptionField.setValue("");
                Notification.show("New Mapping Configuration Context Successfully Created!");
                saveRequiredMonitor.setSaveRequired(false);

                close();
            } catch (CommitException e) {
                Notification.show("An error occurred saving a new context! " + e.getMessage(),
                        Type.ERROR_MESSAGE);
            }
        }
    });
    buttons.addComponent(saveButton);

    Button cancelButton = new Button("Cancel");
    cancelButton.setStyleName(ValoTheme.BUTTON_SMALL);
    cancelButton.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            UI.getCurrent().getNavigator().navigateTo("emptyPanel");
            binder.discard();
            saveRequiredMonitor.setSaveRequired(false);

            close();
        }
    });
    buttons.addComponent(cancelButton);

    form.addComponent(buttons, 0, 3, 1, 3);
    form.setComponentAlignment(buttons, Alignment.MIDDLE_CENTER);

    this.setContent(form);
}

From source file:org.ikasan.dashboard.ui.mappingconfiguration.window.NewMappingConfigurationTypeWindow.java

License:BSD License

/**
 * Helper method to initialise this object.
 *///from w  w w .j a  v a 2 s . com
protected void init() {
    this.setStyleName("dashboard");
    this.setModal(true);
    this.setWidth(500, Unit.PIXELS);
    this.setHeight(180, Unit.PIXELS);

    PropertysetItem item = new PropertysetItem();
    item.addItemProperty(NewContextFieldGroup.NAME, new ObjectProperty<String>(""));

    GridLayout form = new GridLayout(2, 3);
    form.setColumnExpandRatio(0, .15f);
    form.setColumnExpandRatio(1, .85f);
    form.setWidth(100, Unit.PERCENTAGE);
    form.setMargin(true);
    form.setSpacing(true);

    Label newTypeLabel = new Label("New Mapping Configuration Type");
    newTypeLabel.setStyleName(ValoTheme.LABEL_HUGE);
    form.addComponent(newTypeLabel, 0, 0, 1, 0);

    Label nameLabel = new Label("Name:");
    nameLabel.setSizeUndefined();
    form.addComponent(nameLabel, 0, 1);
    form.setComponentAlignment(nameLabel, Alignment.MIDDLE_RIGHT);

    nameField.setStyleName("ikasan");
    nameField.addValidator(new StringLengthValidator("The name must not be blank!", 1, 256, true));
    nameField.setValidationVisible(false);
    nameField.setWidth(70, Unit.PERCENTAGE);
    form.addComponent(nameField, 1, 1);

    final NewConfigurationTypeFieldGroup binder = new NewConfigurationTypeFieldGroup(item, this.refreshGroup,
            this.mappingConfigurationService, systemEventService);
    binder.bind(nameField, NewContextFieldGroup.NAME);

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

    Button saveButton = new Button("Save");
    saveButton.setStyleName(ValoTheme.BUTTON_SMALL);
    saveButton.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            try {
                nameField.validate();
            } catch (InvalidValueException e) {
                nameField.setValidationVisible(true);
                return;
            }

            try {
                binder.commit();
                UI.getCurrent().getNavigator().navigateTo("emptyPanel");
                nameField.setValue("");
                Notification.show("New Mapping Configuration Type Successfully Created!");
                saveRequiredMonitor.setSaveRequired(false);

                close();
            } catch (CommitException e) {
                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);
                e.printStackTrace(pw);

                Notification.show("Cauget exception trying to save a new Mapping Configuration Type!",
                        sw.toString(), Notification.Type.ERROR_MESSAGE);
            }
        }
    });
    buttons.addComponent(saveButton);

    Button cancelButton = new Button("Cancel");
    cancelButton.setStyleName(ValoTheme.BUTTON_SMALL);
    cancelButton.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            UI.getCurrent().getNavigator().navigateTo("emptyPanel");
            binder.discard();
            saveRequiredMonitor.setSaveRequired(false);

            close();
        }
    });
    buttons.addComponent(cancelButton);

    form.addComponent(buttons, 0, 2, 1, 2);
    form.setComponentAlignment(buttons, Alignment.MIDDLE_CENTER);
    this.setContent(form);
}

From source file:org.ikasan.dashboard.ui.topology.window.ActionedExclusionEventViewWindow.java

License:BSD License

protected Panel createExclusionEventDetailsPanel() {
    Panel exclusionEventDetailsPanel = new Panel();
    exclusionEventDetailsPanel.setSizeFull();
    exclusionEventDetailsPanel.setStyleName("dashboard");

    GridLayout layout = new GridLayout(4, 7);
    layout.setSpacing(true);//from  w w w  .  ja  va 2  s  . c o m
    layout.setColumnExpandRatio(0, .10f);
    layout.setColumnExpandRatio(1, .30f);
    layout.setColumnExpandRatio(2, .05f);
    layout.setColumnExpandRatio(3, .30f);

    layout.setWidth("100%");

    Label exclusionEvenDetailsLabel = new Label("Actioned Exclusion Event Details");
    exclusionEvenDetailsLabel.setStyleName(ValoTheme.LABEL_HUGE);
    layout.addComponent(exclusionEvenDetailsLabel, 0, 0, 3, 0);

    Label label = new Label("Module Name:");
    label.setSizeUndefined();
    layout.addComponent(label, 0, 1);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField tf1 = new TextField();
    tf1.setValue(this.action.getModuleName());
    tf1.setReadOnly(true);
    tf1.setWidth("80%");
    layout.addComponent(tf1, 1, 1);

    label = new Label("Flow Name:");
    label.setSizeUndefined();
    layout.addComponent(label, 0, 2);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField tf2 = new TextField();
    tf2.setValue(this.action.getFlowName());
    tf2.setReadOnly(true);
    tf2.setWidth("80%");
    layout.addComponent(tf2, 1, 2);

    label = new Label("Event Id:");
    label.setSizeUndefined();
    layout.addComponent(label, 0, 3);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField tf3 = new TextField();
    tf3.setValue(this.errorOccurrence.getEventLifeIdentifier());
    tf3.setReadOnly(true);
    tf3.setWidth("80%");
    layout.addComponent(tf3, 1, 3);

    label = new Label("Date/Time:");
    label.setSizeUndefined();
    layout.addComponent(label, 0, 4);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField tf4 = new TextField();
    tf4.setValue(new Date(this.action.getTimestamp()).toString());
    tf4.setReadOnly(true);
    tf4.setWidth("80%");
    layout.addComponent(tf4, 1, 4);

    label = new Label("Error URI:");
    label.setSizeUndefined();
    layout.addComponent(label, 0, 5);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField tf5 = new TextField();
    tf5.setValue(this.action.getErrorUri());
    tf5.setReadOnly(true);
    tf5.setWidth("80%");
    layout.addComponent(tf5, 1, 5);

    label = new Label("Action:");
    label.setSizeUndefined();
    layout.addComponent(label, 2, 1);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    final TextField tf6 = new TextField();
    if (this.action != null) {
        tf6.setValue(action.getAction());
    }
    tf6.setReadOnly(true);
    tf6.setWidth("80%");
    layout.addComponent(tf6, 3, 1);

    label = new Label("Actioned By:");
    label.setSizeUndefined();
    layout.addComponent(label, 2, 2);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    final TextField tf7 = new TextField();
    if (this.action != null) {
        tf7.setValue(action.getActionedBy());
    }
    tf7.setReadOnly(true);
    tf7.setWidth("80%");
    layout.addComponent(tf7, 3, 2);

    label = new Label("Actioned Time:");
    label.setSizeUndefined();
    layout.addComponent(label, 2, 3);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    final TextField tf8 = new TextField();
    if (this.action != null) {
        tf8.setValue(new Date(action.getTimestamp()).toString());
    }
    tf8.setReadOnly(true);
    tf8.setWidth("80%");
    layout.addComponent(tf8, 3, 3);

    AceEditor eventEditor = new AceEditor();
    eventEditor.setCaption("Event Payload");

    Object event = this.serialiserFactory.getDefaultSerialiser().deserialise(this.action.getEvent());
    eventEditor.setValue(event.toString());
    eventEditor.setReadOnly(true);
    eventEditor.setMode(AceMode.java);
    eventEditor.setTheme(AceTheme.eclipse);
    eventEditor.setWidth("100%");
    eventEditor.setHeight(600, Unit.PIXELS);

    HorizontalLayout eventEditorLayout = new HorizontalLayout();
    eventEditorLayout.setSizeFull();
    eventEditorLayout.setMargin(true);
    eventEditorLayout.addComponent(eventEditor);

    AceEditor errorEditor = new AceEditor();
    errorEditor.setCaption("Error Details");
    errorEditor.setValue(this.errorOccurrence.getErrorDetail());
    errorEditor.setReadOnly(true);
    errorEditor.setMode(AceMode.xml);
    errorEditor.setTheme(AceTheme.eclipse);
    errorEditor.setWidth("100%");
    errorEditor.setHeight(600, Unit.PIXELS);

    HorizontalLayout errorEditorLayout = new HorizontalLayout();
    errorEditorLayout.setSizeFull();
    errorEditorLayout.setMargin(true);
    errorEditorLayout.addComponent(errorEditor);

    VerticalSplitPanel splitPanel = new VerticalSplitPanel();
    splitPanel.addStyleName(ValoTheme.SPLITPANEL_LARGE);
    splitPanel.setWidth("100%");
    splitPanel.setHeight(800, Unit.PIXELS);
    splitPanel.setFirstComponent(eventEditorLayout);
    splitPanel.setSecondComponent(errorEditorLayout);

    HorizontalLayout formLayout = new HorizontalLayout();
    formLayout.setWidth("100%");
    formLayout.setHeight(220, Unit.PIXELS);
    formLayout.addComponent(layout);

    GridLayout wrapperLayout = new GridLayout(1, 4);
    wrapperLayout.setMargin(true);
    wrapperLayout.setWidth("100%");
    wrapperLayout.addComponent(formLayout);
    wrapperLayout.addComponent(splitPanel);

    exclusionEventDetailsPanel.setContent(wrapperLayout);
    return exclusionEventDetailsPanel;
}

From source file:org.ikasan.dashboard.ui.topology.window.CategorisedErrorOccurrenceViewWindow.java

License:BSD License

protected Panel createErrorOccurrenceDetailsPanel() {
    Panel errorOccurrenceDetailsPanel = new Panel();

    GridLayout layout = new GridLayout(4, 7);
    layout.setWidth("100%");
    layout.setSpacing(true);/* w ww . j av a  2s .  c  om*/
    layout.setColumnExpandRatio(0, .10f);
    layout.setColumnExpandRatio(1, .30f);
    layout.setColumnExpandRatio(2, .05f);
    layout.setColumnExpandRatio(3, .30f);

    Label errorOccurrenceDetailsLabel = new Label(" Categorised Error Occurence Details", ContentMode.HTML);
    Label errorCategoryLabel = new Label();

    if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory()
            .equals(ErrorCategorisation.BLOCKER)) {
        errorOccurrenceDetailsLabel = new Label(
                VaadinIcons.BAN.getHtml() + " Categorised Error Occurence Details", ContentMode.HTML);
        errorCategoryLabel = new Label(VaadinIcons.BAN.getHtml() + " Blocker", ContentMode.HTML);
    } else if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory()
            .equals(ErrorCategorisation.CRITICAL)) {
        errorOccurrenceDetailsLabel = new Label(
                VaadinIcons.EXCLAMATION.getHtml() + " Categorised Error Occurence Details", ContentMode.HTML);
        errorCategoryLabel = new Label(VaadinIcons.EXCLAMATION.getHtml() + " Critical", ContentMode.HTML);
    } else if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory()
            .equals(ErrorCategorisation.MAJOR)) {
        errorOccurrenceDetailsLabel = new Label(
                VaadinIcons.ARROW_UP.getHtml() + " Categorised Error Occurence Details", ContentMode.HTML);
        errorCategoryLabel = new Label(VaadinIcons.ARROW_UP.getHtml() + " Major", ContentMode.HTML);
    } else if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory()
            .equals(ErrorCategorisation.TRIVIAL)) {
        errorOccurrenceDetailsLabel = new Label(
                VaadinIcons.ARROW_DOWN.getHtml() + " Categorised Error Occurence Details", ContentMode.HTML);
        errorCategoryLabel = new Label(VaadinIcons.ARROW_DOWN.getHtml() + " Trivial", ContentMode.HTML);
    }

    errorOccurrenceDetailsLabel.setStyleName(ValoTheme.LABEL_HUGE);
    layout.addComponent(errorOccurrenceDetailsLabel, 0, 0, 3, 0);

    Label label = new Label("Module Name:");
    label.setSizeUndefined();
    layout.addComponent(label, 0, 1);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField tf1 = new TextField();
    tf1.setValue(this.categorisedErrorOccurrence.getErrorOccurrence().getModuleName());
    tf1.setReadOnly(true);
    tf1.setWidth("80%");
    layout.addComponent(tf1, 1, 1);

    label = new Label("Flow Name:");
    label.setSizeUndefined();
    layout.addComponent(label, 0, 2);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField tf2 = new TextField();
    tf2.setValue(this.categorisedErrorOccurrence.getErrorOccurrence().getFlowName());
    tf2.setReadOnly(true);
    tf2.setWidth("80%");
    layout.addComponent(tf2, 1, 2);

    label = new Label("Component Name:");
    label.setSizeUndefined();
    layout.addComponent(label, 0, 3);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField tf3 = new TextField();
    tf3.setValue(this.categorisedErrorOccurrence.getErrorOccurrence().getFlowElementName());
    tf3.setReadOnly(true);
    tf3.setWidth("80%");
    layout.addComponent(tf3, 1, 3);

    label = new Label("Date/Time:");
    label.setSizeUndefined();
    layout.addComponent(label, 0, 4);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField tf4 = new TextField();
    tf4.setValue(new Date(this.categorisedErrorOccurrence.getErrorOccurrence().getTimestamp()).toString());
    tf4.setReadOnly(true);
    tf4.setWidth("80%");
    layout.addComponent(tf4, 1, 4);

    GridLayout wrapperLayout = new GridLayout(1, 4);
    wrapperLayout.setMargin(true);
    wrapperLayout.setWidth("100%");

    Label errorMessageLabel = new Label("Error Message:");
    errorMessageLabel.setSizeUndefined();
    layout.addComponent(errorMessageLabel, 0, 5);
    layout.setComponentAlignment(errorMessageLabel, Alignment.TOP_RIGHT);

    final TextArea errorMessageTextArea = new TextArea();
    errorMessageTextArea.setWidth("650px");
    errorMessageTextArea.setRows(6);
    errorMessageTextArea
            .setValue(this.categorisedErrorOccurrence.getErrorCategorisation().getErrorDescription());

    layout.addComponent(errorMessageTextArea, 1, 5, 3, 5);

    AceEditor editor = new AceEditor();
    editor.setCaption("Error Details");
    editor.setValue(this.categorisedErrorOccurrence.getErrorOccurrence().getErrorDetail());
    editor.setReadOnly(true);
    editor.setMode(AceMode.xml);
    editor.setTheme(AceTheme.eclipse);
    editor.setHeight(470, Unit.PIXELS);
    editor.setWidth("100%");

    label = new Label("Error Category:");
    label.setSizeUndefined();
    layout.addComponent(label, 2, 1);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    layout.addComponent(errorCategoryLabel, 3, 1);
    layout.setComponentAlignment(errorCategoryLabel, Alignment.MIDDLE_LEFT);

    label = new Label("System Action:");
    label.setSizeUndefined();
    layout.addComponent(label, 2, 2);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField systemAction = new TextField();
    systemAction.setValue(this.categorisedErrorOccurrence.getErrorOccurrence().getAction());
    systemAction.setReadOnly(true);
    systemAction.setWidth("80%");
    layout.addComponent(systemAction, 3, 2);

    label = new Label("User Action:");
    label.setSizeUndefined();
    layout.addComponent(label, 2, 3);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField userAction = new TextField();
    userAction.setValue("");
    userAction.setReadOnly(true);
    userAction.setWidth("80%");
    layout.addComponent(userAction, 3, 3);

    label = new Label("User Action By:");
    label.setSizeUndefined();
    layout.addComponent(label, 2, 4);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    Label userActionBy = new Label();
    userActionBy.setValue("");
    userActionBy.setReadOnly(true);
    userActionBy.setWidth("80%");
    layout.addComponent(userActionBy, 3, 4);

    AceEditor eventEditor = new AceEditor();
    eventEditor.setCaption("Event Payload");

    if (this.categorisedErrorOccurrence.getErrorOccurrence().getEvent() != null) {
        eventEditor
                .setValue(new String((byte[]) this.categorisedErrorOccurrence.getErrorOccurrence().getEvent()));
    }

    eventEditor.setReadOnly(true);
    eventEditor.setMode(AceMode.java);
    eventEditor.setTheme(AceTheme.eclipse);
    eventEditor.setHeight(470, Unit.PIXELS);
    eventEditor.setWidth("100%");

    HorizontalLayout formLayout = new HorizontalLayout();
    formLayout.setWidth("100%");
    formLayout.setHeight(300, Unit.PIXELS);
    formLayout.addComponent(layout);
    wrapperLayout.addComponent(formLayout, 0, 0);

    //      VerticalSplitPanel vSplitPanel = new VerticalSplitPanel();
    //      vSplitPanel.setWidth("100%");
    //      vSplitPanel.setHeight(800, Unit.PIXELS);
    //      vSplitPanel.addStyleName(ValoTheme.SPLITPANEL_LARGE);

    TabSheet tabsheet = new TabSheet();
    tabsheet.setSizeFull();

    HorizontalLayout h1 = new HorizontalLayout();
    h1.setSizeFull();
    h1.setMargin(true);
    h1.addComponent(eventEditor);
    //      vSplitPanel.setFirstComponent(h1);

    HorizontalLayout h2 = new HorizontalLayout();
    h2.setSizeFull();
    h2.setMargin(true);
    h2.addComponent(editor);
    //      vSplitPanel.setSecondComponent(h2);

    tabsheet.addTab(h2, "Error Details");
    tabsheet.addTab(h1, "Event Payload");

    wrapperLayout.addComponent(tabsheet, 0, 1);

    //      wrapperLayout.addComponent(vSplitPanel, 0, 1);

    errorOccurrenceDetailsPanel.setContent(wrapperLayout);
    return errorOccurrenceDetailsPanel;
}

From source file:org.ikasan.dashboard.ui.topology.window.ComponentConfigurationWindow.java

License:BSD License

protected Panel createTextAreaPanel(ConfigurationParameter parameter, Validator validator) {
    Panel paramPanel = new Panel();
    paramPanel.setStyleName("dashboard");
    paramPanel.setWidth("100%");

    GridLayout paramLayout = new GridLayout(2, 3);
    paramLayout.setSpacing(true);/*ww w  . ja v  a 2s .c  o m*/
    paramLayout.setSizeFull();
    paramLayout.setMargin(true);
    paramLayout.setColumnExpandRatio(0, .25f);
    paramLayout.setColumnExpandRatio(1, .75f);

    Label label = new Label(parameter.getName());
    label.setIcon(VaadinIcons.COG);
    label.addStyleName(ValoTheme.LABEL_LARGE);
    label.addStyleName(ValoTheme.LABEL_BOLD);
    label.setSizeUndefined();
    paramLayout.addComponent(label, 0, 0, 1, 0);
    paramLayout.setComponentAlignment(label, Alignment.TOP_LEFT);

    logger.info(parameter.getName() + " " + parameter.getValue());
    Label valueLabel = new Label("Value:");
    valueLabel.setSizeUndefined();
    TextArea textField = new TextArea();
    textField.addValidator(validator);
    textField.setNullSettingAllowed(true);
    textField.setNullRepresentation("");
    textField.setValidationVisible(false);
    textField.setRows(4);
    textField.setWidth("80%");
    textField.setId(parameter.getName());

    if (parameter instanceof ConfigurationParameterIntegerImpl) {
        StringToIntegerConverter plainIntegerConverter = new StringToIntegerConverter() {
            protected java.text.NumberFormat getFormat(Locale locale) {
                NumberFormat format = super.getFormat(locale);
                format.setGroupingUsed(false);
                return format;
            };
        };

        // either set for the field or in your field factory for multiple fields
        textField.setConverter(plainIntegerConverter);
    } else if (parameter instanceof ConfigurationParameterLongImpl) {
        StringToLongConverter plainLongConverter = new StringToLongConverter() {
            protected java.text.NumberFormat getFormat(Locale locale) {
                NumberFormat format = super.getFormat(locale);
                format.setGroupingUsed(false);
                return format;
            };
        };

        // either set for the field or in your field factory for multiple fields
        textField.setConverter(plainLongConverter);
    }

    textFields.put(parameter.getName(), textField);

    BeanItem<ConfigurationParameter> parameterItem = new BeanItem<ConfigurationParameter>(parameter);

    if (parameter.getValue() != null) {
        textField.setPropertyDataSource(parameterItem.getItemProperty("value"));
    }

    paramLayout.addComponent(valueLabel, 0, 1);
    paramLayout.addComponent(textField, 1, 1);
    paramLayout.setComponentAlignment(valueLabel, Alignment.TOP_RIGHT);

    Label paramDescriptionLabel = new Label("Description:");
    paramDescriptionLabel.setSizeUndefined();
    TextArea descriptionTextField = new TextArea();
    descriptionTextField.setRows(4);
    descriptionTextField.setWidth("80%");
    descriptionTextField.setId(parameter.getName());

    paramLayout.addComponent(paramDescriptionLabel, 0, 2);
    paramLayout.addComponent(descriptionTextField, 1, 2);
    paramLayout.setComponentAlignment(paramDescriptionLabel, Alignment.TOP_RIGHT);

    descriptionTextFields.put(parameter.getName(), descriptionTextField);

    if (parameter.getDescription() != null) {
        descriptionTextField.setValue(parameter.getDescription());
    }

    paramPanel.setContent(paramLayout);

    return paramPanel;
}

From source file:org.ikasan.dashboard.ui.topology.window.ComponentConfigurationWindow.java

License:BSD License

protected Panel createMapPanel(final ConfigurationParameterMapImpl parameter) {
    Panel paramPanel = new Panel();
    paramPanel.setStyleName("dashboard");
    paramPanel.setWidth("100%");

    GridLayout paramLayout = new GridLayout(2, 3);
    paramLayout.setSpacing(true);// www .  j av a 2  s . c  o  m
    paramLayout.setSizeFull();
    paramLayout.setMargin(true);
    paramLayout.setColumnExpandRatio(0, .25f);
    paramLayout.setColumnExpandRatio(1, .75f);

    Label label = new Label(parameter.getName());
    label.setIcon(VaadinIcons.COG);
    label.addStyleName(ValoTheme.LABEL_LARGE);
    label.addStyleName(ValoTheme.LABEL_BOLD);
    label.setSizeUndefined();
    paramLayout.addComponent(label, 0, 0, 1, 0);
    paramLayout.setComponentAlignment(label, Alignment.TOP_LEFT);

    final Map<String, String> valueMap = parameter.getValue();

    final GridLayout mapLayout = new GridLayout(5, (valueMap.size() != 0 ? valueMap.size() : 1) + 1);
    mapLayout.setMargin(true);
    mapLayout.setSpacing(true);

    int i = 0;

    for (final String key : valueMap.keySet()) {
        final Label keyLabel = new Label("Key");
        final Label valueLabel = new Label("Value");

        final TextField keyField = new TextField();
        keyField.setValue(key);

        final TextField valueField = new TextField();
        valueField.setValue(valueMap.get(key));

        mapLayout.addComponent(keyLabel, 0, i);
        mapLayout.addComponent(keyField, 1, i);
        mapLayout.addComponent(valueLabel, 2, i);
        mapLayout.addComponent(valueField, 3, i);
        final String mapKey = parameter.getName() + i;
        TextFieldKeyValuePair pair = new TextFieldKeyValuePair();
        pair.key = keyField;
        pair.value = valueField;

        this.mapTextFields.put(mapKey, pair);

        final Button removeButton = new Button("remove");
        removeButton.setStyleName(ValoTheme.BUTTON_LINK);
        removeButton.addClickListener(new Button.ClickListener() {
            public void buttonClick(ClickEvent event) {
                valueMap.remove(key);
                mapLayout.removeComponent(keyLabel);
                mapLayout.removeComponent(valueLabel);
                mapLayout.removeComponent(keyField);
                mapLayout.removeComponent(valueField);
                mapLayout.removeComponent(removeButton);

                mapTextFields.remove(mapKey);
            }
        });

        mapLayout.addComponent(removeButton, 4, i);

        i++;
    }

    final Button addButton = new Button("add");
    addButton.setStyleName(ValoTheme.BUTTON_LINK);
    addButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            final Label keyLabel = new Label("Key");
            final Label valueLabel = new Label("Value");

            final TextField keyField = new TextField();

            final TextField valueField = new TextField();

            mapLayout.insertRow(mapLayout.getRows());

            mapLayout.removeComponent(addButton);
            mapLayout.addComponent(keyLabel, 0, mapLayout.getRows() - 2);
            mapLayout.addComponent(keyField, 1, mapLayout.getRows() - 2);
            mapLayout.addComponent(valueLabel, 2, mapLayout.getRows() - 2);
            mapLayout.addComponent(valueField, 3, mapLayout.getRows() - 2);

            final String mapKey = parameter.getName() + mapTextFields.size();
            TextFieldKeyValuePair pair = new TextFieldKeyValuePair();
            pair.key = keyField;
            pair.value = valueField;

            mapTextFields.put(mapKey, pair);

            final Button removeButton = new Button("remove");
            removeButton.setStyleName(ValoTheme.BUTTON_LINK);
            removeButton.addClickListener(new Button.ClickListener() {
                public void buttonClick(ClickEvent event) {
                    mapLayout.removeComponent(keyLabel);
                    mapLayout.removeComponent(valueLabel);
                    mapLayout.removeComponent(keyField);
                    mapLayout.removeComponent(valueField);

                    mapLayout.removeComponent(removeButton);

                    mapTextFields.remove(mapKey);
                }
            });

            mapLayout.addComponent(removeButton, 4, mapLayout.getRows() - 2);

            mapLayout.addComponent(addButton, 0, mapLayout.getRows() - 1);
        }
    });

    mapLayout.addComponent(addButton, 0, mapLayout.getRows() - 1);

    Panel mapPanel = new Panel();
    mapPanel.setStyleName("dashboard");
    mapPanel.setContent(mapLayout);

    paramLayout.addComponent(mapPanel, 0, 1, 1, 1);
    paramLayout.setComponentAlignment(mapPanel, Alignment.TOP_CENTER);
    paramPanel.setContent(paramLayout);

    Label paramDescriptionLabel = new Label("Description:");
    paramDescriptionLabel.setSizeUndefined();
    TextArea descriptionTextField = new TextArea();
    descriptionTextField.setRows(4);
    descriptionTextField.setWidth("80%");
    descriptionTextField.setId(parameter.getName());

    paramLayout.addComponent(paramDescriptionLabel, 0, 2);
    paramLayout.addComponent(descriptionTextField, 1, 2);
    paramLayout.setComponentAlignment(paramDescriptionLabel, Alignment.TOP_RIGHT);

    descriptionTextFields.put(parameter.getName(), descriptionTextField);

    if (parameter.getDescription() != null) {
        descriptionTextField.setValue(parameter.getDescription());
    }

    return paramPanel;
}

From source file:org.ikasan.dashboard.ui.topology.window.ComponentConfigurationWindow.java

License:BSD License

protected Panel createListPanel(final ConfigurationParameterListImpl parameter) {
    Panel paramPanel = new Panel();
    paramPanel.setStyleName("dashboard");
    paramPanel.setWidth("100%");

    GridLayout paramLayout = new GridLayout(2, 3);
    paramLayout.setSpacing(true);/*ww w.j  ava  2 s  .c om*/
    paramLayout.setSizeFull();
    paramLayout.setMargin(true);
    paramLayout.setColumnExpandRatio(0, .25f);
    paramLayout.setColumnExpandRatio(1, .75f);

    Label label = new Label(parameter.getName());
    label.setIcon(VaadinIcons.COG);
    label.addStyleName(ValoTheme.LABEL_LARGE);
    label.addStyleName(ValoTheme.LABEL_BOLD);
    label.setSizeUndefined();
    paramLayout.addComponent(label, 0, 0, 1, 0);
    paramLayout.setComponentAlignment(label, Alignment.TOP_LEFT);

    final List<String> valueList = parameter.getValue();

    final GridLayout listLayout = new GridLayout(3, (valueList.size() != 0 ? valueList.size() : 1) + 1);
    listLayout.setWidth("450px");
    listLayout.setMargin(true);
    listLayout.setSpacing(true);

    listLayout.setColumnExpandRatio(0, 0.25f);
    listLayout.setColumnExpandRatio(1, 0.5f);
    listLayout.setColumnExpandRatio(2, 0.25f);

    int i = 0;

    for (final String value : valueList) {
        final Label valueLabel = new Label("Value");

        final TextField valueField = new TextField();
        valueField.setValue(value);
        valueField.setWidth("90%");

        listLayout.addComponent(valueLabel, 0, i);
        listLayout.addComponent(valueField, 1, i);

        final String mapKey = parameter.getName() + i;

        this.valueTextFields.put(mapKey, valueField);

        final Button removeButton = new Button("remove");
        removeButton.setStyleName(ValoTheme.BUTTON_LINK);
        removeButton.addClickListener(new Button.ClickListener() {
            public void buttonClick(ClickEvent event) {
                valueList.remove(value);
                listLayout.removeComponent(valueLabel);
                listLayout.removeComponent(valueField);
                listLayout.removeComponent(removeButton);

                valueTextFields.remove(mapKey);
            }
        });

        listLayout.addComponent(removeButton, 2, i);

        i++;
    }

    final Button addButton = new Button("add");
    addButton.setStyleName(ValoTheme.BUTTON_LINK);
    addButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            final Label valueLabel = new Label("Value");

            final TextField valueField = new TextField();
            valueField.setWidth("90%");

            listLayout.insertRow(listLayout.getRows());

            listLayout.removeComponent(addButton);
            listLayout.addComponent(valueLabel, 0, listLayout.getRows() - 2);
            listLayout.addComponent(valueField, 1, listLayout.getRows() - 2);

            final String mapKey = parameter.getName() + valueTextFields.size();

            valueTextFields.put(mapKey, valueField);

            final Button removeButton = new Button("remove");
            removeButton.setStyleName(ValoTheme.BUTTON_LINK);
            removeButton.addClickListener(new Button.ClickListener() {
                public void buttonClick(ClickEvent event) {
                    listLayout.removeComponent(valueLabel);
                    listLayout.removeComponent(valueField);

                    listLayout.removeComponent(removeButton);

                    valueTextFields.remove(mapKey);
                }
            });

            listLayout.addComponent(removeButton, 2, listLayout.getRows() - 2);

            listLayout.addComponent(addButton, 0, listLayout.getRows() - 1);
        }
    });

    listLayout.addComponent(addButton, 0, listLayout.getRows() - 1);

    Panel mapPanel = new Panel();
    mapPanel.setStyleName("dashboard");
    mapPanel.setContent(listLayout);

    paramLayout.addComponent(mapPanel, 0, 1, 1, 1);
    paramLayout.setComponentAlignment(mapPanel, Alignment.TOP_CENTER);
    paramPanel.setContent(paramLayout);

    Label paramDescriptionLabel = new Label("Description:");
    paramDescriptionLabel.setSizeUndefined();
    TextArea descriptionTextField = new TextArea();
    descriptionTextField.setRows(4);
    descriptionTextField.setWidth("80%");
    descriptionTextField.setId(parameter.getName());

    paramLayout.addComponent(paramDescriptionLabel, 0, 2);
    paramLayout.addComponent(descriptionTextField, 1, 2);
    paramLayout.setComponentAlignment(paramDescriptionLabel, Alignment.TOP_RIGHT);

    descriptionTextFields.put(parameter.getName(), descriptionTextField);

    if (parameter.getDescription() != null) {
        descriptionTextField.setValue(parameter.getDescription());
    }

    return paramPanel;
}

From source file:org.ikasan.dashboard.ui.topology.window.ExclusionEventViewWindow.java

License:BSD License

protected Panel createExclusionEventDetailsPanel() {
    Panel exclusionEventDetailsPanel = new Panel();
    exclusionEventDetailsPanel.setSizeFull();
    exclusionEventDetailsPanel.setStyleName("dashboard");

    GridLayout layout = new GridLayout(4, 7);
    layout.setSpacing(true);//from w  w  w.j  a va 2s  . c  o m
    layout.setColumnExpandRatio(0, .10f);
    layout.setColumnExpandRatio(1, .30f);
    layout.setColumnExpandRatio(2, .05f);
    layout.setColumnExpandRatio(3, .30f);

    layout.setWidth("100%");

    Label exclusionEvenDetailsLabel = new Label("Exclusion Event Details");
    exclusionEvenDetailsLabel.setStyleName(ValoTheme.LABEL_HUGE);
    layout.addComponent(exclusionEvenDetailsLabel, 0, 0, 3, 0);

    Label label = new Label("Module Name:");
    label.setSizeUndefined();
    layout.addComponent(label, 0, 1);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField tf1 = new TextField();
    tf1.setValue(this.exclusionEvent.getModuleName());
    tf1.setReadOnly(true);
    tf1.setWidth("80%");
    layout.addComponent(tf1, 1, 1);

    label = new Label("Flow Name:");
    label.setSizeUndefined();
    layout.addComponent(label, 0, 2);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField tf2 = new TextField();
    tf2.setValue(this.exclusionEvent.getFlowName());
    tf2.setReadOnly(true);
    tf2.setWidth("80%");
    layout.addComponent(tf2, 1, 2);

    label = new Label("Event Id:");
    label.setSizeUndefined();
    layout.addComponent(label, 0, 3);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField tf3 = new TextField();
    tf3.setValue(this.errorOccurrence.getEventLifeIdentifier());
    tf3.setReadOnly(true);
    tf3.setWidth("80%");
    layout.addComponent(tf3, 1, 3);

    label = new Label("Date/Time:");
    label.setSizeUndefined();
    layout.addComponent(label, 0, 4);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField tf4 = new TextField();
    tf4.setValue(new Date(this.exclusionEvent.getTimestamp()).toString());
    tf4.setReadOnly(true);
    tf4.setWidth("80%");
    layout.addComponent(tf4, 1, 4);

    label = new Label("Error URI:");
    label.setSizeUndefined();
    layout.addComponent(label, 0, 5);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField tf5 = new TextField();
    tf5.setValue(exclusionEvent.getErrorUri());
    tf5.setReadOnly(true);
    tf5.setWidth("80%");
    layout.addComponent(tf5, 1, 5);

    label = new Label("Action:");
    label.setSizeUndefined();
    layout.addComponent(label, 2, 1);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    final TextField tf6 = new TextField();
    if (this.action != null) {
        tf6.setValue(action.getAction());
    }
    tf6.setReadOnly(true);
    tf6.setWidth("80%");
    layout.addComponent(tf6, 3, 1);

    label = new Label("Actioned By:");
    label.setSizeUndefined();
    layout.addComponent(label, 2, 2);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    final TextField tf7 = new TextField();
    if (this.action != null) {
        tf7.setValue(action.getActionedBy());
    }
    tf7.setReadOnly(true);
    tf7.setWidth("80%");
    layout.addComponent(tf7, 3, 2);

    label = new Label("Actioned Time:");
    label.setSizeUndefined();
    layout.addComponent(label, 2, 3);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    final TextField tf8 = new TextField();
    if (this.action != null) {
        tf8.setValue(new Date(action.getTimestamp()).toString());
    }
    tf8.setReadOnly(true);
    tf8.setWidth("80%");
    layout.addComponent(tf8, 3, 3);

    final Button resubmitButton = new Button("Re-submit");
    final Button ignoreButton = new Button("Ignore");

    resubmitButton.addClickListener(new Button.ClickListener() {
        @SuppressWarnings("unchecked")
        public void buttonClick(ClickEvent event) {
            IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest()
                    .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER);

            HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic(authentication.getName(),
                    (String) authentication.getCredentials());

            ClientConfig clientConfig = new ClientConfig();
            clientConfig.register(feature);

            Client client = ClientBuilder.newClient(clientConfig);

            Module module = topologyService.getModuleByName(exclusionEvent.getModuleName());

            if (module == null) {
                Notification
                        .show("Unable to find server information for module we are attempting to re-submit to: "
                                + exclusionEvent.getModuleName(), Type.ERROR_MESSAGE);

                return;
            }

            Server server = module.getServer();

            String url = "http://" + server.getUrl() + ":" + server.getPort() + module.getContextRoot()
                    + "/rest/resubmission/resubmit/" + exclusionEvent.getModuleName() + "/"
                    + exclusionEvent.getFlowName() + "/" + exclusionEvent.getErrorUri();

            logger.info("Resubmission Url: " + url);

            WebTarget webTarget = client.target(url);
            Response response = webTarget.request()
                    .put(Entity.entity(exclusionEvent.getEvent(), MediaType.APPLICATION_OCTET_STREAM));

            if (response.getStatus() != 200) {
                response.bufferEntity();

                String responseMessage = response.readEntity(String.class);
                Notification.show("An error was received trying to resubmit event: " + responseMessage,
                        Type.ERROR_MESSAGE);
            } else {
                Notification.show("Event resumitted successfully.");
                resubmitButton.setVisible(false);
                ignoreButton.setVisible(false);

                ExclusionEventAction action = hospitalManagementService
                        .getExclusionEventActionByErrorUri(exclusionEvent.getErrorUri());
                tf6.setReadOnly(false);
                tf7.setReadOnly(false);
                tf8.setReadOnly(false);
                tf6.setValue(action.getAction());
                tf7.setValue(action.getActionedBy());
                tf8.setValue(new Date(action.getTimestamp()).toString());
                tf6.setReadOnly(true);
                tf7.setReadOnly(true);
                tf8.setReadOnly(true);
            }
        }
    });

    ignoreButton.addClickListener(new Button.ClickListener() {
        @SuppressWarnings("unchecked")
        public void buttonClick(ClickEvent event) {
            IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest()
                    .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER);

            HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic(authentication.getName(),
                    (String) authentication.getCredentials());

            ClientConfig clientConfig = new ClientConfig();
            clientConfig.register(feature);

            Client client = ClientBuilder.newClient(clientConfig);

            Module module = topologyService.getModuleByName(exclusionEvent.getModuleName());

            if (module == null) {
                Notification
                        .show("Unable to find server information for module we are submitting the ignore to: "
                                + exclusionEvent.getModuleName(), Type.ERROR_MESSAGE);

                return;
            }

            Server server = module.getServer();

            String url = "http://" + server.getUrl() + ":" + server.getPort() + module.getContextRoot()
                    + "/rest/resubmission/ignore/" + exclusionEvent.getModuleName() + "/"
                    + exclusionEvent.getFlowName() + "/" + exclusionEvent.getErrorUri();

            logger.info("Ignore Url: " + url);

            WebTarget webTarget = client.target(url);
            Response response = webTarget.request()
                    .put(Entity.entity(exclusionEvent.getEvent(), MediaType.APPLICATION_OCTET_STREAM));

            if (response.getStatus() != 200) {
                response.bufferEntity();

                String responseMessage = response.readEntity(String.class);
                Notification.show("An error was received trying to resubmit event: " + responseMessage,
                        Type.ERROR_MESSAGE);
            } else {
                Notification.show("Event ignored successfully.");
                resubmitButton.setVisible(false);
                ignoreButton.setVisible(false);

                ExclusionEventAction action = hospitalManagementService
                        .getExclusionEventActionByErrorUri(exclusionEvent.getErrorUri());
                tf6.setReadOnly(false);
                tf7.setReadOnly(false);
                tf8.setReadOnly(false);
                tf6.setValue(action.getAction());
                tf7.setValue(action.getActionedBy());
                tf8.setValue(new Date(action.getTimestamp()).toString());
                tf6.setReadOnly(true);
                tf7.setReadOnly(true);
                tf8.setReadOnly(true);
            }
        }
    });

    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setHeight("100%");
    buttonLayout.setSpacing(true);
    buttonLayout.setWidth(200, Unit.PIXELS);
    buttonLayout.setMargin(true);
    buttonLayout.addComponent(resubmitButton);
    buttonLayout.addComponent(ignoreButton);

    if (this.action == null) {
        layout.addComponent(buttonLayout, 0, 6, 3, 6);
        layout.setComponentAlignment(buttonLayout, Alignment.MIDDLE_CENTER);
    }

    final IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest()
            .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER);

    if (authentication != null && (!authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY)
            && !authentication.hasGrantedAuthority(SecurityConstants.ACTION_EXCLUSIONS_AUTHORITY))) {
        resubmitButton.setVisible(false);
        ignoreButton.setVisible(false);
    }

    AceEditor eventEditor = new AceEditor();
    eventEditor.setCaption("Event Payload");
    logger.info("Setting exclusion event to: " + new String(this.exclusionEvent.getEvent()));
    Object event = this.serialiserFactory.getDefaultSerialiser().deserialise(this.exclusionEvent.getEvent());
    eventEditor.setValue(event.toString());
    eventEditor.setReadOnly(true);
    eventEditor.setMode(AceMode.java);
    eventEditor.setTheme(AceTheme.eclipse);
    eventEditor.setWidth("100%");
    eventEditor.setHeight(600, Unit.PIXELS);

    HorizontalLayout eventEditorLayout = new HorizontalLayout();
    eventEditorLayout.setSizeFull();
    eventEditorLayout.setMargin(true);
    eventEditorLayout.addComponent(eventEditor);

    AceEditor errorEditor = new AceEditor();
    errorEditor.setCaption("Error Details");
    errorEditor.setValue(this.errorOccurrence.getErrorDetail());
    errorEditor.setReadOnly(true);
    errorEditor.setMode(AceMode.xml);
    errorEditor.setTheme(AceTheme.eclipse);
    errorEditor.setWidth("100%");
    errorEditor.setHeight(600, Unit.PIXELS);

    HorizontalLayout errorEditorLayout = new HorizontalLayout();
    errorEditorLayout.setSizeFull();
    errorEditorLayout.setMargin(true);
    errorEditorLayout.addComponent(errorEditor);

    VerticalSplitPanel splitPanel = new VerticalSplitPanel();
    splitPanel.addStyleName(ValoTheme.SPLITPANEL_LARGE);
    splitPanel.setWidth("100%");
    splitPanel.setHeight(800, Unit.PIXELS);

    HorizontalLayout h1 = new HorizontalLayout();
    h1.setSizeFull();
    h1.setMargin(true);
    h1.addComponent(eventEditorLayout);
    splitPanel.setFirstComponent(eventEditorLayout);

    HorizontalLayout h2 = new HorizontalLayout();
    h2.setSizeFull();
    h2.setMargin(true);
    h2.addComponent(errorEditorLayout);
    splitPanel.setSecondComponent(errorEditorLayout);

    HorizontalLayout formLayout = new HorizontalLayout();
    formLayout.setWidth("100%");
    formLayout.setHeight(240, Unit.PIXELS);
    formLayout.addComponent(layout);

    GridLayout wrapperLayout = new GridLayout(1, 4);
    wrapperLayout.setMargin(true);
    wrapperLayout.setWidth("100%");
    wrapperLayout.addComponent(formLayout);
    wrapperLayout.addComponent(splitPanel);

    exclusionEventDetailsPanel.setContent(wrapperLayout);
    return exclusionEventDetailsPanel;
}

From source file:org.ikasan.dashboard.ui.topology.window.NewBusinessStreamWindow.java

License:BSD License

public void init() {
    this.setModal(true);
    this.setResizable(false);

    GridLayout gridLayout = new GridLayout(2, 4);
    gridLayout.setWidth("480px");
    gridLayout.setColumnExpandRatio(0, .15f);
    gridLayout.setColumnExpandRatio(1, .85f);

    gridLayout.setSpacing(true);/* w w  w.jav  a2  s .  c o  m*/
    gridLayout.setMargin(true);

    Label newBusinessStreamLabel = new Label("New Business Steam");
    Label nameLabel = new Label("Name:");
    newBusinessStreamLabel.addStyleName(ValoTheme.LABEL_HUGE);

    gridLayout.addComponent(newBusinessStreamLabel, 0, 0, 1, 0);

    nameLabel.setSizeUndefined();
    this.roleName = new TextField();
    this.roleName.addValidator(new StringLengthValidator("A name must be entered.", 1, null, false));
    this.roleName.setWidth("90%");

    gridLayout.addComponent(nameLabel, 0, 1);
    gridLayout.setComponentAlignment(nameLabel, Alignment.MIDDLE_RIGHT);
    gridLayout.addComponent(roleName, 1, 1);

    Label descriptionLabel = new Label("Description:");
    descriptionLabel.setSizeUndefined();
    this.roleDescription = new TextArea();
    this.roleDescription
            .addValidator(new StringLengthValidator("A description must be entered.", 1, null, false));
    this.roleDescription.setWidth("90%");
    this.roleDescription.setRows(4);

    this.roleName.setValidationVisible(false);
    this.roleDescription.setValidationVisible(false);

    gridLayout.addComponent(descriptionLabel, 0, 2);
    gridLayout.setComponentAlignment(descriptionLabel, Alignment.MIDDLE_RIGHT);
    gridLayout.addComponent(roleDescription, 1, 2);

    Button createButton = new Button("Create");
    Button cancelButton = new Button("Cancel");

    GridLayout buttonLayout = new GridLayout(2, 1);
    buttonLayout.setSpacing(true);

    buttonLayout.addComponent(createButton);
    buttonLayout.setComponentAlignment(createButton, Alignment.MIDDLE_CENTER);
    buttonLayout.addComponent(cancelButton);
    buttonLayout.setComponentAlignment(cancelButton, Alignment.MIDDLE_CENTER);

    gridLayout.addComponent(buttonLayout, 0, 3, 1, 3);
    gridLayout.setComponentAlignment(buttonLayout, Alignment.MIDDLE_CENTER);

    BeanItem<BusinessStream> policyItem = new BeanItem<BusinessStream>(this.businessStream);

    roleName.setPropertyDataSource(policyItem.getItemProperty("name"));
    roleDescription.setPropertyDataSource(policyItem.getItemProperty("description"));
    this.businessStream.setFlows(new HashSet<BusinessStreamFlow>());

    createButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            try {
                NewBusinessStreamWindow.this.roleName.validate();
                NewBusinessStreamWindow.this.roleDescription.validate();
            } catch (InvalidValueException e) {
                NewBusinessStreamWindow.this.roleName.setValidationVisible(true);
                NewBusinessStreamWindow.this.roleDescription.setValidationVisible(true);

                return;
            }

            NewBusinessStreamWindow.this.roleName.setValidationVisible(false);
            NewBusinessStreamWindow.this.roleDescription.setValidationVisible(false);

            UI.getCurrent().removeWindow(NewBusinessStreamWindow.this);
        }
    });

    cancelButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            UI.getCurrent().removeWindow(NewBusinessStreamWindow.this);
        }
    });

    this.setContent(gridLayout);
}