]> git.uio.no Git - ifi-stolz-refaktor.git/blame - case-study/jdt-after/ui/org/eclipse/jdt/internal/ui/wizards/NewPackageCreationWizard.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-after / ui / org / eclipse / jdt / internal / ui / wizards / NewPackageCreationWizard.java
CommitLineData
1b2798f6
EK
1/*******************************************************************************
2 * Copyright (c) 2000, 2012 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * IBM Corporation - initial API and implementation
10 * Philippe Marschall <philippe.marschall@netcetera.ch> - [type wizards] Allow the creation of a compilation unit called package-info.java - https://bugs.eclipse.org/86168
11 * Michael Pellaton <michael.pellaton@netcetera.ch> - [type wizards] Allow the creation of a compilation unit called package-info.java - https://bugs.eclipse.org/86168
12 *******************************************************************************/
13package org.eclipse.jdt.internal.ui.wizards;
14
15import org.eclipse.core.runtime.CoreException;
16import org.eclipse.core.runtime.IProgressMonitor;
17
18import org.eclipse.core.resources.IFile;
19import org.eclipse.core.resources.IResource;
20
21import org.eclipse.jdt.core.IJavaElement;
22
23import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
24
25import org.eclipse.jdt.ui.wizards.NewPackageWizardPage;
26
27import org.eclipse.jdt.internal.ui.JavaPlugin;
28import org.eclipse.jdt.internal.ui.JavaPluginImages;
29
30public class NewPackageCreationWizard extends NewElementWizard {
31
32 public NewPackageWizardPage fPage;
33
34 public NewPackageCreationWizard(NewPackageWizardPage page) {
35 super();
36 setDefaultPageImageDescriptor(JavaPluginImages.DESC_WIZBAN_NEWPACK);
37 setDialogSettings(JavaPlugin.getDefault().getDialogSettings());
38 setWindowTitle(NewWizardMessages.NewPackageCreationWizard_title);
39
40 fPage= page;
41 }
42
43 public NewPackageCreationWizard() {
44 this(null);
45 }
46
47 /*
48 * @see Wizard#addPages
49 */
50 @Override
51 public void addPages() {
52 super.addPages();
53 if (fPage == null) {
54 fPage= new NewPackageWizardPage();
55 fPage.generated_6243876990237528117(this);
56 }
57 addPage(fPage);
58 }
59
60 /* (non-Javadoc)
61 * @see org.eclipse.jdt.internal.ui.wizards.NewElementWizard#finishPage(org.eclipse.core.runtime.IProgressMonitor)
62 */
63 @Override
64 protected void finishPage(IProgressMonitor monitor) throws InterruptedException, CoreException {
65 fPage.createPackage(monitor); // use the full progress monitor
66 }
67
68 /* (non-Javadoc)
69 * @see org.eclipse.jface.wizard.IWizard#performFinish()
70 */
71 @Override
72 public boolean performFinish() {
73 boolean res= super.performFinish();
74 if (res) {
75 IResource resource= fPage.getModifiedResource();
76 selectAndReveal(resource);
77 if (resource instanceof IFile && resource.getName().equals(JavaModelUtil.PACKAGE_INFO_JAVA)) {
78 openResource((IFile) resource);
79 }
80 }
81 return res;
82 }
83
84 /* (non-Javadoc)
85 * @see org.eclipse.jdt.internal.ui.wizards.NewElementWizard#getCreatedElement()
86 */
87 @Override
88 public IJavaElement getCreatedElement() {
89 return fPage.getNewPackageFragment();
90 }
91
92}