/** * Method execute * * @param mapping * @param form * @param request * @param response * @return ActionForward */ public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { try { // 从session获取list HttpSession session = request.getSession(); ArrayList<Result6FormBean> list = new ArrayList<Result6FormBean>(); list = (ArrayList<Result6FormBean>) session.getAttribute("DANLULIST"); // 此时取出来的是Object, // 需要强转 // 定义导出excel名字 String fileName = "单炉生产数据统计表.xls"; fileName = new String(fileName.getBytes("UTF-8"), "utf-8"); // 取得检索日期 String riqi = (String) session.getAttribute("RIQI"); // 导出excel到服务器 Excel.exportResult6Excel(list, fileName, riqi); // 下载excel到本地 FileAction fileDownload = new FileAction(); fileDownload.downFile(response, fileName); return null; } catch (Exception e) { e.printStackTrace(); return mapping.findForward("searchError"); } }
public static void readInput(String filename, String filepath) { FileAction aFileAction = new FileAction(fileName, fileFullPath); ArrayList<String> inData = aFileAction.fileRead(); StringTokenizer tokens = new StringTokenizer(inData.get(0), " "); // tokens = new StringTokenizer(line, " "); sim = new Simulation( Integer.parseInt(tokens.nextToken()), Integer.parseInt(tokens.nextToken()), Integer.parseInt(tokens.nextToken()), Integer.parseInt(tokens.nextToken()), Integer.parseInt(tokens.nextToken())); products = new Products(Integer.parseInt(inData.get(1)), inData.get(2)); warehouses = new ArrayList<Warehouse>(); int numWarehouses = Integer.parseInt(inData.get(3)); int i; for (i = 4; i < numWarehouses + 4; i += 2) { warehouses.add(new Warehouse(inData.get(i), inData.get(i + 1))); } int num_orders = Integer.parseInt(inData.get(i)); i++; orders = new ArrayList<Order>(); for (int j = i; j < num_orders * 3 + i; j += 3) { orders.add(new Order(inData.get(j), inData.get(j + 1), inData.get(j + 2))); } // System.out.println(sim + " " +inData.get(1) + // products.getWeights().get(products.getWeights().size() -1)); }
private void filesChangedWorker() { // TODO: once this is editable, make sure changes are committed fileDetails.reset(); for (final FileObject file : table.getSelectedFiles()) fileDetails.showFileDetails(file); if (fileDetails.getDocument().getLength() > 0 && table.areAllSelectedFilesUploadable()) fileDetails.setEditableForDevelopers(); for (final FileAction button : fileActions) button.enableIfValid(); apply.setEnabled(files.hasChanges()); cancel.setText(files.hasChanges() ? "Cancel" : "Close"); if (files.hasUploadableSites()) enableUploadOrNot(); int install = 0, uninstall = 0, upload = 0; long bytesToDownload = 0, bytesToUpload = 0; for (final FileObject file : files) switch (file.getAction()) { case INSTALL: case UPDATE: install++; bytesToDownload += file.filesize; break; case UNINSTALL: uninstall++; break; case UPLOAD: upload++; bytesToUpload += file.filesize; break; } int implicated = 0; final DependencyMap map = files.getDependencies(true); for (final FileObject file : map.keySet()) { implicated++; bytesToUpload += file.filesize; } String text = ""; if (install > 0) text += " install/update: " + install + (implicated > 0 ? "+" + implicated : "") + " (" + sizeToString(bytesToDownload) + ")"; if (uninstall > 0) text += " uninstall: " + uninstall; if (files.hasUploadableSites() && upload > 0) text += " upload: " + upload + " (" + sizeToString(bytesToUpload) + ")"; fileSummary.setText(text); }
protected void showOrHide() { for (final FileAction action : fileActions) { action.setVisible(!easyMode); } searchPanel.setVisible(!easyMode); viewOptionsPanel.setVisible(!easyMode); chooseLabel.setVisible(!easyMode); summaryPanel.setVisible(!easyMode); rightPanel.setVisible(!easyMode); updateSites.setVisible(!easyMode); final boolean uploadable = !easyMode && files.hasUploadableSites(); upload.setVisible(uploadable); if (showChanges != null) showChanges.setVisible(uploadable); if (rebuildButton != null) rebuildButton.setVisible(uploadable); easy.setText(easyMode ? "Advanced mode" : "Easy mode"); }
public static void forEachFile(File src, File dest, FileAction fileAction) throws IOException { if ((src == null || !src.exists()) && dest == null) { throw new IllegalArgumentException("Both path's must actually exist"); } if (src.isDirectory()) { if (!dest.exists()) { dest.mkdir(); } String files[] = src.list(); for (int i = 0; i < files.length; i++) { forEachFile( new File(src, files[i]), fileAction.makeDestination(dest, files[i]), fileAction); } } else { if (!src.exists()) { throw new IOException("File or directory does not exist: " + src); } else { fileAction.sourceToDestination(src, dest); } } }