public Field createField(Item item, Object propertyId, Component uiContext) { String pid = (String) propertyId; PersistentClass entity = ConfigurationMapping.getConfigurationEntity(AddressType.class.getName()); if ("name".equals(pid)) { TextField textField = new TextField( FactoryI18nManager.getI18nManager() .getMessage(Messages.ADDRESS_TYPE_ABM_TABLE_AND_FORM_NAME)); textField.setNullRepresentation(""); textField.setRequired(true); textField.setMaxLength(ConfigurationMapping.getColumnSize("name", entity)); return textField; } else if ("comment".equals(pid)) { TextArea textArea = new TextArea( FactoryI18nManager.getI18nManager() .getMessage(Messages.ADDRESS_TYPE_ABM_TABLE_AND_FORM_COMMENT)); textArea.setWidth("250"); textArea.setHeight("50"); textArea.setNullRepresentation(""); textArea.setMaxLength(ConfigurationMapping.getColumnSize("comment", entity)); // textArea.setRequired(false); // textArea.setMaxLength(maxLength) // textArea.setHeight(height); // textArea.setWidth(width); // textArea.setEnabled(enabled); // textArea.setIcon(icon); return textArea; } return null; }
public void buttonClick(ClickEvent event) { Button source = event.getButton(); dirty = false; if (source == buttonAdd) { if (this.documentsForm.isModified()) { if (!this.documentsForm.isValid()) { getWindow() .showNotification( FactoryI18nManager.getI18nManager().getMessage(Messages.DIALOG_INCORRECT_DATA), Notification.TYPE_ERROR_MESSAGE); return; } if (!isValid()) { getWindow() .showNotification( FactoryI18nManager.getI18nManager() .getMessage(Messages.DIALOG_VALIDATOR_DOCUMENT_EMPTY), Notification.TYPE_ERROR_MESSAGE); return; } dirty = true; this.documentsForm.commit(); } close(); } else if (source == buttonCancel) { dirty = true; cancel(); close(); } else if (source == buttonNew) { DocumentObject d = DocumentObjectFactory.getInstance(); BeanItem<DocumentObject> newBeanItem = new BeanItem<DocumentObject>(d); isNewItem = true; openForm(newBeanItem, readonly, true, context); } else if (source == buttonDelete) { deleteItem(); } else if (source == buttonModify) { if (currentFile != null) { BeanItem<DocumentObject> newBeanItem = new BeanItem<DocumentObject>(currentFile); isNewItem = false; openForm(newBeanItem, readonly, false, context); } } else if (source == buttonLookUp) { if (currentFile != null) { BeanItem<DocumentObject> newBeanItem = new BeanItem<DocumentObject>(currentFile); isNewItem = false; openForm(newBeanItem, true, false, context); // readonly puede ser true o false } } else if (source == buttonDownload) { download(); } }
private boolean validFile() { if (currentFile == null) { getWindow() .showNotification( FactoryI18nManager.getI18nManager().getMessage(Messages.DIALOG_NOTHING_SELECTED), Notification.TYPE_ERROR_MESSAGE); return false; } else { if (currentFile.getUrl() == null) { getWindow() .showNotification( FactoryI18nManager.getI18nManager().getMessage(Messages.DIALOG_NONEXISTING_FILE), Notification.TYPE_ERROR_MESSAGE); return false; } else { return true; } } }
private void deleteItem() { if (currentFile != null) { currentFile.setStateEnable(false); fileTable.removeItem(currentFile); dirty = true; } else { getWindow() .showNotification( FactoryI18nManager.getI18nManager().getMessage(Messages.DIALOG_NOTHING_SELECTED), Notification.TYPE_ERROR_MESSAGE); } }
public TurnSearchForm(TurnSubWindow turnSubWindow) { this.subWindow = turnSubWindow; super.nameMethodFindFilter = "searchFilteredTurn"; super.nameMethodShowAll = "showAllTurn"; super.bean = new Turn(); super.arrPropertyFind = new String[] {"name"}; super.arrPropertyTypeFind = new String[] {CommonSearchForm.DATA_TYPE_STRING}; super.arrMessageField = new String[] { FactoryI18nManager.getI18nManager().getMessage(Messages.TURN_ABM_TABLE_AND_FORM_NAME) }; super.arrPropertyTypeField = new String[] {CommonSearchForm.FIELD_TYPE_TEXT}; super.initialize(); }
private void download() { if (validFile()) { Application app = ((AbstractComponent) subWindow).getApplication(); String file2DL = AttachedDocumentsUtils.getBaseURL(app) + currentFile.getUrl(); File file = new File(file2DL); if (Files.notExists(file.toPath(), LinkOption.NOFOLLOW_LINKS)) { getWindow() .showNotification( FactoryI18nManager.getI18nManager().getMessage(Messages.DIALOG_NONEXISTING_FILE), Notification.TYPE_ERROR_MESSAGE); } else { FileDownloadResource fileDL = new FileDownloadResource(file, app); fileDL.setOutputFile(currentFile.getName() + "." + currentFile.getExtension()); getWindow().open(fileDL, "_top"); } } }
public void setIconsAndDescriptionButton() { buttonNew.setStyleName("newRowButton"); buttonDelete.setStyleName("deleteRowButton"); buttonModify.setStyleName("editButton"); buttonDownload.setStyleName("downloadButton"); buttonAdd.setStyleName("confirmButton"); buttonLookUp.setStyleName("addButton"); buttonCancel.setStyleName("cancelButton"); buttonNew.setDescription( FactoryI18nManager.getI18nManager().getMessage(Messages.BUTTON_DESCRIPTION_NEW)); buttonDelete.setDescription( FactoryI18nManager.getI18nManager().getMessage(Messages.BUTTON_DESCRIPTION_DELETE)); buttonModify.setDescription( FactoryI18nManager.getI18nManager().getMessage(Messages.BUTTON_DESCRIPTION_EDIT)); buttonDownload.setDescription( FactoryI18nManager.getI18nManager().getMessage(Messages.BUTTON_DESCRIPTION_DOWNLOAD)); buttonAdd.setDescription( FactoryI18nManager.getI18nManager().getMessage(Messages.BUTTON_DESCRIPTION_CONFIRM)); buttonLookUp.setDescription( FactoryI18nManager.getI18nManager().getMessage(Messages.BUTTON_DESCRIPTION_LOOK_UP)); buttonCancel.setDescription( FactoryI18nManager.getI18nManager().getMessage(Messages.BUTTON_DESCRIPTION_CANCEL)); }
public void setIconsAndDescriptionButton() { searchButton.setStyleName("searchButton"); minimizeSearchButton.setStyleName("minimizeSearchButton"); maximizeSearchButton.setStyleName("maximizeSearchButton"); minimizeListButton.setStyleName("maximizeListButton"); newBloodFactorButton.setStyleName("newRowButton"); removeBloodFactorButton.setStyleName("deleteRowButton"); searchButton.setDescription( FactoryI18nManager.getI18nManager().getMessage(Messages.BUTTON_DESCRIPTION_SEARCH)); minimizeSearchButton.setDescription( FactoryI18nManager.getI18nManager() .getMessage(Messages.BUTTON_DESCRIPTION_MINIMIZE_SEARCH)); maximizeSearchButton.setDescription( FactoryI18nManager.getI18nManager() .getMessage(Messages.BUTTON_DESCRIPTION_MAXIMIZE_SEARCH)); minimizeListButton.setDescription( FactoryI18nManager.getI18nManager().getMessage(Messages.BUTTON_DESCRIPTION_MINIMIZE_LIST)); newBloodFactorButton.setDescription( FactoryI18nManager.getI18nManager().getMessage(Messages.BUTTON_DESCRIPTION_NEW)); removeBloodFactorButton.setDescription( FactoryI18nManager.getI18nManager().getMessage(Messages.BUTTON_DESCRIPTION_DELETE)); }
public class DivisionContainer extends BeanItemContainer<Division> { private static final long serialVersionUID = 1L; public static final Object[] NATURAL_COL_ORDER = new Object[] {"year", "name", "turn"}; public static final String[] COL_HEADERS_SPANISH = new String[] { FactoryI18nManager.getI18nManager() .getMessage(Messages.DIVISION_ABM_TABLE_AND_FORM_YEAR_CALENDAR), FactoryI18nManager.getI18nManager().getMessage(Messages.DIVISION_ABM_TABLE_AND_FORM_NAME), FactoryI18nManager.getI18nManager().getMessage(Messages.DIVISION_ABM_TABLE_AND_FORM_TURN) }; public DivisionContainer() throws InstantiationException, IllegalAccessException { super(Division.class); } @SuppressWarnings("unchecked") public static DivisionContainer getDivision( DivisionContainer divisionContainer, int offset, DivisionPagingButtonBar paging) { try { if (divisionContainer == null) { divisionContainer = new DivisionContainer(); } divisionContainer.removeAllItems(); LoadAllFacade facade = new LoadAllFacade(paging.context); Object result[] = facade.loadAllDivision(offset, paging.LIMIT); paging.numberOfPages = ((Integer) result[0]).intValue(); Set<Division> divisionSet = (Set<Division>) result[1]; paging.SIZE = ((Long) result[2]).longValue(); divisionContainer.addAll(divisionSet); } catch (Exception e) { e.printStackTrace(); } return divisionContainer; } @SuppressWarnings("unchecked") public static DivisionContainer getDivision( DivisionContainer divisionContainer, int offset, int limit, WebApplicationContext context) { try { if (divisionContainer == null) { divisionContainer = new DivisionContainer(); } divisionContainer.removeAllItems(); LoadAllFacade facade = new LoadAllFacade(context); Object result[] = facade.loadAllDivision(offset, limit); // paging.numberOfPages = ((Integer) result[0]).intValue(); Set<Division> divisionSet = (Set<Division>) result[1]; // paging.SIZE = ((Long) result[2]).longValue(); divisionContainer.addAll(divisionSet); } catch (Exception e) { e.printStackTrace(); } return divisionContainer; } @SuppressWarnings("unchecked") public static DivisionContainer getDivision( DivisionContainer divisionContainer, Division division, int offset, DivisionPagingButtonBar paging) { try { if (divisionContainer == null) { divisionContainer = new DivisionContainer(); } divisionContainer.removeAllItems(); LoadFilteredFacade loadFilteredFacade = new LoadFilteredFacade(paging.context); Object result[] = loadFilteredFacade.loadFilteredDivision(division, offset, paging.LIMIT); paging.numberOfPages = ((Integer) result[0]).intValue(); Set<Division> divisionSet = (Set<Division>) result[1]; paging.SIZE = ((Long) result[2]).longValue(); divisionContainer.addAll(divisionSet); } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return divisionContainer; } @SuppressWarnings("unchecked") public static DivisionContainer getDivisionSearch( DivisionContainer divisionContainer, Division division, int offset, DivisionPagingButtonBar paging) { try { if (divisionContainer == null) { divisionContainer = new DivisionContainer(); } divisionContainer.removeAllItems(); LoadFilteredFacade loadFilteredFacade = new LoadFilteredFacade(paging.context); Object result[] = loadFilteredFacade.loadFilteredDivisionSearch(division, offset, paging.LIMIT); paging.numberOfPages = ((Integer) result[0]).intValue(); Set<Division> divisionSet = (Set<Division>) result[1]; paging.SIZE = ((Long) result[2]).longValue(); if (divisionSet != null) divisionContainer.addAll(divisionSet); } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return divisionContainer; } @SuppressWarnings("unchecked") public static DivisionContainer getDivision( DivisionContainer divisionContainer, Division division, int offset, int limit, WebApplicationContext context) { try { if (divisionContainer == null) { divisionContainer = new DivisionContainer(); } divisionContainer.removeAllItems(); LoadFilteredFacade loadFilteredFacade = new LoadFilteredFacade(context); Object result[] = loadFilteredFacade.loadFilteredDivision(division, offset, limit); // paging.numberOfPages = ((Integer) result[0]).intValue(); Set<Division> divisionSet = (Set<Division>) result[1]; // paging.SIZE = ((Long) result[2]).longValue(); divisionContainer.addAll(divisionSet); } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return divisionContainer; } @SuppressWarnings("unchecked") public static DivisionContainer getDivisionByWatchamn( DivisionContainer divisionContainer, Division division, int offset, int limit, WebApplicationContext context) { try { if (divisionContainer == null) { divisionContainer = new DivisionContainer(); } divisionContainer.removeAllItems(); LoadFilteredFacade loadFilteredFacade = new LoadFilteredFacade(context); Object result[] = loadFilteredFacade.loadFilteredDivisionByWatchman(division, offset, limit); Set<Division> divisionSet = null; if (result != null && result.length > 0) { divisionSet = (Set<Division>) result[1]; divisionContainer.addAll(divisionSet); } } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return divisionContainer; } @SuppressWarnings("unchecked") public static DivisionContainer getDivisionByWatchmanPeriod( DivisionContainer divisionContainer, Division division, int period, int offset, int limit, WebApplicationContext context) { try { if (divisionContainer == null) { divisionContainer = new DivisionContainer(); } divisionContainer.removeAllItems(); LoadFilteredFacade loadFilteredFacade = new LoadFilteredFacade(context); Object result[] = loadFilteredFacade.loadFilteredDivisionByWatchmanPeriod(division, period, offset, limit); Set<Division> divisionSet = null; if (result != null && result.length > 0) { divisionSet = (Set<Division>) result[1]; divisionContainer.addAll(divisionSet); } } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return divisionContainer; } @SuppressWarnings("unchecked") public static DivisionContainer getDivisionByPeriod( DivisionContainer divisionContainer, Division division, int period, int offset, int limit, WebApplicationContext context) { try { if (divisionContainer == null) { divisionContainer = new DivisionContainer(); } divisionContainer.removeAllItems(); LoadFilteredFacade loadFilteredFacade = new LoadFilteredFacade(context); Object result[] = loadFilteredFacade.loadFilteredDivisionByPeriod(division, period, offset, limit); Set<Division> divisionSet = null; if (result != null && result.length > 0) { divisionSet = (Set<Division>) result[1]; divisionContainer.addAll(divisionSet); } } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return divisionContainer; } }
public AttachedDocumentsSubWindow( Window subWindow, BeanItem<AttachedDocumentObject> beanItem, boolean readonly, boolean isNewAttach, WebApplicationContext context) { this.context = context; this.subWindow = subWindow; this.beanItem = beanItem; this.readonly = readonly; setCaption(FactoryI18nManager.getI18nManager().getMessage(Messages.COMMON_ABM_TAB_DOCUMENTS)); setModal(true); setHeight("68%"); setWidth("40%"); center(); setStyleName("pagingButtonBar"); documentsForm = new AttachedDocumentsForm(); documentsForm.setFormFieldFactory(new AttachedDocumentsFormFieldFactory()); fileTable = new Table(); fileTable.setWidth("500"); fileTable.setHeight("180"); fileTable.setSelectable(true); fileTable.setImmediate(true); fileTable.addContainerProperty( FactoryI18nManager.getI18nManager() .getMessage(Messages.ATTACHED_DOCUMENT_OBJECT_FILE_TABLE_HEADER_NAME), String.class, null); fileTable.addContainerProperty( FactoryI18nManager.getI18nManager() .getMessage(Messages.ATTACHED_DOCUMENT_OBJECT_FILE_TABLE_HEADER_SIZE), String.class, null); fileTable.addListener((ValueChangeListener) this); footerTable = new HorizontalLayout(); footerTable.setVisible(true); setIconsAndDescriptionButton(); footerTable.addComponent(buttonNew); footerTable.addComponent(buttonDelete); footerTable.addComponent(buttonModify); footerTable.addComponent(buttonDownload); footerTable.addComponent(buttonLookUp); verticalLayout.setMargin(true); verticalLayout.addComponent(documentsForm); verticalLayout.addComponent(new Label("Archivos:")); verticalLayout.addComponent(fileTable); verticalLayout.addComponent(footerTable); horizontalLayout.addComponent(buttonAdd); horizontalLayout.setComponentAlignment(buttonAdd, Alignment.BOTTOM_CENTER); horizontalLayout.addComponent(buttonCancel); horizontalLayout.setComponentAlignment(buttonCancel, Alignment.BOTTOM_CENTER); verticalLayout.addComponent(horizontalLayout); verticalLayout.setComponentAlignment(horizontalLayout, Alignment.BOTTOM_CENTER); setContent(verticalLayout); initializeForm(); initializeTable(); setComponentsState(isNewAttach); setClosable(readonly); }
public class EditSanctionActsFormUp extends FormLayout implements ClickListener { private static final long serialVersionUID = 1L; private LoadSanctionActSubWindow loadSanctionActSubWindow = null; private EditSanctionActsSubWindow editSanctionActsSubWindow = null; private I18nManager i18nManager = FactoryI18nManager.getI18nManager(); private TextField divisionTextField = new TextField( i18nManager.getMessage(Messages.ABSENCEACT_SUBWINDOW_EDIT_ABSENCE_ACT_FORM_DIVISION)); private TextField enrollmentTextField = new TextField( i18nManager.getMessage(Messages.ABSENCEACT_SUBWINDOW_EDIT_ABSENCE_ACT_FORM_ENROLLMENT)); private TextField stateLcTextField = new TextField("Estado Matricula:"); private Button reloadButton = new Button("", (ClickListener) this); private GridLayout gridLayout = new GridLayout(4, 4); public EditSanctionActsFormUp(EditSanctionActsSubWindow editSanctionActsSubWindow) { this.editSanctionActsSubWindow = editSanctionActsSubWindow; this.loadSanctionActSubWindow = editSanctionActsSubWindow.getLoadSanctionActSubWindow(); removeAllComponents(); setMargin(true); gridLayout.setWidth("95%"); gridLayout.setHeight("65%"); gridLayout.setImmediate(true); // gridLayout.setMargin(true); gridLayout.setSpacing(false); initializeDivisionComboBox(); initializeEnrollmentTextField(); initializeStateLcTextField(); // initializeTrimesterComponents(); addComponent(gridLayout); } private void initializeDivisionComboBox() { FormLayout divisionFormLayout = new FormLayout(); divisionTextField.setWidth("60%"); divisionTextField.setNullRepresentation(""); divisionTextField.setImmediate(true); divisionTextField.setValue(loadSanctionActSubWindow.getDivisionSelected()); divisionTextField.setReadOnly(true); divisionFormLayout.addComponent(divisionTextField); gridLayout.addComponent(divisionFormLayout, 0, 0); gridLayout.setComponentAlignment(divisionFormLayout, Alignment.MIDDLE_LEFT); } private void initializeEnrollmentTextField() { FormLayout enrollmentFormLayout = new FormLayout(); enrollmentTextField.setWidth("90%"); enrollmentTextField.setNullRepresentation(""); enrollmentTextField.setRequired(true); Enrollment enrollmentSelected = editSanctionActsSubWindow.getLoadSanctionActList().getEnrollmentSelected(); if (enrollmentSelected != null) enrollmentTextField.setValue(enrollmentSelected); enrollmentFormLayout.addComponent(enrollmentTextField); enrollmentTextField.setReadOnly(true); gridLayout.addComponent(enrollmentFormLayout, 0, 1); gridLayout.setComponentAlignment(enrollmentFormLayout, Alignment.MIDDLE_LEFT); } private void initializeStateLcTextField() { stateLcTextField.setWidth("90%"); stateLcTextField.setNullRepresentation(""); stateLcTextField.setRequired(true); reloadButton.setStyleName("buttonReload"); reloadButton.setDescription("Generar Reincorporación"); reloadButton.setVisible(false); FormLayout formLayout = new FormLayout(); formLayout.setSizeFull(); formLayout.setMargin(false); formLayout.setSpacing(true); formLayout.addComponent(stateLcTextField); gridLayout.addComponent(formLayout, 0, 2); gridLayout.setComponentAlignment(formLayout, Alignment.MIDDLE_LEFT); TextField reinstTextField = new TextField("Reincorporación:"); Enrollment enrollmentSelected = editSanctionActsSubWindow.getLoadSanctionActList().getEnrollmentSelected(); if (enrollmentSelected != null && enrollmentSelected.getStateLc() != null) { stateLcTextField.setValue( loadSanctionActSubWindow .getLoadSanctionActList() .getfilteredFacade() .getTypeStateEnrolled(enrollmentSelected.getId())); if (enrollmentSelected.getStateLc().equals("E") || enrollmentSelected.getStateLc().equals("F") || enrollmentSelected.getStateLc().equals("G")) { List<Reinstatement> lst = loadSanctionActSubWindow .getLoadSanctionActList() .getfilteredFacade() .getIsInitReinstatementByStateLc(enrollmentSelected); if (lst != null && lst.size() > 0) { Reinstatement reinst = lst.get(0); reinstTextField.setValue( loadSanctionActSubWindow .getLoadSanctionActList() .getfilteredFacade() .getNameStateLc(reinst.getStateLc(), "REINSTATEMENT")); gridLayout.addComponent(reinstTextField, 1, 2); gridLayout.setComponentAlignment(reinstTextField, Alignment.MIDDLE_LEFT); reinstTextField.setReadOnly(true); } else { reloadButton.setVisible(true); gridLayout.addComponent(reloadButton, 1, 2); gridLayout.setComponentAlignment(reloadButton, Alignment.MIDDLE_LEFT); } } } stateLcTextField.setReadOnly(true); } public void buttonClick(ClickEvent event) { Button source = event.getButton(); if (source.equals(reloadButton)) { Enrollment enrollmentSelected = editSanctionActsSubWindow.getLoadSanctionActList().getEnrollmentSelected(); } } }