| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 99408df commit 7895d08
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -85,30 +85,6 @@ protected JavaEditor(Base base, String path, EditorState state, | |||
| 85 | 85 | debugger = new Debugger(this); | |
| 86 | 86 | inspector = new VariableInspector(this); | |
| 87 | 87 | ||
| 88 | - // Add show usage option | ||
| 89 | - JMenuItem showUsageItem = new JMenuItem(Language.text("editor.popup.show_usage")); | ||
| 90 | - showUsageItem.addActionListener(new ActionListener() { | ||
| 91 | - public void actionPerformed(ActionEvent e) { | ||
| 92 | - handleShowUsage(); | ||
| 93 | - } | ||
| 94 | - }); | ||
| 95 | - getTextArea().getRightClickPopup().add(showUsageItem); | ||
| 96 | - | ||
| 97 | - // add refactor option | ||
| 98 | - JMenuItem renameItem = new JMenuItem(Language.text("editor.popup.rename")); | ||
| 99 | - renameItem.addActionListener(new ActionListener() { | ||
| 100 | - public void actionPerformed(ActionEvent e) { | ||
| 101 | - handleRefactor(); | ||
| 102 | - } | ||
| 103 | - }); | ||
| 104 | - | ||
| 105 | - // TODO: Add support for word select on right click and rename. | ||
| 106 | - // ta.customPainter.addMouseListener(new MouseAdapter() { | ||
| 107 | - // public void mouseClicked(MouseEvent evt) { | ||
| 108 | - // System.out.println(evt); | ||
| 109 | - // } | ||
| 110 | - // }); | ||
| 111 | - textarea.getRightClickPopup().add(renameItem); | ||
| 112 | 88 | // set action on frame close | |
| 113 | 89 | // addWindowListener(new WindowAdapter() { | |
| 114 | 90 | // @Override | |
@@ -117,7 +93,6 @@ public void actionPerformed(ActionEvent e) { | |||
| 117 | 93 | // } | |
| 118 | 94 | // }); | |
| 119 | 95 | ||
| 120 | - Toolkit.setMenuMnemonics(textarea.getRightClickPopup()); | ||
| 121 | 96 | ||
| 122 | 97 | // // load settings from theme.txt | |
| 123 | 98 | // breakpointColor = mode.getColor("breakpoint.bgcolor"); | |
@@ -153,6 +128,8 @@ public void actionPerformed(ActionEvent e) { | |||
| 153 | 128 | ||
| 154 | 129 | initPDEX(); | |
| 155 | 130 | ||
| 131 | + Toolkit.setMenuMnemonics(textarea.getRightClickPopup()); | ||
| 132 | + | ||
| 156 | 133 | // ensure completion is hidden when editor loses focus | |
| 157 | 134 | addWindowFocusListener(new WindowFocusListener() { | |
| 158 | 135 | public void windowLostFocus(WindowEvent e) { | |
@@ -173,60 +150,11 @@ public void caretUpdate(CaretEvent e) { | |||
| 173 | 150 | public PdePreprocessor createPreprocessor(final String sketchName) { | |
| 174 | 151 | return new PdePreprocessor(sketchName); | |
| 175 | 152 | } | |
| 176 | - | ||
| 153 | + | ||
| 177 | 154 | ||
| 178 | 155 | protected void initPDEX() { | |
| 179 | 156 | preprocessingService = new PreprocessingService(this); | |
| 180 | 157 | pdex = new PDEX(this, preprocessingService); | |
| 181 | - | ||
| 182 | - // Add ctrl+click listener | ||
| 183 | - getJavaTextArea().getPainter().addMouseListener(new MouseAdapter() { | ||
| 184 | - public void mouseReleased(MouseEvent evt) { | ||
| 185 | - if (evt.getButton() == MouseEvent.BUTTON1) { | ||
| 186 | - if ((evt.isControlDown() && !Platform.isMacOS()) || evt.isMetaDown()) { | ||
| 187 | - handleCtrlClick(evt); | ||
| 188 | - } | ||
| 189 | - } else if (evt.getButton() == MouseEvent.BUTTON2) { | ||
| 190 | - handleCtrlClick(evt); | ||
| 191 | - } | ||
| 192 | - } | ||
| 193 | - }); | ||
| 194 | - | ||
| 195 | - sketchChanged(); | ||
| 196 | - | ||
| 197 | - for (SketchCode code : getSketch().getCode()) { | ||
| 198 | - Document document = code.getDocument(); | ||
| 199 | - addDocumentListener(document); | ||
| 200 | - } | ||
| 201 | - } | ||
| 202 | - | ||
| 203 | - | ||
| 204 | - public void addDocumentListener(Document doc) { | ||
| 205 | - if (doc != null) doc.addDocumentListener(sketchChangedListener); | ||
| 206 | - } | ||
| 207 | - | ||
| 208 | - | ||
| 209 | - protected final DocumentListener sketchChangedListener = new DocumentListener() { | ||
| 210 | - @Override | ||
| 211 | - public void insertUpdate(DocumentEvent e) { | ||
| 212 | - sketchChanged(); | ||
| 213 | - } | ||
| 214 | - | ||
| 215 | - @Override | ||
| 216 | - public void removeUpdate(DocumentEvent e) { | ||
| 217 | - sketchChanged(); | ||
| 218 | - } | ||
| 219 | - | ||
| 220 | - @Override | ||
| 221 | - public void changedUpdate(DocumentEvent e) { | ||
| 222 | - sketchChanged(); | ||
| 223 | - } | ||
| 224 | - }; | ||
| 225 | - | ||
| 226 | - | ||
| 227 | - protected void sketchChanged() { | ||
| 228 | - pdex.notifySketchChanged(); | ||
| 229 | - preprocessingService.notifySketchChanged(); | ||
| 230 | 158 | } | |
| 231 | 159 | ||
| 232 | 160 | ||
@@ -257,7 +185,7 @@ public void rebuild() { | |||
| 257 | 185 | if (preprocessingService != null) { | |
| 258 | 186 | if (hasJavaTabsChanged) { | |
| 259 | 187 | preprocessingService.handleHasJavaTabsChange(hasJavaTabs); | |
| 260 | - pdex.handleHasJavaTabsChange(hasJavaTabs); | ||
| 188 | + pdex.hasJavaTabsChanged(hasJavaTabs); | ||
| 261 | 189 | if (hasJavaTabs) { | |
| 262 | 190 | setProblemList(Collections.emptyList()); | |
| 263 | 191 | } | |
@@ -266,7 +194,7 @@ public void rebuild() { | |||
| 266 | 194 | int currentTabCount = sketch.getCodeCount(); | |
| 267 | 195 | if (currentTabCount != previousTabCount) { | |
| 268 | 196 | previousTabCount = currentTabCount; | |
| 269 | - sketchChanged(); | ||
| 197 | + pdex.sketchChanged(); | ||
| 270 | 198 | } | |
| 271 | 199 | } | |
| 272 | 200 | } | |
@@ -2298,8 +2226,8 @@ public void setCode(SketchCode code) { | |||
| 2298 | 2226 | super.setCode(code); | |
| 2299 | 2227 | ||
| 2300 | 2228 | Document newDoc = code.getDocument(); | |
| 2301 | - if (oldDoc != newDoc && preprocessingService != null) { | ||
| 2302 | - addDocumentListener(newDoc); | ||
| 2229 | + if (oldDoc != newDoc && pdex != null) { | ||
| 2230 | + pdex.documentChanged(newDoc); | ||
| 2303 | 2231 | } | |
| 2304 | 2232 | ||
| 2305 | 2233 | // set line background colors for tab | |
@@ -2717,36 +2645,6 @@ public void updateErrorToggle(boolean hasErrors) { | |||
| 2717 | 2645 | } | |
| 2718 | 2646 | ||
| 2719 | 2647 | ||
| 2720 | - /** Handle refactor operation */ | ||
| 2721 | - private void handleRefactor() { | ||
| 2722 | - int startOffset = getSelectionStart(); | ||
| 2723 | - int stopOffset = getSelectionStop(); | ||
| 2724 | - int tabIndex = sketch.getCurrentCodeIndex(); | ||
| 2725 | - | ||
| 2726 | - pdex.handleRename(tabIndex, startOffset, stopOffset); | ||
| 2727 | - } | ||
| 2728 | - | ||
| 2729 | - | ||
| 2730 | - /** Handle show usage operation */ | ||
| 2731 | - private void handleShowUsage() { | ||
| 2732 | - int startOffset = getSelectionStart(); | ||
| 2733 | - int stopOffset = getSelectionStop(); | ||
| 2734 | - int tabIndex = sketch.getCurrentCodeIndex(); | ||
| 2735 | - | ||
| 2736 | - pdex.handleShowUsage(tabIndex, startOffset, stopOffset); | ||
| 2737 | - } | ||
| 2738 | - | ||
| 2739 | - | ||
| 2740 | - /** Handle ctrl+click */ | ||
| 2741 | - private void handleCtrlClick(MouseEvent evt) { | ||
| 2742 | - int off = getJavaTextArea().xyToOffset(evt.getX(), evt.getY()); | ||
| 2743 | - if (off < 0) return; | ||
| 2744 | - int tabIndex = sketch.getCurrentCodeIndex(); | ||
| 2745 | - | ||
| 2746 | - pdex.handleCtrlClick(tabIndex, off); | ||
| 2747 | - } | ||
| 2748 | - | ||
| 2749 | - | ||
| 2750 | 2648 | public boolean hasJavaTabs() { | |
| 2751 | 2649 | return hasJavaTabs; | |
| 2752 | 2650 | } | |
@@ -2781,7 +2679,7 @@ protected void applyPreferences() { | |||
| 2781 | 2679 | jmode.loadPreferences(); | |
| 2782 | 2680 | Messages.log("Applying prefs"); | |
| 2783 | 2681 | // trigger it once to refresh UI | |
| 2784 | - sketchChanged(); | ||
| 2682 | + pdex.preferencesChanged(); | ||
| 2785 | 2683 | } | |
| 2786 | 2684 | } | |
| 2787 | 2685 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments