mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-26 10:25:32 +02:00
Code cleanup.
Change-Id: Id1f1d6c0c098d94a4275188a3b4f6443ddc4843d
This commit is contained in:
parent
290c8dfe23
commit
1bdfc29020
7 changed files with 217 additions and 285 deletions
|
@ -62,7 +62,7 @@ public class NewClassCreationWizard extends NewElementWizard {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void finishPage(IProgressMonitor monitor) throws InterruptedException, CoreException {
|
protected void finishPage(IProgressMonitor monitor) throws CoreException {
|
||||||
fPage.createClass(monitor); // use the full progress monitor
|
fPage.createClass(monitor); // use the full progress monitor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,6 @@ package org.eclipse.cdt.internal.ui.wizards;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.actions.WorkbenchRunnableAdapter;
|
|
||||||
import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
|
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||||
|
@ -34,8 +31,12 @@ import org.eclipse.ui.PartInitException;
|
||||||
import org.eclipse.ui.ide.IDE;
|
import org.eclipse.ui.ide.IDE;
|
||||||
import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
|
import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
|
||||||
|
|
||||||
public abstract class NewElementWizard extends Wizard implements INewWizard {
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.actions.WorkbenchRunnableAdapter;
|
||||||
|
import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
|
||||||
|
|
||||||
|
public abstract class NewElementWizard extends Wizard implements INewWizard {
|
||||||
private IWorkbench fWorkbench;
|
private IWorkbench fWorkbench;
|
||||||
private IStructuredSelection fSelection;
|
private IStructuredSelection fSelection;
|
||||||
|
|
||||||
|
@ -65,11 +66,8 @@ public abstract class NewElementWizard extends Wizard implements INewWizard {
|
||||||
/**
|
/**
|
||||||
* Subclasses should override to perform the actions of the wizard.
|
* Subclasses should override to perform the actions of the wizard.
|
||||||
* This method is run in the wizard container's context as a workspace runnable.
|
* This method is run in the wizard container's context as a workspace runnable.
|
||||||
* @param monitor
|
|
||||||
* @throws InterruptedException
|
|
||||||
* @throws CoreException
|
|
||||||
*/
|
*/
|
||||||
protected abstract void finishPage(IProgressMonitor monitor) throws InterruptedException, CoreException;
|
protected abstract void finishPage(IProgressMonitor monitor) throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the scheduling rule for creating the element.
|
* Returns the scheduling rule for creating the element.
|
||||||
|
@ -78,31 +76,22 @@ public abstract class NewElementWizard extends Wizard implements INewWizard {
|
||||||
return ResourcesPlugin.getWorkspace().getRoot(); // look all by default
|
return ResourcesPlugin.getWorkspace().getRoot(); // look all by default
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected boolean canRunForked() {
|
protected boolean canRunForked() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void handleFinishException(Shell shell, InvocationTargetException e) {
|
protected void handleFinishException(Shell shell, InvocationTargetException e) {
|
||||||
String title= NewWizardMessages.NewElementWizard_op_error_title;
|
String title= NewWizardMessages.NewElementWizard_op_error_title;
|
||||||
String message= NewWizardMessages.NewElementWizard_op_error_message;
|
String message= NewWizardMessages.NewElementWizard_op_error_message;
|
||||||
ExceptionHandler.handle(e, shell, title, message);
|
ExceptionHandler.handle(e, shell, title, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see Wizard#performFinish
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean performFinish() {
|
public boolean performFinish() {
|
||||||
IWorkspaceRunnable op= new IWorkspaceRunnable() {
|
IWorkspaceRunnable op= new IWorkspaceRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run(IProgressMonitor monitor) throws CoreException, OperationCanceledException {
|
public void run(IProgressMonitor monitor) throws CoreException, OperationCanceledException {
|
||||||
try {
|
|
||||||
finishPage(monitor);
|
finishPage(monitor);
|
||||||
} catch (InterruptedException e) {
|
|
||||||
throw new OperationCanceledException(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
|
@ -116,9 +105,6 @@ public abstract class NewElementWizard extends Wizard implements INewWizard {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
|
public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
|
||||||
fWorkbench= workbench;
|
fWorkbench= workbench;
|
||||||
|
@ -136,5 +122,4 @@ public abstract class NewElementWizard extends Wizard implements INewWizard {
|
||||||
protected void selectAndReveal(IResource newResource) {
|
protected void selectAndReveal(IResource newResource) {
|
||||||
BasicNewResourceWizard.selectAndReveal(newResource, fWorkbench.getActiveWorkbenchWindow());
|
BasicNewResourceWizard.selectAndReveal(newResource, fWorkbench.getActiveWorkbenchWindow());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,10 +29,9 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
import org.eclipse.core.runtime.SubMonitor;
|
||||||
import org.eclipse.jface.text.BadLocationException;
|
import org.eclipse.jface.text.BadLocationException;
|
||||||
import org.eclipse.jface.text.Document;
|
import org.eclipse.jface.text.Document;
|
||||||
import org.eclipse.jface.text.IDocument;
|
import org.eclipse.jface.text.IDocument;
|
||||||
|
@ -181,19 +180,13 @@ public class NewClassCodeGenerator {
|
||||||
/**
|
/**
|
||||||
* Creates the new class.
|
* Creates the new class.
|
||||||
*
|
*
|
||||||
* @param monitor
|
* @param monitor a progress monitor to report progress
|
||||||
* a progress monitor to report progress.
|
* @throws CoreException if the creation failed
|
||||||
* @throws CoreException
|
|
||||||
* Thrown when the creation failed.
|
|
||||||
* @throws InterruptedException
|
|
||||||
* Thrown when the operation was cancelled.
|
|
||||||
*/
|
*/
|
||||||
public ICElement createClass(IProgressMonitor monitor)
|
public ICElement createClass(IProgressMonitor monitor) throws CoreException {
|
||||||
throws CodeGeneratorException, CoreException, InterruptedException {
|
SubMonitor progress = SubMonitor.convert(monitor,
|
||||||
if (monitor == null)
|
NewClassWizardMessages.NewClassCodeGeneration_createType_mainTask,
|
||||||
monitor = new NullProgressMonitor();
|
(fHeaderPath != null ? 3 : 0) + (fSourcePath != null ? 3 : 0)+ (fTestPath != null ? 3 : 0));
|
||||||
|
|
||||||
monitor.beginTask(NewClassWizardMessages.NewClassCodeGeneration_createType_mainTask, 400);
|
|
||||||
|
|
||||||
ITranslationUnit headerTU = null;
|
ITranslationUnit headerTU = null;
|
||||||
ITranslationUnit sourceTU = null;
|
ITranslationUnit sourceTU = null;
|
||||||
|
@ -205,26 +198,25 @@ public class NewClassCodeGenerator {
|
||||||
IWorkingCopy testWorkingCopy = null;
|
IWorkingCopy testWorkingCopy = null;
|
||||||
try {
|
try {
|
||||||
if (fHeaderPath != null) {
|
if (fHeaderPath != null) {
|
||||||
// Get method stubs
|
// Get method stubs.
|
||||||
List<IMethodStub> publicMethods = getStubs(ASTAccessVisibility.PUBLIC, false);
|
List<IMethodStub> publicMethods = getStubs(ASTAccessVisibility.PUBLIC, false);
|
||||||
List<IMethodStub> protectedMethods = getStubs(ASTAccessVisibility.PROTECTED, false);
|
List<IMethodStub> protectedMethods = getStubs(ASTAccessVisibility.PROTECTED, false);
|
||||||
List<IMethodStub> privateMethods = getStubs(ASTAccessVisibility.PRIVATE, false);
|
List<IMethodStub> privateMethods = getStubs(ASTAccessVisibility.PRIVATE, false);
|
||||||
|
|
||||||
IFile headerFile = NewSourceFileGenerator.createHeaderFile(fHeaderPath, true,
|
IFile headerFile =
|
||||||
new SubProgressMonitor(monitor, 50));
|
NewSourceFileGenerator.createHeaderFile(fHeaderPath, true, progress.split(1));
|
||||||
if (headerFile != null) {
|
if (headerFile != null) {
|
||||||
headerTU = (ITranslationUnit) CoreModel.getDefault().create(headerFile);
|
headerTU = (ITranslationUnit) CoreModel.getDefault().create(headerFile);
|
||||||
if (headerTU == null) {
|
if (headerTU == null) {
|
||||||
throw new CodeGeneratorException("Failed to create " + headerFile); //$NON-NLS-1$
|
throw new CodeGeneratorException("Failed to create " + headerFile); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a working copy with a new owner
|
// Create a working copy with a new owner.
|
||||||
headerWorkingCopy = headerTU.getWorkingCopy();
|
headerWorkingCopy = headerTU.getWorkingCopy();
|
||||||
// headerWorkingCopy = headerTU.getSharedWorkingCopy(null, CUIPlugin.getDefault().getBufferFactory());
|
|
||||||
|
|
||||||
String headerContent = constructHeaderFileContent(headerTU, publicMethods,
|
String headerContent = constructHeaderFileContent(headerTU, publicMethods,
|
||||||
protectedMethods, privateMethods, headerWorkingCopy.getBuffer().getContents(),
|
protectedMethods, privateMethods, headerWorkingCopy.getBuffer().getContents(),
|
||||||
new SubProgressMonitor(monitor, 100));
|
progress.split(1));
|
||||||
if (headerContent != null) {
|
if (headerContent != null) {
|
||||||
headerContent= formatSource(headerContent, headerTU);
|
headerContent= formatSource(headerContent, headerTU);
|
||||||
} else {
|
} else {
|
||||||
|
@ -232,13 +224,8 @@ public class NewClassCodeGenerator {
|
||||||
}
|
}
|
||||||
headerWorkingCopy.getBuffer().setContents(headerContent);
|
headerWorkingCopy.getBuffer().setContents(headerContent);
|
||||||
|
|
||||||
if (monitor.isCanceled()) {
|
|
||||||
throw new InterruptedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
headerWorkingCopy.reconcile();
|
headerWorkingCopy.reconcile();
|
||||||
headerWorkingCopy.commit(true, monitor);
|
headerWorkingCopy.commit(true, progress.split(1));
|
||||||
monitor.worked(50);
|
|
||||||
|
|
||||||
createdClass = headerWorkingCopy.getElement(fFullyQualifiedClassName);
|
createdClass = headerWorkingCopy.getElement(fFullyQualifiedClassName);
|
||||||
}
|
}
|
||||||
|
@ -247,30 +234,27 @@ public class NewClassCodeGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fSourcePath != null) {
|
if (fSourcePath != null) {
|
||||||
// Get method stubs
|
// Get method stubs.
|
||||||
List<IMethodStub> publicMethods = getStubs(ASTAccessVisibility.PUBLIC, true);
|
List<IMethodStub> publicMethods = getStubs(ASTAccessVisibility.PUBLIC, true);
|
||||||
List<IMethodStub> protectedMethods = getStubs(ASTAccessVisibility.PROTECTED, true);
|
List<IMethodStub> protectedMethods = getStubs(ASTAccessVisibility.PROTECTED, true);
|
||||||
List<IMethodStub> privateMethods = getStubs(ASTAccessVisibility.PRIVATE, true);
|
List<IMethodStub> privateMethods = getStubs(ASTAccessVisibility.PRIVATE, true);
|
||||||
|
|
||||||
if (!fForceSourceFileCreation && publicMethods.isEmpty() &&
|
if (fForceSourceFileCreation || !publicMethods.isEmpty() ||
|
||||||
protectedMethods.isEmpty() && privateMethods.isEmpty()) {
|
!protectedMethods.isEmpty() || !privateMethods.isEmpty()) {
|
||||||
monitor.worked(100);
|
IFile sourceFile =
|
||||||
} else {
|
NewSourceFileGenerator.createSourceFile(fSourcePath, true, progress.split(1));
|
||||||
IFile sourceFile = NewSourceFileGenerator.createSourceFile(fSourcePath, true,
|
|
||||||
new SubProgressMonitor(monitor, 50));
|
|
||||||
if (sourceFile != null) {
|
if (sourceFile != null) {
|
||||||
sourceTU = (ITranslationUnit) CoreModel.getDefault().create(sourceFile);
|
sourceTU = (ITranslationUnit) CoreModel.getDefault().create(sourceFile);
|
||||||
if (sourceTU == null) {
|
if (sourceTU == null) {
|
||||||
throw new CodeGeneratorException("Failed to create " + sourceFile); //$NON-NLS-1$
|
throw new CodeGeneratorException("Failed to create " + sourceFile); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
monitor.worked(50);
|
|
||||||
|
|
||||||
// Create a working copy with a new owner
|
// Create a working copy with a new owner.
|
||||||
sourceWorkingCopy = sourceTU.getWorkingCopy();
|
sourceWorkingCopy = sourceTU.getWorkingCopy();
|
||||||
|
|
||||||
String sourceContent = constructSourceFileContent(sourceTU, headerTU,
|
String sourceContent = constructSourceFileContent(sourceTU, headerTU,
|
||||||
publicMethods, protectedMethods, privateMethods,
|
publicMethods, protectedMethods, privateMethods,
|
||||||
sourceWorkingCopy.getBuffer().getContents(), new SubProgressMonitor(monitor, 100));
|
sourceWorkingCopy.getBuffer().getContents(), progress.split(1));
|
||||||
if (sourceContent != null) {
|
if (sourceContent != null) {
|
||||||
sourceContent = formatSource(sourceContent, sourceTU);
|
sourceContent = formatSource(sourceContent, sourceTU);
|
||||||
} else {
|
} else {
|
||||||
|
@ -278,13 +262,8 @@ public class NewClassCodeGenerator {
|
||||||
}
|
}
|
||||||
sourceWorkingCopy.getBuffer().setContents(sourceContent);
|
sourceWorkingCopy.getBuffer().setContents(sourceContent);
|
||||||
|
|
||||||
if (monitor.isCanceled()) {
|
|
||||||
throw new InterruptedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceWorkingCopy.reconcile();
|
sourceWorkingCopy.reconcile();
|
||||||
sourceWorkingCopy.commit(true, monitor);
|
sourceWorkingCopy.commit(true, progress.split(1));
|
||||||
monitor.worked(50);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fCreatedSourceTU = sourceTU;
|
fCreatedSourceTU = sourceTU;
|
||||||
|
@ -292,30 +271,23 @@ public class NewClassCodeGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fTestPath != null) {
|
if (fTestPath != null) {
|
||||||
IFile testFile = NewSourceFileGenerator.createTestFile(fTestPath, true,
|
IFile testFile = NewSourceFileGenerator.createTestFile(fTestPath, true, progress.split(1));
|
||||||
new SubProgressMonitor(monitor, 50));
|
|
||||||
if (testFile != null) {
|
if (testFile != null) {
|
||||||
testTU = (ITranslationUnit) CoreModel.getDefault().create(testFile);
|
testTU = (ITranslationUnit) CoreModel.getDefault().create(testFile);
|
||||||
if (testTU == null) {
|
if (testTU == null) {
|
||||||
throw new CodeGeneratorException("Failed to create " + testFile); //$NON-NLS-1$
|
throw new CodeGeneratorException("Failed to create " + testFile); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
monitor.worked(50);
|
|
||||||
|
|
||||||
// Create a working copy with a new owner
|
// Create a working copy with a new owner
|
||||||
testWorkingCopy = testTU.getWorkingCopy();
|
testWorkingCopy = testTU.getWorkingCopy();
|
||||||
|
|
||||||
String testContent = constructTestFileContent(testTU, headerTU,
|
String testContent = constructTestFileContent(testTU, headerTU,
|
||||||
testWorkingCopy.getBuffer().getContents(), new SubProgressMonitor(monitor, 100));
|
testWorkingCopy.getBuffer().getContents(), progress.split(1));
|
||||||
testContent= formatSource(testContent, testTU);
|
testContent= formatSource(testContent, testTU);
|
||||||
testWorkingCopy.getBuffer().setContents(testContent);
|
testWorkingCopy.getBuffer().setContents(testContent);
|
||||||
|
|
||||||
if (monitor.isCanceled()) {
|
|
||||||
throw new InterruptedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
testWorkingCopy.reconcile();
|
testWorkingCopy.reconcile();
|
||||||
testWorkingCopy.commit(true, monitor);
|
testWorkingCopy.commit(true, progress.split(1));
|
||||||
monitor.worked(50);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fCreatedTestTU = testTU;
|
fCreatedTestTU = testTU;
|
||||||
|
@ -332,7 +304,6 @@ public class NewClassCodeGenerator {
|
||||||
if (testWorkingCopy != null) {
|
if (testWorkingCopy != null) {
|
||||||
testWorkingCopy.destroy();
|
testWorkingCopy.destroy();
|
||||||
}
|
}
|
||||||
monitor.done();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return fCreatedClass;
|
return fCreatedClass;
|
||||||
|
@ -382,7 +353,8 @@ public class NewClassCodeGenerator {
|
||||||
public String constructHeaderFileContent(ITranslationUnit headerTU, List<IMethodStub> publicMethods,
|
public String constructHeaderFileContent(ITranslationUnit headerTU, List<IMethodStub> publicMethods,
|
||||||
List<IMethodStub> protectedMethods, List<IMethodStub> privateMethods, String oldContents,
|
List<IMethodStub> protectedMethods, List<IMethodStub> privateMethods, String oldContents,
|
||||||
IProgressMonitor monitor) throws CoreException {
|
IProgressMonitor monitor) throws CoreException {
|
||||||
monitor.beginTask(NewClassWizardMessages.NewClassCodeGeneration_createType_task_header, 100);
|
SubMonitor progress = SubMonitor.convert(monitor,
|
||||||
|
NewClassWizardMessages.NewClassCodeGeneration_createType_task_header, 1);
|
||||||
|
|
||||||
String lineDelimiter= StubUtility.getLineDelimiterUsed(headerTU);
|
String lineDelimiter= StubUtility.getLineDelimiterUsed(headerTU);
|
||||||
|
|
||||||
|
@ -394,13 +366,12 @@ public class NewClassCodeGenerator {
|
||||||
privateMethods, lineDelimiter);
|
privateMethods, lineDelimiter);
|
||||||
|
|
||||||
String includes = null;
|
String includes = null;
|
||||||
if (fBaseClasses != null && fBaseClasses.length > 0) {
|
if (fBaseClasses != null && fBaseClasses.length != 0) {
|
||||||
includes = constructBaseClassIncludes(headerTU, lineDelimiter,
|
includes = constructBaseClassIncludes(headerTU, lineDelimiter, progress.split(1));
|
||||||
new SubProgressMonitor(monitor, 50));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldContents != null) {
|
if (oldContents != null) {
|
||||||
if (oldContents.length() == 0) {
|
if (oldContents.isEmpty()) {
|
||||||
oldContents = null;
|
oldContents = null;
|
||||||
} else if (!oldContents.endsWith(lineDelimiter)) {
|
} else if (!oldContents.endsWith(lineDelimiter)) {
|
||||||
oldContents += lineDelimiter;
|
oldContents += lineDelimiter;
|
||||||
|
@ -466,8 +437,6 @@ public class NewClassCodeGenerator {
|
||||||
namespaceEnd, namespaceName, classComment, classDefinition, fClassName,
|
namespaceEnd, namespaceName, classComment, classDefinition, fClassName,
|
||||||
lineDelimiter);
|
lineDelimiter);
|
||||||
}
|
}
|
||||||
|
|
||||||
monitor.done();
|
|
||||||
return fileContent;
|
return fileContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -710,7 +679,8 @@ public class NewClassCodeGenerator {
|
||||||
|
|
||||||
private String constructBaseClassIncludes(ITranslationUnit headerTU, String lineDelimiter,
|
private String constructBaseClassIncludes(ITranslationUnit headerTU, String lineDelimiter,
|
||||||
IProgressMonitor monitor) throws CodeGeneratorException {
|
IProgressMonitor monitor) throws CodeGeneratorException {
|
||||||
monitor.beginTask(NewClassWizardMessages.NewClassCodeGeneration_createType_task_header_includePaths, 100);
|
SubMonitor progress = SubMonitor.convert(monitor,
|
||||||
|
NewClassWizardMessages.NewClassCodeGeneration_createType_task_header_includePaths, 1);
|
||||||
|
|
||||||
ICProject cProject = headerTU.getCProject();
|
ICProject cProject = headerTU.getCProject();
|
||||||
IProject project = cProject.getProject();
|
IProject project = cProject.getProject();
|
||||||
|
@ -723,7 +693,7 @@ public class NewClassCodeGenerator {
|
||||||
if (createIncludePaths()) {
|
if (createIncludePaths()) {
|
||||||
List<IPath> newIncludePaths = getMissingIncludePaths(projectLocation, includePaths, baseClassPaths);
|
List<IPath> newIncludePaths = getMissingIncludePaths(projectLocation, includePaths, baseClassPaths);
|
||||||
if (!newIncludePaths.isEmpty()) {
|
if (!newIncludePaths.isEmpty()) {
|
||||||
addIncludePaths(cProject, newIncludePaths, monitor);
|
addIncludePaths(cProject, newIncludePaths, progress.split(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -749,8 +719,6 @@ public class NewClassCodeGenerator {
|
||||||
text.append(lineDelimiter);
|
text.append(lineDelimiter);
|
||||||
previousStyle = style;
|
previousStyle = style;
|
||||||
}
|
}
|
||||||
|
|
||||||
monitor.done();
|
|
||||||
return text.toString();
|
return text.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -772,8 +740,10 @@ public class NewClassCodeGenerator {
|
||||||
return NewClassWizardPrefs.createIncludePaths();
|
return NewClassWizardPrefs.createIncludePaths();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addIncludePaths(ICProject cProject, List<IPath> newIncludePaths, IProgressMonitor monitor) throws CodeGeneratorException {
|
private void addIncludePaths(ICProject cProject, List<IPath> newIncludePaths, IProgressMonitor monitor)
|
||||||
monitor.beginTask(NewClassWizardMessages.NewClassCodeGeneration_createType_task_header_addIncludePaths, 100);
|
throws CodeGeneratorException {
|
||||||
|
SubMonitor progress = SubMonitor.convert(monitor,
|
||||||
|
NewClassWizardMessages.NewClassCodeGeneration_createType_task_header_addIncludePaths, 1);
|
||||||
|
|
||||||
//TODO prefs option whether to add to project or parent source folder?
|
//TODO prefs option whether to add to project or parent source folder?
|
||||||
IPath addToResourcePath = cProject.getPath();
|
IPath addToResourcePath = cProject.getPath();
|
||||||
|
@ -802,18 +772,19 @@ public class NewClassCodeGenerator {
|
||||||
if (includeProject != null) {
|
if (includeProject != null) {
|
||||||
// Make sure that the include is made the same way that build properties for
|
// Make sure that the include is made the same way that build properties for
|
||||||
// projects makes them, so .contains below is a valid check
|
// projects makes them, so .contains below is a valid check
|
||||||
IIncludeEntry entry = CoreModel.newIncludeEntry(addToResourcePath, null, new Path(includeProject.getProject().getLocationURI().getPath()), true);
|
IIncludeEntry entry = CoreModel.newIncludeEntry(addToResourcePath, null,
|
||||||
|
new Path(includeProject.getProject().getLocationURI().getPath()), true);
|
||||||
|
|
||||||
if (!checkEntryList.contains(entry)) // if the path already exists in the #includes then don't add it
|
// If the path already exists in the #includes then don't add it.
|
||||||
|
if (!checkEntryList.contains(entry))
|
||||||
pathEntryList.add(entry);
|
pathEntryList.add(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pathEntries = pathEntryList.toArray(new IPathEntry[pathEntryList.size()]);
|
pathEntries = pathEntryList.toArray(new IPathEntry[pathEntryList.size()]);
|
||||||
cProject.setRawPathEntries(pathEntries, new SubProgressMonitor(monitor, 80));
|
cProject.setRawPathEntries(pathEntries, progress.split(1));
|
||||||
} catch (CModelException e) {
|
} catch (CModelException e) {
|
||||||
throw new CodeGeneratorException(e);
|
throw new CodeGeneratorException(e);
|
||||||
}
|
}
|
||||||
monitor.done();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ICProject toCProject(IProject enclosingProject) {
|
private ICProject toCProject(IProject enclosingProject) {
|
||||||
|
@ -925,12 +896,13 @@ public class NewClassCodeGenerator {
|
||||||
public String constructSourceFileContent(ITranslationUnit sourceTU, ITranslationUnit headerTU,
|
public String constructSourceFileContent(ITranslationUnit sourceTU, ITranslationUnit headerTU,
|
||||||
List<IMethodStub> publicMethods, List<IMethodStub> protectedMethods,
|
List<IMethodStub> publicMethods, List<IMethodStub> protectedMethods,
|
||||||
List<IMethodStub> privateMethods, String oldContents, IProgressMonitor monitor) throws CoreException {
|
List<IMethodStub> privateMethods, String oldContents, IProgressMonitor monitor) throws CoreException {
|
||||||
monitor.beginTask(NewClassWizardMessages.NewClassCodeGeneration_createType_task_source, 150);
|
SubMonitor progress = SubMonitor.convert(monitor,
|
||||||
|
NewClassWizardMessages.NewClassCodeGeneration_createType_task_source, 2);
|
||||||
|
|
||||||
String lineDelimiter= StubUtility.getLineDelimiterUsed(sourceTU);
|
String lineDelimiter= StubUtility.getLineDelimiterUsed(sourceTU);
|
||||||
String includeString = null;
|
String includeString = null;
|
||||||
if (headerTU != null) {
|
if (headerTU != null) {
|
||||||
includeString = getHeaderIncludeString(sourceTU, headerTU, new SubProgressMonitor(monitor, 50));
|
includeString = getHeaderIncludeString(sourceTU, headerTU, progress.split(1));
|
||||||
if (includeString != null) {
|
if (includeString != null) {
|
||||||
// Check if file already has the include.
|
// Check if file already has the include.
|
||||||
if (oldContents != null && hasInclude(oldContents, includeString)) {
|
if (oldContents != null && hasInclude(oldContents, includeString)) {
|
||||||
|
@ -944,7 +916,7 @@ public class NewClassCodeGenerator {
|
||||||
if (!publicMethods.isEmpty() || !protectedMethods.isEmpty() || !privateMethods.isEmpty()) {
|
if (!publicMethods.isEmpty() || !protectedMethods.isEmpty() || !privateMethods.isEmpty()) {
|
||||||
// TODO sort methods (e.g. constructor always first?)
|
// TODO sort methods (e.g. constructor always first?)
|
||||||
methodBodies = constructMethodBodies(sourceTU, publicMethods, protectedMethods,
|
methodBodies = constructMethodBodies(sourceTU, publicMethods, protectedMethods,
|
||||||
privateMethods, lineDelimiter, new SubProgressMonitor(monitor, 50));
|
privateMethods, lineDelimiter, progress.split(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
String namespaceBegin = fNamespace == null ?
|
String namespaceBegin = fNamespace == null ?
|
||||||
|
@ -1007,19 +979,19 @@ public class NewClassCodeGenerator {
|
||||||
fileContent= CodeGeneration.getBodyFileContent(sourceTU, includeString, namespaceBegin,
|
fileContent= CodeGeneration.getBodyFileContent(sourceTU, includeString, namespaceBegin,
|
||||||
namespaceEnd, namespaceName, null, methodBodies, fClassName, lineDelimiter);
|
namespaceEnd, namespaceName, null, methodBodies, fClassName, lineDelimiter);
|
||||||
}
|
}
|
||||||
monitor.done();
|
|
||||||
return fileContent;
|
return fileContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String constructTestFileContent(ITranslationUnit testTU, ITranslationUnit headerTU,
|
public String constructTestFileContent(ITranslationUnit testTU, ITranslationUnit headerTU,
|
||||||
String oldContents, IProgressMonitor monitor) throws CoreException {
|
String oldContents, IProgressMonitor monitor) throws CoreException {
|
||||||
monitor.beginTask(NewClassWizardMessages.NewClassCodeGeneration_createType_task_source, 150);
|
SubMonitor progress = SubMonitor.convert(monitor,
|
||||||
|
NewClassWizardMessages.NewClassCodeGeneration_createType_task_source, 1);
|
||||||
|
|
||||||
String lineDelimiter= StubUtility.getLineDelimiterUsed(testTU);
|
String lineDelimiter= StubUtility.getLineDelimiterUsed(testTU);
|
||||||
|
|
||||||
String includeString = null;
|
String includeString = null;
|
||||||
if (headerTU != null) {
|
if (headerTU != null) {
|
||||||
includeString = getHeaderIncludeString(testTU, headerTU, new SubProgressMonitor(monitor, 50));
|
includeString = getHeaderIncludeString(testTU, headerTU, progress.split(1));
|
||||||
if (includeString != null) {
|
if (includeString != null) {
|
||||||
// Check if file already has the include.
|
// Check if file already has the include.
|
||||||
if (oldContents != null && hasInclude(oldContents, includeString)) {
|
if (oldContents != null && hasInclude(oldContents, includeString)) {
|
||||||
|
@ -1071,7 +1043,6 @@ public class NewClassCodeGenerator {
|
||||||
fileContent= CodeGeneration.getTestFileContent(testTU, includeString, namespaceBegin,
|
fileContent= CodeGeneration.getTestFileContent(testTU, includeString, namespaceBegin,
|
||||||
namespaceEnd, namespaceName, null, fClassName, lineDelimiter);
|
namespaceEnd, namespaceName, null, fClassName, lineDelimiter);
|
||||||
}
|
}
|
||||||
monitor.done();
|
|
||||||
return fileContent;
|
return fileContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,18 +11,19 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.wizards.filewizard;
|
package org.eclipse.cdt.internal.ui.wizards.filewizard;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
|
||||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
|
||||||
import org.eclipse.cdt.internal.ui.wizards.NewElementWizard;
|
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
|
||||||
public abstract class AbstractFileCreationWizard extends NewElementWizard {
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
|
||||||
protected AbstractFileCreationWizardPage fPage = null;
|
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||||
|
import org.eclipse.cdt.internal.ui.wizards.NewElementWizard;
|
||||||
|
|
||||||
|
public abstract class AbstractFileCreationWizard extends NewElementWizard {
|
||||||
|
protected AbstractFileCreationWizardPage fPage;
|
||||||
|
|
||||||
public AbstractFileCreationWizard() {
|
public AbstractFileCreationWizard() {
|
||||||
super();
|
super();
|
||||||
|
@ -31,35 +32,20 @@ public abstract class AbstractFileCreationWizard extends NewElementWizard {
|
||||||
setWindowTitle(NewFileWizardMessages.AbstractFileCreationWizard_title);
|
setWindowTitle(NewFileWizardMessages.AbstractFileCreationWizard_title);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.cdt.internal.ui.wizards.NewElementWizard#canRunForked()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean canRunForked() {
|
protected boolean canRunForked() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.cdt.internal.ui.wizards.NewElementWizard#finishPage(org.eclipse.core.runtime.IProgressMonitor)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected void finishPage(IProgressMonitor monitor) throws InterruptedException, CoreException {
|
protected void finishPage(IProgressMonitor monitor) throws CoreException {
|
||||||
fPage.createFile(monitor); // use the full progress monitor
|
fPage.createFile(monitor); // Use the full progress monitor.
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.jface.wizard.IWizard#performFinish()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean performFinish() {
|
public boolean performFinish() {
|
||||||
boolean res = super.performFinish();
|
boolean result = super.performFinish();
|
||||||
if (res) {
|
if (result) {
|
||||||
//TODO need prefs option for opening editor
|
//TODO need prefs option for opening editor
|
||||||
boolean openInEditor = true;
|
boolean openInEditor = true;
|
||||||
|
|
||||||
|
@ -72,6 +58,6 @@ public abstract class AbstractFileCreationWizard extends NewElementWizard {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,9 +23,8 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
import org.eclipse.core.runtime.SubMonitor;
|
||||||
import org.eclipse.jface.dialogs.Dialog;
|
import org.eclipse.jface.dialogs.Dialog;
|
||||||
import org.eclipse.jface.viewers.ILabelProvider;
|
import org.eclipse.jface.viewers.ILabelProvider;
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
@ -180,9 +179,6 @@ public class NewSourceFolderWizardPage extends NewElementWizardPage {
|
||||||
|
|
||||||
// -------- UI Creation ---------
|
// -------- UI Creation ---------
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void createControl(Composite parent) {
|
public void createControl(Composite parent) {
|
||||||
initializeDialogUnits(parent);
|
initializeDialogUnits(parent);
|
||||||
|
@ -212,9 +208,6 @@ public class NewSourceFolderWizardPage extends NewElementWizardPage {
|
||||||
PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.NEW_SRCFLDER_WIZARD_PAGE);
|
PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.NEW_SRCFLDER_WIZARD_PAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setVisible(boolean visible) {
|
public void setVisible(boolean visible) {
|
||||||
super.setVisible(visible);
|
super.setVisible(visible);
|
||||||
|
@ -226,14 +219,11 @@ public class NewSourceFolderWizardPage extends NewElementWizardPage {
|
||||||
// -------- ContainerFieldAdapter --------
|
// -------- ContainerFieldAdapter --------
|
||||||
|
|
||||||
private class RootFieldAdapter implements IStringButtonAdapter, IDialogFieldListener {
|
private class RootFieldAdapter implements IStringButtonAdapter, IDialogFieldListener {
|
||||||
|
|
||||||
// -------- IStringButtonAdapter
|
|
||||||
@Override
|
@Override
|
||||||
public void changeControlPressed(DialogField field) {
|
public void changeControlPressed(DialogField field) {
|
||||||
packRootChangeControlPressed(field);
|
packRootChangeControlPressed(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------- IDialogFieldListener
|
|
||||||
@Override
|
@Override
|
||||||
public void dialogFieldChanged(DialogField field) {
|
public void dialogFieldChanged(DialogField field) {
|
||||||
packRootDialogFieldChanged(field);
|
packRootDialogFieldChanged(field);
|
||||||
|
@ -276,7 +266,7 @@ public class NewSourceFolderWizardPage extends NewElementWizardPage {
|
||||||
fIsProjectAsSourceFolder= false;
|
fIsProjectAsSourceFolder= false;
|
||||||
|
|
||||||
String str= fProjectField.getText();
|
String str= fProjectField.getText();
|
||||||
if (str.length() == 0) {
|
if (str.isEmpty()) {
|
||||||
fProjectStatus.setError(NewFolderWizardMessages.NewSourceFolderWizardPage_error_EnterProjectName);
|
fProjectStatus.setError(NewFolderWizardMessages.NewSourceFolderWizardPage_error_EnterProjectName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -393,34 +383,24 @@ public class NewSourceFolderWizardPage extends NewElementWizardPage {
|
||||||
return fCurrCProject.getProject().getFolder(fRootDialogField.getText());
|
return fCurrCProject.getProject().getFolder(fRootDialogField.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createSourceRoot(IProgressMonitor monitor) throws CoreException, InterruptedException {
|
public void createSourceRoot(IProgressMonitor monitor) throws CoreException {
|
||||||
if (monitor == null) {
|
SubMonitor progress = SubMonitor.convert(monitor,
|
||||||
monitor= new NullProgressMonitor();
|
NewFolderWizardMessages.NewSourceFolderWizardPage_operation, 3);
|
||||||
}
|
|
||||||
monitor.beginTask(NewFolderWizardMessages.NewSourceFolderWizardPage_operation, 3);
|
|
||||||
try {
|
|
||||||
String relPath= fRootDialogField.getText();
|
String relPath= fRootDialogField.getText();
|
||||||
|
|
||||||
IProject project = fCurrCProject.getProject();
|
IProject project = fCurrCProject.getProject();
|
||||||
IFolder folder= project.getFolder(relPath);
|
IFolder folder= project.getFolder(relPath);
|
||||||
if (!folder.exists()) {
|
if (!folder.exists()) {
|
||||||
CoreUtility.createFolder(folder, true, true, new SubProgressMonitor(monitor, 1));
|
CoreUtility.createFolder(folder, true, true, progress.split(1));
|
||||||
}
|
|
||||||
if (monitor.isCanceled()) {
|
|
||||||
throw new InterruptedException();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CCorePlugin.getDefault().isNewStyleProject(project)) {
|
if (CCorePlugin.getDefault().isNewStyleProject(project)) {
|
||||||
InternalCoreModelUtil.addSourceEntry(project, folder, fIsProjectAsSourceFolder,
|
InternalCoreModelUtil.addSourceEntry(project, folder, fIsProjectAsSourceFolder, progress.split(2));
|
||||||
new SubProgressMonitor(monitor, 2));
|
|
||||||
} else {
|
} else {
|
||||||
fCurrCProject.setRawPathEntries(fNewEntries, new SubProgressMonitor(monitor, 2));
|
fCurrCProject.setRawPathEntries(fNewEntries, progress.split(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
fCreatedRoot= fCurrCProject.findSourceRoot(folder);
|
fCreatedRoot= fCurrCProject.findSourceRoot(folder);
|
||||||
} finally {
|
|
||||||
monitor.done();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------- choose dialogs
|
// ------------- choose dialogs
|
||||||
|
|
|
@ -568,6 +568,9 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
|
||||||
* Returns the method stubs to display in the wizard.
|
* Returns the method stubs to display in the wizard.
|
||||||
*
|
*
|
||||||
* @return array of method stubs
|
* @return array of method stubs
|
||||||
|
*
|
||||||
|
* @noreference This method is not intended to be referenced by clients.
|
||||||
|
* @nooverride This method is not intended to be re-implemented or extended by clients.
|
||||||
*/
|
*/
|
||||||
protected IMethodStub[] getDefaultMethodStubs() {
|
protected IMethodStub[] getDefaultMethodStubs() {
|
||||||
return new IMethodStub[] {
|
return new IMethodStub[] {
|
||||||
|
@ -717,6 +720,9 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
|
||||||
* Returns the currently selected (checked) method stubs.
|
* Returns the currently selected (checked) method stubs.
|
||||||
*
|
*
|
||||||
* @return array of <code>IMethodStub</code> or empty array if none selected.
|
* @return array of <code>IMethodStub</code> or empty array if none selected.
|
||||||
|
*
|
||||||
|
* @noreference This method is not intended to be referenced by clients.
|
||||||
|
* @nooverride This method is not intended to be re-implemented or extended by clients.
|
||||||
*/
|
*/
|
||||||
protected IMethodStub[] getSelectedMethodStubs() {
|
protected IMethodStub[] getSelectedMethodStubs() {
|
||||||
return fMethodStubsDialogField.getCheckedMethodStubs();
|
return fMethodStubsDialogField.getCheckedMethodStubs();
|
||||||
|
@ -724,8 +730,12 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a method stub to the method stubs field.
|
* Adds a method stub to the method stubs field.
|
||||||
|
*
|
||||||
* @param methodStub the method stub to add
|
* @param methodStub the method stub to add
|
||||||
* @param selected <code>true</code> if the stub is initially selected (checked)
|
* @param selected <code>true</code> if the stub is initially selected (checked)
|
||||||
|
*
|
||||||
|
* @noreference This method is not intended to be referenced by clients.
|
||||||
|
* @nooverride This method is not intended to be re-implemented or extended by clients.
|
||||||
*/
|
*/
|
||||||
protected void addMethodStub(IMethodStub methodStub, boolean selected) {
|
protected void addMethodStub(IMethodStub methodStub, boolean selected) {
|
||||||
fMethodStubsDialogField.addMethodStub(methodStub, selected);
|
fMethodStubsDialogField.addMethodStub(methodStub, selected);
|
||||||
|
@ -735,6 +745,9 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
|
||||||
* Returns the contents of the base classes field.
|
* Returns the contents of the base classes field.
|
||||||
*
|
*
|
||||||
* @return array of <code>IBaseClassInfo</code>
|
* @return array of <code>IBaseClassInfo</code>
|
||||||
|
*
|
||||||
|
* @noreference This method is not intended to be referenced by clients.
|
||||||
|
* @nooverride This method is not intended to be re-implemented or extended by clients.
|
||||||
*/
|
*/
|
||||||
protected IBaseClassInfo[] getBaseClasses() {
|
protected IBaseClassInfo[] getBaseClasses() {
|
||||||
List<IBaseClassInfo> classesList = fBaseClassesDialogField.getElements();
|
List<IBaseClassInfo> classesList = fBaseClassesDialogField.getElements();
|
||||||
|
@ -748,7 +761,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
|
||||||
* @param isVirtual <code>true</code> if the inheritance is virtual
|
* @param isVirtual <code>true</code> if the inheritance is virtual
|
||||||
*/
|
*/
|
||||||
protected void addBaseClass(ITypeInfo newBaseClass, ASTAccessVisibility access, boolean isVirtual) {
|
protected void addBaseClass(ITypeInfo newBaseClass, ASTAccessVisibility access, boolean isVirtual) {
|
||||||
// check if already exists
|
// Check if already exists.
|
||||||
List<IBaseClassInfo> baseClasses = fBaseClassesDialogField.getElements();
|
List<IBaseClassInfo> baseClasses = fBaseClassesDialogField.getElements();
|
||||||
if (baseClasses != null) {
|
if (baseClasses != null) {
|
||||||
for (IBaseClassInfo baseClassInfo : baseClasses) {
|
for (IBaseClassInfo baseClassInfo : baseClasses) {
|
||||||
|
@ -771,8 +784,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
|
||||||
* Sets the use test file creation checkbox's selection state.
|
* Sets the use test file creation checkbox's selection state.
|
||||||
*
|
*
|
||||||
* @param isSelected the checkbox's selection state
|
* @param isSelected the checkbox's selection state
|
||||||
* @param canBeModified if <code>true</code> the checkbox is
|
* @param canBeModified if <code>true</code> the checkbox is modifiable; otherwise it is read-only.
|
||||||
* modifiable; otherwise it is read-only.
|
|
||||||
* @since 5.3
|
* @since 5.3
|
||||||
*/
|
*/
|
||||||
public void setTestFileSelection(boolean isSelected, boolean canBeModified) {
|
public void setTestFileSelection(boolean isSelected, boolean canBeModified) {
|
||||||
|
@ -1725,6 +1737,9 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
|
||||||
* @param baseClasses an array of base classes
|
* @param baseClasses an array of base classes
|
||||||
*
|
*
|
||||||
* @return the status of the validation
|
* @return the status of the validation
|
||||||
|
*
|
||||||
|
* @noreference This method is not intended to be referenced by clients.
|
||||||
|
* @nooverride This method is not intended to be re-implemented or extended by clients.
|
||||||
*/
|
*/
|
||||||
protected IStatus baseClassesChanged(ICProject project, IPath sourceFolder, IBaseClassInfo[] baseClasses) {
|
protected IStatus baseClassesChanged(ICProject project, IPath sourceFolder, IBaseClassInfo[] baseClasses) {
|
||||||
MultiStatus status = new MultiStatus(CUIPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
|
MultiStatus status = new MultiStatus(CUIPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
|
||||||
|
@ -2020,9 +2035,8 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
|
||||||
*
|
*
|
||||||
* @param monitor a progress monitor to report progress.
|
* @param monitor a progress monitor to report progress.
|
||||||
* @throws CoreException Thrown when the creation failed.
|
* @throws CoreException Thrown when the creation failed.
|
||||||
* @throws InterruptedException Thrown when the operation was cancelled.
|
|
||||||
*/
|
*/
|
||||||
public void createClass(IProgressMonitor monitor) throws CoreException, InterruptedException {
|
public void createClass(IProgressMonitor monitor) throws CoreException {
|
||||||
// Update dialog settings.
|
// Update dialog settings.
|
||||||
fDialogSettings.put(KEY_NAMESPACE_SELECTED, fNamespaceSelection.isSelected());
|
fDialogSettings.put(KEY_NAMESPACE_SELECTED, fNamespaceSelection.isSelected());
|
||||||
fDialogSettings.put(KEY_TEST_FILE_SELECTED, fTestFileSelection.isSelected());
|
fDialogSettings.put(KEY_TEST_FILE_SELECTED, fTestFileSelection.isSelected());
|
||||||
|
@ -2075,12 +2089,14 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
|
||||||
* @param methodStubs array of method stubs
|
* @param methodStubs array of method stubs
|
||||||
* @param monitor a progress monitor
|
* @param monitor a progress monitor
|
||||||
* @throws CoreException if the creation failed
|
* @throws CoreException if the creation failed
|
||||||
* @throws InterruptedException if the operation was cancelled
|
|
||||||
* @since 5.3
|
* @since 5.3
|
||||||
|
*
|
||||||
|
* @noreference This method is not intended to be referenced by clients.
|
||||||
|
* @nooverride This method is not intended to be re-implemented or extended by clients.
|
||||||
*/
|
*/
|
||||||
protected void createClass(IPath headerPath, IPath sourcePath, IPath testPath, String className,
|
protected void createClass(IPath headerPath, IPath sourcePath, IPath testPath, String className,
|
||||||
String namespace, IBaseClassInfo[] baseClasses, IMethodStub[] methodStubs, IProgressMonitor monitor)
|
String namespace, IBaseClassInfo[] baseClasses, IMethodStub[] methodStubs, IProgressMonitor monitor)
|
||||||
throws CoreException, InterruptedException {
|
throws CoreException {
|
||||||
NewClassCodeGenerator generator = new NewClassCodeGenerator(
|
NewClassCodeGenerator generator = new NewClassCodeGenerator(
|
||||||
headerPath,
|
headerPath,
|
||||||
sourcePath,
|
sourcePath,
|
||||||
|
@ -2098,16 +2114,19 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
|
||||||
fCreatedTestFile = generator.getCreatedTestFile();
|
fCreatedTestFile = generator.getCreatedTestFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @noreference This method is not intended to be referenced by clients.
|
||||||
|
* @nooverride This method is not intended to be re-implemented or extended by clients.
|
||||||
|
*/
|
||||||
protected void createClass(IPath headerPath, IPath sourcePath, String className, String namespace,
|
protected void createClass(IPath headerPath, IPath sourcePath, String className, String namespace,
|
||||||
IBaseClassInfo[] baseClasses, IMethodStub[] methodStubs, IProgressMonitor monitor)
|
IBaseClassInfo[] baseClasses, IMethodStub[] methodStubs, IProgressMonitor monitor)
|
||||||
throws CoreException, InterruptedException {
|
throws CoreException {
|
||||||
createClass(headerPath, sourcePath, null, className, namespace, baseClasses, methodStubs,
|
createClass(headerPath, sourcePath, null, className, namespace, baseClasses, methodStubs, monitor);
|
||||||
monitor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the created class. The method only returns a valid class
|
* Returns the created class. The method only returns a valid class
|
||||||
* after <code>createClass</code> has been called.
|
* after {@link #createClass} has been called.
|
||||||
*
|
*
|
||||||
* @return the created class
|
* @return the created class
|
||||||
* @see #createClass(IProgressMonitor)
|
* @see #createClass(IProgressMonitor)
|
||||||
|
@ -2118,7 +2137,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the created header file. The method only returns a valid file
|
* Returns the created header file. The method only returns a valid file
|
||||||
* after <code>createClass</code> has been called.
|
* after {@link #createClass} has been called.
|
||||||
*
|
*
|
||||||
* @return the created header file
|
* @return the created header file
|
||||||
* @see #createClass(IProgressMonitor)
|
* @see #createClass(IProgressMonitor)
|
||||||
|
@ -2129,7 +2148,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the created source file. The method only returns a valid file
|
* Returns the created source file. The method only returns a valid file
|
||||||
* after <code>createClass</code> has been called.
|
* after {@link #createClass} has been called.
|
||||||
*
|
*
|
||||||
* @return the created source file
|
* @return the created source file
|
||||||
* @see #createClass(IProgressMonitor)
|
* @see #createClass(IProgressMonitor)
|
||||||
|
@ -2140,7 +2159,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the created test file. The method only returns a valid file
|
* Returns the created test file. The method only returns a valid file
|
||||||
* after <code>createClass</code> has been called.
|
* after {@link #createClass} has been called.
|
||||||
*
|
*
|
||||||
* @return the created test file
|
* @return the created test file
|
||||||
* @see #createClass(IProgressMonitor)
|
* @see #createClass(IProgressMonitor)
|
||||||
|
|
|
@ -10,16 +10,17 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.ui.wizards;
|
package org.eclipse.cdt.ui.wizards;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||||
import org.eclipse.cdt.internal.ui.wizards.NewElementWizard;
|
import org.eclipse.cdt.internal.ui.wizards.NewElementWizard;
|
||||||
import org.eclipse.cdt.internal.ui.wizards.folderwizard.NewFolderWizardMessages;
|
import org.eclipse.cdt.internal.ui.wizards.folderwizard.NewFolderWizardMessages;
|
||||||
import org.eclipse.cdt.internal.ui.wizards.folderwizard.NewSourceFolderWizardPage;
|
import org.eclipse.cdt.internal.ui.wizards.folderwizard.NewSourceFolderWizardPage;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
|
||||||
|
|
||||||
public class NewSourceFolderCreationWizard extends NewElementWizard {
|
public class NewSourceFolderCreationWizard extends NewElementWizard {
|
||||||
|
|
||||||
private NewSourceFolderWizardPage fPage;
|
private NewSourceFolderWizardPage fPage;
|
||||||
|
|
||||||
public NewSourceFolderCreationWizard() {
|
public NewSourceFolderCreationWizard() {
|
||||||
|
@ -29,9 +30,6 @@ public class NewSourceFolderCreationWizard extends NewElementWizard {
|
||||||
setWindowTitle(NewFolderWizardMessages.NewSourceFolderCreationWizard_title);
|
setWindowTitle(NewFolderWizardMessages.NewSourceFolderCreationWizard_title);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see Wizard#addPages
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void addPages() {
|
public void addPages() {
|
||||||
super.addPages();
|
super.addPages();
|
||||||
|
@ -40,17 +38,11 @@ public class NewSourceFolderCreationWizard extends NewElementWizard {
|
||||||
fPage.init(getSelection());
|
fPage.init(getSelection());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jdt.internal.ui.wizards.NewElementWizard#finishPage(org.eclipse.core.runtime.IProgressMonitor)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected void finishPage(IProgressMonitor monitor) throws InterruptedException, CoreException {
|
protected void finishPage(IProgressMonitor monitor) throws CoreException {
|
||||||
fPage.createSourceRoot(monitor); // use the full progress monitor
|
fPage.createSourceRoot(monitor); // Use the full progress monitor.
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.wizard.IWizard#performFinish()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean performFinish() {
|
public boolean performFinish() {
|
||||||
boolean res= super.performFinish();
|
boolean res= super.performFinish();
|
||||||
|
@ -59,5 +51,4 @@ public class NewSourceFolderCreationWizard extends NewElementWizard {
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue