|
From: David C. <dc...@us...> - 2005-11-18 21:56:22
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3016/src/org/rubypeople/rdt/testunit/views Modified Files: OpenClassAction.java FailureTab.java Added Files: OpenLocationAction.java Log Message: Handle multiple class definitions when opening Class. Index: OpenClassAction.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/OpenClassAction.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OpenClassAction.java 13 Oct 2005 01:00:27 -0000 1.1 --- OpenClassAction.java 18 Nov 2005 21:56:10 -0000 1.2 *************** *** 3,11 **** --- 3,19 ---- import java.util.Set; + import org.eclipse.core.resources.IFile; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; + import org.eclipse.jface.viewers.ILabelProvider; + import org.eclipse.jface.viewers.ILabelProviderListener; + import org.eclipse.swt.SWT; + import org.eclipse.swt.graphics.Image; + import org.eclipse.swt.widgets.Shell; import org.rubypeople.rdt.internal.core.symbols.ClassSymbol; import org.rubypeople.rdt.internal.core.symbols.Location; import org.rubypeople.rdt.internal.core.symbols.SymbolIndex; + import org.rubypeople.rdt.internal.ui.RubyPluginImages; + import org.rubypeople.rdt.internal.ui.dialogs.ElementListSelectionDialog; import org.rubypeople.rdt.internal.ui.util.PositionBasedEditorOpener; *************** *** 13,21 **** public class OpenClassAction extends Action implements IAction { private final String className; private final SymbolIndex index; ! public OpenClassAction(String className, SymbolIndex index) { super(TestUnitMessages.getString("OpenEditor.action.label")); this.className = className; this.index = index; --- 21,32 ---- public class OpenClassAction extends Action implements IAction { + private final String className; private final SymbolIndex index; + private final Shell shell; ! public OpenClassAction(Shell shell, String className, SymbolIndex index) { super(TestUnitMessages.getString("OpenEditor.action.label")); + this.shell = shell; this.className = className; this.index = index; *************** *** 24,35 **** public void run() { Set locations = index.find(new ClassSymbol(className)); if (locations.size() == 1) { ! Location location = (Location) locations.iterator().next(); ! new PositionBasedEditorOpener(location.getFilename(), location.getPosition()).open(); } else { ! System.out.println("Too many locations"); // DSC temporary } } } --- 35,85 ---- public void run() { Set locations = index.find(new ClassSymbol(className)); + Location location; if (locations.size() == 1) { ! location = (Location) locations.iterator().next(); } else { ! ElementListSelectionDialog selectionDialog ! = new ElementListSelectionDialog(shell, new LocationLabel()); ! selectionDialog.setElements(locations.toArray()); ! selectionDialog.setMessage("Select a location"); ! selectionDialog.setTitle("Open Class"); ! selectionDialog.open(); ! if (selectionDialog.getReturnCode() == SWT.CANCEL) ! return; ! location= (Location) selectionDialog.getResult()[0]; } + PositionBasedEditorOpener editorOpener + = new PositionBasedEditorOpener(location.getFilename(), + location.getPosition()); + editorOpener.open(); } + private final class LocationLabel implements ILabelProvider { + public Image getImage(Object element) { + return RubyPluginImages.get(RubyPluginImages.IMG_CTOOLS_RUBY_PAGE); + } + + public String getText(Object element) { + Location location = (Location) element; + IFile sourceFile = location.getSourceFile(); + return sourceFile.getName() + " - " + sourceFile.getFullPath().removeLastSegments(1); + } + + public void addListener(ILabelProviderListener listener) { + } + + public void dispose() { + } + + public boolean isLabelProperty(Object element, String property) { + // TODO Auto-generated method stub + return false; + } + + public void removeListener(ILabelProviderListener listener) { + // TODO Auto-generated method stub + + } + } } --- NEW FILE: OpenLocationAction.java --- package org.rubypeople.rdt.testunit.views; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.rubypeople.rdt.internal.core.symbols.Location; import org.rubypeople.rdt.internal.ui.util.PositionBasedEditorOpener; public class OpenLocationAction extends Action implements IAction { private final Location location; public OpenLocationAction(Location location) { super(location.getFilename()); this.location = location; } public void run() { new PositionBasedEditorOpener(location.getFilename(), location.getPosition()).open(); } } Index: FailureTab.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/FailureTab.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** FailureTab.java 13 Oct 2005 01:00:27 -0000 1.6 --- FailureTab.java 18 Nov 2005 21:56:10 -0000 1.7 *************** *** 35,38 **** --- 35,39 ---- import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Menu; + import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableItem; *************** *** 53,56 **** --- 54,58 ---- private final Image fFailureIcon = TestUnitView.createImage("obj16/testfail.gif"); //$NON-NLS-1$ private final Image fFailureTabIcon = TestUnitView.createImage("obj16/failures.gif"); //$NON-NLS-1$ + private Shell shell; public FailureTab() {} *************** *** 149,156 **** if (fTable.getSelectionCount() > 0) { String className = getClassName(); - System.out.println(className); String methodName = getMethodName(); if (className != null) { ! manager.add(new OpenClassAction(className, getSymbolIndex())); manager.add(new Separator()); manager.add(new RerunAction(fRunnerViewPart, getSelectedTestId(), --- 151,157 ---- if (fTable.getSelectionCount() > 0) { String className = getClassName(); String methodName = getMethodName(); if (className != null) { ! manager.add(new OpenClassAction(getShell(), className, getSymbolIndex())); manager.add(new Separator()); manager.add(new RerunAction(fRunnerViewPart, getSelectedTestId(), *************** *** 275,282 **** void handleDoubleClick(MouseEvent e) { ! if (fTable.getSelectionCount() > 0) ! new OpenClassAction(getClassName(), getSymbolIndex()).run(); } /* * @see ITestRunView#testStatusChanged(TestRunInfo) --- 276,288 ---- void handleDoubleClick(MouseEvent e) { ! shell = getShell(); ! if (fTable.getSelectionCount() > 0) ! new OpenClassAction(shell, getClassName(), getSymbolIndex()).run(); } + private Shell getShell() { + return fTable.getShell(); + } + /* * @see ITestRunView#testStatusChanged(TestRunInfo) |