📄 eventmanagerui.java
字号:
"Target Request not specified", JOptionPane.ERROR_MESSAGE); return; } if (fPythonMachine.isSelected()) { request += "PYTHONMACHINE " + STAFUtil.wrapData(fMachineTF.getText()) + " "; } else { request += "MACHINE " + STAFUtil.wrapData(fMachineTF.getText()) + " "; } if (fPythonService.isSelected()) { request += "PYTHONSERVICE " + STAFUtil.wrapData(fServiceTF.getText()) + " "; } else { request += "SERVICE " + STAFUtil.wrapData(fServiceTF.getText()) + " "; } if (fPythonRequest.isSelected()) { request += "PYTHONREQUEST " + STAFUtil.wrapData(fRequestTF.getText()) + " "; } else { request += "REQUEST " + STAFUtil.wrapData(fRequestTF.getText()) + " "; } if (!(fPrepareTA.getText().equals(""))) { request += "PREPARE " + STAFUtil.wrapData(fPrepareTA.getText()); } if (!(fTypeTF.getText().equals(""))) { request += "TYPE " + STAFUtil.wrapData(fTypeTF.getText()); } if (!(fSubtypeTF.getText().equals(""))) { request += "SUBTYPE " + STAFUtil.wrapData(fSubtypeTF.getText()); } if (!(fDescriptionTF.getText().equals(""))) { request += "DESCRIPTION " + STAFUtil.wrapData(fDescriptionTF.getText()); } if (!(fRegistrationIDLabel.getText().equals("N/A"))) { int response = JOptionPane.showConfirmDialog(fRegistrationDialog, "Do you want to unregister ID " + fRegistrationIDLabel.getText() + " and re-register the " + "STAF request?"); if (response != JOptionPane.YES_OPTION) { return; } STAFResult result = fHandle.submit2(machine, service, " UNREGISTER ID " + fRegistrationIDLabel.getText()); fRegistrationIDLabel.setText("N/A"); } STAFResult result = fHandle.submit2(machine, service, request); if (result.rc != 0) { showErrorDialog(fRegistrationDialog, "An error was encountered while " + "attempting to register" + " rc=" + result.rc + " result=" + result.result); } else { Vector idData = getRegistrationTable(); setInstructionLabel(idData); if (idData == null) { return; } ((RegisterModel)(fIDTable.getModel())).setDataVector(idData, fColumnNames); fIDTable.getColumnModel().getColumn(0).setMaxWidth(40); fIDTable.getColumnModel().getColumn(0).setPreferredWidth(40); fIDTable.getColumnModel().getColumn(1).setPreferredWidth(150); fIDTable.getColumnModel().getColumn(2).setPreferredWidth(30); fIDTable.getColumnModel().getColumn(3).setPreferredWidth(30); fIDTable.getColumnModel().getColumn(4).setPreferredWidth(265); fRegistrationDialog.dispose(); JOptionPane.showMessageDialog(this, "Sucessfully registered. ID = " + result.result, "Sucessfully registerd", JOptionPane.INFORMATION_MESSAGE); fSelectedMenu.setEnabled(false); } } } public void mouseClicked(MouseEvent e) { int selectedRow = fIDTable.getSelectedRow(); if (selectedRow != -1) { fSelectedMenu.setEnabled(true); } if ((e.getClickCount() != 2) || (selectedRow == -1)) { return; } String selectedId = (String) fIDTable.getValueAt(selectedRow, 0); String eventManagerId = ""; Iterator idIter = fEntryList.iterator(); while (idIter.hasNext() && !(eventManagerId.equals(selectedId))) { Map registrationMap = (Map)idIter.next(); eventManagerId = (String)registrationMap.get("eventManagerID"); if (eventManagerId.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 type = (String)registrationMap.get("type"); String subtype = (String)registrationMap.get("subtype"); String dayOfMonth = (String)registrationMap.get("dayOfMonth"); String month = (String)registrationMap.get("month"); String dayOfWeek = (String)registrationMap.get("dayOfWeek"); String description = (String)registrationMap.get("description"); displayfRegistrationDialog(); fRegistrationIDLabel.setText(eventManagerId); 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); fTypeTF.setText(type); fSubtypeTF.setText(subtype); fDescriptionTF.setText(description); fRegistrationDialog.show(); } } } public void mouseEntered(MouseEvent e) {} public void mouseExited(MouseEvent e) {} public void mousePressed(MouseEvent e){} public void mouseReleased(MouseEvent e) { displayPopup(e); } public void displayPopup(MouseEvent e) { if (e.isPopupTrigger()) { int tableIndex = fIDTable.rowAtPoint(new Point(e.getX(), e.getY())); if (tableIndex > -1) { fIDTable.setRowSelectionInterval(tableIndex, tableIndex); fPopupMenu.show(e.getComponent(), e.getX(), e.getY()); fSelectedMenu.setEnabled(true); } } } public void keyPressed(KeyEvent e) { if ((e.getSource() == fServiceMachineTF) || (e.getSource() == fServiceNameTF)) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { Vector idData = getRegistrationTable(); setInstructionLabel(idData); ((RegisterModel)(fIDTable.getModel())).setDataVector(idData, fColumnNames); fIDTable.getColumnModel().getColumn(0).setMaxWidth(40); fIDTable.getColumnModel().getColumn(0).setPreferredWidth(40); fIDTable.getColumnModel().getColumn(1).setPreferredWidth(150); fIDTable.getColumnModel().getColumn(2).setPreferredWidth(30); fIDTable.getColumnModel().getColumn(3).setPreferredWidth(30); fIDTable.getColumnModel().getColumn(4).setPreferredWidth(265); fSelectedMenu.setEnabled(false); } } } public void keyReleased(KeyEvent e) {} public void keyTyped(KeyEvent e) {} public void displayfRegistrationDialog() { fRegistrationDialog = new JDialog(this, "EventManager Registration", true); JPanel optionsPanel = new JPanel(); GridBagLayout gbl = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); optionsPanel.setLayout(gbl); JLabel registrationIDTitle = new JLabel("Registration ID:"); registrationIDTitle.setOpaque(true); registrationIDTitle.setForeground(Color.black); gbc.anchor = GridBagConstraints.NORTHWEST; optionsPanel.add(registrationIDTitle, gbc); optionsPanel.add(Box.createHorizontalStrut(10), gbc); fRegistrationIDLabel = new JLabel("N/A"); fRegistrationIDLabel.setForeground(Color.blue); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.weightx = 1.0; optionsPanel.add(fRegistrationIDLabel, gbc); gbc.weightx = 0; optionsPanel.add(Box.createVerticalStrut(3), gbc); JLabel descriptionLabel = new JLabel("Description:"); descriptionLabel.setOpaque(true); descriptionLabel.setForeground(Color.black); gbc.gridwidth = 1; optionsPanel.add(descriptionLabel, gbc); optionsPanel.add(Box.createHorizontalStrut(10), gbc); fDescriptionTF = new JTextField(20) { public JToolTip createToolTip() { MultiLineToolTip tip = new MultiLineToolTip(); tip.setComponent(this); return tip; } }; fDescriptionTF.setToolTipText("Enter a description for the " + "registration. This field is optional."); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.weightx = 1.0; optionsPanel.add(fDescriptionTF, gbc); gbc.weightx = 0; optionsPanel.add(Box.createVerticalStrut(3), gbc); JLabel machineLabel = new JLabel("Target Machine:"); machineLabel.setOpaque(true); machineLabel.setForeground(Color.black); gbc.gridwidth = 1; optionsPanel.add(machineLabel, gbc); optionsPanel.add(Box.createHorizontalStrut(10), gbc); fPythonMachine = new JCheckBox("Python", false) { public JToolTip createToolTip() { MultiLineToolTip tip = new MultiLineToolTip(); tip.setComponent(this); return tip; } }; fPythonMachine.setToolTipText("Checking \"Python\" indicates that "+ "the text entered\nfor \"Target Machine\" contains Python code."); gbc.gridwidth = 1; optionsPanel.add(fPythonMachine, gbc); optionsPanel.add(Box.createHorizontalStrut(10), gbc); fMachineTF = new JTextField(20) { public JToolTip createToolTip() { MultiLineToolTip tip = new MultiLineToolTip(); tip.setComponent(this); return tip; } }; fMachineTF.setToolTipText("The machine where you wish to have the " + "STAF command\nexecuted. This field is required. If the text " + "contains Python\ncode, then select \"Python\" next to the " + "\"Target Machine\" label."); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.weightx = 1.0; optionsPanel.add(fMachineTF, gbc); gbc.weightx = 0; optionsPanel.add(Box.createVerticalStrut(3), gbc); JLabel serviceLabel = new JLabel("Target Service:"); serviceLabel.setOpaque(true); serviceLabel.setForeground(Color.black); gbc.gridwidth = 1; optionsPanel.add(serviceLabel, gbc); optionsPanel.add(Box.createHorizontalStrut(10), gbc); fPythonService = new JCheckBox("Python", false) { public JToolTip createToolTip() { MultiLineToolTip tip = new MultiLineToolTip(); tip.setComponent(this); return tip;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -