Example usage for com.vaadin.ui VerticalLayout setComponentAlignment

List of usage examples for com.vaadin.ui VerticalLayout setComponentAlignment

Introduction

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

Prototype

@Override
    public void setComponentAlignment(Component childComponent, Alignment alignment) 

Source Link

Usage

From source file:org.opennms.features.vaadin.datacollection.IncludeCollectionField.java

License:Open Source License

@Override
public Component initContent() {
    VerticalLayout layout = new VerticalLayout();
    layout.addComponent(table);/*  w  ww . j  av a2  s.co  m*/
    layout.addComponent(toolbar);
    layout.setComponentAlignment(toolbar, Alignment.MIDDLE_RIGHT);
    return layout;
}

From source file:org.opennms.features.vaadin.datacollection.IncludeCollectionWindow.java

License:Open Source License

/**
 * Instantiates a new include collection window.
 * //from w  ww.j av a2s .  c  om
 * @param dataCollectionConfigDao the data collection configuration DAO
 * @param container the source list of elements
 * @param wrapper the current selected value
 */
public IncludeCollectionWindow(final DataCollectionConfigDao dataCollectionConfigDao,
        final OnmsBeanContainer<IncludeCollectionWrapper> container, final IncludeCollectionWrapper wrapper) {

    setCaption("Include SystemDef/DataCollectionGroup");
    setModal(true);
    setWidth("400px");
    setHeight("2000px");
    setResizable(false);
    setClosable(false);
    addStyleName("dialog");

    final ComboBox valueField = new ComboBox("Value");
    valueField.setEnabled(false);
    valueField.setRequired(true);
    valueField.setImmediate(true);
    valueField.setNewItemsAllowed(false);
    valueField.setNullSelectionAllowed(false);

    final ComboBox typeField = new ComboBox("Type");
    typeField.setRequired(true);
    typeField.setImmediate(true);
    typeField.setNewItemsAllowed(false);
    typeField.setNullSelectionAllowed(false);
    typeField.addItem(IncludeCollectionWrapper.DC_GROUP);
    typeField.addItem(IncludeCollectionWrapper.SYSTEM_DEF);
    typeField.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            String selected = (String) typeField.getValue();
            if (selected == null) {
                return;
            }
            // Get available fields.
            // FIXME If a new dcGroup is added, DataCollectionConfigDao is not able to reach it.
            List<String> values = selected.equals(IncludeCollectionWrapper.SYSTEM_DEF)
                    ? dataCollectionConfigDao.getAvailableSystemDefs()
                    : dataCollectionConfigDao.getAvailableDataCollectionGroups();
            // Remove already selected
            for (IncludeCollectionWrapper obj : container.getOnmsBeans()) {
                if (obj.getType().equals(selected)) {
                    values.remove(obj.getValue());
                }
            }
            // Updating combo-box
            valueField.removeAllItems();
            for (String v : values) {
                valueField.addItem(v);
            }
            if (wrapper.getValue() != null) {
                valueField.addItem(wrapper.getValue());
            }
            valueField.setEnabled(valueField.getItemIds().size() > 1);
        }
    });

    formLayout.setImmediate(true);
    formLayout.setWidth("100%");
    formLayout.addComponent(typeField);
    formLayout.addComponent(valueField);

    formEditor.bind(typeField, "type");
    formEditor.bind(valueField, "value");
    formEditor.setItemDataSource(wrapper);

    final HorizontalLayout toolbar = new HorizontalLayout();
    toolbar.addComponent(okButton);
    toolbar.addComponent(cancelButton);

    final VerticalLayout layout = new VerticalLayout();
    layout.addComponent(formLayout);
    layout.addComponent(toolbar);
    layout.setComponentAlignment(toolbar, Alignment.BOTTOM_RIGHT);
    layout.setMargin(true);
    setContent(layout);
}

From source file:org.opennms.features.vaadin.datacollection.ResourceTypePanel.java

License:Open Source License

/**
 * Instantiates a new resource type panel.
 *
 * @param dataCollectionConfigDao the OpenNMS Data Collection Configuration DAO
 * @param source the OpenNMS Data Collection ResourceType object
 * @param logger the logger object/*from  w ww  .  j  a v  a  2 s . c om*/
 */
public ResourceTypePanel(final DataCollectionConfigDao dataCollectionConfigDao,
        final DatacollectionGroup source, final Logger logger) {

    if (dataCollectionConfigDao == null) {
        throw new RuntimeException("dataCollectionConfigDao cannot be null.");
    }

    if (source == null) {
        throw new RuntimeException("source cannot be null.");
    }

    addStyleName("light");

    resourceTypeTable = new ResourceTypeTable(source.getResourceTypes());

    final ResourceTypeForm resourceTypeForm = new ResourceTypeForm();
    resourceTypeForm.setVisible(false);

    final EditorToolbar bottomToolbar = new EditorToolbar() {
        @Override
        public boolean save() {
            ResourceType resourceType = resourceTypeForm.getResourceType();
            if (!isNew && !resourceType.getName().equals(resourceTypeForm.getResourceTypeName())) {
                Set<String> groups = getParentGroups(dataCollectionConfigDao, resourceType.getName());
                if (!groups.isEmpty()) {
                    final String msg = "The resourceType cannot be renamed because it is being referenced by:\n"
                            + groups.toString();
                    Notification.show(msg, Notification.Type.WARNING_MESSAGE);
                    return false;
                }
            }
            logger.info("Resource Type " + resourceType.getName() + " has been "
                    + (isNew ? "created." : "updated."));
            try {
                resourceTypeForm.commit();
                resourceTypeForm.setReadOnly(true);
                resourceTypeTable.refreshRowCache();
                return true;
            } catch (CommitException e) {
                String msg = "Can't save the changes: " + e.getMessage();
                logger.error(msg);
                Notification.show(msg, Notification.Type.ERROR_MESSAGE);
                return false;
            }
        }

        @Override
        public boolean delete() {
            Object resourceTypeId = resourceTypeTable.getValue();
            if (resourceTypeId != null) {
                ResourceType resourceType = resourceTypeTable.getResourceType(resourceTypeId);
                Set<String> groups = getParentGroups(dataCollectionConfigDao, resourceType.getName());
                if (!groups.isEmpty()) {
                    final String msg = "The resourceType cannot be deleted because it is being referenced by:\n"
                            + groups.toString();
                    Notification.show(msg, Notification.Type.WARNING_MESSAGE);
                    return false;
                }
                logger.info("SNMP ResourceType " + resourceType.getName() + " has been removed.");
                resourceTypeTable.select(null);
                resourceTypeTable.removeItem(resourceTypeId);
                resourceTypeTable.refreshRowCache();
            }
            return true;
        }

        @Override
        public boolean edit() {
            resourceTypeForm.setReadOnly(false);
            return true;
        }

        @Override
        public boolean cancel() {
            resourceTypeForm.discard();
            resourceTypeForm.setReadOnly(true);
            return true;
        }
    };
    bottomToolbar.setVisible(false);

    resourceTypeTable.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            if (resourceTypeForm.isVisible() && !resourceTypeForm.isReadOnly()) {
                resourceTypeTable.select(selectedResourceTypeId);
                Notification.show(
                        "A resource type seems to be being edited.\nPlease save or cancel your current changes.",
                        Notification.Type.WARNING_MESSAGE);
            } else {
                Object resourceTypeId = resourceTypeTable.getValue();
                if (resourceTypeId != null) {
                    selectedResourceTypeId = resourceTypeId;
                    resourceTypeForm.setResourceType(resourceTypeTable.getResourceType(resourceTypeId));
                }
                resourceTypeForm.setReadOnly(true);
                resourceTypeForm.setVisible(resourceTypeId != null);
                bottomToolbar.setReadOnly(true);
                bottomToolbar.setVisible(resourceTypeId != null);
            }
        }
    });

    final Button add = new Button("Add Resource Type", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            resourceTypeTable.addResourceType(resourceTypeForm.createBasicResourceType());
            resourceTypeForm.setReadOnly(false);
            bottomToolbar.setReadOnly(false);
            setIsNew(true);
        }
    });

    final VerticalLayout mainLayout = new VerticalLayout();
    mainLayout.setSpacing(true);
    mainLayout.setMargin(true);
    mainLayout.addComponent(resourceTypeTable);
    mainLayout.addComponent(add);
    mainLayout.addComponent(resourceTypeForm);
    mainLayout.addComponent(bottomToolbar);
    mainLayout.setComponentAlignment(add, Alignment.MIDDLE_RIGHT);
    setContent(mainLayout);
}

From source file:org.opennms.features.vaadin.datacollection.RrdField.java

License:Open Source License

@Override
public Component initContent() {
    VerticalLayout layout = new VerticalLayout();
    layout.addComponent(step);/* w ww  .ja va  2  s.  co  m*/
    layout.addComponent(table);
    layout.addComponent(toolbar);
    layout.setComponentAlignment(toolbar, Alignment.MIDDLE_RIGHT);
    return layout;
}

From source file:org.opennms.features.vaadin.datacollection.SnmpCollectionPanel.java

License:Open Source License

/**
 * Instantiates a new SNMP collection panel.
 *
 * @param dataCollectionConfigDao the OpenNMS data collection configuration DAO
 * @param logger the logger/*from   w  w  w  .ja  v  a  2 s.co m*/
 */
public SnmpCollectionPanel(final DataCollectionConfigDao dataCollectionConfigDao, final Logger logger) {

    if (dataCollectionConfigDao == null)
        throw new RuntimeException("dataCollectionConfigDao cannot be null.");

    this.dataCollectionConfigDao = dataCollectionConfigDao;

    setCaption("SNMP Collections");
    addStyleName("light");

    final List<SnmpCollection> snmpCollections = dataCollectionConfigDao.getRootDataCollection()
            .getSnmpCollections();
    final SnmpCollectionTable snmpCollectionTable = new SnmpCollectionTable(snmpCollections);

    final SnmpCollectionForm snmpCollectionForm = new SnmpCollectionForm(dataCollectionConfigDao);
    snmpCollectionForm.setVisible(false);

    final EditorToolbar bottomToolbar = new EditorToolbar() {
        @Override
        public boolean save() {
            SnmpCollection snmpCollection = snmpCollectionForm.getSnmpCollection();
            logger.info("SNMP Collection " + snmpCollection.getName() + " has been "
                    + (isNew ? "created." : "updated."));
            String oldName = snmpCollection.getName();
            Integer oldStep = snmpCollection.getRrd().getStep();
            try {
                snmpCollectionForm.commit();
                snmpCollectionForm.setReadOnly(true);
                snmpCollectionTable.refreshRowCache();
                saveSnmpCollections(snmpCollectionTable.getSnmpCollections(), logger);
                if (!isNew && !oldName.equals(snmpCollectionForm.getSnmpCollectionName())) {
                    Notification.show(
                            "Be sure to replace " + oldName + " with "
                                    + snmpCollectionForm.getSnmpCollectionName()
                                    + " in case the collection is being used in collectd-configuration.xml",
                            Notification.Type.WARNING_MESSAGE); // TODO Is this enough
                }
                if (!isNew && oldStep != snmpCollectionForm.getRrdStep()) {
                    Notification.show(
                            "Be sure to replace the collection interval from " + oldStep + "s with "
                                    + snmpCollectionForm.getRrdStep()
                                    + "s in case the collection is being used in collectd-configuration.xml",
                            Notification.Type.WARNING_MESSAGE); // TODO Is this enough
                }
            } catch (CommitException e) {
                String msg = "Can't save the changes: " + e.getMessage();
                logger.error(msg);
                Notification.show(msg, Notification.Type.ERROR_MESSAGE);
                return false;
            }
            return true;
        }

        @Override
        public boolean delete() {
            Object snmpCollectionId = snmpCollectionTable.getValue();
            if (snmpCollectionId != null) {
                SnmpCollection snmpCollection = snmpCollectionTable.getSnmpCollection(snmpCollectionId);
                logger.info("SNMP Collection " + snmpCollection.getName() + " has been removed.");
                snmpCollectionTable.select(null);
                snmpCollectionTable.removeItem(snmpCollectionId);
                snmpCollectionTable.refreshRowCache();
                saveSnmpCollections(snmpCollectionTable.getSnmpCollections(), logger);
                Notification.show(
                        "Be sure that " + snmpCollection.getName()
                                + " is not being used in collectd-configuration.xml",
                        Notification.Type.WARNING_MESSAGE); // TODO Is this enough
            }
            return true;
        }

        @Override
        public boolean edit() {
            snmpCollectionForm.setReadOnly(false);
            return true;
        }

        @Override
        public boolean cancel() {
            snmpCollectionForm.discard();
            snmpCollectionForm.setReadOnly(true);
            return true;
        }
    };
    bottomToolbar.setVisible(false);

    snmpCollectionTable.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            if (snmpCollectionForm.isVisible() && !snmpCollectionForm.isReadOnly()) {
                snmpCollectionTable.select(selectedSnmpCollectionId);
                Notification.show(
                        "A SNMP collection type seems to be being edited.\nPlease save or cancel your current changes.",
                        Notification.Type.WARNING_MESSAGE);
            } else {
                Object snmpCollectionId = snmpCollectionTable.getValue();
                if (snmpCollectionId != null) {
                    selectedSnmpCollectionId = snmpCollectionId;
                    snmpCollectionForm
                            .setSnmpCollection(snmpCollectionTable.getSnmpCollection(snmpCollectionId));
                }
                snmpCollectionForm.setReadOnly(true);
                snmpCollectionForm.setVisible(snmpCollectionId != null);
                bottomToolbar.setReadOnly(true);
                bottomToolbar.setVisible(snmpCollectionId != null);
            }
        }
    });

    final Button add = new Button("Add SNMP Collection", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            snmpCollectionTable.addSnmpCollection(snmpCollectionForm.createBasicSnmpCollection());
            snmpCollectionForm.setReadOnly(false);
            bottomToolbar.setReadOnly(false);
            setIsNew(true);
        }
    });

    final Button refresh = new Button("Refresh SNMP Collections", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            ConfirmDialog.show(getUI(), "Are you sure?",
                    "By doing this all unsaved changes on the SNMP collection will be lost.", "Yes", "No",
                    new ConfirmDialog.Listener() {
                        public void onClose(ConfirmDialog dialog) {
                            if (dialog.isConfirmed()) {
                                final List<SnmpCollection> snmpCollections = dataCollectionConfigDao
                                        .getRootDataCollection().getSnmpCollections();
                                snmpCollectionTable.setSnmpCollections(snmpCollections);
                                snmpCollectionTable.select(null);
                                snmpCollectionForm.setVisible(false);
                            }
                        }
                    });
        }
    });

    final HorizontalLayout tableToolbar = new HorizontalLayout();
    tableToolbar.addComponent(add);
    tableToolbar.addComponent(refresh);

    final VerticalLayout mainLayout = new VerticalLayout();
    mainLayout.setSpacing(true);
    mainLayout.setMargin(true);
    mainLayout.addComponent(snmpCollectionTable);
    mainLayout.addComponent(tableToolbar);
    mainLayout.addComponent(snmpCollectionForm);
    mainLayout.addComponent(bottomToolbar);
    mainLayout.setComponentAlignment(tableToolbar, Alignment.MIDDLE_RIGHT);
    setContent(mainLayout);
}

From source file:org.opennms.features.vaadin.datacollection.SystemDefPanel.java

License:Open Source License

/**
 * Instantiates a new system definition panel.
 *
 * @param dataCollectionConfigDao the OpenNMS Data Collection Configuration DAO
 * @param source the OpenNMS Data Collection SystemDef object
 * @param logger the logger object/*from   w w w. j  a v a  2s.com*/
 */
public SystemDefPanel(final DataCollectionConfigDao dataCollectionConfigDao, final DatacollectionGroup source,
        final Logger logger) {

    if (dataCollectionConfigDao == null) {
        throw new RuntimeException("dataCollectionConfigDao cannot be null.");
    }

    if (source == null) {
        throw new RuntimeException("source cannot be null.");
    }

    addStyleName("light");

    // Adding all systemDefs already defined on this source
    final List<String> groupNames = new ArrayList<String>();
    for (Group group : source.getGroups()) {
        groupNames.add(group.getName());
    }

    // Adding all defined groups
    groupNames.addAll(dataCollectionConfigDao.getAvailableMibGroups());

    systemDefTable = new SystemDefTable(source.getSystemDefs());

    final SystemDefForm systemDefForm = new SystemDefForm(groupNames);
    systemDefForm.setVisible(false);

    final EditorToolbar bottomToolbar = new EditorToolbar() {
        @Override
        public boolean save() {
            SystemDef systemDef = systemDefForm.getSystemDef();
            if (!isNew && !systemDef.getName().equals(systemDefForm.getSystemDefName())) {
                Set<String> collections = getParentCollections(dataCollectionConfigDao, systemDef.getName());
                if (!collections.isEmpty()) {
                    final String msg = "The systemDef cannot be renamed because it is being referenced by:\n"
                            + collections.toString();
                    Notification.show(msg, Notification.Type.WARNING_MESSAGE);
                    return false;
                }
            }
            logger.info(
                    "SNMP SystemDef " + systemDef.getName() + " has been " + (isNew ? "created." : "updated."));
            try {
                systemDefForm.commit();
                systemDefForm.setReadOnly(true);
                systemDefTable.refreshRowCache();
                return true;
            } catch (CommitException e) {
                String msg = "Can't save the changes: " + e.getMessage();
                logger.error(msg);
                Notification.show(msg, Notification.Type.ERROR_MESSAGE);
                return false;
            }
        }

        @Override
        public boolean delete() {
            Object systemDefId = systemDefTable.getValue();
            if (systemDefId != null) {
                SystemDef systemDef = systemDefTable.getSystemDef(systemDefId);
                Set<String> collections = getParentCollections(dataCollectionConfigDao, systemDef.getName());
                if (!collections.isEmpty()) {
                    final String msg = "The systemDef cannot be deleted because it is being referenced by:\n"
                            + collections.toString();
                    Notification.show(msg, Notification.Type.WARNING_MESSAGE);
                    return false;
                }
                logger.info("SNMP SystemDef " + systemDef.getName() + " has been removed.");
                systemDefTable.select(null);
                systemDefTable.removeItem(systemDefId);
                systemDefTable.refreshRowCache();
            }
            return true;
        }

        @Override
        public boolean edit() {
            systemDefForm.setReadOnly(false);
            return true;
        }

        @Override
        public boolean cancel() {
            systemDefForm.discard();
            systemDefForm.setReadOnly(true);
            return true;
        }
    };
    bottomToolbar.setVisible(false);

    systemDefTable.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            if (systemDefForm.isVisible() && !systemDefForm.isReadOnly()) {
                systemDefTable.select(selectedSystemDefId);
                Notification.show(
                        "A system definition seems to be being edited.\nPlease save or cancel your current changes.",
                        Notification.Type.WARNING_MESSAGE);
            } else {
                Object systemDefId = systemDefTable.getValue();
                if (systemDefId != null) {
                    selectedSystemDefId = systemDefId;
                    systemDefForm.setSystemDef(systemDefTable.getSystemDef(systemDefId));
                }
                systemDefForm.setReadOnly(true);
                systemDefForm.setVisible(systemDefId != null);
                bottomToolbar.setReadOnly(true);
                bottomToolbar.setVisible(systemDefId != null);
            }
        }
    });

    final Button add = new Button("Add SNMP SystemDef", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            systemDefTable.addSystemDef(systemDefForm.createBasicSystemDef());
            systemDefForm.setReadOnly(false);
            bottomToolbar.setReadOnly(false);
            setIsNew(true);
        }
    });

    final VerticalLayout mainLayout = new VerticalLayout();
    mainLayout.setSpacing(true);
    mainLayout.setMargin(true);
    mainLayout.addComponent(systemDefTable);
    mainLayout.addComponent(add);
    mainLayout.addComponent(systemDefForm);
    mainLayout.addComponent(bottomToolbar);
    mainLayout.setComponentAlignment(add, Alignment.MIDDLE_RIGHT);
    setContent(mainLayout);
}

From source file:org.opennms.features.vaadin.events.EventPanel.java

License:Open Source License

/**
 * Instantiates a new event panel./*from   www . j  a v  a2 s  .  c om*/
 *
 * @param eventConfDao the OpenNMS Events Configuration DAO
 * @param eventProxy the OpenNMS Events Proxy
 * @param eventFile the events file
 * @param events the OpenNMS events object
 * @param logger the logger object
 */
public EventPanel(final EventConfDao eventConfDao, final EventProxy eventProxy, final File eventFile,
        final Events events, final Logger logger) {

    if (eventProxy == null) {
        throw new RuntimeException("eventProxy cannot be null.");
    }

    if (eventConfDao == null) {
        throw new RuntimeException("eventConfDao cannot be null.");
    }

    this.eventConfDao = eventConfDao;
    this.eventProxy = eventProxy;
    this.eventFile = eventFile;

    setCaption("Events");
    addStyleName("light");

    baseEventsObject.setGlobal(events.getGlobal());
    baseEventsObject.setEventFileCollection(events.getEventFileCollection());

    final HorizontalLayout topToolbar = new HorizontalLayout();
    topToolbar.addComponent(new Button("Save Events File", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            processEvents(logger);
        }
    }));
    topToolbar.addComponent(new Button("Cancel", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            logger.info("Event processing has been canceled");
            cancel();
        }
    }));

    eventTable = new EventTable(events.getEventCollection());

    final EventForm eventForm = new EventForm();
    eventForm.setVisible(false);

    final EditorToolbar bottomToolbar = new EditorToolbar() {
        @Override
        public boolean save() {
            org.opennms.netmgt.xml.eventconf.Event event = eventForm.getEvent();
            logger.info("Event " + event.getUei() + " has been " + (isNew ? "created." : "updated."));
            try {
                eventForm.commit();
                eventForm.setReadOnly(true);
                eventTable.refreshRowCache();
            } catch (CommitException e) {
                String msg = "Can't save the changes: " + e.getMessage();
                logger.error(msg);
                Notification.show(msg, Notification.Type.ERROR_MESSAGE);
                return false;
            }
            return true;
        }

        @Override
        public boolean delete() {
            Object eventId = eventTable.getValue();
            if (eventId != null) {
                org.opennms.netmgt.xml.eventconf.Event event = eventTable.getEvent(eventId);
                logger.info("Event " + event.getUei() + " has been removed.");
                eventTable.select(null);
                eventTable.removeItem(eventId);
                eventTable.refreshRowCache();
            }
            return true;
        }

        @Override
        public boolean edit() {
            eventForm.setReadOnly(false);
            return true;
        }

        @Override
        public boolean cancel() {
            eventForm.discard();
            eventForm.setReadOnly(true);
            return true;
        }
    };
    bottomToolbar.setVisible(false);

    eventTable.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            if (eventForm.isVisible() && !eventForm.isReadOnly()) {
                eventTable.select(selectedEventId);
                Notification.show(
                        "An event seems to be being edited.\nPlease save or cancel your current changes.",
                        Notification.Type.WARNING_MESSAGE);
            } else {
                Object eventId = eventTable.getValue();
                if (eventId != null) {
                    selectedEventId = eventId;
                    eventForm.setEvent(eventTable.getEvent(eventId));
                }
                eventForm.setReadOnly(true);
                eventForm.setVisible(eventId != null);
                bottomToolbar.setReadOnly(true);
                bottomToolbar.setVisible(eventId != null);
            }
        }
    });

    final Button add = new Button("Add Event", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            eventTable.addEvent(eventForm.createBasicEvent());
            eventForm.setReadOnly(false);
            bottomToolbar.setReadOnly(false);
            setIsNew(true);
        }
    });

    final VerticalLayout mainLayout = new VerticalLayout();
    mainLayout.setSpacing(true);
    mainLayout.setMargin(true);
    mainLayout.addComponent(topToolbar);
    mainLayout.addComponent(eventTable);
    mainLayout.addComponent(add);
    mainLayout.addComponent(eventForm);
    mainLayout.addComponent(bottomToolbar);
    mainLayout.setComponentAlignment(topToolbar, Alignment.MIDDLE_RIGHT);
    mainLayout.setComponentAlignment(add, Alignment.MIDDLE_RIGHT);

    setContent(mainLayout);
}

From source file:org.opennms.features.vaadin.events.MaskElementField.java

License:Open Source License

@Override
public Component initContent() {
    final VerticalLayout layout = new VerticalLayout();
    layout.addComponent(table);/*from ww w . j  av a  2 s . co  m*/
    layout.addComponent(toolbar);
    layout.setComponentAlignment(toolbar, Alignment.MIDDLE_RIGHT);
    return layout;
}

From source file:org.opennms.features.vaadin.mibcompiler.EventUeiWindow.java

License:Open Source License

/**
 * Instantiates a new Event Generator window.
 * /*from ww  w .jav a 2 s  . c om*/
 * @param defaultUei the default value for UEI base
 */
public EventUeiWindow(String defaultUei) {
    setCaption("Generate Events");
    setModal(true);
    setWidth("400px");
    setHeight("150px");
    setResizable(false);
    setClosable(false);
    addStyleName("dialog");

    ueiBase = new TextField("UEI Base");
    ueiBase.setNullSettingAllowed(false);
    ueiBase.setWidth("100%");
    ueiBase.setRequired(true);
    ueiBase.setValue(defaultUei);
    ueiBase.setRequiredError("UEI Base cannot be null.");

    okButton = new Button("Continue");
    okButton.addClickListener(this);

    cancelButton = new Button("Cancel");
    cancelButton.addClickListener(this);

    HorizontalLayout toolbar = new HorizontalLayout();
    toolbar.addComponent(okButton);
    toolbar.addComponent(cancelButton);

    VerticalLayout layout = new VerticalLayout();
    layout.addComponent(ueiBase);
    layout.addComponent(toolbar);
    layout.setComponentAlignment(toolbar, Alignment.BOTTOM_RIGHT);
    setContent(layout);
}

From source file:org.opennms.features.vaadin.mibcompiler.FileEditorWindow.java

License:Open Source License

/**
 * Instantiates a new file editor window.
 *
 * @param file the file/*from   ww  w . j a  v  a  2s  .c  om*/
 * @param logger the logger
 * @param readOnly true, if you want to display a read only window.
 */
public FileEditorWindow(final File file, final Logger logger, boolean readOnly) {
    this.file = file;
    this.logger = logger;

    setCaption((readOnly ? "View" : "Edit") + " MIB");
    addStyleName("dialog");
    setModal(true);
    setClosable(false);
    setWidth("800px");
    setHeight("540px");

    editor = new TextArea();
    editor.setPropertyDataSource(new TextFileProperty(file));
    editor.setImmediate(false);
    editor.setSizeFull();
    editor.setRows(30);
    editor.setReadOnly(readOnly);

    cancel = new Button(readOnly ? "Close" : "Cancel");
    cancel.setImmediate(false);
    cancel.addClickListener(this);
    save = new Button("Save");
    save.setImmediate(false);
    save.addClickListener(this);

    HorizontalLayout toolbar = new HorizontalLayout();
    toolbar.addComponent(cancel);
    if (!readOnly)
        toolbar.addComponent(save);

    VerticalLayout layout = new VerticalLayout();
    layout.addComponent(editor);
    layout.addComponent(toolbar);
    layout.setExpandRatio(editor, 1.0f);
    layout.setComponentAlignment(toolbar, Alignment.BOTTOM_RIGHT);
    setContent(layout);
}