Example usage for com.vaadin.ui.themes ValoTheme TABSHEET_FRAMED

List of usage examples for com.vaadin.ui.themes ValoTheme TABSHEET_FRAMED

Introduction

In this page you can find the example usage for com.vaadin.ui.themes ValoTheme TABSHEET_FRAMED.

Prototype

String TABSHEET_FRAMED

To view the source code for com.vaadin.ui.themes ValoTheme TABSHEET_FRAMED.

Click Source Link

Document

Adds a border around the whole component as well as around individual tabs in the tab bar.

Usage

From source file:de.uni_tuebingen.qbic.qbicmainportlet.PatientView.java

License:Open Source License

/**
 * init this view. builds the layout skeleton Menubar Description and others Statisitcs Experiment
 * Table Graph//  w w  w. ja v a2  s  . c om
 */
void initView() {
    patientViewContent = new VerticalLayout();
    patientViewContent.setMargin(new MarginInfo(true, false, false, false));
    // patientViewContent.setMargin(true);

    headerLabel = "";

    patientViewTab = new TabSheet();
    patientViewTab.setHeight("100%");
    patientViewTab.setWidth("100%");

    datasetComponent = new DatasetComponent(datahandler, state, resourceUrl);
    biologicalSamplesComponent = new BiologicalSamplesComponent(datahandler, state, resourceUrl,
            "Biological Samples");
    measuredSamplesComponent = new LevelComponent(datahandler, state, resourceUrl, "Raw Data");
    resultsComponent = new LevelComponent(datahandler, state, resourceUrl, "Results");
    statusComponent = new PatientStatusComponent(datahandler, state, resourceUrl);
    workflowComponent = new WorkflowComponent(wfController);
    uploadComponent = new AttachmentUploadComponent();
    projectInformation = new ProjInformationComponent(datahandler, state, resourceUrl);
    experimentComponent = new ExperimentComponent(datahandler, state, resourceUrl);

    patientViewTab.addStyleName(ValoTheme.TABSHEET_EQUAL_WIDTH_TABS);
    patientViewTab.addStyleName(ValoTheme.TABSHEET_FRAMED);
    patientViewTab.addStyleName(ValoTheme.TABSHEET_PADDED_TABBAR);

    // patientViewTab.addTab(initDescription()).setIcon(FontAwesome.INFO_CIRCLE);
    patientViewTab.addTab(projectInformation).setIcon(FontAwesome.INFO_CIRCLE);
    patientViewTab.addTab(statusComponent).setIcon(FontAwesome.CHECK_CIRCLE);
    patientViewTab.addTab(initGraphs()).setIcon(FontAwesome.SITEMAP);
    // patientViewTab.addTab(initMemberSection()).setIcon(FontAwesome.USERS);
    // patientViewTab.addTab(initHLALayout()).setIcon(FontAwesome.BARCODE);
    // patientViewTab.addTab(initTable()).setIcon(FontAwesome.FLASK);

    patientViewTab.addTab(experimentComponent).setIcon(FontAwesome.FLASK);
    patientViewTab.addTab(datasetComponent).setIcon(FontAwesome.DATABASE);
    patientViewTab.addTab(biologicalSamplesComponent).setIcon(FontAwesome.TINT);
    patientViewTab.addTab(measuredSamplesComponent).setIcon(FontAwesome.SIGNAL);
    patientViewTab.addTab(resultsComponent).setIcon(FontAwesome.TH_LARGE);
    patientViewTab.addTab(workflowComponent).setIcon(FontAwesome.COGS);
    patientViewTab.addTab(uploadComponent).setIcon(FontAwesome.UPLOAD);

    patientViewTab.setImmediate(true);

    patientViewTab.addSelectedTabChangeListener(new SelectedTabChangeListener() {

        @Override
        public void selectedTabChange(SelectedTabChangeEvent event) {
            TabSheet tab = (TabSheet) event.getSource();

            if (event.getTabSheet().getSelectedTab().getCaption().equals("Project Graph")) {
                loadGraph();
            } else if (event.getTabSheet().getSelectedTab().getCaption().equals("Exp. Steps")) {
                experimentComponent.updateUI(getCurrentBean());
            } else if (event.getTabSheet().getSelectedTab().getCaption().equals("Datasets")) {
                datasetComponent.updateUI("project", getCurrentBean().getId());
            } else if (event.getTabSheet().getSelectedTab().getCaption().equals("Raw Data")) {
                measuredSamplesComponent.updateUI("project", getCurrentBean().getId(), "measured");
            } else if (event.getTabSheet().getSelectedTab().getCaption().equals("Biological Samples")) {
                biologicalSamplesComponent.updateUI(getCurrentBean().getId());
            } else if (event.getTabSheet().getSelectedTab().getCaption().equals("Results")) {
                resultsComponent.updateUI("project", getCurrentBean().getId(), "results");
            } else if (event.getTabSheet().getSelectedTab().getCaption().equals("Status")) {
                statusComponent.updateUI(getCurrentBean());
            } else if (event.getTabSheet().getSelectedTab().getCaption().equals("Workflows")) {
                Map<String, String> args = new HashMap<String, String>();
                args.put("id", getCurrentBean().getId());
                args.put("type", "project");
                workflowComponent.update(args);
            } else if (event.getTabSheet().getSelectedTab().getCaption().equals("Upload Files")) {
                // (get space from currentBean)
                uploadComponent.updateUI(manager, getCurrentBean().getCode(), currentBean.getId().split("/")[1],
                        datahandler.getOpenBisClient());
            } else if (event.getTabSheet().getSelectedTab().getCaption().equals("")) {
                projectInformation.updateUI(getCurrentBean(), "patient");
            }
        }
    });

    patientViewContent.addComponent(patientViewTab);
    this.addComponent(patientViewContent);

}

From source file:de.uni_tuebingen.qbic.qbicmainportlet.ProjectView.java

License:Open Source License

/**
 * init this view. builds the layout skeleton Menubar Description and others Statisitcs Experiment
 * Table Graph/*from  w  w w. j a v  a 2 s  .c  o  m*/
 */
void initView() {
    projectview_content = new VerticalLayout();
    projectview_content.setMargin(new MarginInfo(true, false, false, false));

    // labelContent = new VerticalLayout();
    // labelContent.setMargin(new MarginInfo(true, false, true, false));

    headerLabel = "";

    // labelContent.addComponent(headerLabel);
    // projectview_content.addComponent(labelContent);

    projectview_tab = new TabSheet();
    projectview_tab.setWidth("100%");
    projectview_tab.setHeight("100%");

    datasetComponent = new DatasetComponent(datahandler, state, resourceUrl);
    biologicalSamplesComponent = new BiologicalSamplesComponent(datahandler, state, resourceUrl,
            "Biological Samples");
    measuredSamplesComponent = new LevelComponent(datahandler, state, resourceUrl, "Raw Data");
    resultsComponent = new LevelComponent(datahandler, state, resourceUrl, "Results");
    workflowComponent = new WorkflowComponent(wfController);
    uploadComponent = new AttachmentUploadComponent();
    projectInformation = new ProjInformationComponent(datahandler, state, resourceUrl);
    experimentComponent = new ExperimentComponent(datahandler, state, resourceUrl);

    // add styles to tab sheet
    projectview_tab.addStyleName(ValoTheme.TABSHEET_EQUAL_WIDTH_TABS);
    projectview_tab.addStyleName(ValoTheme.TABSHEET_FRAMED);
    // projectview_tab.addStyleName(ValoTheme.TABSHEET_PADDED_TABBAR);

    // add tabs to tabsheet
    projectview_tab.addTab(projectInformation).setIcon(FontAwesome.INFO_CIRCLE);
    projectview_tab.addTab(initGraphs()).setIcon(FontAwesome.SITEMAP);
    // projectview_tab.addTab(initMemberSection()).setIcon(FontAwesome.USERS);

    projectview_tab.addTab(experimentComponent).setIcon(FontAwesome.FLASK);
    projectview_tab.addTab(datasetComponent).setIcon(FontAwesome.DATABASE);
    projectview_tab.addTab(biologicalSamplesComponent).setIcon(FontAwesome.TINT);
    projectview_tab.addTab(measuredSamplesComponent).setIcon(FontAwesome.SIGNAL);
    projectview_tab.addTab(resultsComponent).setIcon(FontAwesome.TH_LARGE);
    projectview_tab.addTab(workflowComponent).setIcon(FontAwesome.COGS);
    projectview_tab.addTab(uploadComponent).setIcon(FontAwesome.UPLOAD);

    projectview_tab.setImmediate(true);

    projectview_tab.addSelectedTabChangeListener(new SelectedTabChangeListener() {

        @Override
        public void selectedTabChange(SelectedTabChangeEvent event) {
            if (event.getTabSheet().getSelectedTab().getCaption().equals("Project Graph")) {
                loadGraph();
            } else if (event.getTabSheet().getSelectedTab().getCaption().equals("Exp. Steps")) {
                experimentComponent.updateUI(getCurrentBean());
            } else if (event.getTabSheet().getSelectedTab().getCaption().equals("Datasets")) {
                datasetComponent.updateUI(navigateToLabel, getCurrentBean().getId());
            } else if (event.getTabSheet().getSelectedTab().getCaption().equals("Raw Data")) {
                measuredSamplesComponent.updateUI(navigateToLabel, getCurrentBean().getId(), "measured");
            } else if (event.getTabSheet().getSelectedTab().getCaption().equals("Biological Samples")) {
                biologicalSamplesComponent.updateUI(getCurrentBean().getId());
            } else if (event.getTabSheet().getSelectedTab().getCaption().equals("Results")) {
                resultsComponent.updateUI(navigateToLabel, getCurrentBean().getId(), "results");
            } else if (event.getTabSheet().getSelectedTab().getCaption().equals("Workflows")) {
                Map<String, String> args = new HashMap<String, String>();
                args.put("id", getCurrentBean().getId());
                args.put("type", navigateToLabel);
                workflowComponent.update(args);
            } else if (event.getTabSheet().getSelectedTab().getCaption().equals("Upload Files")) {
                // (get space from currentBean)
                uploadComponent.updateUI(manager, getCurrentBean().getCode(), currentBean.getId().split("/")[1],
                        datahandler.getOpenBisClient());
            } else if (event.getTabSheet().getSelectedTab().getCaption().equals("")) {
                projectInformation.updateUI(getCurrentBean(), "project");
            }
        }
    });

    // projectview_content.addComponent(initMenuBar());
    projectview_content.addComponent(projectview_tab);
    // projectview_content.addComponent(initDescription());
    // projectview_content.addComponent(initStatistics());
    // projectview_content.addComponent(initTable());
    // projectview_content.addComponent(initButtonLayout());

    // projectview_content.addComponent(initGraph());

    // use the component that is returned by initTable
    // projectview_content.setComponentAlignment(this.table, Alignment.TOP_CENTER);
    // projectview_content.setWidth("100%");
    this.addComponent(projectview_content);
}

From source file:de.uni_tuebingen.qbic.qbicmainportlet.SampleView.java

License:Open Source License

/**
 * init this view. builds the layout skeleton Menubar Description and others Statisitcs Experiment
 * Table Graph//  w w  w.  j  a  v a 2s.co m
 */
void initView() {
    setResponsive(true);
    setWidth(100, Unit.PERCENTAGE);

    sampview_content = new VerticalLayout();
    sampview_content.setMargin(new MarginInfo(true, true, false, false));
    sampview_content.setResponsive(true);

    sampview_tab = new TabSheet();
    sampview_tab.setResponsive(true);
    sampview_tab.setWidth(100, Unit.PERCENTAGE);
    sampview_tab.addStyleName(ValoTheme.TABSHEET_FRAMED);
    sampview_tab.addStyleName(ValoTheme.TABSHEET_EQUAL_WIDTH_TABS);
    sampview_tab.addStyleName(ValoTheme.TABSHEET_PADDED_TABBAR);

    header = "";

    datasetComponent = new DatasetComponent(datahandler, state, resourceUrl);
    changeMetaDataComponent = new ChangeMetadataComponent(datahandler, state, resourceUrl);

    sampview_tab.addTab(initDescription()).setIcon(FontAwesome.INFO_CIRCLE);
    // sampview_tab.addTab(initStatistics()).setIcon(FontAwesome.BAR_CHART_O);
    sampview_tab.addTab(datasetComponent).setIcon(FontAwesome.DATABASE);
    initNoteComponent();
    sampview_tab.addTab(innerNotesComponent).setIcon(FontAwesome.PENCIL);

    sampview_tab.setImmediate(true);

    sampview_tab.addSelectedTabChangeListener(new SelectedTabChangeListener() {

        /**
         * 
         */
        private static final long serialVersionUID = 6899763427531265769L;

        @Override
        public void selectedTabChange(SelectedTabChangeEvent event) {

            if (event.getTabSheet().getSelectedTab().getCaption().equals("Datasets")) {
                datasetComponent.updateUI(navigateToLabel, getCurrentBean().getId());
            }
        }
    });

    sampview_content.addComponent(sampview_tab);
    this.addComponent(sampview_content);
}

From source file:facs.components.BookAdmin.java

License:Open Source License

public BookAdmin(User user) {

    Date dNow = new Date();
    SimpleDateFormat ft = new SimpleDateFormat("dd.MM.yyyy hh:mm:ss");
    System.out.println(ft.format(dNow) + "  INFO  Calendar Admin accessed! - User: "
            + LiferayAndVaadinUtils.getUser().getScreenName());

    Label infoLabel = new Label(
            DBManager.getDatabaseInstance().getUserNameByUserID(LiferayAndVaadinUtils.getUser().getScreenName())
                    + "  " + LiferayAndVaadinUtils.getUser().getScreenName());
    infoLabel.addStyleName("h4");

    String buttonRefreshTitle = "Refresh";
    Button refresh = new Button(buttonRefreshTitle);
    refresh.setIcon(FontAwesome.REFRESH);
    refresh.setSizeFull();//from ww  w. ja  va2  s. c  o  m
    refresh.setDescription("Click here to reload the data from the database!");
    refresh.addStyleName(ValoTheme.BUTTON_FRIENDLY);

    String buttonUpdateTitle = "Update";
    Button updateUser = new Button(buttonUpdateTitle);
    updateUser.setIcon(FontAwesome.WRENCH);
    updateUser.setSizeFull();
    updateUser.setDescription("Click here to update your user role and group!");

    userDevice = new ListSelect("Select a device");
    userDevice.addItems(DBManager.getDatabaseInstance().getDeviceNames());
    userDevice.setRows(6);
    userDevice.setNullSelectionAllowed(false);
    userDevice.setSizeFull();
    userDevice.setImmediate(true);
    /*
     * userDevice.addValueChangeListener(e -> Notification.show("Device:",
     * String.valueOf(e.getProperty().getValue()), Type.TRAY_NOTIFICATION));
     */
    userGroup = new ListSelect("Select a user group");
    userGroup.addItems(DBManager.getDatabaseInstance().getUserGroups());
    userGroup.setRows(6);
    userGroup.setNullSelectionAllowed(false);
    userGroup.setSizeFull();
    userGroup.setImmediate(true);
    /*
     * userGroup.addValueChangeListener(e -> Notification.show("User Group:",
     * String.valueOf(e.getProperty().getValue()), Type.TRAY_NOTIFICATION));
     */
    userRole = new ListSelect("Select a user role");
    userRole.addItems(DBManager.getDatabaseInstance().getUserRoles());
    userRole.setRows(6);
    userRole.setNullSelectionAllowed(false);
    userRole.setSizeFull();
    userRole.setImmediate(true);
    /*
     * userRole.addValueChangeListener(e -> Notification.show("User Role:",
     * String.valueOf(e.getProperty().getValue()), Type.TRAY_NOTIFICATION));
     */
    refresh.addClickListener(new ClickListener() {
        private static final long serialVersionUID = -3610721151565496269L;

        @Override
        public void buttonClick(ClickEvent event) {
            refreshDataSources();
        }
    });

    updateUser.addClickListener(new ClickListener() {
        private static final long serialVersionUID = -3610721151565496909L;

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                if (userDevice.getValue().equals(null) || userRole.getValue().equals(null)
                        || userGroup.getValue().equals(null)) {
                    showErrorNotification("Something's missing!",
                            "Please make sure that you selected a Device, a Role and a Group! Each list has to have one highligthed option.'.");
                    // System.out.println("Device: "+userDevice.getValue()+" Group: "+userGroup.getValue()+" Role: "+userRole.getValue());
                } else {
                    DBManager.getDatabaseInstance().getShitDone(
                            DBManager.getDatabaseInstance().getUserRoleIDbyDesc(userRole.getValue().toString()),
                            DBManager.getDatabaseInstance()
                                    .getUserIDbyLDAPID(LiferayAndVaadinUtils.getUser().getScreenName()),
                            DBManager.getDatabaseInstance()
                                    .getDeviceIDByName(userDevice.getValue().toString()));

                    DBManager.getDatabaseInstance().getShitDoneAgain(
                            DBManager.getDatabaseInstance()
                                    .getUserGroupIDByName(userGroup.getValue().toString()),
                            LiferayAndVaadinUtils.getUser().getScreenName());

                }
            } catch (Exception e) {
                showErrorNotification("Something's missing!",
                        "Please make sure that you selected a Device, a Role and a Group! Each list has to have one highligthed option.'.");
            }
            refreshDataSources();
        }
    });

    // only admins are allowed to see the admin panel ;)
    if (!DBManager.getDatabaseInstance()
            .getUserAdminPanelAccessByLDAPId(LiferayAndVaadinUtils.getUser().getScreenName()).equals("1")) {
        VerticalLayout errorLayout = new VerticalLayout();
        infoLabel.setValue("ACCESS DENIED");
        errorLayout.addComponent(infoLabel);
        showErrorNotification("Access Denied!",
                "Sorry, you're not allowed to see anything here, at least your username told us so. Do you need assistance? Please contact 'info@qbic.uni-tuebingen.de'.");
        setCompositionRoot(errorLayout);
        return;
    }

    this.setCaption("Admin");

    final TabSheet bookAdmin = new TabSheet();
    bookAdmin.addStyleName(ValoTheme.TABSHEET_FRAMED);
    bookAdmin.addStyleName(ValoTheme.TABSHEET_EQUAL_WIDTH_TABS);

    ArrayList<String> deviceNames = new ArrayList<String>();
    deviceNames = DBManager.getDatabaseInstance().getDeviceNames();

    bookAdmin.addTab(awaitingRequestsGrid());

    for (int i = 0; i < deviceNames.size(); i++) {
        bookAdmin.addTab(newDeviceGrid(deviceNames.get(i)));
    }

    bookAdmin.addTab(deletedBookingsGrid());

    bookAdmin.addSelectedTabChangeListener(new SelectedTabChangeListener() {

        /**
         * 
         */
        private static final long serialVersionUID = 8987818794404251063L;

        @Override
        public void selectedTabChange(SelectedTabChangeEvent event) {
            userDevice.select(bookAdmin.getSelectedTab().getCaption());
            userRole.select(DBManager.getDatabaseInstance()
                    .getUserGroupDescriptionByLDAPId(LiferayAndVaadinUtils.getUser().getScreenName(), DBManager
                            .getDatabaseInstance().getDeviceIDByName(bookAdmin.getSelectedTab().getCaption())));
            userGroup.select(DBManager.getDatabaseInstance()
                    .getUserRoleNameByLDAPId(LiferayAndVaadinUtils.getUser().getScreenName()));

        }
    });

    gridLayout.setWidth("100%");

    // add components to the grid layout
    // gridLayout.addComponent(infoLabel, 0, 0, 3, 0);
    gridLayout.addComponent(bookAdmin, 0, 1, 5, 1);
    gridLayout.addComponent(refresh, 0, 2);
    gridLayout.addComponent(userDevice, 0, 4, 1, 4);
    gridLayout.addComponent(userRole, 2, 4, 3, 4);
    gridLayout.addComponent(userGroup, 4, 4, 5, 4);
    gridLayout.addComponent(updateUser, 0, 5, 5, 5);
    gridLayout.setSizeFull();

    gridLayout.setSpacing(true);
    setCompositionRoot(gridLayout);

    /*
     * JavaScript to update the Grid try { JDBCConnectionPool connectionPool = new
     * SimpleJDBCConnectionPool("com.mysql.jdbc.Driver",
     * "jdbc:mysql://localhost:8889/facs_facility", "facs", "facs"); QueryDelegate qd = new
     * FreeformQuery("select * from facs_facility", connectionPool, "id"); final SQLContainer c =
     * new SQLContainer(qd); bookAdmin.setContainerDataSource(c); }
     * 
     * JavaScript.getCurrent().execute("setInterval(function(){refreshTable();},5000);");
     * JavaScript.getCurrent().addFunction("refreshTable", new JavaScriptFunction() {
     * 
     * @Override public void call(JsonArray arguments) { // TODO Auto-generated method stub
     * 
     * } });
     */

}

From source file:facs.components.Booking.java

License:Open Source License

public Booking(final BookingModel bookingModel, Date referenceDate) {

    String[] sayHello = { "Kon'nichiwa", "Hello", "Halo", "Hiya", "Hej", "Hallo", "Hola", "Grezi", "Servus",
            "Merhaba", "Bonjour", "Ahoj", "Moi", "Ciao", "Buongiorno" };

    this.bookingModel = bookingModel;
    this.referenceDate = referenceDate;

    Label infoLabel = new Label();
    infoLabel.addStyleName("h4");

    Label selectDeviceLabel = new Label();
    selectDeviceLabel.addStyleName("h4");
    selectDeviceLabel.setValue("Please Select a Device");

    final Label versionLabel = new Label();
    versionLabel.addStyleName("h4");
    versionLabel.setValue("Version 0.1.160727");

    // showSuccessfulNotification(sayHello[(int) (Math.random() * sayHello.length)] + ", "
    // + bookingModel.userName() + "!", "");

    Date dNow = new Date();
    SimpleDateFormat ft = new SimpleDateFormat("dd.MM.yyyy hh:mm:ss");
    System.out.println(ft.format(dNow) + "  INFO  Calendar initiated! - User: " + bookingModel.getLDAP() + " "
            + versionLabel);/*from   w  ww  . j  a v  a2  s .com*/

    // only users who are allowed to book devices will be able to do so
    if (bookingModel.isNotAllowed()) {
        VerticalLayout errorLayout = new VerticalLayout();
        infoLabel.setValue("ACCESS DENIED");
        errorLayout.addComponent(infoLabel);
        showErrorNotification("Access Denied!",
                "Sorry, you're not allowed to see anything here, at least your username told us so. Do you need assistance? Please contact 'info@qbic.uni-tuebingen.de'.");
        setCompositionRoot(errorLayout);
        return;
    }

    Panel book = new Panel();
    book.addStyleName(ValoTheme.PANEL_BORDERLESS);

    DBManager.getDatabaseInstance();
    db = Database.Instance;
    db.userLogin(bookingModel.getLDAP());
    selectedDevice = initCalendars(bookingModel.getDevicesNames());

    selectedService = new NativeSelect("Please select a service:");
    selectedService.setDescription("Please select the service you would like to receive!");

    selectedKostenstelle = new NativeSelect("Please select konstenstelle:");
    selectedKostenstelle.setDescription("Please select the Kostenstelle you would like to use!");

    selectedDevice.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 8153818693511960689L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            versionLabel.setValue(db.getUserRoleDescByLDAPId(bookingModel.getLDAP(), getCurrentDevice()));

            selectedKostenstelle.setVisible(true);

            if (bookMap.containsKey(getCurrentDevice())) {
                cal.removeAllComponents();
                setCalendar();

                if (selectedDevice.getValue().equals("Aria")) {
                    selectedService.removeAllItems();
                    selectedService.addItems("Full Service", "Partial Service", "Self Service");
                    selectedService.setValue("Full Service");
                    selectedService.setVisible(true);
                } else if (selectedDevice.getValue().equals("Mac")) {
                    selectedService.removeAllItems();
                    selectedService.addItems("Self", "Service");
                    selectedService.setValue("Service");
                    selectedService.setVisible(true);
                } else {
                    selectedService.setValue(null);
                    selectedService.setVisible(false);
                }

            } else {

                bookMap.put(getCurrentDevice(), initCal(bookingModel, getCurrentDevice()));
                cal.removeAllComponents();
                setCalendar();

                if (selectedDevice.getValue().equals("Aria")) {
                    selectedService.removeAllItems();
                    selectedService.addItems("Full Service", "Partial Service", "Self Service");
                    selectedService.setValue("Full Service");
                    selectedService.setVisible(true);
                } else if (selectedDevice.getValue().equals("Mac")) {
                    selectedService.removeAllItems();
                    selectedService.addItems("Self", "Service");
                    selectedService.setValue("Service");
                    selectedService.setVisible(true);
                } else {
                    selectedService.setValue(null);
                    selectedService.setVisible(false);
                }
            }
        }
    });

    if (bookingModel.getProject().isEmpty()) {
        infoLabel.setValue(bookingModel.userName() + "  Kostenstelle: " + bookingModel.getKostenstelle()
                + "  Institute: " + bookingModel.getInstitute());

    } else {
        infoLabel.setValue(bookingModel.userName() + "  Kostenstelle: " + bookingModel.getKostenstelle()
                + "  Project: " + bookingModel.getProject() + "  Institute: "
                + bookingModel.getInstitute());
    }

    // bookDeviceLayout.addComponent(infoLabel);
    cal.setLocale(Locale.getDefault());
    cal.setImmediate(true);
    selectedService.setImmediate(true);
    cal.setSizeFull();

    String submitTitle = "Book";
    Button submit = new Button(submitTitle);
    submit.setIcon(FontAwesome.CALENDAR);
    submit.setDescription("Please select a device and a time frame at first then click 'BOOK'!");
    submit.setSizeFull();

    // submit.setVisible(false);

    submit.addClickListener(new ClickListener() {
        private static final long serialVersionUID = -3610721151565496269L;

        @Override
        public void buttonClick(ClickEvent event) {
            submit(bookingModel.getLDAP(), getCurrentDevice());
            newEvents.clear();
            refreshDataSources();
        }
    });

    String buttonTitle = "Refresh";
    Button refresh = new Button(buttonTitle);
    refresh.setIcon(FontAwesome.REFRESH);
    refresh.setSizeFull();
    refresh.setDescription("Click here to reload the data from the database!");
    refresh.addStyleName(ValoTheme.BUTTON_FRIENDLY);

    refresh.addClickListener(new ClickListener() {
        private static final long serialVersionUID = -3610721151565496269L;

        @Override
        public void buttonClick(ClickEvent event) {

            refreshDataSources();

        }
    });

    gridLayout.setWidth("100%");
    // add components to the grid layout
    gridLayout.addComponent(infoLabel, 0, 4, 3, 4);
    gridLayout.addComponent(versionLabel, 4, 4, 5, 4);

    // gridLayout.addComponent(selectDeviceLabel,0,1);
    gridLayout.addComponent(selectedDevice, 0, 0);
    gridLayout.addComponent(selectedService, 1, 0);
    gridLayout.addComponent(selectedKostenstelle, 2, 0);
    selectedService.setVisible(false);

    gridLayout.addComponent(cal, 0, 2, 5, 2);

    gridLayout.addComponent(refresh, 0, 3);
    gridLayout.addComponent(submit, 1, 3, 5, 3);

    // gridLayout.addComponent(myBookings(), 0, 5, 5, 5);

    gridLayout.setMargin(true);
    gridLayout.setSpacing(true);
    gridLayout.setSizeFull();

    book.setContent(gridLayout);

    booking = new TabSheet();

    booking.addStyleName(ValoTheme.TABSHEET_FRAMED);
    booking.addTab(book).setCaption("Calendar");
    booking.addTab(myNext24HoursBookings()).setCaption("Next 24 Hours");
    booking.addTab(myUpcomingBookings()).setCaption("Upcoming");
    booking.addTab(myPastBookings()).setCaption("Past Bookings");
    // booking.addTab(myUpcomingBookingsSQLContainer()).setCaption("Test");
    setCompositionRoot(booking);

}

From source file:facs.components.Settings.java

License:Open Source License

public Settings(User user) {

    Date dNow = new Date();
    SimpleDateFormat ft = new SimpleDateFormat("dd.MM.yyyy hh:mm:ss");
    System.out.println(ft.format(dNow) + "  INFO  Settings accessed! - User: "
            + LiferayAndVaadinUtils.getUser().getScreenName());

    this.setCaption("Settings");
    TabSheet settings = new TabSheet();
    settings.addStyleName(ValoTheme.TABSHEET_FRAMED);

    // TODO: a new device functionality is temporarily removed from the user interface
    // settings.addTab(newDeviceGrid());

    // upload csv files of devices
    settings.addTab(new UploadBox());

    setCompositionRoot(settings);//ww w  . j  a v a  2 s.c o  m
}

From source file:facs.components.Statistics.java

License:Open Source License

private void init() {

    TabSheet statistics = new TabSheet();

    statistics.addStyleName(ValoTheme.TABSHEET_FRAMED);
    statistics.addTab(newMatchedGrid()).setCaption("Matched");
    statistics.addTab(initialGrid()).setCaption("Not Matched");

    setCompositionRoot(statistics);//from w  w  w.  j av a  2 s. c o m

}

From source file:facs.components.UserAdmin.java

License:Open Source License

public UserAdmin(User user) {

    Date dNow = new Date();
    SimpleDateFormat ft = new SimpleDateFormat("dd.MM.yyyy hh:mm:ss");
    System.out.println(ft.format(dNow) + "  INFO  Calendar User Manager accessed! - User: "
            + LiferayAndVaadinUtils.getUser().getScreenName());

    Label infoLabel = new Label(
            DBManager.getDatabaseInstance().getUserNameByUserID(LiferayAndVaadinUtils.getUser().getScreenName())
                    + "  " + LiferayAndVaadinUtils.getUser().getScreenName());
    infoLabel.addStyleName("h4");

    CheckBox isAdmin = new CheckBox("user has admin panel access");
    isAdmin.setEnabled(false);/* w ww.j a va  2 s.  com*/

    String buttonGroupUpdateTitle = "Edit Group";
    Button updateUserGroup = new Button(buttonGroupUpdateTitle);
    updateUserGroup.setIcon(FontAwesome.EDIT);
    updateUserGroup.setSizeFull();
    updateUserGroup.setDescription("Click here to update the group of the user!");

    String buttonWorkgroupUpdateTitle = "Edit Workgroup";
    Button updateUserWorkgroup = new Button(buttonWorkgroupUpdateTitle);
    updateUserWorkgroup.setIcon(FontAwesome.EDIT);
    updateUserWorkgroup.setSizeFull();
    updateUserWorkgroup.setDescription("Click here to update the workgroup of the user!");

    String buttonUpdateTitle = "Update (user role & group for device)";
    Button updateUserRightsAndRoles = new Button(buttonUpdateTitle);
    updateUserRightsAndRoles.setIcon(FontAwesome.WRENCH);
    updateUserRightsAndRoles.setSizeFull();
    updateUserRightsAndRoles.setDescription("Click here to update the user's role and group for a device!");

    String buttonTitle = "Refresh";
    Button refresh = new Button(buttonTitle);
    refresh.setIcon(FontAwesome.REFRESH);
    refresh.setSizeFull();
    refresh.setDescription("Click here to reload the data from the database!");
    refresh.addStyleName(ValoTheme.BUTTON_FRIENDLY);

    // String buttonTitleSave = "Save";
    // Button save = new Button(buttonTitleSave);
    // save.setIcon(FontAwesome.SAVE);
    // save.setSizeFull();
    // save.setDescription("Click here to save all changes!");
    // save.addStyleName(ValoTheme.BUTTON_BORDERLESS);

    userDevice = new ListSelect("Devices");
    userDevice.addItems(DBManager.getDatabaseInstance().getDeviceNames());
    userDevice.setRows(6);
    userDevice.setNullSelectionAllowed(false);
    userDevice.setSizeFull();
    userDevice.setImmediate(true);
    /*
     * userDevice.addValueChangeListener(e -> Notification.show("Device:",
     * String.valueOf(e.getProperty().getValue()), Type.TRAY_NOTIFICATION));
     */
    userGroup = new ListSelect("User Groups");
    userGroup.addItems(DBManager.getDatabaseInstance().getUserGroups());
    userGroup.addItem("N/A");
    userGroup.setRows(6);
    userGroup.setNullSelectionAllowed(false);
    userGroup.setSizeFull();
    userGroup.setImmediate(true);
    /*
     * userGroup.addValueChangeListener(e -> Notification.show("User Group:",
     * String.valueOf(e.getProperty().getValue()), Type.TRAY_NOTIFICATION));
     */
    userRole = new ListSelect("User Roles");
    userRole.addItems(DBManager.getDatabaseInstance().getUserRoles());
    userRole.addItem("N/A");
    userRole.setRows(6);
    userRole.setNullSelectionAllowed(false);
    userRole.setSizeFull();
    userRole.setImmediate(true);
    /*
     * userRole.addValueChangeListener(e -> Notification.show("User Role:",
     * String.valueOf(e.getProperty().getValue()), Type.TRAY_NOTIFICATION));
     */
    userWorkgroup = new ListSelect("Workgroups");
    userWorkgroup.addItems(DBManager.getDatabaseInstance().getUserWorkgroups());
    userWorkgroup.setRows(6);
    userWorkgroup.setNullSelectionAllowed(false);
    userWorkgroup.setSizeFull();
    userWorkgroup.setImmediate(true);
    /*
     * userRole.addValueChangeListener(e -> Notification.show("User Role:",
     * String.valueOf(e.getProperty().getValue()), Type.TRAY_NOTIFICATION));
     */

    Button updateUser = new Button(buttonTitle);
    updateUser.setIcon(FontAwesome.WRENCH);
    updateUser.setDescription("Click here to update your user role and group!");

    refresh.addClickListener(new ClickListener() {
        private static final long serialVersionUID = -3610721151565496269L;

        @Override
        public void buttonClick(ClickEvent event) {
            refreshDataSources();
        }
    });

    updateUser.addClickListener(new ClickListener() {
        private static final long serialVersionUID = -3610721151565496909L;

        @Override
        public void buttonClick(ClickEvent event) {
            refreshDataSources();
        }
    });

    updateUserWorkgroup.addClickListener(new ClickListener() {

        /**
         * 
         */
        private static final long serialVersionUID = -295434651623561492L;

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                Object selectedRow = ((SingleSelectionModel) usersGrid.getSelectionModel()).getSelectedRow();

                if (selectedRow == null || userWorkgroup.getValue().equals(null)) {
                    Notification("Something's missing!",
                            "Please make sure that you selected the user and workgroup! Make sure they are highligthed.",
                            "error");
                } else {
                    DBManager.getDatabaseInstance().adminUpdatesUserWorkgroup(
                            DBManager.getDatabaseInstance()
                                    .getUserGroupIDByName(userWorkgroup.getValue().toString()),
                            DBManager.getDatabaseInstance().getUserLDAPIDbyID(selectedRow.toString()));

                    // log changes in 'user_log' table
                    DBManager.getDatabaseInstance().logEverything(
                            LiferayAndVaadinUtils.getUser().getScreenName(), "Admin edited Workgroup");

                    Notification("Successfully Updated",
                            "Selected values are updated in the database. If it was a mistake, please remind that there is no 'undo' functionality yet.",
                            "success");

                }
            } catch (Exception e) {
                Notification("Something's missing!",
                        "Please make sure that you selected the user and workgroup! Make sure they are highligthed.",
                        "error");
            }
            refreshDataSources();
        }
    });

    updateUserGroup.addClickListener(new ClickListener() {

        /**
         * 
         */
        private static final long serialVersionUID = -5539382755814626288L;

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                Object selectedRow = ((SingleSelectionModel) usersGrid.getSelectionModel()).getSelectedRow();

                if (selectedRow == null || userWorkgroup.getValue().equals(null)) {
                    Notification("Something's missing!",
                            "Please make sure that you selected the user and group! Make sure they are highligthed.",
                            "error");
                } else {
                    DBManager.getDatabaseInstance().adminUpdatesUserGroup(
                            DBManager.getDatabaseInstance()
                                    .getUserGroupIDByName(userGroup.getValue().toString()),
                            DBManager.getDatabaseInstance().getUserIDbyLDAPID(selectedRow.toString()));

                    // log changes in 'user_log' table
                    DBManager.getDatabaseInstance().logEverything(
                            LiferayAndVaadinUtils.getUser().getScreenName(), "Admin edited User Group");

                    Notification("Successfully Updated",
                            "Selected values are updated in the database. If it was a mistake, please remind that there is no 'undo' functionality yet.",
                            "success");

                }
            } catch (Exception e) {
                Notification("Something's missing!",
                        "Please make sure that you selected the user and group! Make sure they are highligthed.",
                        "error");
            }
            refreshDataSources();
        }
    });

    updateUserRightsAndRoles.addClickListener(new ClickListener() {

        /**
         * 
         */
        private static final long serialVersionUID = -295434651623561492L;

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                Object selectedRow = ((SingleSelectionModel) usersGrid.getSelectionModel()).getSelectedRow();

                if (selectedRow == null || userDevice.getValue().equals(null)
                        || userRole.getValue().equals(null)) {
                    Notification("Something's missing!",
                            "Please make sure that you selected the user, device and role! Each list has to have one highligthed option.",
                            "error");
                } else {
                    DBManager.getDatabaseInstance().adminUpdatesUserRoleForDevice(
                            DBManager.getDatabaseInstance().getUserRoleIDbyDesc(userRole.getValue().toString()),
                            DBManager.getDatabaseInstance().getUserIDbyLDAPID(
                                    DBManager.getDatabaseInstance().getUserLDAPIDbyID(selectedRow.toString())),
                            DBManager.getDatabaseInstance()
                                    .getDeviceIDByName(userDevice.getValue().toString()));

                    // log changes in 'user_log' table
                    DBManager.getDatabaseInstance().logEverything(
                            LiferayAndVaadinUtils.getUser().getScreenName(),
                            "Admin edited Device, Role, Group");

                    Notification("Successfully Updated",
                            "Selected values are updated in the database. If it was a mistake, please remind that there is no 'undo' functionality yet.",
                            "success");

                }
            } catch (Exception e) {
                Notification("Something's missing!",
                        "Please make sure that you selected the user, device and role! Each list has to have one highligthed option.",
                        "error");
            }
            refreshDataSources();
        }
    });

    try {
        TableQuery tq = new TableQuery("user", DBManager.getDatabaseInstanceAlternative());
        tq.setVersionColumn("OPTLOCK");
        SQLContainer container = new SQLContainer(tq);

        // System.out.println("Print Container: " + container.size());
        container.setAutoCommit(isEnabled());

        usersGrid = new Grid(container);

        FieldGroup fieldGroup = usersGrid.getEditorFieldGroup();
        fieldGroup.addCommitHandler(new FieldGroup.CommitHandler() {
            /**
             * 
             */
            private static final long serialVersionUID = 3799806709907688919L;

            @Override
            public void preCommit(FieldGroup.CommitEvent commitEvent) throws FieldGroup.CommitException {

            }

            @Override
            public void postCommit(FieldGroup.CommitEvent commitEvent) throws FieldGroup.CommitException {

                Notification("Successfully Updated",
                        "Selected values are updated in the database. If it was a mistake, please remind that there is no 'undo' functionality yet.",
                        "success");

                refreshGrid();
            }

            private void refreshGrid() {
                container.refresh();
            }

        });

        usersGrid.addSelectionListener(selectionEvent -> { // Java 8
            // Get selection from the selection model
            Object selected = ((SingleSelectionModel) usersGrid.getSelectionModel()).getSelectedRow();

            if (selected != null) {

                // userDevice.select(bookAdmin.getSelectedTab().getCaption());
                userWorkgroup.select(DBManager.getDatabaseInstance().getUserWorkgroupByUserId(usersGrid
                        .getContainerDataSource().getItem(selected).getItemProperty("user_id").toString()));
                userGroup.select(DBManager.getDatabaseInstance().getUserRoleByUserId(usersGrid
                        .getContainerDataSource().getItem(selected).getItemProperty("user_id").toString()));

                userDevice.addValueChangeListener(new ValueChangeListener() {

                    /**
                     * 
                     */
                    private static final long serialVersionUID = -8696555155016720475L;

                    @Override
                    public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
                        userRole.select(
                                DBManager.getDatabaseInstance().getUserGroupDescriptionByUserID(
                                        usersGrid.getContainerDataSource().getItem(selected)
                                                .getItemProperty("user_id").toString(),
                                        userDevice.getValue().toString()));

                    }
                });

                isAdmin.setValue(DBManager.getDatabaseInstance().hasAdminPanelAccess(usersGrid
                        .getContainerDataSource().getItem(selected).getItemProperty("user_id").toString()));

                Notification.show("Selected "
                        + usersGrid.getContainerDataSource().getItem(selected).getItemProperty("user_id"));
            } else
                Notification.show("Nothing selected");
        });

    } catch (Exception e) {
        // TODO Auto-generated catch block
        Notification("Something went wrong!",
                "Unable to update/connect the database. There may be a connection problem, please check your internet connection settings then try it again.",
                "error");
        e.printStackTrace();
    }

    /*
     * // only admins are allowed to see the admin panel ;) if (!DBManager.getDatabaseInstance()
     * .getUserAdminPanelAccessByLDAPId(LiferayAndVaadinUtils.getUser().getScreenName())
     * .equals("1")) { VerticalLayout errorLayout = new VerticalLayout();
     * infoLabel.setValue("ACCESS DENIED"); errorLayout.addComponent(infoLabel);
     * showErrorNotification( "Access Denied!",
     * "Sorry, you're not allowed to see anything here, at least your username told us so. Do you need assistance? Please contact 'info@qbic.uni-tuebingen.de'."
     * ); setCompositionRoot(errorLayout); return; }
     */

    this.setCaption("User Manager");

    final TabSheet userAdmin = new TabSheet();
    userAdmin.addStyleName(ValoTheme.TABSHEET_FRAMED);
    userAdmin.addTab(usersGrid());
    /*
     * userAdmin.addSelectedTabChangeListener(new SelectedTabChangeListener() {
     * 
     * @Override public void selectedTabChange(SelectedTabChangeEvent event) {
     * 
     * } });
     */

    gridLayout.setWidth("100%");

    // add components to the grid layout
    // gridLayout.addComponent(infoLabel, 0, 0, 3, 0);
    gridLayout.addComponent(userAdmin, 0, 1, 5, 1);
    gridLayout.addComponent(refresh, 0, 2);
    gridLayout.addComponent(isAdmin, 5, 2);
    // gridLayout.addComponent(save);

    gridLayout.addComponent(userWorkgroup, 0, 4);
    gridLayout.addComponent(userDevice, 1, 4);
    gridLayout.addComponent(userRole, 2, 4, 4, 4);
    gridLayout.addComponent(userGroup, 5, 4);
    gridLayout.addComponent(updateUserWorkgroup, 0, 5);
    gridLayout.addComponent(updateUserRightsAndRoles, 1, 5, 4, 5);
    gridLayout.addComponent(updateUserGroup, 5, 5);
    // gridLayout.addComponent(newContainerGrid, 1, 4);

    gridLayout.setSpacing(true);
    gridLayout.setSizeFull();
    setCompositionRoot(gridLayout);

}

From source file:fr.univlorraine.mondossierweb.MainUI.java

License:Apache License

/**
 * @see com.vaadin.ui.UI#init(com.vaadin.server.VaadinRequest)
 *//*from  w w w.j a v a2s  .c  o  m*/
@Override
protected void init(VaadinRequest request) {

    LOG.debug("init(); mainUI");

    if (PropertyUtils.isPushEnabled() && !PropertyUtils.isWebSocketPushEnabled()) {
        getPushConfiguration().setTransport(Transport.LONG_POLLING);
    }

    //Gestion des erreurs
    VaadinSession.getCurrent().setErrorHandler(e -> {
        Throwable cause = e.getThrowable();
        while (cause instanceof Throwable) {
            /* Gre les accs non autoriss */
            if (cause instanceof AccessDeniedException) {
                Notification.show(cause.getMessage(), Type.ERROR_MESSAGE);
                displayViewFullScreen(AccesRefuseView.NAME);
                return;
            }
            if (cause != null && cause.getClass() != null) {
                String simpleName = cause.getClass().getSimpleName();
                if (PropertyUtils.getListeErreursAIgnorer().contains(simpleName)) {
                    Notification.show(cause.getMessage(), Type.ERROR_MESSAGE);
                    displayViewFullScreen(ErreurView.NAME);
                    return;
                }
            }
            cause = cause.getCause();
        }
        // Traite les autres erreurs normalement 
        LOG.error(e.getThrowable().toString(), e.getThrowable());
        // Affiche de la vue d'erreur
        displayViewFullScreen(ErreurView.NAME);
        //DefaultErrorHandler.doDefault(e);
    });

    // Affiche le nom de l'application dans l'onglet du navigateur 
    getPage().setTitle(environment.getRequiredProperty("app.name"));

    //Gestion de l'acces a un dossier prcis via url deepLinking (ne peut pas tre fait dans navigator 
    //car le fragment ne correspond pas  une vue existante)
    getPage().addUriFragmentChangedListener(new UriFragmentChangedListener() {
        public void uriFragmentChanged(UriFragmentChangedEvent source) {

            //Si l'application est en maintenance on bloque l'accs
            if (!applicationActive() && !source.getUriFragment().contains(AccesBloqueView.NAME)
                    && !(source.getUriFragment().contains(AdminView.NAME) && userController.isAdmin())) {

                displayViewFullScreen(AccesBloqueView.NAME);
            } else {

                if (source.getUriFragment().contains("accesDossierEtudiant") && userController.isEnseignant()) {
                    rechercheController.accessToDossierEtudiantDeepLinking(source.getUriFragment());

                } /*else{
                    if(source.getUriFragment().contains("accesNotesEtudiant") 
                  && userController.isEnseignant()){
                       rechercheController.accessToDossierEtudiantDeepLinking(source.getUriFragment());
                       navigator.navigateTo(NotesView.NAME);
                    }
                  }*/

            }
        }
    });

    //Paramtrage du comportement en cas de perte de connexion
    configReconnectDialog();

    /* Construit le gestionnaire de vues utilis par la barre d'adresse et pour naviguer dans le dossier d'un tudiant */
    navigator.addProvider(viewProvider);
    navigator.setErrorProvider(new ViewProvider() {
        @Override
        public String getViewName(final String viewAndParameters) {
            return ErreurView.NAME;
        }

        @Override
        public View getView(final String viewName) {
            return viewProvider.getView(ErreurView.NAME);
        }
    });

    navigator.addViewChangeListener(new ViewChangeListener() {
        private static final long serialVersionUID = 7905379446201794289L;

        private static final String SELECTED_ITEM = "selected";

        @Override
        public boolean beforeViewChange(ViewChangeEvent event) {

            //Avant de se rendre sur une vue, on supprime le style "selected" des objets du menu
            viewButtons.values().forEach(button -> button.removeStyleName(SELECTED_ITEM));

            //Si on tente d'accder  la vue admin et que l'utilisateur est admin
            if (event.getViewName().equals(AdminView.NAME) && userController.userCanAccessAdminView()) {
                //Afficher la vue admin
                setContent(adminView);
                return true;
            }

            //Si l'application est en maintenance on bloque l'accs
            if (!applicationActive() && !event.getViewName().equals(AccesBloqueView.NAME)) {
                displayViewFullScreen(AccesBloqueView.NAME);
                return false;
            }

            //On bloque l'accs aux vues mobile
            if (!Utils.isViewDesktop(event.getViewName())) {
                return false;
            }
            //On bloque l'accs aux vues enseignants
            if (Utils.isViewEnseignant(event.getViewName())) {
                //Si utilisateur n'est pas enseignant
                if (!userController.isEnseignant()) {
                    //acces bloque
                    return false;
                } else {
                    //Affichage de la vue enseignant demande
                    if (event.getViewName().equals(FavorisView.NAME)) {
                        navigateToFavoris();
                        return true;
                    }
                    if (event.getViewName().equals(ListeInscritsView.NAME)) {
                        navigateToListeInscrits(null);
                        return true;
                    }
                    if (event.getViewName().equals(RechercheRapideView.NAME)) {
                        navigateToRechercheRapide();
                        return true;
                    }
                    if (event.getViewName().equals(RechercheArborescenteView.NAME)) {
                        navigateToRechercheArborescente(null);
                        return true;
                    }

                    return false; //la vue enseignant demande n'est pas gr (ex :vue mobile appele depuis la version desktop)
                }
            }

            return true;
        }

        @Override
        public void afterViewChange(ViewChangeEvent event) {

            //On rcupre l'lment du menu concern par la vue  afficher
            Button button = viewButtons.get(event.getViewName());

            if (button instanceof Button) {
                //on applique le style "selected" sur l'objet du menu concern par la vue affiche
                button.addStyleName(SELECTED_ITEM);
            }
        }
    });

    //init du tracker
    initAnalyticsTracker();

    //mainVerticalLayout est le contenu principal de la page
    setContent(mainVerticalLayout);

    //Si utilisateur enseignant ou tudiant
    if (userController.isEnseignant() || userController.isEtudiant()) {

        if (!applicationActive()) {
            displayViewFullScreen(AccesBloqueView.NAME);
        } else {
            //On rcupre l'IP du client
            GenericUI.getCurrent().getIpClient();
            /* Parametre le layoutDossierEtudiant */
            menuLayout.setPrimaryStyleName(ValoTheme.MENU_ROOT);
            //Le contentLayout est scrollable si besoin
            contentLayout.addStyleName("v-scrollable");
            //contentLayout prend toute la place possible
            contentLayout.setSizeFull();
            //le contentLayout prend toute la place disponible dans le layoutDossierEtudiant
            layoutDossierEtudiant.setExpandRatio(contentLayout, 1);
            //layoutDossierEtudiant prend toute la place possible
            layoutDossierEtudiant.setSizeFull();

            //Si user enseignant
            if (userController.isEnseignant()) {
                //On consultera les notes en vue enseignant
                vueEnseignantNotesEtResultats = true;

                //Construit le menu horizontal pour les enseignants
                tabSheetGlobal.setSizeFull();
                tabSheetGlobal.addStyleName(ValoTheme.TABSHEET_FRAMED);

                rangTabRecherche = 0;
                rangTabDossierEtudiant = 1;

                //ajout de l'onglet principal 'recherche'
                layoutOngletRecherche = new VerticalLayout();
                ajoutOngletRecherche();
                layoutOngletRecherche.setSizeFull();
                tabSheetGlobal.addTab(layoutOngletRecherche,
                        applicationContext.getMessage("mainUI.recherche.title", null, getLocale()),
                        FontAwesome.SEARCH);

                //ajout de l'onglet principal 'assistance'
                tabSheetGlobal.addTab(assistanceView,
                        applicationContext.getMessage(assistanceView.NAME + ".title", null, getLocale()),
                        FontAwesome.SUPPORT);

                //ajout de l'onglet dossier tudiant
                addTabDossierEtudiant();

                //Ce tabSheet sera align  droite
                tabSheetGlobal.addStyleName("right-aligned-tabs");

                //Le menu horizontal pour les enseignants est dfinit comme tant le contenu de la page
                mainVerticalLayout.addComponent(tabSheetGlobal);
                mainVerticalLayout.setSizeFull();
                mainVerticalLayout.setExpandRatio(tabSheetGlobal, 1);
            } else {
                //On consultera les notes en vue etudiant
                vueEnseignantNotesEtResultats = false;

                //User Etudiant
                //Le Dossier est dfinit comme tant le contenu de la page
                mainVerticalLayout.addComponent(layoutDossierEtudiant);
                mainVerticalLayout.setSizeFull();
                mainVerticalLayout.setExpandRatio(layoutDossierEtudiant, 1);

                //On renseigne l'tudiant dont on consulte le dossier
                //Rcupration du cod_etu
                etudiant = new Etudiant(
                        daoCodeLoginEtudiant.getCodEtuFromLogin(userController.getCurrentUserName()));
                LOG.debug("MainUI etudiant : " + MainUI.getCurrent().getEtudiant().getCod_etu());
                //Rcupration de l'tat-civil (et les adresses)
                etudiantController.recupererEtatCivil();
                //On construit le menu affich  l'tudiant
                buildMainMenuEtudiant();
            }

            /* Enregistre l'UI pour la rception de notifications */
            uiController.registerUI(this);

            boolean navigationComplete = false;
            String fragment = Page.getCurrent().getUriFragment();
            if (fragment != null && !fragment.isEmpty()) {
                //Cas de l'appel initial de l'application via l'url vers la vue admin (sinon le cas est grer dans le listener du navigator
                if (fragment.contains("adminView") && userController.userCanAccessAdminView()) {
                    //Afficher la vue admin
                    navigator.navigateTo(AdminView.NAME);
                    navigationComplete = true;
                }
                if (fragment.contains("accesDossierEtudiant") && userController.isEnseignant()) {
                    rechercheController.accessToDossierEtudiantDeepLinking(fragment);
                    navigationComplete = true;
                }
                /*if(fragment.contains("accesNotesEtudiant") && userController.isEnseignant()){
                   rechercheController.accessToDossierEtudiantDeepLinking(fragment);
                   navigator.navigateTo(NotesView.NAME);
                   navigationComplete=true;
                }*/
            }

            if (!navigationComplete) {
                //PROBLEME DU F5 : on passe ici (init()) que quand on reinitialise l'UI ou en cas d'erreur. 
                //On ne peut donc pas rediriger vers des vues qui utilisent des variables non initialises (ex : Main.getCurrent.getEtudiant)
                if (!applicationActive()) {
                    displayViewFullScreen(AccesBloqueView.NAME);
                } else {
                    //Si utilisateur enseignant
                    if (userController.isEnseignant()) {
                        //Rcupration des favoris pour l'utilisateur
                        List<Favoris> lfav = favorisController.getFavoris();
                        if (lfav != null && lfav.size() > 0) {
                            //On affiche la vue des favoris
                            navigator.navigateTo(FavorisView.NAME);
                        } else {
                            //On affiche la vue de recherche rapide
                            navigator.navigateTo(RechercheRapideView.NAME);
                        }
                        //Affichage du message d'intro si besoin
                        afficherMessageIntroEnseignants(false, true);
                    } else {
                        //Si utilisateur tudiant
                        if (userController.isEtudiant()) {
                            //On affiche la vue de l'tat-civil
                            navigator.navigateTo(EtatCivilView.NAME);
                            //Affichage du message d'intro si besoin
                            afficherMessageIntroEtudiants();
                        } else {
                            //On affiche la vue d'erreur
                            displayViewFullScreen(ErreurView.NAME);
                        }
                    }
                }
            }
        }
    } else {
        //Si utilisateur n'est ni enseignant, ni tudiant
        //On affiche la vue accs refus
        displayViewFullScreen(AccesRefuseView.NAME);
    }
}

From source file:fr.univlorraine.mondossierweb.views.AdminView.java

License:Apache License

/**
 * Initialise la vue/*from w  ww.  j ava 2s .  c om*/
 */
@PostConstruct
public void init() {
    //On vrifie le droit d'accder  la vue
    if (userController.userCanAccessAdminView()) {
        removeAllComponents();
        /* Style */
        setMargin(true);
        setSpacing(true);

        /* En-tete menu large */
        topLayout = new HorizontalLayout();
        topLayout.addStyleName(ValoTheme.MENU_TITLE);
        topLayout.setWidth(100, Unit.PERCENTAGE);
        topLayout.setSpacing(true);

        Label Apptitle = new Label(environment.getRequiredProperty("app.name"));
        Apptitle.addStyleName(ValoTheme.LABEL_HUGE);
        Apptitle.addStyleName(ValoTheme.LABEL_BOLD);

        Label versionLabel = new Label("v" + environment.getRequiredProperty("app.version"));
        versionLabel.addStyleName(ValoTheme.LABEL_TINY);

        VerticalLayout appTitleLayout = new VerticalLayout(Apptitle, versionLabel);
        topLayout.addComponent(appTitleLayout);
        topLayout.setComponentAlignment(appTitleLayout, Alignment.MIDDLE_LEFT);
        topLayout.setExpandRatio(appTitleLayout, 1);

        addComponent(topLayout);

        // Titre 
        /*Label title = new Label(applicationContext.getMessage(NAME + ".title", null, getLocale()));
        title.addStyleName(ValoTheme.LABEL_H1);
        addComponent(title);*/

        // Texte 
        //addComponent(new Label(applicationContext.getMessage(NAME + ".message", null, getLocale()), ContentMode.HTML));

        tabSheetGlobal = new TabSheet();
        tabSheetGlobal.setSizeFull();
        tabSheetGlobal.addStyleName(ValoTheme.TABSHEET_FRAMED);

        //ajout de l'onglet principal 'parametres'
        layoutConfigApplication = new VerticalLayout();
        layoutConfigApplication.setSizeFull();
        ajoutGestionParametresApplicatifs();
        tabSheetGlobal.addTab(layoutConfigApplication, "Paramtres de l'application", FontAwesome.COGS);

        //ajout de l'onglet 'swap'
        layoutSwapUser = new VerticalLayout();
        layoutSwapUser.setSizeFull();
        ajoutGestionSwap();
        tabSheetGlobal.addTab(layoutSwapUser, "Swap utilisateur", FontAwesome.GROUP);

        tabSheetGlobal.setSelectedTab(tabSelectedPosition);
        //Ce tabSheet sera align  droite
        //tabSheetGlobal.addStyleName("right-aligned-tabs");

        //Le menu horizontal pour les enseignants est dfinit comme tant le contenu de la page
        addComponent(tabSheetGlobal);
        setExpandRatio(tabSheetGlobal, 1);
    }
}