Example usage for com.vaadin.ui Alignment MIDDLE_RIGHT

List of usage examples for com.vaadin.ui Alignment MIDDLE_RIGHT

Introduction

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

Prototype

Alignment MIDDLE_RIGHT

To view the source code for com.vaadin.ui Alignment MIDDLE_RIGHT.

Click Source Link

Usage

From source file:com.esofthead.mycollab.vaadin.web.ui.SearchTextField.java

License:Open Source License

public SearchTextField() {
    this.setDefaultComponentAlignment(Alignment.MIDDLE_RIGHT);
    ELabel icon = ELabel.fontIcon(FontAwesome.SEARCH);
    innerField = new TextField();
    innerField.setImmediate(true);/* w  ww .j  a v a 2  s .c om*/
    innerField.setInputPrompt("Search");
    innerField.setWidth("180px");
    this.with(icon, innerField).withStyleName("searchfield");
    ShortcutListener shortcutListener = new ShortcutListener("searchfield", ShortcutAction.KeyCode.ENTER,
            null) {
        @Override
        public void handleAction(Object sender, Object target) {
            String value = ((TextField) target).getValue();
            if (isNotBlank(value)) {
                doSearch(value);
            } else {
                emptySearch();
            }
        }
    };
    ShortcutExtension.installShortcutAction(innerField, shortcutListener);
}

From source file:com.esofthead.mycollab.vaadin.web.ui.StyleCalendarExp.java

License:Open Source License

public StyleCalendarExp() {
    this.setWidth("230px");
    this.setHeightUndefined();
    this.setSpacing(false);
    this.setStyleName("stylecalendar-ext");
    this.setMargin(new MarginInfo(true, false, false, false));

    styleCalendar.setRenderHeader(false);
    styleCalendar.setRenderWeekNumbers(false);
    styleCalendar.setImmediate(true);//from   www . j  ava  2s. c o  m
    styleCalendar.setWidth("100%");
    setDateOptionsGenerator();

    btnShowNextYear = new Button();
    btnShowNextYear.setIcon(new AssetResource("icons/16/cal_year_next.png"));
    btnShowNextYear.setStyleName(UIConstants.BUTTON_LINK);

    btnShowNextMonth = new Button();
    btnShowNextMonth.setIcon(new AssetResource("icons/16/cal_month_next.png"));
    btnShowNextMonth.setStyleName(UIConstants.BUTTON_LINK);

    btnShowPreviousMonth = new Button();
    btnShowPreviousMonth.setIcon(new AssetResource("icons/16/cal_month_pre.png"));
    btnShowPreviousMonth.setStyleName(UIConstants.BUTTON_LINK);

    btnShowPreviousYear = new Button();
    btnShowPreviousYear.setIcon(new AssetResource("icons/16/cal_year_pre.png"));
    btnShowPreviousYear.setStyleName(UIConstants.BUTTON_LINK);

    lbSelectedDate.setValue(AppContext.formatDate(new Date()));
    lbSelectedDate.addStyleName("calendarDateLabel");
    lbSelectedDate.setWidth("80");

    HorizontalLayout layoutControl = new HorizontalLayout();
    layoutControl.setStyleName("calendarHeader");
    layoutControl.setWidth("100%");
    layoutControl.setHeight("35px");

    HorizontalLayout layoutButtonPrevious = new HorizontalLayout();
    layoutButtonPrevious.setSpacing(true);
    layoutButtonPrevious.addComponent(btnShowPreviousYear);
    layoutButtonPrevious.setComponentAlignment(btnShowPreviousYear, Alignment.MIDDLE_LEFT);
    layoutButtonPrevious.addComponent(btnShowPreviousMonth);
    layoutButtonPrevious.setComponentAlignment(btnShowPreviousMonth, Alignment.MIDDLE_LEFT);
    layoutControl.addComponent(layoutButtonPrevious);
    layoutControl.setComponentAlignment(layoutButtonPrevious, Alignment.MIDDLE_LEFT);

    layoutControl.addComponent(lbSelectedDate);
    layoutControl.setComponentAlignment(lbSelectedDate, Alignment.MIDDLE_CENTER);

    MHorizontalLayout layoutButtonNext = new MHorizontalLayout();
    layoutButtonNext.addComponent(btnShowNextMonth);
    layoutButtonNext.setComponentAlignment(btnShowNextMonth, Alignment.MIDDLE_RIGHT);
    layoutButtonNext.addComponent(btnShowNextYear);
    layoutButtonNext.setComponentAlignment(btnShowNextYear, Alignment.MIDDLE_RIGHT);
    layoutControl.addComponent(layoutButtonNext);
    layoutControl.setComponentAlignment(layoutButtonNext, Alignment.MIDDLE_RIGHT);

    this.addComponent(layoutControl);
    this.setComponentAlignment(layoutControl, Alignment.TOP_CENTER);

    this.addComponent(styleCalendar);
    this.setExpandRatio(styleCalendar, 1.0f);
}

From source file:com.esofthead.mycollab.vaadin.web.ui.table.AbstractPagedBeanTable.java

License:Open Source License

private ComponentContainer createPagingControls() {
    controlBarWrapper = new HorizontalLayout();
    controlBarWrapper.setWidth("100%");
    controlBarWrapper.setStyleName("listControl");

    pageManagement = new MHorizontalLayout();

    // defined layout here ---------------------------

    if (currentPage > 1) {
        Button firstLink = new Button("1", new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override//  w  ww .j a v a  2  s  .co  m
            public void buttonClick(final ClickEvent event) {
                pageChange(1);
            }
        });
        firstLink.addStyleName("buttonPaging");
        pageManagement.addComponent(firstLink);
    }
    if (currentPage >= 5) {
        Label ss1 = new Label("...");
        ss1.addStyleName("buttonPaging");
        pageManagement.addComponent(ss1);
    }

    if (currentPage > 3) {
        Button previous2 = new Button("" + (currentPage - 2), new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                pageChange(currentPage - 2);
            }
        });
        previous2.addStyleName("buttonPaging");
        pageManagement.addComponent(previous2);
    }
    if (currentPage > 2) {
        Button previous1 = new Button("" + (currentPage - 1), new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                pageChange(currentPage - 1);
            }
        });
        previous1.addStyleName("buttonPaging");
        pageManagement.addComponent(previous1);
    }
    // Here add current ButtonLinkLegacy
    Button current = new Button("" + currentPage, new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            pageChange(currentPage);
        }
    });
    current.addStyleName("buttonPaging");
    current.addStyleName("current");

    pageManagement.addComponent(current);
    final int range = totalPage - currentPage;
    if (range >= 1) {
        Button next1 = new Button("" + (currentPage + 1), new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                pageChange(currentPage + 1);
            }
        });
        next1.addStyleName("buttonPaging");
        pageManagement.addComponent(next1);
    }
    if (range >= 2) {
        Button next2 = new Button("" + (currentPage + 2), new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                pageChange(currentPage + 2);
            }
        });
        next2.addStyleName("buttonPaging");
        pageManagement.addComponent(next2);
    }
    if (range >= 4) {
        final Label ss2 = new Label("...");
        ss2.addStyleName("buttonPaging");
        pageManagement.addComponent(ss2);
    }
    if (range >= 3) {
        Button last = new Button("" + totalPage, new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                pageChange(totalPage);
            }
        });
        last.addStyleName("buttonPaging");
        pageManagement.addComponent(last);
    }

    pageManagement.setWidth(null);
    controlBarWrapper.addComponent(pageManagement);
    controlBarWrapper.setComponentAlignment(pageManagement, Alignment.MIDDLE_RIGHT);

    return controlBarWrapper;
}

From source file:com.esspl.datagen.ui.ExecutorView.java

License:Open Source License

public ExecutorView(DataGenApplication application) {
    log.debug("ExecutorView - constructor start");
    dataGenApplication = application;// w  w w. j a v a2s.  c  o  m
    setSizeFull();

    VerticalLayout vl = new VerticalLayout();
    vl.setSizeFull();
    setCompositionRoot(vl);

    splitPanel = new VerticalSplitPanel();
    splitPanel.setSizeFull();

    //Script TextArea
    sqlScript = new TextArea();
    sqlScript.setSizeFull();
    sqlScript.setWordwrap(false);
    sqlScript.setStyleName("noResizeTextArea");

    HorizontalLayout queryOptions = new HorizontalLayout();
    queryOptions.setMargin(false, false, false, true);
    queryOptions.setSpacing(true);
    queryOptions.setWidth("100%");
    queryOptions.setHeight("40px");

    Button executeButton = new Button("Execute", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            log.info("ExecutorView - Execute Button clicked");
            executeScript(sqlScript.getValue().toString());
        }
    });
    executeButton.addStyleName("small");
    executeButton.setIcon(DataGenConstant.EXECUTOR_ICON);
    executeButton.setDescription("Press Ctrl+Enter to execute the query");

    Button clearQueryButton = new Button("Clear SQL", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            log.info("ExecutorView - Clear SQL Button clicked");
            sqlScript.setValue("");
        }
    });
    clearQueryButton.addStyleName("small");
    clearQueryButton.setIcon(DataGenConstant.CLEAR_SMALL);
    clearQueryButton.setDescription("Clears the Sql");

    Button clearConsoleButton = new Button("Clear Console", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            log.info("ExecutorView - Clear Console Button clicked");
            logText.setValue("");
        }
    });
    clearConsoleButton.addStyleName("small");
    clearConsoleButton.setIcon(DataGenConstant.CLEAR_SMALL);
    clearConsoleButton.setDescription("Clears the Console");

    maxRowsBox = new ComboBox(null, Arrays.asList(10, 100, 500, 1000, 5000, 10000));
    maxRowsBox.setDescription("Max number of rows to retrieve");
    maxRowsBox.setWidth(100, UNITS_PIXELS);
    maxRowsBox.setNewItemsAllowed(false);
    maxRowsBox.setNullSelectionAllowed(false);
    maxRowsBox.setValue(100);

    //Bottom section components
    resultSheet = new TabSheet();
    resultSheet.setSizeFull();
    resultSheet.addStyleName(Runo.TABSHEET_SMALL);

    logText = new Label();
    logText.setContentMode(Label.CONTENT_XHTML);
    logText.setSizeFull();

    //Panel to add refresher
    logPanel = new Panel();
    logPanel.setSizeFull();
    logPanel.setScrollable(true);
    logPanel.setStyleName(Runo.PANEL_LIGHT);
    logPanel.addComponent(logText);

    //Refresher added to show instant log messages
    refresher = new Refresher();
    logPanel.addComponent(refresher);

    //Loading image
    loadingImg = new Embedded("", DataGenConstant.LOADING_ICON);
    loadingImg.setVisible(false);
    logPanel.addComponent(loadingImg);

    resultSheet.addTab(logPanel, "Console");
    resultTab = resultSheet.addTab(new Label(), "Results");

    queryOptions.addComponent(executeButton);
    queryOptions.setComponentAlignment(executeButton, Alignment.MIDDLE_LEFT);
    queryOptions.addComponent(clearQueryButton);
    queryOptions.setComponentAlignment(clearQueryButton, Alignment.MIDDLE_LEFT);
    queryOptions.addComponent(clearConsoleButton);
    queryOptions.setComponentAlignment(clearConsoleButton, Alignment.MIDDLE_LEFT);
    queryOptions.setExpandRatio(clearConsoleButton, 1);
    queryOptions.addComponent(maxRowsBox);
    queryOptions.setComponentAlignment(maxRowsBox, Alignment.MIDDLE_RIGHT);

    splitPanel.setFirstComponent(sqlScript);
    splitPanel.setSecondComponent(resultSheet);

    vl.addComponent(queryOptions);
    vl.addComponent(splitPanel);
    vl.setExpandRatio(splitPanel, 1);

    sqlScript.addShortcutListener(new ShortcutListener("Execute Script", null, ShortcutAction.KeyCode.ENTER,
            ShortcutAction.ModifierKey.CTRL) {

        @Override
        public void handleAction(Object sender, Object target) {
            executeScript(sqlScript.getValue().toString());
        }
    });
    log.debug("ExecutorView - constructor end");
}

From source file:com.esspl.datagen.ui.SettingsView.java

License:Open Source License

public SettingsView(DataGenApplication application) {
    setModal(true);//from www.  j a  va 2  s .  c o  m
    setResizable(false);
    setCaption("Settings");
    setWidth("620px");
    setHeight("440px");
    dataGenApplication = application;

    GridLayout layout = createMainLayout();
    setContent(layout);

    Component bottom = createBottomBar(dataGenApplication);
    layout.addComponent(bottom, 0, 1);
    layout.setComponentAlignment(bottom, Alignment.MIDDLE_RIGHT);
    layout.setRowExpandRatio(0, 1);

    //Context Help added
    contextHelp = new ContextHelp();
    layout.addComponent(contextHelp);

    refreshDetails();
}

From source file:com.esspl.datagen.ui.SettingsView.java

License:Open Source License

private Component createBottomBar(final DataGenApplication dataGenApplication) {
    HorizontalLayout bottom = new HorizontalLayout();
    bottom.setWidth("100%");
    bottom.setSpacing(true);//from   w  w w  . j  ava2  s.  c  o  m

    Button addButton = new Button("Add", new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            ConnectionProfile profile = new ConnectionProfile("New Profile", "", "", "", "");
            SettingsManager.get().getConfiguration().addProfile(profile);
            list.getContainerDataSource().addItem(profile);
            list.select(profile);
        }
    });

    Button saveProfilesButton = new Button("Save Profiles", new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            SettingsManager.get().persistConfiguration();
        }
    });

    Button closeButton = new Button("Close", new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            dataGenApplication.toolbar.reloadConnectionProfile();
            close();
        }
    });

    bottom.addComponent(addButton);
    bottom.addComponent(saveProfilesButton);
    bottom.addComponent(closeButton);

    bottom.setComponentAlignment(closeButton, Alignment.MIDDLE_RIGHT);
    bottom.setExpandRatio(closeButton, 1);

    return bottom;
}

From source file:com.esspl.datagen.ui.TableDataView.java

License:Open Source License

public TableDataView(final JdbcTable table, final Connection connection, final DataGenApplication dataApp) {
    log.debug("TableDataView - constructor start");
    setCaption("Data");
    dataGenApplication = dataApp;//from  w  w w.j  a  v a2s. c  om
    VerticalLayout vl = new VerticalLayout();
    vl.setSizeFull();
    setCompositionRoot(vl);

    HorizontalLayout hBar = new HorizontalLayout();
    hBar.setWidth("98%");
    hBar.setHeight("40px");

    rows = new TextField();
    rows.setWidth("50px");
    rows.setImmediate(true);
    rows.addValidator(new IntegerValidator("Rows must be an Integer"));
    Label lbl = new Label("Generate ");

    content = new HorizontalLayout();
    content.setHeight("40px");
    content.setMargin(false, false, false, true);
    content.setSpacing(true);
    content.addComponent(lbl);
    content.setComponentAlignment(lbl, Alignment.MIDDLE_CENTER);
    content.addComponent(rows);
    content.setComponentAlignment(rows, Alignment.MIDDLE_CENTER);

    Button addDataButton = new Button("Row(S) Data", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            log.debug("TableDataView - Generate Data Button clicked");
            populateGenerator(table);
        }
    });
    addDataButton.addStyleName("small");
    addDataButton.setIcon(DataGenConstant.ADD_SMALL);
    content.addComponent(addDataButton);
    content.setComponentAlignment(addDataButton, Alignment.MIDDLE_CENTER);

    Button refreshButton = new Button("Refresh", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            log.debug("TableDataView - Refresh Button clicked");
            refreshDataView(table, connection);
        }
    });
    refreshButton.addStyleName("small");
    refreshButton.setIcon(DataGenConstant.RESET);
    content.addComponent(refreshButton);
    content.setComponentAlignment(refreshButton, Alignment.MIDDLE_CENTER);

    //Tapas:10/08/2012 - Export feature implementation started
    HorizontalLayout expContainer = new HorizontalLayout();
    expContainer.setSpacing(true);

    PopupButton exportButton = new PopupButton("Export");
    exportButton.setComponent(new DataExportView());
    exportButton.addListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            //dataApp.getMainWindow().showNotification("Export Button clicked!");
        }
    });
    exportButton.setIcon(DataGenConstant.DATAEXPORT_ICON);
    expContainer.addComponent(exportButton);
    expContainer.setComponentAlignment(exportButton, Alignment.MIDDLE_LEFT);

    //Tapas:10/08/2012 - Import feature implementation started
    PopupButton importButton = new PopupButton("Import");
    importButton.setComponent(new DataImportView());
    importButton.addListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            //dataApp.getMainWindow().showNotification("Import Button clicked!");
        }
    });
    importButton.setIcon(DataGenConstant.DATAIMPORT_ICON);
    expContainer.addComponent(importButton);
    expContainer.setComponentAlignment(importButton, Alignment.MIDDLE_RIGHT);

    tableContainer = new VerticalLayout();
    tableContainer.setSizeFull();
    hBar.addComponent(content);
    hBar.setComponentAlignment(content, Alignment.MIDDLE_LEFT);
    hBar.addComponent(expContainer);
    hBar.setComponentAlignment(expContainer, Alignment.MIDDLE_RIGHT);
    vl.addComponent(hBar);
    vl.addComponent(tableContainer);
    vl.setExpandRatio(tableContainer, 1f);

    refreshDataView(table, connection);
    log.debug("TableDataView - constructor end");
}

From source file:com.esspl.datagen.ui.ToolBar.java

License:Open Source License

public ToolBar(final DataGenApplication dataGenApplication) {
    log.debug("ToolBar constructor start");
    List<ConnectionProfile> profileList = SettingsManager.get().getConfiguration().getProfiles();
    profiles = new Select(null, new BeanItemContainer<ConnectionProfile>(ConnectionProfile.class, profileList));
    profiles.setImmediate(true);/* w ww . ja  v  a  2s . c om*/
    profiles.setNewItemsAllowed(false);
    profiles.setNullSelectionAllowed(false);
    addComponent(profiles);
    setComponentAlignment(profiles, Alignment.MIDDLE_RIGHT);
    setStyleName("toolbar");
    setSpacing(true);

    //Connect button
    connect = new Button("Connect", new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            log.debug("ToolBar - Connect button clicked");
            ConnectionProfile cp = (ConnectionProfile) profiles.getValue();
            if (cp == null) {
                getApplication().getMainWindow().showNotification("Select a Connection profile to connect.",
                        Notification.TYPE_ERROR_MESSAGE);
                return;
            }
            try {
                dataGenApplication.databaseSessionManager.connect(cp);
            } catch (Exception ex) {
                getApplication().getMainWindow().showNotification("Failed to connect<br/>", ex.getMessage(),
                        Notification.TYPE_ERROR_MESSAGE);
                return;
            }
            profiles.setVisible(false);
            connect.setVisible(false);
            disConnect.setVisible(true);
            dataGenApplication.connectedString.setVisible(true);
            dataGenApplication.connectedString.setValue("Connected to - " + cp.getName());
            boolean isExplorerSelected = dataGenApplication.tabSheet.getSelectedTab() instanceof ExplorerView;
            dataGenApplication.tabSheet.removeComponent(dataGenApplication.explorer);
            dataGenApplication.explorer = new ExplorerView(dataGenApplication,
                    dataGenApplication.databaseSessionManager);
            dataGenApplication.tabSheet.addTab(dataGenApplication.explorer, "Explorer",
                    DataGenConstant.EXPLORER_ICON, 2);
            if (isExplorerSelected) {
                dataGenApplication.tabSheet.setSelectedTab(dataGenApplication.explorer);
            }
        }
    });
    connect.setIcon(DataGenConstant.DB_CONNECT_ICON);
    addComponent(connect);
    setComponentAlignment(connect, Alignment.MIDDLE_RIGHT);

    //Disconnect button
    disConnect = new Button("Disconnect", new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            log.debug("ToolBar - Disconnect button clicked");
            dataGenApplication.databaseSessionManager.disconnect();
            profiles.setVisible(true);
            connect.setVisible(true);
            disConnect.setVisible(false);
            dataGenApplication.connectedString.setVisible(false);
            dataGenApplication.connectedString.setValue("");
            boolean isExplorerSelected = dataGenApplication.tabSheet.getSelectedTab() instanceof ExplorerView;
            dataGenApplication.tabSheet.removeComponent(dataGenApplication.explorer);
            dataGenApplication.explorer = new ExplorerView(dataGenApplication,
                    dataGenApplication.databaseSessionManager);
            dataGenApplication.tabSheet.addTab(dataGenApplication.explorer, "Explorer",
                    DataGenConstant.EXPLORER_ICON, 2);
            if (isExplorerSelected) {
                dataGenApplication.tabSheet.setSelectedTab(dataGenApplication.explorer);
            }
        }
    });
    disConnect.setIcon(DataGenConstant.DB_DISCONNECT_ICON);
    disConnect.setVisible(false);
    addComponent(disConnect);
    setComponentAlignment(disConnect, Alignment.MIDDLE_RIGHT);

    //Settings button
    Button settings = new Button("Settings", new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            log.debug("ToolBar - Settings button clicked");
            SettingsView settingsManagerView = new SettingsView(dataGenApplication);
            getWindow().addWindow(settingsManagerView);
        }
    });
    settings.setIcon(DataGenConstant.DB_SETTING_ICON);
    addComponent(settings);
    setComponentAlignment(settings, Alignment.MIDDLE_RIGHT);

    //Reload button
    Button reset = new Button("Reset", new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            log.debug("ToolBar - Reset button clicked");
            dataGenApplication.getMainWindow().getApplication().close();
        }
    });
    reset.setIcon(DataGenConstant.RESET);
    addComponent(reset);
    setComponentAlignment(reset, Alignment.MIDDLE_RIGHT);
    log.debug("ToolBar constructor end");
}

From source file:com.etest.view.notification.NotificationMainUI.java

public NotificationMainUI() {
    setSizeFull();//from  w ww  .  j a va2 s.  c  om
    setSpacing(true);

    if (VaadinSession.getCurrent().getAttribute("userId") == null) {
        Page.getCurrent().setLocation("http://localhost:8080/");
    } else {
        addComponent(populateNoficationTable());
    }

    HorizontalLayout h = new HorizontalLayout();
    h.setWidth("950px");

    Button sendMsgBtn = new Button("Send Message");
    sendMsgBtn.setWidthUndefined();
    sendMsgBtn.addStyleName(ValoTheme.BUTTON_SMALL);
    sendMsgBtn.addStyleName(ValoTheme.BUTTON_PRIMARY);
    sendMsgBtn.addClickListener((Button.ClickEvent event) -> {
        Notification.show("Send Message!");
    });

    h.addComponent(sendMsgBtn);
    h.setComponentAlignment(sendMsgBtn, Alignment.MIDDLE_RIGHT);
    addComponent(h);
}

From source file:com.etest.view.testbank.CellCaseWindow.java

FormLayout buildForms() {
    FormLayout form = new FormLayout();
    form.setWidth("100%");
    form.setMargin(true);/*from  w w  w.  j  a v  a 2  s. c o  m*/

    subject.setCaption("Subject: ");
    subject.setWidth("50%");
    subject.addValueChangeListener((new CurriculumPropertyChangeListener(topic)));
    form.addComponent(subject);

    topic.setCaption("Topic: ");
    topic.setWidth("80%");
    topic.setInputPrompt("Select a Topic..");
    topic.addStyleName(ValoTheme.COMBOBOX_SMALL);
    form.addComponent(topic);

    caseTopic = new TextArea();
    caseTopic.setCaption("Case: ");
    caseTopic.setWidth("100%");
    caseTopic.setRows(5);
    form.addComponent(caseTopic);

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

    Button save = new Button("SAVE");
    save.setWidth("200px");
    save.setIcon(FontAwesome.SAVE);
    save.addStyleName(ValoTheme.BUTTON_PRIMARY);
    save.addStyleName(ValoTheme.BUTTON_SMALL);
    save.addClickListener(buttonClickListener);

    Button modify = new Button("MODIFY");
    modify.setWidth("200px");
    modify.setIcon(FontAwesome.EDIT);
    modify.addStyleName(ValoTheme.BUTTON_PRIMARY);
    modify.addStyleName(ValoTheme.BUTTON_SMALL);
    modify.addClickListener(buttonClickListener);

    Button approve = new Button("APPROVE");
    approve.setWidth("200px");
    approve.setIcon(FontAwesome.THUMBS_UP);
    approve.addStyleName(ValoTheme.BUTTON_PRIMARY);
    approve.addStyleName(ValoTheme.BUTTON_SMALL);
    approve.setEnabled(UserAccess.approve());
    approve.addClickListener(buttonClickListener);

    Button delete = new Button("DELETE");
    delete.setWidth("200px");
    delete.setIcon(FontAwesome.TRASH_O);
    delete.addStyleName(ValoTheme.BUTTON_PRIMARY);
    delete.addStyleName(ValoTheme.BUTTON_SMALL);
    delete.setEnabled(UserAccess.delete());
    delete.addClickListener(buttonClickListener);

    if (getCellCaseId() != 0) {
        CellCase cc = ccs.getCellCaseById(getCellCaseId());
        subject.setValue(cc.getCurriculumId());
        topic.setValue(cc.getSyllabusId());
        caseTopic.setValue(cc.getCaseTopic());

        approve.setVisible(cc.getApprovalStatus() == 0);
        hlayout.addComponent(approve);
        hlayout.setComponentAlignment(approve, Alignment.MIDDLE_RIGHT);

        hlayout.addComponent(modify);
        hlayout.setComponentAlignment(modify, Alignment.MIDDLE_RIGHT);

        hlayout.addComponent(delete);
        hlayout.setComponentAlignment(delete, Alignment.MIDDLE_RIGHT);
    } else {
        hlayout.addComponent(save);
        hlayout.setComponentAlignment(save, Alignment.MIDDLE_RIGHT);
    }

    form.addComponent(hlayout);
    form.setComponentAlignment(hlayout, Alignment.MIDDLE_RIGHT);

    return form;
}