diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog.java
index 5cae83cb0b5..d52441a03f7 100644
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog.java
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog.java
@@ -48,7 +48,6 @@ import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.ui.util.StringMatcher;
-
/**
* A dialog to select a type from a list of types.
*
@@ -264,20 +263,19 @@ public class TypeSelectionDialog extends TwoPaneElementSelector {
public void setVisibleTypes(int[] types) {
fKnownTypes.clear();
for (int i = 0; i < types.length; ++i) {
- fKnownTypes.add(new Integer(types[i]));
+ fKnownTypes.add(types[i]);
}
}
/**
* Answer whether the given type is visible in the dialog.
*
- * @param type
- * the type constant, see {@link ICElement}
+ * @param type the type constant, see {@link ICElement}
* @return true
if the given type is visible,
* false
otherwise
*/
protected boolean isVisibleType(int type) {
- return fKnownTypes.contains(new Integer(type));
+ return fKnownTypes.contains(type);
}
/**
@@ -436,8 +434,7 @@ public class TypeSelectionDialog extends TwoPaneElementSelector {
upperLayout.marginWidth = 0;
upperRow.setLayout(upperLayout);
- // the for loop is here to guarantee we always
- // create the checkboxes in the same order
+ // The 'for' loop is here to guarantee that we always create the checkboxes in the same order.
for (int i = 0; i < ALL_TYPES.length; ++i) {
Integer typeObject = new Integer(ALL_TYPES[i]);
if (fKnownTypes.contains(typeObject))
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewBaseClassSelectionDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewBaseClassSelectionDialog.java
index 6fef55a6c2a..d605c0db3b1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewBaseClassSelectionDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewBaseClassSelectionDialog.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2008 QNX Software Systems and others.
+ * Copyright (c) 2004, 2011 QNX Software Systems 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
@@ -7,6 +7,7 @@
*
* Contributors:
* QNX Software Systems - initial API and implementation
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.wizards.classwizard;
@@ -16,8 +17,9 @@ import java.util.List;
import org.eclipse.cdt.core.browser.ITypeInfo;
import org.eclipse.cdt.core.model.ICElement;
+
+import org.eclipse.cdt.internal.ui.browser.opentype.ElementSelectionDialog;
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.osgi.util.NLS;
@@ -26,39 +28,37 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.progress.IProgressService;
-public class NewBaseClassSelectionDialog extends TypeSelectionDialog {
-
+public class NewBaseClassSelectionDialog extends ElementSelectionDialog {
private static final String DIALOG_SETTINGS = NewBaseClassSelectionDialog.class.getName();
private static final int[] VISIBLE_TYPES = { ICElement.C_CLASS, ICElement.C_STRUCT };
private static final int ADD_ID = IDialogConstants.CLIENT_ID + 1;
private List fTypeList;
private List fTypeListeners;
-
+
public interface ITypeSelectionListener {
void typeAdded(ITypeInfo baseClass);
}
-
+
public NewBaseClassSelectionDialog(Shell parent) {
super(parent);
setTitle(NewClassWizardMessages.NewBaseClassSelectionDialog_title);
setMessage(NewClassWizardMessages.NewBaseClassSelectionDialog_message);
setDialogSettings(DIALOG_SETTINGS);
setVisibleTypes(VISIBLE_TYPES);
- setFilter("*", true); //$NON-NLS-1$
setStatusLineAboveButtons(true);
fTypeList = new ArrayList();
fTypeListeners = new ArrayList();
}
-
+
public void addListener(ITypeSelectionListener listener) {
if (!fTypeListeners.contains(listener))
fTypeListeners.add(listener);
}
-
+
public void removeListener(ITypeSelectionListener listener) {
fTypeListeners.remove(listener);
}
-
+
private void notifyTypeAddedListeners(ITypeInfo type) {
// first copy listeners in case one calls removeListener
List list = new ArrayList(fTypeListeners);
@@ -67,7 +67,7 @@ public class NewBaseClassSelectionDialog extends TypeSelectionDialog {
listener.typeAdded(type);
}
}
-
+
public ITypeInfo[] getAddedTypes() {
return fTypeList.toArray(new ITypeInfo[fTypeList.size()]);
}
@@ -80,7 +80,7 @@ public class NewBaseClassSelectionDialog extends TypeSelectionDialog {
createButton(parent, ADD_ID, NewClassWizardMessages.NewBaseClassSelectionDialog_addButton_label, true);
super.createButtonsForButtonBar(parent);
}
-
+
/*
* @see Dialog#buttonPressed
*/
@@ -91,7 +91,7 @@ public class NewBaseClassSelectionDialog extends TypeSelectionDialog {
}
super.buttonPressed(buttonId);
}
-
+
/*
* @see Dialog#okPressed
*/
@@ -100,7 +100,7 @@ public class NewBaseClassSelectionDialog extends TypeSelectionDialog {
addType(getLowerSelectedElement());
super.okPressed();
}
-
+
private void addType(Object elem) {
if (elem instanceof ITypeInfo) {
ITypeInfo type = (ITypeInfo)elem;
@@ -119,8 +119,8 @@ public class NewBaseClassSelectionDialog extends TypeSelectionDialog {
NewClassWizardUtil.resolveClassLocation(type, service);
canAdd = (type.getResolvedReference() != null);
}
-
-// // resolve location of base class
+
+// // Resolve location of base class
// if (type.getResolvedReference() == null) {
// final ITypeInfo[] typesToResolve = new ITypeInfo[] { type };
// IRunnableWithProgress runnable = new IRunnableWithProgress() {
@@ -131,7 +131,7 @@ public class NewBaseClassSelectionDialog extends TypeSelectionDialog {
// }
// }
// };
-//
+//
// IProgressService service = PlatformUI.getWorkbench().getProgressService();
// try {
// service.busyCursorWhile(runnable);
@@ -140,13 +140,13 @@ public class NewBaseClassSelectionDialog extends TypeSelectionDialog {
// String errorMessage= NewClassWizardMessages.getString("NewBaseClassSelectionDialog.getClasses.exception.message"); //$NON-NLS-1$
// ExceptionHandler.handle(e, title, errorMessage);
// } catch (InterruptedException e) {
-// // cancelled by user
+// // Cancelled by user
// }
// }
-
+
if (canAdd) {
fTypeList.add(type);
-
+
message = NLS.bind(NewClassWizardMessages.NewBaseClassSelectionDialog_classadded_info, qualifiedName);
updateStatus(new StatusInfo(IStatus.INFO, message));
@@ -158,16 +158,16 @@ public class NewBaseClassSelectionDialog extends TypeSelectionDialog {
}
}
}
-
+
/**
- * Checks if the base classes need to be verified (ie they must exist in the project)
+ * Checks if the base classes need to be verified (i.e. they must exist in the project)
*
* @return true
if the base classes should be verified
*/
public boolean verifyBaseClasses() {
return NewClassWizardPrefs.verifyBaseClasses();
}
-
+
/*
* @see AbstractElementListSelectionDialog#handleDefaultSelected()
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.java
index 3c1510f2046..b2cd29b36cf 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.java
@@ -17,8 +17,6 @@ public final class NewClassWizardMessages extends NLS {
public static String NewClassCreationWizard_title;
public static String NewClassCreationWizardPage_title;
public static String NewClassCreationWizardPage_description;
- public static String NewClassCreationWizardPage_getTypes_noClasses_title;
- public static String NewClassCreationWizardPage_getTypes_noClasses_message;
public static String NewClassCreationWizardPage_getTypes_noNamespaces_title;
public static String NewClassCreationWizardPage_getTypes_noNamespaces_message;
public static String NewClassCreationWizardPage_sourceFolder_label;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.properties
index db06f35dc59..ff35ba93539 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.properties
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.properties
@@ -7,7 +7,7 @@
#
# Contributors:
# QNX Software Systems - Initial API and implementation
-# IBM Corporation
+# IBM Corporation
# Anton Leherbauer (Wind River Systems)
# Sergey Prigogin (Google)
###############################################################################
@@ -19,8 +19,6 @@ NewClassCreationWizard_title=New C++ Class
NewClassCreationWizardPage_title=C++ Class
NewClassCreationWizardPage_description=Create a new C++ class.
-NewClassCreationWizardPage_getTypes_noClasses_title=Class Selection
-NewClassCreationWizardPage_getTypes_noClasses_message=No classes available.
NewClassCreationWizardPage_getTypes_noNamespaces_title=Namespace Selection
NewClassCreationWizardPage_getTypes_noNamespaces_message=No namespaces available.
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java
index 3beb305e7df..a479240e672 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java
@@ -13,11 +13,7 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.wizards.classwizard;
-import java.util.ArrayList;
-import java.util.List;
-
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -34,11 +30,9 @@ import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.views.contentoutline.ContentOutline;
import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.browser.AllTypesCache;
import org.eclipse.cdt.core.browser.IQualifiedTypeName;
import org.eclipse.cdt.core.browser.ITypeInfo;
import org.eclipse.cdt.core.browser.ITypeReference;
-import org.eclipse.cdt.core.browser.TypeSearchScope;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IBinding;
@@ -56,8 +50,6 @@ import org.eclipse.cdt.core.model.ICContainer;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.ISourceRoot;
-import org.eclipse.cdt.core.parser.IScannerInfo;
-import org.eclipse.cdt.core.parser.IScannerInfoProvider;
import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.ui.CUIPlugin;
@@ -65,7 +57,6 @@ import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.cdt.internal.ui.viewsupport.IViewPartInputProvider;
public class NewClassWizardUtil {
-
/**
* Returns the parent source folder of the given element. If the given
* element is already a source folder, the element itself is returned.
@@ -276,41 +267,6 @@ public class NewClassWizardUtil {
return type.getResolvedReference();
}
- private static final int[] CLASS_TYPES = { ICElement.C_CLASS, ICElement.C_STRUCT };
-
- /**
- * Returns all classes/structs which are accessible from the include
- * paths of the given project.
- *
- * @param cProject the given project
- * @return array of classes/structs
- */
- public static ITypeInfo[] getReachableClasses(ICProject cProject) {
- ITypeInfo[] elements = AllTypesCache.getTypes(new TypeSearchScope(true), CLASS_TYPES);
- if (elements != null && elements.length > 0) {
- if (cProject != null) {
- IProject project = cProject.getProject();
- IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project);
- if (provider != null) {
- //TODO get the scanner info for the actual source folder
- IScannerInfo info = provider.getScannerInformation(project);
- if (info != null) {
- String[] includePaths = info.getIncludePaths();
- List filteredTypes = new ArrayList();
- for (int i = 0; i < elements.length; ++i) {
- ITypeInfo baseType = elements[i];
- if (isTypeReachable(baseType, cProject, includePaths)) {
- filteredTypes.add(baseType);
- }
- }
- return filteredTypes.toArray(new ITypeInfo[filteredTypes.size()]);
- }
- }
- }
- }
- return elements;
- }
-
/**
* Checks whether the given type can be found in the given project or the
* given include paths.
@@ -402,7 +358,7 @@ public class NewClassWizardUtil {
boolean sameNameDifferentTypeExists = false;
for (int i = 0; i < bindings.length; ++i) {
- ICPPBinding binding = (ICPPBinding)bindings[i];
+ ICPPBinding binding = (ICPPBinding) bindings[i];
//get the fully qualified name of this binding
String bindingFullName = renderQualifiedName(binding.getQualifiedName());
@@ -424,8 +380,7 @@ public class NewClassWizardUtil {
IEnumeration.class.isAssignableFrom(currentNodeType) || // TODO - this should maybe be ICPPEnumeration
ICPPNamespace.class.isAssignableFrom(currentNodeType) ||
ITypedef.class.isAssignableFrom(currentNodeType) ||
- ICPPBasicType.class.isAssignableFrom(currentNodeType))
- {
+ ICPPBasicType.class.isAssignableFrom(currentNodeType)) {
if (bindingFullName.equals(fullyQualifiedTypeName)) {
return SEARCH_MATCH_FOUND_EXACT_ANOTHER_TYPE;
}
@@ -446,8 +401,7 @@ public class NewClassWizardUtil {
return SEARCH_MATCH_ERROR;
}
return SEARCH_MATCH_NOTFOUND;
- }
- finally {
+ } finally {
index.releaseReadLock();
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java
index f57fb9261cb..ae4f03403c3 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java
@@ -1178,14 +1178,6 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
}
private void chooseBaseClasses() {
- ITypeInfo[] elements = NewClassWizardUtil.getReachableClasses(getCurrentProject());
- if (elements == null || elements.length == 0) {
- String title = NewClassWizardMessages.NewClassCreationWizardPage_getTypes_noClasses_title;
- String message = NewClassWizardMessages.NewClassCreationWizardPage_getTypes_noClasses_message;
- MessageDialog.openInformation(getShell(), title, message);
- return;
- }
-
List oldContents = fBaseClassesDialogField.getElements();
NewBaseClassSelectionDialog dialog = new NewBaseClassSelectionDialog(getShell());
dialog.addListener(new ITypeSelectionListener() {
@@ -1193,16 +1185,15 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
addBaseClass(newBaseClass, ASTAccessVisibility.PUBLIC, false);
}
});
- dialog.setElements(elements);
int result = dialog.open();
if (result != IDialogConstants.OK_ID) {
- // restore the old contents
+ // Restore the old contents
fBaseClassesDialogField.setElements(oldContents);
}
}
/**
- * handles changes to the method stubs field
+ * Handles changes to the method stubs field
*/
private final class MethodStubsFieldAdapter implements IListAdapter {
@@ -1667,7 +1658,6 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
ICProject project = getCurrentProject();
if (project != null) {
-
IQualifiedTypeName fullyQualifiedName = typeName;
if (isNamespaceSelected()) {
String namespace = getNamespaceText();
@@ -1745,7 +1735,8 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
ITypeInfo baseType = baseClass.getType();
StatusInfo baseClassStatus = new StatusInfo();
if (!NewClassWizardUtil.isTypeReachable(baseType, project, includePaths)) {
- baseClassStatus.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_BaseClassNotExistsInProject, baseType.getQualifiedTypeName().toString()));
+ baseClassStatus.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_BaseClassNotExistsInProject,
+ baseType.getQualifiedTypeName().toString()));
}
status.add(baseClassStatus);
}