private Select buildPairSelect() { IndexedContainer pairsCon = new IndexedContainer(); for (Pair pair : Pair.values()) { pairsCon.addItem(pair); } Select pairSelect = new Select("Select Pair"); pairSelect.setContainerDataSource(pairsCon); return pairSelect; }
@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); } }
private void buildFeedSelect() { IndexedContainer feedsCon = new IndexedContainer(); File feedFolder = new File(feedsPath); for (String feed : feedFolder.list()) { feedsCon.addItem(feed); } feedSelect.setContainerDataSource(feedsCon); }
@Override public void buttonClick(Button.ClickEvent clickEvent) { if (clickEvent.getSource() == myOkButton) { onOk((T) mySelect.getValue()); } else { onCancel(); } }
public SelectWindow( float width, int units, Collection<T> items, T selectedItem, Resource icon, String caption, String message, String okButtonText, String cancelButtonText) { super(); if (caption != null) { setCaption(caption); } if (icon != null) { setIcon(icon); } setWidth(width, units); setModal(true); setClosable(false); setResizable(false); setDraggable(false); VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setMargin(true); verticalLayout.setSpacing(true); setContent(verticalLayout); Label label = new Label(message); addComponent(label); mySelect = new Select(null, items); mySelect.setNullSelectionAllowed(false); mySelect.setValue(selectedItem != null ? selectedItem : items.iterator().next()); mySelect.setWidth(100, Sizeable.UNITS_PERCENTAGE); addComponent(mySelect); Panel panel = new Panel(); addComponent(panel); verticalLayout.setComponentAlignment(panel, Alignment.MIDDLE_RIGHT); panel.addStyleName("light"); HorizontalLayout horizontalLayout = new HorizontalLayout(); panel.setContent(horizontalLayout); horizontalLayout.setSpacing(true); verticalLayout.setComponentAlignment(panel, Alignment.MIDDLE_RIGHT); myCancelButton = new Button(cancelButtonText, this); panel.addComponent(myCancelButton); myOkButton = new Button(okButtonText, this); panel.addComponent(myOkButton); }
@SuppressWarnings("serial") @Override public void afterPropertiesSet() throws Exception { setHeight("200px"); setWidth("700px"); crossNameOptionGroup = new OptionGroup(); sequenceNumCheckBox = new CheckBox(); sequenceNumCheckBox.setImmediate(true); sequenceNumCheckBox.addListener( new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { enableSpecifyLeadingZerosComponents(sequenceNumCheckBox.booleanValue()); } }); specifyPrefixLabel = new Label(); prefixTextField = new TextField(); prefixTextField.setWidth("500px"); howManyDigitsLabel = new Label(); leadingZerosSelect = new Select(); for (int i = 1; i <= MAX_LEADING_ZEROS; i++) { leadingZerosSelect.addItem(Integer.valueOf(i)); } leadingZerosSelect.setNullSelectionAllowed(false); leadingZerosSelect.select(Integer.valueOf(1)); leadingZerosSelect.setWidth("50px"); specifySuffixLabel = new Label(); suffixTextField = new TextField(); suffixTextField.setWidth("500px"); nextNameInSequenceLabel = new Label(); generatedNameLabel = new Label(); generateButton = new Button(); generateButton.setData(GENERATE_BUTTON_ID); generateButton.addListener(new CrossingManagerImportButtonClickListener(this)); layoutComponents(); initializeToggableComponents(); }
private VerticalLayout generateCreateNewTypeForm() { typeFrm = new Form(); Select selCatg = new Select( STRINGS.getString(AccountsMessages.BAL_SHEET_PAYMENT_CATEGORY), categories.keySet()); selCatg.setNullSelectionAllowed(false); selCatg.setImmediate(true); TextField typeName = new TextField( STRINGS.getString(AccountsMessages.BAL_SHEET_PAYMENT_CATEGORY) + " " + STRINGS.getString(AccountsMessages.NAME)); typeName.addValidator(new ConfirmUniqueTypeNameFieldValidator(selCatg, categories)); typeFrm.addField(ADD_TYPE_FLD_NAME, typeName); typeFrm.addField(ADD_TYPE_FLD_CAT, selCatg); return generateGenericTabSheet(typeFrm, ADD_NEW_TYPE); }
/** * Sets the value of the current field component. * * @param value The value to set */ public void setValue(Object value) { if (fieldComponent != null) { if (fieldComponent instanceof Field) { Field field = ((Field) fieldComponent); field.setValue(value); if (field instanceof Select) { ((Select) fieldComponent).select(value); } } else if (fieldComponent instanceof FilterContainer) { ((FilterContainer) fieldComponent).setValue(value); } } }
private String getNumberWithLeadingZeroesAsString(Integer number) { StringBuilder sb = new StringBuilder(); String numberString = number.toString(); if (sequenceNumCheckBox.booleanValue()) { Integer numOfZeros = (Integer) leadingZerosSelect.getValue(); int numOfZerosNeeded = numOfZeros - numberString.length(); if (numOfZerosNeeded > 0) { for (int i = 0; i < numOfZerosNeeded; i++) { sb.append("0"); } } } sb.append(number); return sb.toString(); }
private void populateKindergartenSelect() { Select kindergartenSelect = this.getView().getKindergarten(); kindergartenSelect.addItem(ApplicationConstants.SELECT_ALL); kindergartenSelect.setItemCaption( ApplicationConstants.SELECT_ALL, this.getMessage("kindergarten.select.all", this.getLocale())); kindergartenSelect.select(ApplicationConstants.SELECT_ALL); for (KindergartenDTO kindergarten : kindergartenService.getAll()) { kindergartenSelect.addItem(kindergarten.getId()); kindergartenSelect.setItemCaption(kindergarten.getId(), kindergarten.getName()); } }
@Override protected void writeToConfig() { MyTunesRss.CONFIG.setWebLoginMessage(myWebLoginMessage.getStringValue(null)); MyTunesRss.CONFIG.setWebWelcomeMessage(myWebWelcomeMessage.getStringValue(null)); MyTunesRss.CONFIG.setServerBrowserActive(myServerBrowserActive.booleanValue()); MyTunesRss.CONFIG.setOpenIdActive(myOpenIdActive.booleanValue()); MyTunesRss.CONFIG.setProxyHost(myProxyHost.getStringValue(null)); MyTunesRss.CONFIG.setProxyPort(myProxyPort.getIntegerValue(-1)); MyTunesRss.CONFIG.setMailHost(myMailHost.getStringValue(null)); MyTunesRss.CONFIG.setMailPort(myMailPort.getIntegerValue(-1)); MyTunesRss.CONFIG.setSmtpProtocol((SmtpProtocol) mySmtpProtocol.getValue()); MyTunesRss.CONFIG.setMailLogin(myMailLogin.getStringValue(null)); MyTunesRss.CONFIG.setMailPassword(myMailPassword.getStringValue(null)); MyTunesRss.CONFIG.setMailSender(myMailSender.getStringValue(null)); MyTunesRss.CONFIG.setHeadless(myHeadless.booleanValue()); String gmBinary = myGraphicsMagickBinary.getStringValue(null); MyTunesRss.CONFIG.setGmExecutable(gmBinary != null ? new File(gmBinary) : null); MyTunesRss.CONFIG.setGmEnabled(myGraphicsMagickEnabled.booleanValue()); MyTunesRss.CONFIG.save(); }
@Override protected void initFromConfig() { myWebLoginMessage.setValue(MyTunesRss.CONFIG.getWebLoginMessage()); myWebWelcomeMessage.setValue(MyTunesRss.CONFIG.getWebWelcomeMessage()); myServerBrowserActive.setValue(MyTunesRss.CONFIG.isServerBrowserActive()); myOpenIdActive.setValue(MyTunesRss.CONFIG.isOpenIdActive()); myProxyHost.setValue(MyTunesRss.CONFIG.getProxyHost()); myProxyPort.setValue(MyTunesRss.CONFIG.getProxyPort(), 1, 65535, ""); myMailHost.setValue(MyTunesRss.CONFIG.getMailHost()); myMailPort.setValue(MyTunesRss.CONFIG.getMailPort(), 1, 65535, ""); mySmtpProtocol.setValue(MyTunesRss.CONFIG.getSmtpProtocol()); myMailLogin.setValue(MyTunesRss.CONFIG.getMailLogin()); myMailPassword.setValue(MyTunesRss.CONFIG.getMailPassword()); myMailSender.setValue(MyTunesRss.CONFIG.getMailSender()); myHeadless.setValue(MyTunesRss.CONFIG.isHeadless()); myGraphicsMagickEnabled.setValue(MyTunesRss.CONFIG.isGmEnabled()); myGraphicsMagickBinary.setValue( MyTunesRss.CONFIG.getGmExecutable() != null ? MyTunesRss.CONFIG.getGmExecutable().getAbsolutePath() : ""); }
private ExperimentBean validateForm() { ExperimentBean newExp; if (select.getValue() == null) // new experiment { String expName = (String) expNameField.getValue(); String expSpecies = (String) speciesField.getValue(); String expSampleType = (String) sampleTypeField.getValue(); String expSampleProcessing = (String) sampleProcessingField.getValue(); String expInstrumentType = (String) instrumentTypeField.getValue(); String expFragMode = (String) fragModeField.getValue(); String expUploadedByName = (String) UploadedByNameField.getValue(); String expEmail = (String) emailField.getValue(); String expPublicationLink = (String) publicationLinkField.getValue(); String expDescription = (String) descriptionField.getValue(); if ((expName == null) || (expDescription == null) || (expSpecies == null) || (expSampleType == null) || (expSampleProcessing == null) || (expInstrumentType == null) || (expFragMode == null) || (expUploadedByName == null) || (expEmail == null) || expName.equals("") || expDescription.equals("") || expSpecies.equals("") || expSampleType.equals("") || expSampleProcessing.equals("") || expInstrumentType.equals("") || expFragMode.equals("") || expUploadedByName.equals("") || expEmail.equals("")) { // file didn't store in data base newExpForm.commit(); newExpForm.focus(); return null; } else { boolean checkName = false; for (ExperimentBean exp : expList.values()) { if (exp.getName().equalsIgnoreCase(expName)) { checkName = true; break; } } if (checkName) { expNameField.setValue("This Name is Not Available Please Choose Another Name "); expNameField.commit(); newExpForm.focus(); return null; } else { newExp = new ExperimentBean(); newExp.setName(expName); newExp.setSpecies(expSpecies); newExp.setSampleType(expSampleType); newExp.setSampleProcessing(expSampleProcessing); newExp.setInstrumentType(expInstrumentType); newExp.setFragMode(expFragMode); newExp.setUploadedByName(expUploadedByName); newExp.setEmail(expEmail); newExp.setPublicationLink(expPublicationLink); newExp.setExpId(-1); newExp.setDescription(expDescription); return newExp; } } } else // update old experiment { String str = select.getValue().toString(); String[] strArr = str.split("\t"); int id = (Integer.valueOf(strArr[0])); ExperimentBean exp = expList.get(id); return exp; } }
@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); }