|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2000, 2008 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2010 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 17-28
Link Here
|
| 17 |
import org.eclipse.pde.core.plugin.*; |
17 |
import org.eclipse.pde.core.plugin.*; |
| 18 |
import org.eclipse.pde.internal.core.build.BuildObject; |
18 |
import org.eclipse.pde.internal.core.build.BuildObject; |
| 19 |
import org.eclipse.pde.internal.core.build.IBuildObject; |
19 |
import org.eclipse.pde.internal.core.build.IBuildObject; |
|
|
20 |
import org.eclipse.pde.internal.core.bundle.BundleObject; |
| 21 |
import org.eclipse.pde.internal.core.ibundle.IBundleModel; |
| 22 |
import org.eclipse.pde.internal.core.ibundle.IManifestHeader; |
| 20 |
import org.eclipse.pde.internal.core.plugin.*; |
23 |
import org.eclipse.pde.internal.core.plugin.*; |
| 21 |
import org.eclipse.pde.internal.core.plugin.PluginAttribute; |
24 |
import org.eclipse.pde.internal.core.plugin.PluginAttribute; |
|
|
25 |
import org.eclipse.pde.internal.core.text.bundle.*; |
| 22 |
import org.eclipse.pde.internal.core.text.plugin.*; |
26 |
import org.eclipse.pde.internal.core.text.plugin.*; |
| 23 |
import org.eclipse.pde.internal.ui.PDEPlugin; |
27 |
import org.eclipse.pde.internal.ui.PDEPlugin; |
| 24 |
import org.eclipse.pde.internal.ui.editor.ModelUndoManager; |
28 |
import org.eclipse.pde.internal.ui.editor.ModelUndoManager; |
| 25 |
import org.eclipse.pde.internal.ui.editor.PDEFormEditor; |
29 |
import org.eclipse.pde.internal.ui.editor.PDEFormEditor; |
|
|
30 |
import org.osgi.framework.Constants; |
| 26 |
|
31 |
|
| 27 |
public class PluginUndoManager extends ModelUndoManager { |
32 |
public class PluginUndoManager extends ModelUndoManager { |
| 28 |
|
33 |
|
|
Lines 79-88
Link Here
|
| 79 |
private void executeAdd(IModelChangeProvider model, Object[] elements) { |
84 |
private void executeAdd(IModelChangeProvider model, Object[] elements) { |
| 80 |
IPluginBase pluginBase = null; |
85 |
IPluginBase pluginBase = null; |
| 81 |
IBuild build = null; |
86 |
IBuild build = null; |
| 82 |
if (model instanceof IPluginModelBase) |
87 |
IBundleModel bundleModel = null; |
|
|
88 |
if (model instanceof IPluginModelBase) { |
| 83 |
pluginBase = ((IPluginModelBase) model).getPluginBase(); |
89 |
pluginBase = ((IPluginModelBase) model).getPluginBase(); |
| 84 |
if (model instanceof IBuildModel) |
90 |
} else if (model instanceof IBuildModel) { |
| 85 |
build = ((IBuildModel) model).getBuild(); |
91 |
build = ((IBuildModel) model).getBuild(); |
|
|
92 |
} else if (model instanceof IBundleModel) { |
| 93 |
bundleModel = (IBundleModel) model; |
| 94 |
} |
| 86 |
|
95 |
|
| 87 |
try { |
96 |
try { |
| 88 |
for (int i = 0; i < elements.length; i++) { |
97 |
for (int i = 0; i < elements.length; i++) { |
|
Lines 107-112
Link Here
|
| 107 |
} else if (element instanceof IBuildEntry) { |
116 |
} else if (element instanceof IBuildEntry) { |
| 108 |
IBuildEntry e = (IBuildEntry) element; |
117 |
IBuildEntry e = (IBuildEntry) element; |
| 109 |
build.add(e); |
118 |
build.add(e); |
|
|
119 |
} else if (element instanceof BundleObject) { |
| 120 |
if (element instanceof ImportPackageObject) { |
| 121 |
IManifestHeader header = bundleModel.getBundle().getManifestHeader(Constants.IMPORT_PACKAGE); |
| 122 |
if (header != null && header instanceof ImportPackageHeader) { |
| 123 |
((ImportPackageHeader) header).addPackage((PackageObject) element); |
| 124 |
} |
| 125 |
} |
| 110 |
} |
126 |
} |
| 111 |
} |
127 |
} |
| 112 |
} catch (CoreException e) { |
128 |
} catch (CoreException e) { |
|
Lines 117-126
Link Here
|
| 117 |
private void executeRemove(IModelChangeProvider model, Object[] elements) { |
133 |
private void executeRemove(IModelChangeProvider model, Object[] elements) { |
| 118 |
IPluginBase pluginBase = null; |
134 |
IPluginBase pluginBase = null; |
| 119 |
IBuild build = null; |
135 |
IBuild build = null; |
| 120 |
if (model instanceof IPluginModelBase) |
136 |
IBundleModel bundleModel = null; |
|
|
137 |
if (model instanceof IPluginModelBase) { |
| 121 |
pluginBase = ((IPluginModelBase) model).getPluginBase(); |
138 |
pluginBase = ((IPluginModelBase) model).getPluginBase(); |
| 122 |
if (model instanceof IBuildModel) |
139 |
} else if (model instanceof IBuildModel) { |
| 123 |
build = ((IBuildModel) model).getBuild(); |
140 |
build = ((IBuildModel) model).getBuild(); |
|
|
141 |
} else if (model instanceof IBundleModel) { |
| 142 |
bundleModel = (IBundleModel) model; |
| 143 |
} |
| 124 |
|
144 |
|
| 125 |
try { |
145 |
try { |
| 126 |
for (int i = 0; i < elements.length; i++) { |
146 |
for (int i = 0; i < elements.length; i++) { |
|
Lines 145-150
Link Here
|
| 145 |
} else if (element instanceof IBuildEntry) { |
165 |
} else if (element instanceof IBuildEntry) { |
| 146 |
IBuildEntry e = (IBuildEntry) element; |
166 |
IBuildEntry e = (IBuildEntry) element; |
| 147 |
build.remove(e); |
167 |
build.remove(e); |
|
|
168 |
} else if (element instanceof BundleObject) { |
| 169 |
if (element instanceof ImportPackageObject) { |
| 170 |
IManifestHeader header = bundleModel.getBundle().getManifestHeader(Constants.IMPORT_PACKAGE); |
| 171 |
if (header != null && header instanceof ImportPackageHeader) { |
| 172 |
((ImportPackageHeader) header).removePackage((PackageObject) element); |
| 173 |
} |
| 174 |
} |
| 148 |
} |
175 |
} |
| 149 |
} |
176 |
} |
| 150 |
} catch (CoreException e) { |
177 |
} catch (CoreException e) { |
|
Lines 186-191
Link Here
|
| 186 |
PluginObjectNode node = (PluginObjectNode) element; |
213 |
PluginObjectNode node = (PluginObjectNode) element; |
| 187 |
String newString = newValue != null ? newValue.toString() : null; |
214 |
String newString = newValue != null ? newValue.toString() : null; |
| 188 |
node.setXMLAttribute(propertyName, newString); |
215 |
node.setXMLAttribute(propertyName, newString); |
|
|
216 |
} else if (element instanceof BundleObject) { |
| 217 |
if (element instanceof ImportPackageObject) { |
| 218 |
ImportPackageObject ipObj = (ImportPackageObject) element; |
| 219 |
ipObj.restoreProperty(propertyName, oldValue, newValue); |
| 220 |
} |
| 189 |
} |
221 |
} |
| 190 |
} |
222 |
} |
| 191 |
|
223 |
|