private void updateProjectPath() { if (myProjectPath.getPath() == null || myProjectPath.getPath().length() == 0 || myProjectPath.getPath().startsWith(PROJECTS_DIR)) { myProjectPath.setPath(PROJECTS_DIR + File.separator + myProjectName.getText()); } }
// 开始建模 private void start() { File input = new File(pathTraffic.getPath()); File output = new File(pathOutput.getPath()); String level = "packet"; if (btnSession.isSelected()) level = "session"; int precisionSize = 20; int precisionTime = 50; ArrayList<String> inputFiles = new ArrayList<String>(); try { precisionSize = Integer.parseInt(txtPrecisionSize.getText()); precisionTime = Integer.parseInt(txtPrecisionTime.getText()); } catch (Exception e) { JOptionPane.showMessageDialog(this, "精度输入有误!"); return; } if (!output.exists() || !output.isDirectory()) { JOptionPane.showMessageDialog(this, "输出路径不存在!"); return; } if (input.exists()) { if (input.isDirectory()) { for (File file : input.listFiles()) { inputFiles.add(file.getAbsolutePath()); } } else if (input.isFile()) { inputFiles.add(input.getAbsolutePath()); } } else { JOptionPane.showMessageDialog(this, "输入路径/文件不存在!"); return; } File temp = new File(output.getAbsolutePath() + "\\.temp"); temp.mkdir(); for (String pcapFile : inputFiles) { try { buildOneModel(pcapFile, output.getAbsolutePath(), level, precisionSize, precisionTime); } catch (Exception e) { // TODO Auto-generated catch block System.out.println("使用" + pcapFile + "建模失败"); e.printStackTrace(); } } // temp.delete(); }
private void updateRightPanel() { setOKActionEnabled(myCurrentTemplateItem != null); String description = myCurrentTemplateItem != null ? myCurrentTemplateItem.getDescription() : null; if (StringUtil.isNotEmpty(description)) { StringBuilder sb = new StringBuilder("<html><body><font face=\"Verdana\" "); sb.append(SystemInfo.isMac ? "" : "size=\"-1\"").append('>'); sb.append(description).append("</font></body></html>"); description = sb.toString(); } myDescriptionPane.setText(description); myDescriptionPanel.setVisible(description != null); JComponent component = myCurrentTemplateItem != null ? myCurrentTemplateItem.getSettings() : null; myTemplateSettings.removeAll(); if (component != null) { myTemplateSettings.add( component, new GridConstraints( 0, 0, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null)); myTemplateSettings.add( myProjectFormatPanel.getPanel(), new GridConstraints( 1, 0, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1)); } if (myCurrentTemplateItem != null) myCurrentTemplateItem.setNewProjectPath(myProjectPath.getPath()); myTemplateSettingsHolder.setVisible(component != null); }
@Override protected void doOKAction() { super.doOKAction(); if (myCurrentProject != null) { int exitCode = Messages.showDialog( IdeBundle.message("prompt.open.project.in.new.frame"), IdeBundle.message("title.open.project"), new String[] { IdeBundle.message("button.newframe"), IdeBundle.message("button.existingframe") }, 1, Messages.getQuestionIcon()); if (exitCode == 1) { ProjectUtil.closeAndDispose(myCurrentProject); } } final ProjectOptions myOptions = new ProjectOptions(); myOptions.setProjectName(myProjectName.getText()); myOptions.setProjectPath(myProjectPath.getPath()); myOptions.setCreateNewLanguage(false); myOptions.setCreateNewSolution(false); myOptions.setStorageScheme(myProjectFormatPanel.isDefault()); // invoke later is for plugins to be ready ApplicationManager.getApplication() .invokeLater( new Runnable() { @Override public void run() { try { ProjectFactory factory = new ProjectFactory(myCurrentProject, myOptions); Project project = factory.createProject(); myCurrentTemplateItem .getTemplateFiller() .fillProjectWithModules(project.getComponent(MPSProject.class)); factory.activate(); } catch (ProjectNotCreatedException e) { Messages.showErrorDialog(getContentPane(), e.getMessage()); } } }); }