| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2897,6 +2897,20 @@ public void prepareRun() { | |||
| 2897 | 2897 | abstract public void deactivateRun(); | |
| 2898 | 2898 | ||
| 2899 | 2899 | ||
| 2900 | + // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | ||
| 2901 | + | ||
| 2902 | + | ||
| 2903 | + /** | ||
| 2904 | + * Called by ErrorTable when a row is selected. Action taken is specific | ||
| 2905 | + * to each Mode, based on the object passed in. | ||
| 2906 | + */ | ||
| 2907 | + public void errorTableClick(Object item) { } | ||
| 2908 | + | ||
| 2909 | + | ||
| 2910 | + public void errorTableDoubleClick(Object item) { } | ||
| 2911 | + | ||
| 2912 | + | ||
| 2913 | + | ||
| 2900 | 2914 | // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | |
| 2901 | 2915 | ||
| 2902 | 2916 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,9 +14,11 @@ | |||
| 14 | 14 | ||
| 15 | 15 | import javax.swing.*; | |
| 16 | 16 | import javax.swing.border.*; | |
| 17 | + import javax.swing.event.ListSelectionEvent; | ||
| 18 | + import javax.swing.event.ListSelectionListener; | ||
| 17 | 19 | import javax.swing.event.MenuEvent; | |
| 18 | 20 | import javax.swing.event.MenuListener; | |
| 19 | - import javax.swing.table.TableModel; | ||
| 21 | + import javax.swing.text.BadLocationException; | ||
| 20 | 22 | import javax.swing.text.Document; | |
| 21 | 23 | ||
| 22 | 24 | import org.eclipse.jdt.core.compiler.IProblem; | |
@@ -2559,12 +2561,120 @@ public void showConsole() { | |||
| 2559 | 2561 | // } | |
| 2560 | 2562 | ||
| 2561 | 2563 | ||
| 2562 | - /** Updates the error table */ | ||
| 2563 | - synchronized public boolean updateTable(final TableModel tableModel) { | ||
| 2564 | - return errorTable.updateTable(tableModel); | ||
| 2564 | + public XQErrorTable getErrorTable() { | ||
| 2565 | + return errorTable; | ||
| 2565 | 2566 | } | |
| 2566 | 2567 | ||
| 2567 | 2568 | ||
| 2569 | + public void errorTableClick(Object item) { | ||
| 2570 | + Problem p = (Problem) item; | ||
| 2571 | + errorCheckerService.scrollToErrorLine(p); | ||
| 2572 | + } | ||
| 2573 | + | ||
| 2574 | + | ||
| 2575 | + public void errorTableDoubleClick(Object item) { | ||
| 2576 | + Problem p = (Problem) item; | ||
| 2577 | + | ||
| 2578 | + // MouseEvent evt = null; | ||
| 2579 | + String[] suggs = p.getImportSuggestions(); | ||
| 2580 | + if (suggs != null && suggs.length > 0) { | ||
| 2581 | + // String t = p.getMessage() + "(Import Suggestions available)"; | ||
| 2582 | + // FontMetrics fm = getFontMetrics(getFont()); | ||
| 2583 | + // int x1 = fm.stringWidth(p.getMessage()); | ||
| 2584 | + // int x2 = fm.stringWidth(t); | ||
| 2585 | + // if (evt.getX() > x1 && evt.getX() < x2) { | ||
| 2586 | + String[] list = p.getImportSuggestions(); | ||
| 2587 | + String className = list[0].substring(list[0].lastIndexOf('.') + 1); | ||
| 2588 | + String[] temp = new String[list.length]; | ||
| 2589 | + for (int i = 0; i < list.length; i++) { | ||
| 2590 | + temp[i] = "<html>Import '" + className + "' <font color=#777777>(" + list[i] + ")</font></html>"; | ||
| 2591 | + } | ||
| 2592 | + // showImportSuggestion(temp, evt.getXOnScreen(), evt.getYOnScreen() - 3 * getFont().getSize()); | ||
| 2593 | + Point mouse = MouseInfo.getPointerInfo().getLocation(); | ||
| 2594 | + showImportSuggestion(temp, mouse.x, mouse.y); | ||
| 2595 | + } | ||
| 2596 | + } | ||
| 2597 | + | ||
| 2598 | + | ||
| 2599 | + JFrame frmImportSuggest; | ||
| 2600 | + | ||
| 2601 | + private void showImportSuggestion(String[] list, int x, int y) { | ||
| 2602 | + if (frmImportSuggest != null) { | ||
| 2603 | + // frmImportSuggest.setVisible(false); | ||
| 2604 | + // frmImportSuggest = null; | ||
| 2605 | + return; | ||
| 2606 | + } | ||
| 2607 | + final JList<String> classList = new JList<String>(list); | ||
| 2608 | + classList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); | ||
| 2609 | + frmImportSuggest = new JFrame(); | ||
| 2610 | + | ||
| 2611 | + frmImportSuggest.setUndecorated(true); | ||
| 2612 | + frmImportSuggest.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); | ||
| 2613 | + JPanel panel = new JPanel(); | ||
| 2614 | + panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); | ||
| 2615 | + panel.setBackground(Color.WHITE); | ||
| 2616 | + frmImportSuggest.setBackground(Color.WHITE); | ||
| 2617 | + panel.add(classList); | ||
| 2618 | + JLabel label = new JLabel("<html><div alight = \"left\"><font size = \"2\"><br>(Click to insert)</font></div></html>"); | ||
| 2619 | + label.setBackground(Color.WHITE); | ||
| 2620 | + label.setHorizontalTextPosition(SwingConstants.LEFT); | ||
| 2621 | + panel.add(label); | ||
| 2622 | + panel.validate(); | ||
| 2623 | + frmImportSuggest.getContentPane().add(panel); | ||
| 2624 | + frmImportSuggest.pack(); | ||
| 2625 | + | ||
| 2626 | + classList.addListSelectionListener(new ListSelectionListener() { | ||
| 2627 | + public void valueChanged(ListSelectionEvent e) { | ||
| 2628 | + if (classList.getSelectedValue() != null) { | ||
| 2629 | + try { | ||
| 2630 | + String t = classList.getSelectedValue().trim(); | ||
| 2631 | + Messages.log(t); | ||
| 2632 | + int x = t.indexOf('('); | ||
| 2633 | + String impString = "import " + t.substring(x + 1, t.indexOf(')')) + ";\n"; | ||
| 2634 | + int ct = getSketch().getCurrentCodeIndex(); | ||
| 2635 | + getSketch().setCurrentCode(0); | ||
| 2636 | + getTextArea().getDocument().insertString(0, impString, null); | ||
| 2637 | + getSketch().setCurrentCode(ct); | ||
| 2638 | + } catch (BadLocationException ble) { | ||
| 2639 | + Messages.log("Failed to insert import"); | ||
| 2640 | + ble.printStackTrace(); | ||
| 2641 | + } | ||
| 2642 | + } | ||
| 2643 | + frmImportSuggest.setVisible(false); | ||
| 2644 | + frmImportSuggest.dispose(); | ||
| 2645 | + frmImportSuggest = null; | ||
| 2646 | + } | ||
| 2647 | + }); | ||
| 2648 | + | ||
| 2649 | + frmImportSuggest.addWindowFocusListener(new WindowFocusListener() { | ||
| 2650 | + | ||
| 2651 | + @Override | ||
| 2652 | + public void windowLostFocus(WindowEvent e) { | ||
| 2653 | + if (frmImportSuggest != null) { | ||
| 2654 | + frmImportSuggest.dispose(); | ||
| 2655 | + frmImportSuggest = null; | ||
| 2656 | + } | ||
| 2657 | + } | ||
| 2658 | + | ||
| 2659 | + @Override | ||
| 2660 | + public void windowGainedFocus(WindowEvent e) { | ||
| 2661 | + | ||
| 2662 | + } | ||
| 2663 | + }); | ||
| 2664 | + | ||
| 2665 | + frmImportSuggest.setLocation(x, y); | ||
| 2666 | + frmImportSuggest.setBounds(x, y, 250, 100); | ||
| 2667 | + frmImportSuggest.pack(); | ||
| 2668 | + frmImportSuggest.setVisible(true); | ||
| 2669 | + } | ||
| 2670 | + | ||
| 2671 | + | ||
| 2672 | + // /** Updates the error table */ | ||
| 2673 | + // synchronized public boolean updateTable(final TableModel tableModel) { | ||
| 2674 | + // return errorTable.updateTable(tableModel); | ||
| 2675 | + // } | ||
| 2676 | + | ||
| 2677 | + | ||
| 2568 | 2678 | /** | |
| 2569 | 2679 | * Handle whether the tiny red error indicator is shown near | |
| 2570 | 2680 | * the error button at the bottom of the PDE | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,7 +35,6 @@ | |||
| 35 | 35 | ||
| 36 | 36 | import javax.swing.event.DocumentEvent; | |
| 37 | 37 | import javax.swing.event.DocumentListener; | |
| 38 | - import javax.swing.table.DefaultTableModel; | ||
| 39 | 38 | import javax.swing.text.BadLocationException; | |
| 40 | 39 | import javax.swing.text.Document; | |
| 41 | 40 | import javax.swing.text.Element; | |
@@ -919,20 +918,15 @@ protected void prepareCompilerSetting() { | |||
| 919 | 918 | */ | |
| 920 | 919 | public void updateErrorTable() { | |
| 921 | 920 | try { | |
| 922 | - String[][] errorData = new String[problemsList.size()][3]; | ||
| 923 | - int index = 0; | ||
| 921 | + XQErrorTable table = editor.getErrorTable(); | ||
| 922 | + table.clear(); | ||
| 923 | + | ||
| 924 | + // String[][] errorData = new String[problemsList.size()][3]; | ||
| 925 | + // int index = 0; | ||
| 924 | 926 | // for (int i = 0; i < problemsList.size(); i++) { | |
| 927 | + Sketch sketch = editor.getSketch(); | ||
| 925 | 928 | for (Problem p : problemsList) { | |
| 926 | - errorData[index][0] = p.getMessage(); | ||
| 927 | - errorData[index][1] = editor.getSketch().getCode(p.getTabIndex()).getPrettyName(); | ||
| 928 | - errorData[index][2] = Integer.toString(p.getLineNumber() + 1); | ||
| 929 | - // Added +1 because lineNumbers internally are 0-indexed | ||
| 930 | - | ||
| 931 | - // //TODO: This is temporary | ||
| 932 | - // if (tempErrorLog.size() < 200) { | ||
| 933 | - // tempErrorLog.put(p.getMessage(), p.getIProblem()); | ||
| 934 | - // } | ||
| 935 | - | ||
| 929 | + String message = p.getMessage(); | ||
| 936 | 930 | if (JavaMode.importSuggestEnabled) { | |
| 937 | 931 | if (p.getIProblem().getID() == IProblem.UndefinedType) { | |
| 938 | 932 | String[] args = p.getIProblem().getArguments(); | |
@@ -941,18 +935,29 @@ public void updateErrorTable() { | |||
| 941 | 935 | String[] si = astGenerator.getSuggestImports(missingClass); | |
| 942 | 936 | if (si != null && si.length > 0) { | |
| 943 | 937 | p.setImportSuggestions(si); | |
| 944 | - errorData[index][0] = "<html>" + p.getMessage() + | ||
| 945 | - " (<font color=#0000ff><u>Import Suggestions available</u></font>)</html>"; | ||
| 938 | + // errorData[index][0] = "<html>" + p.getMessage() + | ||
| 939 | + // " (<font color=#0000ff><u>Import Suggestions available</u></font>)</html>"; | ||
| 940 | + message += " (click for suggested libraries)"; | ||
| 946 | 941 | } | |
| 947 | 942 | } | |
| 948 | 943 | } | |
| 949 | 944 | } | |
| 950 | - index++; | ||
| 945 | + | ||
| 946 | + table.append(p, message, | ||
| 947 | + sketch.getCode(p.getTabIndex()).getPrettyName(), | ||
| 948 | + Integer.toString(p.getLineNumber() + 1)); | ||
| 949 | + // Added +1 because lineNumbers internally are 0-indexed | ||
| 950 | + | ||
| 951 | + // //TODO: This is temporary | ||
| 952 | + // if (tempErrorLog.size() < 200) { | ||
| 953 | + // tempErrorLog.put(p.getMessage(), p.getIProblem()); | ||
| 954 | + // } | ||
| 955 | + | ||
| 951 | 956 | } | |
| 952 | 957 | ||
| 953 | - DefaultTableModel tm = | ||
| 954 | - new DefaultTableModel(errorData, XQErrorTable.columnNames); | ||
| 955 | - editor.updateTable(tm); | ||
| 958 | + // DefaultTableModel tm = | ||
| 959 | + // new DefaultTableModel(errorData, XQErrorTable.columnNames); | ||
| 960 | + // editor.updateTable(tm); | ||
| 956 | 961 | ||
| 957 | 962 | } catch (Exception e) { | |
| 958 | 963 | Messages.loge("Exception at updateErrorTable()", e); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments