void install() { Vector components = new Vector(); Vector indicies = new Vector(); int size = 0; JPanel comp = selectComponents.comp; Vector ids = selectComponents.filesets; for (int i = 0; i < comp.getComponentCount(); i++) { if (((JCheckBox) comp.getComponent(i)).getModel().isSelected()) { size += installer.getIntegerProperty("comp." + ids.elementAt(i) + ".real-size"); components.addElement(installer.getProperty("comp." + ids.elementAt(i) + ".fileset")); indicies.addElement(new Integer(i)); } } String installDir = chooseDirectory.installDir.getText(); Map osTaskDirs = chooseDirectory.osTaskDirs; Iterator keys = osTaskDirs.keySet().iterator(); while (keys.hasNext()) { OperatingSystem.OSTask osTask = (OperatingSystem.OSTask) keys.next(); String dir = ((JTextField) osTaskDirs.get(osTask)).getText(); if (dir != null && dir.length() != 0) { osTask.setEnabled(true); osTask.setDirectory(dir); } else osTask.setEnabled(false); } InstallThread thread = new InstallThread(installer, progress, installDir, osTasks, size, components, indicies); progress.setThread(thread); thread.start(); }
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String dbHost = request.getParameter("dbHost"); String dbPort = request.getParameter("dbPort"); String dbName = request.getParameter("dbName"); String dbUser = request.getParameter("dbUser"); String dbPassword = request.getParameter("dbPassword"); String isCreateDb = request.getParameter("isCreateDb"); String isCreateTable = request.getParameter("isCreateTable"); String isInitData = request.getParameter("isInitData"); String domain = request.getParameter("domain"); String cxtPath = request.getParameter("cxtPath"); String port = request.getParameter("port"); String dbFileName = request.getParameter("dbFileName"); String initFileName = request.getParameter("initFileName"); String dbXmlFileName = "/WEB-INF/config/jdbc.properties"; String webXmlFrom = "/install/config/web.xml"; String webXmlTo = "/WEB-INF/web.xml"; // 创建数据库 try { if ("true".equals(isCreateDb)) { Install.createDb(dbHost, dbPort, dbName, dbUser, dbPassword); } else { Install.changeDbCharset(dbHost, dbPort, dbName, dbUser, dbPassword); } // 创建表 if ("true".equals(isCreateTable)) { String sqlPath = getServletContext().getRealPath(dbFileName); List<String> sqlList = Install.readSql(sqlPath); Install.createTable(dbHost, dbPort, dbName, dbUser, dbPassword, sqlList); } // 初始化数据 if ("true".equals(isInitData)) { String initPath = getServletContext().getRealPath(initFileName); List<String> initList = Install.readSql(initPath); Install.createTable(dbHost, dbPort, dbName, dbUser, dbPassword, initList); } // 更新配置 Install.updateConfig(dbHost, dbPort, dbName, dbUser, dbPassword, domain, cxtPath, port); // 处理数据库配置文件 String dbXmlPath = getServletContext().getRealPath(dbXmlFileName); Install.dbXml(dbXmlPath, dbHost, dbPort, dbName, dbUser, dbPassword); // 处理web.xml String webXmlFromPath = getServletContext().getRealPath(webXmlFrom); String webXmlToPath = getServletContext().getRealPath(webXmlTo); Install.webXml(webXmlFromPath, webXmlToPath); } catch (Exception e) { throw new ServletException("install failed!", e); } RequestDispatcher dispatcher = request.getRequestDispatcher("/install/install_setup.jsp"); dispatcher.forward(request, response); }
private void searchJars(File folder) { File[] files = folder.listFiles(); String version = null; try { version = Install.getVersion(); } catch (IOException e) { version = ""; } for (File f : files) { String s = f.getName(); if (s.startsWith("matconsolectl")) { if (jarMCTL != null) { // if there are more than one files matching this, only one allowed jarMCTL = null; break; } jarMCTL = f; } if (s.startsWith("MEP_" + version)) { if (jarMEP != null) { // if there are more than one files matching this, only one allowed jarMEP = null; break; } jarMEP = f; } } checkJARPath(); }
private void appendJCPT(File file) { try { Install.appendJCPT(txtJCP, file.toString()); } catch (IOException e) { JOptionPane.showMessageDialog( new JFrame(""), e.getMessage(), "Uh Oh " + file.getName(), JOptionPane.ERROR_MESSAGE); } }
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String dbHost = request.getParameter("dbHost"); String dbPort = request.getParameter("dbPort"); String dbName = request.getParameter("dbName"); String dbUser = request.getParameter("dbUser"); String dbPassword = request.getParameter("dbPassword"); String domain = request.getParameter("domain"); String cxtPath = request.getParameter("cxtPath"); String port = request.getParameter("port"); String dbFileName = request.getParameter("dbFileName"); String dbXmlFileName = "/WEB-INF/config/jdbc.properties"; String webXmlFrom = "/update/config/web.xml"; String webXmlTo = "/WEB-INF/web.xml"; try { // 创建表 String sqlPath = getServletContext().getRealPath(dbFileName); List<String> sqlList = Install.readSql(sqlPath); Install.createTable(dbHost, dbPort, dbName, dbUser, dbPassword, sqlList); // 更新配置 Install.updateConfig(dbHost, dbPort, dbName, dbUser, dbPassword, domain, cxtPath, port); // 处理数据库配置文件 String dbXmlPath = getServletContext().getRealPath(dbXmlFileName); Install.dbXml(dbXmlPath, dbHost, dbPort, dbName, dbUser, dbPassword); // 处理web.xml String webXmlFromPath = getServletContext().getRealPath(webXmlFrom); String webXmlToPath = getServletContext().getRealPath(webXmlTo); Install.webXml(webXmlFromPath, webXmlToPath); } catch (Exception e) { throw new ServletException("update failed!", e); } RequestDispatcher dispatcher = request.getRequestDispatcher("/update/update_setup.jsp"); dispatcher.forward(request, response); }
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // String dbHost = request.getHeader("BaeEnv.BAE_ENV_ADDR_SQL_IP"); // String dbPort = request.getHeader("BaeEnv.BAE_ENV_ADDR_SQL_PORT"); String dbHost = "sqld.duapp.com"; String dbPort = "4050"; String dbName = "GejwcSiuDbGfAVCrCopl"; String dbUser = "******"; String dbPassword = "******"; String isCreateDb = request.getParameter("isCreateDb"); String isCreateTable = request.getParameter("isCreateTable"); String isInitData = request.getParameter("isInitData"); String domain = request.getParameter("domain"); String cxtPath = request.getParameter("cxtPath"); String port = request.getParameter("port"); String dbFileName = request.getParameter("dbFileName"); String initFileName = request.getParameter("initFileName"); String dbXmlFileName = "/WEB-INF/config/jdbc.properties"; String webXmlFrom = "/install/config/web.xml"; String webXmlTo = "/WEB-INF/web.xml"; String install = "/install"; // 创建数据库 try { // if ("true".equals(isCreateDb)) { // Install.createDb(dbHost, dbPort, dbName, dbUser, dbPassword); // } else { // Install.changeDbCharset(dbHost, dbPort, dbName, dbUser, // dbPassword); // } // 创建表 if ("true".equals(isCreateTable)) { String sqlPath = getServletContext().getRealPath(dbFileName); List<String> sqlList = Install.readSql(sqlPath); Install.createTable(dbHost, dbPort, dbName, dbUser, dbPassword, sqlList); } // 初始化数据 if ("true".equals(isInitData)) { String initPath = getServletContext().getRealPath(initFileName); List<String> initList = Install.readSql(initPath); Install.createTable(dbHost, dbPort, dbName, dbUser, dbPassword, initList); } // 更新配置 Install.updateConfig(dbHost, dbPort, dbName, dbUser, dbPassword, domain, cxtPath, port); // 处理数据库配置文件 String dbXmlPath = getServletContext().getRealPath(dbXmlFileName); Install.dbXml(dbXmlPath, dbHost, dbPort, dbName, dbUser, dbPassword); // 处理web.xml String webXmlFromPath = getServletContext().getRealPath(webXmlFrom); String webXmlToPath = getServletContext().getRealPath(webXmlTo); Install.webXml(webXmlFromPath, webXmlToPath); // 处理安装程序目录 File installDirectory = new File(getServletContext().getRealPath(install)); FileUtils.deleteDirectory(installDirectory); } catch (Exception e) { throw new ServletException("install failed!", e); } RequestDispatcher dispatcher = request.getRequestDispatcher("/install_setup.html"); dispatcher.forward(request, response); }
private void addPathSelectionPanel() { File file = null; try { file = Install.getJarFile(); } catch (IOException e) { e.printStackTrace(); } { // label for JAR files GridBagConstraints cLabel = new GridBagConstraints(); cLabel.gridy = 0; cLabel.gridx = 0; cLabel.weightx = 1; cLabel.insets = new Insets(10, 10, 0, 0); cLabel.fill = GridBagConstraints.HORIZONTAL; add(new JLabel("Location of MEP and matconsolectl .JAR-files"), cLabel); // jar textfield GridBagConstraints cJARPath = new GridBagConstraints(); cJARPath.gridy = 1; cJARPath.gridx = 0; cJARPath.weightx = 1; cJARPath.insets = new Insets(0, 10, 0, 10); cJARPath.fill = GridBagConstraints.HORIZONTAL; jtJAR = new JTextField(file.getParent()); jtJAR.setEditable(false); add(jtJAR, cJARPath); searchJars(file.getParentFile()); // jar browser button GridBagConstraints cJARPathBrowse = new GridBagConstraints(); cJARPathBrowse.gridy = 1; cJARPathBrowse.gridx = 1; cJARPathBrowse.weightx = 0.1; cJARPathBrowse.insets = new Insets(0, 0, 0, 10); final JButton jb = new JButton("..."); jb.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int returnVal = fc.showOpenDialog(jb); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); jtJAR.setText(file.toString()); searchJars(file); } } }); add(jb, cJARPathBrowse); } { // label for javaclasspath.txt GridBagConstraints cLabel = new GridBagConstraints(); cLabel.gridy = 2; cLabel.gridx = 0; cLabel.weightx = 1; cLabel.insets = new Insets(10, 10, 0, 0); cLabel.fill = GridBagConstraints.HORIZONTAL; add(new JLabel("Location of javaclasspath.txt"), cLabel); // jcp textfield File file2 = null; try { file2 = Install.getJavaClassPathTxt(); jtJCP = new JTextField(file2.toString()); txtJCP = file2; } catch (IOException ignored) { jtJCP = new JTextField(); } jtJCP.setEditable(false); GridBagConstraints cJCPPath = new GridBagConstraints(); cJCPPath.gridy = 3; cJCPPath.gridx = 0; cJCPPath.weightx = 1; cJCPPath.insets = new Insets(0, 10, 0, 10); cJCPPath.fill = GridBagConstraints.HORIZONTAL; add(jtJCP, cJCPPath); // jcp browser button GridBagConstraints cJCPPathBrowse = new GridBagConstraints(); cJCPPathBrowse.gridy = 3; cJCPPathBrowse.gridx = 1; cJCPPathBrowse.weightx = 0.1; cJCPPathBrowse.insets = new Insets(0, 0, 0, 10); final JButton jb = new JButton("..."); jb.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { fc.setFileSelectionMode(JFileChooser.FILES_ONLY); int returnVal = fc.showOpenDialog(jb); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); if (file.getName().startsWith("javaclasspath")) { txtJCP = file; } else { txtJCP = null; } jtJCP.setText(file.toString()); checkJCPPath(); } } }); add(jb, cJCPPathBrowse); } { // label for installdir GridBagConstraints cLabel = new GridBagConstraints(); cLabel.gridy = 4; cLabel.gridx = 0; cLabel.weightx = 1; cLabel.insets = new Insets(10, 10, 0, 0); cLabel.fill = GridBagConstraints.HORIZONTAL; add(new JLabel("Installation directory"), cLabel); GridBagConstraints cID = new GridBagConstraints(); cID.gridy = 5; cID.gridx = 0; cID.weightx = 1; cID.insets = new Insets(0, 10, 0, 10); cID.fill = GridBagConstraints.HORIZONTAL; jtID = new JTextField("", 50); jtID.setEditable(false); add(jtID, cID); // jcp browser button GridBagConstraints cIDPathBrowse = new GridBagConstraints(); cIDPathBrowse.gridy = 5; cIDPathBrowse.gridx = 1; cIDPathBrowse.weightx = 0.1; cIDPathBrowse.insets = new Insets(0, 0, 0, 10); final JButton jb = new JButton("..."); jb.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int returnVal = fc.showOpenDialog(jb); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); id = new File(file.toString() + "\\MEP"); jtID.setText(id.toString()); } } }); add(jb, cIDPathBrowse); } checkJARPath(); checkJCPPath(); }