Author: dgolovin
Date: 2011-08-05 20:17:32 -0400 (Fri, 05 Aug 2011)
New Revision: 33646
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewAnnotationLiteralCreationWizard.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeansXMLCreationWizard.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewCDIElementWizard.java
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/pom.xml
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CATest.java
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CDIUIAllTests.java
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/TCKUITest.java
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/wizard/NewCDIWizardTest.java
Log:
Minor performance improvements for cdi tests. Opening editor after finishing wizards is
now configurable. Wizards don't open editors during tests and it should save some
time
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewAnnotationLiteralCreationWizard.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewAnnotationLiteralCreationWizard.java 2011-08-06
00:15:14 UTC (rev 33645)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewAnnotationLiteralCreationWizard.java 2011-08-06
00:17:32 UTC (rev 33646)
@@ -23,51 +23,67 @@
/**
*
* @author Viacheslav Kabanovich
- *
+ *
*/
public class NewAnnotationLiteralCreationWizard extends NewElementWizard {
private NewClassWizardPage fPage;
- private boolean fOpenEditorOnFinish = true;
+ private boolean fOpenEditorOnFinish = true;
-
public NewAnnotationLiteralCreationWizard() {
setWindowTitle(CDIUIMessages.NEW_ANNOTATION_LITERAL_WIZARD_TITLE);
}
+ public boolean isOpenEditorAfterFinish() {
+ return fOpenEditorOnFinish;
+ }
+
+ public void setOpenEditorAfterFinish(boolean set) {
+ this.fOpenEditorOnFinish = set;
+ }
+
/*
* @see Wizard#createPages
*/
public void addPages() {
super.addPages();
if (fPage == null) {
- fPage = new NewAnnotationLiteralWizardPage();
+ fPage = new NewAnnotationLiteralWizardPage();
fPage.init(getSelection());
}
addPage(fPage);
}
- /*(non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.jdt.internal.ui.wizards.NewElementWizard#canRunForked()
*/
protected boolean canRunForked() {
return !fPage.isEnclosingTypeSelected();
}
- /* (non-Javadoc)
- * @see
org.eclipse.jdt.internal.ui.wizards.NewElementWizard#finishPage(org.eclipse.core.runtime.IProgressMonitor)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jdt.internal.ui.wizards.NewElementWizard#finishPage(org.eclipse
+ * .core.runtime.IProgressMonitor)
*/
- protected void finishPage(IProgressMonitor monitor) throws InterruptedException,
CoreException {
+ protected void finishPage(IProgressMonitor monitor)
+ throws InterruptedException, CoreException {
fPage.createType(monitor); // use the full progress monitor
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.jface.wizard.IWizard#performFinish()
*/
public boolean performFinish() {
warnAboutTypeCommentDeprecation();
- boolean res= super.performFinish();
+ boolean res = super.performFinish();
if (res) {
- IResource resource= fPage.getModifiedResource();
+ IResource resource = fPage.getModifiedResource();
if (resource != null) {
selectAndReveal(resource);
if (fOpenEditorOnFinish) {
@@ -78,12 +94,14 @@
return res;
}
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.ui.wizards.NewElementWizard#getCreatedElement()
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jdt.internal.ui.wizards.NewElementWizard#getCreatedElement()
*/
public IJavaElement getCreatedElement() {
return fPage.getCreatedType();
}
-
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeansXMLCreationWizard.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeansXMLCreationWizard.java 2011-08-06
00:15:14 UTC (rev 33645)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeansXMLCreationWizard.java 2011-08-06
00:17:32 UTC (rev 33646)
@@ -56,6 +56,8 @@
private WizardNewFileCreationPage mainPage;
+ private boolean fOpenEditorOnFinish;
+
/**
* Creates a wizard for creating a new file resource in the workspace.
*/
@@ -95,34 +97,41 @@
setDefaultPageImageDescriptor(desc);
}
- /* (non-Javadoc)
- * Method declared on IWizard.
- */
- public boolean performFinish() {
- IFile file = mainPage.createNewFile();
- if (file == null) {
+ public boolean isOpenEditorAfterFinish() {
+ return fOpenEditorOnFinish;
+ }
+
+ public void setOpenEditorAfterFinish(boolean set) {
+ this.fOpenEditorOnFinish = set;
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IWizard.
+ */
+ public boolean performFinish() {
+ IFile file = mainPage.createNewFile();
+ if (file == null) {
return false;
}
- selectAndReveal(file);
+ selectAndReveal(file);
+ if (fOpenEditorOnFinish) {
+ // Open editor on new file.
+ IWorkbenchWindow dw = getWorkbench().getActiveWorkbenchWindow();
+ try {
+ if (dw != null) {
+ IWorkbenchPage page = dw.getActivePage();
+ if (page != null) {
+ IDE.openEditor(page, file, true);
+ }
+ }
+ } catch (PartInitException e) {
+ DialogUtil.openError(dw.getShell(), ResourceMessages.FileResource_errorMessage,
e.getMessage(), e);
+ }
+ }
+ return true;
+ }
- // Open editor on new file.
- IWorkbenchWindow dw = getWorkbench().getActiveWorkbenchWindow();
- try {
- if (dw != null) {
- IWorkbenchPage page = dw.getActivePage();
- if (page != null) {
- IDE.openEditor(page, file, true);
- }
- }
- } catch (PartInitException e) {
- DialogUtil.openError(dw.getShell(),
ResourceMessages.FileResource_errorMessage,
- e.getMessage(), e);
- }
-
- return true;
- }
-
class WizardNewBeansXMLFileCreationPage extends WizardNewFileCreationPage {
public WizardNewBeansXMLFileCreationPage(String pageName, IStructuredSelection
selection) {
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewCDIElementWizard.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewCDIElementWizard.java 2011-08-06
00:15:14 UTC (rev 33645)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewCDIElementWizard.java 2011-08-06
00:17:32 UTC (rev 33646)
@@ -23,6 +23,14 @@
this.adapter = adapter;
}
+ public boolean isOpenEditorAfterFinish() {
+ return fOpenEditorOnFinish;
+ }
+
+ public void setOpenEditorAfterFinish(boolean set) {
+ this.fOpenEditorOnFinish = set;
+ }
+
public String getQualifiedClassName() {
IType type = fPage.getCreatedType();
return type == null ? "" : type.getFullyQualifiedName();
Modified: trunk/cdi/tests/org.jboss.tools.cdi.ui.test/pom.xml
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.ui.test/pom.xml 2011-08-06 00:15:14 UTC (rev
33645)
+++ trunk/cdi/tests/org.jboss.tools.cdi.ui.test/pom.xml 2011-08-06 00:17:32 UTC (rev
33646)
@@ -30,4 +30,21 @@
</plugin>
</plugins>
</build>
+
+ <profiles>
+ <profile>
+ <id>profiler</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.sonatype.tycho</groupId>
+ <artifactId>maven-osgi-test-plugin</artifactId>
+ <configuration>
+ <argLine>-XX:+UseLinuxPosixThreadCPUClocks
-agentpath:/home/eskimo/Java/netbeans-7.0.1/profiler/lib/deployed/jdk16/linux-amd64/libprofilerinterface.so=/home/eskimo/Java/netbeans-7.0.1/profiler/lib,5140</argLine>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
</project>
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CATest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CATest.java 2011-08-06
00:15:14 UTC (rev 33645)
+++
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CATest.java 2011-08-06
00:17:32 UTC (rev 33646)
@@ -30,7 +30,7 @@
public CATest() {
super();
try {
- project = TCKTest.importPreparedProject("/tests/lookup");
+ project = TCKUITest.importPreparedProject("/tests/lookup");
caTest.setProject(project);
} catch (Exception e) {
e.printStackTrace();
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CDIUIAllTests.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CDIUIAllTests.java 2011-08-06
00:15:14 UTC (rev 33645)
+++
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CDIUIAllTests.java 2011-08-06
00:17:32 UTC (rev 33646)
@@ -14,6 +14,7 @@
import junit.framework.TestSuite;
import org.apache.xerces.impl.validation.ValidationManager;
+import org.eclipse.core.internal.jobs.JobManager;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -48,7 +49,6 @@
public static Test suite() {
// it could be done here because it is not needed to be enabled back
JavaModelManager.getIndexManager().shutdown();
-
try {
ResourcesUtils.setBuildAutomatically(false);
ValidationFramework.getDefault().suspendAllValidation(true);
@@ -73,6 +73,9 @@
protected void setUp() throws Exception {
tckProject = TCKUITest.importPreparedProject("/");
}
+ protected void tearDown() throws Exception {
+ tckProject.delete(true, true, null);
+ }
}
);
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/TCKUITest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/TCKUITest.java 2011-08-06
00:15:14 UTC (rev 33645)
+++
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/TCKUITest.java 2011-08-06
00:17:32 UTC (rev 33646)
@@ -3,9 +3,11 @@
import java.io.File;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
@@ -61,6 +63,8 @@
File webInfTo = new File(projectPath + WEB_CONTENT_SUFFIX + WEB_INF_SUFFIX);
FileUtil.copyDir(from, webInfTo, true, true, true, new XmlFileFilter());
}
+
+ project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
project.build(IncrementalProjectBuilder.CLEAN_BUILD,null);
project.build(IncrementalProjectBuilder.FULL_BUILD,null);
TestUtil._waitForValidation(project);
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/wizard/NewCDIWizardTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/wizard/NewCDIWizardTest.java 2011-08-06
00:15:14 UTC (rev 33645)
+++
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/wizard/NewCDIWizardTest.java 2011-08-06
00:17:32 UTC (rev 33646)
@@ -30,7 +30,6 @@
import org.eclipse.jdt.ui.wizards.NewTypeWizardPage;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.osgi.util.NLS;
import org.eclipse.ui.PlatformUI;
@@ -43,10 +42,11 @@
import org.jboss.tools.cdi.core.IStereotype;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.CDIUIPlugin;
-//import org.jboss.tools.cdi.ui.wizard.NewCDIAnnotationWizardPage;
+import org.jboss.tools.cdi.ui.wizard.NewAnnotationLiteralCreationWizard;
import org.jboss.tools.cdi.ui.wizard.NewAnnotationLiteralWizardPage;
import org.jboss.tools.cdi.ui.wizard.NewBeanWizardPage;
import org.jboss.tools.cdi.ui.wizard.NewBeansXMLCreationWizard;
+import org.jboss.tools.cdi.ui.wizard.NewCDIElementWizard;
import org.jboss.tools.cdi.ui.wizard.NewDecoratorWizardPage;
import org.jboss.tools.cdi.ui.wizard.NewInterceptorBindingWizardPage;
import org.jboss.tools.cdi.ui.wizard.NewInterceptorWizardPage;
@@ -58,7 +58,6 @@
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.util.FileUtil;
import org.jboss.tools.test.util.JUnitUtils;
-import org.jboss.tools.test.util.JobUtils;
import org.jboss.tools.test.util.WorkbenchUtils;
/**
@@ -95,6 +94,11 @@
tck = ResourcesPlugin.getWorkspace().getRoot().getProject("tck");
jp = EclipseUtil.getJavaProject(tck);
wizard.init(CDIUIPlugin.getDefault().getWorkbench(), new StructuredSelection(jp));
+ if(wizard instanceof NewCDIElementWizard) {
+ ((NewCDIElementWizard)wizard).setOpenEditorAfterFinish(false);
+ } else if(wizard instanceof NewAnnotationLiteralCreationWizard) {
+ ((NewAnnotationLiteralCreationWizard)wizard).setOpenEditorAfterFinish(false);
+ }
dialog = new WizardDialog(
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
wizard);
@@ -151,6 +155,7 @@
dialog = new WizardDialog(
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
wizard);
+ wizard.setOpenEditorAfterFinish(false);
dialog.setBlockOnOpen(false);
dialog.open();
}