📄 cronui.java
字号:
} 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); JOptionPane.showMessageDialog(this, "Sucessfully unregistered.", "Sucessfully unregistered", JOptionPane.INFORMATION_MESSAGE); fSelectedMenu.setEnabled(false); } } else if (e.getSource() == fRegisterButton) { String machine = fServiceMachineTF.getText(); String service = fServiceNameTF.getText(); String request = "REGISTER "; if (fMachineTF.getText().equals("")) { JOptionPane.showMessageDialog(fRegistrationDialog, "You must specify a value for Target Machine", "Target Machine not specified", JOptionPane.ERROR_MESSAGE); return; } if (fServiceTF.getText().equals("")) { JOptionPane.showMessageDialog(fRegistrationDialog, "You must specify a value for Target Service", "Target Service not specified", JOptionPane.ERROR_MESSAGE); return; } if (fRequestTF.getText().equals("")) { JOptionPane.showMessageDialog(fRegistrationDialog, "You must specify a value for Target Request", "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 (!(fMinuteTF.getText().equals(""))) { request += "MINUTE " + STAFUtil.wrapData(fMinuteTF.getText()); } if (!(fHourTF.getText().equals(""))) { request += "HOUR " + STAFUtil.wrapData(fHourTF.getText()); } if (!(fDayTF.getText().equals(""))) { request += "DAY " + STAFUtil.wrapData(fDayTF.getText()); } if (!(fMonthTF.getText().equals(""))) { request += "MONTH " + STAFUtil.wrapData(fMonthTF.getText()); } if (!(fWeekDayTF.getText().equals(""))) { request += "WEEKDAY " + STAFUtil.wrapData(fWeekDayTF.getText()); } if (!(fDescriptionTF.getText().equals(""))) { request += "DESCRIPTION " + STAFUtil.wrapData(fDescriptionTF.getText()); } if (fOnceCB.isSelected()) { request += "ONCE "; } 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 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(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(); } } } 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, "Cron 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;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -