Example usage for com.vaadin.ui VerticalLayout setMargin

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

Introduction

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

Prototype

@Override
    public void setMargin(boolean enabled) 

Source Link

Usage

From source file:com.packtpub.learnvaadin.MainWindow.java

public MainWindow() {
    VerticalLayout vLayout = new VerticalLayout();
    vLayout.setMargin(true);
    setContent(vLayout);//from w  ww .j a  v a  2 s .  c  o  m
    table = new Table();
    table.setPageLength(10);
    table.setEditable(true);
    table.setSizeFull();
    table.addGeneratedColumn("delete", new DeleteColumnGenerator());
    vLayout.addComponent(table);
    HorizontalLayout hLayout = new HorizontalLayout();
    hLayout.setMargin(true);
    hLayout.setSpacing(true);
    vLayout.addComponent(hLayout);
}

From source file:com.peergreen.webconsole.core.notifier.NotifierService.java

License:Open Source License

/**
 * {@inheritDoc}/*from  w  w w  . jav  a  2  s  .c  o  m*/
 */
@Override
public void addNotificationsButton(Button button, final Window window, final UI ui) {
    final VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    window.setContent(layout);

    notificationButtons.put(ui, new NotificationButton(button, 0));

    button.addClickListener(new NotificationClickListener(layout));
}

From source file:com.peergreen.webconsole.scope.deployment.internal.deployable.DeployablePanel.java

License:Open Source License

@PostConstruct
public void init() {

    setSizeFull();/*from   w  w w. j a v  a  2 s  .c  om*/

    VerticalLayout mainContent = new VerticalLayout();
    mainContent.setSpacing(true);
    mainContent.setMargin(true);
    mainContent.setStyleName("deployable-style");
    mainContent.setSizeFull();

    HorizontalLayout header = new HorizontalLayout();
    header.setWidth("100%");
    Button openManager = new Button("Edit repositories");
    openManager.addStyleName("link");
    openManager.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (tabSheet.getTab(manager) == null) {
                tabSheet.addTab(manager, "Manager",
                        new ClassResource(getClass(), "/images/22x22/configuration.png"), containers.size())
                        .setClosable(true);
            }
            tabSheet.setSelectedTab(manager);
        }
    });
    header.addComponent(openManager);
    header.setComponentAlignment(openManager, Alignment.MIDDLE_RIGHT);
    mainContent.addComponent(header);

    tabSheet.setSizeFull();
    mainContent.addComponent(tabSheet);
    mainContent.setExpandRatio(tabSheet, 1.5f);

    DragAndDropWrapper mainContentWrapper = new DragAndDropWrapper(mainContent);
    mainContentWrapper.setDropHandler(new DeploymentDropHandler(deploymentViewManager, this, notifierService));
    mainContentWrapper.setSizeFull();

    setContent(mainContentWrapper);
}

From source file:com.peergreen.webconsole.scope.deployment.internal.deployable.repository.BaseRepositoryManagerPanel.java

License:Open Source License

@PostConstruct
public void init() {
    setSizeFull();//from w ww .  jav  a  2 s .  c  o  m
    VerticalLayout mainLayout = new VerticalLayout();
    mainLayout.setMargin(true);
    mainLayout.setSpacing(true);
    setContent(mainLayout);

    HorizontalLayout header = new HorizontalLayout();
    header.setWidth("100%");
    header.setSpacing(true);
    header.setMargin(true);

    TextField filter = new TextField();
    filter.setInputPrompt("Filter repositories");
    filter.setWidth("100%");
    filter.addTextChangeListener(new RepositoryFilter());
    header.addComponent(filter);
    header.setComponentAlignment(filter, Alignment.TOP_LEFT);

    Button createRepository = new Button("Add repository");
    createRepository.addStyleName("wide");
    createRepository.addStyleName("default");
    createRepository.addClickListener(new CreateNewRepositoryListener());
    header.addComponent(createRepository);
    header.setComponentAlignment(createRepository, Alignment.TOP_RIGHT);
    mainLayout.addComponent(header);
    mainLayout.addComponent(contentLayout);
    mainLayout.setExpandRatio(contentLayout, 1.5f);

    updateRepositories();
}

From source file:com.peergreen.webconsole.scope.deployment.internal.deployed.DeployedPanel.java

License:Open Source License

@PostConstruct
public void init() {
    setSizeFull();/*from  w w w.j  ava2 s .c  o  m*/
    Table table = new Table();

    VerticalLayout mainContent = new VerticalLayout();
    mainContent.setSpacing(true);
    mainContent.setMargin(true);
    mainContent.setStyleName("deployable-style");
    mainContent.setSizeFull();

    setContent(mainContent);

    HorizontalLayout toolBar = new HorizontalLayout();
    toolBar.setMargin(true);
    toolBar.setSpacing(true);
    toolBar.setWidth("100%");

    // Select all deployed artifacts
    CheckBox selectAll = new CheckBox("All");
    selectAll.addValueChangeListener(new SelectAll(table));
    toolBar.addComponent(selectAll);
    toolBar.setExpandRatio(selectAll, 1);

    // Filter
    TextField filter = new TextField();
    filter.setInputPrompt("Filter deployed artifacts");
    filter.setWidth("100%");
    filter.addTextChangeListener(new FilterFiles(TREE_ITEM_ID, container));
    toolBar.addComponent(filter);
    toolBar.setComponentAlignment(filter, Alignment.TOP_LEFT);
    toolBar.setExpandRatio(filter, 3);

    HorizontalLayout actionArea = new HorizontalLayout();
    final NativeSelect actionSelection = new NativeSelect();
    actionSelection.addItem(DeploymentActions.UNDEPLOY);
    actionSelection.addItem(DeploymentActions.DELETE);
    actionSelection.addItem(DeploymentActions.DEPLOYMENT_PLAN);
    actionSelection.setWidth("100px");
    actionSelection.setNullSelectionAllowed(false);

    Button doButton = new Button("Do");
    doButton.addStyleName("default");
    doButton.addClickListener(
            new DoClickListener(artifactBuilder, table, actionSelection, deploymentViewManager));

    actionArea.addComponent(actionSelection);
    actionArea.addComponent(doButton);
    toolBar.addComponent(actionArea);
    toolBar.setComponentAlignment(actionArea, Alignment.TOP_RIGHT);
    mainContent.addComponent(toolBar);

    VerticalLayout deployedContainer = new VerticalLayout();
    DragAndDropWrapper deployedContainerWrapper = new DragAndDropWrapper(deployedContainer);
    deployedContainerWrapper
            .setDropHandler(new DeploymentDropHandler(deploymentViewManager, this, notifierService));
    deployedContainerWrapper.setSizeFull();
    mainContent.addComponent(deployedContainerWrapper);
    mainContent.setExpandRatio(deployedContainerWrapper, 1.5f);

    container.addContainerProperty(TREE_ITEM_ID, String.class, null);
    table.setSizeFull();
    table.setImmediate(true);
    table.setMultiSelect(true);
    table.setSelectable(true);
    table.setColumnHeaderMode(Table.ColumnHeaderMode.HIDDEN);
    table.setContainerDataSource(container);
    table.setDragMode(Table.TableDragMode.MULTIROW);
    table.setItemCaptionPropertyId(TREE_ITEM_ID);
    table.setCellStyleGenerator(new ItemStyle(DeployableContainerType.DEPLOYED, deploymentManager));
    table.addShortcutListener(new DeleteFileShortcutListener(deploymentViewManager, table, "Delete",
            ShortcutAction.KeyCode.DELETE, null));
    table.setItemDescriptionGenerator(new ItemDescription());
    table.addItemClickListener(new ItemClickEvent.ItemClickListener() {
        @Override
        public void itemClick(ItemClickEvent event) {
            if (event.isDoubleClick()) {
                DeployableEntry deployableEntry = (DeployableEntry) event.getItemId();
                try {
                    ArtifactStatusReport report = deploymentManager
                            .getReport(deployableEntry.getUri().toString());
                    event.getComponent().getUI()
                            .addWindow(new DeployableWindow(deployableEntry, report).getWindow());
                } catch (ArtifactStatusReportException e) {
                    LOGGER.warn("Cannot get artifact status report for ''{0}''", deployableEntry.getUri(), e);
                    event.getComponent().getUI().addWindow(new DeployableWindow(deployableEntry).getWindow());
                }
            }
        }
    });
    deployedContainer.addComponent(table);
    deployedContainer.setExpandRatio(table, 1.5f);

    refresh();
}

From source file:com.peergreen.webconsole.scope.deployment.internal.deploymentplan.DeploymentPlanPanel.java

License:Open Source License

@PostConstruct
public void init() {
    setSizeFull();/* w  w w  . j a va2  s  .  c o  m*/

    TreeTable table = new TreeTable();

    VerticalLayout mainContent = new VerticalLayout();
    mainContent.setSpacing(true);
    mainContent.setMargin(true);
    mainContent.setStyleName("deployable-style");
    mainContent.setSizeFull();

    setContent(mainContent);

    HorizontalLayout toolBar = new HorizontalLayout();
    toolBar.setMargin(true);
    toolBar.setSpacing(true);
    toolBar.setWidth("100%");

    // Deployment Plan name
    Label deploymentPlanNameLabel = new Label("Plan");
    toolBar.addComponent(deploymentPlanNameLabel);
    toolBar.setExpandRatio(deploymentPlanNameLabel, 1);

    deploymentPlanName = new TextField();
    deploymentPlanName.setInputPrompt(getDefaultName());
    deploymentPlanName.setWidth("100%");
    toolBar.addComponent(deploymentPlanName);
    toolBar.setComponentAlignment(deploymentPlanName, Alignment.TOP_LEFT);
    toolBar.setExpandRatio(deploymentPlanName, 3);

    error = new Label("", ContentMode.HTML);
    error.addStyleName("error");
    error.setSizeUndefined();
    error.addStyleName("light");
    error.addStyleName("v-animate-reveal");
    error.setVisible(false);
    toolBar.addComponent(error);
    toolBar.setComponentAlignment(error, Alignment.TOP_RIGHT);
    toolBar.setExpandRatio(error, 1);
    mainContent.addComponent(toolBar);
    mainContent.setComponentAlignment(toolBar, Alignment.TOP_LEFT);
    mainContent.setExpandRatio(toolBar, 1);

    VerticalLayout deploymentPlanContainer = new VerticalLayout();
    DragAndDropWrapper deploymentPlanContainerWrapper = new DragAndDropWrapper(deploymentPlanContainer);
    DropHandler deploymentPlanDropHandler = new DeploymentDropHandler(deploymentViewManager, this,
            notifierService);
    deploymentPlanContainerWrapper.setDropHandler(deploymentPlanDropHandler);
    deploymentPlanContainerWrapper.setSizeFull();
    mainContent.addComponent(deploymentPlanContainerWrapper);
    mainContent.setExpandRatio(deploymentPlanContainerWrapper, 10);

    container.addContainerProperty(TREE_ITEM_ID, String.class, null);
    table.setSizeFull();
    table.setImmediate(true);
    table.setMultiSelect(true);
    table.setSelectable(true);
    table.setContainerDataSource(container);
    table.setDragMode(Table.TableDragMode.MULTIROW);
    table.setItemCaptionPropertyId(TREE_ITEM_ID);
    table.setCellStyleGenerator(new ItemStyle(DeployableContainerType.DEPLOYED));
    table.setColumnHeaderMode(Table.ColumnHeaderMode.HIDDEN);
    table.setDropHandler(new OrderedContainerDropHandler(table, deploymentPlanDropHandler));
    table.addShortcutListener(new ShortcutListener("Delete", ShortcutAction.KeyCode.DELETE, null) {
        @Override
        public void handleAction(Object sender, Object target) {
            Table table = (Table) target;
            Collection<DeployableEntry> deployableEntries = (Collection<DeployableEntry>) table.getValue();
            for (DeployableEntry deployableEntry : deployableEntries) {
                removeDeployable(deployableEntry);
            }
        }
    });
    deploymentPlanContainer.addComponent(table);

    HorizontalLayout footer = new HorizontalLayout();
    footer.setSizeFull();
    footer.setSpacing(true);
    footer.setMargin(true);
    footer.addStyleName("footer");
    footer.setWidth("100%");

    deployIt = new CheckBox("Deploy this deployment plan");
    footer.addComponent(deployIt);
    footer.setComponentAlignment(deployIt, Alignment.TOP_LEFT);

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.setMargin(true);
    Button cancel = new Button("Cancel");
    cancel.addClickListener(new CancelButtonListener());
    Button create = new Button("Create");
    create.addClickListener(new CreateButtonListener());
    create.addStyleName("wide");
    create.addStyleName("default");
    buttons.addComponent(cancel);
    buttons.addComponent(create);
    footer.addComponent(buttons);
    footer.setComponentAlignment(buttons, Alignment.TOP_RIGHT);

    mainContent.addComponent(footer);
    mainContent.setComponentAlignment(footer, Alignment.BOTTOM_RIGHT);
    mainContent.setExpandRatio(footer, 1);
}

From source file:com.peergreen.webconsole.vaadin.DefaultWindow.java

License:Open Source License

/**
 * Create a default window/*from   w w  w  . j  av  a2s. co  m*/
 * @param caption window caption
 * @param content window content. Vaadin component
 * @param footerButtons list of buttons in footer
 */
public DefaultWindow(String caption, Component content, Button... footerButtons) {
    setCaption(caption);
    setClosable(false);
    setResizable(false);
    addStyleName("edit-dashboard");

    VerticalLayout main = new VerticalLayout();
    main.setSpacing(true);
    main.setMargin(true);
    main.setStyleName("default-window");

    content.addStyleName("default-window-content");
    main.addComponent(content);

    HorizontalLayout footer = new HorizontalLayout();
    footer.setStyleName("footer");
    footer.setWidth("100%");
    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.setMargin(true);

    for (Button button : footerButtons) {
        buttons.addComponent(button);
    }
    footer.addComponent(buttons);
    footer.setComponentAlignment(buttons, Alignment.MIDDLE_RIGHT);

    main.addComponent(footer);
    setContent(main);
}

From source file:com.pms.component.ganttchart.DemoUI.java

License:Apache License

private void openStepEditor(AbstractStep step) {
    final Window win = new Window("Step Editor");
    win.setResizable(false);//from w w  w . j a va2  s . c  om
    win.center();

    final Collection<Component> hidden = new ArrayList<Component>();

    BeanItem<AbstractStep> item = new BeanItem<AbstractStep>(step);

    final FieldGroup group = new FieldGroup(item);
    group.setBuffered(true);

    TextField captionField = new TextField("Caption");
    captionField.setNullRepresentation("");
    group.bind(captionField, "caption");

    TextField descriptionField = new TextField("Description");
    descriptionField.setNullRepresentation("");
    group.bind(descriptionField, "description");
    descriptionField.setVisible(false);
    hidden.add(descriptionField);

    NativeSelect captionMode = new NativeSelect("Caption Mode");
    captionMode.addItem(Step.CaptionMode.TEXT);
    captionMode.addItem(Step.CaptionMode.HTML);
    group.bind(captionMode, "captionMode");
    captionMode.setVisible(false);
    hidden.add(captionMode);

    final NativeSelect parentStepSelect = new NativeSelect("Parent Step");
    parentStepSelect.setEnabled(false);
    if (!gantt.getSteps().contains(step)) {
        // new step
        parentStepSelect.setEnabled(true);
        for (Step parentStepCanditate : gantt.getSteps()) {
            parentStepSelect.addItem(parentStepCanditate);
            parentStepSelect.setItemCaption(parentStepCanditate, parentStepCanditate.getCaption());
            if (step instanceof SubStep) {
                if (parentStepCanditate.getSubSteps().contains(step)) {
                    parentStepSelect.setValue(parentStepCanditate);
                    parentStepSelect.setEnabled(false);
                    break;
                }
            }
        }
    }
    parentStepSelect.setVisible(false);
    hidden.add(parentStepSelect);

    TextField bgField = new TextField("Background color");
    bgField.setNullRepresentation("");
    group.bind(bgField, "backgroundColor");
    bgField.setVisible(false);
    hidden.add(bgField);

    DateField startDate = new DateField("Start date");
    startDate.setLocale(gantt.getLocale());
    startDate.setTimeZone(gantt.getTimeZone());
    startDate.setResolution(Resolution.SECOND);
    startDate.setConverter(new DateToLongConverter());
    group.bind(startDate, "startDate");

    DateField endDate = new DateField("End date");
    endDate.setLocale(gantt.getLocale());
    endDate.setTimeZone(gantt.getTimeZone());
    endDate.setResolution(Resolution.SECOND);
    endDate.setConverter(new DateToLongConverter());
    group.bind(endDate, "endDate");

    CheckBox showMore = new CheckBox("Show all settings");
    showMore.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            for (Component c : hidden) {
                c.setVisible((Boolean) event.getProperty().getValue());
            }
            win.center();
        }
    });

    VerticalLayout content = new VerticalLayout();
    content.setMargin(true);
    content.setSpacing(true);
    win.setContent(content);

    content.addComponent(captionField);
    content.addComponent(captionMode);
    content.addComponent(descriptionField);
    content.addComponent(parentStepSelect);
    content.addComponent(bgField);
    content.addComponent(startDate);
    content.addComponent(endDate);
    content.addComponent(showMore);

    HorizontalLayout buttons = new HorizontalLayout();
    content.addComponent(buttons);

    Button ok = new Button("Ok", new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                group.commit();
                AbstractStep step = ((BeanItem<AbstractStep>) group.getItemDataSource()).getBean();
                gantt.markStepDirty(step);
                if (parentStepSelect.isEnabled() && parentStepSelect.getValue() != null) {
                    SubStep subStep = addSubStep(parentStepSelect, step);
                    step = subStep;
                }
                if (step instanceof Step && !gantt.getSteps().contains(step)) {
                    gantt.addStep((Step) step);
                }
                if (ganttListener != null && step instanceof Step) {
                    ganttListener.stepModified((Step) step);
                }
                win.close();
            } catch (CommitException e) {
                Notification.show("Commit failed", e.getMessage(), Type.ERROR_MESSAGE);
                e.printStackTrace();
            }
        }

        private SubStep addSubStep(final NativeSelect parentStepSelect, AbstractStep dataSource) {
            SubStep subStep = new SubStep();
            subStep.setCaption(dataSource.getCaption());
            subStep.setCaptionMode(dataSource.getCaptionMode());
            subStep.setStartDate(dataSource.getStartDate());
            subStep.setEndDate(dataSource.getEndDate());
            subStep.setBackgroundColor(dataSource.getBackgroundColor());
            subStep.setDescription(dataSource.getDescription());
            subStep.setStyleName(dataSource.getStyleName());
            ((Step) parentStepSelect.getValue()).addSubStep(subStep);
            return subStep;
        }
    });
    Button cancel = new Button("Cancel", new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            group.discard();
            win.close();
        }
    });
    Button delete = new Button("Delete", new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            AbstractStep step = ((BeanItem<AbstractStep>) group.getItemDataSource()).getBean();
            if (step instanceof SubStep) {
                SubStep substep = (SubStep) step;
                substep.getOwner().removeSubStep(substep);
            } else {
                gantt.removeStep((Step) step);
                if (ganttListener != null) {
                    ganttListener.stepDeleted((Step) step);
                }
            }
            win.close();
        }
    });
    buttons.addComponent(ok);
    buttons.addComponent(cancel);
    buttons.addComponent(delete);
    win.setClosable(true);

    DashboardUI.getCurrent().getUI().addWindow(win);
}

From source file:com.pms.component.ganttchart.scheduletask.TaskGanntChart.java

License:Apache License

private void openStepEditor(AbstractStep step) {
    final Window win = new Window("More Info");
    win.setResizable(false);/*from  w  ww . j  av  a2s. c om*/
    win.center();

    VerticalLayout content = new VerticalLayout();
    content.setMargin(true);
    content.setSpacing(true);
    win.setContent(content);

    String taskName = step.getCaption();
    UserStoryDAO userStoryDAO = (UserStoryDAO) DashboardUI.context.getBean("UserStory");
    UserStory userStory = userStoryDAO.getCurrentWorkingUserStory(project);

    TaskDAO taskDAO = (TaskDAO) DashboardUI.context.getBean("Task");
    Task task1 = taskDAO.getTaskFromUserStroyNameAndTaskName(userStory.getName(), taskName);

    TextField userStoryNameField = new TextField("Task Name");
    userStoryNameField.setValue(task1.getName());

    TextField userStoryPriority = new TextField("Priority");
    userStoryPriority.setValue(String.valueOf(task1.getPriority()));

    TextField userStoryState = new TextField("State");
    userStoryState.setValue(task1.getState());

    TextField projectName = new TextField("Project Name");
    projectName.setValue(project.getName());

    TextField userStoryName = new TextField("UserStoryName Name");
    userStoryName.setValue(userStory.getName());

    content.addComponent(userStoryNameField);
    content.addComponent(userStoryPriority);
    content.addComponent(userStoryState);
    content.addComponent(projectName);
    content.addComponent(userStoryName);

    Button ok = new Button("Ok", new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {

            win.close();
        }

    });

    content.addComponent(ok);
    win.setClosable(true);

    DashboardUI.getCurrent().getUI().addWindow(win);
}

From source file:com.pms.component.ganttchart.scheduletask.UserStoryGanntChart.java

License:Apache License

private void openStepEditor(AbstractStep step) {
    final Window win = new Window("More Info");
    win.setResizable(false);//  ww  w  .  j  a va2 s. co m
    win.center();

    VerticalLayout content = new VerticalLayout();
    content.setMargin(true);
    content.setSpacing(true);
    win.setContent(content);

    String userStoryName = step.getCaption();
    UserStoryDAO userStoryDAO = (UserStoryDAO) DashboardUI.context.getBean("UserStory");
    UserStory userStory = userStoryDAO.getUserStoryFormProjectNameAndUserStoryName(project.getName(),
            userStoryName);

    TextField userStoryNameField = new TextField("User Story Name");
    userStoryNameField.setValue(userStory.getName());

    TextField userStoryPriority = new TextField("Priority");
    userStoryPriority.setValue(String.valueOf(userStory.getPriority()));

    TextField userStoryState = new TextField("State");
    userStoryState.setValue(userStory.getState());

    TextField projectName = new TextField("Project Name");
    projectName.setValue(project.getName());

    content.addComponent(userStoryNameField);
    content.addComponent(userStoryPriority);
    content.addComponent(userStoryState);
    content.addComponent(projectName);

    Button ok = new Button("Ok", new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {

            win.close();
        }

    });

    content.addComponent(ok);
    win.setClosable(true);

    DashboardUI.getCurrent().getUI().addWindow(win);
}