List of usage examples for com.vaadin.ui GridLayout setComponentAlignment
@Override public void setComponentAlignment(Component childComponent, Alignment alignment)
From source file:io.subutai.plugin.accumulo.ui.manager.AddNodeWindow.java
public AddNodeWindow(final Accumulo accumulo, final ExecutorService executorService, final Tracker tracker, final AccumuloClusterConfig accumuloClusterConfig, Set<EnvironmentContainerHost> nodes, final NodeType nodeType) { super("Add New Node"); setModal(true);//ww w.j a va 2s. com setWidth(650, Unit.PIXELS); setHeight(450, Unit.PIXELS); GridLayout content = new GridLayout(1, 3); content.setSizeFull(); content.setMargin(true); content.setSpacing(true); HorizontalLayout topContent = new HorizontalLayout(); topContent.setSpacing(true); content.addComponent(topContent); topContent.addComponent(new Label("Nodes:")); final ComboBox hadoopNodes = new ComboBox(); hadoopNodes.setId("HadoopNodesCb"); hadoopNodes.setImmediate(true); hadoopNodes.setTextInputAllowed(false); hadoopNodes.setNullSelectionAllowed(false); hadoopNodes.setRequired(true); hadoopNodes.setWidth(200, Unit.PIXELS); for (EnvironmentContainerHost node : nodes) { hadoopNodes.addItem(node); hadoopNodes.setItemCaption(node, node.getHostname()); } if (nodes.size() == 0) { return; } hadoopNodes.setValue(nodes.iterator().next()); topContent.addComponent(hadoopNodes); final Button addNodeBtn = new Button("Add"); addNodeBtn.setId("AddSelectedNode"); topContent.addComponent(addNodeBtn); final Button ok = new Button("Ok"); addNodeBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { addNodeBtn.setEnabled(false); ok.setEnabled(false); showProgress(); EnvironmentContainerHost containerHost = (EnvironmentContainerHost) hadoopNodes.getValue(); final UUID trackID = accumulo.addNode(accumuloClusterConfig.getClusterName(), containerHost.getHostname(), nodeType); executorService.execute(new Runnable() { public void run() { while (track) { TrackerOperationView po = tracker.getTrackerOperation(AccumuloClusterConfig.PRODUCT_KEY, trackID); if (po != null) { setOutput(po.getDescription() + "\nState: " + po.getState() + "\nLogs:\n" + po.getLog()); if (po.getState() != OperationState.RUNNING) { hideProgress(); ok.setEnabled(true); break; } } else { setOutput("Product operation not found. Check logs"); break; } try { Thread.sleep(1000); } catch (InterruptedException ex) { break; } } } }); } }); outputTxtArea = new TextArea("Operation output"); outputTxtArea.setId("outputTxtArea"); outputTxtArea.setRows(13); outputTxtArea.setColumns(43); outputTxtArea.setImmediate(true); outputTxtArea.setWordwrap(true); content.addComponent(outputTxtArea); indicator = new Label(); indicator.setId("indicator"); indicator.setIcon(new ThemeResource("img/spinner.gif")); indicator.setContentMode(ContentMode.HTML); indicator.setHeight(11, Unit.PIXELS); indicator.setWidth(50, Unit.PIXELS); indicator.setVisible(false); ok.setId("btnOk"); ok.setStyleName("default"); ok.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { //close window track = false; close(); } }); HorizontalLayout bottomContent = new HorizontalLayout(); bottomContent.addComponent(indicator); bottomContent.setComponentAlignment(indicator, Alignment.MIDDLE_RIGHT); bottomContent.addComponent(ok); content.addComponent(bottomContent); content.setComponentAlignment(bottomContent, Alignment.MIDDLE_RIGHT); setContent(content); }
From source file:io.subutai.plugin.accumulo.ui.wizard.WelcomeStep.java
public WelcomeStep(final Wizard wizard) { setSizeFull();/*ww w.j a v a 2 s. co m*/ GridLayout grid = new GridLayout(10, 6); grid.setSpacing(true); grid.setMargin(true); grid.setSizeFull(); Label welcomeMsg = new Label("<center><h2>Welcome to Accumulo Installation Wizard!</h2>"); welcomeMsg.setContentMode(ContentMode.HTML); grid.addComponent(welcomeMsg, 3, 1, 6, 2); Label logoImg = new Label(); // Image as a file resource logoImg.setIcon(new FileResource(FileUtil.getFile(AccumuloPortalModule.MODULE_IMAGE, this))); logoImg.setContentMode(ContentMode.HTML); logoImg.setHeight(56, Unit.PIXELS); logoImg.setWidth(220, Unit.PIXELS); grid.addComponent(logoImg, 1, 3, 2, 5); Button startOverHadoopNZK = new Button("Start over Hadoop & ZK installation"); startOverHadoopNZK.setId("startOverHadoopNZK"); startOverHadoopNZK.addStyleName("default"); grid.addComponent(startOverHadoopNZK, 4, 4, 4, 4); grid.setComponentAlignment(startOverHadoopNZK, Alignment.BOTTOM_RIGHT); startOverHadoopNZK.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { wizard.init(); wizard.getConfig().setSetupType(SetupType.OVER_HADOOP_N_ZK); wizard.next(); } }); setContent(grid); }
From source file:lu.uni.lassy.excalibur.examples.icrash.dev.web.java.views.AdminAuthView.java
License:Open Source License
public AdminAuthView() { setSizeFull();//from ww w.j av a2 s. c om VerticalLayout header = new VerticalLayout(); header.setSizeFull(); HorizontalLayout content = new HorizontalLayout(); content.setSizeFull(); addComponents(header, content); setExpandRatio(header, 1); setExpandRatio(content, 6); welcomeText.setValue("<h1>Welcome to the iCrash Administrator console!</h1>"); welcomeText.setContentMode(ContentMode.HTML); welcomeText.setSizeUndefined(); header.addComponent(welcomeText); header.setComponentAlignment(welcomeText, Alignment.MIDDLE_CENTER); Panel controlPanel = new Panel("Administrator control panel"); controlPanel.setSizeUndefined(); Panel addCoordPanel = new Panel("Create a new coordinator"); addCoordPanel.setSizeUndefined(); Panel messagesPanel = new Panel("Administrator messages"); messagesPanel.setWidth("580px"); Table adminMessagesTable = new Table(); adminMessagesTable.setContainerDataSource(actAdmin.getMessagesDataSource()); adminMessagesTable.setColumnWidth("inputEvent", 180); adminMessagesTable.setSizeFull(); VerticalLayout controlLayout = new VerticalLayout(controlPanel); controlLayout.setSizeFull(); controlLayout.setMargin(false); controlLayout.setComponentAlignment(controlPanel, Alignment.TOP_CENTER); VerticalLayout coordOperationsLayout = new VerticalLayout(addCoordPanel); coordOperationsLayout.setSizeFull(); coordOperationsLayout.setMargin(false); coordOperationsLayout.setComponentAlignment(addCoordPanel, Alignment.TOP_CENTER); /******************************************/ coordOperationsLayout.setVisible(true); // main layout in the middle addCoordPanel.setVisible(false); // ...which contains the panel "Create a new coordinator" /******************************************/ HorizontalLayout messagesExternalLayout = new HorizontalLayout(messagesPanel); VerticalLayout messagesInternalLayout = new VerticalLayout(adminMessagesTable); messagesExternalLayout.setSizeFull(); messagesExternalLayout.setMargin(false); messagesExternalLayout.setComponentAlignment(messagesPanel, Alignment.TOP_CENTER); messagesInternalLayout.setMargin(false); messagesInternalLayout.setSizeFull(); messagesInternalLayout.setComponentAlignment(adminMessagesTable, Alignment.TOP_CENTER); messagesPanel.setContent(messagesInternalLayout); TextField idCoordAdd = new TextField(); TextField loginCoord = new TextField(); PasswordField pwdCoord = new PasswordField(); Label idCaptionAdd = new Label("ID"); Label loginCaption = new Label("Login"); Label pwdCaption = new Label("Password"); idCaptionAdd.setSizeUndefined(); idCoordAdd.setSizeUndefined(); loginCaption.setSizeUndefined(); loginCoord.setSizeUndefined(); pwdCaption.setSizeUndefined(); pwdCoord.setSizeUndefined(); Button validateNewCoord = new Button("Validate"); validateNewCoord.setClickShortcut(KeyCode.ENTER); validateNewCoord.setStyleName(ValoTheme.BUTTON_PRIMARY); GridLayout addCoordinatorLayout = new GridLayout(2, 4); addCoordinatorLayout.setSpacing(true); addCoordinatorLayout.setMargin(true); addCoordinatorLayout.setSizeFull(); addCoordinatorLayout.addComponents(idCaptionAdd, idCoordAdd, loginCaption, loginCoord, pwdCaption, pwdCoord); addCoordinatorLayout.addComponent(validateNewCoord, 1, 3); addCoordinatorLayout.setComponentAlignment(idCaptionAdd, Alignment.MIDDLE_LEFT); addCoordinatorLayout.setComponentAlignment(idCoordAdd, Alignment.MIDDLE_LEFT); addCoordinatorLayout.setComponentAlignment(loginCaption, Alignment.MIDDLE_LEFT); addCoordinatorLayout.setComponentAlignment(loginCoord, Alignment.MIDDLE_LEFT); addCoordinatorLayout.setComponentAlignment(pwdCaption, Alignment.MIDDLE_LEFT); addCoordinatorLayout.setComponentAlignment(pwdCoord, Alignment.MIDDLE_LEFT); addCoordPanel.setContent(addCoordinatorLayout); content.addComponents(controlLayout, coordOperationsLayout, messagesExternalLayout); content.setComponentAlignment(messagesExternalLayout, Alignment.TOP_CENTER); content.setComponentAlignment(controlLayout, Alignment.TOP_CENTER); content.setComponentAlignment(messagesExternalLayout, Alignment.TOP_CENTER); content.setExpandRatio(controlLayout, 20); content.setExpandRatio(coordOperationsLayout, 10); content.setExpandRatio(messagesExternalLayout, 28); Button addCoordinator = new Button("Add coordinator"); Button deleteCoordinator = new Button("Delete coordinator"); addCoordinator.addStyleName(ValoTheme.BUTTON_HUGE); deleteCoordinator.addStyleName(ValoTheme.BUTTON_HUGE); logoutBtn.addStyleName(ValoTheme.BUTTON_HUGE); VerticalLayout buttons = new VerticalLayout(); buttons.setMargin(true); buttons.setSpacing(true); buttons.setSizeFull(); buttons.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); controlPanel.setContent(buttons); buttons.addComponents(addCoordinator, deleteCoordinator, logoutBtn); /******* DELETE COORDINATOR PANEL BEGIN *********/ Label idCaptionDel = new Label("ID"); TextField idCoordDel = new TextField(); Panel delCoordPanel = new Panel("Delete a coordinator"); coordOperationsLayout.addComponent(delCoordPanel); delCoordPanel.setVisible(false); coordOperationsLayout.setComponentAlignment(delCoordPanel, Alignment.TOP_CENTER); delCoordPanel.setSizeUndefined(); GridLayout delCoordinatorLayout = new GridLayout(2, 2); delCoordinatorLayout.setSpacing(true); delCoordinatorLayout.setMargin(true); delCoordinatorLayout.setSizeFull(); Button deleteCoordBtn = new Button("Delete"); deleteCoordBtn.setClickShortcut(KeyCode.ENTER); deleteCoordBtn.setStyleName(ValoTheme.BUTTON_PRIMARY); delCoordinatorLayout.addComponents(idCaptionDel, idCoordDel); delCoordinatorLayout.addComponent(deleteCoordBtn, 1, 1); delCoordinatorLayout.setComponentAlignment(idCaptionDel, Alignment.MIDDLE_LEFT); delCoordinatorLayout.setComponentAlignment(idCoordDel, Alignment.MIDDLE_LEFT); delCoordPanel.setContent(delCoordinatorLayout); /******* DELETE COORDINATOR PANEL END *********/ /************************************************* MAIN BUTTONS LOGIC BEGIN *************************************************/ addCoordinator.addClickListener(event -> { if (!addCoordPanel.isVisible()) { delCoordPanel.setVisible(false); addCoordPanel.setVisible(true); idCoordAdd.focus(); } else addCoordPanel.setVisible(false); }); deleteCoordinator.addClickListener(event -> { if (!delCoordPanel.isVisible()) { addCoordPanel.setVisible(false); delCoordPanel.setVisible(true); idCoordDel.focus(); } else delCoordPanel.setVisible(false); }); /************************************************* MAIN BUTTONS LOGIC END *************************************************/ /************************************************* ADD COORDINATOR FORM LOGIC BEGIN *************************************************/ validateNewCoord.addClickListener(event -> { String currentURL = Page.getCurrent().getLocation().toString(); int strIndexCreator = currentURL.lastIndexOf(AdministratorLauncher.adminPageName); String iCrashURL = currentURL.substring(0, strIndexCreator); String googleShebang = "#!"; String coordURL = iCrashURL + CoordinatorServlet.coordinatorsName + googleShebang; try { sys.oeAddCoordinator(new DtCoordinatorID(new PtString(idCoordAdd.getValue())), new DtLogin(new PtString(loginCoord.getValue())), new DtPassword(new PtString(pwdCoord.getValue()))); // open new browser tab with the newly created coordinator console... // "_blank" instructs the browser to open a new tab instead of a new window... // unhappily not all browsers interpret it correctly, // some versions of some browsers might still open a new window instead (notably Firefox)! Page.getCurrent().open(coordURL + idCoordAdd.getValue(), "_blank"); } catch (Exception e) { e.printStackTrace(); } idCoordAdd.setValue(""); loginCoord.setValue(""); pwdCoord.setValue(""); idCoordAdd.focus(); }); /************************************************* ADD COORDINATOR FORM LOGIC END *************************************************/ /************************************************* DELETE COORDINATOR FORM LOGIC BEGIN *************************************************/ deleteCoordBtn.addClickListener(event -> { IcrashSystem sys = IcrashSystem.getInstance(); try { sys.oeDeleteCoordinator(new DtCoordinatorID(new PtString(idCoordDel.getValue()))); } catch (Exception e) { e.printStackTrace(); } idCoordDel.setValue(""); idCoordDel.focus(); }); /************************************************* DELETE COORDINATOR FORM LOGIC END *************************************************/ }
From source file:module.pandabox.presentation.PandaBox.java
License:Open Source License
private void initView() { setCompositionRoot(root);/*from w ww . ja v a 2 s. c om*/ root.setSizeFull(); root.setSplitPosition(15); root.setStyleName("small previews"); previewArea.setWidth("100%"); previewTabs = new VerticalLayout(); previewTabs.setSizeFull(); previewTabs.setHeight(null); compoundTabs = new VerticalLayout(); compoundTabs.setSizeFull(); compoundTabs.setHeight(null); bennuStylesTabs = new VerticalLayout(); bennuStylesTabs.setSizeFull(); bennuStylesTabs.setHeight(null); VerticalLayout menu = new VerticalLayout(); menu.setSizeFull(); menu.setStyleName("sidebar-menu"); Button syncThemes = new Button("Sync Themes", new ClickListener() { @Override public void buttonClick(ClickEvent event) { syncThemes(); } }); menu.addComponent(syncThemes); menu.addComponent(new Label("Single Components")); menu.addComponent(previewTabs); menu.addComponent(new Label("Compound Styles")); menu.addComponent(compoundTabs); menu.addComponent(new Label("Bennu Styles")); menu.addComponent(bennuStylesTabs); root.setFirstComponent(menu); CssLayout toolbar = new CssLayout(); toolbar.setWidth("100%"); toolbar.setStyleName("toolbar"); toolbar.addComponent(editorToggle); final Window downloadWindow = new Window("Download Theme"); GridLayout l = new GridLayout(3, 2); l.setSizeUndefined(); l.setMargin(true); l.setSpacing(true); downloadWindow.setContent(l); downloadWindow.setModal(true); downloadWindow.setResizable(false); downloadWindow.setCloseShortcut(KeyCode.ESCAPE, null); downloadWindow.addStyleName("opaque"); Label caption = new Label("Theme Name"); l.addComponent(caption); l.setComponentAlignment(caption, Alignment.MIDDLE_CENTER); final TextField name = new TextField(); name.setValue("my-chameleon"); name.addValidator(new RegexpValidator("[a-zA-Z0-9\\-_\\.]+", "Only alpha-numeric characters allowed")); name.setRequired(true); name.setRequiredError("Please give a name for the theme"); downloadWindow.addComponent(name); Label info = new Label( "This is the name you will use to set the theme in your application code, i.e. <code>setTheme(\"my-cameleon\")</code>.", Label.CONTENT_XHTML); info.addStyleName("tiny"); info.setWidth("200px"); l.addComponent(info, 1, 1, 2, 1); Button download = new Button(null, new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { getApplication().getMainWindow().addWindow(downloadWindow); name.focus(); } }); download.setDescription("Donwload the current theme"); download.setIcon(new ThemeResource("download.png")); download.setStyleName("icon-only"); toolbar.addComponent(download); menu.addComponent(toolbar); menu.setExpandRatio(toolbar, 1); menu.setComponentAlignment(toolbar, Alignment.BOTTOM_CENTER); }
From source file:org.accelerators.activiti.admin.ui.GroupTab.java
License:Open Source License
public GroupTab(AdminApp application) { // Set application reference this.app = application; // Set tab name setCaption(app.getMessage(Messages.Groups)); // Add main layout VerticalLayout layout = new VerticalLayout(); layout.setMargin(true);/* w w w.ja va 2 s. com*/ layout.setSpacing(true); layout.setSizeFull(); // Add toolbar layout GridLayout toolbar = new GridLayout(2, 1); toolbar.setWidth("100%"); layout.addComponent(toolbar); // Add create button create = new Button(app.getMessage(Messages.Create), (ClickListener) this); create.setDescription(app.getMessage(Messages.CreateGroup)); create.setIcon(new ThemeResource("../runo/icons/16/ok.png")); toolbar.addComponent(create, 0, 0); toolbar.setComponentAlignment(create, Alignment.TOP_LEFT); // Add refresh button refresh = new Button(app.getMessage(Messages.Refresh), (ClickListener) this); refresh.setDescription(app.getMessage(Messages.RefreshTable)); refresh.setIcon(new ThemeResource("../runo/icons/16/reload.png")); toolbar.addComponent(refresh, 1, 0); toolbar.setComponentAlignment(refresh, Alignment.TOP_RIGHT); // Add table table = new GroupTable(app); table.setSizeFull(); layout.addComponent(table); // Set table to expand layout.setExpandRatio(table, 1.0f); // Root setCompositionRoot(layout); }
From source file:org.accelerators.activiti.admin.ui.LoginView.java
License:Open Source License
@SuppressWarnings("serial") public LoginView(AdminApp application) { // Set application reference this.app = application; // Init window caption app.getMainWindow().setCaption(app.getMessage(Messages.Title)); // Set layout to full size setSizeFull();//from ww w . ja v a 2s. c om // Set style this.setStyleName("login-background"); // Add header bar final HorizontalLayout header = new HorizontalLayout(); header.setHeight("50px"); header.setWidth("100%"); addComponent(header); setComponentAlignment(header, Alignment.MIDDLE_CENTER); // Setup grid GridLayout loginGrid = new GridLayout(1, 2); loginGrid.setWidth("250px"); addComponent(loginGrid); setComponentAlignment(loginGrid, Alignment.MIDDLE_CENTER); // Add title to header GridLayout logoGrid = new GridLayout(1, 1); loginGrid.addComponent(logoGrid, 0, 0); loginGrid.setComponentAlignment(logoGrid, Alignment.MIDDLE_CENTER); Embedded logoImage = new Embedded(null, new ThemeResource("img/login-logo.png")); logoImage.setType(Embedded.TYPE_IMAGE); logoImage.addStyleName("login-image"); logoGrid.addComponent(logoImage, 0, 0); logoGrid.setComponentAlignment(logoImage, Alignment.MIDDLE_CENTER); // Add field and button layout VerticalLayout buttonLayout = new VerticalLayout(); buttonLayout.setSizeFull(); buttonLayout.setSpacing(true); buttonLayout.setMargin(false); buttonLayout.setStyleName("login-form"); loginGrid.addComponent(buttonLayout, 0, 1); loginGrid.setComponentAlignment(buttonLayout, Alignment.MIDDLE_CENTER); // Add username field username = new TextField(app.getMessage(Messages.Username)); username.setWidth("100%"); buttonLayout.addComponent(username); // Add password field password = new PasswordField(app.getMessage(Messages.Password)); password.setWidth("100%"); buttonLayout.addComponent(password); // Add Login button buttonLayout.addComponent(login); buttonLayout.setComponentAlignment(login, Alignment.BOTTOM_RIGHT); // Set focus to this component username.focus(); // Add shortcut to login button login.setClickShortcut(KeyCode.ENTER); login.addListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { try { // Athenticate the user authenticate((String) username.getValue(), (String) password.getValue()); // Switch to the main view app.getViewManager().switchScreen(MainView.class.getName(), new MainView(app)); } catch (Exception e) { getWindow().showNotification(e.toString()); } } }); HorizontalLayout footer = new HorizontalLayout(); footer.setHeight("50px"); footer.setWidth("100%"); addComponent(footer); }
From source file:org.accelerators.activiti.admin.ui.MainView.java
License:Open Source License
public MainView(AdminApp application) { // Set application this.app = application; // Setup main layout setStyleName(Reindeer.LAYOUT_WHITE); setMargin(false);/*from w w w . ja va 2s.c o m*/ setSpacing(false); setSizeFull(); // Add header GridLayout header = new GridLayout(2, 1); header.setWidth("100%"); header.setHeight("34px"); addComponent(header); // Add header styles header.addStyleName(Consts.HEADER); header.addStyleName("header"); header.setSpacing(true); // Add title to header GridLayout logoGrid = new GridLayout(1, 1); header.addComponent(logoGrid, 0, 0); header.setComponentAlignment(logoGrid, Alignment.MIDDLE_LEFT); Embedded logoImage = new Embedded(null, new ThemeResource("img/header-logo.png")); logoImage.setType(Embedded.TYPE_IMAGE); logoImage.addStyleName("header-image"); logoGrid.addComponent(logoImage, 0, 0); logoGrid.setComponentAlignment(logoImage, Alignment.MIDDLE_CENTER); // Add logout button to header GridLayout logoutGrid = new GridLayout(2, 1); Label userLabel = new Label("Signed in as: " + app.getUser().toString()); userLabel.addStyleName("user"); logout.setStyleName(Reindeer.BUTTON_LINK); logout.addStyleName("logout"); logoutGrid.addComponent(userLabel, 0, 0); logoutGrid.addComponent(logout, 1, 0); header.addComponent(logoutGrid, 1, 0); header.setComponentAlignment(logoutGrid, Alignment.TOP_RIGHT); // Create tab sheet TabSheet tabs = new TabSheet(); tabs.setSizeFull(); // Add tab styles tabs.addStyleName(Reindeer.TABSHEET_BORDERLESS); tabs.addStyleName(Reindeer.LAYOUT_WHITE); // Add task view tab tabs.addTab(new UserTab(app)); tabs.addTab(new GroupTab(app)); // Add tab sheet to layout addComponent(tabs); setExpandRatio(tabs, 1.0F); // Add footer text Label footerText = new Label(app.getMessage(Messages.Footer)); footerText.setSizeUndefined(); footerText.setStyleName(Reindeer.LABEL_SMALL); addComponent(footerText); setComponentAlignment(footerText, Alignment.BOTTOM_CENTER); }
From source file:org.accelerators.activiti.admin.ui.UserTab.java
License:Open Source License
public UserTab(AdminApp application) { // Set application reference this.app = application; // Set tab name setCaption(app.getMessage(Messages.Users)); // Add main layout VerticalLayout layout = new VerticalLayout(); layout.setMargin(true);/*from ww w . j a v a 2 s. c o m*/ layout.setSpacing(true); layout.setSizeFull(); // Add toolbar layout GridLayout toolbar = new GridLayout(2, 1); toolbar.setWidth("100%"); layout.addComponent(toolbar); // Add create button create = new Button(app.getMessage(Messages.Create), (ClickListener) this); create.setDescription(app.getMessage(Messages.CreateUser)); create.setIcon(new ThemeResource("../runo/icons/16/ok.png")); toolbar.addComponent(create, 0, 0); toolbar.setComponentAlignment(create, Alignment.TOP_LEFT); // Add refresh button refresh = new Button(app.getMessage(Messages.Refresh), (ClickListener) this); refresh.setDescription(app.getMessage(Messages.RefreshTable)); refresh.setIcon(new ThemeResource("../runo/icons/16/reload.png")); toolbar.addComponent(refresh, 1, 0); toolbar.setComponentAlignment(refresh, Alignment.TOP_RIGHT); // Add table table = new UserTable(app); table.setSizeFull(); layout.addComponent(table); // Set table to expand layout.setExpandRatio(table, 1.0f); // Root setCompositionRoot(layout); }
From source file:org.activiti.explorer.ui.task.TaskDetailPanel.java
License:Apache License
protected void initHeader() { GridLayout taskDetails = new GridLayout(2, 2); taskDetails.setWidth(100, UNITS_PERCENTAGE); taskDetails.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK); taskDetails.setSpacing(true);/*w ww. j a va2 s . c om*/ taskDetails.setMargin(false, false, true, false); taskDetails.setColumnExpandRatio(1, 1.0f); centralLayout.addComponent(taskDetails); // Add image Embedded image = new Embedded(null, Images.TASK_50); taskDetails.addComponent(image, 0, 0, 0, 1); // Add task name Label nameLabel = new Label(task.getName()); nameLabel.addStyleName(Reindeer.LABEL_H2); taskDetails.addComponent(nameLabel, 1, 0); taskDetails.setComponentAlignment(nameLabel, Alignment.MIDDLE_LEFT); // Properties HorizontalLayout propertiesLayout = new HorizontalLayout(); propertiesLayout.setSpacing(true); taskDetails.addComponent(propertiesLayout); propertiesLayout.addComponent(new DueDateComponent(task, i18nManager, taskService)); propertiesLayout.addComponent(new PriorityComponent(task, i18nManager, taskService)); initCreateTime(propertiesLayout); }
From source file:org.diretto.web.richwebclient.view.windows.UploadSettingsWindow.java
/** * Constructs an {@link UploadSettingsWindow}. * //from w ww .java 2s . co m * @param mainWindow The corresponding {@code MainWindow} * @param uploadSection The corresponding {@code UploadSection} * @param fileInfo The {@code FileInfo} object * @param mediaType The {@code MediaType} of the file * @param uploadSettings The corresponding {@code UploadSettings} * @param otherFiles The names of the other upload files */ public UploadSettingsWindow(final MainWindow mainWindow, final UploadSection uploadSection, FileInfo fileInfo, MediaType mediaType, UploadSettings uploadSettings, List<String> otherFiles) { super("Upload Settings"); this.mainWindow = mainWindow; setModal(true); setStyleName(Reindeer.WINDOW_BLACK); setWidth("940px"); setHeight((((int) mainWindow.getHeight()) - 160) + "px"); setResizable(false); setClosable(false); setDraggable(false); setPositionX((int) (mainWindow.getWidth() / 2.0f) - 470); setPositionY(126); wrapperLayout = new HorizontalLayout(); wrapperLayout.setSizeFull(); wrapperLayout.setMargin(true, true, true, true); addComponent(wrapperLayout); mainLayout = new VerticalLayout(); mainLayout.setSizeFull(); mainLayout.setSpacing(true); HorizontalLayout titleLayout = new HorizontalLayout(); titleLayout.setWidth("100%"); mainLayout.addComponent(titleLayout); HorizontalLayout leftTitleLayout = new HorizontalLayout(); titleLayout.addComponent(leftTitleLayout); titleLayout.setComponentAlignment(leftTitleLayout, Alignment.MIDDLE_LEFT); Label fileNameLabel = StyleUtils.getLabelH2(fileInfo.getName()); leftTitleLayout.addComponent(fileNameLabel); leftTitleLayout.setComponentAlignment(fileNameLabel, Alignment.MIDDLE_LEFT); Label bullLabel = StyleUtils.getLabelHTML( " • "); leftTitleLayout.addComponent(bullLabel); leftTitleLayout.setComponentAlignment(bullLabel, Alignment.MIDDLE_LEFT); Label titleLabel = StyleUtils.getLabelHTML("<b>Title</b> "); leftTitleLayout.addComponent(titleLabel); leftTitleLayout.setComponentAlignment(titleLabel, Alignment.MIDDLE_LEFT); final TextField titleField = new TextField(); titleField.setMaxLength(50); titleField.setWidth("100%"); titleField.setImmediate(true); if (uploadSettings != null && uploadSettings.getTitle() != null) { titleField.setValue(uploadSettings.getTitle()); } titleField.focus(); titleField.setCursorPosition(((String) titleField.getValue()).length()); titleLayout.addComponent(titleField); titleLayout.setComponentAlignment(titleField, Alignment.MIDDLE_RIGHT); titleLayout.setExpandRatio(leftTitleLayout, 0); titleLayout.setExpandRatio(titleField, 1); mainLayout.addComponent(StyleUtils.getHorizontalLine()); GridLayout topGridLayout = new GridLayout(2, 3); topGridLayout.setColumnExpandRatio(0, 1.0f); topGridLayout.setColumnExpandRatio(1, 0.0f); topGridLayout.setWidth("100%"); topGridLayout.setSpacing(true); mainLayout.addComponent(topGridLayout); Label descriptionLabel = StyleUtils.getLabelBold("Description"); topGridLayout.addComponent(descriptionLabel, 0, 0); final TextArea descriptionArea = new TextArea(); descriptionArea.setSizeFull(); descriptionArea.setImmediate(true); if (uploadSettings != null && uploadSettings.getDescription() != null) { descriptionArea.setValue(uploadSettings.getDescription()); } topGridLayout.addComponent(descriptionArea, 0, 1); VerticalLayout tagsWrapperLayout = new VerticalLayout(); tagsWrapperLayout.setHeight("30px"); tagsWrapperLayout.setSpacing(false); topGridLayout.addComponent(tagsWrapperLayout, 0, 2); HorizontalLayout tagsLayout = new HorizontalLayout(); tagsLayout.setWidth("100%"); tagsLayout.setSpacing(true); Label tagsLabel = StyleUtils.getLabelBoldHTML("Tags "); tagsLabel.setSizeUndefined(); tagsLayout.addComponent(tagsLabel); tagsLayout.setComponentAlignment(tagsLabel, Alignment.MIDDLE_LEFT); addTagField = new TextField(); addTagField.setImmediate(true); addTagField.setInputPrompt("Enter new Tag"); addTagField.addShortcutListener(new ShortcutListener(null, KeyCode.ENTER, new int[0]) { private static final long serialVersionUID = -4767515198819351723L; @Override public void handleAction(Object sender, Object target) { if (target == addTagField) { addTag(); } } }); tagsLayout.addComponent(addTagField); tagsLayout.setComponentAlignment(addTagField, Alignment.MIDDLE_LEFT); tabSheet = new TabSheet(); tabSheet.setStyleName(Reindeer.TABSHEET_SMALL); tabSheet.addStyleName("view"); tabSheet.addListener(new ComponentDetachListener() { private static final long serialVersionUID = -657657505471281795L; @Override public void componentDetachedFromContainer(ComponentDetachEvent event) { tags.remove(tabSheet.getTab(event.getDetachedComponent()).getCaption()); } }); Button addTagButton = new Button("Add", new Button.ClickListener() { private static final long serialVersionUID = 5914473126402594623L; @Override public void buttonClick(ClickEvent event) { addTag(); } }); addTagButton.setStyleName(Reindeer.BUTTON_DEFAULT); tagsLayout.addComponent(addTagButton); tagsLayout.setComponentAlignment(addTagButton, Alignment.MIDDLE_LEFT); Label spaceLabel = StyleUtils.getLabelHTML(""); spaceLabel.setSizeUndefined(); tagsLayout.addComponent(spaceLabel); tagsLayout.setComponentAlignment(spaceLabel, Alignment.MIDDLE_LEFT); tagsLayout.addComponent(tabSheet); tagsLayout.setComponentAlignment(tabSheet, Alignment.MIDDLE_LEFT); tagsLayout.setExpandRatio(tabSheet, 1.0f); tagsWrapperLayout.addComponent(tagsLayout); tagsWrapperLayout.setComponentAlignment(tagsLayout, Alignment.TOP_LEFT); if (uploadSettings != null && uploadSettings.getTags() != null && uploadSettings.getTags().size() > 0) { for (String tag : uploadSettings.getTags()) { addTagField.setValue(tag); addTag(); } } Label presettingLabel = StyleUtils.getLabelBold("Presetting"); topGridLayout.addComponent(presettingLabel, 1, 0); final TwinColSelect twinColSelect; if (otherFiles != null && otherFiles.size() > 0) { twinColSelect = new TwinColSelect(null, otherFiles); } else { twinColSelect = new TwinColSelect(); } twinColSelect.setWidth("400px"); twinColSelect.setRows(10); topGridLayout.addComponent(twinColSelect, 1, 1); topGridLayout.setComponentAlignment(twinColSelect, Alignment.TOP_RIGHT); Label otherFilesLabel = StyleUtils .getLabelSmallHTML("Select the files which should get the settings of this file as presetting."); otherFilesLabel.setSizeUndefined(); topGridLayout.addComponent(otherFilesLabel, 1, 2); topGridLayout.setComponentAlignment(otherFilesLabel, Alignment.MIDDLE_CENTER); mainLayout.addComponent(StyleUtils.getHorizontalLine()); final UploadGoogleMap googleMap; if (uploadSettings != null && uploadSettings.getTopographicPoint() != null) { googleMap = new UploadGoogleMap(mediaType, 12, uploadSettings.getTopographicPoint().getLatitude(), uploadSettings.getTopographicPoint().getLongitude(), MapType.HYBRID); } else { googleMap = new UploadGoogleMap(mediaType, 12, 48.42255269321401d, 9.956477880477905d, MapType.HYBRID); } googleMap.setWidth("100%"); googleMap.setHeight("300px"); mainLayout.addComponent(googleMap); mainLayout.addComponent(StyleUtils.getHorizontalLine()); GridLayout bottomGridLayout = new GridLayout(3, 3); bottomGridLayout.setSizeFull(); bottomGridLayout.setSpacing(true); mainLayout.addComponent(bottomGridLayout); Label licenseLabel = StyleUtils.getLabelBold("License"); bottomGridLayout.addComponent(licenseLabel, 0, 0); final TextArea licenseArea = new TextArea(); licenseArea.setWidth("320px"); licenseArea.setHeight("175px"); licenseArea.setImmediate(true); if (uploadSettings != null && uploadSettings.getLicense() != null) { licenseArea.setValue(uploadSettings.getLicense()); } bottomGridLayout.addComponent(licenseArea, 0, 1); final Label startTimeLabel = StyleUtils.getLabelBold("Earliest possible Start Date"); startTimeLabel.setSizeUndefined(); bottomGridLayout.setComponentAlignment(startTimeLabel, Alignment.TOP_CENTER); bottomGridLayout.addComponent(startTimeLabel, 1, 0); final InlineDateField startTimeField = new InlineDateField(); startTimeField.setImmediate(true); startTimeField.setResolution(InlineDateField.RESOLUTION_SEC); boolean currentTimeAdjusted = false; if (uploadSettings != null && uploadSettings.getTimeRange() != null && uploadSettings.getTimeRange().getStartDateTime() != null) { startTimeField.setValue(uploadSettings.getTimeRange().getStartDateTime().toDate()); } else { currentTimeAdjusted = true; startTimeField.setValue(new Date()); } bottomGridLayout.setComponentAlignment(startTimeField, Alignment.TOP_CENTER); bottomGridLayout.addComponent(startTimeField, 1, 1); final CheckBox exactTimeCheckBox = new CheckBox("This is the exact point in time."); exactTimeCheckBox.setImmediate(true); bottomGridLayout.setComponentAlignment(exactTimeCheckBox, Alignment.TOP_CENTER); bottomGridLayout.addComponent(exactTimeCheckBox, 1, 2); final Label endTimeLabel = StyleUtils.getLabelBold("Latest possible Start Date"); endTimeLabel.setSizeUndefined(); bottomGridLayout.setComponentAlignment(endTimeLabel, Alignment.TOP_CENTER); bottomGridLayout.addComponent(endTimeLabel, 2, 0); final InlineDateField endTimeField = new InlineDateField(); endTimeField.setImmediate(true); endTimeField.setResolution(InlineDateField.RESOLUTION_SEC); if (uploadSettings != null && uploadSettings.getTimeRange() != null && uploadSettings.getTimeRange().getEndDateTime() != null) { endTimeField.setValue(uploadSettings.getTimeRange().getEndDateTime().toDate()); } else { endTimeField.setValue(startTimeField.getValue()); } bottomGridLayout.setComponentAlignment(endTimeField, Alignment.TOP_CENTER); bottomGridLayout.addComponent(endTimeField, 2, 1); if (!currentTimeAdjusted && ((Date) startTimeField.getValue()).equals((Date) endTimeField.getValue())) { exactTimeCheckBox.setValue(true); endTimeLabel.setEnabled(false); endTimeField.setEnabled(false); } exactTimeCheckBox.addListener(new ValueChangeListener() { private static final long serialVersionUID = 7193545421803538364L; @Override public void valueChange(ValueChangeEvent event) { if ((Boolean) event.getProperty().getValue()) { endTimeLabel.setEnabled(false); endTimeField.setEnabled(false); } else { endTimeLabel.setEnabled(true); endTimeField.setEnabled(true); } } }); mainLayout.addComponent(StyleUtils.getHorizontalLine()); HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setMargin(true, false, false, false); buttonLayout.setSpacing(false); HorizontalLayout uploadButtonLayout = new HorizontalLayout(); uploadButtonLayout.setMargin(false, true, false, false); uploadButton = new Button("Upload File", new Button.ClickListener() { private static final long serialVersionUID = 8013811216568950479L; @Override @SuppressWarnings("unchecked") public void buttonClick(ClickEvent event) { String titleValue = titleField.getValue().toString().trim(); Date startTimeValue = (Date) startTimeField.getValue(); Date endTimeValue = (Date) endTimeField.getValue(); boolean exactTimeValue = (Boolean) exactTimeCheckBox.getValue(); if (titleValue.equals("")) { ConfirmWindow confirmWindow = new ConfirmWindow(mainWindow, "Title Field", StyleUtils.getLabelHTML("A title entry is required.")); mainWindow.addWindow(confirmWindow); } else if (titleValue.length() < 5 || titleValue.length() > 50) { ConfirmWindow confirmWindow = new ConfirmWindow(mainWindow, "Title Field", StyleUtils .getLabelHTML("The number of characters of the title has to be between 5 and 50.")); mainWindow.addWindow(confirmWindow); } else if (!exactTimeValue && startTimeValue.after(endTimeValue)) { ConfirmWindow confirmWindow = new ConfirmWindow(mainWindow, "Date Entries", StyleUtils.getLabelHTML("The second date has to be after the first date.")); mainWindow.addWindow(confirmWindow); } else if (startTimeValue.after(new Date()) || (!exactTimeValue && endTimeValue.after(new Date()))) { ConfirmWindow confirmWindow = new ConfirmWindow(mainWindow, "Date Entries", StyleUtils.getLabelHTML("The dates are not allowed to be in the future.")); mainWindow.addWindow(confirmWindow); } else { disableButtons(); String descriptionValue = descriptionArea.getValue().toString().trim(); String licenseValue = licenseArea.getValue().toString().trim(); TopographicPoint topographicPointValue = googleMap.getMarkerPosition(); Collection<String> presettingValues = (Collection<String>) twinColSelect.getValue(); if (exactTimeValue) { endTimeValue = startTimeValue; } TimeRange timeRange = new TimeRange(new DateTime(startTimeValue), new DateTime(endTimeValue)); UploadSettings uploadSettings = new UploadSettings(titleValue, descriptionValue, licenseValue, new Vector<String>(tags), topographicPointValue, timeRange); mainWindow.removeWindow(event.getButton().getWindow()); requestRepaint(); uploadSection.upload(uploadSettings, new Vector<String>(presettingValues)); } } }); uploadButton.setStyleName(Reindeer.BUTTON_DEFAULT); uploadButtonLayout.addComponent(uploadButton); buttonLayout.addComponent(uploadButtonLayout); HorizontalLayout cancelButtonLayout = new HorizontalLayout(); cancelButtonLayout.setMargin(false, true, false, false); cancelButton = new Button("Cancel", new Button.ClickListener() { private static final long serialVersionUID = -2565870159504952913L; @Override public void buttonClick(ClickEvent event) { disableButtons(); mainWindow.removeWindow(event.getButton().getWindow()); requestRepaint(); uploadSection.cancelUpload(); } }); cancelButton.setStyleName(Reindeer.BUTTON_DEFAULT); cancelButtonLayout.addComponent(cancelButton); buttonLayout.addComponent(cancelButtonLayout); cancelAllButton = new Button("Cancel All", new Button.ClickListener() { private static final long serialVersionUID = -8578124709201789182L; @Override public void buttonClick(ClickEvent event) { disableButtons(); mainWindow.removeWindow(event.getButton().getWindow()); requestRepaint(); uploadSection.cancelAllUploads(); } }); cancelAllButton.setStyleName(Reindeer.BUTTON_DEFAULT); buttonLayout.addComponent(cancelAllButton); mainLayout.addComponent(buttonLayout); mainLayout.setComponentAlignment(buttonLayout, Alignment.BOTTOM_CENTER); wrapperLayout.addComponent(mainLayout); }