@SuppressWarnings("deprecation") private Form getRemoveForm(final String admin) { removeExperimentForm = new Form(); removeExperimentForm.setCaption("Remove Existing Experiment"); removeExperimentForm.setWidth("50%"); expList = eh.getExperiments(null); List<String> strExpList = new ArrayList<String>(); for (ExperimentBean exp : expList.values()) { if (user.getEmail().equalsIgnoreCase("*****@*****.**") || exp.getEmail().equalsIgnoreCase(user.getEmail())) { String str = exp.getExpId() + " " + exp.getName() + " ( " + exp.getUploadedByName() + " )"; strExpList.add(str); } } final Select selectExp = new Select("Experiment ID", strExpList); selectExp.setWidth("100%"); removeExperimentForm.addField(Integer.valueOf(1), selectExp); Button removeExpButton = new Button("Remove Experiment"); removeExpButton.setStyle(Reindeer.BUTTON_SMALL); removeExperimentForm.addField(Integer.valueOf(2), removeExpButton); removeExpButton.addListener( new ClickListener() { /** */ private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { String str = selectExp.getValue().toString(); String[] strArr = str.split("\t"); Integer expId = (Integer.valueOf(strArr[0])); if (expId != null) { boolean test = auth.removeExp(expId); if (test) { updateComponents(user); } else { getWindow().showNotification("Failed to Remove The Experiment! "); } } else { } } }); return removeExperimentForm; }
/** * Fills the form with current field component. Adds additional widgets if needed (i.e. "select * all" box) * * @param form The form to place the field in * @param layout The layout that displays the field */ public void placeYourselfInForm(Form form, FormLayout layout) { if (fieldComponent == null) { return; } if (fieldComponent instanceof Field) { form.addField(name, (Field) fieldComponent); } else if (fieldComponent instanceof FilterContainer) { for (Select select : ((FilterContainer) fieldComponent).getLevels()) { form.addField(select.getCaption(), select); } } else { layout.addComponent(fieldComponent); } if (selectAll) { final CheckBox saCheckbox = UiFactory.createCheckBox(UiIds.AR_MSG_SELECT_ALL, null); saCheckbox.addListener( new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { boolean selected = (Boolean) saCheckbox.getValue(); if (fieldComponent instanceof Select) { for (Object itemId : ((Select) fieldComponent).getItemIds()) { if (selected) { ((Select) fieldComponent).select(itemId); } else { ((Select) fieldComponent).unselect(itemId); } } } if (fieldComponent instanceof FilterContainer) { List<Select> selectList = ((FilterContainer) fieldComponent).getLevels(); Select select = selectList.get(selectList.size() - 1); for (Object itemId : select.getItemIds()) { if (selected) { select.select(itemId); } else { select.unselect(itemId); } } } } }); form.addField(name + "_all", saCheckbox); } }
@Override public void init() { Window mainWindow = new Window("Test Application"); Form form = new Form(); form.setCaption("Form Caption"); form.setDescription( "This is a description of the Form that is " + "displayed in the upper part of the form. You normally " + "enter some descriptive text about the form and its " + "use here."); // Add a field and bind it to an named item property. form.addField("nom", new TextField("Nom")); form.addField("prenom", new TextField("Prenom")); form.addField("age", new TextField("Age")); // Set the footer layout. form.setFooter(new VerticalLayout()); form.getFooter() .addComponent( new Label( "This is the footer area of the Form. " + "You can use any layout here. " + "This is nice for buttons.")); // Have a button bar in the footer. HorizontalLayout okbar = new HorizontalLayout(); okbar.setHeight("25px"); form.getFooter().addComponent(okbar); Button okbutton = new Button("OK", form, "commit"); okbutton.addListener(new OkListener(form)); okbar.addComponent(okbutton); okbar.setComponentAlignment(okbutton, Alignment.TOP_RIGHT); Button resetbutton = new Button("Reset", form, "discard"); resetbutton.addListener(new ResetListener(form)); okbar.addComponent(resetbutton); mainWindow.addComponent(form); setMainWindow(mainWindow); }
@SuppressWarnings({"deprecation", "serial"}) private void updateComponents(final User user) { if (container != null) { container.removeAllComponents(); } container = new Panel(); root = new Panel(); root.setStyle(Reindeer.PANEL_LIGHT); container.setHeight("100%"); container.setStyle(Reindeer.PANEL_LIGHT); setCompositionRoot(container); // Create the Form newExpForm = new Form(); newExpForm.setCaption("New Experiment"); newExpForm.setWriteThrough(false); // we want explicit 'apply' newExpForm.setInvalidCommitted(false); // no invalid values in data model // Determines which properties are shown, and in which order: expNameField = new TextField("Experiment Name:"); expNameField.setStyle(Reindeer.TEXTFIELD_SMALL); expNameField.setRequired(true); expNameField.setRequiredError("EXPERIMENT NAME CAN NOT BE EMPTY!"); expNameField.setWidth("350px"); expNameField.setMaxLength(70); speciesField = new TextField("Species:"); speciesField.setStyle(Reindeer.TEXTFIELD_SMALL); speciesField.setRequired(true); speciesField.setRequiredError("EXPERIMENT SPECIES CAN NOT BE EMPTY!"); speciesField.setWidth("350px"); speciesField.setMaxLength(70); sampleTypeField = new TextField("Sample Type:"); sampleTypeField.setStyle(Reindeer.TEXTFIELD_SMALL); sampleTypeField.setRequired(true); sampleTypeField.setRequiredError("EXPERIMENT SAMPLE TYPE CAN NOT BE EMPTY!"); sampleTypeField.setWidth("350px"); sampleTypeField.setMaxLength(70); sampleProcessingField = new TextField("Sample Processing:"); sampleProcessingField.setStyle(Reindeer.TEXTFIELD_SMALL); sampleProcessingField.setRequired(true); sampleProcessingField.setRequiredError("EXPERIMENT SAMPLE PROCESSING CAN NOT BE EMPTY!"); sampleProcessingField.setWidth("350px"); sampleProcessingField.setMaxLength(70); instrumentTypeField = new TextField("Instrument Type:"); instrumentTypeField.setStyle(Reindeer.TEXTFIELD_SMALL); instrumentTypeField.setRequired(true); instrumentTypeField.setRequiredError("EXPERIMENT INSTURMENT TYPE CAN NOT BE EMPTY!"); instrumentTypeField.setWidth("350px"); instrumentTypeField.setMaxLength(70); fragModeField = new TextField("Frag Mode:"); fragModeField.setStyle(Reindeer.TEXTFIELD_SMALL); fragModeField.setRequired(true); fragModeField.setRequiredError("EXPERIMENT FRAG MODE CAN NOT BE EMPTY!"); fragModeField.setWidth("350px"); fragModeField.setMaxLength(70); UploadedByNameField = new TextField("Uploaded By:"); UploadedByNameField.setStyle(Reindeer.TEXTFIELD_SMALL); UploadedByNameField.setRequired(true); UploadedByNameField.setRequiredError("EXPERIMENT UPLOADED BY CAN NOT BE EMPTY!"); UploadedByNameField.setValue(user.getUsername()); UploadedByNameField.setEnabled(false); UploadedByNameField.setWidth("350px"); UploadedByNameField.setMaxLength(70); emailField = new TextField("Email:"); emailField.setStyle(Reindeer.TEXTFIELD_SMALL); emailField.setRequired(true); emailField.setValue(user.getEmail()); emailField.setEnabled(false); emailField.setRequiredError("EXPERIMENT EMAIL CAN NOT BE EMPTY!"); emailField.setWidth("350px"); emailField.setMaxLength(70); descriptionField = new TextArea("Description:"); descriptionField.setStyle(Reindeer.TEXTFIELD_SMALL); descriptionField.setRequired(true); descriptionField.setRequiredError("EXPERIMENT Description CAN NOT BE EMPTY!"); descriptionField.setWidth("350px"); descriptionField.setMaxLength(950); publicationLinkField = new TextField("Publication Link:"); publicationLinkField.setStyle(Reindeer.TEXTFIELD_SMALL); publicationLinkField.setWidth("350px"); publicationLinkField.setMaxLength(300); newExpForm.addField(Integer.valueOf(1), expNameField); newExpForm.addField(Integer.valueOf(2), descriptionField); newExpForm.addField(Integer.valueOf(3), speciesField); newExpForm.addField(Integer.valueOf(4), sampleTypeField); newExpForm.addField(Integer.valueOf(5), sampleProcessingField); newExpForm.addField(Integer.valueOf(6), instrumentTypeField); newExpForm.addField(Integer.valueOf(7), fragModeField); newExpForm.addField(Integer.valueOf(8), UploadedByNameField); newExpForm.addField(Integer.valueOf(9), emailField); newExpForm.addField(Integer.valueOf(10), publicationLinkField); // Add form to layout container.addComponent(newExpForm); Panel p = new Panel(); Label l = new Label( "<h4 style='color:blue'>Or Update Existing Experiments !</h4><h4 style='color:blue'>For New Experiment Please Leave Experiment ID Blank!</h4><h4 style='color:blue'><strong style='color:red'>* </strong> For New Experiment Please Remember to Upload Protein file first!</h4>"); l.setContentMode(Label.CONTENT_XHTML); p.addComponent(l); container.addComponent(p); // Create the Form Form existExpForm = new Form(); existExpForm.setCaption("Exist Experiments"); expList = eh.getExperiments(null); List<String> strExpList = new ArrayList<String>(); for (ExperimentBean exp : expList.values()) { if (user.getEmail().equalsIgnoreCase("*****@*****.**") || exp.getEmail().equalsIgnoreCase(user.getEmail())) { String str = exp.getExpId() + " " + exp.getName() + " ( " + exp.getUploadedByName() + " )"; strExpList.add(str); } } select = new Select("Experiment ID", strExpList); select.setImmediate(true); select.addListener( new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { Object o = select.getValue(); if (o != null) { String str = select.getValue().toString(); String[] strArr = str.split("\t"); int id = (Integer.valueOf(strArr[0])); ExperimentBean expDet = expList.get(id); if (expDetails != null) { expDetails.removeAllComponents(); if (expDet.getProteinsNumber() == 0) { Label l = new Label("<h4 style='color:red'>1) Protein File is Missing</h4>"); l.setContentMode(Label.CONTENT_XHTML); expDetails.addComponent(l); } else { Label l = new Label("<h4 style='color:blue'>1) Protein File is Uploaded</h4>"); l.setContentMode(Label.CONTENT_XHTML); expDetails.addComponent(l); } if (expDet.getFractionsNumber() == 0) { Label l = new Label("<h4 style='color:red'>2) Fraction File is Missing</h4>"); l.setContentMode(Label.CONTENT_XHTML); expDetails.addComponent(l); } else { Label l = new Label("<h4 style='color:blue'>2) Fraction File Uploaded</h4>"); l.setContentMode(Label.CONTENT_XHTML); expDetails.addComponent(l); } // if (expDet.getFractionRange() == 0) { // Label l = new Label("<h4 style='color:red'>3) Fraction // Range File is Missing</h4>"); // l.setContentMode(Label.CONTENT_XHTML); // expDetails.addComponent(l); // } else { // Label l = new Label("<h4 style='color:blue'>3) // Fraction Range File Uploaded</h4>"); // l.setContentMode(Label.CONTENT_XHTML); // expDetails.addComponent(l); // } if (expDet.getPeptidesNumber() == 0) { Label l = new Label("<h4 style='color:red'>3) Peptides File is Missing</h4>"); l.setContentMode(Label.CONTENT_XHTML); expDetails.addComponent(l); } else { Label l = new Label("<h4 style='color:blue'>3) Peptides File Uploaded</h4>"); l.setContentMode(Label.CONTENT_XHTML); expDetails.addComponent(l); } } } else { expDetails.removeAllComponents(); Label labelDetails = new Label( "<h4 style='color:red;'>Please Select Experiment To Show the Details.</h4>"); labelDetails.setContentMode(Label.CONTENT_XHTML); expDetails.addComponent(labelDetails); } } }); select.setWidth("60%"); existExpForm.addField(Integer.valueOf(1), select); // Add form to layout VerticalLayout vlo = new VerticalLayout(); if (hslo != null) { vlo.removeComponent(hslo); } hslo = new HorizontalLayout(); hslo.setSizeFull(); hslo.addComponent(existExpForm); vlo.addComponent(hslo); if (removeExperimentLayout != null) { hslo.removeComponent(removeExperimentLayout); } removeExperimentLayout = this.getRemoveForm(user.getEmail()); hslo.addComponent(removeExperimentLayout); hslo.setComponentAlignment(removeExperimentForm, Alignment.MIDDLE_CENTER); vlo.addComponent(hslo); container.addComponent(vlo); // Create the Upload component. upload = new Upload(null, this); upload.setStyleName("small"); upload.setVisible(true); upload.setHeight("30px"); upload.setButtonCaption("ADD / EDIT EXPERIMENT !"); // ***************************************************** upload.addListener( new Upload.StartedListener() { @SuppressWarnings("static-access") @Override public void uploadStarted(StartedEvent event) { try { Thread.currentThread().sleep(1000); Thread t = new Thread( new Runnable() { @Override public void run() { pi.setVisible(true); } }); t.start(); t.join(); } catch (InterruptedException e) { } mainTabs.setReadOnly(true); subTabs.setReadOnly(true); } }); upload.addListener( new Upload.FinishedListener() { @Override public void uploadFinished(FinishedEvent event) { pi.setVisible(false); mainTabs.setReadOnly(false); subTabs.setReadOnly(false); file = new File(event.getFilename()); } }); // *********************************** upload.addListener((Upload.SucceededListener) this); upload.addListener((Upload.FailedListener) this); if (helpNote != null) { vlo.removeComponent(helpNote); } Label label = new Label( "<h4 style='color:red;'>Please upload proteins file first</h4><h4 style='color:red;'>Please upload proteins files in (.txt) format.</h4><h4 style='color:red;'>Upload fraction range file after upload protein fraction file.</h4><h4 style='color:red;'>Upload fraction range file in (.xlsx) format.</h4>"); label.setContentMode(Label.CONTENT_XHTML); helpNote = help.getHelpNote(label); helpNote.setMargin(false, true, true, true); vlo.addComponent(upload); vlo.addComponent(pi); vlo.addComponent(helpNote); vlo.setComponentAlignment(helpNote, Alignment.MIDDLE_RIGHT); expDetails = new Panel("Experiment Details"); Label labelDetails = new Label("<h4 style='color:red;'>Please Select Experiment To Show the Details.</h4>"); labelDetails.setContentMode(Label.CONTENT_XHTML); expDetails.addComponent(labelDetails); vlo.addComponent(expDetails); root.addComponent(vlo); container.addComponent(root); }
@Override public void attach() { super.attach(); init( getBundleString("streamingConfigPanel.caption"), getComponentFactory().createGridLayout(1, 5, true, true)); myVlcEnabled = getComponentFactory().createCheckBox("streamingConfigPanel.vlcEnabled"); myVlcBinary = getComponentFactory() .createTextField( "streamingConfigPanel.vlcBinary", new VlcExecutableFileValidator( getBundleString("streamingConfigPanel.vlcBinary.invalidBinary"))); myVlcBinary.setImmediate(false); myVlcBinarySelect = getComponentFactory().createButton("streamingConfigPanel.vlcBinary.select", this); myVlcHomepageButton = getComponentFactory().createButton("streamingConfigPanel.vlcHomepage", this); myVlcForm = getComponentFactory().createForm(null, true); myVlcForm.addField(myVlcEnabled, myVlcEnabled); myVlcForm.addField(myVlcBinary, myVlcBinary); myVlcForm.addField(myVlcBinarySelect, myVlcBinarySelect); myVlcForm.addField(myVlcHomepageButton, myVlcHomepageButton); Panel vlcPanel = getComponentFactory() .surroundWithPanel( myVlcForm, FORM_PANEL_MARGIN_INFO, getBundleString("streamingConfigPanel.caption.vlc")); addComponent(vlcPanel); Panel transcoderPanel = new Panel(getBundleString("streamingConfigPanel.caption.transcoder")); transcoderPanel.setContent(getComponentFactory().createVerticalLayout(true, true)); Panel addTranscoderButtons = new Panel(); addTranscoderButtons.addStyleName("light"); addTranscoderButtons.setContent( getApplication().getComponentFactory().createHorizontalLayout(false, true)); myAddTranscoder = getComponentFactory().createButton("streamingConfigPanel.transcoder.add", this); addTranscoderButtons.addComponent(myAddTranscoder); myTranscoderTable = new Table(); myTranscoderTable.setCacheRate(50); myTranscoderTable.addContainerProperty( "name", String.class, null, getBundleString("streamingConfigPanel.transcoder.name"), null, null); myTranscoderTable.addContainerProperty("edit", Button.class, null, "", null, null); myTranscoderTable.addContainerProperty("delete", Button.class, null, "", null, null); myTranscoderTable.setSortContainerPropertyId("name"); transcoderPanel.addComponent(myTranscoderTable); transcoderPanel.addComponent(addTranscoderButtons); addComponent(transcoderPanel); myCacheForm = getComponentFactory().createForm(null, true); myTranscodingCacheMaxGiB = getComponentFactory() .createTextField( "streamingConfigPanel.cache.transcodingCacheMaxGiB", getApplication().getValidatorFactory().createMinMaxValidator(1, 1024)); myCacheForm.addField("limitTranscoding", myTranscodingCacheMaxGiB); myHttpLiveStreamCacheMaxGiB = getComponentFactory() .createTextField( "streamingConfigPanel.cache.httpLiveStreamCacheMaxGiB", getApplication().getValidatorFactory().createMinMaxValidator(1, 1024)); myCacheForm.addField("limitHttpLiveStream", myHttpLiveStreamCacheMaxGiB); myClearAllCachesButton = getComponentFactory().createButton("streamingConfigPanel.clearAllCaches", this); myCacheForm.addField(myClearAllCachesButton, myClearAllCachesButton); addComponent( getComponentFactory() .surroundWithPanel( myCacheForm, FORM_PANEL_MARGIN_INFO, getBundleString("streamingConfigPanel.caption.cache"))); addDefaultComponents(0, 4, 0, 4, false); initFromConfig(); }
@Override public void attach() { super.attach(); init( getBundleString("miscConfigPanel.caption"), getComponentFactory().createGridLayout(1, 6, true, true)); myMainWindowForm = getComponentFactory().createForm(null, true); myMyTunesRssComForm = getComponentFactory().createForm(null, true); myWebInterfaceForm = getComponentFactory().createForm(null, true); myProxyForm = getComponentFactory().createForm(null, true); mySmtpForm = getComponentFactory().createForm(null, true); myWebLoginMessage = getComponentFactory().createTextField("miscConfigPanel.webLoginMessage"); myWebWelcomeMessage = getComponentFactory().createTextField("miscConfigPanel.webWelcomeMessage"); myServerBrowserActive = getComponentFactory().createCheckBox("miscConfigPanel.serverBrowserActive"); myOpenIdActive = getComponentFactory().createCheckBox("miscConfigPanel.openIdActive"); myProxyHost = getComponentFactory().createTextField("miscConfigPanel.proxyHost"); myProxyPort = getComponentFactory() .createTextField( "miscConfigPanel.proxyPort", getApplication().getValidatorFactory().createPortValidator()); myMailHost = getComponentFactory().createTextField("miscConfigPanel.mailHost"); myMailPort = getComponentFactory() .createTextField( "miscConfigPanel.mailPort", getApplication().getValidatorFactory().createPortValidator()); mySmtpProtocol = getComponentFactory() .createSelect( "miscConfigPanel.smtpProtocol", Arrays.asList(SmtpProtocol.PLAINTEXT, SmtpProtocol.STARTTLS, SmtpProtocol.SSL)); myMailLogin = getComponentFactory().createTextField("miscConfigPanel.mailLogin"); myMailPassword = getComponentFactory().createPasswordTextField("miscConfigPanel.mailPassword"); myMailSender = getComponentFactory() .createTextField( "miscConfigPanel.mailSender", getApplication().getValidatorFactory().createEmailValidator()); myHeadless = getComponentFactory().createCheckBox("miscConfigPanel.headless"); myMainWindowForm.addField(myHeadless, myHeadless); Panel mainWindowPanel = getComponentFactory() .surroundWithPanel( myMainWindowForm, FORM_PANEL_MARGIN_INFO, getBundleString("miscConfigPanel.caption.mainWindow")); addComponent(mainWindowPanel); myProxyForm.addField(myProxyHost, myProxyHost); myProxyForm.addField(myProxyPort, myProxyPort); Panel proxyPanel = getComponentFactory() .surroundWithPanel( myProxyForm, FORM_PANEL_MARGIN_INFO, getBundleString("miscConfigPanel.caption.proxy")); addComponent(proxyPanel); mySmtpForm.addField(myMailHost, myMailHost); mySmtpForm.addField(myMailPort, myMailPort); mySmtpForm.addField(mySmtpProtocol, mySmtpProtocol); mySmtpForm.addField(myMailLogin, myMailLogin); mySmtpForm.addField(myMailPassword, myMailPassword); mySmtpForm.addField(myMailSender, myMailSender); Panel smtpPanel = getComponentFactory() .surroundWithPanel( mySmtpForm, FORM_PANEL_MARGIN_INFO, getBundleString("miscConfigPanel.caption.smtp")); addComponent(smtpPanel); myWebInterfaceForm.addField(myWebLoginMessage, myWebLoginMessage); myWebInterfaceForm.addField(myWebWelcomeMessage, myWebWelcomeMessage); myWebInterfaceForm.addField(myServerBrowserActive, myServerBrowserActive); myWebInterfaceForm.addField(myOpenIdActive, myOpenIdActive); Panel webInterfacePanel = getComponentFactory() .surroundWithPanel( myWebInterfaceForm, FORM_PANEL_MARGIN_INFO, getBundleString("miscConfigPanel.caption.webInterface")); addComponent(webInterfacePanel); myGraphicsMagickEnabled = getComponentFactory().createCheckBox("miscConfigPanel.graphicsMagickEnabled"); myGraphicsMagickBinary = getComponentFactory() .createTextField( "miscConfigPanel.graphicsMagickBinary", new GraphicsMagickExecutableFileValidator( getBundleString("miscConfigPanel.graphicsMagickBinary.invalidBinary"))); myGraphicsMagickBinary.setImmediate(false); myGraphicsMagickBinarySelect = getComponentFactory().createButton("miscConfigPanel.graphicsMagickBinary.select", this); myGraphicsMagickHomepageButton = getComponentFactory().createButton("miscConfigPanel.graphicsMagickHomepage", this); myGraphicsMagickForm = getComponentFactory().createForm(null, true); myGraphicsMagickForm.addField(myGraphicsMagickEnabled, myGraphicsMagickEnabled); myGraphicsMagickForm.addField(myGraphicsMagickBinary, myGraphicsMagickBinary); myGraphicsMagickForm.addField(myGraphicsMagickBinarySelect, myGraphicsMagickBinarySelect); myGraphicsMagickForm.addField(myGraphicsMagickHomepageButton, myGraphicsMagickHomepageButton); Panel graphicsMagickPanel = getComponentFactory() .surroundWithPanel( myGraphicsMagickForm, FORM_PANEL_MARGIN_INFO, getBundleString("miscConfigPanel.caption.GraphicsMagick")); addComponent(graphicsMagickPanel); addDefaultComponents(0, 5, 0, 5, false); initFromConfig(); }