List of usage examples for com.vaadin.ui HorizontalLayout setHeight
@Override public void setHeight(String height)
From source file:org.ow2.sirocco.cloudmanager.KeyPairView.java
License:Open Source License
public KeyPairView() { this.setSizeFull(); HorizontalLayout actionButtonHeader = new HorizontalLayout(); actionButtonHeader.setMargin(true);//from ww w .j a va 2 s.c o m actionButtonHeader.setSpacing(true); actionButtonHeader.setWidth("100%"); actionButtonHeader.setHeight("50px"); Button button = new Button("Import Key Pair..."); button.setIcon(new ThemeResource("img/add.png")); button.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { KeyPairImportDialog dialog = new KeyPairImportDialog(new KeyPairImportDialog.DialogCallback() { @Override public void response(final String name, final String publicKey) { try { CredentialsCreate credentialsCreate = new CredentialsCreate(); credentialsCreate.setName(name); CredentialsTemplate credentialsTemplate = new CredentialsTemplate(); credentialsTemplate.setPublicKey(publicKey); credentialsCreate.setCredentialTemplate(credentialsTemplate); KeyPairView.this.credentialManager.createCredentials(credentialsCreate); } catch (CloudProviderException e) { Notification.show("Key Pair creation failure", e.getMessage(), Notification.Type.ERROR_MESSAGE); } KeyPairView.this.refresh(); KeyPairView.this.valueChange(null); } }); UI.getCurrent().addWindow(dialog); } }); actionButtonHeader.addComponent(button); this.deleteKeyPairButton = new Button("Delete"); this.deleteKeyPairButton.setIcon(new ThemeResource("img/delete.png")); this.deleteKeyPairButton.setEnabled(false); this.deleteKeyPairButton.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { final Set<?> selectedKeyPairIds = (Set<?>) KeyPairView.this.keyPairTable.getValue(); String name = KeyPairView.this.keyPairs.getItem(selectedKeyPairIds.iterator().next()).getBean() .getName(); ConfirmDialog confirmDialog = ConfirmDialog.newConfirmDialog("Delete Image", "Are you sure you want to delete key pair " + name + " ?", new ConfirmDialog.ConfirmationDialogCallback() { @Override public void response(final boolean ok, final boolean ignored) { if (ok) { for (Object id : selectedKeyPairIds) { try { KeyPairView.this.credentialManager.deleteCredentials(id.toString()); KeyPairView.this.keyPairs.removeItem(id); } catch (CloudProviderException e) { e.printStackTrace(); } } KeyPairView.this.keyPairTable.setValue(null); KeyPairView.this.valueChange(null); } } }); KeyPairView.this.getUI().addWindow(confirmDialog); } }); actionButtonHeader.addComponent(this.deleteKeyPairButton); 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) { KeyPairView.this.refresh(); } }); button.setIcon(new ThemeResource("img/refresh.png")); actionButtonHeader.addComponent(button); this.addComponent(actionButtonHeader); this.addComponent(this.keyPairTable = this.createkeyPairTable()); this.setExpandRatio(this.keyPairTable, 1.0f); }
From source file:org.ow2.sirocco.cloudmanager.MachineImageView.java
License:Open Source License
public MachineImageView() { this.setSizeFull(); VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setSizeFull();/*from ww w. 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"); this.registerMachineImageButton = new Button("Register Image..."); this.registerMachineImageButton.setIcon(new ThemeResource("img/add.png")); this.registerMachineImageButton.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { if (MachineImageView.this.machineImageRegisterWizard.init(MachineImageView.this)) { UI.getCurrent().addWindow(MachineImageView.this.machineImageRegisterWizard); } } }); actionButtonHeader.addComponent(this.registerMachineImageButton); this.deleteMachineImageButton = new Button("Delete"); this.deleteMachineImageButton.setIcon(new ThemeResource("img/delete.png")); this.deleteMachineImageButton.setEnabled(false); this.deleteMachineImageButton.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { final Set<?> selectedImageIds = (Set<?>) MachineImageView.this.machineImageTable.getValue(); StringBuilder sb = new StringBuilder(); sb.append("Are you sure you want to delete "); if (selectedImageIds.size() == 1) { Object id = selectedImageIds.iterator().next(); sb.append("image " + MachineImageView.this.images.getItem(id).getBean().getName() + " ?"); } else { sb.append(" these " + selectedImageIds.size() + " images ?"); } String name = MachineImageView.this.images.getItem(selectedImageIds.iterator().next()).getBean() .getName(); ConfirmDialog confirmDialog = ConfirmDialog.newConfirmDialogWithOption("Delete Image", sb.toString(), "delete image on provider", new ConfirmDialog.ConfirmationDialogCallback() { @Override public void response(final boolean ok, final boolean deleteOnProvider) { if (ok) { for (Object id : selectedImageIds) { try { if (deleteOnProvider) { MachineImageView.this.machineImageManager .deleteMachineImage(id.toString()); } else { MachineImageView.this.machineImageManager .unregisterMachineImage(id.toString()); } } catch (CloudProviderException e) { Util.diplayErrorMessageBox("Image delete failure", e); } } MachineImageView.this.valueChange(null); } } }); MachineImageView.this.getUI().addWindow(confirmDialog); } }); actionButtonHeader.addComponent(this.deleteMachineImageButton); Label spacer = new Label(); spacer.setWidth("100%"); actionButtonHeader.addComponent(spacer); actionButtonHeader.setExpandRatio(spacer, 1.0f); Button button = new Button("Refresh", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { MachineImageView.this.refresh(); } }); button.setIcon(new ThemeResource("img/refresh.png")); actionButtonHeader.addComponent(button); verticalLayout.addComponent(actionButtonHeader); verticalLayout.addComponent(this.machineImageTable = this.createMachineImageTable()); verticalLayout.setExpandRatio(this.machineImageTable, 1.0f); this.setFirstComponent(verticalLayout); this.setSecondComponent(this.detailView = new MachineImageDetailView(this)); this.setSplitPosition(60.0f); }
From source file:org.ow2.sirocco.cloudmanager.MachineView.java
License:Open Source License
public MachineView() { this.setSizeFull(); VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setSizeFull();/* ww w .ja v a 2 s . co m*/ HorizontalLayout actionButtonHeader = new HorizontalLayout(); actionButtonHeader.setMargin(true); actionButtonHeader.setSpacing(true); actionButtonHeader.setWidth("100%"); actionButtonHeader.setHeight("50px"); Button button = new Button("Launch Instance..."); button.setIcon(new ThemeResource("img/add.png")); button.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { if (MachineView.this.machineCreationWizard.init(MachineView.this)) { UI.getCurrent().addWindow(MachineView.this.machineCreationWizard); } } }); actionButtonHeader.addComponent(button); this.startMachineButton = new Button("Start"); this.startMachineButton.setIcon(new ThemeResource("img/poweron.png")); this.startMachineButton.setEnabled(false); this.startMachineButton.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { Set<?> selectedMachineIds = (Set<?>) MachineView.this.machineTable.getValue(); String id = (String) selectedMachineIds.iterator().next(); try { MachineView.this.machineManager.startMachine(id); } catch (CloudProviderException e) { Util.diplayErrorMessageBox("Cannot start instance", e); } } }); actionButtonHeader.addComponent(this.startMachineButton); this.stopMachineButton = new Button("Stop"); this.stopMachineButton.setIcon(new ThemeResource("img/poweroff.png")); this.stopMachineButton.setEnabled(false); this.stopMachineButton.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { Set<?> selectedMachineIds = (Set<?>) MachineView.this.machineTable.getValue(); String id = (String) selectedMachineIds.iterator().next(); try { MachineView.this.machineManager.stopMachine(id); } catch (CloudProviderException e) { Util.diplayErrorMessageBox("Cannot stop instance", e); } } }); actionButtonHeader.addComponent(this.stopMachineButton); this.restartMachineButton = new Button("Reboot"); this.restartMachineButton.setIcon(new ThemeResource("img/restart.png")); this.restartMachineButton.setEnabled(false); this.restartMachineButton.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { Set<?> selectedMachineIds = (Set<?>) MachineView.this.machineTable.getValue(); String id = (String) selectedMachineIds.iterator().next(); try { MachineView.this.machineManager.restartMachine(id, false); } catch (CloudProviderException e) { Util.diplayErrorMessageBox("Cannot reboot instance", e); } } }); actionButtonHeader.addComponent(this.restartMachineButton); this.deleteMachineButton = new Button("Delete"); this.deleteMachineButton.setIcon(new ThemeResource("img/delete.png")); this.deleteMachineButton.setEnabled(false); this.deleteMachineButton.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { final Set<?> selectedMachineIds = (Set<?>) MachineView.this.machineTable.getValue(); StringBuilder sb = new StringBuilder(); sb.append("Are you sure you want to delete "); if (selectedMachineIds.size() == 1) { Object id = selectedMachineIds.iterator().next(); sb.append("instance " + MachineView.this.machines.getItem(id).getBean().getName() + " ?"); } else { sb.append(" these " + selectedMachineIds.size() + " instances ?"); } ConfirmDialog confirmDialog = ConfirmDialog.newConfirmDialog("Delete Machine", sb.toString(), new ConfirmDialog.ConfirmationDialogCallback() { @Override public void response(final boolean ok, final boolean ignored) { if (ok) { for (Object id : selectedMachineIds) { try { MachineView.this.machineManager.deleteMachine(id.toString()); } catch (CloudProviderException e) { Util.diplayErrorMessageBox("Cannot delete instance", e); } } MachineView.this.valueChange(null); } } }); MachineView.this.getUI().addWindow(confirmDialog); } }); actionButtonHeader.addComponent(this.deleteMachineButton); 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) { MachineView.this.refresh(); } }); button.setIcon(new ThemeResource("img/refresh.png")); actionButtonHeader.addComponent(button); verticalLayout.addComponent(actionButtonHeader); verticalLayout.addComponent(this.machineTable = this.createMachineTable()); verticalLayout.setExpandRatio(this.machineTable, 1.0f); this.setFirstComponent(verticalLayout); this.setSecondComponent(this.detailView = new MachineDetailView(this)); this.setSplitPosition(60.0f); }
From source file:org.ow2.sirocco.cloudmanager.MyUI.java
License:Open Source License
@Override protected void init(final VaadinRequest request) { this.userName = request.getUserPrincipal().getName(); this.identityContext.setUserName(this.userName); this.getPage().setTitle("Sirocco Dashboard"); final VerticalLayout layout = new VerticalLayout(); layout.setSizeFull();/* ww w.j a v a 2 s. c o m*/ this.setContent(layout); // Top header ********************* HorizontalLayout header = new HorizontalLayout(); header.setMargin(true); header.setWidth("100%"); header.setHeight("70px"); header.setStyleName("topHeader"); // logo Image image = new Image(null, new ThemeResource("img/sirocco_small_logo.png")); header.addComponent(image); // spacer Label spacer = new Label(); spacer.setWidth("100%"); header.addComponent(spacer); header.setExpandRatio(spacer, 1.0f); HorizontalLayout rightButtons = new HorizontalLayout(); rightButtons.setStyleName("topHeader"); rightButtons.setSpacing(true); this.userName = request.getUserPrincipal().getName(); User user = null; try { user = this.userManager.getUserByUsername(this.userName); } catch (CloudProviderException e) { e.printStackTrace(); } Label label = new Label("Tenant:"); label.setStyleName("topHeaderLabel"); rightButtons.addComponent(label); final ComboBox tenantSelect = new ComboBox(); tenantSelect.setTextInputAllowed(false); tenantSelect.setNullSelectionAllowed(false); for (Tenant tenant : user.getTenants()) { tenantSelect.addItem(tenant.getName()); } tenantSelect.setValue(user.getTenants().iterator().next().getName()); tenantSelect.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent event) { Notification.show("Switching to tenant " + tenantSelect.getValue()); } }); tenantSelect.setImmediate(true); rightButtons.addComponent(tenantSelect); this.tenantId = user.getTenants().iterator().next().getUuid(); this.identityContext.setTenantId(this.tenantId); // logged user name label = new Label("Logged in as: " + this.userName); label.setStyleName("topHeaderLabel"); rightButtons.addComponent(label); // sign out button Button button = new Button("Sign Out"); // button.setStyleName(BaseTheme.BUTTON_LINK); button.addClickListener(new Button.ClickListener() { public void buttonClick(final ClickEvent event) { MyUI.this.logout(); } }); rightButtons.addComponent(button); header.addComponent(rightButtons); layout.addComponent(header); // Split view HorizontalSplitPanel splitPanel = new HorizontalSplitPanel(); splitPanel.setSizeFull(); splitPanel.setFirstComponent(this.createLeftMenu()); this.inventoryContainer = new VerticalLayout(); this.inventoryContainer.setSizeFull(); this.inventoryContainer.addComponent(this.machineView); splitPanel.setSecondComponent(this.inventoryContainer); splitPanel.setSplitPosition(15); layout.addComponent(splitPanel); layout.setExpandRatio(splitPanel, 1.0f); this.listenToNotifications(); }
From source file:org.ow2.sirocco.cloudmanager.NetworkView.java
License:Open Source License
public NetworkView() { this.setSizeFull(); HorizontalLayout actionButtonHeader = new HorizontalLayout(); actionButtonHeader.setMargin(true);/*from www . java2 s. co m*/ 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 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();/* w w w.j av a2 s .co 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);//from w w w . ja v a2s . c o m 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 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.core.template.DefaultConfirmDialogFactory.java
License:Open Source License
public ConfirmDialog create(final String caption, final String message, final String okCaption, final String cancelCaption) { // Create a confirm dialog final ConfirmDialog confirm = new ConfirmDialog(); confirm.setCaption(caption != null ? caption : DEFAULT_CAPTION); // Close listener implementation confirm.addListener(new Window.CloseListener() { private static final long serialVersionUID = 1971800928047045825L; public void windowClose(CloseEvent ce) { confirm.setConfirmed(false); if (confirm.getListener() != null) { confirm.getListener().onClose(confirm); }/*from w w w . ja v a 2s . c o m*/ } }); // Create content VerticalLayout c = (VerticalLayout) confirm.getContent(); c.setSizeFull(); c.setSpacing(true); // Panel for scrolling lengthty messages. Panel scroll = new Panel(new VerticalLayout()); scroll.setScrollable(true); c.addComponent(scroll); scroll.setWidth("100%"); scroll.setHeight("100%"); scroll.setStyleName(Reindeer.PANEL_LIGHT); c.setExpandRatio(scroll, 1f); // Always HTML, but escape Label text = new Label("", Label.CONTENT_RAW); scroll.addComponent(text); confirm.setMessageLabel(text); confirm.setMessage(message); HorizontalLayout buttons = new HorizontalLayout(); c.addComponent(buttons); buttons.setSpacing(true); buttons.setHeight(format(BUTTON_HEIGHT) + "em"); buttons.setWidth("100%"); Label spacer = new Label(""); buttons.addComponent(spacer); spacer.setWidth("100%"); buttons.setExpandRatio(spacer, 1f); final Button cancel = new Button(cancelCaption != null ? cancelCaption : DEFAULT_CANCEL_CAPTION); cancel.setData(false); cancel.setClickShortcut(KeyCode.ESCAPE, null); buttons.addComponent(cancel); buttons.setComponentAlignment(cancel, Alignment.MIDDLE_RIGHT); confirm.setCancelButton(cancel); final Button ok = new Button(okCaption != null ? okCaption : DEFAULT_OK_CAPTION); ok.setData(true); ok.setClickShortcut(KeyCode.ENTER, null); ok.setStyleName(Reindeer.BUTTON_DEFAULT); ok.focus(); buttons.addComponent(ok); buttons.setComponentAlignment(ok, Alignment.MIDDLE_RIGHT); confirm.setOkButton(ok); // Create a listener for buttons Button.ClickListener cb = new Button.ClickListener() { private static final long serialVersionUID = 3525060915814334881L; public void buttonClick(ClickEvent event) { // Copy the button date to window for passing through either // "OK" or "CANCEL" confirm.setConfirmed(event.getButton() == ok); // This has to be invoked as the window.close // event is not fired when removed. if (confirm.getListener() != null) { confirm.getListener().onClose(confirm); } confirm.close(); } }; cancel.addListener(cb); ok.addListener(cb); // Approximate the size of the dialog double[] dim = getDialogDimensions(message, ConfirmDialog.CONTENT_TEXT_WITH_NEWLINES); confirm.setWidth(format(dim[0]) + "em"); confirm.setHeight(format(dim[1]) + "em"); confirm.setResizable(false); return confirm; }
From source file:org.s23m.cell.editor.semanticdomain.ui.components.EdgeCreationForm.java
License:Mozilla Public License
private void init() { setReadOnly(true);/*from w ww.j ava 2 s . c om*/ setImmediate(true); setWriteThrough(false); setInvalidCommitted(false); // set up form data binding edgeData = new EdgeData(sourceInstance); final BeanItem<EdgeData> item = new BeanItem<EdgeData>(edgeData); setFormFieldFactory(new FormFieldFactory() { public Field createField(final Item item, final Object propertyId, final Component uiContext) { final String pid = (String) propertyId; if (EdgeData.getDisplayedInstances().contains(pid)) { @SuppressWarnings("unchecked") final Set edge = (Set) item.getItemProperty(propertyId).getValue(); //see if this set has any associated instances if (EdgeData.getInstancesWithAssociatedList().contains(pid)) { //Returns a field that shows a list of options final BeanItemContainer<SetData> listContainer = new BeanItemContainer<SetData>( SetData.class); final List<SetData> assocList = EdgeData.getAssociatedListOf(pid); listContainer.addAll(assocList); final ListField listField = new ListField( DefaultFieldFactory.createCaptionByPropertyId(pid), "Select...", listContainer); return listField; } else { //Returns a field that shows the name of a set if (EdgeData.META_ELEMENT.equals(pid)) { final BeanItemContainer<SetData> listContainer = new BeanItemContainer<SetData>( SetData.class); final List<SetData> assocList = edgeData .getAllValidEdgeFlavoredInstances(targetInstance); listContainer.addAll(assocList); final ListField listField = new ListField( DefaultFieldFactory.createCaptionByPropertyId(pid), "Select...", listContainer); metaField = listField; enableOrDisableMetaField(assocList); return listField; } else if (EdgeData.TARGET_INSTANCE.equals(pid)) { //target field final BeanItemContainer<SetData> listContainer = new BeanItemContainer<SetData>( SetData.class); final List<SetData> assocList = edgeData.getAllVisibleVertices(); listContainer.addAll(assocList); final ListField listField = new ListField( DefaultFieldFactory.createCaptionByPropertyId(pid), "Select...", listContainer); targetField = listField; return listField; } else { return new SetField(DefaultFieldFactory.createCaptionByPropertyId(pid), new SetData(edge), true, true); } } } else { final TextField f = new TextField(DefaultFieldFactory.createCaptionByPropertyId(pid)); f.setReadOnly(true); return f; } } }); setItemDataSource(item); setVisibleItemProperties(EdgeData.getDisplayedInstances()); targetField.addEventListener(this); final HorizontalLayout buttonBarLayout = new HorizontalLayout(); buttonBarLayout.setSpacing(true); buttonBarLayout.setHeight(BUTTON_BAR_HEIGHT); getFooter().addComponent(buttonBarLayout); final Button okBtn = new Button("OK", new Button.ClickListener() { public void buttonClick(final ClickEvent event) { try { commit(); processFormData(edgeData); } catch (final Throwable th) { } } private void processFormData(final EdgeData edgeData) { final Set edgeIdentity = lookupSet(EdgeData.EDGE_IDENTITY_INSTANCE); final Set edgeSet = Instantiation.arrow(lookupSet(EdgeData.META_ELEMENT), edgeIdentity, lookupSet(EdgeData.FIRST_SEMANTIC_IDENTITY), lookupSet(EdgeData.SOURCE_INSTANCE), lookupSet(EdgeData.FIRST_MIN_CARDINALITY), lookupSet(EdgeData.FIRST_MAX_CARDINALITY), lookupSet(EdgeData.FIRST_IS_NAVIGABLE), lookupSet(EdgeData.FIRST_IS_CONTAINER), lookupSet(EdgeData.SECOND_SEMANTIC_IDENTITY), lookupSet(EdgeData.TARGET_INSTANCE), lookupSet(EdgeData.SECOND_MIN_CARDINALITY), lookupSet(EdgeData.SECOND_MAX_CARDINALITY), lookupSet(EdgeData.SECOND_IS_NAVIGABLE), lookupSet(EdgeData.SECOND_IS_CONTAINER)); if (edgeSet.identity().name().equals(edgeIdentity.identity().name())) { // propertyChangeSupport.firePropertyChange( // EditorEvents.CHANGESET_MODIFIED.getEventName(), // null, null); ((org.s23m.cell.editor.semanticdomain.Editor) getApplication()).updateContainmentTree(); containerLayout.getParent().closeTab(containerLayout); } containerLayout.getParent().getMainApplication().getMainWindow().showNotification("Edge created"); } }); final Button closeBtn = new Button("Cancel", new Button.ClickListener() { public void buttonClick(final ClickEvent event) { discard(); containerLayout.getParent().closeTab(containerLayout); } }); buttonBarLayout.addComponent(okBtn); buttonBarLayout.addComponent(closeBtn); buttonBarLayout.setComponentAlignment(closeBtn, Alignment.TOP_RIGHT); }
From source file:org.s23m.cell.editor.semanticdomain.ui.components.layout.AdminFormLayout.java
License:Mozilla Public License
private void init() { setMargin(true);//from w w w . ja v a 2 s. c o m final String lblMsg = STATUS_MSG_SERVER_INACTIVE;//RepositoryClientServer.getInstance().isRepositoryServerRunning() ? STATUS_MSG_SERVER_ACTIVE : STATUS_MSG_SERVER_INACTIVE; final Label lblStatus = new Label(lblMsg); addComponent(lblStatus); final HorizontalLayout buttonBarLayout = new HorizontalLayout(); buttonBarLayout.setSpacing(true); buttonBarLayout.setHeight(BUTTON_BAR_HEIGHT); final HorizontalLayout checkinBarLayout = new HorizontalLayout(); checkinBarLayout.setSpacing(true); checkinBarLayout.setHeight(BUTTON_BAR_HEIGHT); final Button okBtn = new Button("Start Repository Client", new Button.ClickListener() { public void buttonClick(final ClickEvent event) { try { if (!RepositoryClientServer.getInstance().isRepositoryServerRunning()) { RepositoryClientServer.getInstance().start(); lblStatus.setValue(STATUS_MSG_SERVER_ACTIVE); } } catch (final Throwable th) { lblStatus.setValue(th); } } }); final Button stopBtn = new Button("Stop Repository Client", new Button.ClickListener() { public void buttonClick(final ClickEvent event) { try { if (RepositoryClientServer.getInstance().isRepositoryServerRunning()) { RepositoryClientServer.getInstance().stop(); lblStatus.setValue(STATUS_MSG_SERVER_INACTIVE); } } catch (final Throwable th) { lblStatus.setValue(th); } } }); buttonBarLayout.addComponent(okBtn); buttonBarLayout.addComponent(stopBtn); buttonBarLayout.setComponentAlignment(stopBtn, Alignment.TOP_RIGHT); final Button checkInButton = new Button("Do initial check-in", new Button.ClickListener() { public void buttonClick(final ClickEvent event) { try { S23MKernel.completeCellKernelInitialization(); CellPlatform.instantiateFeature(); //org.s23m.cell.test.artifactinstantiation.Test.main(null); final ArtefactContainer container = ObjectFactoryHolder.getInstance().createArtefactContainer(); container.setContentType(SerializationType.IN_MEMORY_PERSISTENCE.name()); client.put(container); lblStatus.setValue("Initial check-in done."); } catch (final Throwable th) { lblStatus.setValue(th); } } }); checkInButton.setEnabled(true); checkinBarLayout.addComponent(checkInButton); addComponent(buttonBarLayout); addComponent(checkinBarLayout); }