|
From: <cal...@us...> - 2007-02-21 10:04:56
|
Revision: 1989
http://svn.sourceforge.net/rubyeclipse/?rev=1989&view=rev
Author: callandor1983
Date: 2007-02-21 02:04:53 -0800 (Wed, 21 Feb 2007)
Log Message:
-----------
Candidates at end of document can now be selected on a OccurenceReplaceSelectionPage.
Modified Paths:
--------------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamefield/RenameFieldRefactoring.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemethod/RenameMethodRefactoring.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/RdtCodeViewer.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/OccurenceReplaceSelectionPage.java
Removed Paths:
-------------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/CallReplaceSelectionPage.java
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamefield/RenameFieldRefactoring.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamefield/RenameFieldRefactoring.java 2007-02-20 16:25:36 UTC (rev 1988)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamefield/RenameFieldRefactoring.java 2007-02-21 10:04:53 UTC (rev 1989)
@@ -35,7 +35,7 @@
import org.rubypeople.rdt.refactoring.documentprovider.DocumentWithIncluding;
import org.rubypeople.rdt.refactoring.ui.IValidator;
import org.rubypeople.rdt.refactoring.ui.NewNameListener;
-import org.rubypeople.rdt.refactoring.ui.pages.CallReplaceSelectionPage;
+import org.rubypeople.rdt.refactoring.ui.pages.OccurenceReplaceSelectionPage;
import org.rubypeople.rdt.refactoring.ui.pages.RenameFieldPage;
import org.rubypeople.rdt.refactoring.util.NameValidator;
@@ -53,7 +53,7 @@
private FieldRenamer renamer;
private NewNameListener nameListener;
private RenameFieldPage pageOne;
- private CallReplaceSelectionPage page;
+ private OccurenceReplaceSelectionPage page;
public RenameFieldRefactoring(TextSelectionProvider selectionProvider) {
super(NAME);
@@ -70,7 +70,7 @@
pageOne = new RenameFieldPage(config.getSelectedName().replaceAll("@", ""), nameListener, config);
pages.add(pageOne);
- page = new CallReplaceSelectionPage(config, config.getDocProvider());
+ page = new OccurenceReplaceSelectionPage(config, config.getDocProvider());
pages.add(page);
}
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemethod/RenameMethodRefactoring.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemethod/RenameMethodRefactoring.java 2007-02-20 16:25:36 UTC (rev 1988)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemethod/RenameMethodRefactoring.java 2007-02-21 10:04:53 UTC (rev 1989)
@@ -34,7 +34,7 @@
import org.rubypeople.rdt.refactoring.core.TextSelectionProvider;
import org.rubypeople.rdt.refactoring.ui.IValidator;
import org.rubypeople.rdt.refactoring.ui.NewNameListener;
-import org.rubypeople.rdt.refactoring.ui.pages.CallReplaceSelectionPage;
+import org.rubypeople.rdt.refactoring.ui.pages.OccurenceReplaceSelectionPage;
import org.rubypeople.rdt.refactoring.ui.pages.RenamePage;
import org.rubypeople.rdt.refactoring.util.NameValidator;
@@ -64,7 +64,7 @@
RenamePage page = new RenamePage(NAME + "...", config.getTargetMethod().getName(), nameListener);
pages.add(page);
if(!config.getPossibleCalls().isEmpty()){
- pages.add(new CallReplaceSelectionPage(config, config.getDocProvider()));
+ pages.add(new OccurenceReplaceSelectionPage(config, config.getDocProvider()));
}
}
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/RdtCodeViewer.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/RdtCodeViewer.java 2007-02-20 16:25:36 UTC (rev 1988)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/RdtCodeViewer.java 2007-02-21 10:04:53 UTC (rev 1989)
@@ -71,7 +71,7 @@
public void setBackgroundColor(int start, int length, Color color) {
StyleRange styleRangeNode = new StyleRange();
styleRangeNode.start = start;
- styleRangeNode.length = length + 1;
+ styleRangeNode.length = length;
styleRangeNode.background = color;
getTextWidget().setStyleRange(styleRangeNode);
}
Deleted: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/CallReplaceSelectionPage.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/CallReplaceSelectionPage.java 2007-02-20 16:25:36 UTC (rev 1988)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/CallReplaceSelectionPage.java 2007-02-21 10:04:53 UTC (rev 1989)
@@ -1,148 +0,0 @@
-/***** BEGIN LICENSE BLOCK *****
- * Version: CPL 1.0/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Common Public
- * License Version 1.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.eclipse.org/legal/cpl-v10.html
- *
- * Software distributed under the License is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * rights and limitations under the License.
- *
- * Copyright (C) 2006 Lukas Felber <lf...@hs...>
- * Copyright (C) 2006 Mirko Stocker <me...@mi...>
- * Copyright (C) 2006 Thomas Corbat <tc...@hs...>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the CPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the CPL, the GPL or the LGPL.
- ***** END LICENSE BLOCK *****/
-
-package org.rubypeople.rdt.refactoring.ui.pages;
-
-import java.util.ArrayList;
-
-import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-import org.jruby.lexer.yacc.ISourcePosition;
-import org.rubypeople.rdt.refactoring.JRubyRefactoringUtils;
-import org.rubypeople.rdt.refactoring.core.renamemethod.NodeSelector;
-import org.rubypeople.rdt.refactoring.documentprovider.DocumentProvider;
-import org.rubypeople.rdt.refactoring.nodewrapper.INodeWrapper;
-import org.rubypeople.rdt.refactoring.ui.RdtCodeViewer;
-
-public class CallReplaceSelectionPage extends UserInputWizardPage {
-
- public static final String NAME = "Select Calls...";
- private final static RGB highlightColor = new RGB(173, 193, 217);
-
- private NodeSelector selector;
- private Table possibilityTable;
- private DocumentProvider docProvider;
-
-
- public CallReplaceSelectionPage(NodeSelector selector, DocumentProvider docProvider) {
- super(NAME);
- this.selector = selector;
- this.docProvider = docProvider;
- }
-
- public void createControl(Composite parent) {
-
- Composite control = new Composite(parent, SWT.NONE);
- FillLayout controlLayout = new FillLayout();
- controlLayout.spacing = 10;
- controlLayout.marginHeight = 10;
- controlLayout.marginWidth = 10;
- control.setLayout(controlLayout);
- initPossibilityTable(control);
- initCodeView(control);
- setControl(control);
- }
-
- private void initCodeView(Composite control) {
- final RdtCodeViewer viewer = RdtCodeViewer.create(control);
- possibilityTable.addSelectionListener(new SelectionListener(){
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- public void widgetSelected(SelectionEvent e) {
- INodeWrapper currentCall = (INodeWrapper) e.item.getData();
- ISourcePosition pos = currentCall.getWrappedNode().getPosition();
- int length = pos.getEndOffset() - pos.getStartOffset();
- String file = docProvider.getFileContent(currentCall.getWrappedNode().getPosition().getFile());
- updateCodeViewer(viewer, pos, length, file);
-
- updateChecks();
- }
-
- private void updateCodeViewer(final RdtCodeViewer viewer, ISourcePosition pos, int length, String content) {
- viewer.setPreviewText(content);
- viewer.setBackgroundColor(pos.getStartOffset(), length, highlightColor);
- viewer.getTextWidget().setSelection(pos.getStartOffset());
- viewer.getTextWidget().showSelection();
- }
-
- private void updateChecks() {
- ArrayList<INodeWrapper> checkedCalls = new ArrayList<INodeWrapper>();
- for(TableItem currentItem : possibilityTable.getItems()){
- if(currentItem.getChecked()){
- checkedCalls.add((INodeWrapper) currentItem.getData());
- }
- }
- selector.setSelectedCalls(checkedCalls);
- }
- });
- }
-
- private void initPossibilityTable(Composite control) {
- possibilityTable = new Table(control, SWT.BORDER | SWT.CHECK);
- for(INodeWrapper currentCall : selector.getPossibleCalls()){
- TableItem currentItem = new TableItem(possibilityTable, SWT.NONE);
- currentItem.setText(getTableCaption(currentCall));
- if(proableCall(currentCall)){
- currentItem.setChecked(true);
- }
- currentItem.setData(currentCall);
- }
- }
-
- private String getTableCaption(INodeWrapper currentCall) {
- ISourcePosition pos = currentCall.getWrappedNode().getPosition();
- return pos.getFile() + " line: " + (pos.getStartLine() + 1) ;
- }
-
- private boolean proableCall(INodeWrapper currentCall) {
-
- for(INodeWrapper targetCall : selector.getSelectedCalls()){
- if(hasSamePosition(currentCall, targetCall)){
- return true;
- }
- }
- return false;
- }
-
- private boolean hasSamePosition(INodeWrapper currentCall, INodeWrapper targetCall) {
- return JRubyRefactoringUtils.hasSamePosition(currentCall.getWrappedNode(), targetCall.getWrappedNode());
- }
-
-
-}
Copied: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/OccurenceReplaceSelectionPage.java (from rev 1988, trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/CallReplaceSelectionPage.java)
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/OccurenceReplaceSelectionPage.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/OccurenceReplaceSelectionPage.java 2007-02-21 10:04:53 UTC (rev 1989)
@@ -0,0 +1,148 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Copyright (C) 2006 Lukas Felber <lf...@hs...>
+ * Copyright (C) 2006 Mirko Stocker <me...@mi...>
+ * Copyright (C) 2006 Thomas Corbat <tc...@hs...>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+
+package org.rubypeople.rdt.refactoring.ui.pages;
+
+import java.util.ArrayList;
+
+import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.jruby.lexer.yacc.ISourcePosition;
+import org.rubypeople.rdt.refactoring.JRubyRefactoringUtils;
+import org.rubypeople.rdt.refactoring.core.renamemethod.NodeSelector;
+import org.rubypeople.rdt.refactoring.documentprovider.DocumentProvider;
+import org.rubypeople.rdt.refactoring.nodewrapper.INodeWrapper;
+import org.rubypeople.rdt.refactoring.ui.RdtCodeViewer;
+
+public class OccurenceReplaceSelectionPage extends UserInputWizardPage {
+
+ public static final String NAME = "Select Calls...";
+ private final static RGB highlightColor = new RGB(173, 193, 217);
+
+ private NodeSelector selector;
+ private Table possibilityTable;
+ private DocumentProvider docProvider;
+
+
+ public OccurenceReplaceSelectionPage(NodeSelector selector, DocumentProvider docProvider) {
+ super(NAME);
+ this.selector = selector;
+ this.docProvider = docProvider;
+ }
+
+ public void createControl(Composite parent) {
+
+ Composite control = new Composite(parent, SWT.NONE);
+ FillLayout controlLayout = new FillLayout();
+ controlLayout.spacing = 10;
+ controlLayout.marginHeight = 10;
+ controlLayout.marginWidth = 10;
+ control.setLayout(controlLayout);
+ initPossibilityTable(control);
+ initCodeView(control);
+ setControl(control);
+ }
+
+ private void initCodeView(Composite control) {
+ final RdtCodeViewer viewer = RdtCodeViewer.create(control);
+ possibilityTable.addSelectionListener(new SelectionListener(){
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ INodeWrapper currentCall = (INodeWrapper) e.item.getData();
+ ISourcePosition pos = currentCall.getWrappedNode().getPosition();
+ String file = docProvider.getFileContent(currentCall.getWrappedNode().getPosition().getFile());
+ updateCodeViewer(viewer, pos, file);
+
+ updateChecks();
+ }
+
+ private void updateCodeViewer(final RdtCodeViewer viewer, ISourcePosition pos, String content) {
+ int length = pos.getEndOffset() - pos.getStartOffset();
+ viewer.setPreviewText(content);
+ viewer.setBackgroundColor(pos.getStartOffset(), length, highlightColor);
+ viewer.getTextWidget().setSelection(pos.getStartOffset());
+ viewer.getTextWidget().showSelection();
+ }
+
+ private void updateChecks() {
+ ArrayList<INodeWrapper> checkedCalls = new ArrayList<INodeWrapper>();
+ for(TableItem currentItem : possibilityTable.getItems()){
+ if(currentItem.getChecked()){
+ checkedCalls.add((INodeWrapper) currentItem.getData());
+ }
+ }
+ selector.setSelectedCalls(checkedCalls);
+ }
+ });
+ }
+
+ private void initPossibilityTable(Composite control) {
+ possibilityTable = new Table(control, SWT.BORDER | SWT.CHECK);
+ for(INodeWrapper currentCall : selector.getPossibleCalls()){
+ TableItem currentItem = new TableItem(possibilityTable, SWT.NONE);
+ currentItem.setText(getTableCaption(currentCall));
+ if(proableCall(currentCall)){
+ currentItem.setChecked(true);
+ }
+ currentItem.setData(currentCall);
+ }
+ }
+
+ private String getTableCaption(INodeWrapper currentCall) {
+ ISourcePosition pos = currentCall.getWrappedNode().getPosition();
+ return pos.getFile() + " line: " + (pos.getStartLine() + 1) ;
+ }
+
+ private boolean proableCall(INodeWrapper currentCall) {
+
+ for(INodeWrapper targetCall : selector.getSelectedCalls()){
+ if(hasSamePosition(currentCall, targetCall)){
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean hasSamePosition(INodeWrapper currentCall, INodeWrapper targetCall) {
+ return JRubyRefactoringUtils.hasSamePosition(currentCall.getWrappedNode(), targetCall.getWrappedNode());
+ }
+
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|