📄 cronui.java
字号:
String request = (String)registrationMap.get("request"); String requestType = (String)registrationMap.get("requestType"); String prepareScript = (String)registrationMap.get("prepareScript"); String minute = (String)registrationMap.get("minute"); String hour = (String)registrationMap.get("hour"); String dayOfMonth = (String)registrationMap.get("dayOfMonth"); String month = (String)registrationMap.get("month"); String dayOfWeek = (String)registrationMap.get("dayOfWeek"); String description = (String)registrationMap.get("description"); String once = (String)registrationMap.get("once"); displayfRegistrationDialog(); fRegistrationIDLabel.setText(cronId); fMachineTF.setText(machine); fPythonMachine.setSelected(machineType.equals("Python")); fServiceTF.setText(service); fPythonService.setSelected(serviceType.equals("Python")); fRequestTF.setText(request); fPythonRequest.setSelected(requestType.equals("Python")); fPrepareTA.setText(prepareScript); fMinuteTF.setText(minute); fHourTF.setText(hour); fDayTF.setText(dayOfMonth); fMonthTF.setText(month); fWeekDayTF.setText(dayOfWeek); fDescriptionTF.setText(description); if (once.equals("false")) { fOnceCB.setSelected(false); } else { fOnceCB.setSelected(true); } fRegistrationDialog.show(); } } } else if (e.getSource() == fSelectedTrigger || e.getSource() == fPopupMenuTrigger) { String machine = fServiceMachineTF.getText(); String service = fServiceNameTF.getText(); int selectedRow = fIDTable.getSelectedRow(); if (selectedRow == -1) { return; } String selectedId = (String) fIDTable.getValueAt(selectedRow, 0); STAFResult result = fHandle.submit2(machine, service, " TRIGGER ID " + selectedId); if (result.rc != 0) { showErrorDialog(fRegistrationDialog, "An error was encountered while " + "attempting to trigger" + " rc=" + result.rc + " result=" + result.result); } else { STAFMarshallingContext mc = STAFMarshallingContext.unmarshall(result.result); Map triggerMap = (Map)mc.getRootObject(); String triggerMachine = (String)triggerMap.get("machine"); String triggerRequestNumber = (String)triggerMap.get("requestNumber"); String logQueryContains = "[ID=" + selectedId + "] [" + triggerMachine + ":" + triggerRequestNumber + "]"; // Get Cron Machine nickname String serviceMachineNickname = ""; STAFResult res = fHandle.submit2(machine, "VAR", "RESOLVE STRING {STAF/Config/MachineNickname}"); if (res.rc == 0) { serviceMachineNickname = res.result; } else { System.out.println( "Error resolving string {STAF/Config/MachineNickname} " + "on machine " + serviceMachineNickname + ". RC=" + res.rc + ", Result=" + res.result); } try { Thread.sleep(250); } catch(InterruptedException ex) {} String queryRequest = " QUERY MACHINE " + serviceMachineNickname + " LOGNAME " + service + " CONTAINS " + logQueryContains; STAFLogViewer logViewer = new STAFLogViewer(this, fHandle, machine, "LOG ", queryRequest, "", "Monospaced"); } } else if (e.getSource() == fSelectedTriggerWithScript || e.getSource() == fPopupMenuTriggerWithScript) { fScriptDialog = new JDialog(this, "Trigger Script", true); fScriptDialog.setSize(new Dimension(400, 200)); JPanel scriptPanel = new JPanel(); scriptPanel.setLayout(new BorderLayout()); fScriptTextArea = new JTextArea(5, 15); fScriptTextArea.setBorder(new TitledBorder("Enter script here")); scriptPanel.add(BorderLayout.CENTER, new JScrollPane(fScriptTextArea)); fScriptTriggerButton = new JButton("Trigger"); fScriptCancelButton = new JButton("Cancel"); JPanel scriptButtonPanel = new JPanel(); scriptButtonPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0)); scriptButtonPanel.add(fScriptTriggerButton); scriptButtonPanel.add(Box.createHorizontalStrut(20)); scriptButtonPanel.add(fScriptCancelButton); scriptPanel.add(BorderLayout.SOUTH, scriptButtonPanel); fScriptTriggerButton.addActionListener(this); fScriptCancelButton.addActionListener(this); fScriptDialog.getContentPane().add(scriptPanel); fScriptTextArea.setFont(new Font("Monospaced", Font.PLAIN, 12)); fScriptDialog.setLocationRelativeTo(this); fScriptDialog.setFont(new Font("Monospaced", Font.PLAIN, 12)); fScriptDialog.show(); } else if (e.getSource() == fScriptCancelButton) { fScriptDialog.dispose(); } else if (e.getSource() == fScriptTriggerButton) { String triggerScript = fScriptTextArea.getText(); fScriptDialog.dispose(); String machine = fServiceMachineTF.getText(); String service = fServiceNameTF.getText(); int selectedRow = fIDTable.getSelectedRow(); if (selectedRow == -1) { return; } String selectedId = (String) fIDTable.getValueAt(selectedRow, 0); STAFResult result = fHandle.submit2(machine, service, " TRIGGER ID " + selectedId + " SCRIPT " + STAFUtil.wrapData(triggerScript)); if (result.rc != 0) { showErrorDialog(fRegistrationDialog, "An error was encountered while " + "attempting to trigger" + " rc=" + result.rc + " result=" + result.result); } else { STAFMarshallingContext mc = STAFMarshallingContext.unmarshall(result.result); Map triggerMap = (Map)mc.getRootObject(); String triggerMachine = (String)triggerMap.get("machine"); String triggerRequestNumber = (String)triggerMap.get("requestNumber"); String logQueryContains = "[ID=" + selectedId + "] [" + triggerMachine + ":" + triggerRequestNumber + "]"; // Get Cron Machine nickname String serviceMachineNickname = ""; STAFResult res = fHandle.submit2(machine, "VAR", "RESOLVE STRING {STAF/Config/MachineNickname}"); if (res.rc == 0) { serviceMachineNickname = res.result; } else { System.out.println( "Error resolving string {STAF/Config/MachineNickname} " + "on machine " + serviceMachineNickname + ". RC=" + res.rc + ", Result=" + res.result); } try { Thread.sleep(250); } catch(InterruptedException ex) {} String queryRequest = " QUERY MACHINE " + serviceMachineNickname + " LOGNAME " + service + " CONTAINS " + logQueryContains; STAFLogViewer logViewer = new STAFLogViewer(this, fHandle, machine, "LOG ", queryRequest, "", "Monospaced"); } } else if (e.getSource() == fSelectedCopyToNewRegistration || e.getSource() == fPopupMenuCopyToNewRegistration) { int selectedRow = fIDTable.getSelectedRow(); if (selectedRow == -1) { return; } String selectedId = (String) fIDTable.getValueAt(selectedRow, 0); String cronId = ""; Iterator idIter = fEntryList.iterator(); while (idIter.hasNext() && !(cronId.equals(selectedId))) { Map registrationMap = (Map)idIter.next(); cronId = (String)registrationMap.get("cronID"); if (cronId.equals(selectedId)) { String machine = (String)registrationMap.get("machine"); String machineType = (String)registrationMap.get("machineType"); String service = (String)registrationMap.get("service"); String serviceType = (String)registrationMap.get("serviceType"); String request = (String)registrationMap.get("request"); String requestType = (String)registrationMap.get("requestType"); String prepareScript = (String)registrationMap.get("prepareScript"); String minute = (String)registrationMap.get("minute"); String hour = (String)registrationMap.get("hour"); String dayOfMonth = (String)registrationMap.get("dayOfMonth"); String month = (String)registrationMap.get("month"); String dayOfWeek = (String)registrationMap.get("dayOfWeek"); String description = (String)registrationMap.get("description"); String once = (String)registrationMap.get("once"); displayfRegistrationDialog(); fRegistrationIDLabel.setText("N/A"); fMachineTF.setText(machine); fPythonMachine.setSelected(machineType.equals("Python")); fServiceTF.setText(service); fPythonService.setSelected(serviceType.equals("Python")); fRequestTF.setText(request); fPythonRequest.setSelected(requestType.equals("Python")); fPrepareTA.setText(prepareScript); fMinuteTF.setText(minute); fHourTF.setText(hour); fDayTF.setText(dayOfMonth); fMonthTF.setText(month); fWeekDayTF.setText(dayOfWeek); fDescriptionTF.setText(description); if (once.equals("false")) { fOnceCB.setSelected(false); } else { fOnceCB.setSelected(true); } fRegistrationDialog.show(); } } } else if (e.getSource() == fSelectedUnregister || e.getSource() == fPopupMenuUnregister) { String machine = fServiceMachineTF.getText(); String service = fServiceNameTF.getText(); int selectedRow = fIDTable.getSelectedRow(); if (selectedRow == -1) { return; } String selectedId = (String) fIDTable.getValueAt(selectedRow, 0); int response = JOptionPane.showConfirmDialog(this, "Are you sure you want to unregister ID " + selectedId + "?"); if (response != JOptionPane.YES_OPTION) { return; } STAFResult result = fHandle.submit2(machine, service, " UNREGISTER ID " + selectedId); if (result.rc != 0) { showErrorDialog(fRegistrationDialog, "An error was encountered while " + "attempting to unregister" + " rc=" + result.rc + " result=" + result.result);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -