List of usage examples for javax.imageio.stream FileImageOutputStream write
public void write(int b) throws IOException
From source file:edu.ku.brc.specify.extras.FishBaseInfoGetter.java
/** * Performs a "generic" HTTP request and fill member variable with results use * "getDigirResultsetStr" to get the results as a String * *///ww w .ja va2 s. co m public Image getImage(final String fileName, final String url) { imageURL = url; String fullPath = tmpDir + File.separator + fileName; ////System.out.println(fullPath); File file = new File(fullPath); if (file.exists()) { try { return new ImageIcon(fullPath).getImage(); } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(FishBaseInfoGetter.class, ex); ex.printStackTrace(); status = ErrorCode.Error; } } else { byte[] bytes = super.doHTTPRequest(url); try { FileImageOutputStream fos = new FileImageOutputStream(file); fos.write(bytes); fos.flush(); fos.close(); return new ImageIcon(bytes).getImage(); } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(FishBaseInfoGetter.class, ex); ex.printStackTrace(); status = ErrorCode.Error; } } return null; }
From source file:com.lynk.hrm.ui.dialog.InfoEmployee.java
private void updateData() { uiId.setText(employee.getId());// ww w . j av a2 s . c o m uiName.setText(employee.getName()); uiNamePy.setText(employee.getNamePy()); if (StringUtils.isNotEmpty(employee.getState())) { uiState.setSelectedItem(employee.getState()); switch (employee.getState()) { case Employee.STATE_LEAVE: case Employee.STATE_RETIRE: case Employee.STATE_DELETE: uiInfoTab.setSelectedIndex(1); break; case Employee.STATE_SUSPEND: uiInfoTab.setSelectedIndex(2); break; case Employee.STATE_PROBATION: case Employee.STATE_CONTRACT: default: break; } } uiTimeCardLeaveCertify.setText(employee.getTimeCard()); uiIdCard.setText(employee.getIdCard()); uiBirthday.setText(employee.getBirthday()); uiAge.setText(employee.getAge().toString()); uiGender.setText(employee.getGender()); if (StringUtils.isNotEmpty(employee.getMaritalStatus())) { uiMarital.setSelectedItem(employee.getMaritalStatus()); } uiContact.setText(employee.getContact()); if (StringUtils.isNotEmpty(employee.getCensus())) { uiCensus.setSelectedItem(employee.getCensus()); } uiCensusAddress.setText(employee.getCensusAddress()); // ? if (employee.getEmployeePhoto() != null && employee.getEmployeePhoto().getPhoto() != null && employee.getEmployeePhoto().getPhoto().length > 0) { EmployeePhoto photo = employee.getEmployeePhoto(); try { File imageFile = new File(System.getProperty("user.dir") + "/temp/" + employee.getId() + ".png"); FileImageOutputStream fios = new FileImageOutputStream(imageFile); fios.write(photo.getPhoto()); fios.flush(); fios.close(); uiPhoto.putClientProperty("path", imageFile.getPath()); uiPhoto.setImage(imageFile.getPath()); } catch (Exception e) { showErrorMsg(e); } } else { uiPhoto.setImage("resource/image/default_emp_photo.png", true); } uiAddress.setText(employee.getAddress()); if (StringUtils.isNotEmpty(employee.getCensusProvince())) { uiResidencePermit.setSelectedItem(employee.getCensusProvince()); } if (StringUtils.isNotEmpty(employee.getDept())) { uiDept.setText(employee.getDept()); } if (StringUtils.isNotEmpty(employee.getJob())) { uiJob.setText(employee.getJob()); } if (StringUtils.isNotEmpty(employee.getEntryDate())) { uiEntryDate.setDate(Utils.dateFromStr(employee.getEntryDate())); } uiWorkAge.setText(UtilsClient.convertWorkAgeToStr(employee.getWorkAge())); if (StringUtils.isNotEmpty(employee.getProbationDate())) { uiProbation.setDate(Utils.dateFromStr(employee.getProbationDate())); } if (StringUtils.isNotEmpty(employee.getExpirationDate())) { uiExpiration.setText(employee.getExpirationDate()); } if (StringUtils.isNotEmpty(employee.getDegree())) { uiDegree.setSelectedItem(employee.getDegree()); } uiSchool.setText(employee.getSchool()); uiMajor.setText(employee.getMajor()); // uiSuspendEnd.setText(employee.getSuspendEnd()); uiWorkExperience.setText(employee.getWorkExperience()); uiSocialCard.setText(employee.getSocialCard()); uiHousingCard.setText(employee.getHousingCard()); uiBankCard.setText(employee.getBankCard()); uiNote.setText(employee.getNote()); uiPerformance.setText(employee.getCensusCity()); if (StringUtils.isNotEmpty(employee.getLeaveDate())) { uiLeaveDate.setDate(Utils.dateFromStr(employee.getLeaveDate())); } if (StringUtils.isNotEmpty(employee.getSocialEndDate())) { uiSocialEndDate.setText(employee.getSocialEndDate()); } if (StringUtils.isNotEmpty(employee.getHousingEndDate())) { uiHousingEndDate.setText(employee.getHousingEndDate()); } uiLeaveType.setSelectedItem(employee.getLeaveType()); uiLeaveReason.setText(employee.getLeaveReason()); uiFactory.setSelectedItem(employee.getSuspendNote()); uiDdg.setSelectedItem(employee.getSuspendStart()); }
From source file:com.lynk.hrm.ui.dialog.InfoEmployee.java
private void initData(final String id) { showWaitPanel("?......"); new SwingWorker<Employee, Void>() { @Override/*from w w w . j a v a 2s . co m*/ protected Employee doInBackground() throws Exception { if (StringUtils.isEmpty(id)) { return Employee.createNewEmployee(); } else { return HrmBiz.getInstance().getEmployee(id); } } @Override protected void done() { try { employee = get(); uiEntryDate.setCalendar(Calendar.getInstance()); uiId.setText(employee.getId()); uiName.setText(employee.getName()); uiNamePy.setText(employee.getNamePy()); if (StringUtils.isNotEmpty(employee.getState())) { uiState.setSelectedItem(employee.getState()); switch (employee.getState()) { case Employee.STATE_LEAVE: case Employee.STATE_RETIRE: case Employee.STATE_DELETE: uiInfoTab.setSelectedIndex(1); break; case Employee.STATE_SUSPEND: uiInfoTab.setSelectedIndex(2); break; case Employee.STATE_PROBATION: case Employee.STATE_CONTRACT: default: break; } } uiTimeCardLeaveCertify.setText(employee.getTimeCard()); uiIdCard.setText(employee.getIdCard()); uiBirthday.setText(employee.getBirthday()); uiAge.setText(employee.getAge().toString()); uiGender.setText(employee.getGender()); if (StringUtils.isNotEmpty(employee.getMaritalStatus())) { uiMarital.setSelectedItem(employee.getMaritalStatus()); } uiContact.setText(employee.getContact()); if (StringUtils.isNotEmpty(employee.getCensus())) { uiCensus.setSelectedItem(employee.getCensus()); } uiCensusAddress.setText(employee.getCensusAddress()); // ? if (employee.getEmployeePhoto() != null && employee.getEmployeePhoto().getPhoto() != null && employee.getEmployeePhoto().getPhoto().length > 0) { EmployeePhoto photo = employee.getEmployeePhoto(); uiPhoto.putClientProperty("photo", employee.getEmployeePhoto().getPhoto()); try { File imageFile = new File( System.getProperty("user.dir") + "/temp/" + employee.getId() + ".png"); FileImageOutputStream fios = new FileImageOutputStream(imageFile); fios.write(photo.getPhoto()); fios.flush(); fios.close(); uiPhoto.putClientProperty("path", imageFile.getPath()); uiPhoto.setImage(imageFile.getPath()); } catch (Exception e) { showErrorMsg(e); } } else { uiPhoto.setImage("resource/image/default_emp_photo.png", true); } uiAddress.setText(employee.getAddress()); if (StringUtils.isNotEmpty(employee.getCensusProvince())) { uiResidencePermit.setSelectedItem(employee.getCensusProvince()); } if (StringUtils.isNotEmpty(employee.getSuspendNote())) { uiFactory.setSelectedItem(employee.getSuspendNote()); } if (StringUtils.isNotEmpty(employee.getDept())) { uiDept.setText(employee.getDept()); } if (StringUtils.isNotEmpty(employee.getJob())) { uiJob.setText(employee.getJob()); } if (StringUtils.isNotEmpty(employee.getSuspendStart())) { uiDdg.setSelectedItem(employee.getSuspendStart()); } if (StringUtils.isNotEmpty(employee.getEntryDate())) { uiEntryDate.setDate(Utils.dateFromStr(employee.getEntryDate())); } uiWorkAge.setText(UtilsClient.convertWorkAgeToStr(employee.getWorkAge())); if (StringUtils.isNotEmpty(employee.getProbationDate())) { uiProbation.setDate(Utils.dateFromStr(employee.getProbationDate())); } if (StringUtils.isNotEmpty(employee.getExpirationDate())) { uiExpiration.setText(employee.getExpirationDate()); } if (StringUtils.isNotEmpty(employee.getDegree())) { uiDegree.setSelectedItem(employee.getDegree()); } uiSchool.setText(employee.getSchool()); uiMajor.setText(employee.getMajor()); uiWorkExperience.setText(employee.getWorkExperience()); // uiSuspendEnd.setText(employee.getSuspendEnd()); uiSocialCard.setText(employee.getSocialCard()); uiHousingCard.setText(employee.getHousingCard()); uiBankCard.setText(employee.getBankCard()); uiNote.setText(employee.getNote()); uiPerformance.setText(employee.getCensusCity()); uiPhoneShort.setText(employee.getPhoneShort()); if (StringUtils.isNotEmpty(employee.getLeaveDate())) { uiLeaveDate.setDate(Utils.dateFromStr(employee.getLeaveDate())); } if (StringUtils.isNotEmpty(employee.getSocialEndDate())) { uiSocialEndDate.setText(employee.getSocialEndDate()); } if (StringUtils.isNotEmpty(employee.getHousingEndDate())) { uiHousingEndDate.setText(employee.getHousingEndDate()); } uiLeaveType.setSelectedItem(employee.getLeaveType()); uiLeaveReason.setText(employee.getLeaveReason()); if (StringUtils.isNotEmpty(employee.getJobTitle())) { uiGuide.setText(employee.getJobTitle()); } hideWaitPanel(); } catch (Exception e) { hideWaitPanel(); showErrorMsg(e); } } }.execute(); }