mirror of
https://github.com/processing/processing4.git
synced 2026-02-13 18:35:37 +01:00
further work on cc
This commit is contained in:
@@ -9,9 +9,7 @@ import java.awt.event.MouseEvent;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.text.BadLocationException;
|
||||
|
||||
import processing.app.syntax.JEditTextArea;
|
||||
@@ -25,11 +23,11 @@ public class CompletionPanel {
|
||||
|
||||
private final int insertionPosition;
|
||||
|
||||
private JEditTextArea textarea;
|
||||
private TextArea textarea;
|
||||
|
||||
public CompletionPanel(JEditTextArea textarea, int position, String subWord,
|
||||
String[] items, Point location) {
|
||||
this.textarea = textarea;
|
||||
CompletionCandidate[] items, Point location) {
|
||||
this.textarea = (TextArea) textarea;
|
||||
this.insertionPosition = position;
|
||||
if (subWord.indexOf('.') != -1)
|
||||
this.subWord = subWord.substring(subWord.lastIndexOf('.') + 1);
|
||||
@@ -43,6 +41,8 @@ public class CompletionPanel {
|
||||
BorderLayout.CENTER);
|
||||
popupMenu.show(textarea, location.x, textarea.getBaseline(0, 0)
|
||||
+ location.y);
|
||||
this.textarea.errorCheckerService.astGenerator.updateJavaDoc((CompletionCandidate) list
|
||||
.getSelectedValue());
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
@@ -53,27 +53,7 @@ public class CompletionPanel {
|
||||
return popupMenu.isVisible();
|
||||
}
|
||||
|
||||
// private JList createSuggestionList(final int position, final String subWord) {
|
||||
// Object[] data = new Object[10];
|
||||
// for (int i = 0; i < data.length; i++) {
|
||||
// data[i] = subWord + i * 10;
|
||||
// }
|
||||
// JList list = new JList(data);
|
||||
// list.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1));
|
||||
// list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
// list.setSelectedIndex(0);
|
||||
// list.addMouseListener(new MouseAdapter() {
|
||||
// @Override
|
||||
// public void mouseClicked(MouseEvent e) {
|
||||
// if (e.getClickCount() == 2) {
|
||||
// insertSelection();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// return list;
|
||||
// }
|
||||
|
||||
public JList createSuggestionList(final int position, final String[] items) {
|
||||
public JList createSuggestionList(final int position, final CompletionCandidate[] items) {
|
||||
|
||||
JList list = new JList(items);
|
||||
list.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1));
|
||||
@@ -84,6 +64,7 @@ public class CompletionPanel {
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if (e.getClickCount() == 2) {
|
||||
insertSelection();
|
||||
hideSuggestion();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -93,7 +74,7 @@ public class CompletionPanel {
|
||||
public boolean insertSelection() {
|
||||
if (list.getSelectedValue() != null) {
|
||||
try {
|
||||
final String selectedSuggestion = ((String) list.getSelectedValue())
|
||||
final String selectedSuggestion = ((CompletionCandidate) list.getSelectedValue()).toString()
|
||||
.substring(subWord.length());
|
||||
textarea.getDocument().insertString(insertionPosition,
|
||||
selectedSuggestion, null);
|
||||
@@ -119,6 +100,9 @@ public class CompletionPanel {
|
||||
int index = Math.max(list.getSelectedIndex() - 1, 0);
|
||||
selectIndex(index);
|
||||
}
|
||||
textarea.errorCheckerService.astGenerator.updateJavaDoc((CompletionCandidate) list
|
||||
.getSelectedValue());
|
||||
|
||||
}
|
||||
|
||||
public void moveDown() {
|
||||
@@ -129,6 +113,8 @@ public class CompletionPanel {
|
||||
.getSize() - 1);
|
||||
selectIndex(index);
|
||||
}
|
||||
textarea.errorCheckerService.astGenerator.updateJavaDoc((CompletionCandidate) list
|
||||
.getSelectedValue());
|
||||
}
|
||||
|
||||
private void selectIndex(int index) {
|
||||
|
||||
Reference in New Issue
Block a user