1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-21 21:52:10 +02:00

Generification and other code cleanup.

Change-Id: Ifb35a80ec8cf563c5635078db947768d1a7aa6ff
This commit is contained in:
Sergey Prigogin 2016-10-06 16:24:34 -07:00
parent c8d528587e
commit 33f0522906
8 changed files with 48 additions and 62 deletions

View file

@ -12,14 +12,13 @@ package org.eclipse.cdt.managedbuilder.ui.tests;
import java.util.List;
import junit.framework.TestCase;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.ui.wizards.MBSCustomPageManager;
import org.eclipse.cdt.ui.wizards.CDTMainWizardPage;
import org.eclipse.cdt.ui.wizards.CDTProjectWizard;
import org.eclipse.cdt.ui.wizards.CWizardHandler;
import org.eclipse.cdt.ui.wizards.EntryDescriptor;
import org.eclipse.cdt.ui.wizards.IWizardItemsListListener;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jface.wizard.WizardPage;
@ -27,12 +26,13 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import junit.framework.TestCase;
/**
* Tests for the get/setSelectedProjectType() of CProjectPlatformPage.
* @author Elias Volanakis
*/
public class TestCProjectPlatformPage extends TestCase implements IWizardItemsListListener {
//TODO: migrate to the new UI functionality
private CDTProjectWizard wizard;
private TestPage page;
@ -141,7 +141,7 @@ public class TestCProjectPlatformPage extends TestCase implements IWizardItemsLi
}
@Override
public List filterItems(List items) {
public List<EntryDescriptor> filterItems(List<EntryDescriptor> items) {
return items;
}
}
@ -149,11 +149,12 @@ public class TestCProjectPlatformPage extends TestCase implements IWizardItemsLi
// methods of IToolChainListListener
@Override
public boolean isCurrent() { return currentState; }
@Override
public void toolChainListChanged(int count) {}
@Override
public List filterItems(List items) {
public List<EntryDescriptor> filterItems(List<EntryDescriptor> items) {
return items;
}
}

View file

@ -15,14 +15,14 @@ package org.eclipse.cdt.managedbuilder.ui.tests;
import java.util.ArrayList;
import java.util.List;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.eclipse.cdt.managedbuilder.ui.tests.util.TestToolchain;
import org.eclipse.cdt.managedbuilder.ui.wizards.MBSCustomPageManager;
import org.eclipse.core.runtime.NullProgressMonitor;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* This class is responsible for testing the functionality of the custom page manager (MBSCustomPageManager)
* that manages custom wizard pages that are provided by ISVs to supplement the pages in the New Project wizards
@ -36,9 +36,7 @@ import org.eclipse.core.runtime.NullProgressMonitor;
* change around what options (i.e. nature, project type, toolchain) a hypothetical user would set, and then
* check to see if the proper pages are displayed in the proper order.
*/
public class TestCustomPageManager extends TestCase
{
public class TestCustomPageManager extends TestCase {
private static final String alwaysPresentPageName = "org.eclipse.cdt.managedbuilder.ui.tests.wizardPages.AlwaysPresentWizardPage";
private static final String natureAPageName = "org.eclipse.cdt.managedbuilder.ui.tests.wizardPages.NatureAWizardPage";
private static final String natureBPageName = "org.eclipse.cdt.managedbuilder.ui.tests.wizardPages.NatureBWizardPage";
@ -70,7 +68,7 @@ public class TestCustomPageManager extends TestCase
MBSCustomPageManager.addPageProperty(MBSCustomPageManager.PAGE_ID, MBSCustomPageManager.PROJECT_TYPE, "X");
// set the toolchain to "Y"
List toolchainSet = new ArrayList();
List<TestToolchain> toolchainSet = new ArrayList<TestToolchain>();
TestToolchain toolchain = new TestToolchain();
toolchain.setID("Y");
toolchainSet.add(toolchain);
@ -146,7 +144,7 @@ public class TestCustomPageManager extends TestCase
MBSCustomPageManager.addPageProperty(MBSCustomPageManager.PAGE_ID, MBSCustomPageManager.PROJECT_TYPE, "X");
// set the toolchain to "Y"
List toolchainSet = new ArrayList();
List<TestToolchain> toolchainSet = new ArrayList<TestToolchain>();
TestToolchain toolchain = new TestToolchain();
toolchain.setID("Y");
toolchainSet.add(toolchain);
@ -233,7 +231,7 @@ public class TestCustomPageManager extends TestCase
MBSCustomPageManager.addPageProperty(MBSCustomPageManager.PAGE_ID, MBSCustomPageManager.PROJECT_TYPE, "X");
// set the toolchain to "Y"
List toolchainSet = new ArrayList();
List<TestToolchain> toolchainSet = new ArrayList<TestToolchain>();
TestToolchain toolchain = new TestToolchain();
toolchain.setID("Y");
toolchainSet.add(toolchain);
@ -320,7 +318,7 @@ public class TestCustomPageManager extends TestCase
MBSCustomPageManager.addPageProperty(MBSCustomPageManager.PAGE_ID, MBSCustomPageManager.PROJECT_TYPE, "X");
// set the toolchain to "C"
List toolchainSet = new ArrayList();
List<TestToolchain> toolchainSet = new ArrayList<TestToolchain>();
TestToolchain toolchain = new TestToolchain();
toolchain.setID("C");
toolchainSet.add(toolchain);
@ -408,7 +406,7 @@ public class TestCustomPageManager extends TestCase
MBSCustomPageManager.addPageProperty(MBSCustomPageManager.PAGE_ID, MBSCustomPageManager.PROJECT_TYPE, "X");
// set the toolchain to "C"
List toolchainSet = new ArrayList();
List<TestToolchain> toolchainSet = new ArrayList<TestToolchain>();
TestToolchain toolchain = new TestToolchain();
toolchain.setID("C_2.0.0");
toolchainSet.add(toolchain);
@ -510,7 +508,7 @@ public class TestCustomPageManager extends TestCase
MBSCustomPageManager.addPageProperty(MBSCustomPageManager.PAGE_ID, MBSCustomPageManager.PROJECT_TYPE, "D");
// set the toolchain to "Y"
List toolchainSet = new ArrayList();
List<TestToolchain> toolchainSet = new ArrayList<TestToolchain>();
TestToolchain toolchain = new TestToolchain();
toolchain.setID("Y");
toolchainSet.add(toolchain);
@ -600,7 +598,7 @@ public class TestCustomPageManager extends TestCase
MBSCustomPageManager.addPageProperty(MBSCustomPageManager.PAGE_ID, MBSCustomPageManager.PROJECT_TYPE, "E");
// set the toolchain to "Y"
List toolchainSet = new ArrayList();
List<TestToolchain> toolchainSet = new ArrayList<TestToolchain>();
TestToolchain toolchain = new TestToolchain();
toolchain.setID("Y");
toolchainSet.add(toolchain);
@ -682,13 +680,12 @@ public class TestCustomPageManager extends TestCase
/**
* Set the toolchain to "F". Only pages with no contraints or toolchains set to "F" should show up.
*/
public void testToolchainF()
{
public void testToolchainF() {
// set the project type to be "X"
MBSCustomPageManager.addPageProperty(MBSCustomPageManager.PAGE_ID, MBSCustomPageManager.PROJECT_TYPE, "X");
// set the toolchain to "F"
List toolchainSet = new ArrayList();
List<TestToolchain> toolchainSet = new ArrayList<TestToolchain>();
TestToolchain toolchain = new TestToolchain();
toolchain.setID("F");
toolchainSet.add(toolchain);
@ -776,7 +773,7 @@ public class TestCustomPageManager extends TestCase
MBSCustomPageManager.addPageProperty(MBSCustomPageManager.PAGE_ID, MBSCustomPageManager.PROJECT_TYPE, "D");
// set the toolchain to "C"
List toolchainSet = new ArrayList();
List<TestToolchain> toolchainSet = new ArrayList<TestToolchain>();
TestToolchain toolchain = new TestToolchain();
toolchain.setID("C");
toolchainSet.add(toolchain);

View file

@ -51,7 +51,6 @@ import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
* @noinstantiate This class is not intended to be instantiated by clients.
*/
public class ConvertToMakeWizardPage extends ConvertProjectWizardPage {
private static final String WZ_TITLE = "WizardMakeProjectConversion.title"; //$NON-NLS-1$
private static final String WZ_DESC = "WizardMakeProjectConversion.description"; //$NON-NLS-1$
@ -147,12 +146,10 @@ public class ConvertToMakeWizardPage extends ConvertProjectWizardPage {
gd.horizontalSpan = 2;
show_sup.setLayoutData(gd);
final IWizardItemsListListener filter = new IWizardItemsListListener() {
// Show only category
@Override
public List<EntryDescriptor> filterItems(
List<? extends EntryDescriptor> items) {
List<EntryDescriptor> results = new ArrayList<EntryDescriptor>();
public List<EntryDescriptor> filterItems(List<EntryDescriptor> items) {
List<EntryDescriptor> results = new ArrayList<>();
for (EntryDescriptor entry : items) {
if (entry.isCategory()) {

View file

@ -183,7 +183,7 @@ public class CoreModel {
public boolean isObject(IFile file) {
ICElement celement = create(file);
if (celement instanceof IBinary) {
return ((IBinary)celement).isObject();
return ((IBinary) celement).isObject();
}
return false;
}
@ -194,7 +194,7 @@ public class CoreModel {
public boolean isExecutable(IFile file) {
ICElement celement = create(file);
if (celement instanceof IBinary) {
return ((IBinary)celement).isExecutable();
return ((IBinary) celement).isExecutable();
}
return false;
}
@ -204,7 +204,7 @@ public class CoreModel {
*/
public boolean isBinary(IFile file) {
ICElement celement = create(file);
return (celement instanceof IBinary);
return celement instanceof IBinary;
}
/**
@ -212,7 +212,7 @@ public class CoreModel {
*/
public boolean isArchive(IFile file) {
ICElement celement = create(file);
return(celement instanceof IArchive);
return celement instanceof IArchive;
}
/**
@ -494,7 +494,6 @@ public class CoreModel {
return new LibraryEntry(resourcePath, null, baseRef, libraryPath, null, null, null, false);
}
/**
* Creates and returns a new entry of kind {@code CDT_LIBRARY}
* for the archive or folder identified by the given absolute path.
@ -665,7 +664,7 @@ public class CoreModel {
* @param includePath
* the path of the include
* @param isSystemInclude
* wheter this include path should be consider the system
* whether this include path should be consider the system
* include path
* @param exclusionPatterns
* exclusion patterns in the resource if a container
@ -1328,7 +1327,7 @@ public class CoreModel {
}
/**
* this method is a full equivalent to {@code createProjectDescription(project, loadIfExists, false)}.
* This method is a full equivalent to {@code createProjectDescription(project, loadIfExists, false)}.
*
* @see #createProjectDescription(IProject, boolean, boolean)
*/
@ -1337,7 +1336,7 @@ public class CoreModel {
}
/**
* the method creates and returns a writable project description
* Creates and returns a writable project description
*
* @param project project for which the project description is requested
* @param loadIfExists if true the method first tries to load and return the project description
@ -1356,7 +1355,7 @@ public class CoreModel {
}
/**
* returns the project description associated with this project or null if the project does not contain the
* Returns the project description associated with this project or null if the project does not contain the
* CDT data associated with it.
*
* this is a convenience method fully equivalent to getProjectDescription(project, true)
@ -1374,7 +1373,7 @@ public class CoreModel {
}
/**
* this method is called to save/apply the project description
* This method is called to save/apply the project description
* the method should be called to apply changes made to the project description
* returned by the {@link #getProjectDescription(IProject, boolean)} or {@link #createProjectDescription(IProject, boolean)}
*
@ -1407,7 +1406,7 @@ public class CoreModel {
* All set* calls to the read-only description result in the {@link WriteAccessException}
*
* When the writable description is requested, the description copy is created.
* Changes to this description will not be reflected/used by the core and Build System untill the
* Changes to this description will not be reflected/used by the core and Build System until the
* {@link #setProjectDescription(IProject, ICProjectDescription)} is called
*
* Each getProjectDescription(project, true) returns a new copy of the project description
@ -1465,7 +1464,7 @@ public class CoreModel {
if (descriptionManager != null)
return descriptionManager;
// Initialization of the CoreModel hasn't finished yet.
// The method was called while initialization of the CoreModel hasn't finished yet.
return CProjectDescriptionManager.getInstance();
}
}

View file

@ -18,8 +18,7 @@ import java.lang.reflect.Method;
/**
* This class contains several convenience methods
* mainly for debugging purposes.
* This class contains several convenience methods mainly for debugging purposes.
*
* @noextend This interface is not intended to be extended by clients.
* @noinstantiate This class is not intended to be instantiated by clients.
@ -93,7 +92,7 @@ public class DebugUtil {
System.out.println("Object: " + obj);
BeanInfo info = Introspector.getBeanInfo(obj.getClass());
for(PropertyDescriptor propertyDescriptor : info.getPropertyDescriptors()) {
for (PropertyDescriptor propertyDescriptor : info.getPropertyDescriptors()) {
Method getter = propertyDescriptor.getReadMethod();
try {
System.out.println(" " + getter.getName() + "=" + getter.invoke(obj, new Object[0]));

View file

@ -517,8 +517,7 @@ public class CDTMainWizardPage extends WizardNewProjectCreationPage implements I
}
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public List filterItems(List items) {
public List<EntryDescriptor> filterItems(List<EntryDescriptor> items) {
return items;
}
}

View file

@ -20,29 +20,25 @@ import java.util.List;
*/
public interface IWizardItemsListListener {
/**
* Called by ICNewWizard instance when
* user has changed tool chains selection
* Called by ICNewWizard instance when user has changed tool chains selection.
*
* @param count - number of selected toolchains.
*/
void toolChainListChanged(int count);
/**
* @return true if this page is visible
*/
boolean isCurrent();
/**
* Ability to filter items which would be shown
* in the left pane of Main Wizard Page.
* Standard implementation: return unchanged list.
* When filtering, please note :
* - Each item has {@link}EntryDescriptor type
* - Items have hierarchical relations with others,
* so removing some item(s) can break a tree.
*
* Ability to filter items which would be shown in the left pane of Main Wizard Page.
* Standard implementation: returns unchanged list. When filtering, please note that
* the items have hierarchical relations with others, so removing some item(s) can
* break a tree.
*
* @param items - list of EntryDescriptor objects
* @return - list with filtered items
*/
List<EntryDescriptor> filterItems(List<? extends EntryDescriptor> items);
List<EntryDescriptor> filterItems(List<EntryDescriptor> items);
}

View file

@ -61,15 +61,13 @@ public class UpcProjectWizard extends CDTCommonProjectWizard {
@Override
public void addPages() {
fMainPage = new CDTMainWizardPage(PAGE_NAME) {
@Override
@SuppressWarnings("unchecked")
public List filterItems(List items) {
public List<EntryDescriptor> filterItems(List<EntryDescriptor> items) {
// filter out all non-UPC project types
if (items != null) {
Iterator iter = items.iterator();
Iterator<EntryDescriptor> iter = items.iterator();
while (iter.hasNext()) {
EntryDescriptor entryDescriptor = (EntryDescriptor) iter.next();
EntryDescriptor entryDescriptor = iter.next();
if(!ALL_TYPES.contains(entryDescriptor.getId()))
iter.remove();
}