[Pydev-cvs] org.python.pydev.refactoring/src/org/python/pydev/refactoring/ui/pages/listener IValid
Brought to you by:
fabioz
Update of /cvsroot/pydev/org.python.pydev.refactoring/src/org/python/pydev/refactoring/ui/pages/listener In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21605/src/org/python/pydev/refactoring/ui/pages/listener Modified Files: IValidationPage.java FunctionSignatureListener.java TableCellEditorListener.java ButtonActivationListener.java Log Message: Synching to latest changes: Pydev <ul> <li><strong>Editor</strong>: Cursor settings no longer overridden</li> <li><strong>Code-completion</strong>: If __all__ is defined with runtime elements (and not only in a single assign statement), it's ignored for code-completion purposes</li> <li><strong>Debugger</strong>: Pythonpath the same in debug and regular modes (sys.path[0] is the same directory as the file run)</li> <li><strong>Debugger</strong>: Persist choices done in the debugger when files from the debugger are not found</li> <li><strong>Interpreter config</strong>: "email" automatically added to the "forced builtins"</li> <li><strong>Parser</strong>: Correctly recognizing absolute import with 3 or more levels</li> <li><strong>Syntax check</strong>: Option to do only on active editor</li> </ul> Also: tabs changed for spaces Index: ButtonActivationListener.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.refactoring/src/org/python/pydev/refactoring/ui/pages/listener/ButtonActivationListener.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ButtonActivationListener.java 20 Oct 2007 19:31:02 -0000 1.3 --- ButtonActivationListener.java 27 Sep 2008 20:00:49 -0000 1.4 *************** *** 15,53 **** public class ButtonActivationListener implements Listener { ! private Table table; ! private Button upButton; ! private Button downButton; ! private Button editButton; ! public ButtonActivationListener(Table table, Button upButton, Button downButton, Button editButton) { ! this.table = table; ! this.upButton = upButton; ! this.downButton = downButton; ! this.editButton = editButton; ! } ! public void handleEvent(Event event) { ! updateButtonState(); ! } ! private void updateButtonState() { ! editButton.setEnabled(false); ! upButton.setEnabled(true); ! downButton.setEnabled(true); ! if (table.getSelectionCount() == 1) { ! editButton.setEnabled(true); ! if (table.getSelectionIndex() == table.getItemCount() - 1) { ! downButton.setEnabled(false); ! } ! if (table.getSelectionIndex() == 0) { ! upButton.setEnabled(false); ! } ! } ! } } --- 15,53 ---- public class ButtonActivationListener implements Listener { ! private Table table; ! private Button upButton; ! private Button downButton; ! private Button editButton; ! public ButtonActivationListener(Table table, Button upButton, Button downButton, Button editButton) { ! this.table = table; ! this.upButton = upButton; ! this.downButton = downButton; ! this.editButton = editButton; ! } ! public void handleEvent(Event event) { ! updateButtonState(); ! } ! private void updateButtonState() { ! editButton.setEnabled(false); ! upButton.setEnabled(true); ! downButton.setEnabled(true); ! if (table.getSelectionCount() == 1) { ! editButton.setEnabled(true); ! if (table.getSelectionIndex() == table.getItemCount() - 1) { ! downButton.setEnabled(false); ! } ! if (table.getSelectionIndex() == 0) { ! upButton.setEnabled(false); ! } ! } ! } } Index: IValidationPage.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.refactoring/src/org/python/pydev/refactoring/ui/pages/listener/IValidationPage.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** IValidationPage.java 20 Oct 2007 19:31:02 -0000 1.2 --- IValidationPage.java 27 Sep 2008 20:00:49 -0000 1.3 *************** *** 13,18 **** public interface IValidationPage extends IWizardPage, Listener { ! public void setErrorMessage(String error); ! public void validate(); } --- 13,18 ---- public interface IValidationPage extends IWizardPage, Listener { ! public void setErrorMessage(String error); ! public void validate(); } Index: FunctionSignatureListener.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.refactoring/src/org/python/pydev/refactoring/ui/pages/listener/FunctionSignatureListener.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** FunctionSignatureListener.java 20 Oct 2007 19:31:02 -0000 1.3 --- FunctionSignatureListener.java 27 Sep 2008 20:00:49 -0000 1.4 *************** *** 22,82 **** public class FunctionSignatureListener implements Listener { ! private final String METHODDEF = "def "; ! private final String OPENBRACKET = "("; ! private final String CLOSEBRACKET = ")"; ! private Table argumentTable; ! private Label signatureLabel; ! private LabeledEdit functionNameEdit; ! private IValidationPage page; ! public FunctionSignatureListener(IValidationPage page, Label signature, LabeledEdit functionNameEdit, Table argumentTable) { ! this.page = page; ! this.signatureLabel = signature; ! this.functionNameEdit = functionNameEdit; ! this.argumentTable = argumentTable; ! } ! private void updateSignature() { ! if (functionNameEdit.getEdit().getText().length() == 0) { ! return; ! } ! StringBuilder signature = new StringBuilder(); ! signature.append(METHODDEF); ! signature.append(this.functionNameEdit.getEdit().getText()); ! signature.append(OPENBRACKET); ! initArguments(signature); ! signature.append(CLOSEBRACKET); ! signatureLabel.setText(signature.toString()); ! } ! private void initArguments(StringBuilder signature) { ! if (this.argumentTable != null) { ! List<TableItem> items = Arrays.asList(argumentTable.getItems()); ! Iterator<TableItem> iter = items.iterator(); ! while (iter.hasNext()) { ! TableItem item = iter.next(); ! if (item instanceof SimpleTableItem) { ! signature.append(item.getText()); ! if (iter.hasNext()) ! signature.append(", "); ! } ! } ! } ! } ! public void handleEvent(Event event) { ! if (page.isPageComplete()) { ! updateSignature(); ! } ! } } --- 22,82 ---- public class FunctionSignatureListener implements Listener { ! private final String METHODDEF = "def "; ! private final String OPENBRACKET = "("; ! private final String CLOSEBRACKET = ")"; ! private Table argumentTable; ! private Label signatureLabel; ! private LabeledEdit functionNameEdit; ! private IValidationPage page; ! public FunctionSignatureListener(IValidationPage page, Label signature, LabeledEdit functionNameEdit, Table argumentTable) { ! this.page = page; ! this.signatureLabel = signature; ! this.functionNameEdit = functionNameEdit; ! this.argumentTable = argumentTable; ! } ! private void updateSignature() { ! if (functionNameEdit.getEdit().getText().length() == 0) { ! return; ! } ! StringBuilder signature = new StringBuilder(); ! signature.append(METHODDEF); ! signature.append(this.functionNameEdit.getEdit().getText()); ! signature.append(OPENBRACKET); ! initArguments(signature); ! signature.append(CLOSEBRACKET); ! signatureLabel.setText(signature.toString()); ! } ! private void initArguments(StringBuilder signature) { ! if (this.argumentTable != null) { ! List<TableItem> items = Arrays.asList(argumentTable.getItems()); ! Iterator<TableItem> iter = items.iterator(); ! while (iter.hasNext()) { ! TableItem item = iter.next(); ! if (item instanceof SimpleTableItem) { ! signature.append(item.getText()); ! if (iter.hasNext()) ! signature.append(", "); ! } ! } ! } ! } ! public void handleEvent(Event event) { ! if (page.isPageComplete()) { ! updateSignature(); ! } ! } } Index: TableCellEditorListener.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.refactoring/src/org/python/pydev/refactoring/ui/pages/listener/TableCellEditorListener.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TableCellEditorListener.java 20 Oct 2007 19:31:02 -0000 1.3 --- TableCellEditorListener.java 27 Sep 2008 20:00:49 -0000 1.4 *************** *** 22,106 **** public class TableCellEditorListener extends Observable implements Listener { ! private final Table table; ! private IValidationPage wizard; ! public TableCellEditorListener(IValidationPage wizard, Table parametersTable) { ! this.wizard = wizard; ! this.table = parametersTable; ! } ! /** ! * http://www.eclipse.org/swt/snippets/ ! */ ! public void handleEvent(Event event) { ! final TableEditor editor = new TableEditor(table); ! editor.horizontalAlignment = SWT.LEFT; ! editor.grabHorizontal = true; ! Rectangle clientArea = table.getClientArea(); ! if (table.getSelection().length != 1) ! return; ! Rectangle bounds = table.getSelection()[0].getBounds(); ! Point pt = new Point(bounds.x, bounds.y); ! int index = table.getTopIndex(); ! while (index < table.getItemCount()) { ! boolean visible = false; ! final SimpleTableItem item = (SimpleTableItem) table.getItem(index); ! for (int i = 0; i < table.getColumnCount(); i++) { ! Rectangle rect = item.getBounds(i); ! if (rect.contains(pt)) { ! final Text text = new Text(table, SWT.NONE); ! Listener textListener = new TextListener(item, text); ! text.addListener(SWT.FocusOut, textListener); ! text.addListener(SWT.Traverse, textListener); ! text.addListener(SWT.FocusOut, wizard); ! editor.setEditor(text, item, i); ! text.setText(item.getText(i)); ! text.selectAll(); ! text.setFocus(); ! return; ! } ! if (!visible && rect.intersects(clientArea)) { ! visible = true; ! } ! } ! if (!visible) { ! return; ! } ! index++; ! } ! } ! private final class TextListener implements Listener { ! private SimpleTableItem tableItem; ! private final Text text; ! private TextListener(SimpleTableItem item, Text text) { ! this.tableItem = item; ! this.text = text; ! } ! public void handleEvent(final Event e) { ! if (e.type == SWT.FocusOut) { ! tableItem.setText(text.getText()); ! text.dispose(); ! table.setFocus(); ! } else if (e.type == SWT.Traverse) { ! if (e.detail == SWT.TRAVERSE_RETURN) { ! tableItem.setText(text.getText()); ! e.doit = true; ! } ! if (e.detail == SWT.TRAVERSE_RETURN || e.detail == SWT.TRAVERSE_ESCAPE) { ! text.dispose(); ! if (e.detail == SWT.TRAVERSE_ESCAPE) ! e.doit = false; ! } ! } ! } ! } } --- 22,106 ---- public class TableCellEditorListener extends Observable implements Listener { ! private final Table table; ! private IValidationPage wizard; ! public TableCellEditorListener(IValidationPage wizard, Table parametersTable) { ! this.wizard = wizard; ! this.table = parametersTable; ! } ! /** ! * http://www.eclipse.org/swt/snippets/ ! */ ! public void handleEvent(Event event) { ! final TableEditor editor = new TableEditor(table); ! editor.horizontalAlignment = SWT.LEFT; ! editor.grabHorizontal = true; ! Rectangle clientArea = table.getClientArea(); ! if (table.getSelection().length != 1) ! return; ! Rectangle bounds = table.getSelection()[0].getBounds(); ! Point pt = new Point(bounds.x, bounds.y); ! int index = table.getTopIndex(); ! while (index < table.getItemCount()) { ! boolean visible = false; ! final SimpleTableItem item = (SimpleTableItem) table.getItem(index); ! for (int i = 0; i < table.getColumnCount(); i++) { ! Rectangle rect = item.getBounds(i); ! if (rect.contains(pt)) { ! final Text text = new Text(table, SWT.NONE); ! Listener textListener = new TextListener(item, text); ! text.addListener(SWT.FocusOut, textListener); ! text.addListener(SWT.Traverse, textListener); ! text.addListener(SWT.FocusOut, wizard); ! editor.setEditor(text, item, i); ! text.setText(item.getText(i)); ! text.selectAll(); ! text.setFocus(); ! return; ! } ! if (!visible && rect.intersects(clientArea)) { ! visible = true; ! } ! } ! if (!visible) { ! return; ! } ! index++; ! } ! } ! private final class TextListener implements Listener { ! private SimpleTableItem tableItem; ! private final Text text; ! private TextListener(SimpleTableItem item, Text text) { ! this.tableItem = item; ! this.text = text; ! } ! public void handleEvent(final Event e) { ! if (e.type == SWT.FocusOut) { ! tableItem.setText(text.getText()); ! text.dispose(); ! table.setFocus(); ! } else if (e.type == SWT.Traverse) { ! if (e.detail == SWT.TRAVERSE_RETURN) { ! tableItem.setText(text.getText()); ! e.doit = true; ! } ! if (e.detail == SWT.TRAVERSE_RETURN || e.detail == SWT.TRAVERSE_ESCAPE) { ! text.dispose(); ! if (e.detail == SWT.TRAVERSE_ESCAPE) ! e.doit = false; ! } ! } ! } ! } } |