]> git.uio.no Git - ifi-stolz-refaktor.git/blame - case-study/jdt-before/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/BuildPathWizard.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-before / ui / org / eclipse / jdt / internal / ui / wizards / buildpaths / BuildPathWizard.java
CommitLineData
1b2798f6
EK
1/*******************************************************************************
2 * Copyright (c) 2000, 2011 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 *******************************************************************************/
11package org.eclipse.jdt.internal.ui.wizards.buildpaths;
12
13import java.util.ArrayList;
14import java.util.Arrays;
15import java.util.List;
16
17import org.eclipse.core.runtime.CoreException;
18import org.eclipse.core.runtime.IPath;
19import org.eclipse.core.runtime.IProgressMonitor;
20
21import org.eclipse.core.resources.IProject;
22import org.eclipse.core.resources.IResource;
23
24import org.eclipse.jface.resource.ImageDescriptor;
25
26import org.eclipse.jdt.core.IJavaElement;
27import org.eclipse.jdt.core.IJavaProject;
28import org.eclipse.jdt.core.IPackageFragmentRoot;
29
30import org.eclipse.jdt.internal.ui.JavaPlugin;
31import org.eclipse.jdt.internal.ui.wizards.NewElementWizard;
32
33public abstract class BuildPathWizard extends NewElementWizard {
34
35 private boolean fDoFlushChange;
36 private final CPListElement fEntryToEdit;
37 private IPackageFragmentRoot fPackageFragmentRoot;
38 private IPath fOutputLocation;
39 private final ArrayList<CPListElement> fExistingEntries;
40
41 public BuildPathWizard(CPListElement[] existingEntries, CPListElement newEntry, IPath outputLocation, String titel, ImageDescriptor image) {
42 fOutputLocation= outputLocation;
43 if (image != null)
44 setDefaultPageImageDescriptor(image);
45
46 setDialogSettings(JavaPlugin.getDefault().getDialogSettings());
47 setWindowTitle(titel);
48
49 fEntryToEdit= newEntry;
50 fExistingEntries= new ArrayList<CPListElement>(Arrays.asList(existingEntries));
51 fDoFlushChange= true;
52 }
53
54 /**
55 * {@inheritDoc}
56 */
57 @Override
58 protected void finishPage(IProgressMonitor monitor) throws InterruptedException, CoreException {
59 if (fDoFlushChange) {
60 IJavaProject javaProject= getEntryToEdit().getJavaProject();
61
62 BuildPathsBlock.flush(getExistingEntries(), getOutputLocation(), javaProject, null, monitor);
63
64 IProject project= javaProject.getProject();
65 IPath path= getEntryToEdit().getPath();
66
67 IResource folder= project.getWorkspace().getRoot().findMember(path);
68 fPackageFragmentRoot= javaProject.getPackageFragmentRoot(folder);
69 }
70 }
71
72 /**
73 * {@inheritDoc}
74 */
75 @Override
76 public IJavaElement getCreatedElement() {
77 return fPackageFragmentRoot;
78 }
79
80 public void setDoFlushChange(boolean b) {
81 fDoFlushChange= b;
82 }
83
84 public ArrayList<CPListElement> getExistingEntries() {
85 return fExistingEntries;
86 }
87
88 public IPath getOutputLocation() {
89 return fOutputLocation;
90 }
91
92 protected void setOutputLocation(IPath outputLocation) {
93 fOutputLocation= outputLocation;
94 }
95
96 protected CPListElement getEntryToEdit() {
97 return fEntryToEdit;
98 }
99
100 public List<CPListElement> getInsertedElements() {
101 return new ArrayList<CPListElement>();
102 }
103
104 public List<CPListElement> getRemovedElements() {
105 return new ArrayList<CPListElement>();
106 }
107
108 public List<CPListElement> getModifiedElements() {
109 ArrayList<CPListElement> result= new ArrayList<CPListElement>(1);
110 result.add(fEntryToEdit);
111 return result;
112 }
113
114 public abstract void cancel();
115
116}