Example usage for com.vaadin.ui HorizontalSplitPanel setFirstComponent

List of usage examples for com.vaadin.ui HorizontalSplitPanel setFirstComponent

Introduction

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

Prototype

public void setFirstComponent(Component c) 

Source Link

Document

Sets the first component of this split panel.

Usage

From source file:org.vaadin.spring.samples.sidebar.SideBarUI.java

License:Apache License

@Override
protected void init(VaadinRequest vaadinRequest) {
    getPage().setTitle("Vaadin4Spring Side Bar Sample");
    final HorizontalSplitPanel rootLayout = new HorizontalSplitPanel();
    rootLayout.setStyleName(Reindeer.SPLITPANEL_SMALL);
    rootLayout.setSizeFull();// w  w w .  j  ava  2s  .  c  om
    setContent(rootLayout);

    final Navigator navigator = new Navigator(this, new ViewDisplay() {
        @Override
        public void showView(View view) {
            System.out.println("Showing view " + view);
            rootLayout.setSecondComponent((com.vaadin.ui.Component) view);
        }
    });
    navigator.setErrorView(new ErrorView());
    navigator.addProvider(viewProvider);
    setNavigator(navigator);

    rootLayout.setFirstComponent(sideBar);
    rootLayout.setSplitPosition(150, Unit.PIXELS);
}

From source file:pt.yellowduck.ramboia.RamboiaApplication.java

License:Open Source License

private void buildMainLayout() {

    VerticalSplitPanel vSplit = new VerticalSplitPanel();
    vSplit.setSplitPosition(15, Sizeable.UNITS_PERCENTAGE);
    vSplit.setSizeFull();// www  .  j a va2 s  .co  m

    HorizontalSplitPanel hSplit_top = new HorizontalSplitPanel();
    hSplit_top.setSizeFull();
    hSplit_top.setSplitPosition(50, Sizeable.UNITS_PERCENTAGE);
    hSplit_top.setFirstComponent(viewPlayer);
    hSplit_top.setSecondComponent(viewUpload);
    hSplit_top.setLocked(true);

    vSplit.setFirstComponent(hSplit_top);

    HorizontalSplitPanel hSplit_bottom = new HorizontalSplitPanel();
    hSplit_bottom.setSizeFull();
    hSplit_bottom.setSplitPosition(75, Sizeable.UNITS_PERCENTAGE);
    hSplit_bottom.setFirstComponent(viewLibrary);
    hSplit_bottom.setSecondComponent(viewPlaylist);
    hSplit_bottom.setLocked(true);

    vSplit.setSecondComponent(hSplit_bottom);

    mainWindow.setContent(vSplit);
}

From source file:ru.codeinside.gses.webui.executor.ExecutorFactory.java

License:Mozilla Public License

public static Component create(final Changer changer, final TabSheet tabs) {

    final ItemBuilder<Task> assigneeBuilder = new BatchItemBuilder<Task>() {
        private static final long serialVersionUID = 1L;

        transient Durations durations;

        @Override//from  w w w. j a  v  a2 s .c om
        public void batchStart() {
            durations = new Durations();
        }

        @Override
        public void batchFinish() {
            durations = null;
        }

        @Override
        public Item createItem(final Task task) {
            final String taskId = task.getId();
            final ProcessDefinition def = ActivitiBean.get().getProcessDefinition(task.getProcessDefinitionId(),
                    Flash.login());
            String procedureName = Flash.flash().getExecutorService()
                    .getProcedureNameByDefinitionId(def.getId());
            final PropertysetItem item = new PropertysetItem();
            final Bid bid = getBid(task);
            final String bidId = bid.getId() == null ? "" : bid.getId().toString();
            item.addItemProperty("id", buttonProperty(bidId, new TaskGraphListener(changer, task)));
            item.addItemProperty("name", stringProperty(task.getName()));
            item.addItemProperty("startDate", stringProperty(formatter.format(bid.getDateCreated())));
            item.addItemProperty("declarant", stringProperty(bid.getDeclarant()));
            if (bid.getTag() == null || bid.getTag().isEmpty()) {
                item.addItemProperty("process", stringProperty(procedureName));
            } else {
                item.addItemProperty("process", stringProperty(bid.getTag() + " - " + procedureName));
            }
            item.addItemProperty("version", stringProperty(bid.getVersion()));
            final Button b = new Button("", new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    try {
                        showForm(tabs, taskId);
                    } catch (Exception e) {
                        Components.showException(event.getButton().getWindow(), e);
                    }
                }
            });
            b.setStyleName(Reindeer.BUTTON_SMALL);
            item.addItemProperty("claim", new ObjectProperty<Component>(b));
            item.addItemProperty("priority", stringProperty(String.valueOf(task.getPriority())));
            TaskDates td = AdminServiceProvider.get().getTaskDatesByTaskId(taskId);
            durations.fillBidAndTask(bid, td, item);
            return item;
        }

        private Bid getBid(final Task task) {
            Bid bid = AdminServiceProvider.get().getBidByTask(task.getId());

            if (bid == null) {
                bid = new Bid();
                bid.setDeclarant("");
                bid.setVersion("");
                bid.setStatus(BidStatus.Execute);
            }
            return bid;
        }

    };
    final AssigneeTaskListQuery assigneeTaskQuery = new AssigneeTaskListQuery(assigneeBuilder);
    final TableForExecutor assignee = new TableForExecutor(assigneeTaskQuery);
    assignee.setCaption("?? ?");
    assignee.addContainerProperty("id", Component.class, null);
    assignee.addContainerProperty("name", String.class, null);
    assignee.addContainerProperty("startDate", String.class, null);
    assignee.addContainerProperty("declarant", String.class, null);
    assignee.addContainerProperty("process", String.class, null);
    assignee.addContainerProperty("version", String.class, null);
    assignee.addContainerProperty("status", String.class, null);
    assignee.addContainerProperty("claim", Component.class, null);
    assignee.addContainerProperty("priority", String.class, null);
    assignee.addContainerProperty("bidDays", String.class, null);
    assignee.addContainerProperty("taskDays", String.class, null);
    assignee.setVisibleColumns(new Object[] { "id", "name", "startDate", "declarant", "process", "version",
            "claim", "bidDays", "taskDays" });
    assignee.setColumnHeaders(new String[] { "?", "", "  ?",
            "?", "", "v", "", "..", ".?." });
    assignee.setSelectable(false);
    assignee.setSortDisabled(true);

    assignee.setColumnAlignment("id", Table.ALIGN_RIGHT);
    assignee.setColumnExpandRatio("id", 0.3f);
    assignee.setColumnExpandRatio("name", 1f);
    assignee.setColumnExpandRatio("process", 1.2f);
    assignee.setColumnExpandRatio("bidDays", 0.2f);
    assignee.setColumnExpandRatio("taskDays", 0.2f);

    assignee.setCellStyleGenerator(new TaskStylist(assignee));

    final ItemBuilder<Task> claimBuilder = new BatchItemBuilder<Task>() {
        private static final long serialVersionUID = 1L;

        Durations durations;

        @Override
        public void batchStart() {
            durations = new Durations();
        }

        @Override
        public void batchFinish() {
            durations = null;
        }

        @Override
        public Item createItem(final Task task) {
            final String taskId = task.getId();
            final ProcessDefinition def = ActivitiBean.get().getProcessDefinition(task.getProcessDefinitionId(),
                    Flash.login());
            String procedureName = Flash.flash().getExecutorService()
                    .getProcedureNameByDefinitionId(def.getId());
            PropertysetItem item = new PropertysetItem();
            final Bid bid = getBid(task);
            ObjectProperty idProperty;
            if (bid.getId() == null) {
                idProperty = new ObjectProperty<String>("");
            } else {
                idProperty = buttonProperty(bid.getId().toString(), new TaskGraphListener(changer, task));
            }
            item.addItemProperty("id", idProperty);
            item.addItemProperty("name", stringProperty(task.getName()));
            item.addItemProperty("startDate", stringProperty(formatter.format(bid.getDateCreated())));
            item.addItemProperty("declarant", stringProperty(bid.getDeclarant()));
            if (bid.getTag() == null || bid.getTag().isEmpty()) {
                item.addItemProperty("process", stringProperty(procedureName));
            } else {
                item.addItemProperty("process", stringProperty(bid.getTag() + " - " + procedureName));
            }
            item.addItemProperty("version", stringProperty(bid.getVersion()));
            item.addItemProperty("status", stringProperty(bid.getStatus().getName()));
            final Button b = new Button("", new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    final String login = Flash.login();
                    final String errMessage = ActivitiBean.get().claim(taskId, login, login, false);
                    if (!StringUtils.isEmpty(errMessage)) {
                        event.getButton().getWindow().showNotification("", errMessage,
                                Notification.TYPE_ERROR_MESSAGE);
                    }
                    fireTaskChangedEvent(taskId, this);
                }
            });
            b.setStyleName(Reindeer.BUTTON_SMALL);
            item.addItemProperty("claim", new ObjectProperty<Component>(b));
            item.addItemProperty("priority", stringProperty(String.valueOf(task.getPriority())));
            TaskDates td = AdminServiceProvider.get().getTaskDatesByTaskId(taskId);
            durations.fillBidAndTask(bid, td, item);
            return item;
        }

        private Bid getBid(final Task task) {
            Bid bid = AdminServiceProvider.get().getBidByTask(task.getId());

            if (bid == null) {
                bid = new Bid();
                bid.setDeclarant("");
                bid.setVersion("");
                bid.setStatus(BidStatus.Execute);
            }
            return bid;
        }

    };
    final CandidateTaskListQuery candidateTaskQuery = new CandidateTaskListQuery(claimBuilder, Flash.login());
    final TableForExecutor candidate = new TableForExecutor(candidateTaskQuery);
    candidate.setCaption(" ?");
    candidate.addContainerProperty("id", Component.class, null);
    candidate.addContainerProperty("name", String.class, null);
    candidate.addContainerProperty("startDate", String.class, null);
    candidate.addContainerProperty("declarant", String.class, null);
    candidate.addContainerProperty("process", String.class, null);
    candidate.addContainerProperty("version", String.class, null);
    candidate.addContainerProperty("status", String.class, null);
    candidate.addContainerProperty("claim", Component.class, null);
    candidate.addContainerProperty("priority", String.class, null);
    candidate.addContainerProperty("bidDays", String.class, null);
    candidate.addContainerProperty("taskDays", String.class, null);
    candidate.setVisibleColumns(new Object[] { "id", "name", "startDate", "declarant", "process", "version",
            "status", "claim", "bidDays", "taskDays" });
    candidate.setColumnHeaders(new String[] { "?", "", "  ?",
            "?", "", "v", "?", "", "..", ".?." });
    candidate.setSelectable(false);
    candidate.setSortDisabled(true);

    candidate.setColumnAlignment("id", Table.ALIGN_RIGHT);
    candidate.setColumnExpandRatio("name", 1f);
    candidate.setColumnExpandRatio("process", 1f);

    candidate.setCellStyleGenerator(new TaskStylist(candidate));

    final Form filter = new TaskFilter(candidateTaskQuery, candidate, assigneeTaskQuery, assignee,
            TaskFilter.Mode.Executor);

    HorizontalLayout asigneeLayout = new HorizontalLayout();
    asigneeLayout.setSizeFull();
    asigneeLayout.setMargin(true);
    asigneeLayout.setSpacing(true);
    asigneeLayout.addComponent(assignee);

    Panel filterPanel = new Panel();
    filterPanel.setHeight("100%");
    filterPanel.addComponent(filter);
    final HorizontalSplitPanel hSplitter = new HorizontalSplitPanel();
    hSplitter.setSizeFull();
    hSplitter.setFirstComponent(filterPanel);
    hSplitter.setSecondComponent(asigneeLayout);
    hSplitter.setSplitPosition(35);

    VerticalLayout candidateLayout = new VerticalLayout();
    candidateLayout.setSizeFull();
    candidateLayout.setMargin(true);
    candidateLayout.addComponent(candidate);

    final TasksSplitter vSplitter = new TasksSplitter(assignee, candidate);
    vSplitter.setSizeFull();
    vSplitter.setFirstComponent(hSplitter);
    vSplitter.setSecondComponent(candidateLayout);
    vSplitter.setSplitPosition(57);
    return vSplitter;
}

From source file:ru.codeinside.gses.webui.manager.DirectoryPanel.java

License:Mozilla Public License

static Component createDirectoryPanel() {
    HorizontalSplitPanel horSplit = new HorizontalSplitPanel();
    horSplit.setSizeFull();/* ww w . j a  v  a 2 s .c om*/
    horSplit.setMargin(true);

    Panel panel00 = new Panel();
    Panel panel01 = new Panel();

    Panel panel10 = new Panel();

    horSplit.setFirstComponent(panel00);

    VerticalLayout vl = new VerticalLayout();
    horSplit.setSecondComponent(vl);

    vl.addComponent(panel01);
    vl.addComponent(panel10);

    vl.setSpacing(true);

    horSplit.setWidth("100%");
    vl.setHeight("100%");

    panel00.setHeight("100%");
    panel00.setWidth("100%");

    panel01.setWidth("100%");
    panel01.setHeight("100%");
    panel10.setHeight("100%");
    horSplit.setSplitPosition(35);
    vl.setExpandRatio(panel01, 0.25f);
    vl.setExpandRatio(panel10, 0.75f);

    final Table dirMapTable = ManagerWorkplace.createDirectoryMapTable();
    final FilterTable directoryTable = ManagerWorkplace.createDirectoryTable();
    dirMapTable.setVisible(false);

    final Form createFieldForm = new Form();
    createFieldForm.setCaption(" ?  ?");

    final TextField keyField = new TextField("");
    keyField.setRequired(true);
    keyField.setMaxLength(254);
    createFieldForm.addField("key", keyField);

    final TextField valField = new TextField("");
    valField.setRequired(true);
    valField.setMaxLength(1022);
    createFieldForm.addField("val", valField);
    createFieldForm.setVisible(false);

    Button addButton = new Button("",
            new AddTupleButtonListener(createFieldForm, directoryTable, keyField, valField, dirMapTable));
    createFieldForm.addField("submit", addButton);

    directoryTable.addListener(new DirectoryTableChangeListener(createFieldForm, directoryTable, dirMapTable));

    ManagerWorkplace.buildContainer(directoryTable, createFieldForm, dirMapTable);
    directoryTable.setColumnHeaders(new String[] { "?", "", "" });

    final Form createDirectory = new Form();
    createDirectory.setCaption(" ?");
    final TextField field = new TextField("?");
    field.setRequired(true);
    field.setMaxLength(255);
    field.setRequiredError("  ?");
    createDirectory.addField("name", field);
    Button createButton = new Button("",
            new CreateDirectoryButtonListener(field, createDirectory, directoryTable));
    createDirectory.addField("submit", createButton);

    Panel loadPanel = new Panel();
    loadPanel.setCaption(" ?");

    UploadDirectory events = new UploadDirectory(directoryTable, dirMapTable);

    Upload c = new Upload("", events);
    c.addListener(events);

    c.setButtonCaption("");
    loadPanel.addComponent(c);

    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setSizeFull();
    verticalLayout.setSpacing(true);
    verticalLayout.addComponent(loadPanel);
    verticalLayout.addComponent(createDirectory);
    verticalLayout.addComponent(directoryTable);

    panel00.addComponent(verticalLayout);

    panel01.addComponent(createFieldForm);

    dirMapTable.setSizeFull();
    dirMapTable.setPageLength(13);
    panel10.addComponent(dirMapTable);

    return horSplit;
}