diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoring.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoring.java index 39c713cf9a8..fde32199eaa 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoring.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoring.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -7,8 +7,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Institute for Software - initial API and implementation - * Marc-Andre Laperle + * Institute for Software - initial API and implementation + * Marc-Andre Laperle *******************************************************************************/ package org.eclipse.cdt.internal.ui.refactoring.implementmethod; @@ -91,14 +91,20 @@ public class ImplementMethodRefactoring extends CRefactoring2 { super.checkInitialConditions(sm.newChild(6)); if (!initStatus.hasFatalError()) { - data.setMethodDeclarations(findUnimplementedMethodDeclarations(pm)); + List unimplementedMethodDeclarations = findUnimplementedMethodDeclarations(pm); + if (unimplementedMethodDeclarations.isEmpty()) { + initStatus.addFatalError(Messages.ImplementMethodRefactoring_NoMethodToImplement); + } + else { + data.setMethodDeclarations(unimplementedMethodDeclarations); - if (selectedRegion.getLength() > 0) { - IASTSimpleDeclaration methodDeclaration = SelectionHelper.findFirstSelectedDeclaration(selectedRegion, astCache.getAST(tu, pm)); - if (NodeHelper.isMethodDeclaration(methodDeclaration)) { - for (MethodToImplementConfig config : data.getMethodDeclarations()) { - if (config.getDeclaration() == methodDeclaration) { - config.setChecked(true); + if (selectedRegion.getLength() > 0) { + IASTSimpleDeclaration methodDeclaration = SelectionHelper.findFirstSelectedDeclaration(selectedRegion, astCache.getAST(tu, pm)); + if (NodeHelper.isMethodDeclaration(methodDeclaration)) { + for (MethodToImplementConfig config : data.getMethodDeclarations()) { + if (config.getDeclaration() == methodDeclaration) { + config.setChecked(true); + } } } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/Messages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/Messages.java index 52e3420e0d7..c3ded7f342a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/Messages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/Messages.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2011 IBM Corporation and others. + * Copyright (c) 2005, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -21,7 +21,7 @@ public final class Messages extends NLS { public static String ImplementMethodRefactoringPage_GeneratingPreview; public static String ImplementMethodRefactoringPage_PreviewCanceled; public static String ImplementMethodRefactoringPage_PreviewGenerationNotPossible; - public static String ImplementMethodRefactoring_NoMethodSelected; + public static String ImplementMethodRefactoring_NoMethodToImplement; public static String ImplementMethodRefactoring_MethodHasImpl; public static String ImplementMethodRefactoring_NoImplFile; public static String ImplementMethodRefactoringWizard_CancelingPreviewGeneration; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/Messages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/Messages.properties index 1b60d0f979e..452aa2dddd9 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/Messages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/Messages.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik +# Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik # Rapperswil, University of applied sciences and others # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 @@ -20,7 +20,7 @@ ImplementMethodInputPage_DeselectAll=Deselect All ImplementMethodRefactoringPage_PreviewGenerationNotPossible=Preview generation not possible ImplementMethodRefactoringPage_GeneratingPreview=Generating preview... ImplementMethodRefactoringPage_PreviewCanceled=Preview canceled -ImplementMethodRefactoring_NoMethodSelected=No method declaration selected +ImplementMethodRefactoring_NoMethodToImplement=No methods to implement found. ImplementMethodRefactoring_MethodHasImpl=This method already has an implementation. ImplementMethodRefactoring_NoImplFile=No implementation file found for one or more method. Inserting definition(s) into the header file. ImplementMethodRefactoringWizard_CancelingPreviewGeneration=Canceling preview generation \ No newline at end of file