List of usage examples for com.vaadin.ui TabSheet TabSheet
public TabSheet()
From source file:eu.maxschuster.vaadin.signaturefield.demo.DemoUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { getPage().setTitle(pageTitle);// ww w .ja v a 2s.c o m final VerticalLayout margin = new VerticalLayout(); setContent(margin); final VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setWidth("658px"); margin.addComponent(layout); margin.setComponentAlignment(layout, Alignment.TOP_CENTER); final Label header1 = new Label(pageTitle); header1.addStyleName("h1"); header1.setSizeUndefined(); layout.addComponent(header1); layout.setComponentAlignment(header1, Alignment.TOP_CENTER); final TabSheet tabSheet = new TabSheet(); tabSheet.setWidth("100%"); layout.addComponent(tabSheet); layout.setComponentAlignment(tabSheet, Alignment.TOP_CENTER); final Panel signaturePanel = new Panel(); signaturePanel.addStyleName("signature-panel"); signaturePanel.setWidth("100%"); tabSheet.addTab(signaturePanel, "Demo"); final VerticalLayout signatureLayout = new VerticalLayout(); signatureLayout.setMargin(true); signatureLayout.setSpacing(true); signatureLayout.setSizeFull(); signaturePanel.setContent(signatureLayout); final SignatureField signatureField = new SignatureField(); signatureField.setWidth("100%"); signatureField.setHeight("318px"); signatureField.setPenColor(Color.ULTRAMARINE); signatureField.setBackgroundColor("white"); signatureField.setConverter(new StringToDataUrlConverter()); signatureField.setPropertyDataSource(dataUrlProperty); signatureField.setVelocityFilterWeight(0.7); signatureLayout.addComponent(signatureField); signatureLayout.setComponentAlignment(signatureField, Alignment.MIDDLE_CENTER); final HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); buttonLayout.setWidth("100%"); signatureLayout.addComponent(buttonLayout); final Button clearButton = new Button("Clear", new ClickListener() { @Override public void buttonClick(ClickEvent event) { signatureField.clear(); } }); buttonLayout.addComponent(clearButton); buttonLayout.setComponentAlignment(clearButton, Alignment.MIDDLE_LEFT); final Label message = new Label("Sign above"); message.setSizeUndefined(); buttonLayout.addComponent(message); buttonLayout.setComponentAlignment(message, Alignment.MIDDLE_CENTER); final ButtonLink saveButtonLink = new ButtonLink("Save", null); saveButtonLink.setTargetName("_blank"); buttonLayout.addComponent(saveButtonLink); buttonLayout.setComponentAlignment(saveButtonLink, Alignment.MIDDLE_RIGHT); final Panel optionsPanel = new Panel(); optionsPanel.setSizeFull(); tabSheet.addTab(optionsPanel, "Options"); final FormLayout optionsLayout = new FormLayout(); optionsLayout.setMargin(true); optionsLayout.setSpacing(true); optionsPanel.setContent(optionsLayout); final ComboBox mimeTypeComboBox = new ComboBox(null, mimeTypeContainer); optionsLayout.addComponent(mimeTypeComboBox); mimeTypeComboBox.setItemCaptionPropertyId("mimeType"); mimeTypeComboBox.setNullSelectionAllowed(false); mimeTypeComboBox.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { MimeType mimeType = (MimeType) event.getProperty().getValue(); signatureField.setMimeType(mimeType); } }); mimeTypeComboBox.setValue(MimeType.PNG); mimeTypeComboBox.setCaption("Result MIME-Type"); final CheckBox immediateCheckBox = new CheckBox("immediate", false); optionsLayout.addComponent(immediateCheckBox); immediateCheckBox.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { boolean immediate = (Boolean) event.getProperty().getValue(); signatureField.setImmediate(immediate); } }); final CheckBox readOnlyCheckBox = new CheckBox("readOnly", false); optionsLayout.addComponent(readOnlyCheckBox); readOnlyCheckBox.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { boolean readOnly = (Boolean) event.getProperty().getValue(); signatureField.setReadOnly(readOnly); mimeTypeComboBox.setReadOnly(readOnly); clearButton.setEnabled(!readOnly); } }); final CheckBox requiredCheckBox = new CheckBox("required (causes bug that clears field)", false); optionsLayout.addComponent(requiredCheckBox); requiredCheckBox.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { boolean required = (Boolean) event.getProperty().getValue(); signatureField.setRequired(required); } }); final CheckBox clearButtonEnabledButton = new CheckBox("clearButtonEnabled", false); optionsLayout.addComponent(clearButtonEnabledButton); clearButtonEnabledButton.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { boolean clearButtonEnabled = (Boolean) event.getProperty().getValue(); signatureField.setClearButtonEnabled(clearButtonEnabled); } }); final Panel resultPanel = new Panel("Results:"); resultPanel.setWidth("100%"); layout.addComponent(resultPanel); final VerticalLayout resultLayout = new VerticalLayout(); resultLayout.setMargin(true); resultPanel.setContent(resultLayout); final Image stringPreviewImage = new Image("String preview image:"); stringPreviewImage.setWidth("500px"); resultLayout.addComponent(stringPreviewImage); final Image dataUrlPreviewImage = new Image("DataURL preview image:"); dataUrlPreviewImage.setWidth("500px"); resultLayout.addComponent(dataUrlPreviewImage); final TextArea textArea = new TextArea("DataURL:"); textArea.setWidth("100%"); textArea.setHeight("300px"); resultLayout.addComponent(textArea); final Label emptyLabel = new Label(); emptyLabel.setCaption("Is Empty:"); emptyLabel.setValue(String.valueOf(signatureField.isEmpty())); resultLayout.addComponent(emptyLabel); signatureField.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { String signature = (String) event.getProperty().getValue(); stringPreviewImage.setSource(signature != null ? new ExternalResource(signature) : null); textArea.setValue(signature); emptyLabel.setValue(String.valueOf(signatureField.isEmpty())); } }); dataUrlProperty.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { try { final DataUrl signature = (DataUrl) event.getProperty().getValue(); dataUrlPreviewImage.setSource( signature != null ? new ExternalResource(serializer.serialize(signature)) : null); StreamResource streamResource = null; if (signature != null) { StreamSource streamSource = new StreamSource() { @Override public InputStream getStream() { return new ByteArrayInputStream(signature.getData()); } }; MimeType mimeType = MimeType.valueOfMimeType(signature.getMimeType()); String extension = null; switch (mimeType) { case JPEG: extension = "jpg"; break; case PNG: extension = "png"; break; } streamResource = new StreamResource(streamSource, "signature." + extension); streamResource.setMIMEType(signature.getMimeType()); streamResource.setCacheTime(0); } saveButtonLink.setResource(streamResource); } catch (MalformedURLException e) { logger.error(e.getMessage(), e); } } }); }
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 w w w.jav a 2 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);/* ww w . ja va 2s. 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);/*from w w w . j a v a2 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);// ww w.j av a2s . c om }
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);/*from w w w.ja v a 2 s.c o m*/ 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:facs.ui.ServletUI.java
License:Open Source License
@Override protected void init(VaadinRequest request) { // Date referenceDate = new java.util.Date(); // BookingModel bookingModel = FacsModelUtil.getNoviceBookingModel(request.getRemoteUser()); try {/*from ww w .j ava 2 s.c o m*/ BookingModel bookingModel = FacsModelUtil.getNoviceBookingModel(); TabSheet tabs = new TabSheet(); // tabs.addComponent(new Booking(bookingModel, referenceDate)); // statistics Statistics statistics = new Statistics(); tabs.addComponent(statistics); tabs.addComponent(new Settings(null)); setContent(tabs); } catch (Exception e) { setContent(errorView()); e.printStackTrace(); } }
From source file:fr.amapj.view.engine.popup.formpopup.tab.TabFormPopup.java
License:Open Source License
protected void createContent(VerticalLayout contentLayout) { ///*from www. ja va2 s.c o m*/ contentLayout.addStyleName("wizard-popup"); // TODO // Vrification des conditions initiales String str = checkInitialCondition(); if (str != null) { errorInInitialCondition = true; Label label = new Label(str, ContentMode.HTML); label.setStyleName(ChameleonTheme.LABEL_BIG); contentLayout.addComponent(label); return; } // Mise en place des onglets addTabInfo(); tabSheet = new TabSheet(); for (int i = 0; i < tabInfos.size(); i++) { TabInfo tabInfo = tabInfos.get(i); tabInfo.verticalLayout = new VerticalLayout(); tabInfo.verticalLayout.setData(i); tabSheet.addTab(tabInfo.verticalLayout, tabInfo.tabName); } tabSheet.addSelectedTabChangeListener(this); contentLayout.addComponent(tabSheet); vLayout = new VerticalLayout(); contentLayout.addComponent(vLayout); // Affichage du premier onglet updateForm(tabInfos.get(0)); selectedTab = 0; }
From source file:fr.univlorraine.mondossierweb.views.AdminView.java
License:Apache License
/** * Initialise la vue/*from w w w .j av a2s. c o m*/ */ @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); } }
From source file:fr.univlorraine.mondossierweb.views.EtatCivilView.java
License:Apache License
/** * Initialise la vue/*from www. j av a 2 s . c o m*/ */ @PostConstruct public void init() { LOG.debug(userController.getCurrentUserName() + " EtatCivilView"); //On vrifie le droit d'accder la vue if (UI.getCurrent() instanceof MainUI && (userController.isEnseignant() || userController.isEtudiant())) { if (MainUI.getCurrent() != null && MainUI.getCurrent().getEtudiant() != null) { LOG.debug(userController.getCurrentUserName() + " init EtatCivilView"); /* Style */ setMargin(true); setSpacing(true); /* Titre */ Label title = new Label(applicationContext.getMessage(NAME + ".title", null, getLocale())); title.addStyleName(ValoTheme.LABEL_H1); addComponent(title); VerticalLayout globalLayout = new VerticalLayout(); globalLayout.setSizeFull(); globalLayout.setSpacing(true); //Layout avec les infos etatcivil et contact CssLayout idLayout = new CssLayout(); idLayout.setSizeFull(); idLayout.setStyleName("flexwrap"); globalLayout.addComponent(idLayout); // Enable Responsive CSS selectors for the layout Responsive.makeResponsive(idLayout); /* Generalites */ FormLayout formGeneralitesLayout = new FormLayout(); formGeneralitesLayout.setSpacing(true); formGeneralitesLayout.setMargin(true); Panel panelGeneralites = new Panel( applicationContext.getMessage(NAME + ".generalites.title", null, getLocale())); String captionNumDossier = applicationContext.getMessage(NAME + ".numdossier.title", null, getLocale()); Label fieldNumDossier = new Label(); formatLabel(fieldNumDossier, captionNumDossier, MainUI.getCurrent().getEtudiant().getCod_etu()); formGeneralitesLayout.addComponent(fieldNumDossier); String captionNNE = applicationContext.getMessage(NAME + ".nne.title", null, getLocale()); Label fieldNNE = new Label(); formatLabel(fieldNNE, captionNNE, MainUI.getCurrent().getEtudiant().getCod_nne()); formGeneralitesLayout.addComponent(fieldNNE); String captionNom = applicationContext.getMessage(NAME + ".nom.title", null, getLocale()); Label fieldNom = new Label(); formatLabel(fieldNom, captionNom, MainUI.getCurrent().getEtudiant().getNom()); formGeneralitesLayout.addComponent(fieldNom); String captionMail = applicationContext.getMessage(NAME + ".mail.title", null, getLocale()); Label mailLabel = new Label(); mailLabel.setCaption(captionMail); String mail = MainUI.getCurrent().getEtudiant().getEmail(); if (StringUtils.hasText(mail)) { mail = "<a href=\"mailto:" + mail + "\">" + mail + "</a>"; mailLabel.setValue(mail); mailLabel.setContentMode(ContentMode.HTML); } mailLabel.setSizeFull(); formGeneralitesLayout.addComponent(mailLabel); String captionNationalite = applicationContext.getMessage(NAME + ".nationalite.title", null, getLocale()); Label fieldNationalite = new Label(); formatLabel(fieldNationalite, captionNationalite, MainUI.getCurrent().getEtudiant().getNationalite()); formGeneralitesLayout.addComponent(fieldNationalite); String captionDateNaissance = applicationContext.getMessage(NAME + ".naissance.title", null, getLocale()); Label fieldDateNaissance = new Label(); formatLabel(fieldDateNaissance, captionDateNaissance, MainUI.getCurrent().getEtudiant().getDatenaissance()); formGeneralitesLayout.addComponent(fieldDateNaissance); String captionLieuNaissance = applicationContext.getMessage(NAME + ".lieunaissance.title", null, getLocale()); Label fieldLieuNaissance = new Label(); formatLabel(fieldLieuNaissance, captionLieuNaissance, MainUI.getCurrent().getEtudiant().getLieunaissance()); formGeneralitesLayout.addComponent(fieldLieuNaissance); String captionDepNaissance = applicationContext.getMessage(NAME + ".depnaissance.title", null, getLocale()); Label fieldDepNaissance = new Label(); formatLabel(fieldDepNaissance, captionDepNaissance, MainUI.getCurrent().getEtudiant().getDepartementnaissance()); formGeneralitesLayout.addComponent(fieldDepNaissance); panelGeneralites.setContent(formGeneralitesLayout); HorizontalLayout generalitesGlobalLayout = new HorizontalLayout(); generalitesGlobalLayout.setSizeUndefined(); generalitesGlobalLayout.setStyleName("firstitembox"); generalitesGlobalLayout.addComponent(panelGeneralites); generalitesGlobalLayout.setExpandRatio(panelGeneralites, 1); idLayout.addComponent(generalitesGlobalLayout); /* Bac */ Panel panelBac = new Panel(applicationContext.getMessage(NAME + ".bac.title", null, getLocale())); //Si plusieurs bac if (MainUI.getCurrent().getEtudiant().getListeBac() != null && MainUI.getCurrent().getEtudiant().getListeBac().size() > 1) { panelBac.setCaption(applicationContext.getMessage(NAME + ".bacs.title", null, getLocale())); TabSheet bacTabSheet = new TabSheet(); VerticalLayout vBacLayout = new VerticalLayout(); vBacLayout.setSizeFull(); bacTabSheet.setSizeFull(); bacTabSheet.addStyleName(ValoTheme.TABSHEET_FRAMED); for (BacEtatCivil bec : MainUI.getCurrent().getEtudiant().getListeBac()) { FormLayout tabBacLayout = new FormLayout(); tabBacLayout.setSizeFull(); tabBacLayout.setMargin(false); ajouterBacToView(tabBacLayout, bec); bacTabSheet.addTab(tabBacLayout, bec.getCod_bac(), FontAwesome.GRADUATION_CAP); } vBacLayout.addComponent(bacTabSheet); panelBac.setContent(vBacLayout); } else { //Si un seul bac FormLayout formBacLayout = new FormLayout(); formBacLayout.setSizeFull(); if (MainUI.getCurrent().getEtudiant().getListeBac() != null && MainUI.getCurrent().getEtudiant().getListeBac().size() == 1) { formBacLayout.setSpacing(true); formBacLayout.setMargin(true); ajouterBacToView(formBacLayout, MainUI.getCurrent().getEtudiant().getListeBac().get(0)); } panelBac.setContent(formBacLayout); } HorizontalLayout bacGlobalLayout = new HorizontalLayout(); bacGlobalLayout.setSizeUndefined(); bacGlobalLayout.setStyleName("itembox"); bacGlobalLayout.addComponent(panelBac); bacGlobalLayout.setExpandRatio(panelBac, 1); idLayout.addComponent(bacGlobalLayout); /* Info de contact */ panelContact = new Panel(applicationContext.getMessage(NAME + ".contact.title", null, getLocale())); renseignerPanelContact(); globalLayout.addComponent(panelContact); addComponent(globalLayout); } else { /* Erreur */ addComponent(new BasicErreurMessageLayout(applicationContext)); } } }