/** * * Displays an alert box * * @param title The text to set the Alert box to * @param headerText The header text to set the Alert box to * @param contentText The content text to set the Alert box to */ public static void show(String title, String headerText, String contentText) { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle(title); alert.setHeaderText(headerText); alert.setContentText(contentText); alert.initModality(Modality.APPLICATION_MODAL); alert.initStyle(StageStyle.UTILITY); alert.showAndWait(); }
public void popupAboutDialog(ActionEvent actionEvent) { final Alert aboutDialog = new Alert(Alert.AlertType.INFORMATION); aboutDialog.setTitle("关于 - Dima"); aboutDialog.setHeaderText(null); aboutDialog.setContentText("本软件制作权属于 @Yunlu"); aboutDialog.initStyle(StageStyle.DECORATED); aboutDialog.showAndWait(); /** Hooked, For temporary use */ if (plus.getService(TreeViewService.class).getCurrentUIProject() == null) { return; } final UINode uiPlan = plus.getService(TreeViewService.class) .getCurrentUIProject() .getFirstChildByName(UIPlan_NAME); final File ipmDir = PlusFileUtil.newDir(plus, uiPlan, "ipm", "1", "ES_1"); final File switchDir = PlusFileUtil.newDir(plus, uiPlan, "switch", "1", "SW_1"); final File rdcDir = PlusFileUtil.newDir(plus, uiPlan, "rdc", "1", "Rdc429ToDis"); final BusinessNode businessNode653 = plus.getService(XMLService.class).parseRootBusinessNode("config/653.xml"); final BusinessNode businessNodeBSP = plus.getService(XMLService.class).parseRootBusinessNode("config/BSP.xml"); final BusinessNode businessNodeWL = plus.getService(XMLService.class).parseRootBusinessNode("config/网络配置表.xml"); final BusinessNode businessNodeYY = plus.getService(XMLService.class).parseRootBusinessNode("config/应用配置表.xml"); final BusinessNode businessNodeSwitch = plus.getService(XMLService.class).parseRootBusinessNode("config/switch.xml"); final BusinessNode businessNodeIPMInternalData = plus.getService(XMLService.class).parseRootBusinessNode("config/IPMInternalData.xml"); final BusinessNode businessNodeRDCInstance = plus.getService(XMLService.class).parseRootBusinessNode("config/RDCInstance.xml"); final BusinessNode businessNodeTopoData = plus.getService(XMLService.class).parseRootBusinessNode("config/TopoData.xml"); /** IPM */ plus.getService(XMLService.class) .outputBusinessNodeToXML(businessNode653, new File(ipmDir, Names.FILE_653)); plus.getService(XMLService.class) .outputBusinessNodeToXML(businessNodeWL, new File(ipmDir, Names.FILE_WL("1", "ES_1"))); plus.getService(XMLService.class) .outputBusinessNodeToXML(businessNodeYY, new File(ipmDir, Names.FILE_YY("1", "app_sync"))); plus.getService(XMLService.class) .outputBusinessNodeToXML(businessNodeYY, new File(ipmDir, Names.FILE_YY("1", "app_part1"))); plus.getService(XMLService.class) .outputBusinessNodeToXML( businessNodeIPMInternalData, new File(ipmDir, Names.FILE_IPM_INTERNAL_DATA)); plus.getService(XMLService.class) .outputBusinessNodeToXML(businessNodeBSP, new File(ipmDir, Names.FILE_BSP)); plus.getService(XMLService.class) .outputBusinessNodeToXML(businessNodeTopoData, new File(ipmDir, Names.FILE_TOPO_DATA)); /** Switch */ plus.getService(XMLService.class) .outputBusinessNodeToXML(businessNodeSwitch, new File(switchDir, Names.FILE_SWITCH)); plus.getService(XMLService.class) .outputBusinessNodeToXML(businessNodeTopoData, new File(switchDir, Names.FILE_TOPO_DATA)); /** RDC */ plus.getService(XMLService.class) .outputBusinessNodeToXML(businessNodeRDCInstance, new File(rdcDir, Names.FILE_RDCInstance)); plus.getService(XMLService.class) .outputBusinessNodeToXML(businessNodeTopoData, new File(rdcDir, Names.FILE_TOPO_DATA)); plus.fireEvent(PlusEventListenerType.RequirePlanUpdate, uiPlan); plus.fireEvent(PlusEventListenerType.RequirePlanStatisticsUpdate, uiPlan); /** Mock Chart */ final ObservableList<PieChart.Data> pieChartData1 = FXCollections.observableArrayList( new PieChart.Data("空闲", 12), new PieChart.Data("CPU-1", 18), new PieChart.Data("CPU-2", 53), new PieChart.Data("CPU-3", 24), new PieChart.Data("CPU-4", 11)); final ObservableList<PieChart.Data> pieChartData2 = FXCollections.observableArrayList( new PieChart.Data("空闲", 12), new PieChart.Data("内存-1", 18), new PieChart.Data("内存-2", 53), new PieChart.Data("内存-3", 24), new PieChart.Data("内存-4", 11)); plus.fireEvent(Input_CPU_Memory_Data, pieChartData1, pieChartData2); final ObservableList<PieChart.Data> pieChartData3 = FXCollections.observableArrayList( new PieChart.Data("空闲", 12), new PieChart.Data("带宽-1", 18), new PieChart.Data("带宽-2", 53), new PieChart.Data("带宽-3", 24), new PieChart.Data("带宽-4", 11)); final ObservableList<PieChart.Data> pieChartData4 = FXCollections.observableArrayList( new PieChart.Data("空闲", 12), new PieChart.Data("带宽-1", 18), new PieChart.Data("带宽-2", 53), new PieChart.Data("带宽-3", 24), new PieChart.Data("带宽-4", 11)); plus.fireEvent(Input_LLDK_Data, pieChartData3, pieChartData4); /** Mock line chart */ Random random = new Random(); final XYChart.Series<Number, Number> series1 = new XYChart.Series<>(); series1.getData().add(new XYChart.Data<>(1, Math.abs(random.nextInt(20)) + 1900)); series1.getData().add(new XYChart.Data<>(2, Math.abs(random.nextInt(20)) + 1900)); series1.getData().add(new XYChart.Data<>(3, Math.abs(random.nextInt(20)) + 1900)); series1.getData().add(new XYChart.Data<>(6, Math.abs(random.nextInt(20)) + 1900)); series1.getData().add(new XYChart.Data<>(7, Math.abs(random.nextInt(20)) + 1900)); series1.getData().add(new XYChart.Data<>(8, Math.abs(random.nextInt(20)) + 1900)); series1.setName("消息1"); final XYChart.Series<Number, Number> series2 = new XYChart.Series<>(); series2.getData().add(new XYChart.Data<>(1, Math.abs(random.nextInt(20)) + 1900)); series2.getData().add(new XYChart.Data<>(2, Math.abs(random.nextInt(20)) + 1900)); series2.getData().add(new XYChart.Data<>(3, Math.abs(random.nextInt(20)) + 1900)); series2.getData().add(new XYChart.Data<>(6, Math.abs(random.nextInt(20)) + 1900)); series2.getData().add(new XYChart.Data<>(7, Math.abs(random.nextInt(20)) + 1900)); series2.getData().add(new XYChart.Data<>(8, Math.abs(random.nextInt(20)) + 1900)); series2.setName("消息2"); final XYChart.Series<Number, Number> series3 = new XYChart.Series<>(); series3.getData().add(new XYChart.Data<>(2, Math.abs(random.nextInt(20)) + 1900)); series3.getData().add(new XYChart.Data<>(4, Math.abs(random.nextInt(20)) + 1900)); series3.getData().add(new XYChart.Data<>(5, Math.abs(random.nextInt(20)) + 1900)); series3.getData().add(new XYChart.Data<>(6, Math.abs(random.nextInt(20)) + 1900)); series3.getData().add(new XYChart.Data<>(8, Math.abs(random.nextInt(20)) + 1900)); series3.getData().add(new XYChart.Data<>(10, Math.abs(random.nextInt(20)) + 1900)); series3.setName("消息3"); final XYChart.Series<Number, Number> series4 = new XYChart.Series<>(); series4.getData().add(new XYChart.Data<>(2, Math.abs(random.nextInt(20)) + 1900)); series4.getData().add(new XYChart.Data<>(4, Math.abs(random.nextInt(20)) + 1900)); series4.getData().add(new XYChart.Data<>(5, Math.abs(random.nextInt(20)) + 1900)); series4.getData().add(new XYChart.Data<>(6, Math.abs(random.nextInt(20)) + 1900)); series4.getData().add(new XYChart.Data<>(8, Math.abs(random.nextInt(20)) + 1900)); series4.getData().add(new XYChart.Data<>(10, Math.abs(random.nextInt(20)) + 1900)); series4.setName("消息4"); final List<XYChart.Series<Number, Number>> delaySeriesList = Lists.newArrayList(); final List<XYChart.Series<Number, Number>> jitterSeriesList = Lists.newArrayList(); delaySeriesList.add(series1); delaySeriesList.add(series2); jitterSeriesList.add(series3); jitterSeriesList.add(series4); plus.fireEvent(Input_Message_Data, delaySeriesList, jitterSeriesList); /** Mock console */ final TreeItem<ConsoleBoxItem> r1 = new TreeItem<>( new ConsoleBoxItem("结果1", "XXXX1"), new ImageView( new Image( MainFrame.class .getClassLoader() .getResourceAsStream("dima/view/res/console_24.png")))); final TreeItem<ConsoleBoxItem> r2 = new TreeItem<>( new ConsoleBoxItem("结果1 - 1", "XXXX2"), new ImageView( new Image( MainFrame.class .getClassLoader() .getResourceAsStream("dima/view/res/console_24.png")))); final TreeItem<ConsoleBoxItem> r3 = new TreeItem<>( new ConsoleBoxItem("结果1 - 2", "XXXX3"), new ImageView( new Image( MainFrame.class .getClassLoader() .getResourceAsStream("dima/view/res/console_24.png")))); r1.getChildren().addAll(r2, r3); plus.fireEvent(Add_Console_Message, r1); // log.info("Confirm = {}", // plus.getService(DialogService.class).confirmDialog("这条消息确定吗")); plus.fireEvent( PlusEventListenerType.IPMInstance_Refresh, UINode.findFromChildren( plus.getService(TreeViewService.class).getCurrentUIProject(), UIPlan_NAME), 0); plus.fireEvent( PlusEventListenerType.SwitchInstance_Refresh, UINode.findFromChildren( plus.getService(TreeViewService.class).getCurrentUIProject(), UIPlan_NAME), 0); }
public static EventHandler<ActionEvent> getUploadHandler( FXController controller, ProgressBar progressBar, CheckBox stem) { return e -> { Alert a; if (selectedFiles != null) { controller.selectedFiles = new File[selectedFiles.size()]; for (int i = 0; i < selectedFiles.size(); i++) { String filepath = selectedFiles.get(i).getAbsolutePath(); if (lastUpload.contains(filepath)) { a = new Alert(Alert.AlertType.CONFIRMATION); a.setTitle("Are you sure?"); a.setContentText( "You just uploaded " + filepath + ", are you sure you want to upload it again?"); Optional<ButtonType> result = a.showAndWait(); if (result.get() != ButtonType.OK) { return; } } if (selectedFiles.get(i).isAbsolute() && selectedFiles.get(i).exists()) { controller.selectedFiles[i] = selectedFiles.get(i); } else { a = new Alert(Alert.AlertType.INFORMATION, "Invalid path to file.", ButtonType.OK); a.setTitle("Information"); a.showAndWait(); return; } } } else { a = new Alert(Alert.AlertType.INFORMATION, "Please select a file.", ButtonType.OK); a.initStyle(StageStyle.UTILITY); a.setTitle("Information"); a.showAndWait(); return; } progressBar.setProgress(0); controller.writeLog("Uploading file(s)..."); Button source = (Button) e.getSource(); source.setDisable(true); SwingWorker<Boolean, Double> worker = new SwingWorker<Boolean, Double>() { @Override protected Boolean doInBackground() throws Exception { String[] key = new String[FXController.selectedFiles.length]; publish(0.05); for (int i = 0; i < FXController.selectedFiles.length; i++) { key[i] = UUID.randomUUID().toString(); FileUtils.uploadFile(FXController.selectedFiles[i], key[i], AESCTR.secretKey); } publish(0.4); Map<String, ArrayList<StringPair>> map = SSE.EDBSetup( FXController.selectedFiles, AESCTR.secretKey, key, stem.isSelected()); publish(0.6); ObjectMapper mapper = new ObjectMapper(); try { String json = mapper.writeValueAsString(map); publish(0.8); HttpUtil.HttpPost(json); } catch (JsonProcessingException e1) { e1.printStackTrace(); return false; } publish(1.0); return true; } @Override protected void done() { Platform.runLater( new TimerTask() { @Override public void run() { Alert a; try { if (get()) { controller.writeLog("Upload successful!"); a = new Alert( Alert.AlertType.INFORMATION, "Upload successful!", ButtonType.OK); a.setTitle("Success!"); a.showAndWait(); lastUpload.clear(); for (File f : FXController.selectedFiles) { lastUpload.add(f.getAbsolutePath()); } } else { controller.writeLog("Upload failed!"); a = new Alert(Alert.AlertType.ERROR, "Upload failed!", ButtonType.OK); a.setTitle("Error!"); a.showAndWait(); } } catch (Exception ex) { a = new Alert(Alert.AlertType.ERROR, "Upload error!", ButtonType.OK); a.setTitle("Error!"); a.showAndWait(); ex.printStackTrace(); } source.setDisable(false); } }); } @Override protected void process(List<Double> n) { progressBar.setProgress(n.get(n.size() - 1)); } }; worker.execute(); }; }