diff --git a/pdex/Todo, GSoC 2013.txt b/pdex/Todo, GSoC 2013.txt index a156e43cb..754eb4b3a 100644 --- a/pdex/Todo, GSoC 2013.txt +++ b/pdex/Todo, GSoC 2013.txt @@ -50,6 +50,8 @@ x Edge Case: Need to take displaced offsets on a line, due to pde enhancements, 4. All the changes in code would be made in a separate copy of the code(?). After all the renaming is done, allow it only if the new code compiles. Basically an undo should be possible in case of conflicts. * Undo misbehaves here, handle carefully. * Handle saving. If sketch closed after renaming w/o saving find bugs. +* Refactoring ui +* Add support for word select on right click and rename, mouse co-ordinates need to obtained carefully Quick Navigation ================ diff --git a/pdex/src/processing/mode/experimental/ASTGenerator.java b/pdex/src/processing/mode/experimental/ASTGenerator.java index cd79906e7..b4ebb3413 100644 --- a/pdex/src/processing/mode/experimental/ASTGenerator.java +++ b/pdex/src/processing/mode/experimental/ASTGenerator.java @@ -115,6 +115,8 @@ public class ASTGenerator { private JEditorPane javadocPane; private JScrollPane scrollPane; + + private JFrame renameWindow; private JButton renameButton; @@ -136,16 +138,16 @@ public class ASTGenerator { renameButton = new JButton("Rename"); listOccurrence = new JButton("Find All"); - JFrame frame3 = new JFrame(); - frame3.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - frame3.setBounds(new Rectangle(680, 50, 150, 150)); - frame3.setLayout(new GridLayout(3, 1)); - frame3.add(renameButton); - frame3.add(listOccurrence); + renameWindow = new JFrame(); + renameWindow.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + renameWindow.setBounds(new Rectangle(680, 50, 150, 150)); + renameWindow.setLayout(new GridLayout(3, 1)); + renameWindow.add(renameButton); + renameWindow.add(listOccurrence); renameTextField = new JTextField(); renameTextField.setPreferredSize(new Dimension(150, 60)); - frame3.add(renameTextField); - frame3.setVisible(true); + renameWindow.add(renameTextField); + renameWindow.setVisible(true); JFrame frame4 = new JFrame(); frame4.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); @@ -1550,6 +1552,11 @@ public class ASTGenerator { return false; } + public void handleRefactor(){ + if (!renameWindow.isVisible()) + renameWindow.setVisible(true); + renameWindow.toFront(); + } public static void printRecur(ASTNode node) { diff --git a/pdex/src/processing/mode/experimental/DebugEditor.java b/pdex/src/processing/mode/experimental/DebugEditor.java index 268720017..099e90d1a 100755 --- a/pdex/src/processing/mode/experimental/DebugEditor.java +++ b/pdex/src/processing/mode/experimental/DebugEditor.java @@ -25,6 +25,8 @@ import java.awt.Frame; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -153,7 +155,21 @@ public class DebugEditor extends JavaEditor implements ActionListener { // access to customized (i.e. subclassed) text area ta = (TextArea) textarea; - + + // add refactor option + JMenuItem renameItem = new JMenuItem("Rename.."); + renameItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + handleRefactor(); + } + }); + // TODO: Add support for word select on right click and rename. +// ta.customPainter.addMouseListener(new MouseAdapter() { +// public void mouseClicked(MouseEvent evt) { +// System.out.println(evt); +// } +// }); + ta.getRightClickPopup().add(renameItem); // set action on frame close // addWindowListener(new WindowAdapter() { // @Override @@ -1122,6 +1138,12 @@ public class DebugEditor extends JavaEditor implements ActionListener { return errorTable.updateTable(tableModel); } + private void handleRefactor() { + System.out.println("Caret at:"); + System.out.println(ta.getLineText(ta.getCaretLine())); + errorCheckerService.astGenerator.handleRefactor(); + } + /** * Checks if the sketch contains java tabs. If it does, XQMode ain't built * for it, yet. Also, user should really start looking at Eclipse. Disable