List of usage examples for com.vaadin.ui HorizontalLayout setMargin
@Override public void setMargin(boolean enabled)
From source file:nz.co.senanque.workflow.GenericVaadinForm.java
License:Apache License
protected HorizontalLayout createButtons() { log.debug("isReadOnlyForm():{}", isReadOnlyForm()); okay = fieldGroup.createSubmitButton("OK", this); okay.setReadOnly(isReadOnlyForm());//from w ww. j a v a2 s . c om okay.setEnabled(!isReadOnlyForm()); cancel = fieldGroup.createButton("cancel", this); HorizontalLayout actions = new HorizontalLayout(); actions.setMargin(true); actions.setSpacing(true); actions.addComponent(okay); cancel.addClickListener(this); actions.addComponent(cancel); park = fieldGroup.createSubmitButton("park", this); park.setReadOnly(this.isReadOnlyForm()); park.setEnabled(!isReadOnlyForm()); actions.addComponent(park); park.addClickListener(this); park.setVisible(false); return actions; }
From source file:nz.co.senanque.workflowui.AttachmentsPopup.java
License:Apache License
@SuppressWarnings("serial") public void load(final long pid) { m_currentPid = pid;//from w ww . j a v a 2s.c o m panel.removeAllComponents(); HorizontalLayout hl = new HorizontalLayout(); hl.setMargin(true); hl.setSpacing(true); Button done = new Button(m_messageSourceAccessor.getMessage("done", "Close")); done.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { close(); } }); Button newAttachment = new Button(m_messageSourceAccessor.getMessage("new", "New")); newAttachment.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { m_attachmentPopup.load(m_currentPid); ; } }); hl.addComponent(newAttachment); hl.addComponent(done); panel.addComponent(hl); refresh(); try { Method method = this.getClass().getMethod("refresh", new Class<?>[] {}); m_attachmentPopup.addListener(AttachmentEvent.class, this, method); } catch (NoSuchMethodException | SecurityException e) { e.printStackTrace(); } if (getParent() == null) { UI.getCurrent().addWindow(this); this.center(); } }
From source file:nz.co.senanque.workflowui.AuditPopup.java
License:Apache License
@SuppressWarnings("serial") private Component getInitialLayout() { VerticalLayout ret = new VerticalLayout(); // Buttons/*from w ww . j a v a2s .co m*/ Button close = new Button(m_messageSourceAccessor.getMessage("close", "Close")); HorizontalLayout actions = new HorizontalLayout(); actions.setMargin(true); actions.setSpacing(true); actions.addComponent(close); close.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { close(); } }); ret.addComponent(actions); return ret; }
From source file:nz.co.senanque.workflowui.LaunchWizard.java
License:Apache License
@SuppressWarnings("serial") private Component getInitialLayout() { VerticalLayout ret = new VerticalLayout(); // Buttons//from w ww . j a v a 2 s . co m final Button cancel = new Button(m_messageSourceAccessor.getMessage("Cancel", "Cancel")); HorizontalLayout actions = new HorizontalLayout(); actions.setMargin(true); actions.setSpacing(true); actions.addComponent(cancel); cancel.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { close(); } }); select.setImmediate(true); select.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { ProcessDefinitionHolder pdh = (ProcessDefinitionHolder) select.getValue(); if (pdh != null) { select.unselect(pdh); final ProcessDefinition processDefinition = pdh.getProcessDefinition(); final WorkflowForm form = m_workflowClient.getLaunchForm(processDefinition.getName()); form.getProcessInstance().setBundleName(processDefinition.getVersion()); form.bind(); ((VerticalLayout) form).addListener(new Listener() { @Override public void componentEvent(Event event) { try { Object o = ((Button) event.getComponent()).getData(); String s = (o == null) ? "" : o.toString(); if ("Cancel".equals(s)) { close(); } else if (s.startsWith(WorkflowForm.OK)) { panel.removeAllComponents(); panel.addComponent(getFinalLayout(processDefinition.getName(), Long.parseLong(s.substring(WorkflowForm.OK.length())), form.isLauncher())); panel.markAsDirty(); ; } } catch (Exception e) { // ignore null pointer exceptions etc e.printStackTrace(); } } }); panel.removeAllComponents(); panel.setSizeUndefined(); panel.addComponent((VerticalLayout) form); panel.markAsDirty(); } } }); ret.addComponent(select); ret.addComponent(actions); return ret; }
From source file:nz.co.senanque.workflowui.LaunchWizard.java
License:Apache License
@SuppressWarnings("serial") private Component getFinalLayout(String processName, final long processId, final boolean launcher) { VerticalLayout ret = new VerticalLayout(); Button okay = new Button(m_messageSourceAccessor.getMessage("OK", "Okay")); HorizontalLayout actions = new HorizontalLayout(); Label label = new Label( m_messageSourceAccessor.getMessage("launched.processid", new Object[] { processName, processId })); ret.addComponent(label);// www . j a v a 2s . c o m actions.setMargin(true); actions.setSpacing(true); actions.addComponent(okay); okay.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { close(); Button button = (com.vaadin.ui.Button) (event.getSource()); button.setData((launcher ? WorkflowForm.LAUNCH : WorkflowForm.OK) + processId); fireEvent(event); } }); ret.addComponent(actions); Button attachments = new Button(m_messageSourceAccessor.getMessage("attachments", "Attachments")); actions.addComponent(attachments); attachments.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { m_attachmentsPopup.load(processId); } }); return ret; }
From source file:org.activiti.explorer.ui.management.crystalball.EventOverviewPanel.java
License:Apache License
protected void initProcessInstances() { HorizontalLayout instancesHeader = new HorizontalLayout(); instancesHeader.setSpacing(false);/* w ww.j ava2 s .c o m*/ instancesHeader.setMargin(false); instancesHeader.setWidth(100, UNITS_PERCENTAGE); instancesHeader.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK); addDetailComponent(instancesHeader); initProcessInstanceTitle(instancesHeader); HorizontalLayout selectLayout = new HorizontalLayout(); selectLayout.setSpacing(true); selectLayout.setMargin(true); selectLayout.setWidth(50, UNITS_PERCENTAGE); addDetailComponent(selectLayout); definitionSelect = new NativeSelect(i18nManager.getMessage(Messages.DEPLOYMENT_HEADER_DEFINITIONS)); definitionSelect.setImmediate(true); for (ProcessDefinition definition : definitionList) { definitionSelect.addItem(definition.getId()); definitionSelect.setItemCaption(definition.getId(), definition.getName()); } definitionSelect.addListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { if (definitionSelect.getValue() != null) { String selectedDefinitionId = (String) definitionSelect.getValue(); ExplorerApp.get().setCrystalBallCurrentDefinitionId(selectedDefinitionId); refreshInstances(selectedDefinitionId); } } }); selectLayout.addComponent(definitionSelect); replayButton = new Button(i18nManager.getMessage(Messages.CRYSTALBALL_BUTTON_REPLAY)); replayButton.setEnabled(false); replayButton.addListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { if (instanceTable.getValue() != null) { String processInstanceId = (String) instanceTable.getValue(); ExplorerApp.get().setCrystalBallCurrentInstanceId(processInstanceId); List<EventLogEntry> eventLogEntries = managementService .getEventLogEntriesByProcessInstanceId(processInstanceId); if (eventLogEntries == null || eventLogEntries.isEmpty()) return; EventLogTransformer transformer = new EventLogTransformer(getTransformers()); simulationEvents = transformer.transform(eventLogEntries); ExplorerApp.get().setCrystalBallSimulationEvents(simulationEvents); SimpleEventCalendar eventCalendar = new SimpleEventCalendar( ProcessEngines.getDefaultProcessEngine().getProcessEngineConfiguration().getClock(), new SimulationEventComparator()); eventCalendar.addEvents(simulationEvents); // replay process instance run simulationDebugger = new ReplaySimulationRun(ProcessEngines.getDefaultProcessEngine(), eventCalendar, getReplayHandlers(processInstanceId)); ExplorerApp.get().setCrystalBallSimulationDebugger(simulationDebugger); simulationDebugger.init(new NoExecutionVariableScope()); simulationDebugger.step(); // replay process was started List<HistoricProcessInstance> replayProcessInstanceList = historyService .createHistoricProcessInstanceQuery() .processInstanceBusinessKey(SIMULATION_BUSINESS_KEY).orderByProcessInstanceStartTime() .desc().list(); if (replayProcessInstanceList != null && !replayProcessInstanceList.isEmpty()) { replayHistoricInstance = replayProcessInstanceList.get(0); } refreshEvents(); } } }); selectLayout.addComponent(replayButton); selectLayout.setComponentAlignment(replayButton, Alignment.MIDDLE_LEFT); instanceLayout = new HorizontalLayout(); instanceLayout.setWidth(100, UNITS_PERCENTAGE); addDetailComponent(instanceLayout); initInstancesTable(); }
From source file:org.apache.ace.webui.vaadin.AddArtifactWindow.java
License:Apache License
/** * Creates a new {@link AddArtifactWindow} instance. * //from ww w .j a va 2 s. c o m * @param sessionDir * the session directory to temporary place artifacts in; * @param obrUrl * the URL of the OBR to use. */ public AddArtifactWindow(File sessionDir, URL obrUrl, String repositoryXML) { super("Add artifact"); m_sessionDir = sessionDir; m_obrUrl = obrUrl; m_repositoryXML = repositoryXML; setModal(true); setWidth("50em"); setCloseShortcut(KeyCode.ESCAPE); m_artifactsTable = new Table("Artifacts in repository"); m_artifactsTable.addContainerProperty(PROPERTY_SYMBOLIC_NAME, String.class, null); m_artifactsTable.addContainerProperty(PROPERTY_VERSION, String.class, null); m_artifactsTable.addContainerProperty(PROPERTY_PURGE, Button.class, null); m_artifactsTable.setSizeFull(); m_artifactsTable.setSelectable(true); m_artifactsTable.setMultiSelect(true); m_artifactsTable.setImmediate(true); m_artifactsTable.setHeight("15em"); final Table uploadedArtifacts = new Table("Uploaded artifacts"); uploadedArtifacts.addContainerProperty(PROPERTY_SYMBOLIC_NAME, String.class, null); uploadedArtifacts.addContainerProperty(PROPERTY_VERSION, String.class, null); uploadedArtifacts.setSizeFull(); uploadedArtifacts.setSelectable(false); uploadedArtifacts.setMultiSelect(false); uploadedArtifacts.setImmediate(true); uploadedArtifacts.setHeight("15em"); final GenericUploadHandler uploadHandler = new GenericUploadHandler(m_sessionDir) { @Override public void updateProgress(long readBytes, long contentLength) { // TODO Auto-generated method stub } @Override protected void artifactsUploaded(List<UploadHandle> uploads) { for (UploadHandle handle : uploads) { try { URL artifact = handle.getFile().toURI().toURL(); Item item = uploadedArtifacts.addItem(artifact); item.getItemProperty(PROPERTY_SYMBOLIC_NAME).setValue(handle.getFilename()); item.getItemProperty(PROPERTY_VERSION).setValue(""); m_uploadedArtifacts.add(handle.getFile()); } catch (MalformedURLException e) { showErrorNotification("Upload artifact processing failed", "<br />Reason: " + e.getMessage()); logError("Processing of " + handle.getFilename() + " failed.", e); } } } }; final Upload uploadArtifact = new Upload(); uploadArtifact.setCaption("Upload Artifact"); uploadHandler.install(uploadArtifact); final DragAndDropWrapper finalUploadedArtifacts = new DragAndDropWrapper(uploadedArtifacts); finalUploadedArtifacts.setDropHandler(new ArtifactDropHandler(uploadHandler)); addListener(new Window.CloseListener() { public void windowClose(CloseEvent e) { for (File artifact : m_uploadedArtifacts) { artifact.delete(); } } }); HorizontalLayout searchBar = new HorizontalLayout(); searchBar.setMargin(false); searchBar.setSpacing(true); final TextField searchField = new TextField(); searchField.setImmediate(true); searchField.setValue(""); final IndexedContainer dataSource = (IndexedContainer) m_artifactsTable.getContainerDataSource(); m_searchButton = new Button("Search", new ClickListener() { public void buttonClick(ClickEvent event) { String searchValue = (String) searchField.getValue(); dataSource.removeAllContainerFilters(); if (searchValue != null && searchValue.trim().length() > 0) { dataSource.addContainerFilter(PROPERTY_SYMBOLIC_NAME, searchValue, true /* ignoreCase */, false /* onlyMatchPrefix */); } } }); m_searchButton.setImmediate(true); searchBar.addComponent(searchField); searchBar.addComponent(m_searchButton); m_addButton = new Button("Add", new ClickListener() { public void buttonClick(ClickEvent event) { // Import all "local" (existing) bundles... importLocalBundles(m_artifactsTable); // Import all "remote" (non existing) bundles... importRemoteBundles(m_uploadedArtifacts); close(); } }); m_addButton.setImmediate(true); m_addButton.setStyleName(Reindeer.BUTTON_DEFAULT); m_addButton.setClickShortcut(KeyCode.ENTER); VerticalLayout layout = (VerticalLayout) getContent(); layout.setMargin(true); layout.setSpacing(true); layout.addComponent(searchBar); layout.addComponent(m_artifactsTable); layout.addComponent(uploadArtifact); layout.addComponent(finalUploadedArtifacts); // The components added to the window are actually added to the window's // layout; you can use either. Alignments are set using the layout layout.addComponent(m_addButton); layout.setComponentAlignment(m_addButton, Alignment.MIDDLE_RIGHT); searchField.focus(); }
From source file:org.bubblecloud.ilves.component.flow.AbstractFlowlet.java
License:Apache License
@Override public final void attach() { super.attach(); this.setSizeFull(); rootLayout = new GridLayout(1, 2); rootLayout.setMargin(false);/* w ww . j a v a 2 s . c om*/ rootLayout.setSpacing(true); rootLayout.setSizeFull(); rootLayout.setRowExpandRatio(0, 0f); rootLayout.setRowExpandRatio(1, 1f); final HorizontalLayout titleLayout = new HorizontalLayout(); titleLayout.setMargin(new MarginInfo(true, false, true, false)); titleLayout.setSpacing(true); final Embedded titleIcon = new Embedded(null, getSite().getIcon("view-icon-" + getFlowletKey())); titleIcon.setWidth(32, Unit.PIXELS); titleIcon.setHeight(32, Unit.PIXELS); titleLayout.addComponent(titleIcon); final Label titleLabel = new Label("<h1>" + getSite().localize("view-" + getFlowletKey()) + "</h1>", ContentMode.HTML); titleLayout.addComponent(titleLabel); rootLayout.addComponent(titleLayout, 0, 0); setCompositionRoot(rootLayout); initialize(); }
From source file:org.bubblecloud.ilves.ui.anonymous.login.LoginFlowlet.java
License:Apache License
@SuppressWarnings("serial") @Override/*from w ww. j a v a2 s . co m*/ public void initialize() { final VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); final Company company = getSite().getSiteContext().getObject(Company.class); if (company.isOpenIdLogin()) { final VerticalLayout mainPanel = new VerticalLayout(); mainPanel.setCaption(getSite().localize("header-open-id-login")); layout.addComponent(mainPanel); final HorizontalLayout openIdLayout = new HorizontalLayout(); mainPanel.addComponent(openIdLayout); openIdLayout.setMargin(new MarginInfo(false, false, true, false)); openIdLayout.setSpacing(true); final String returnViewName = "openidlogin"; final Map<String, String> urlIconMap = OpenIdUtil.getOpenIdProviderUrlIconMap(); for (final String url : urlIconMap.keySet()) { openIdLayout.addComponent(OpenIdUtil.getLoginButton(url, urlIconMap.get(url), returnViewName)); } } try { final CustomLayout loginFormLayout = new CustomLayout( JadeUtil.parse("/VAADIN/themes/ilves/layouts/login.jade")); Responsive.makeResponsive(loginFormLayout); loginFormLayout.setCaption(getSite().localize("header-email-and-password-login")); layout.addComponent(loginFormLayout); } catch (final IOException e) { throw new SiteException("Error loading login form.", e); } if (company.isSelfRegistration()) { final Button registerButton = new Button(getSite().localize("button-register") + " >>"); registerButton.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { getFlow().forward(RegisterFlowlet.class); } }); layout.addComponent(registerButton); } if (company.isEmailPasswordReset()) { final Button forgotPasswordButton = new Button(getSite().localize("button-forgot-password") + " >>"); forgotPasswordButton.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { getFlow().forward(ForgotPasswordFlowlet.class); } }); layout.addComponent(forgotPasswordButton); } final Panel panel = new Panel(); panel.setSizeUndefined(); panel.setContent(layout); setViewContent(panel); }
From source file:org.bubblecloud.ilves.ui.anonymous.login.RegisterFlowlet.java
License:Apache License
@Override public void initialize() { originalPasswordProperty = new ObjectProperty<String>(null, String.class); verifiedPasswordProperty = new ObjectProperty<String>(null, String.class); final List<FieldDescriptor> fieldDescriptors = new ArrayList<FieldDescriptor>(); final PasswordValidator passwordValidator = new PasswordValidator(getSite(), originalPasswordProperty, "password2"); //fieldDescriptors.addAll(SiteFields.getFieldDescriptors(Customer.class)); for (final FieldDescriptor fieldDescriptor : SiteFields.getFieldDescriptors(Customer.class)) { if (fieldDescriptor.getId().equals("adminGroup")) { continue; }//from w ww . j a v a 2 s. c om if (fieldDescriptor.getId().equals("memberGroup")) { continue; } if (fieldDescriptor.getId().equals("created")) { continue; } if (fieldDescriptor.getId().equals("modified")) { continue; } fieldDescriptors.add(fieldDescriptor); } //fieldDescriptors.remove(fieldDescriptors.size() - 1); //fieldDescriptors.remove(fieldDescriptors.size() - 1); fieldDescriptors .add(new FieldDescriptor("password1", getSite().localize("input-password"), PasswordField.class, null, 150, null, String.class, null, false, true, true).addValidator(passwordValidator)); fieldDescriptors.add(new FieldDescriptor("password2", getSite().localize("input-password-verification"), PasswordField.class, null, 150, null, String.class, null, false, true, true) .addValidator(new PasswordVerificationValidator(getSite(), originalPasswordProperty))); editor = new ValidatingEditor(fieldDescriptors); passwordValidator.setEditor(editor); final Button registerButton = new Button(getSite().localize("button-register")); registerButton.setStyleName(ValoTheme.BUTTON_PRIMARY); registerButton.addClickListener(new ClickListener() { /** The default serial version ID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { editor.commit(); customer.setCreated(new Date()); customer.setModified(customer.getCreated()); final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class); final Company company = getSite().getSiteContext().getObject(Company.class); final PostalAddress invoicingAddress = new PostalAddress(); invoicingAddress.setAddressLineOne("?"); invoicingAddress.setAddressLineTwo("?"); invoicingAddress.setAddressLineThree("?"); invoicingAddress.setCity("?"); invoicingAddress.setPostalCode("?"); invoicingAddress.setCountry("?"); final PostalAddress deliveryAddress = new PostalAddress(); deliveryAddress.setAddressLineOne("?"); deliveryAddress.setAddressLineTwo("?"); deliveryAddress.setAddressLineThree("?"); deliveryAddress.setCity("?"); deliveryAddress.setPostalCode("?"); deliveryAddress.setCountry("?"); customer.setInvoicingAddress(invoicingAddress); customer.setDeliveryAddress(deliveryAddress); if (UserDao.getUser(entityManager, company, customer.getEmailAddress()) != null) { Notification.show(getSite().localize("message-user-email-address-registered"), Notification.Type.WARNING_MESSAGE); return; } final HttpServletRequest request = ((VaadinServletRequest) VaadinService.getCurrentRequest()) .getHttpServletRequest(); try { final byte[] passwordAndSaltBytes = (customer.getEmailAddress() + ":" + ((String) originalPasswordProperty.getValue())).getBytes("UTF-8"); final MessageDigest md = MessageDigest.getInstance("SHA-256"); final byte[] passwordAndSaltDigest = md.digest(passwordAndSaltBytes); customer.setOwner(company); final User user = new User(company, customer.getFirstName(), customer.getLastName(), customer.getEmailAddress(), customer.getPhoneNumber(), StringUtil.toHexString(passwordAndSaltDigest)); SecurityService.addUser(getSite().getSiteContext(), user, UserDao.getGroup(entityManager, company, "user")); if (SiteModuleManager.isModuleInitialized(CustomerModule.class)) { SecurityService.addCustomer(getSite().getSiteContext(), customer, user); } final String url = company.getUrl() + "#!validate/" + user.getUserId(); final Thread emailThread = new Thread(new Runnable() { @Override public void run() { EmailUtil.send(PropertiesUtil.getProperty("site", "smtp-host"), user.getEmailAddress(), company.getSupportEmailAddress(), "Email Validation", "Please validate your email by browsing to this URL: " + url); } }); emailThread.start(); LOGGER.info("User registered " + user.getEmailAddress() + " (IP: " + request.getRemoteHost() + ":" + request.getRemotePort() + ")"); Notification.show(getSite().localize("message-registration-success"), Notification.Type.HUMANIZED_MESSAGE); getFlow().back(); } catch (final Exception e) { LOGGER.error("Error adding user. (IP: " + request.getRemoteHost() + ":" + request.getRemotePort() + ")", e); Notification.show(getSite().localize("message-registration-error"), Notification.Type.WARNING_MESSAGE); } reset(); } }); editor.addListener(new ValidatingEditorStateListener() { @Override public void editorStateChanged(final ValidatingEditor source) { if (source.isValid()) { registerButton.setEnabled(true); } else { registerButton.setEnabled(false); } } }); reset(); final VerticalLayout panel = new VerticalLayout(); panel.addComponent(editor); panel.addComponent(registerButton); panel.setSpacing(true); final HorizontalLayout mainLayout = new HorizontalLayout(); mainLayout.setMargin(true); mainLayout.addComponent(panel); final Panel mainPanel = new Panel(); mainPanel.setSizeUndefined(); mainPanel.setContent(mainLayout); setViewContent(mainPanel); }