|
From: David C. <dc...@us...> - 2005-11-18 22:46:17
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14686/src/org/rubypeople/rdt/testunit/views Modified Files: TestHierarchyTab.java FailureTab.java Added Files: OpenSymbolAction.java Removed Files: OpenClassAction.java Log Message: Fleshed out all the "open" menus and double-clicks for the Test::Unit view. --- OpenClassAction.java DELETED --- Index: FailureTab.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/FailureTab.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** FailureTab.java 18 Nov 2005 21:56:10 -0000 1.7 --- FailureTab.java 18 Nov 2005 22:46:09 -0000 1.8 *************** *** 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() {} --- 54,57 ---- *************** *** 153,157 **** String methodName = getMethodName(); if (className != null) { ! manager.add(new OpenClassAction(getShell(), className, getSymbolIndex())); manager.add(new Separator()); manager.add(new RerunAction(fRunnerViewPart, getSelectedTestId(), --- 152,156 ---- String methodName = getMethodName(); if (className != null) { ! manager.add(OpenSymbolAction.forClass(className, getSymbolIndex(), getShell())); manager.add(new Separator()); manager.add(new RerunAction(fRunnerViewPart, getSelectedTestId(), *************** *** 276,282 **** void handleDoubleClick(MouseEvent e) { - shell = getShell(); if (fTable.getSelectionCount() > 0) ! new OpenClassAction(shell, getClassName(), getSymbolIndex()).run(); } --- 275,280 ---- void handleDoubleClick(MouseEvent e) { if (fTable.getSelectionCount() > 0) ! OpenSymbolAction.forClass(getClassName(), getSymbolIndex(), getShell()).run(); } Index: TestHierarchyTab.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/TestHierarchyTab.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TestHierarchyTab.java 18 Jan 2005 21:56:22 -0000 1.3 --- TestHierarchyTab.java 18 Nov 2005 22:46:09 -0000 1.4 *************** *** 22,25 **** --- 22,26 ---- import org.eclipse.debug.core.ILaunchManager; import org.eclipse.jface.action.Action; + import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; *************** *** 41,46 **** --- 42,51 ---- import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Menu; + import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.TreeItem; + import org.rubypeople.rdt.core.RubyCore; + import org.rubypeople.rdt.internal.core.symbols.ClassSymbol; + import org.rubypeople.rdt.internal.core.symbols.SymbolIndex; import org.rubypeople.rdt.testunit.ITestRunListener; *************** *** 402,422 **** void handleDoubleClick(MouseEvent e) { ! // TODO Fix and enable OpenTestAction ! // TestRunInfo testInfo= getTestInfo(); ! // ! // if (testInfo == null) ! // return; ! // ! // String testLabel= testInfo.getTestName(); ! // OpenTestAction action= null; ! // ! // if (isSuiteSelected()) ! // action= new OpenTestAction(fTestRunnerPart, testLabel); ! // else ! // action= new OpenTestAction(fTestRunnerPart, getClassName(), ! // getTestMethod()); ! // ! // if (action != null && action.isEnabled()) ! // action.run(); } --- 407,427 ---- void handleDoubleClick(MouseEvent e) { ! TestRunInfo testInfo= getTestInfo(); ! ! if (testInfo == null) ! return; ! ! String testLabel= testInfo.getTestName(); ! IAction action = null; ! ! Shell shell = fTree.getShell(); ! SymbolIndex index = RubyCore.getPlugin().getSymbolIndex(); ! if (isSuiteSelected()) ! action= OpenSymbolAction.forClass(getClassName(), index, shell); ! else ! action= OpenSymbolAction.forMethod(getClassName(), getTestMethod(), index, shell); ! ! if (action != null && action.isEnabled()) ! action.run(); } *************** *** 426,432 **** TestRunInfo testInfo = (TestRunInfo) treeItem.getData(); String testLabel = testInfo.getTestName(); if (isSuiteSelected()) { ! // TODO Re-enable OpenTestAction ! //manager.add(new OpenTestAction(fTestRunnerPart, testLabel)); manager.add(new Separator()); if (testClassExists(getClassName()) && !fTestRunnerPart.lastLaunchIsKeptAlive()) { --- 431,438 ---- TestRunInfo testInfo = (TestRunInfo) treeItem.getData(); String testLabel = testInfo.getTestName(); + Shell shell = fTree.getShell(); + SymbolIndex symbolIndex = RubyCore.getPlugin().getSymbolIndex(); if (isSuiteSelected()) { ! manager.add(OpenSymbolAction.forClass(getClassName(), symbolIndex, shell)); manager.add(new Separator()); if (testClassExists(getClassName()) && !fTestRunnerPart.lastLaunchIsKeptAlive()) { *************** *** 435,440 **** } } else { ! //manager.add(new OpenTestAction(fTestRunnerPart, ! // getClassName(), getTestMethod())); manager.add(new Separator()); manager.add(new RerunAction(fTestRunnerPart, getSelectedTestId(), getClassName(), getTestMethod(), ILaunchManager.RUN_MODE)); --- 441,446 ---- } } else { ! manager.add(OpenSymbolAction.forMethod(getClassName(), ! getTestMethod(), symbolIndex, shell)); manager.add(new Separator()); manager.add(new RerunAction(fTestRunnerPart, getSelectedTestId(), getClassName(), getTestMethod(), ILaunchManager.RUN_MODE)); *************** *** 447,460 **** private boolean testClassExists(String className) { ! // TODO Fix / clean up ! // IJavaProject project= fTestRunnerPart.getLaunchedProject(); ! // try { ! // IType type= project.findType(className); ! // return type != null; ! // } catch (JavaModelException e) { ! // // fall through ! // } ! // return false; ! return true; } --- 453,457 ---- private boolean testClassExists(String className) { ! return RubyCore.getPlugin().getSymbolIndex().find(new ClassSymbol(className)).size() > 0; } --- NEW FILE: OpenSymbolAction.java --- package org.rubypeople.rdt.testunit.views; 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.MethodSymbol; import org.rubypeople.rdt.internal.core.symbols.Symbol; 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; public class OpenSymbolAction extends Action implements IAction { private final Symbol symbol; private final SymbolIndex index; private final Shell shell; private String dialogTitle; public static IAction forClass(String className, SymbolIndex index, Shell shell) { return new OpenSymbolAction(new ClassSymbol(className), index, shell, "Open Class"); } public static IAction forMethod(String className, String testMethod, SymbolIndex index, Shell shell) { return new OpenSymbolAction(new MethodSymbol(className, testMethod), index, shell, "Open Method"); } public OpenSymbolAction(Symbol symbol, SymbolIndex index, Shell shell, String title) { super(TestUnitMessages.getString("OpenEditor.action.label")); this.shell = shell; this.symbol = symbol; this.index = index; this.dialogTitle = title; } public void run() { Set locations = index.find(symbol); if (locations.size() == 0) return; 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(dialogTitle); 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() + ":" + location.getPosition().getStartLine() + " - " + sourceFile.getFullPath().removeLastSegments(1); } public void addListener(ILabelProviderListener listener) { } public void dispose() { } public boolean isLabelProperty(Object element, String property) { return false; } public void removeListener(ILabelProviderListener listener) { } } } |