List of usage examples for com.vaadin.ui HorizontalLayout setMargin
@Override public void setMargin(boolean enabled)
From source file:org.ow2.sirocco.cloudmanager.NetworkView.java
License:Open Source License
public NetworkView() { this.setSizeFull(); HorizontalLayout actionButtonHeader = new HorizontalLayout(); actionButtonHeader.setMargin(true); actionButtonHeader.setSpacing(true); actionButtonHeader.setWidth("100%"); actionButtonHeader.setHeight("50px"); Button button = new Button("Create Network..."); button.setIcon(new ThemeResource("img/add.png")); button.addClickListener(new ClickListener() { @Override//from w w w .ja va 2 s. c om public void buttonClick(final ClickEvent event) { if (NetworkView.this.networkCreationWizard.init(NetworkView.this)) { UI.getCurrent().addWindow(NetworkView.this.networkCreationWizard); } } }); actionButtonHeader.addComponent(button); this.deleteNetworkButton = new Button("Delete"); this.deleteNetworkButton.setIcon(new ThemeResource("img/delete.png")); this.deleteNetworkButton.setEnabled(false); this.deleteNetworkButton.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { final Set<?> selectedNetworkIds = (Set<?>) NetworkView.this.networkTable.getValue(); String name = NetworkView.this.networks.getItem(selectedNetworkIds.iterator().next()).getBean() .getName(); ConfirmDialog confirmDialog = ConfirmDialog.newConfirmDialog("Delete Network", "Are you sure you want to delete network " + name + " ?", new ConfirmDialog.ConfirmationDialogCallback() { @Override public void response(final boolean ok, final boolean ignored) { if (ok) { for (Object id : selectedNetworkIds) { try { NetworkView.this.networkManager.deleteNetwork(id.toString()); } catch (CloudProviderException e) { e.printStackTrace(); } } NetworkView.this.valueChange(null); } } }); NetworkView.this.getUI().addWindow(confirmDialog); } }); actionButtonHeader.addComponent(this.deleteNetworkButton); Label spacer = new Label(); spacer.setWidth("100%"); actionButtonHeader.addComponent(spacer); actionButtonHeader.setExpandRatio(spacer, 1.0f); button = new Button("Refresh", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { NetworkView.this.refresh(); } }); button.setIcon(new ThemeResource("img/refresh.png")); actionButtonHeader.addComponent(button); this.addComponent(actionButtonHeader); this.addComponent(this.networkTable = this.createNetworkTable()); this.setExpandRatio(this.networkTable, 1.0f); }
From source file:org.ow2.sirocco.cloudmanager.SecurityGroupView.java
License:Open Source License
public SecurityGroupView() { VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setSizeFull();//from w ww. j a v a 2 s . c o m HorizontalLayout actionButtonHeader = new HorizontalLayout(); actionButtonHeader.setMargin(true); actionButtonHeader.setSpacing(true); actionButtonHeader.setWidth("100%"); actionButtonHeader.setHeight("50px"); Button button = new Button("Create SecurityGroup..."); button.setIcon(new ThemeResource("img/add.png")); button.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { if (SecurityGroupView.this.securityGroupCreationWizard.init(SecurityGroupView.this)) { UI.getCurrent().addWindow(SecurityGroupView.this.securityGroupCreationWizard); } } }); actionButtonHeader.addComponent(button); this.deleteSecurityGroupButton = new Button("Delete"); this.deleteSecurityGroupButton.setIcon(new ThemeResource("img/delete.png")); this.deleteSecurityGroupButton.setEnabled(false); this.deleteSecurityGroupButton.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { final Set<?> selectedSecurityGroupIds = (Set<?>) SecurityGroupView.this.securityGroupTable .getValue(); String name = SecurityGroupView.this.securityGroups .getItem(selectedSecurityGroupIds.iterator().next()).getBean().getName(); ConfirmDialog confirmDialog = ConfirmDialog.newConfirmDialog("Delete SecurityGroup", "Are you sure you want to delete securityGroup " + name + " ?", new ConfirmDialog.ConfirmationDialogCallback() { @Override public void response(final boolean ok, final boolean ignored) { if (ok) { for (Object id : selectedSecurityGroupIds) { try { SecurityGroupView.this.networkManager .deleteSecurityGroup(id.toString()); } catch (CloudProviderException e) { Util.diplayErrorMessageBox("Cannot delete security group " + SecurityGroupView.this.securityGroups.getItem(id).getBean() .getName(), e); } } SecurityGroupView.this.valueChange(null); } } }); SecurityGroupView.this.getUI().addWindow(confirmDialog); } }); actionButtonHeader.addComponent(this.deleteSecurityGroupButton); Label spacer = new Label(); spacer.setWidth("100%"); actionButtonHeader.addComponent(spacer); actionButtonHeader.setExpandRatio(spacer, 1.0f); button = new Button("Refresh", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { SecurityGroupView.this.refresh(); } }); button.setIcon(new ThemeResource("img/refresh.png")); actionButtonHeader.addComponent(button); verticalLayout.addComponent(actionButtonHeader); verticalLayout.addComponent(this.securityGroupTable = this.createSecurityGroupTable()); verticalLayout.setExpandRatio(this.securityGroupTable, 1.0f); this.setFirstComponent(verticalLayout); this.setSecondComponent(this.detailView = new SecurityGroupDetailView(this)); this.setSplitPosition(60.0f); }
From source file:org.ow2.sirocco.cloudmanager.VolumeView.java
License:Open Source License
public VolumeView() { this.setSizeFull(); HorizontalLayout actionButtonHeader = new HorizontalLayout(); actionButtonHeader.setMargin(true); actionButtonHeader.setSpacing(true); actionButtonHeader.setWidth("100%"); actionButtonHeader.setHeight("50px"); Button button = new Button("Create Volume..."); button.setIcon(new ThemeResource("img/add.png")); button.addClickListener(new ClickListener() { @Override//from www. j av a 2 s . co m public void buttonClick(final ClickEvent event) { if (VolumeView.this.volumeCreationWizard.init(VolumeView.this)) { UI.getCurrent().addWindow(VolumeView.this.volumeCreationWizard); } } }); actionButtonHeader.addComponent(button); this.attachVolumeButton = new Button("Attach"); this.attachVolumeButton.setEnabled(false); this.attachVolumeButton.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { Set<?> selectedVolumeIds = (Set<?>) VolumeView.this.volumeTable.getValue(); final String volumeId = (String) selectedVolumeIds.iterator().next(); List<VolumeAttachDialog.MachineChoice> choices = new ArrayList<>(); Volume volume; try { volume = VolumeView.this.volumeManager.getVolumeByUuid(volumeId); List<Machine> machines = VolumeView.this.machineManager.getMachines().getItems(); for (Machine machine : machines) { if (machine.getCloudProviderAccount().getId() == volume.getCloudProviderAccount().getId() && machine.getLocation().getId() == volume.getLocation().getId()) { MachineChoice machineChoice = new MachineChoice(); machineChoice.id = machine.getUuid(); machineChoice.name = machine.getName(); choices.add(machineChoice); } } } catch (CloudProviderException e) { Util.diplayErrorMessageBox("Internal error", e); } VolumeAttachDialog volumeAttachDialog = new VolumeAttachDialog(choices, new VolumeAttachDialog.DialogCallback() { @Override public void response(final String machineId, final String location) { try { Volume volume = VolumeView.this.volumeManager.getVolumeByUuid(volumeId); MachineVolume volumeAttachment = new MachineVolume(); volumeAttachment.setInitialLocation(location); volumeAttachment.setVolume(volume); VolumeView.this.machineManager.addVolumeToMachine(machineId, volumeAttachment); } catch (CloudProviderException e) { Util.diplayErrorMessageBox("Volume attach failure", e); } } }); UI.getCurrent().addWindow(volumeAttachDialog); } }); actionButtonHeader.addComponent(this.attachVolumeButton); this.detachVolumeButton = new Button("Detach"); this.detachVolumeButton.setEnabled(false); this.detachVolumeButton.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { Set<?> selectedVolumeIds = (Set<?>) VolumeView.this.volumeTable.getValue(); String volumeId = (String) selectedVolumeIds.iterator().next(); try { Volume volume = VolumeView.this.volumeManager.getVolumeByUuid(volumeId); MachineVolume volumeAttachment = volume.getAttachments().get(0); VolumeView.this.machineManager.removeVolumeFromMachine(volumeAttachment.getOwner().getUuid(), volumeAttachment.getUuid()); } catch (CloudProviderException e) { Util.diplayErrorMessageBox("Volume detach failure", e); } } }); actionButtonHeader.addComponent(this.detachVolumeButton); this.deleteVolumeButton = new Button("Delete"); this.deleteVolumeButton.setIcon(new ThemeResource("img/delete.png")); this.deleteVolumeButton.setEnabled(false); this.deleteVolumeButton.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { final Set<?> selectedVolumeIds = (Set<?>) VolumeView.this.volumeTable.getValue(); String name = VolumeView.this.volumes.getItem(selectedVolumeIds.iterator().next()).getBean() .getName(); ConfirmDialog confirmDialog = ConfirmDialog.newConfirmDialog("Delete Volume", "Are you sure you want to delete volume " + name + " ?", new ConfirmDialog.ConfirmationDialogCallback() { @Override public void response(final boolean ok, final boolean ignored) { if (ok) { for (Object id : selectedVolumeIds) { try { VolumeView.this.volumeManager.deleteVolume(id.toString()); } catch (CloudProviderException e) { Util.diplayErrorMessageBox("Volume delete failure", e); } } VolumeView.this.valueChange(null); } } }); VolumeView.this.getUI().addWindow(confirmDialog); } }); actionButtonHeader.addComponent(this.deleteVolumeButton); Label spacer = new Label(); spacer.setWidth("100%"); actionButtonHeader.addComponent(spacer); actionButtonHeader.setExpandRatio(spacer, 1.0f); button = new Button("Refresh", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { VolumeView.this.refresh(); } }); button.setIcon(new ThemeResource("img/refresh.png")); actionButtonHeader.addComponent(button); this.addComponent(actionButtonHeader); this.addComponent(this.volumeTable = this.createVolumeTable()); this.setExpandRatio(this.volumeTable, 1.0f); }
From source file:org.processbase.ui.servlet.MainWindow.java
License:Open Source License
Layout getHeader() { HorizontalLayout header = new HorizontalLayout(); header.setWidth("100%"); header.setMargin(false); header.setSpacing(true);//from ww w. ja v a 2 s .c o m ThemeResource themeResource = new ThemeResource("icons/processbase.png"); Embedded logo = new Embedded(); logo.setSource(themeResource); logo.setType(Embedded.TYPE_IMAGE); header.addComponent(logo); header.setExpandRatio(logo, 1.0f); Label helloUser = new Label("Welcome, " + user.getFirstName() + " " + user.getLastName()); // helloUser.setStyleName(Runo.LABEL_H2); header.addComponent(helloUser); header.setComponentAlignment(helloUser, Alignment.MIDDLE_RIGHT); header.setExpandRatio(helloUser, 1.0f); Button profile = new Button(((PbApplication) getApplication()).getPbMessages().getString("btnProfile"), new Button.ClickListener() { public void buttonClick(ClickEvent event) { openProfileWindow(); } }); profile.setStyleName(Runo.BUTTON_LINK); header.addComponent(profile); header.setComponentAlignment(profile, Alignment.MIDDLE_RIGHT); Button logout = new Button(((PbApplication) getApplication()).getPbMessages().getString("btnLogout"), new Button.ClickListener() { public void buttonClick(ClickEvent event) { openLogoutWindow(); } }); logout.setStyleName(Runo.BUTTON_LINK); header.addComponent(logout); header.setComponentAlignment(logout, Alignment.MIDDLE_RIGHT); return header; }
From source file:org.qi4j.library.vaadin.MyVaadinApplication.java
License:Open Source License
@Override public void init() { final TextField field = new TextField(); field.setInputPrompt("Type your name here"); Button button = new Button("Greetings mortals.."); button.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { String name = "" + field.getValue(); if (name.length() <= 0) { window.showNotification("You must type your name in the field", Window.Notification.TYPE_ERROR_MESSAGE); } else { window.showNotification(greeter.greet("" + field.getValue())); }//w w w . ja v a 2s . c om } }); HorizontalLayout horizLayout = new HorizontalLayout(); horizLayout.setMargin(true); horizLayout.addComponent(field); horizLayout.addComponent(button); Panel panel = new Panel("Vaadin seems nice : )"); panel.addComponent(horizLayout); VerticalLayout vertLayout = new VerticalLayout(); vertLayout.setMargin(true); vertLayout.addComponent(panel); window = new Window("test app"); window.setSizeFull(); window.setContent(vertLayout); setMainWindow(window); }
From source file:org.ripla.web.controllers.RiplaBody.java
License:Open Source License
/** * Returns the default menu bar's layout component.<br /> * Subclasses may override./*from ww w . j a v a2 s.c o m*/ * * @return {@link HorizontalLayout} the default layout for the menu bar. */ protected HorizontalLayout getDftMenuBarLayout() { final HorizontalLayout outLayout = new HorizontalLayout(); outLayout.setStyleName("ripla-menubar"); //$NON-NLS-1$ outLayout.setMargin(new MarginInfo(false, false, false, true)); outLayout.setWidth("100%"); //$NON-NLS-1$ outLayout.setHeight(32, Unit.PIXELS); return outLayout; }
From source file:org.ripla.web.controllers.RiplaBody.java
License:Open Source License
private Component createToolbar(final Label inSeparator) { final HorizontalLayout outToolbar = new HorizontalLayout(); outToolbar.setStyleName("ripla-toolbar"); //$NON-NLS-1$ outToolbar.setWidth("100%"); //$NON-NLS-1$ outToolbar.setSpacing(true);//from w ww . j ava 2 s . c o m outToolbar.setMargin(new MarginInfo(false, true, false, true)); outToolbar.setHeight(22, Unit.PIXELS); final Label lExpand = new Label(" ", ContentMode.HTML); lExpand.setWidth("100%"); outToolbar.addComponent(lExpand); outToolbar.setExpandRatio(lExpand, 1); final Iterator<IToolbarItem> lItems = ToolbarItemRegistry.INSTANCE.getSortedItems().iterator(); boolean lFirst = true; while (lItems.hasNext()) { final IToolbarItem lItem = lItems.next(); final IToolbarItemCreator lFactory = lItem.getCreator(); final Component lComponent = lFactory == null ? lItem.getComponent() : lFactory.createToolbarItem(application, getUser()); if (lComponent == null) { continue; } if (!lFirst) { final Label lSeparator = getSeparator(inSeparator); outToolbar.addComponent(lSeparator); outToolbar.setComponentAlignment(lSeparator, Alignment.MIDDLE_CENTER); } lFirst = false; outToolbar.addComponent(lComponent); outToolbar.setComponentAlignment(lComponent, Alignment.MIDDLE_CENTER); lItem.registerToolbarActionListener(new IToolbarActionListener() { // NOPMD @Override public void processAction(final IToolbarAction inAction) { inAction.run(); } }); } return outToolbar; }
From source file:org.ripla.web.demo.skin.Skin.java
License:Open Source License
@Override public Component getHeader(final String inAppName) { final HorizontalLayout out = new HorizontalLayout(); out.setStyleName("demo-header"); //$NON-NLS-1$ out.setMargin(true); out.setWidth("100%"); //$NON-NLS-1$ out.setHeight(90, Unit.PIXELS);/*from w w w . j a v a 2s . co m*/ final Label lTitle = LabelHelper.createLabel("Ripla Demo Application", "demo-header-text"); lTitle.setSizeUndefined(); out.addComponent(lTitle); out.setComponentAlignment(lTitle, Alignment.MIDDLE_CENTER); return out; }
From source file:org.sensorhub.ui.AdminUI.java
License:Mozilla Public License
protected Component buildHeader() { HorizontalLayout header = new HorizontalLayout(); header.setMargin(false); header.setHeight(100.0f, Unit.PIXELS); header.setWidth(100.0f, Unit.PERCENTAGE); Image img = new Image(null, LOGO_ICON); img.setHeight(90, Unit.PIXELS);/*w ww .j a va 2 s .com*/ img.setStyleName(STYLE_LOGO); header.addComponent(img); Label title = new Label("SensorHub"); title.addStyleName(UIConstants.STYLE_H1); title.addStyleName(STYLE_LOGO); title.setWidth(null); header.addComponent(title); header.setExpandRatio(img, 0); header.setExpandRatio(title, 1); header.setComponentAlignment(img, Alignment.MIDDLE_LEFT); header.setComponentAlignment(title, Alignment.MIDDLE_RIGHT); return header; }
From source file:org.sensorhub.ui.GenericConfigForm.java
License:Mozilla Public License
protected Component buildTabs(final String propId, final ContainerProperty prop, final FieldGroup fieldGroup) { GridLayout layout = new GridLayout(); layout.setWidth(100.0f, Unit.PERCENTAGE); // title bar//from ww w . j a v a 2s . c om HorizontalLayout titleBar = new HorizontalLayout(); titleBar.setMargin(new MarginInfo(true, false, false, false)); titleBar.setSpacing(true); String label = prop.getLabel(); if (label == null) label = DisplayUtils.getPrettyName((String) propId); Label sectionLabel = new Label(label); sectionLabel.setDescription(prop.getDescription()); sectionLabel.addStyleName(STYLE_H3); sectionLabel.addStyleName(STYLE_COLORED); titleBar.addComponent(sectionLabel); layout.addComponent(titleBar); // create one tab per item in container final MyBeanItemContainer<Object> container = prop.getValue(); final TabSheet tabs = new TabSheet(); tabs.setSizeFull(); int i = 1; for (Object itemId : container.getItemIds()) { MyBeanItem<Object> childBeanItem = (MyBeanItem<Object>) container.getItem(itemId); IModuleConfigForm subform = AdminUI.getInstance().generateForm(childBeanItem.getBean().getClass()); subform.build(null, childBeanItem); ((MarginHandler) subform).setMargin(new MarginInfo(true, false, true, false)); allForms.add(subform); Tab tab = tabs.addTab(subform, "Item #" + (i++)); tab.setClosable(true); // store item id so we can map a tab with the corresponding bean item ((AbstractComponent) subform).setData(itemId); } // draw icon on last tab to add new items tabs.addTab(new VerticalLayout(), "", UIConstants.ADD_ICON); // catch close event to delete item tabs.setCloseHandler(new CloseHandler() { private static final long serialVersionUID = 1L; @Override public void onTabClose(TabSheet tabsheet, Component tabContent) { final Tab tab = tabs.getTab(tabContent); final ConfirmDialog popup = new ConfirmDialog( "Are you sure you want to delete " + tab.getCaption() + "?</br>All settings will be lost."); popup.addCloseListener(new CloseListener() { private static final long serialVersionUID = 1L; @Override public void windowClose(CloseEvent e) { if (popup.isConfirmed()) { // retrieve id of item shown on tab AbstractComponent tabContent = (AbstractComponent) tab.getComponent(); Object itemId = tabContent.getData(); // remove from UI int deletedTabPos = tabs.getTabPosition(tab); tabs.removeTab(tab); tabs.setSelectedTab(deletedTabPos - 1); // remove from container container.removeItem(itemId); } } }); popup.setModal(true); AdminUI.getInstance().addWindow(popup); } }); // catch select event on '+' tab to add new item tabs.addSelectedTabChangeListener(new SelectedTabChangeListener() { private static final long serialVersionUID = 1L; public void selectedTabChange(SelectedTabChangeEvent event) { Component selectedTab = event.getTabSheet().getSelectedTab(); final Tab tab = tabs.getTab(selectedTab); final int selectedTabPos = tabs.getTabPosition(tab); // case of + tab to add new item if (tab.getCaption().equals("")) { tabs.setSelectedTab(selectedTabPos - 1); try { // show popup to select among available module types String title = "Please select the desired option"; Map<String, Class<?>> typeList = GenericConfigForm.this.getPossibleTypes(propId); ObjectTypeSelectionPopup popup = new ObjectTypeSelectionPopup(title, typeList, new ObjectTypeSelectionCallback() { public void typeSelected(Class<?> objectType) { try { // add new item to container MyBeanItem<Object> childBeanItem = container.addBean( objectType.newInstance(), ((String) propId) + PROP_SEP); // generate form for new item IModuleConfigForm subform = AdminUI.getInstance() .generateForm(childBeanItem.getBean().getClass()); subform.build(null, childBeanItem); ((MarginHandler) subform) .setMargin(new MarginInfo(true, false, true, false)); allForms.add(subform); // add new tab and select it Tab newTab = tabs.addTab(subform, "Item #" + (selectedTabPos + 1), null, selectedTabPos); newTab.setClosable(true); tabs.setSelectedTab(newTab); } catch (Exception e) { Notification.show("Error", e.getMessage(), Notification.Type.ERROR_MESSAGE); } } }); popup.setModal(true); AdminUI.getInstance().addWindow(popup); } catch (Exception e) { e.printStackTrace(); } } } }); // also register commit handler fieldGroup.addCommitHandler(new CommitHandler() { private static final long serialVersionUID = 1L; @Override public void preCommit(CommitEvent commitEvent) throws CommitException { } @Override public void postCommit(CommitEvent commitEvent) throws CommitException { // make sure new items are transfered to model prop.setValue(prop.getValue()); } }); layout.addComponent(tabs); return layout; }