(JavaEditor editor, PreprocessingService pps, ShowUsage showUsage)
| 61 | |
| 62 | |
| 63 | Rename(JavaEditor editor, PreprocessingService pps, ShowUsage showUsage) { |
| 64 | this.editor = editor; |
| 65 | this.pps = pps; |
| 66 | this.showUsage = showUsage; |
| 67 | |
| 68 | // Add rename option |
| 69 | JMenuItem renameItem = new JMenuItem(Language.text("editor.popup.rename")); |
| 70 | renameItem.addActionListener(e -> handleRename()); |
| 71 | editor.getTextArea().getRightClickPopup().add(renameItem); |
| 72 | |
| 73 | window = new JDialog(editor); |
| 74 | JRootPane rootPane = window.getRootPane(); |
| 75 | window.setTitle("Rename"); |
| 76 | window.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); |
| 77 | Toolkit.registerWindowCloseKeys(rootPane, new ActionListener() { |
| 78 | @Override |
| 79 | public void actionPerformed(ActionEvent e) { |
| 80 | window.setVisible(false); |
| 81 | } |
| 82 | }); |
| 83 | Toolkit.setIcon(window); |
| 84 | |
| 85 | window.setModal(true); |
| 86 | window.setResizable(false); |
| 87 | window.addComponentListener(new ComponentAdapter() { |
| 88 | @Override |
| 89 | public void componentHidden(ComponentEvent e) { |
| 90 | binding = null; |
| 91 | ps = null; |
| 92 | } |
| 93 | }); |
| 94 | //window.setSize(Toolkit.zoom(250, 130)); |
| 95 | //window.setLayout(new BoxLayout(window.getContentPane(), BoxLayout.Y_AXIS)); |
| 96 | Box windowBox = Box.createVerticalBox(); |
| 97 | Toolkit.setBorder(windowBox); |
| 98 | final int GAP = Toolkit.zoom(5); |
| 99 | |
| 100 | { // old name |
| 101 | Box oldBox = Box.createHorizontalBox(); |
| 102 | oldNameLabel = new JLabel("Current Name: "); |
| 103 | oldBox.add(oldNameLabel); |
| 104 | //oldBox.add(Box.createHorizontalStrut(10)); |
| 105 | oldBox.add(Box.createHorizontalGlue()); |
| 106 | windowBox.add(oldBox); |
| 107 | windowBox.add(Box.createVerticalStrut(GAP)); |
| 108 | } |
| 109 | |
| 110 | { // new name |
| 111 | Box newBox = Box.createHorizontalBox(); |
| 112 | JLabel newNameLabel = new JLabel("New Name: "); |
| 113 | newBox.add(newNameLabel); |
| 114 | newBox.add(textField = new JTextField(20)); |
| 115 | newBox.add(Box.createHorizontalGlue()); |
| 116 | windowBox.add(newBox); |
| 117 | windowBox.add(Box.createVerticalStrut(GAP*2)); |
| 118 | } |
| 119 | |
| 120 | { // button panel |
nothing calls this directly
no test coverage detected