Skip to content

Commit

Permalink
ImportExistingArchiveProjectFilterTest: fix leaked shells
Browse files Browse the repository at this point in the history
  • Loading branch information
EcljpseB0T authored and jukzi committed Oct 10, 2024
1 parent 3cddf27 commit 83bf670
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.WorkbenchPlugin;
import org.eclipse.ui.internal.dialogs.ImportExportWizard;
import org.eclipse.ui.internal.wizards.datatransfer.WizardProjectsImportPage;
import org.eclipse.ui.internal.wizards.datatransfer.WizardProjectsImportPage.ProjectRecord;
import org.eclipse.ui.navigator.resources.ProjectExplorer;
import org.eclipse.ui.tests.TestPlugin;
import org.eclipse.ui.tests.harness.util.DialogCheck;
import org.eclipse.ui.tests.harness.util.EmptyPerspective;
import org.eclipse.ui.tests.harness.util.FileUtil;
import org.eclipse.ui.tests.harness.util.UITestCase;
Expand All @@ -66,6 +66,10 @@ public ImportExistingArchiveProjectFilterTest() {

@Override
protected void doTearDown() throws Exception {
if (dialog != null) {
dialog.close();
dialog = null;
}
IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
IProject[] projects = wsRoot.getProjects();
for (int i = projects.length - 1; i >= 0; i--) {
Expand Down Expand Up @@ -158,6 +162,7 @@ private void processElementAndChildren(Object element, ITreeContentProvider cont
}
}

private WizardDialog dialog;
public WizardProjectsImportPage getNewWizard() {
ImportExportWizard wizard = new ImportExportWizard(ImportExportWizard.IMPORT);
wizard.init(getWorkbench(), null);
Expand All @@ -173,7 +178,10 @@ public WizardProjectsImportPage getNewWizard() {

Shell shell = getShell();

WizardDialog dialog = new WizardDialog(shell, wizard);
if (dialog != null) {
dialog.close();
}
dialog = new WizardDialog(shell, wizard);
dialog.create();
dialog.getShell().setSize(Math.max(100, dialog.getShell().getSize().x), 100);

Expand All @@ -185,6 +193,6 @@ public WizardProjectsImportPage getNewWizard() {
}

private Shell getShell() {
return DialogCheck.getShell();
return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
}
}

0 comments on commit 83bf670

Please sign in to comment.