List of usage examples for org.apache.poi.ss.usermodel Workbook createCellStyle
CellStyle createCellStyle();
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.PostReviewQAReportGenerator.java
License:Apache License
/** * For Post-Review QA Report, Write segment information into each row of the * sheet./* w w w . jav a 2 s. co m*/ * * @param p_sheet * the sheet * @param p_jobId * the job id * @param p_targetLang * the target locale String * @param p_srcPageId * the source page id * @param p_dateFormat * the data format * @param p_row * the segment row in sheet */ @SuppressWarnings({ "rawtypes", "unchecked" }) private int writeSegmentInfo(Workbook p_workBook, Sheet p_sheet, Job p_job, GlobalSightLocale p_targetLocale, String p_srcPageId, String p_dateFormat, int p_row) throws Exception { boolean review_only = false; Vector<TargetPage> targetPages = new Vector<TargetPage>(); TranslationMemoryProfile tmp = null; Vector<String> excludItems = null; for (Workflow workflow : p_job.getWorkflows()) { if (cancel) return 0; if (Workflow.PENDING.equals(workflow.getState()) || Workflow.CANCELLED.equals(workflow.getState()) // || Workflow.EXPORT_FAILED.equals(workflow.getState()) || Workflow.IMPORT_FAILED.equals(workflow.getState())) { continue; } if (p_targetLocale.getId() == workflow.getTargetLocale().getId()) { targetPages = workflow.getTargetPages(); tmp = workflow.getJob().getL10nProfile().getTranslationMemoryProfile(); if (tmp != null) { excludItems = tmp.getJobExcludeTuTypes(); } Collection tasks = ServerProxy.getTaskManager().getCurrentTasks(workflow.getId()); if (tasks != null) { for (Iterator it = tasks.iterator(); it.hasNext();) { Task task = (Task) it.next(); review_only = task.isType(Task.TYPE_REVIEW); } } } } if (targetPages.isEmpty()) { // If no corresponding target page exists, set the cell blank writeBlank(p_sheet, p_row, 11); } else { LeverageMatchLingManager lmLingManager = LingServerProxy.getLeverageMatchLingManager(); TermLeverageManager termLeverageManager = ServerProxy.getTermLeverageManager(); Locale sourcePageLocale = p_job.getSourceLocale().getLocale(); Locale targetPageLocale = p_targetLocale.getLocale(); TermLeverageOptions termLeverageOptions = getTermLeverageOptions(sourcePageLocale, targetPageLocale, p_job.getL10nProfile().getProject().getTermbaseName(), String.valueOf(p_job.getCompanyId())); Map<Long, Set<TermLeverageMatch>> termLeverageMatchResultMap = null; if (termLeverageOptions != null) { termLeverageMatchResultMap = termLeverageManager.getTermMatchesForPages(p_job.getSourcePages(), p_targetLocale); } String category = null; PseudoData pData = new PseudoData(); pData.setMode(PseudoConstants.PSEUDO_COMPACT); String sid = null; Set<Integer> rowsWithCommentSet = new HashSet<Integer>(); for (int i = 0; i < targetPages.size(); i++) { if (cancel) return 0; TargetPage targetPage = (TargetPage) targetPages.get(i); SourcePage sourcePage = targetPage.getSourcePage(); if (!"".equals(p_srcPageId) && !p_srcPageId.equals(String.valueOf(sourcePage.getId()))) { // ignore the source pages not equal to the one // if the request comes from pop up editor continue; } SegmentTuUtil.getTusBySourcePageId(sourcePage.getId()); List sourceTuvs = SegmentTuvUtil.getSourceTuvs(sourcePage); List targetTuvs = SegmentTuvUtil.getTargetTuvs(targetPage); MatchTypeStatistics tuvMatchTypes = lmLingManager.getMatchTypesForStatistics( sourcePage.getIdAsLong(), targetPage.getLocaleId(), p_job.getLeverageMatchThreshold()); Map<Long, Set<LeverageMatch>> fuzzyLeverageMatchMap = lmLingManager .getFuzzyMatches(sourcePage.getIdAsLong(), new Long(targetPage.getLocaleId())); Map<Long, Tuv> allTuvMap = this.getAllTuvsMap(targetPage); sourcePageLocale = sourcePage.getGlobalSightLocale().getLocale(); targetPageLocale = targetPage.getGlobalSightLocale().getLocale(); boolean m_rtlSourceLocale = EditUtil.isRTLLocale(sourcePageLocale.toString()); boolean m_rtlTargetLocale = EditUtil.isRTLLocale(targetPageLocale.toString()); // Find segment all comments belong to this target page Map<Long, IssueImpl> issuesMap = CommentHelper.getIssuesMap(targetPage.getId()); for (int j = 0; j < targetTuvs.size(); j++) { if (cancel) return 0; int col = 0; Tuv targetTuv = (Tuv) targetTuvs.get(j); Tuv sourceTuv = (Tuv) sourceTuvs.get(j); category = sourceTuv.getTu(p_job.getId()).getTuType(); if (excludItems != null && excludItems.contains(category)) { continue; } // Comment List<IssueHistory> issueHistories = null; String commentHistory = ""; String failure = ""; String commentStatus = ""; String lastComment = ""; String priority = ""; Issue issue = issuesMap.get(targetTuv.getId()); if (issue != null) { issueHistories = issue.getHistory(); failure = issue.getCategory(); commentStatus = issue.getStatus(); priority = issue.getPriority(); } if (issueHistories != null && issueHistories.size() > 0) { for (IssueHistory issueHistory : issueHistories) { commentHistory += issueHistory.getComment() + "\r"; } lastComment = issueHistories.get(0).getComment(); } sid = sourceTuv.getSid(); StringBuilder matches = getMatches(fuzzyLeverageMatchMap, tuvMatchTypes, excludItems, sourceTuvs, targetTuvs, sourceTuv, targetTuv, p_job.getId()); // Get Terminology/Glossary Source and Target. String sourceTerms = ""; String targetTerms = ""; if (termLeverageMatchResultMap != null && termLeverageMatchResultMap.size() > 0) { Set<TermLeverageMatch> termLeverageMatchSet = termLeverageMatchResultMap .get(sourceTuv.getId()); if (termLeverageMatchSet != null && termLeverageMatchSet.size() > 0) { TermLeverageMatch tlm = termLeverageMatchSet.iterator().next(); sourceTerms = tlm.getMatchedSourceTerm(); targetTerms = tlm.getMatchedTargetTerm(); } } Row currentRow = getRow(p_sheet, p_row); // Source segment with compact tags CellStyle srcStyle = m_rtlSourceLocale ? getRtlContentStyle(p_workBook) : getContentStyle(p_workBook); Cell cell_A = getCell(currentRow, col); cell_A.setCellValue(getSegment(pData, sourceTuv, m_rtlSourceLocale, p_job.getId())); cell_A.setCellStyle(srcStyle); col++; // Target segment with compact tags CellStyle trgStyle = m_rtlTargetLocale ? getRtlContentStyle(p_workBook) : getContentStyle(p_workBook); String previousSegments = getPreviousSegments(allTuvMap, targetTuv.getId(), targetTuv, p_job.getId(), pData); Cell cell_B = getCell(currentRow, col); cell_B.setCellValue(previousSegments); cell_B.setCellStyle(trgStyle); col++; // Modify the translation CellStyle modifyTranslationStyle = m_rtlTargetLocale ? getUnlockedRightStyle(p_workBook) : getUnlockedStyle(p_workBook); modifyTranslationStyle.setLocked(false); Cell cell_C = getCell(currentRow, col); cell_C.setCellValue(getSegment(pData, targetTuv, m_rtlTargetLocale, p_job.getId())); if (review_only) { modifyTranslationStyle.setLocked(true); } cell_C.setCellStyle(modifyTranslationStyle); col++; // Reviewers Comments Cell cell_D = getCell(currentRow, col); cell_D.setCellValue(commentHistory); cell_D.setCellStyle(getContentStyle(p_workBook)); col++; // Category failure Cell cell_E = getCell(currentRow, col); cell_E.setCellValue(failure); cell_E.setCellStyle(getContentStyle(p_workBook)); col++; // Comment Status Cell cell_F = getCell(currentRow, col); cell_F.setCellValue(commentStatus); CellStyle commentCS = p_workBook.createCellStyle(); commentCS.cloneStyleFrom(getContentStyle(p_workBook)); // commentCS.setLocked(false); cell_F.setCellStyle(commentCS); // add comment status drop down list for current row. String[] statusArray = getCommentStatusList(lastComment); if (statusArray.length > 1) { rowsWithCommentSet.add(p_row); } col++; // Priority Cell cell_G = getCell(currentRow, col); cell_G.setCellValue(priority); cell_G.setCellStyle(getContentStyle(p_workBook)); col++; // TM match Cell cell_H = getCell(currentRow, col); cell_H.setCellValue(matches.toString()); cell_H.setCellStyle(getContentStyle(p_workBook)); col++; // Glossary source Cell cell_I = getCell(currentRow, col); cell_I.setCellValue(sourceTerms); cell_I.setCellStyle(getContentStyle(p_workBook)); col++; // Glossary target Cell cell_J = getCell(currentRow, col); cell_J.setCellValue(targetTerms); cell_J.setCellStyle(getContentStyle(p_workBook)); col++; // Job Id Cell cell_K = getCell(currentRow, col); cell_K.setCellValue(p_job.getId()); cell_K.setCellStyle(getContentStyle(p_workBook)); col++; // Segment id Cell cell_L = getCell(currentRow, col); cell_L.setCellValue(sourceTuv.getTu(p_job.getId()).getId()); cell_L.setCellStyle(getContentStyle(p_workBook)); col++; // Fix for GBS-1484 String externalPageId = sourcePage.getExternalPageId(); String[] pathNames = externalPageId.split("\\\\"); String name = pathNames[pathNames.length - 1]; boolean temp = pathNames[0].contains(")"); if (temp) { String[] firstNames = pathNames[0].split("\\)"); String detailName = firstNames[0]; name = name + detailName + ")"; } // Page Name Cell cell_M = getCell(currentRow, col); cell_M.setCellValue(name); cell_M.setCellStyle(getContentStyle(p_workBook)); col++; // SID Cell cell_N = getCell(currentRow, col); cell_N.setCellValue(sid); cell_N.setCellStyle(getContentStyle(p_workBook)); col++; p_row++; } } // Add comment status addCommentStatus(p_sheet, rowsWithCommentSet, p_row); // Add category failure drop down list here. addCategoryFailureValidation(p_sheet, SEGMENT_START_ROW, p_row - 1, CATEGORY_FAILURE_COLUMN, CATEGORY_FAILURE_COLUMN); addPriority(p_sheet, SEGMENT_START_ROW, p_row - 1, PRIORITY_COLUMN, PRIORITY_COLUMN); } return p_row; }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.ReviewersCommentsReportGenerator.java
License:Apache License
/** * Add title to the sheet// w w w .j a va2 s . c o m * * @param p_workBook * @param p_sheet * the sheet * @throws Exception */ private void addTitle(Workbook p_workBook, Sheet p_sheet) throws Exception { Font titleFont = p_workBook.createFont(); titleFont.setUnderline(Font.U_NONE); titleFont.setFontName("Times"); titleFont.setFontHeightInPoints((short) 14); titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD); CellStyle cs = p_workBook.createCellStyle(); cs.setFont(titleFont); Row titleRow = getRow(p_sheet, 0); Cell titleCell = getCell(titleRow, 0); titleCell.setCellValue(m_bundle.getString("review_reviewers_comments")); titleCell.setCellStyle(cs); }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.ReviewersCommentsSimpleReportGenerator.java
License:Apache License
/** * Add title to the sheet//from ww w. jav a 2 s . c o m * * @param p_workBook * @param p_sheet * the sheet * @throws Exception */ private void addTitle(Workbook p_workBook, Sheet p_sheet) throws Exception { Font titleFont = p_workBook.createFont(); titleFont.setUnderline(Font.U_NONE); titleFont.setFontName("Times"); titleFont.setFontHeightInPoints((short) 14); titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD); CellStyle cs = p_workBook.createCellStyle(); cs.setFont(titleFont); Row titleRow = getRow(p_sheet, 0); Cell titleCell = getCell(titleRow, 0); titleCell.setCellValue(m_bundle.getString("review_reviewers_comments_simple")); titleCell.setCellStyle(cs); }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.ReviewersCommentsSimpleReportGenerator.java
License:Apache License
private CellStyle getHeaderStyle(Workbook p_workbook) throws Exception { if (headerStyle == null) { Font font = p_workbook.createFont(); font.setBoldweight(Font.BOLDWEIGHT_BOLD); font.setColor(IndexedColors.BLACK.getIndex()); font.setUnderline(Font.U_NONE); font.setFontName("Times"); font.setFontHeightInPoints((short) 11); CellStyle cs = p_workbook.createCellStyle(); cs.setFont(font);// w ww .j av a2 s.c o m cs.setWrapText(true); cs.setFillPattern(CellStyle.SOLID_FOREGROUND); cs.setFillForegroundColor(IndexedColors.GREY_40_PERCENT.getIndex()); cs.setBorderTop(CellStyle.BORDER_THIN); cs.setBorderRight(CellStyle.BORDER_THIN); cs.setBorderBottom(CellStyle.BORDER_THIN); cs.setBorderLeft(CellStyle.BORDER_THIN); headerStyle = cs; } return headerStyle; }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.ReviewersCommentsSimpleReportGenerator.java
License:Apache License
private CellStyle getContentStyle(Workbook p_workbook) throws Exception { if (contentStyle == null) { CellStyle style = p_workbook.createCellStyle(); style.setWrapText(true);/*w w w.j av a2s . c om*/ style.setAlignment(CellStyle.ALIGN_LEFT); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); style.setBorderTop(CellStyle.BORDER_THIN); style.setBorderRight(CellStyle.BORDER_THIN); style.setBorderBottom(CellStyle.BORDER_THIN); style.setBorderLeft(CellStyle.BORDER_THIN); Font font = p_workbook.createFont(); font.setFontName("Arial"); font.setFontHeightInPoints((short) 10); style.setFont(font); contentStyle = style; } return contentStyle; }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.ReviewersCommentsSimpleReportGenerator.java
License:Apache License
private CellStyle getIceContentStyle(Workbook p_workbook) throws Exception { if (iceContentStyle == null) { CellStyle style = p_workbook.createCellStyle(); style.setWrapText(true);/*from w w w .ja v a2 s. c om*/ style.setAlignment(CellStyle.ALIGN_LEFT); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); style.setBorderTop(CellStyle.BORDER_THIN); style.setBorderRight(CellStyle.BORDER_THIN); style.setBorderBottom(CellStyle.BORDER_THIN); style.setBorderLeft(CellStyle.BORDER_THIN); Font font = p_workbook.createFont(); font.setFontName("Arial"); font.setFontHeightInPoints((short) 10); style.setFont(font); iceContentStyle = style; } return iceContentStyle; }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.ReviewersCommentsSimpleReportGenerator.java
License:Apache License
private CellStyle getExactContentStyle(Workbook p_workbook) throws Exception { if (exactContentStyle == null) { CellStyle style = p_workbook.createCellStyle(); style.setWrapText(true);/* ww w.jav a 2s . c o m*/ style.setAlignment(CellStyle.ALIGN_LEFT); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex()); style.setBorderTop(CellStyle.BORDER_THIN); style.setBorderRight(CellStyle.BORDER_THIN); style.setBorderBottom(CellStyle.BORDER_THIN); style.setBorderLeft(CellStyle.BORDER_THIN); Font font = p_workbook.createFont(); font.setFontName("Arial"); font.setFontHeightInPoints((short) 10); style.setFont(font); exactContentStyle = style; } return exactContentStyle; }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.ReviewersCommentsSimpleReportGenerator.java
License:Apache License
private CellStyle getRtlContentStyle(Workbook p_workbook) throws Exception { if (rtlContentStyle == null) { Font font = p_workbook.createFont(); font.setFontName("Arial"); font.setFontHeightInPoints((short) 10); CellStyle style = p_workbook.createCellStyle(); style.setFont(font);/*from www . j ava2 s .c o m*/ style.setWrapText(true); style.setAlignment(CellStyle.ALIGN_RIGHT); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); style.setBorderTop(CellStyle.BORDER_THIN); style.setBorderRight(CellStyle.BORDER_THIN); style.setBorderBottom(CellStyle.BORDER_THIN); style.setBorderLeft(CellStyle.BORDER_THIN); rtlContentStyle = style; } return rtlContentStyle; }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.ReviewersCommentsSimpleReportGenerator.java
License:Apache License
private CellStyle getIceRtlContentStyle(Workbook p_workbook) throws Exception { if (iceRtlContentStyle == null) { Font font = p_workbook.createFont(); font.setFontName("Arial"); font.setFontHeightInPoints((short) 10); CellStyle style = p_workbook.createCellStyle(); style.setFont(font);/* www. j a v a2 s. c om*/ style.setWrapText(true); style.setAlignment(CellStyle.ALIGN_RIGHT); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); style.setBorderTop(CellStyle.BORDER_THIN); style.setBorderRight(CellStyle.BORDER_THIN); style.setBorderBottom(CellStyle.BORDER_THIN); style.setBorderLeft(CellStyle.BORDER_THIN); iceRtlContentStyle = style; } return iceRtlContentStyle; }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.ReviewersCommentsSimpleReportGenerator.java
License:Apache License
private CellStyle getExactRtlContentStyle(Workbook p_workbook) throws Exception { if (exactRtlContentStyle == null) { Font font = p_workbook.createFont(); font.setFontName("Arial"); font.setFontHeightInPoints((short) 10); CellStyle style = p_workbook.createCellStyle(); style.setFont(font);//www. j a v a 2 s. c o m style.setWrapText(true); style.setAlignment(CellStyle.ALIGN_RIGHT); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex()); style.setBorderTop(CellStyle.BORDER_THIN); style.setBorderRight(CellStyle.BORDER_THIN); style.setBorderBottom(CellStyle.BORDER_THIN); style.setBorderLeft(CellStyle.BORDER_THIN); exactRtlContentStyle = style; } return exactRtlContentStyle; }