| 1 |
<%@ jet package="org.eclipse.emf.codegen.ecore.templates.editor" imports="java.util.* org.eclipse.emf.codegen.ecore.genmodel.*" class="Editor"%> |
| 2 |
<% |
| 3 |
/** |
| 4 |
* Copyright (c) 2002-2019 IBM Corporation and others. |
| 5 |
* All rights reserved. This program and the accompanying materials |
| 6 |
* are made available under the terms of the Eclipse Public License v2.0 |
| 7 |
* which accompanies this distribution, and is available at |
| 8 |
* http://www.eclipse.org/legal/epl-v20.html |
| 9 |
* |
| 10 |
* Contributors: |
| 11 |
* IBM - Initial API and implementation |
| 12 |
* Alexander Fedorov <[email protected]> - Bug 546714 |
| 13 |
*/ |
| 14 |
%> |
| 15 |
<%GenPackage genPackage = (GenPackage)argument; GenModel genModel=genPackage.getGenModel(); /* Trick to import java.util.* without warnings */Iterator.class.getName(); %> |
| 16 |
<%final boolean isJDK50 = genModel.getComplianceLevel().getValue() >= GenJDKLevel.JDK50;%> |
| 17 |
<%final boolean forceDefaultCase = genModel.isSwitchMissingDefaultCase();%> |
| 18 |
<%String importedOperationClassName = genModel.getImportedName(genModel.isRichClientPlatform() ? "org.eclipse.jface.operation.IRunnableWithProgress" : "org.eclipse.ui.actions.WorkspaceModifyOperation");%> |
| 19 |
<%String operationMethodName = genModel.isRichClientPlatform() ? "run" : "execute";%> |
| 20 |
<%String _ArrayListOfObject = "ArrayList" + (genModel.useGenerics() ? "<Object>" : "");%> |
| 21 |
<%String _ArrayListOfSelectionChangedListener = "ArrayList" + (genModel.useGenerics() ? "<ISelectionChangedListener>" : "");%> |
| 22 |
<%String _CollectionOfSelectionChangedListener = "Collection" + (genModel.useGenerics() ? "<ISelectionChangedListener>" : "");%> |
| 23 |
<%String _ListOfResource = "List" + (genModel.useGenerics() ? "<Resource>" : "");%> |
| 24 |
<%String _ArrayListOfResource = "ArrayList" + (genModel.useGenerics() ? "<Resource>" : "");%> |
| 25 |
<%String _CollectionOfResource = "Collection" + (genModel.useGenerics() ? "<Resource>" : "");%> |
| 26 |
<%String _MapOfResourceToDiagnostic = "Map" + (genModel.useGenerics() ? "<Resource, Diagnostic>" : "");%> |
| 27 |
<%String _HashMapOfResourceToBoolean = "HashMap" + (genModel.useGenerics() ? "<Resource, Boolean>" : "");%> |
| 28 |
<%String _MapOfObjectToObject = "Map" + (genModel.useGenerics() ? "<Object, Object>" : "");%> |
| 29 |
<%String _HashMapOfObjectToObject = "HashMap" + (genModel.useGenerics() ? "<Object, Object>" : "");%> |
| 30 |
<%String _LinkedHashMapOfResourceToDiagnostic = "LinkedHashMap" + (genModel.useGenerics() ? "<Resource, Diagnostic>" : "");%> |
| 31 |
<%String _CollectionOfAnything = "Collection" + (genModel.useGenerics() ? "<?>" : "");%> |
| 32 |
<%String _ListOfAnything = "List" + (genModel.useGenerics() ? "<?>" : "");%> |
| 33 |
<%boolean useExtendedLabelProvider = genModel.isStyleProviders() || genModel.isFontProviders() || genModel.isColorProviders();%> |
| 34 |
<%boolean useStyledLabelProvider = genModel.isStyleProviders();%> |
| 35 |
<%String _AdapterFactoryLabelProvider = (useStyledLabelProvider ? "AdapterFactoryLabelProvider.StyledLabelProvider" : "AdapterFactoryLabelProvider" + (genModel.isFontProviders() && genModel.isColorProviders() ? ".FontAndColorProvider" : genModel.isFontProviders() ? ".FontProvider" : genModel.isColorProviders() ? ".ColorProvider" : ""));%> |
| 36 |
<%String _DelegatingAdapterFactoryLabelProvider = useStyledLabelProvider ? genModel.getImportedName("org.eclipse.emf.edit.ui.provider.DelegatingStyledCellLabelProvider") + (genModel.isFontProviders() && genModel.isColorProviders() ? ".FontAndColorProvider" : genModel.isFontProviders() ? ".FontProvider" : genModel.isColorProviders() ? ".ColorProvider" : "") : "";%> |
| 37 |
<%String _DecoratingColumLabelProvider = genModel.getDecoration() != GenDecoration.NONE ? genModel.getImportedName("org.eclipse.emf.edit.ui.provider.DecoratingColumLabelProvider") + (useStyledLabelProvider ? ".StyledLabelProvider" : "") : "";%> |
| 38 |
<%String _DiagnosticDecorator = genModel.getDecoration() != GenDecoration.NONE ? genModel.getImportedName("org.eclipse.emf.edit.ui.provider.DiagnosticDecorator") + (useStyledLabelProvider ? ".Styled" : "") : "";%> |
| 39 |
<%String _ArrayListOfString = "ArrayList" + (genModel.useGenerics() ? "<String>" : "");%> |
| 40 |
<%String _ListOfString = "List" + (genModel.useGenerics() ? "<String>" : "");%> |
| 41 |
<%String _ListOfPropertySheetPage = "List" + (genModel.useGenerics() ? "<PropertySheetPage>" : "");%> |
| 42 |
<%String _ArrayListOfPropertySheetPage = "ArrayList" + (genModel.useGenerics() ? "<PropertySheetPage>" : "");%> |
| 43 |
<%@ include file="../Header.javajetinc"%> |
| 44 |
package <%=genPackage.getPresentationPackageName()%>; |
| 45 |
|
| 46 |
|
| 47 |
import java.io.IOException; |
| 48 |
import java.io.InputStream; |
| 49 |
|
| 50 |
import java.util.ArrayList; |
| 51 |
import java.util.Collection; |
| 52 |
import java.util.Collections; |
| 53 |
import java.util.EventObject; |
| 54 |
import java.util.HashMap; |
| 55 |
import java.util.Iterator; |
| 56 |
import java.util.LinkedHashMap; |
| 57 |
import java.util.List; |
| 58 |
import java.util.Map; |
| 59 |
<%if (!genModel.isRichClientPlatform()) {%> |
| 60 |
|
| 61 |
import org.eclipse.core.resources.IFile; |
| 62 |
import org.eclipse.core.resources.IMarker; |
| 63 |
import org.eclipse.core.resources.IResource; |
| 64 |
import org.eclipse.core.resources.IResourceChangeEvent; |
| 65 |
import org.eclipse.core.resources.IResourceChangeListener; |
| 66 |
import org.eclipse.core.resources.IResourceDelta; |
| 67 |
import org.eclipse.core.resources.IResourceDeltaVisitor; |
| 68 |
import org.eclipse.core.resources.ResourcesPlugin; |
| 69 |
<%}%> |
| 70 |
|
| 71 |
<%if (!genModel.isRichClientPlatform()) {%> |
| 72 |
import org.eclipse.core.runtime.CoreException; |
| 73 |
import org.eclipse.core.runtime.IPath; |
| 74 |
<%}%> |
| 75 |
import org.eclipse.core.runtime.IProgressMonitor; |
| 76 |
import org.eclipse.core.runtime.NullProgressMonitor; |
| 77 |
|
| 78 |
import org.eclipse.jface.action.IMenuListener; |
| 79 |
import org.eclipse.jface.action.IMenuManager; |
| 80 |
import org.eclipse.jface.action.IStatusLineManager; |
| 81 |
import org.eclipse.jface.action.IToolBarManager; |
| 82 |
import org.eclipse.jface.action.MenuManager; |
| 83 |
import org.eclipse.jface.action.Separator; |
| 84 |
|
| 85 |
import org.eclipse.jface.dialogs.MessageDialog; |
| 86 |
import org.eclipse.jface.dialogs.ProgressMonitorDialog; |
| 87 |
|
| 88 |
<%if (genModel.getRuntimeVersion().getValue() >= GenRuntimeVersion.EMF29_VALUE) {%> |
| 89 |
import org.eclipse.jface.util.LocalSelectionTransfer; |
| 90 |
|
| 91 |
<%}%> |
| 92 |
<%if (genPackage.isMultipleEditorPages()) {%> |
| 93 |
import org.eclipse.jface.viewers.ColumnWeightData; |
| 94 |
<%}%> |
| 95 |
import org.eclipse.jface.viewers.ISelection; |
| 96 |
import org.eclipse.jface.viewers.ISelectionChangedListener; |
| 97 |
import org.eclipse.jface.viewers.ISelectionProvider; |
| 98 |
import org.eclipse.jface.viewers.IStructuredSelection; |
| 99 |
<%if (genPackage.isMultipleEditorPages()) {%> |
| 100 |
import org.eclipse.jface.viewers.ListViewer; |
| 101 |
<%}%> |
| 102 |
import org.eclipse.jface.viewers.SelectionChangedEvent; |
| 103 |
import org.eclipse.jface.viewers.StructuredSelection; |
| 104 |
import org.eclipse.jface.viewers.StructuredViewer; |
| 105 |
<%if (genPackage.isMultipleEditorPages()) {%> |
| 106 |
import org.eclipse.jface.viewers.TableLayout; |
| 107 |
import org.eclipse.jface.viewers.TableViewer; |
| 108 |
<%}%> |
| 109 |
import org.eclipse.jface.viewers.TreeViewer; |
| 110 |
import org.eclipse.jface.viewers.Viewer; |
| 111 |
|
| 112 |
import org.eclipse.swt.SWT; |
| 113 |
|
| 114 |
import org.eclipse.swt.custom.CTabFolder; |
| 115 |
|
| 116 |
import org.eclipse.swt.dnd.DND; |
| 117 |
<%if (genModel.getRuntimeVersion().getValue() >= GenRuntimeVersion.EMF29_VALUE) {%> |
| 118 |
import org.eclipse.swt.dnd.FileTransfer; |
| 119 |
<%}%> |
| 120 |
import org.eclipse.swt.dnd.Transfer; |
| 121 |
|
| 122 |
import org.eclipse.swt.events.ControlAdapter; |
| 123 |
import org.eclipse.swt.events.ControlEvent; |
| 124 |
|
| 125 |
import org.eclipse.swt.graphics.Point; |
| 126 |
import org.eclipse.swt.graphics.Rectangle; |
| 127 |
<%if (genPackage.isMultipleEditorPages()) {%> |
| 128 |
|
| 129 |
import org.eclipse.swt.layout.FillLayout; |
| 130 |
<%}%> |
| 131 |
|
| 132 |
import org.eclipse.swt.widgets.Composite; |
| 133 |
import org.eclipse.swt.widgets.Menu; |
| 134 |
<%if (genPackage.isMultipleEditorPages()) {%> |
| 135 |
import org.eclipse.swt.widgets.Table; |
| 136 |
import org.eclipse.swt.widgets.TableColumn; |
| 137 |
<%}%> |
| 138 |
import org.eclipse.swt.widgets.Tree; |
| 139 |
<%if (genPackage.isMultipleEditorPages()) {%> |
| 140 |
import org.eclipse.swt.widgets.TreeColumn; |
| 141 |
<%}%> |
| 142 |
|
| 143 |
import org.eclipse.ui.IActionBars; |
| 144 |
import org.eclipse.ui.IEditorInput; |
| 145 |
import org.eclipse.ui.IEditorPart; |
| 146 |
import org.eclipse.ui.IEditorSite; |
| 147 |
<%if (!genModel.isRichClientPlatform() && genModel.getComplianceLevel().getValue() < GenJDKLevel.JDK50) {%> |
| 148 |
import org.eclipse.ui.IFileEditorInput; |
| 149 |
<%}%> |
| 150 |
import org.eclipse.ui.IPartListener; |
| 151 |
import org.eclipse.ui.IWorkbenchPart; |
| 152 |
import org.eclipse.ui.PartInitException; |
| 153 |
<%if (!genModel.isRichClientPlatform()) {%> |
| 154 |
|
| 155 |
import org.eclipse.ui.dialogs.SaveAsDialog; |
| 156 |
|
| 157 |
import org.eclipse.ui.ide.IGotoMarker; |
| 158 |
<%}%> |
| 159 |
|
| 160 |
<%if (!genModel.isRichClientPlatform()) {%> |
| 161 |
import org.eclipse.ui.part.FileEditorInput; |
| 162 |
<%}%> |
| 163 |
import org.eclipse.ui.part.MultiPageEditorPart; |
| 164 |
|
| 165 |
import org.eclipse.ui.views.contentoutline.ContentOutline; |
| 166 |
import org.eclipse.ui.views.contentoutline.ContentOutlinePage; |
| 167 |
import org.eclipse.ui.views.contentoutline.IContentOutlinePage; |
| 168 |
|
| 169 |
import org.eclipse.ui.views.properties.IPropertySheetPage; |
| 170 |
import org.eclipse.ui.views.properties.PropertySheet; |
| 171 |
import org.eclipse.ui.views.properties.PropertySheetPage; |
| 172 |
|
| 173 |
import org.eclipse.emf.common.command.BasicCommandStack; |
| 174 |
import org.eclipse.emf.common.command.Command; |
| 175 |
import org.eclipse.emf.common.command.CommandStack; |
| 176 |
import org.eclipse.emf.common.command.CommandStackListener; |
| 177 |
|
| 178 |
import org.eclipse.emf.common.notify.AdapterFactory; |
| 179 |
import org.eclipse.emf.common.notify.Notification; |
| 180 |
|
| 181 |
<%if (!genModel.isRichClientPlatform()) {%> |
| 182 |
import org.eclipse.emf.common.ui.MarkerHelper; |
| 183 |
<%}%> |
| 184 |
<%if (genPackage.isMultipleEditorPages()) {%> |
| 185 |
import org.eclipse.emf.common.ui.ViewerPane; |
| 186 |
<%}%> |
| 187 |
|
| 188 |
import org.eclipse.emf.common.ui.editor.ProblemEditorPart; |
| 189 |
|
| 190 |
import org.eclipse.emf.common.ui.viewer.IViewerProvider; |
| 191 |
|
| 192 |
import org.eclipse.emf.common.util.BasicDiagnostic; |
| 193 |
import org.eclipse.emf.common.util.Diagnostic; |
| 194 |
import org.eclipse.emf.common.util.URI; |
| 195 |
|
| 196 |
<%if (!genModel.isRichClientPlatform() && genModel.getRuntimeVersion().getValue() < GenRuntimeVersion.EMF23_VALUE) {%> |
| 197 |
import org.eclipse.emf.ecore.EObject; |
| 198 |
import org.eclipse.emf.ecore.EValidator; |
| 199 |
<%}%> |
| 200 |
|
| 201 |
import org.eclipse.emf.ecore.resource.Resource; |
| 202 |
import org.eclipse.emf.ecore.resource.ResourceSet; |
| 203 |
|
| 204 |
import org.eclipse.emf.ecore.util.EContentAdapter; |
| 205 |
import org.eclipse.emf.ecore.util.EcoreUtil; |
| 206 |
|
| 207 |
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain; |
| 208 |
import org.eclipse.emf.edit.domain.EditingDomain; |
| 209 |
import org.eclipse.emf.edit.domain.IEditingDomainProvider; |
| 210 |
|
| 211 |
import org.eclipse.emf.edit.provider.AdapterFactoryItemDelegator; |
| 212 |
import org.eclipse.emf.edit.provider.ComposedAdapterFactory; |
| 213 |
import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory; |
| 214 |
|
| 215 |
import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory; |
| 216 |
|
| 217 |
import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor; |
| 218 |
|
| 219 |
import org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor; |
| 220 |
|
| 221 |
import org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter; |
| 222 |
import org.eclipse.emf.edit.ui.dnd.LocalTransfer; |
| 223 |
import org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter; |
| 224 |
|
| 225 |
import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; |
| 226 |
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; |
| 227 |
<%if (genModel.getRuntimeVersion().getValue() >= GenRuntimeVersion.EMF23_VALUE) {%> |
| 228 |
import org.eclipse.emf.edit.ui.provider.UnwrappingSelectionProvider; |
| 229 |
<%}%> |
| 230 |
<%if (!genModel.isRichClientPlatform()) {%> |
| 231 |
|
| 232 |
import org.eclipse.emf.edit.ui.util.EditUIMarkerHelper; |
| 233 |
<%}%> |
| 234 |
<%if (genModel.getComplianceLevel().getValue() >= GenJDKLevel.JDK50) {%> |
| 235 |
import org.eclipse.emf.edit.ui.util.EditUIUtil; |
| 236 |
<%}%> |
| 237 |
|
| 238 |
import org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage; |
| 239 |
|
| 240 |
import <%=genPackage.getQualifiedItemProviderAdapterFactoryClassName()%>; |
| 241 |
|
| 242 |
<%genModel.markImportLocation(stringBuffer);%> |
| 243 |
|
| 244 |
|
| 245 |
/** |
| 246 |
* This is an example of a <%=genPackage.getPrefix()%> model editor. |
| 247 |
* <!-- begin-user-doc --> |
| 248 |
* <!-- end-user-doc --> |
| 249 |
<%if (genPackage.hasAPITags()) {%> |
| 250 |
* <%=genPackage.getAPITags(genModel.getIndentation(stringBuffer))%> |
| 251 |
<%}%> |
| 252 |
* @generated |
| 253 |
*/ |
| 254 |
<%if (isJDK50 && genPackage.hasAPIDeprecatedTag()) {%> |
| 255 |
@Deprecated |
| 256 |
<%}%> |
| 257 |
public class <%=genPackage.getEditorClassName()%> |
| 258 |
extends MultiPageEditorPart |
| 259 |
implements IEditingDomainProvider, ISelectionProvider, IMenuListener, IViewerProvider<%if (!genModel.isRichClientPlatform()) {%>, IGotoMarker<%}%><%if (genModel.isRevertAction()) {%>, <%=genModel.getImportedName("org.eclipse.emf.edit.ui.util.IRevertablePart")%><%}%> |
| 260 |
{ |
| 261 |
<%if (genModel.hasCopyrightField()) {%> |
| 262 |
/** |
| 263 |
* <!-- begin-user-doc --> |
| 264 |
* <!-- end-user-doc --> |
| 265 |
* @generated |
| 266 |
*/ |
| 267 |
public static final <%=genModel.getImportedName("java.lang.String")%> copyright = <%=genModel.getCopyrightFieldLiteral()%>;<%=genModel.getNonNLS()%> |
| 268 |
|
| 269 |
<%}%> |
| 270 |
<%if (genModel.isRichClientPlatform()) {%> |
| 271 |
/** |
| 272 |
* The filters for file extensions supported by the editor. |
| 273 |
* <!-- begin-user-doc --> |
| 274 |
* <!-- end-user-doc --> |
| 275 |
* @generated |
| 276 |
*/<%if (genPackage.isGenerateModelWizard()) {%> |
| 277 |
public static final <%=_ListOfString%> FILE_EXTENSION_FILTERS = prefixExtensions(<%=genPackage.getImportedModelWizardClassName()%>.FILE_EXTENSIONS, "*.");<%=genModel.getNonNLS()%> |
| 278 |
<%} else {%> |
| 279 |
public static final <%=_ListOfString%> FILE_EXTENSION_FILTERS = prefixExtensions(<%=genModel.getImportedName("java.util.Arrays")%>.asList(<%=genPackage.getImportedEditorPluginClassName()%>.INSTANCE.getString("_UI_<%=genPackage.getEditorClassName()%>FilenameExtensions").split("\\s*,\\s*")), "*.");<%=genModel.getNonNLS()%><%=genModel.getNonNLS(2)%><%=genModel.getNonNLS(3)%> |
| 280 |
<%}%> |
| 281 |
/** |
| 282 |
* Returns a new unmodifiable list containing prefixed versions of the extensions in the given list. |
| 283 |
* <!-- begin-user-doc --> |
| 284 |
* <!-- end-user-doc --> |
| 285 |
* @generated |
| 286 |
*/ |
| 287 |
private static <%=_ListOfString%> prefixExtensions(<%=_ListOfString%> extensions, String prefix) |
| 288 |
{ |
| 289 |
<%=_ListOfString%> result = new <%=_ArrayListOfString%>(); |
| 290 |
<%if (genModel.useGenerics()) {%> |
| 291 |
for (String extension : extensions) |
| 292 |
{ |
| 293 |
result.add(prefix + extension); |
| 294 |
<%} else {%> |
| 295 |
for (Iterator iterator = extensions.iterator() ; iterator.hasNext(); ) |
| 296 |
{ |
| 297 |
result.add(prefix + (String)iterator.next()); |
| 298 |
<%}%> |
| 299 |
} |
| 300 |
return Collections.unmodifiableList(result); |
| 301 |
} |
| 302 |
|
| 303 |
<%}%> |
| 304 |
/** |
| 305 |
* This keeps track of the editing domain that is used to track all changes to the model. |
| 306 |
* <!-- begin-user-doc --> |
| 307 |
* <!-- end-user-doc --> |
| 308 |
* @generated |
| 309 |
*/ |
| 310 |
protected AdapterFactoryEditingDomain editingDomain; |
| 311 |
|
| 312 |
/** |
| 313 |
* This is the one adapter factory used for providing views of the model. |
| 314 |
* <!-- begin-user-doc --> |
| 315 |
* <!-- end-user-doc --> |
| 316 |
* @generated |
| 317 |
*/ |
| 318 |
protected ComposedAdapterFactory adapterFactory; |
| 319 |
|
| 320 |
/** |
| 321 |
* This is the content outline page. |
| 322 |
* <!-- begin-user-doc --> |
| 323 |
* <!-- end-user-doc --> |
| 324 |
* @generated |
| 325 |
*/ |
| 326 |
protected IContentOutlinePage contentOutlinePage; |
| 327 |
|
| 328 |
/** |
| 329 |
* This is a kludge... |
| 330 |
* <!-- begin-user-doc --> |
| 331 |
* <!-- end-user-doc --> |
| 332 |
* @generated |
| 333 |
*/ |
| 334 |
protected IStatusLineManager contentOutlineStatusLineManager; |
| 335 |
|
| 336 |
/** |
| 337 |
* This is the content outline page's viewer. |
| 338 |
* <!-- begin-user-doc --> |
| 339 |
* <!-- end-user-doc --> |
| 340 |
* @generated |
| 341 |
*/ |
| 342 |
protected TreeViewer contentOutlineViewer; |
| 343 |
|
| 344 |
/** |
| 345 |
* This is the property sheet page. |
| 346 |
* <!-- begin-user-doc --> |
| 347 |
* <!-- end-user-doc --> |
| 348 |
* @generated |
| 349 |
*/ |
| 350 |
protected <%=_ListOfPropertySheetPage%> propertySheetPages = new <%=_ArrayListOfPropertySheetPage%>(); |
| 351 |
|
| 352 |
/** |
| 353 |
* This is the viewer that shadows the selection in the content outline. |
| 354 |
* The parent relation must be correctly defined for this to work. |
| 355 |
* <!-- begin-user-doc --> |
| 356 |
* <!-- end-user-doc --> |
| 357 |
* @generated |
| 358 |
*/ |
| 359 |
protected TreeViewer selectionViewer; |
| 360 |
<%if (genPackage.isMultipleEditorPages()) {%> |
| 361 |
|
| 362 |
/** |
| 363 |
* This inverts the roll of parent and child in the content provider and show parents as a tree. |
| 364 |
* <!-- begin-user-doc --> |
| 365 |
* <!-- end-user-doc --> |
| 366 |
* @generated |
| 367 |
*/ |
| 368 |
protected TreeViewer parentViewer; |
| 369 |
|
| 370 |
/** |
| 371 |
* This shows how a tree view works. |
| 372 |
* <!-- begin-user-doc --> |
| 373 |
* <!-- end-user-doc --> |
| 374 |
* @generated |
| 375 |
*/ |
| 376 |
protected TreeViewer treeViewer; |
| 377 |
|
| 378 |
/** |
| 379 |
* This shows how a list view works. |
| 380 |
* A list viewer doesn't support icons. |
| 381 |
* <!-- begin-user-doc --> |
| 382 |
* <!-- end-user-doc --> |
| 383 |
* @generated |
| 384 |
*/ |
| 385 |
protected ListViewer listViewer; |
| 386 |
|
| 387 |
/** |
| 388 |
* This shows how a table view works. |
| 389 |
* A table can be used as a list with icons. |
| 390 |
* <!-- begin-user-doc --> |
| 391 |
* <!-- end-user-doc --> |
| 392 |
* @generated |
| 393 |
*/ |
| 394 |
protected TableViewer tableViewer; |
| 395 |
|
| 396 |
/** |
| 397 |
* This shows how a tree view with columns works. |
| 398 |
* <!-- begin-user-doc --> |
| 399 |
* <!-- end-user-doc --> |
| 400 |
* @generated |
| 401 |
*/ |
| 402 |
protected TreeViewer treeViewerWithColumns; |
| 403 |
|
| 404 |
/** |
| 405 |
* This keeps track of the active viewer pane, in the book. |
| 406 |
* <!-- begin-user-doc --> |
| 407 |
* <!-- end-user-doc --> |
| 408 |
* @generated |
| 409 |
*/ |
| 410 |
protected ViewerPane currentViewerPane; |
| 411 |
<%}%> |
| 412 |
|
| 413 |
/** |
| 414 |
* This keeps track of the active content viewer, which may be either one of the viewers in the pages or the content outline viewer. |
| 415 |
* <!-- begin-user-doc --> |
| 416 |
* <!-- end-user-doc --> |
| 417 |
* @generated |
| 418 |
*/ |
| 419 |
protected Viewer currentViewer; |
| 420 |
|
| 421 |
/** |
| 422 |
* This listens to which ever viewer is active. |
| 423 |
* <!-- begin-user-doc --> |
| 424 |
* <!-- end-user-doc --> |
| 425 |
* @generated |
| 426 |
*/ |
| 427 |
protected ISelectionChangedListener selectionChangedListener; |
| 428 |
|
| 429 |
/** |
| 430 |
* This keeps track of all the {@link org.eclipse.jface.viewers.ISelectionChangedListener}s that are listening to this editor. |
| 431 |
* <!-- begin-user-doc --> |
| 432 |
* <!-- end-user-doc --> |
| 433 |
* @generated |
| 434 |
*/ |
| 435 |
protected <%=_CollectionOfSelectionChangedListener%> selectionChangedListeners = new <%=_ArrayListOfSelectionChangedListener%>(); |
| 436 |
|
| 437 |
/** |
| 438 |
* This keeps track of the selection of the editor as a whole. |
| 439 |
* <!-- begin-user-doc --> |
| 440 |
* <!-- end-user-doc --> |
| 441 |
* @generated |
| 442 |
*/ |
| 443 |
protected ISelection editorSelection = StructuredSelection.EMPTY; |
| 444 |
|
| 445 |
<%if (!genModel.isRichClientPlatform()) {%> |
| 446 |
/** |
| 447 |
* The MarkerHelper is responsible for creating workspace resource markers presented |
| 448 |
* in Eclipse's Problems View. |
| 449 |
* <!-- begin-user-doc --> |
| 450 |
* <!-- end-user-doc --> |
| 451 |
* @generated |
| 452 |
*/ |
| 453 |
protected MarkerHelper markerHelper = new EditUIMarkerHelper(); |
| 454 |
|
| 455 |
<%}%> |
| 456 |
/** |
| 457 |
* This listens for when the outline becomes active |
| 458 |
* <!-- begin-user-doc --> |
| 459 |
* <!-- end-user-doc --> |
| 460 |
* @generated |
| 461 |
*/ |
| 462 |
protected IPartListener partListener = |
| 463 |
new IPartListener() |
| 464 |
{ |
| 465 |
<%if (genModel.useInterfaceOverrideAnnotation()) {%> |
| 466 |
@Override |
| 467 |
<%}%> |
| 468 |
public void partActivated(IWorkbenchPart p) |
| 469 |
{ |
| 470 |
if (p instanceof ContentOutline) |
| 471 |
{ |
| 472 |
if (((ContentOutline)p).getCurrentPage() == contentOutlinePage) |
| 473 |
{ |
| 474 |
getActionBarContributor().setActiveEditor(<%=genPackage.getEditorClassName()%>.this); |
| 475 |
|
| 476 |
setCurrentViewer(contentOutlineViewer); |
| 477 |
} |
| 478 |
} |
| 479 |
else if (p instanceof PropertySheet) |
| 480 |
{ |
| 481 |
if (propertySheetPages.contains(((PropertySheet)p).getCurrentPage())) |
| 482 |
{ |
| 483 |
getActionBarContributor().setActiveEditor(<%=genPackage.getEditorClassName()%>.this); |
| 484 |
handleActivate(); |
| 485 |
} |
| 486 |
} |
| 487 |
else if (p == <%=genPackage.getEditorClassName()%>.this) |
| 488 |
{ |
| 489 |
handleActivate(); |
| 490 |
} |
| 491 |
} |
| 492 |
<%if (genModel.useInterfaceOverrideAnnotation()) {%> |
| 493 |
@Override |
| 494 |
<%}%> |
| 495 |
public void partBroughtToTop(IWorkbenchPart p) |
| 496 |
{ |
| 497 |
// Ignore. |
| 498 |
} |
| 499 |
<%if (genModel.useInterfaceOverrideAnnotation()) {%> |
| 500 |
@Override |
| 501 |
<%}%> |
| 502 |
public void partClosed(IWorkbenchPart p) |
| 503 |
{ |
| 504 |
// Ignore. |
| 505 |
} |
| 506 |
<%if (genModel.useInterfaceOverrideAnnotation()) {%> |
| 507 |
@Override |
| 508 |
<%}%> |
| 509 |
public void partDeactivated(IWorkbenchPart p) |
| 510 |
{ |
| 511 |
// Ignore. |
| 512 |
} |
| 513 |
<%if (genModel.useInterfaceOverrideAnnotation()) {%> |
| 514 |
@Override |
| 515 |
<%}%> |
| 516 |
public void partOpened(IWorkbenchPart p) |
| 517 |
{ |
| 518 |
// Ignore. |
| 519 |
} |
| 520 |
}; |
| 521 |
|
| 522 |
/** |
| 523 |
* Resources that have been removed since last activation. |
| 524 |
* <!-- begin-user-doc --> |
| 525 |
* <!-- end-user-doc --> |
| 526 |
* @generated |
| 527 |
*/ |
| 528 |
protected <%=_CollectionOfResource%> removedResources = new <%=_ArrayListOfResource%>(); |
| 529 |
|
| 530 |
/** |
| 531 |
* Resources that have been changed since last activation. |
| 532 |
* <!-- begin-user-doc --> |
| 533 |
* <!-- end-user-doc --> |
| 534 |
* @generated |
| 535 |
*/ |
| 536 |
protected <%=_CollectionOfResource%> changedResources = new <%=_ArrayListOfResource%>(); |
| 537 |
|
| 538 |
/** |
| 539 |
* Resources that have been saved. |
| 540 |
* <!-- begin-user-doc --> |
| 541 |
* <!-- end-user-doc --> |
| 542 |
* @generated |
| 543 |
*/ |
| 544 |
protected <%=_CollectionOfResource%> savedResources = new <%=_ArrayListOfResource%>(); |
| 545 |
|
| 546 |
/** |
| 547 |
* Map to store the diagnostic associated with a resource. |
| 548 |
* <!-- begin-user-doc --> |
| 549 |
* <!-- end-user-doc --> |
| 550 |
* @generated |
| 551 |
*/ |
| 552 |
protected <%=_MapOfResourceToDiagnostic%> resourceToDiagnosticMap = new <%=_LinkedHashMapOfResourceToDiagnostic%>(); |
| 553 |
|
| 554 |
/** |
| 555 |
* Controls whether the problem indication should be updated. |
| 556 |
* <!-- begin-user-doc --> |
| 557 |
* <!-- end-user-doc --> |
| 558 |
* @generated |
| 559 |
*/ |
| 560 |
protected boolean updateProblemIndication = true; |
| 561 |
|
| 562 |
/** |
| 563 |
* Adapter used to update the problem indication when resources are demanded loaded. |
| 564 |
* <!-- begin-user-doc --> |
| 565 |
* <!-- end-user-doc --> |
| 566 |
* @generated |
| 567 |
*/ |
| 568 |
protected EContentAdapter problemIndicationAdapter = |
| 569 |
new EContentAdapter() |
| 570 |
{ |
| 571 |
protected boolean dispatching; |
| 572 |
|
| 573 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 574 |
@Override |
| 575 |
<%}%> |
| 576 |
public void notifyChanged(Notification notification) |
| 577 |
{ |
| 578 |
if (notification.getNotifier() instanceof Resource) |
| 579 |
{ |
| 580 |
switch (notification.getFeatureID(Resource.class)) |
| 581 |
{ |
| 582 |
case Resource.RESOURCE__IS_LOADED: |
| 583 |
case Resource.RESOURCE__ERRORS: |
| 584 |
case Resource.RESOURCE__WARNINGS: |
| 585 |
{ |
| 586 |
Resource resource = (Resource)notification.getNotifier(); |
| 587 |
Diagnostic diagnostic = analyzeResourceProblems(resource, null); |
| 588 |
if (diagnostic.getSeverity() != Diagnostic.OK) |
| 589 |
{ |
| 590 |
resourceToDiagnosticMap.put(resource, diagnostic); |
| 591 |
} |
| 592 |
else |
| 593 |
{ |
| 594 |
resourceToDiagnosticMap.remove(resource); |
| 595 |
} |
| 596 |
dispatchUpdateProblemIndication(); |
| 597 |
break; |
| 598 |
} |
| 599 |
<%if (forceDefaultCase) {%> |
| 600 |
default: |
| 601 |
break; |
| 602 |
<%}%> |
| 603 |
} |
| 604 |
} |
| 605 |
else |
| 606 |
{ |
| 607 |
super.notifyChanged(notification); |
| 608 |
} |
| 609 |
} |
| 610 |
|
| 611 |
protected void dispatchUpdateProblemIndication() |
| 612 |
{ |
| 613 |
if (updateProblemIndication && !dispatching) |
| 614 |
{ |
| 615 |
dispatching = true; |
| 616 |
getSite().getShell().getDisplay().asyncExec |
| 617 |
(new Runnable() |
| 618 |
{ |
| 619 |
<%if (genModel.useInterfaceOverrideAnnotation()) {%> |
| 620 |
@Override |
| 621 |
<%}%> |
| 622 |
public void run() |
| 623 |
{ |
| 624 |
dispatching = false; |
| 625 |
updateProblemIndication(); |
| 626 |
} |
| 627 |
}); |
| 628 |
} |
| 629 |
} |
| 630 |
|
| 631 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 632 |
@Override |
| 633 |
<%}%> |
| 634 |
protected void setTarget(Resource target) |
| 635 |
{ |
| 636 |
basicSetTarget(target); |
| 637 |
} |
| 638 |
|
| 639 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 640 |
@Override |
| 641 |
<%}%> |
| 642 |
protected void unsetTarget(Resource target) |
| 643 |
{ |
| 644 |
basicUnsetTarget(target); |
| 645 |
resourceToDiagnosticMap.remove(target); |
| 646 |
dispatchUpdateProblemIndication(); |
| 647 |
} |
| 648 |
}; |
| 649 |
<%if (!genModel.isRichClientPlatform()) {%> |
| 650 |
|
| 651 |
/** |
| 652 |
* This listens for workspace changes. |
| 653 |
* <!-- begin-user-doc --> |
| 654 |
* <!-- end-user-doc --> |
| 655 |
* @generated |
| 656 |
*/ |
| 657 |
protected IResourceChangeListener resourceChangeListener = |
| 658 |
new IResourceChangeListener() |
| 659 |
{ |
| 660 |
<%if (genModel.useInterfaceOverrideAnnotation()) {%> |
| 661 |
@Override |
| 662 |
<%}%> |
| 663 |
public void resourceChanged(IResourceChangeEvent event) |
| 664 |
{ |
| 665 |
IResourceDelta delta = event.getDelta(); |
| 666 |
try |
| 667 |
{ |
| 668 |
class ResourceDeltaVisitor implements IResourceDeltaVisitor |
| 669 |
{ |
| 670 |
protected ResourceSet resourceSet = editingDomain.getResourceSet(); |
| 671 |
protected <%=_CollectionOfResource%> changedResources = new <%=_ArrayListOfResource%>(); |
| 672 |
protected <%=_CollectionOfResource%> removedResources = new <%=_ArrayListOfResource%>(); |
| 673 |
|
| 674 |
<%if (genModel.useInterfaceOverrideAnnotation()) {%> |
| 675 |
@Override |
| 676 |
<%}%> |
| 677 |
public boolean visit(<%if (genModel.getDecoration() != GenDecoration.NONE) {%>final <%}%>IResourceDelta delta) |
| 678 |
{ |
| 679 |
if (delta.getResource().getType() == IResource.FILE) |
| 680 |
{ |
| 681 |
if (delta.getKind() == IResourceDelta.REMOVED || |
| 682 |
delta.getKind() == IResourceDelta.CHANGED<%if (genModel.getDecoration() == GenDecoration.NONE) {%> && delta.getFlags() != IResourceDelta.MARKERS<%}%>) |
| 683 |
{ |
| 684 |
<%if (genModel.getDecoration() != GenDecoration.NONE) {%>final <%}%>Resource resource = resourceSet.getResource(URI.createPlatformResourceURI(delta.getFullPath().toString(), true), false); |
| 685 |
if (resource != null) |
| 686 |
{ |
| 687 |
if (delta.getKind() == IResourceDelta.REMOVED) |
| 688 |
{ |
| 689 |
removedResources.add(resource); |
| 690 |
} |
| 691 |
<%if (genModel.getDecoration() == GenDecoration.NONE) {%> |
| 692 |
else if (!savedResources.remove(resource)) |
| 693 |
{ |
| 694 |
changedResources.add(resource); |
| 695 |
} |
| 696 |
<%} else {%> |
| 697 |
else |
| 698 |
{ |
| 699 |
if ((delta.getFlags() & IResourceDelta.MARKERS) != 0) |
| 700 |
{ |
| 701 |
<%=_DiagnosticDecorator%>.DiagnosticAdapter.update(resource, markerHelper.getMarkerDiagnostics(resource, (IFile)delta.getResource()<%if (genModel.getRuntimeVersion().getValue() >= GenRuntimeVersion.EMF211_VALUE) {%>, false<%}%>)); |
| 702 |
} |
| 703 |
if ((delta.getFlags() & IResourceDelta.CONTENT) != 0) |
| 704 |
{ |
| 705 |
if (!savedResources.remove(resource)) |
| 706 |
{ |
| 707 |
changedResources.add(resource); |
| 708 |
} |
| 709 |
} |
| 710 |
} |
| 711 |
<%}%> |
| 712 |
} |
| 713 |
} |
| 714 |
return false; |
| 715 |
} |
| 716 |
|
| 717 |
return true; |
| 718 |
} |
| 719 |
|
| 720 |
public <%=_CollectionOfResource%> getChangedResources() |
| 721 |
{ |
| 722 |
return changedResources; |
| 723 |
} |
| 724 |
|
| 725 |
public <%=_CollectionOfResource%> getRemovedResources() |
| 726 |
{ |
| 727 |
return removedResources; |
| 728 |
} |
| 729 |
} |
| 730 |
|
| 731 |
final ResourceDeltaVisitor visitor = new ResourceDeltaVisitor(); |
| 732 |
delta.accept(visitor); |
| 733 |
|
| 734 |
if (!visitor.getRemovedResources().isEmpty()) |
| 735 |
{ |
| 736 |
getSite().getShell().getDisplay().asyncExec |
| 737 |
(new Runnable() |
| 738 |
{ |
| 739 |
<%if (genModel.useInterfaceOverrideAnnotation()) {%> |
| 740 |
@Override |
| 741 |
<%}%> |
| 742 |
public void run() |
| 743 |
{ |
| 744 |
removedResources.addAll(visitor.getRemovedResources()); |
| 745 |
if (!isDirty()) |
| 746 |
{ |
| 747 |
getSite().getPage().closeEditor(<%=genPackage.getEditorClassName()%>.this, false); |
| 748 |
} |
| 749 |
} |
| 750 |
}); |
| 751 |
} |
| 752 |
|
| 753 |
if (!visitor.getChangedResources().isEmpty()) |
| 754 |
{ |
| 755 |
getSite().getShell().getDisplay().asyncExec |
| 756 |
(new Runnable() |
| 757 |
{ |
| 758 |
<%if (genModel.useInterfaceOverrideAnnotation()) {%> |
| 759 |
@Override |
| 760 |
<%}%> |
| 761 |
public void run() |
| 762 |
{ |
| 763 |
changedResources.addAll(visitor.getChangedResources()); |
| 764 |
if (getSite().getPage().getActiveEditor() == <%=genPackage.getEditorClassName()%>.this) |
| 765 |
{ |
| 766 |
handleActivate(); |
| 767 |
} |
| 768 |
} |
| 769 |
}); |
| 770 |
} |
| 771 |
} |
| 772 |
catch (CoreException exception) |
| 773 |
{ |
| 774 |
<%=genPackage.getImportedEditorPluginClassName()%>.INSTANCE.log(exception); |
| 775 |
} |
| 776 |
} |
| 777 |
}; |
| 778 |
<%}%> |
| 779 |
|
| 780 |
/** |
| 781 |
* Handles activation of the editor or it's associated views. |
| 782 |
* <!-- begin-user-doc --> |
| 783 |
* <!-- end-user-doc --> |
| 784 |
* @generated |
| 785 |
*/ |
| 786 |
protected void handleActivate() |
| 787 |
{ |
| 788 |
// Recompute the read only state. |
| 789 |
// |
| 790 |
if (editingDomain.getResourceToReadOnlyMap() != null) |
| 791 |
{ |
| 792 |
editingDomain.getResourceToReadOnlyMap().clear(); |
| 793 |
|
| 794 |
// Refresh any actions that may become enabled or disabled. |
| 795 |
// |
| 796 |
setSelection(getSelection()); |
| 797 |
} |
| 798 |
|
| 799 |
if (!removedResources.isEmpty()) |
| 800 |
{ |
| 801 |
if (handleDirtyConflict()) |
| 802 |
{ |
| 803 |
getSite().getPage().closeEditor(<%=genPackage.getEditorClassName()%>.this, false); |
| 804 |
} |
| 805 |
else |
| 806 |
{ |
| 807 |
removedResources.clear(); |
| 808 |
changedResources.clear(); |
| 809 |
savedResources.clear(); |
| 810 |
} |
| 811 |
} |
| 812 |
else if (!changedResources.isEmpty()) |
| 813 |
{ |
| 814 |
changedResources.removeAll(savedResources); |
| 815 |
handleChangedResources(); |
| 816 |
changedResources.clear(); |
| 817 |
savedResources.clear(); |
| 818 |
} |
| 819 |
} |
| 820 |
|
| 821 |
/** |
| 822 |
* Handles what to do with changed resources on activation. |
| 823 |
* <!-- begin-user-doc --> |
| 824 |
* <!-- end-user-doc --> |
| 825 |
* @generated |
| 826 |
*/ |
| 827 |
protected void handleChangedResources() |
| 828 |
{ |
| 829 |
if (!changedResources.isEmpty() && (!isDirty() || handleDirtyConflict())) |
| 830 |
{ |
| 831 |
ResourceSet resourceSet = editingDomain.getResourceSet(); |
| 832 |
if (isDirty()) |
| 833 |
{ |
| 834 |
changedResources.addAll(resourceSet.getResources()); |
| 835 |
} |
| 836 |
editingDomain.getCommandStack().flush(); |
| 837 |
|
| 838 |
updateProblemIndication = false; |
| 839 |
<%if (genModel.useGenerics()) {%> |
| 840 |
for (Resource resource : changedResources) |
| 841 |
<%} else {%> |
| 842 |
for (Iterator i = changedResources.iterator(); i.hasNext(); ) |
| 843 |
<%}%> |
| 844 |
{ |
| 845 |
<%if (!genModel.useGenerics()) {%> |
| 846 |
Resource resource = (Resource)i.next(); |
| 847 |
<%}%> |
| 848 |
if (resource.isLoaded()) |
| 849 |
{ |
| 850 |
resource.unload(); |
| 851 |
try |
| 852 |
{ |
| 853 |
resource.load(resourceSet.getLoadOptions()); |
| 854 |
} |
| 855 |
catch (IOException exception) |
| 856 |
{ |
| 857 |
if (!resourceToDiagnosticMap.containsKey(resource)) |
| 858 |
{ |
| 859 |
resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception)); |
| 860 |
} |
| 861 |
} |
| 862 |
} |
| 863 |
} |
| 864 |
|
| 865 |
<%if (genModel.getRuntimeVersion().getValue() >= GenRuntimeVersion.EMF24_VALUE) {%> |
| 866 |
if (AdapterFactoryEditingDomain.isStale(editorSelection)) |
| 867 |
{ |
| 868 |
setSelection(StructuredSelection.EMPTY); |
| 869 |
} |
| 870 |
<%}%> |
| 871 |
|
| 872 |
updateProblemIndication = true; |
| 873 |
updateProblemIndication(); |
| 874 |
} |
| 875 |
} |
| 876 |
|
| 877 |
/** |
| 878 |
* Updates the problems indication with the information described in the specified diagnostic. |
| 879 |
* <!-- begin-user-doc --> |
| 880 |
* <!-- end-user-doc --> |
| 881 |
* @generated |
| 882 |
*/ |
| 883 |
protected void updateProblemIndication() |
| 884 |
{ |
| 885 |
if (updateProblemIndication) |
| 886 |
{ |
| 887 |
BasicDiagnostic diagnostic = |
| 888 |
new BasicDiagnostic |
| 889 |
(Diagnostic.OK, |
| 890 |
"<%=genPackage.getGenModel().getEditorPluginID()%>",<%=genModel.getNonNLS()%> |
| 891 |
0, |
| 892 |
null, |
| 893 |
new Object [] { editingDomain.getResourceSet() }); |
| 894 |
<%if (genModel.useGenerics()) {%> |
| 895 |
for (Diagnostic childDiagnostic : resourceToDiagnosticMap.values()) |
| 896 |
<%} else {%> |
| 897 |
for (Iterator i = resourceToDiagnosticMap.values().iterator(); i.hasNext(); ) |
| 898 |
<%}%> |
| 899 |
{ |
| 900 |
<%if (!genModel.useGenerics()) {%> |
| 901 |
Diagnostic childDiagnostic = (Diagnostic)i.next(); |
| 902 |
<%}%> |
| 903 |
if (childDiagnostic.getSeverity() != Diagnostic.OK) |
| 904 |
{ |
| 905 |
diagnostic.add(childDiagnostic); |
| 906 |
} |
| 907 |
} |
| 908 |
|
| 909 |
int lastEditorPage = getPageCount() - 1; |
| 910 |
if (lastEditorPage >= 0 && getEditor(lastEditorPage) instanceof ProblemEditorPart) |
| 911 |
{ |
| 912 |
((ProblemEditorPart)getEditor(lastEditorPage)).setDiagnostic(diagnostic); |
| 913 |
if (diagnostic.getSeverity() != Diagnostic.OK) |
| 914 |
{ |
| 915 |
setActivePage(lastEditorPage); |
| 916 |
} |
| 917 |
} |
| 918 |
else if (diagnostic.getSeverity() != Diagnostic.OK) |
| 919 |
{ |
| 920 |
ProblemEditorPart problemEditorPart = new ProblemEditorPart(); |
| 921 |
problemEditorPart.setDiagnostic(diagnostic); |
| 922 |
<%if (!genModel.isRichClientPlatform()) {%> |
| 923 |
problemEditorPart.setMarkerHelper(markerHelper); |
| 924 |
<%}%> |
| 925 |
try |
| 926 |
{ |
| 927 |
addPage(++lastEditorPage, problemEditorPart, getEditorInput()); |
| 928 |
setPageText(lastEditorPage, problemEditorPart.getPartName()); |
| 929 |
setActivePage(lastEditorPage); |
| 930 |
showTabs(); |
| 931 |
} |
| 932 |
catch (PartInitException exception) |
| 933 |
{ |
| 934 |
<%=genPackage.getImportedEditorPluginClassName()%>.INSTANCE.log(exception); |
| 935 |
} |
| 936 |
} |
| 937 |
<%if (!genModel.isRichClientPlatform()) {%> |
| 938 |
|
| 939 |
if (markerHelper.hasMarkers(editingDomain.getResourceSet())) |
| 940 |
{ |
| 941 |
<%if (genModel.getRuntimeVersion().getValue() < GenRuntimeVersion.EMF213_VALUE) {%> |
| 942 |
markerHelper.deleteMarkers(editingDomain.getResourceSet()); |
| 943 |
if (diagnostic.getSeverity() != Diagnostic.OK) |
| 944 |
{ |
| 945 |
try |
| 946 |
{ |
| 947 |
markerHelper.createMarkers(diagnostic); |
| 948 |
} |
| 949 |
catch (CoreException exception) |
| 950 |
{ |
| 951 |
<%=genPackage.getImportedEditorPluginClassName()%>.INSTANCE.log(exception); |
| 952 |
} |
| 953 |
} |
| 954 |
<%} else {%> |
| 955 |
try |
| 956 |
{ |
| 957 |
markerHelper.updateMarkers(diagnostic); |
| 958 |
} |
| 959 |
catch (CoreException exception) |
| 960 |
{ |
| 961 |
<%=genPackage.getImportedEditorPluginClassName()%>.INSTANCE.log(exception); |
| 962 |
} |
| 963 |
<%}%> |
| 964 |
} |
| 965 |
<%}%> |
| 966 |
} |
| 967 |
} |
| 968 |
|
| 969 |
/** |
| 970 |
* Shows a dialog that asks if conflicting changes should be discarded. |
| 971 |
* <!-- begin-user-doc --> |
| 972 |
* <!-- end-user-doc --> |
| 973 |
* @generated |
| 974 |
*/ |
| 975 |
protected boolean handleDirtyConflict() |
| 976 |
{ |
| 977 |
return |
| 978 |
MessageDialog.openQuestion |
| 979 |
(getSite().getShell(), |
| 980 |
getString("_UI_FileConflict_label"),<%=genModel.getNonNLS()%> |
| 981 |
getString("_WARN_FileConflict"));<%=genModel.getNonNLS()%> |
| 982 |
} |
| 983 |
|
| 984 |
/** |
| 985 |
* This creates a model editor. |
| 986 |
* <!-- begin-user-doc --> |
| 987 |
* <!-- end-user-doc --> |
| 988 |
* @generated |
| 989 |
*/ |
| 990 |
public <%=genPackage.getEditorClassName()%>() |
| 991 |
{ |
| 992 |
super(); |
| 993 |
initializeEditingDomain(); |
| 994 |
} |
| 995 |
|
| 996 |
/** |
| 997 |
* This sets up the editing domain for the model editor. |
| 998 |
* <!-- begin-user-doc --> |
| 999 |
* <!-- end-user-doc --> |
| 1000 |
* @generated |
| 1001 |
*/ |
| 1002 |
protected void initializeEditingDomain() |
| 1003 |
{ |
| 1004 |
// Create an adapter factory that yields item providers. |
| 1005 |
// |
| 1006 |
adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE); |
| 1007 |
|
| 1008 |
adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory()); |
| 1009 |
<%@ include file="Editor/addItemProviderFactories.override.javajetinc" fail="alternative"%> |
| 1010 |
<%@ start%> |
| 1011 |
<%for (GenPackage aGenPackage : genModel.getAllGenPackagesWithClassifiers()) {%> |
| 1012 |
<%if (!aGenPackage.getGenClasses().isEmpty() && aGenPackage.getGenModel().hasEditSupport()) {%> |
| 1013 |
adapterFactory.addAdapterFactory(new <%=aGenPackage.getImportedItemProviderAdapterFactoryClassName()%>()); |
| 1014 |
<%}%> |
| 1015 |
<%}%> |
| 1016 |
<%for (GenPackage aGenPackage : genModel.getAllUsedGenPackagesWithClassifiers()) {%> |
| 1017 |
<%if (!aGenPackage.getGenClasses().isEmpty() && aGenPackage.getGenModel().hasEditSupport()) {%> |
| 1018 |
adapterFactory.addAdapterFactory(new <%=aGenPackage.getImportedItemProviderAdapterFactoryClassName()%>()); |
| 1019 |
<%}%> |
| 1020 |
<%}%> |
| 1021 |
<%@ include file="Editor/addItemProviderFactories.insert.javajetinc" fail="silent"%> |
| 1022 |
<%@end%><%//Editor/addItemproviderFactories.override.javajetinc"%> |
| 1023 |
adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory()); |
| 1024 |
|
| 1025 |
// Create the command stack that will notify this editor as commands are executed. |
| 1026 |
// |
| 1027 |
<%if (genModel.getDecoration() != GenDecoration.LIVE || genModel.getRuntimeVersion().getValue() < GenRuntimeVersion.EMF212_VALUE) {%> |
| 1028 |
BasicCommandStack commandStack = new BasicCommandStack(); |
| 1029 |
<%} else {%> |
| 1030 |
BasicCommandStack commandStack = |
| 1031 |
new BasicCommandStack() |
| 1032 |
{ |
| 1033 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 1034 |
@Override |
| 1035 |
<%}%> |
| 1036 |
public void execute(Command command) |
| 1037 |
{ |
| 1038 |
// Cancel live validation before executing a command that will trigger a new round of validation. |
| 1039 |
// |
| 1040 |
if (!(command instanceof <%=genModel.getImportedName("org.eclipse.emf.common.command.AbstractCommand")%>.NonDirtying)) |
| 1041 |
{ |
| 1042 |
<%=_DiagnosticDecorator%>.cancel(editingDomain); |
| 1043 |
} |
| 1044 |
super.execute(command); |
| 1045 |
} |
| 1046 |
}; |
| 1047 |
<%}%> |
| 1048 |
|
| 1049 |
// Add a listener to set the most recent command's affected objects to be the selection of the viewer with focus. |
| 1050 |
// |
| 1051 |
commandStack.addCommandStackListener |
| 1052 |
(new CommandStackListener() |
| 1053 |
{ |
| 1054 |
<%if (genModel.useInterfaceOverrideAnnotation()) {%> |
| 1055 |
@Override |
| 1056 |
<%}%> |
| 1057 |
public void commandStackChanged(final EventObject event) |
| 1058 |
{ |
| 1059 |
getContainer().getDisplay().asyncExec |
| 1060 |
(new Runnable() |
| 1061 |
{ |
| 1062 |
<%if (genModel.useInterfaceOverrideAnnotation()) {%> |
| 1063 |
@Override |
| 1064 |
<%}%> |
| 1065 |
public void run() |
| 1066 |
{ |
| 1067 |
firePropertyChange(IEditorPart.PROP_DIRTY); |
| 1068 |
|
| 1069 |
// Try to select the affected objects. |
| 1070 |
// |
| 1071 |
Command mostRecentCommand = ((CommandStack)event.getSource()).getMostRecentCommand(); |
| 1072 |
if (mostRecentCommand != null) |
| 1073 |
{ |
| 1074 |
setSelectionToViewer(mostRecentCommand.getAffectedObjects()); |
| 1075 |
} |
| 1076 |
for (Iterator<%if (genModel.useGenerics()) {%><PropertySheetPage><%}%> i = propertySheetPages.iterator(); i.hasNext(); ) |
| 1077 |
{ |
| 1078 |
PropertySheetPage propertySheetPage = <%if (!genModel.useGenerics()) {%>(PropertySheetPage)<%}%>i.next(); |
| 1079 |
if (propertySheetPage.getControl() == null || propertySheetPage.getControl().isDisposed()) |
| 1080 |
{ |
| 1081 |
i.remove(); |
| 1082 |
} |
| 1083 |
else |
| 1084 |
{ |
| 1085 |
propertySheetPage.refresh(); |
| 1086 |
} |
| 1087 |
} |
| 1088 |
} |
| 1089 |
}); |
| 1090 |
} |
| 1091 |
}); |
| 1092 |
|
| 1093 |
// Create the editing domain with a special command stack. |
| 1094 |
// |
| 1095 |
editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new <%=_HashMapOfResourceToBoolean%>()); |
| 1096 |
} |
| 1097 |
|
| 1098 |
/** |
| 1099 |
* This is here for the listener to be able to call it. |
| 1100 |
* <!-- begin-user-doc --> |
| 1101 |
* <!-- end-user-doc --> |
| 1102 |
* @generated |
| 1103 |
*/ |
| 1104 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 1105 |
@Override |
| 1106 |
<%}%> |
| 1107 |
protected void firePropertyChange(int action) |
| 1108 |
{ |
| 1109 |
super.firePropertyChange(action); |
| 1110 |
} |
| 1111 |
|
| 1112 |
/** |
| 1113 |
* This sets the selection into whichever viewer is active. |
| 1114 |
* <!-- begin-user-doc --> |
| 1115 |
* <!-- end-user-doc --> |
| 1116 |
* @generated |
| 1117 |
*/ |
| 1118 |
public void setSelectionToViewer(<%=_CollectionOfAnything%> collection) |
| 1119 |
{ |
| 1120 |
final <%=_CollectionOfAnything%> theSelection = collection; |
| 1121 |
// Make sure it's okay. |
| 1122 |
// |
| 1123 |
if (theSelection != null && !theSelection.isEmpty()) |
| 1124 |
{ |
| 1125 |
Runnable runnable = |
| 1126 |
new Runnable() |
| 1127 |
{ |
| 1128 |
<%if (genModel.useInterfaceOverrideAnnotation()) {%> |
| 1129 |
@Override |
| 1130 |
<%}%> |
| 1131 |
public void run() |
| 1132 |
{ |
| 1133 |
// Try to select the items in the current content viewer of the editor. |
| 1134 |
// |
| 1135 |
if (currentViewer != null) |
| 1136 |
{ |
| 1137 |
currentViewer.setSelection(new StructuredSelection(theSelection.toArray()), true); |
| 1138 |
} |
| 1139 |
} |
| 1140 |
}; |
| 1141 |
getSite().getShell().getDisplay().asyncExec(runnable); |
| 1142 |
} |
| 1143 |
} |
| 1144 |
|
| 1145 |
/** |
| 1146 |
* This returns the editing domain as required by the {@link IEditingDomainProvider} interface. |
| 1147 |
* This is important for implementing the static methods of {@link AdapterFactoryEditingDomain} |
| 1148 |
* and for supporting {@link org.eclipse.emf.edit.ui.action.CommandAction}. |
| 1149 |
* <!-- begin-user-doc --> |
| 1150 |
* <!-- end-user-doc --> |
| 1151 |
* @generated |
| 1152 |
*/ |
| 1153 |
<%if (genModel.useInterfaceOverrideAnnotation()) {%> |
| 1154 |
@Override |
| 1155 |
<%}%> |
| 1156 |
public EditingDomain getEditingDomain() |
| 1157 |
{ |
| 1158 |
return editingDomain; |
| 1159 |
} |
| 1160 |
|
| 1161 |
/** |
| 1162 |
* <!-- begin-user-doc --> |
| 1163 |
* <!-- end-user-doc --> |
| 1164 |
* @generated |
| 1165 |
*/ |
| 1166 |
public class ReverseAdapterFactoryContentProvider extends AdapterFactoryContentProvider |
| 1167 |
{ |
| 1168 |
/** |
| 1169 |
* <!-- begin-user-doc --> |
| 1170 |
* <!-- end-user-doc --> |
| 1171 |
* @generated |
| 1172 |
*/ |
| 1173 |
public ReverseAdapterFactoryContentProvider(AdapterFactory adapterFactory) |
| 1174 |
{ |
| 1175 |
super(adapterFactory); |
| 1176 |
} |
| 1177 |
|
| 1178 |
/** |
| 1179 |
* <!-- begin-user-doc --> |
| 1180 |
* <!-- end-user-doc --> |
| 1181 |
* @generated |
| 1182 |
*/ |
| 1183 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 1184 |
@Override |
| 1185 |
<%}%> |
| 1186 |
public Object [] getElements(Object object) |
| 1187 |
{ |
| 1188 |
Object parent = super.getParent(object); |
| 1189 |
return (parent == null ? Collections.EMPTY_SET : Collections.singleton(parent)).toArray(); |
| 1190 |
} |
| 1191 |
|
| 1192 |
/** |
| 1193 |
* <!-- begin-user-doc --> |
| 1194 |
* <!-- end-user-doc --> |
| 1195 |
* @generated |
| 1196 |
*/ |
| 1197 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 1198 |
@Override |
| 1199 |
<%}%> |
| 1200 |
public Object [] getChildren(Object object) |
| 1201 |
{ |
| 1202 |
Object parent = super.getParent(object); |
| 1203 |
return (parent == null ? Collections.EMPTY_SET : Collections.singleton(parent)).toArray(); |
| 1204 |
} |
| 1205 |
|
| 1206 |
/** |
| 1207 |
* <!-- begin-user-doc --> |
| 1208 |
* <!-- end-user-doc --> |
| 1209 |
* @generated |
| 1210 |
*/ |
| 1211 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 1212 |
@Override |
| 1213 |
<%}%> |
| 1214 |
public boolean hasChildren(Object object) |
| 1215 |
{ |
| 1216 |
Object parent = super.getParent(object); |
| 1217 |
return parent != null; |
| 1218 |
} |
| 1219 |
|
| 1220 |
/** |
| 1221 |
* <!-- begin-user-doc --> |
| 1222 |
* <!-- end-user-doc --> |
| 1223 |
* @generated |
| 1224 |
*/ |
| 1225 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 1226 |
@Override |
| 1227 |
<%}%> |
| 1228 |
public Object getParent(Object object) |
| 1229 |
{ |
| 1230 |
return null; |
| 1231 |
} |
| 1232 |
} |
| 1233 |
<%if (genPackage.isMultipleEditorPages()) {%> |
| 1234 |
|
| 1235 |
/** |
| 1236 |
* <!-- begin-user-doc --> |
| 1237 |
* <!-- end-user-doc --> |
| 1238 |
* @generated |
| 1239 |
*/ |
| 1240 |
public void setCurrentViewerPane(ViewerPane viewerPane) |
| 1241 |
{ |
| 1242 |
if (currentViewerPane != viewerPane) |
| 1243 |
{ |
| 1244 |
if (currentViewerPane != null) |
| 1245 |
{ |
| 1246 |
currentViewerPane.showFocus(false); |
| 1247 |
} |
| 1248 |
currentViewerPane = viewerPane; |
| 1249 |
} |
| 1250 |
setCurrentViewer(currentViewerPane.getViewer()); |
| 1251 |
} |
| 1252 |
<%}%> |
| 1253 |
|
| 1254 |
/** |
| 1255 |
* This makes sure that one content viewer, either for the current page or the outline view, if it has focus, |
| 1256 |
* is the current one. |
| 1257 |
* <!-- begin-user-doc --> |
| 1258 |
* <!-- end-user-doc --> |
| 1259 |
* @generated |
| 1260 |
*/ |
| 1261 |
public void setCurrentViewer(Viewer viewer) |
| 1262 |
{ |
| 1263 |
// If it is changing... |
| 1264 |
// |
| 1265 |
if (currentViewer != viewer) |
| 1266 |
{ |
| 1267 |
if (selectionChangedListener == null) |
| 1268 |
{ |
| 1269 |
// Create the listener on demand. |
| 1270 |
// |
| 1271 |
selectionChangedListener = |
| 1272 |
new ISelectionChangedListener() |
| 1273 |
{ |
| 1274 |
// This just notifies those things that are affected by the section. |
| 1275 |
// |
| 1276 |
<%if (genModel.useInterfaceOverrideAnnotation()) {%> |
| 1277 |
@Override |
| 1278 |
<%}%> |
| 1279 |
public void selectionChanged(SelectionChangedEvent selectionChangedEvent) |
| 1280 |
{ |
| 1281 |
setSelection(selectionChangedEvent.getSelection()); |
| 1282 |
} |
| 1283 |
}; |
| 1284 |
} |
| 1285 |
|
| 1286 |
// Stop listening to the old one. |
| 1287 |
// |
| 1288 |
if (currentViewer != null) |
| 1289 |
{ |
| 1290 |
currentViewer.removeSelectionChangedListener(selectionChangedListener); |
| 1291 |
} |
| 1292 |
|
| 1293 |
// Start listening to the new one. |
| 1294 |
// |
| 1295 |
if (viewer != null) |
| 1296 |
{ |
| 1297 |
viewer.addSelectionChangedListener(selectionChangedListener); |
| 1298 |
} |
| 1299 |
|
| 1300 |
// Remember it. |
| 1301 |
// |
| 1302 |
currentViewer = viewer; |
| 1303 |
|
| 1304 |
// Set the editors selection based on the current viewer's selection. |
| 1305 |
// |
| 1306 |
setSelection(currentViewer == null ? StructuredSelection.EMPTY : currentViewer.getSelection()); |
| 1307 |
} |
| 1308 |
} |
| 1309 |
|
| 1310 |
/** |
| 1311 |
* This returns the viewer as required by the {@link IViewerProvider} interface. |
| 1312 |
* <!-- begin-user-doc --> |
| 1313 |
* <!-- end-user-doc --> |
| 1314 |
* @generated |
| 1315 |
*/ |
| 1316 |
<%if (genModel.useInterfaceOverrideAnnotation()) {%> |
| 1317 |
@Override |
| 1318 |
<%}%> |
| 1319 |
public Viewer getViewer() |
| 1320 |
{ |
| 1321 |
return currentViewer; |
| 1322 |
} |
| 1323 |
|
| 1324 |
/** |
| 1325 |
* This creates a context menu for the viewer and adds a listener as well registering the menu for extension. |
| 1326 |
* <!-- begin-user-doc --> |
| 1327 |
* <!-- end-user-doc --> |
| 1328 |
* @generated |
| 1329 |
*/ |
| 1330 |
protected void createContextMenuFor(StructuredViewer viewer) |
| 1331 |
{ |
| 1332 |
MenuManager contextMenu = new MenuManager("#PopUp");<%=genModel.getNonNLS()%> |
| 1333 |
contextMenu.add(new Separator("additions"));<%=genModel.getNonNLS()%> |
| 1334 |
contextMenu.setRemoveAllWhenShown(true); |
| 1335 |
contextMenu.addMenuListener(this); |
| 1336 |
Menu menu= contextMenu.createContextMenu(viewer.getControl()); |
| 1337 |
viewer.getControl().setMenu(menu); |
| 1338 |
<%if (genModel.getRuntimeVersion().getValue() >= GenRuntimeVersion.EMF23_VALUE) {%> |
| 1339 |
getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer)); |
| 1340 |
<%} else {%> |
| 1341 |
getSite().registerContextMenu(contextMenu, viewer); |
| 1342 |
<%}%> |
| 1343 |
|
| 1344 |
int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK; |
| 1345 |
Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance()<%if (genModel.getRuntimeVersion().getValue() >= GenRuntimeVersion.EMF29_VALUE) {%>, LocalSelectionTransfer.getTransfer(), FileTransfer.getInstance()<%}%> }; |
| 1346 |
viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer)); |
| 1347 |
viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer)); |
| 1348 |
} |
| 1349 |
|
| 1350 |
/** |
| 1351 |
* This is the method called to load a resource into the editing domain's resource set based on the editor's input. |
| 1352 |
* <!-- begin-user-doc --> |
| 1353 |
* <!-- end-user-doc --> |
| 1354 |
* @generated |
| 1355 |
*/ |
| 1356 |
public void createModel() |
| 1357 |
{ |
| 1358 |
<%if (genModel.getRuntimeVersion().getValue() >= GenRuntimeVersion.EMF211_VALUE) {%> |
| 1359 |
URI resourceURI = EditUIUtil.getURI(getEditorInput(), editingDomain.getResourceSet().getURIConverter()); |
| 1360 |
<%} else if (genModel.getRuntimeVersion().getValue() >= GenRuntimeVersion.EMF23_VALUE) {%> |
| 1361 |
URI resourceURI = EditUIUtil.getURI(getEditorInput()); |
| 1362 |
<%} else if (genModel.isRichClientPlatform()) {%> |
| 1363 |
URI resourceURI = URI.createURI(getEditorInput().getName()); |
| 1364 |
<%} else {%> |
| 1365 |
// Assumes that the input is a file object. |
| 1366 |
// |
| 1367 |
IFileEditorInput modelFile = (IFileEditorInput)getEditorInput(); |
| 1368 |
URI resourceURI = URI.createPlatformResourceURI(modelFile.getFile().getFullPath().toString(), true); |
| 1369 |
<%}%> |
| 1370 |
Exception exception = null; |
| 1371 |
Resource resource = null; |
| 1372 |
try |
| 1373 |
{ |
| 1374 |
// Load the resource through the editing domain. |
| 1375 |
// |
| 1376 |
resource = editingDomain.getResourceSet().getResource(resourceURI, true); |
| 1377 |
} |
| 1378 |
catch (Exception e) |
| 1379 |
{ |
| 1380 |
exception = e; |
| 1381 |
resource = editingDomain.getResourceSet().getResource(resourceURI, false); |
| 1382 |
} |
| 1383 |
|
| 1384 |
Diagnostic diagnostic = analyzeResourceProblems(resource, exception); |
| 1385 |
if (diagnostic.getSeverity() != Diagnostic.OK) |
| 1386 |
{ |
| 1387 |
resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception)); |
| 1388 |
} |
| 1389 |
editingDomain.getResourceSet().eAdapters().add(problemIndicationAdapter); |
| 1390 |
} |
| 1391 |
|
| 1392 |
/** |
| 1393 |
* Returns a diagnostic describing the errors and warnings listed in the resource |
| 1394 |
* and the specified exception (if any). |
| 1395 |
* <!-- begin-user-doc --> |
| 1396 |
* <!-- end-user-doc --> |
| 1397 |
* @generated |
| 1398 |
*/ |
| 1399 |
public Diagnostic analyzeResourceProblems(Resource resource, Exception exception) |
| 1400 |
{ |
| 1401 |
boolean hasErrors = !resource.getErrors().isEmpty(); |
| 1402 |
if (hasErrors || !resource.getWarnings().isEmpty()) |
| 1403 |
{ |
| 1404 |
BasicDiagnostic basicDiagnostic = |
| 1405 |
new BasicDiagnostic |
| 1406 |
(hasErrors ? Diagnostic.ERROR : Diagnostic.WARNING, |
| 1407 |
"<%=genPackage.getGenModel().getEditorPluginID()%>",<%=genModel.getNonNLS()%> |
| 1408 |
0, |
| 1409 |
getString("_UI_CreateModelError_message", resource.getURI()),<%=genModel.getNonNLS()%> |
| 1410 |
new Object [] { exception == null ? (Object)resource : exception }); |
| 1411 |
basicDiagnostic.merge(EcoreUtil.computeDiagnostic(resource, true)); |
| 1412 |
return basicDiagnostic; |
| 1413 |
} |
| 1414 |
else if (exception != null) |
| 1415 |
{ |
| 1416 |
return |
| 1417 |
new BasicDiagnostic |
| 1418 |
(Diagnostic.ERROR, |
| 1419 |
"<%=genPackage.getGenModel().getEditorPluginID()%>",<%=genModel.getNonNLS()%> |
| 1420 |
0, |
| 1421 |
getString("_UI_CreateModelError_message", resource.getURI()),<%=genModel.getNonNLS()%> |
| 1422 |
new Object[] { exception }); |
| 1423 |
} |
| 1424 |
else |
| 1425 |
{ |
| 1426 |
return Diagnostic.OK_INSTANCE; |
| 1427 |
} |
| 1428 |
} |
| 1429 |
|
| 1430 |
/** |
| 1431 |
* This is the method used by the framework to install your own controls. |
| 1432 |
* <!-- begin-user-doc --> |
| 1433 |
* <!-- end-user-doc --> |
| 1434 |
* @generated |
| 1435 |
*/ |
| 1436 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 1437 |
@Override |
| 1438 |
<%}%> |
| 1439 |
public void createPages() |
| 1440 |
{ |
| 1441 |
// Creates the model from the editor input |
| 1442 |
// |
| 1443 |
createModel(); |
| 1444 |
|
| 1445 |
// Only creates the other pages if there is something that can be edited |
| 1446 |
// |
| 1447 |
if (!getEditingDomain().getResourceSet().getResources().isEmpty()) |
| 1448 |
{ |
| 1449 |
// Create a page for the selection tree view. |
| 1450 |
// |
| 1451 |
<%if (genPackage.isMultipleEditorPages()) {%> |
| 1452 |
{ |
| 1453 |
ViewerPane viewerPane = |
| 1454 |
new ViewerPane(getSite().getPage(), <%=genPackage.getEditorClassName()%>.this) |
| 1455 |
{ |
| 1456 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 1457 |
@Override |
| 1458 |
<%}%> |
| 1459 |
public Viewer createViewer(Composite composite) |
| 1460 |
{ |
| 1461 |
Tree tree = new Tree(composite, SWT.MULTI); |
| 1462 |
TreeViewer newTreeViewer = new TreeViewer(tree); |
| 1463 |
return newTreeViewer; |
| 1464 |
} |
| 1465 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 1466 |
@Override |
| 1467 |
<%}%> |
| 1468 |
public void requestActivation() |
| 1469 |
{ |
| 1470 |
super.requestActivation(); |
| 1471 |
setCurrentViewerPane(this); |
| 1472 |
} |
| 1473 |
}; |
| 1474 |
viewerPane.createControl(getContainer()); |
| 1475 |
|
| 1476 |
selectionViewer = (TreeViewer)viewerPane.getViewer(); |
| 1477 |
selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); |
| 1478 |
selectionViewer.setUseHashlookup(true); |
| 1479 |
|
| 1480 |
selectionViewer.setLabelProvider(<%if (useStyledLabelProvider) {%>new <%=_DelegatingAdapterFactoryLabelProvider%>(<%}%><%if (genModel.getDecoration() != GenDecoration.NONE) {%>new <%=_DecoratingColumLabelProvider%>(<%}%>new <%=_AdapterFactoryLabelProvider%>(adapterFactory<%if (useExtendedLabelProvider) {%>, selectionViewer<%}%>)<%if (genModel.getDecoration() != GenDecoration.NONE) {%>, new <%=_DiagnosticDecorator%>(editingDomain<%if (genModel.getDecoration() == GenDecoration.MANUAL) {%>.getResourceSet()<%}%>, selectionViewer<%if (genModel.getDecoration() == GenDecoration.LIVE) {%>, <%=genPackage.getImportedEditorPluginClassName()%>.getPlugin().getDialogSettings()<%}%>))<%}%><%if (useStyledLabelProvider) {%>)<%}%>); |
| 1481 |
selectionViewer.setInput(editingDomain.getResourceSet()); |
| 1482 |
selectionViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true); |
| 1483 |
viewerPane.setTitle(editingDomain.getResourceSet()); |
| 1484 |
|
| 1485 |
new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory); |
| 1486 |
<%if (genModel.getDecoration() != GenDecoration.NONE) {%> |
| 1487 |
new <%=genModel.getImportedName("org.eclipse.emf.common.ui.viewer.ColumnViewerInformationControlToolTipSupport")%>(selectionViewer, new <%=_DiagnosticDecorator%>.EditingDomainLocationListener(editingDomain, selectionViewer)); |
| 1488 |
<%}%> |
| 1489 |
|
| 1490 |
createContextMenuFor(selectionViewer); |
| 1491 |
int pageIndex = addPage(viewerPane.getControl()); |
| 1492 |
setPageText(pageIndex, getString("_UI_SelectionPage_label"));<%=genModel.getNonNLS()%> |
| 1493 |
} |
| 1494 |
|
| 1495 |
// Create a page for the parent tree view. |
| 1496 |
// |
| 1497 |
{ |
| 1498 |
ViewerPane viewerPane = |
| 1499 |
new ViewerPane(getSite().getPage(), <%=genPackage.getEditorClassName()%>.this) |
| 1500 |
{ |
| 1501 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 1502 |
@Override |
| 1503 |
<%}%> |
| 1504 |
public Viewer createViewer(Composite composite) |
| 1505 |
{ |
| 1506 |
Tree tree = new Tree(composite, SWT.MULTI); |
| 1507 |
TreeViewer newTreeViewer = new TreeViewer(tree); |
| 1508 |
return newTreeViewer; |
| 1509 |
} |
| 1510 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 1511 |
@Override |
| 1512 |
<%}%> |
| 1513 |
public void requestActivation() |
| 1514 |
{ |
| 1515 |
super.requestActivation(); |
| 1516 |
setCurrentViewerPane(this); |
| 1517 |
} |
| 1518 |
}; |
| 1519 |
viewerPane.createControl(getContainer()); |
| 1520 |
|
| 1521 |
parentViewer = (TreeViewer)viewerPane.getViewer(); |
| 1522 |
parentViewer.setAutoExpandLevel(30); |
| 1523 |
parentViewer.setContentProvider(new ReverseAdapterFactoryContentProvider(adapterFactory)); |
| 1524 |
parentViewer.setLabelProvider(<%if (useStyledLabelProvider) {%>new <%=_DelegatingAdapterFactoryLabelProvider%>(<%}%>new <%=_AdapterFactoryLabelProvider%>(adapterFactory<%if (useExtendedLabelProvider) {%>, parentViewer<%}%>)<%if (useStyledLabelProvider) {%>)<%}%>); |
| 1525 |
|
| 1526 |
createContextMenuFor(parentViewer); |
| 1527 |
int pageIndex = addPage(viewerPane.getControl()); |
| 1528 |
setPageText(pageIndex, getString("_UI_ParentPage_label"));<%=genModel.getNonNLS()%> |
| 1529 |
} |
| 1530 |
|
| 1531 |
// This is the page for the list viewer |
| 1532 |
// |
| 1533 |
{ |
| 1534 |
ViewerPane viewerPane = |
| 1535 |
new ViewerPane(getSite().getPage(), <%=genPackage.getEditorClassName()%>.this) |
| 1536 |
{ |
| 1537 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 1538 |
@Override |
| 1539 |
<%}%> |
| 1540 |
public Viewer createViewer(Composite composite) |
| 1541 |
{ |
| 1542 |
return new ListViewer(composite); |
| 1543 |
} |
| 1544 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 1545 |
@Override |
| 1546 |
<%}%> |
| 1547 |
public void requestActivation() |
| 1548 |
{ |
| 1549 |
super.requestActivation(); |
| 1550 |
setCurrentViewerPane(this); |
| 1551 |
} |
| 1552 |
}; |
| 1553 |
viewerPane.createControl(getContainer()); |
| 1554 |
listViewer = (ListViewer)viewerPane.getViewer(); |
| 1555 |
listViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); |
| 1556 |
listViewer.setLabelProvider(<%if (useStyledLabelProvider) {%>new <%=_DelegatingAdapterFactoryLabelProvider%>(<%}%>new <%=_AdapterFactoryLabelProvider%>(adapterFactory<%if (useExtendedLabelProvider) {%>, listViewer<%}%>)<%if (useStyledLabelProvider) {%>)<%}%>); |
| 1557 |
|
| 1558 |
createContextMenuFor(listViewer); |
| 1559 |
int pageIndex = addPage(viewerPane.getControl()); |
| 1560 |
setPageText(pageIndex, getString("_UI_ListPage_label"));<%=genModel.getNonNLS()%> |
| 1561 |
} |
| 1562 |
|
| 1563 |
// This is the page for the tree viewer |
| 1564 |
// |
| 1565 |
{ |
| 1566 |
ViewerPane viewerPane = |
| 1567 |
new ViewerPane(getSite().getPage(), <%=genPackage.getEditorClassName()%>.this) |
| 1568 |
{ |
| 1569 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 1570 |
@Override |
| 1571 |
<%}%> |
| 1572 |
public Viewer createViewer(Composite composite) |
| 1573 |
{ |
| 1574 |
return new TreeViewer(composite); |
| 1575 |
} |
| 1576 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 1577 |
@Override |
| 1578 |
<%}%> |
| 1579 |
public void requestActivation() |
| 1580 |
{ |
| 1581 |
super.requestActivation(); |
| 1582 |
setCurrentViewerPane(this); |
| 1583 |
} |
| 1584 |
}; |
| 1585 |
viewerPane.createControl(getContainer()); |
| 1586 |
treeViewer = (TreeViewer)viewerPane.getViewer(); |
| 1587 |
treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); |
| 1588 |
treeViewer.setLabelProvider(<%if (useStyledLabelProvider) {%>new <%=_DelegatingAdapterFactoryLabelProvider%>(<%}%><%if (genModel.getDecoration() != GenDecoration.NONE) {%>new <%=_DecoratingColumLabelProvider%>(<%}%>new <%=_AdapterFactoryLabelProvider%>(adapterFactory<%if (useExtendedLabelProvider) {%>, treeViewer<%}%>)<%if (genModel.getDecoration() != GenDecoration.NONE) {%>, new <%=_DiagnosticDecorator%>(editingDomain<%if (genModel.getDecoration() == GenDecoration.MANUAL) {%>.getResourceSet()<%}%>, treeViewer))<%}%><%if (useStyledLabelProvider) {%>)<%}%>); |
| 1589 |
|
| 1590 |
new AdapterFactoryTreeEditor(treeViewer.getTree(), adapterFactory); |
| 1591 |
<%if (genModel.getDecoration() != GenDecoration.NONE) {%> |
| 1592 |
new <%=genModel.getImportedName("org.eclipse.emf.common.ui.viewer.ColumnViewerInformationControlToolTipSupport")%>(treeViewer, new <%=_DiagnosticDecorator%>.EditingDomainLocationListener(editingDomain, treeViewer)); |
| 1593 |
<%}%> |
| 1594 |
|
| 1595 |
createContextMenuFor(treeViewer); |
| 1596 |
int pageIndex = addPage(viewerPane.getControl()); |
| 1597 |
setPageText(pageIndex, getString("_UI_TreePage_label"));<%=genModel.getNonNLS()%> |
| 1598 |
} |
| 1599 |
|
| 1600 |
// This is the page for the table viewer. |
| 1601 |
// |
| 1602 |
{ |
| 1603 |
ViewerPane viewerPane = |
| 1604 |
new ViewerPane(getSite().getPage(), <%=genPackage.getEditorClassName()%>.this) |
| 1605 |
{ |
| 1606 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 1607 |
@Override |
| 1608 |
<%}%> |
| 1609 |
public Viewer createViewer(Composite composite) |
| 1610 |
{ |
| 1611 |
return new TableViewer(composite); |
| 1612 |
} |
| 1613 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 1614 |
@Override |
| 1615 |
<%}%> |
| 1616 |
public void requestActivation() |
| 1617 |
{ |
| 1618 |
super.requestActivation(); |
| 1619 |
setCurrentViewerPane(this); |
| 1620 |
} |
| 1621 |
}; |
| 1622 |
viewerPane.createControl(getContainer()); |
| 1623 |
tableViewer = (TableViewer)viewerPane.getViewer(); |
| 1624 |
|
| 1625 |
Table table = tableViewer.getTable(); |
| 1626 |
TableLayout layout = new TableLayout(); |
| 1627 |
table.setLayout(layout); |
| 1628 |
table.setHeaderVisible(true); |
| 1629 |
table.setLinesVisible(true); |
| 1630 |
|
| 1631 |
TableColumn objectColumn = new TableColumn(table, SWT.NONE); |
| 1632 |
layout.addColumnData(new ColumnWeightData(3, 100, true)); |
| 1633 |
objectColumn.setText(getString("_UI_ObjectColumn_label"));<%=genModel.getNonNLS()%> |
| 1634 |
objectColumn.setResizable(true); |
| 1635 |
|
| 1636 |
TableColumn selfColumn = new TableColumn(table, SWT.NONE); |
| 1637 |
layout.addColumnData(new ColumnWeightData(2, 100, true)); |
| 1638 |
selfColumn.setText(getString("_UI_SelfColumn_label"));<%=genModel.getNonNLS()%> |
| 1639 |
selfColumn.setResizable(true); |
| 1640 |
|
| 1641 |
tableViewer.setColumnProperties(new String [] {"a", "b"});<%=genModel.getNonNLS()%><%=genModel.getNonNLS(2)%> |
| 1642 |
tableViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); |
| 1643 |
tableViewer.setLabelProvider(<%if (useStyledLabelProvider) {%>new <%=_DelegatingAdapterFactoryLabelProvider%>(<%}%><%if (genModel.getDecoration() != GenDecoration.NONE) {%>new <%=_DecoratingColumLabelProvider%>(<%}%>new <%=_AdapterFactoryLabelProvider%>(adapterFactory<%if (useExtendedLabelProvider) {%>, tableViewer<%}%>)<%if (genModel.getDecoration() != GenDecoration.NONE) {%>, new <%=_DiagnosticDecorator%>(editingDomain<%if (genModel.getDecoration() == GenDecoration.MANUAL) {%>.getResourceSet()<%}%>, tableViewer<%if (genModel.getDecoration() == GenDecoration.LIVE) {%>, <%=genPackage.getImportedEditorPluginClassName()%>.getPlugin().getDialogSettings()<%}%>))<%}%><%if (useStyledLabelProvider) {%>)<%}%>); |
| 1644 |
|
| 1645 |
<%if (genModel.getDecoration() != GenDecoration.NONE) {%> |
| 1646 |
new <%=genModel.getImportedName("org.eclipse.emf.common.ui.viewer.ColumnViewerInformationControlToolTipSupport")%>(tableViewer, new <%=_DiagnosticDecorator%>.EditingDomainLocationListener(editingDomain, tableViewer)); |
| 1647 |
|
| 1648 |
<%}%> |
| 1649 |
createContextMenuFor(tableViewer); |
| 1650 |
int pageIndex = addPage(viewerPane.getControl()); |
| 1651 |
setPageText(pageIndex, getString("_UI_TablePage_label"));<%=genModel.getNonNLS()%> |
| 1652 |
} |
| 1653 |
|
| 1654 |
// This is the page for the table tree viewer. |
| 1655 |
// |
| 1656 |
{ |
| 1657 |
ViewerPane viewerPane = |
| 1658 |
new ViewerPane(getSite().getPage(), <%=genPackage.getEditorClassName()%>.this) |
| 1659 |
{ |
| 1660 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 1661 |
@Override |
| 1662 |
<%}%> |
| 1663 |
public Viewer createViewer(Composite composite) |
| 1664 |
{ |
| 1665 |
return new TreeViewer(composite); |
| 1666 |
} |
| 1667 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 1668 |
@Override |
| 1669 |
<%}%> |
| 1670 |
public void requestActivation() |
| 1671 |
{ |
| 1672 |
super.requestActivation(); |
| 1673 |
setCurrentViewerPane(this); |
| 1674 |
} |
| 1675 |
}; |
| 1676 |
viewerPane.createControl(getContainer()); |
| 1677 |
|
| 1678 |
treeViewerWithColumns = (TreeViewer)viewerPane.getViewer(); |
| 1679 |
|
| 1680 |
Tree tree = treeViewerWithColumns.getTree(); |
| 1681 |
tree.setLayoutData(new FillLayout()); |
| 1682 |
tree.setHeaderVisible(true); |
| 1683 |
tree.setLinesVisible(true); |
| 1684 |
|
| 1685 |
TreeColumn objectColumn = new TreeColumn(tree, SWT.NONE); |
| 1686 |
objectColumn.setText(getString("_UI_ObjectColumn_label"));<%=genModel.getNonNLS()%> |
| 1687 |
objectColumn.setResizable(true); |
| 1688 |
objectColumn.setWidth(250); |
| 1689 |
|
| 1690 |
TreeColumn selfColumn = new TreeColumn(tree, SWT.NONE); |
| 1691 |
selfColumn.setText(getString("_UI_SelfColumn_label"));<%=genModel.getNonNLS()%> |
| 1692 |
selfColumn.setResizable(true); |
| 1693 |
selfColumn.setWidth(200); |
| 1694 |
|
| 1695 |
treeViewerWithColumns.setColumnProperties(new String [] {"a", "b"});<%=genModel.getNonNLS()%><%=genModel.getNonNLS(2)%> |
| 1696 |
treeViewerWithColumns.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); |
| 1697 |
treeViewerWithColumns.setLabelProvider(<%if (useStyledLabelProvider) {%>new <%=_DelegatingAdapterFactoryLabelProvider%>(<%}%><%if (genModel.getDecoration() != GenDecoration.NONE) {%>new <%=_DecoratingColumLabelProvider%>(<%}%>new <%=_AdapterFactoryLabelProvider%>(adapterFactory<%if (useExtendedLabelProvider) {%>, treeViewerWithColumns<%}%>)<%if (genModel.getDecoration() != GenDecoration.NONE) {%>, new <%=_DiagnosticDecorator%>(editingDomain<%if (genModel.getDecoration() == GenDecoration.MANUAL) {%>.getResourceSet()<%}%>, treeViewerWithColumns<%if (genModel.getDecoration() == GenDecoration.LIVE) {%>, <%=genPackage.getImportedEditorPluginClassName()%>.getPlugin().getDialogSettings()<%}%>))<%}%><%if (useStyledLabelProvider) {%>)<%}%>); |
| 1698 |
|
| 1699 |
<%if (genModel.getDecoration() != GenDecoration.NONE) {%> |
| 1700 |
new <%=genModel.getImportedName("org.eclipse.emf.common.ui.viewer.ColumnViewerInformationControlToolTipSupport")%>(treeViewerWithColumns, new <%=_DiagnosticDecorator%>.EditingDomainLocationListener(editingDomain, treeViewerWithColumns)); |
| 1701 |
|
| 1702 |
<%}%> |
| 1703 |
createContextMenuFor(treeViewerWithColumns); |
| 1704 |
int pageIndex = addPage(viewerPane.getControl()); |
| 1705 |
setPageText(pageIndex, getString("_UI_TreeWithColumnsPage_label"));<%=genModel.getNonNLS()%> |
| 1706 |
} |
| 1707 |
<%} else {%> |
| 1708 |
Tree tree = new Tree(getContainer(), SWT.MULTI); |
| 1709 |
selectionViewer = new TreeViewer(tree); |
| 1710 |
setCurrentViewer(selectionViewer); |
| 1711 |
|
| 1712 |
selectionViewer.setUseHashlookup(true); |
| 1713 |
selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); |
| 1714 |
selectionViewer.setLabelProvider(<%if (useStyledLabelProvider) {%>new <%=_DelegatingAdapterFactoryLabelProvider%>(<%}%><%if (genModel.getDecoration() != GenDecoration.NONE) {%>new <%=_DecoratingColumLabelProvider%>(<%}%>new <%=_AdapterFactoryLabelProvider%>(adapterFactory<%if (useExtendedLabelProvider) {%>, selectionViewer<%}%>)<%if (genModel.getDecoration() != GenDecoration.NONE) {%>, new <%=_DiagnosticDecorator%>(editingDomain<%if (genModel.getDecoration() == GenDecoration.MANUAL) {%>.getResourceSet()<%}%>, selectionViewer<%if (genModel.getDecoration() == GenDecoration.LIVE) {%>, <%=genPackage.getImportedEditorPluginClassName()%>.getPlugin().getDialogSettings()<%}%>))<%}%><%if (useStyledLabelProvider) {%>)<%}%>); |
| 1715 |
selectionViewer.setInput(editingDomain.getResourceSet()); |
| 1716 |
selectionViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true); |
| 1717 |
|
| 1718 |
new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory); |
| 1719 |
<%if (genModel.getDecoration() != GenDecoration.NONE) {%> |
| 1720 |
new <%=genModel.getImportedName("org.eclipse.emf.common.ui.viewer.ColumnViewerInformationControlToolTipSupport")%>(selectionViewer, new <%=_DiagnosticDecorator%>.EditingDomainLocationListener(editingDomain, selectionViewer)); |
| 1721 |
<%}%> |
| 1722 |
|
| 1723 |
createContextMenuFor(selectionViewer); |
| 1724 |
int pageIndex = addPage(tree); |
| 1725 |
setPageText(pageIndex, getString("_UI_SelectionPage_label"));<%=genModel.getNonNLS()%> |
| 1726 |
<%}%> |
| 1727 |
|
| 1728 |
getSite().getShell().getDisplay().asyncExec |
| 1729 |
(new Runnable() |
| 1730 |
{ |
| 1731 |
<%if (genModel.useInterfaceOverrideAnnotation()) {%> |
| 1732 |
@Override |
| 1733 |
<%}%> |
| 1734 |
public void run() |
| 1735 |
{ |
| 1736 |
if (!getContainer().isDisposed()) |
| 1737 |
{ |
| 1738 |
setActivePage(0); |
| 1739 |
} |
| 1740 |
} |
| 1741 |
}); |
| 1742 |
} |
| 1743 |
|
| 1744 |
// Ensures that this editor will only display the page's tab |
| 1745 |
// area if there are more than one page |
| 1746 |
// |
| 1747 |
getContainer().addControlListener |
| 1748 |
(new ControlAdapter() |
| 1749 |
{ |
| 1750 |
boolean guard = false; |
| 1751 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 1752 |
@Override |
| 1753 |
<%}%> |
| 1754 |
public void controlResized(ControlEvent event) |
| 1755 |
{ |
| 1756 |
if (!guard) |
| 1757 |
{ |
| 1758 |
guard = true; |
| 1759 |
hideTabs(); |
| 1760 |
guard = false; |
| 1761 |
} |
| 1762 |
} |
| 1763 |
}); |
| 1764 |
|
| 1765 |
getSite().getShell().getDisplay().asyncExec |
| 1766 |
(new Runnable() |
| 1767 |
{ |
| 1768 |
<%if (genModel.useInterfaceOverrideAnnotation()) {%> |
| 1769 |
@Override |
| 1770 |
<%}%> |
| 1771 |
public void run() |
| 1772 |
{ |
| 1773 |
updateProblemIndication(); |
| 1774 |
} |
| 1775 |
}); |
| 1776 |
} |
| 1777 |
|
| 1778 |
/** |
| 1779 |
* If there is just one page in the multi-page editor part, |
| 1780 |
* this hides the single tab at the bottom. |
| 1781 |
* <!-- begin-user-doc --> |
| 1782 |
* <!-- end-user-doc --> |
| 1783 |
* @generated |
| 1784 |
*/ |
| 1785 |
protected void hideTabs() |
| 1786 |
{ |
| 1787 |
if (getPageCount() <= 1) |
| 1788 |
{ |
| 1789 |
setPageText(0, "");<%=genModel.getNonNLS()%> |
| 1790 |
if (getContainer() instanceof CTabFolder) |
| 1791 |
{ |
| 1792 |
Point point = getContainer().getSize(); |
| 1793 |
Rectangle clientArea = getContainer().getClientArea(); |
| 1794 |
getContainer().setSize(point.x, 2 * point.y - clientArea.height - clientArea.y); |
| 1795 |
} |
| 1796 |
} |
| 1797 |
} |
| 1798 |
|
| 1799 |
/** |
| 1800 |
* If there is more than one page in the multi-page editor part, |
| 1801 |
* this shows the tabs at the bottom. |
| 1802 |
* <!-- begin-user-doc --> |
| 1803 |
* <!-- end-user-doc --> |
| 1804 |
* @generated |
| 1805 |
*/ |
| 1806 |
protected void showTabs() |
| 1807 |
{ |
| 1808 |
if (getPageCount() > 1) |
| 1809 |
{ |
| 1810 |
setPageText(0, getString("_UI_SelectionPage_label"));<%=genModel.getNonNLS()%> |
| 1811 |
if (getContainer() instanceof CTabFolder) |
| 1812 |
{ |
| 1813 |
Point point = getContainer().getSize(); |
| 1814 |
Rectangle clientArea = getContainer().getClientArea(); |
| 1815 |
getContainer().setSize(point.x, clientArea.height + clientArea.y); |
| 1816 |
} |
| 1817 |
} |
| 1818 |
} |
| 1819 |
|
| 1820 |
/** |
| 1821 |
* This is used to track the active viewer. |
| 1822 |
* <!-- begin-user-doc --> |
| 1823 |
* <!-- end-user-doc --> |
| 1824 |
* @generated |
| 1825 |
*/ |
| 1826 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 1827 |
@Override |
| 1828 |
<%}%> |
| 1829 |
protected void pageChange(int pageIndex) |
| 1830 |
{ |
| 1831 |
super.pageChange(pageIndex); |
| 1832 |
|
| 1833 |
if (contentOutlinePage != null) |
| 1834 |
{ |
| 1835 |
handleContentOutlineSelection(contentOutlinePage.getSelection()); |
| 1836 |
} |
| 1837 |
} |
| 1838 |
|
| 1839 |
/** |
| 1840 |
* This is how the framework determines which interfaces we implement. |
| 1841 |
* <!-- begin-user-doc --> |
| 1842 |
* <!-- end-user-doc --> |
| 1843 |
* @generated |
| 1844 |
*/ |
| 1845 |
<%if (genModel.useGenerics() && genModel.getEclipsePlatformVersion().getValue() < GenEclipsePlatformVersion.MARS_VALUE) {%> |
| 1846 |
@SuppressWarnings("<%if (genModel.getRuntimeVersion().getValue() >= GenRuntimeVersion.EMF26_VALUE) {%>rawtypes<%} else {%>unchecked<%}%>") |
| 1847 |
<%}%> |
| 1848 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 1849 |
@Override |
| 1850 |
<%}%> |
| 1851 |
<%if (genModel.getEclipsePlatformVersion().getValue() >= GenEclipsePlatformVersion.MARS_VALUE) {%> |
| 1852 |
public <T> T getAdapter(Class<T> key) |
| 1853 |
<%} else {%> |
| 1854 |
public Object getAdapter(Class key) |
| 1855 |
<%}%> |
| 1856 |
{ |
| 1857 |
if (key.equals(IContentOutlinePage.class)) |
| 1858 |
{ |
| 1859 |
<%if (genModel.getEclipsePlatformVersion().getValue() >= GenEclipsePlatformVersion.MARS_VALUE) {%> |
| 1860 |
return showOutlineView() ? key.cast(getContentOutlinePage()) : null; |
| 1861 |
<%} else {%> |
| 1862 |
return showOutlineView() ? getContentOutlinePage() : null; |
| 1863 |
<%}%> |
| 1864 |
} |
| 1865 |
else if (key.equals(IPropertySheetPage.class)) |
| 1866 |
{ |
| 1867 |
<%if (genModel.getEclipsePlatformVersion().getValue() >= GenEclipsePlatformVersion.MARS_VALUE) {%> |
| 1868 |
return key.cast(getPropertySheetPage()); |
| 1869 |
<%} else {%> |
| 1870 |
return getPropertySheetPage(); |
| 1871 |
<%}%> |
| 1872 |
} |
| 1873 |
<%if (!genModel.isRichClientPlatform()) {%> |
| 1874 |
else if (key.equals(IGotoMarker.class)) |
| 1875 |
{ |
| 1876 |
<%if (genModel.getEclipsePlatformVersion().getValue() >= GenEclipsePlatformVersion.MARS_VALUE) {%> |
| 1877 |
return key.cast(this); |
| 1878 |
<%} else {%> |
| 1879 |
return this; |
| 1880 |
<%}%> |
| 1881 |
} |
| 1882 |
<%}%> |
| 1883 |
<%if (genModel.isFindAction()) {%> |
| 1884 |
else if (key.equals(<%=genModel.getImportedName("org.eclipse.jface.text.IFindReplaceTarget")%>.class)) |
| 1885 |
{ |
| 1886 |
return <%=genModel.getImportedName("org.eclipse.emf.edit.ui.util.FindAndReplaceTarget")%>.getAdapter(key, this, <%=genPackage.getImportedEditorPluginClassName()%>.getPlugin()); |
| 1887 |
} |
| 1888 |
<%}%> |
| 1889 |
else |
| 1890 |
{ |
| 1891 |
return super.getAdapter(key); |
| 1892 |
} |
| 1893 |
} |
| 1894 |
|
| 1895 |
/** |
| 1896 |
* This accesses a cached version of the content outliner. |
| 1897 |
* <!-- begin-user-doc --> |
| 1898 |
* <!-- end-user-doc --> |
| 1899 |
* @generated |
| 1900 |
*/ |
| 1901 |
public IContentOutlinePage getContentOutlinePage() |
| 1902 |
{ |
| 1903 |
if (contentOutlinePage == null) |
| 1904 |
{ |
| 1905 |
// The content outline is just a tree. |
| 1906 |
// |
| 1907 |
class MyContentOutlinePage extends ContentOutlinePage |
| 1908 |
{ |
| 1909 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 1910 |
@Override |
| 1911 |
<%}%> |
| 1912 |
public void createControl(Composite parent) |
| 1913 |
{ |
| 1914 |
super.createControl(parent); |
| 1915 |
contentOutlineViewer = getTreeViewer(); |
| 1916 |
contentOutlineViewer.addSelectionChangedListener(this); |
| 1917 |
|
| 1918 |
// Set up the tree viewer. |
| 1919 |
// |
| 1920 |
contentOutlineViewer.setUseHashlookup(true); |
| 1921 |
contentOutlineViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); |
| 1922 |
contentOutlineViewer.setLabelProvider(<%if (useStyledLabelProvider) {%>new <%=_DelegatingAdapterFactoryLabelProvider%>(<%}%><%if (genModel.getDecoration() != GenDecoration.NONE) {%>new <%=_DecoratingColumLabelProvider%>(<%}%>new <%=_AdapterFactoryLabelProvider%>(adapterFactory<%if (useExtendedLabelProvider) {%>, contentOutlineViewer<%}%>)<%if (genModel.getDecoration() != GenDecoration.NONE) {%>, new <%=_DiagnosticDecorator%>(editingDomain<%if (genModel.getDecoration() == GenDecoration.MANUAL) {%>.getResourceSet()<%}%>, contentOutlineViewer<%if (genModel.getDecoration() == GenDecoration.LIVE) {%>, <%=genPackage.getImportedEditorPluginClassName()%>.getPlugin().getDialogSettings()<%}%>))<%}%><%if (useStyledLabelProvider) {%>)<%}%>); |
| 1923 |
contentOutlineViewer.setInput(editingDomain.getResourceSet()); |
| 1924 |
|
| 1925 |
<%if (genModel.getDecoration() != GenDecoration.NONE) {%> |
| 1926 |
new <%=genModel.getImportedName("org.eclipse.emf.common.ui.viewer.ColumnViewerInformationControlToolTipSupport")%>(contentOutlineViewer, new <%=_DiagnosticDecorator%>.EditingDomainLocationListener(editingDomain, contentOutlineViewer)); |
| 1927 |
|
| 1928 |
<%}%> |
| 1929 |
// Make sure our popups work. |
| 1930 |
// |
| 1931 |
createContextMenuFor(contentOutlineViewer); |
| 1932 |
|
| 1933 |
if (!editingDomain.getResourceSet().getResources().isEmpty()) |
| 1934 |
{ |
| 1935 |
// Select the root object in the view. |
| 1936 |
// |
| 1937 |
contentOutlineViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true); |
| 1938 |
} |
| 1939 |
} |
| 1940 |
|
| 1941 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 1942 |
@Override |
| 1943 |
<%}%> |
| 1944 |
public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager, IStatusLineManager statusLineManager) |
| 1945 |
{ |
| 1946 |
super.makeContributions(menuManager, toolBarManager, statusLineManager); |
| 1947 |
contentOutlineStatusLineManager = statusLineManager; |
| 1948 |
} |
| 1949 |
|
| 1950 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 1951 |
@Override |
| 1952 |
<%}%> |
| 1953 |
public void setActionBars(IActionBars actionBars) |
| 1954 |
{ |
| 1955 |
super.setActionBars(actionBars); |
| 1956 |
getActionBarContributor().shareGlobalActions(this, actionBars); |
| 1957 |
} |
| 1958 |
} |
| 1959 |
|
| 1960 |
contentOutlinePage = new MyContentOutlinePage(); |
| 1961 |
|
| 1962 |
// Listen to selection so that we can handle it is a special way. |
| 1963 |
// |
| 1964 |
contentOutlinePage.addSelectionChangedListener |
| 1965 |
(new ISelectionChangedListener() |
| 1966 |
{ |
| 1967 |
// This ensures that we handle selections correctly. |
| 1968 |
// |
| 1969 |
<%if (genModel.useInterfaceOverrideAnnotation()) {%> |
| 1970 |
@Override |
| 1971 |
<%}%> |
| 1972 |
public void selectionChanged(SelectionChangedEvent event) |
| 1973 |
{ |
| 1974 |
handleContentOutlineSelection(event.getSelection()); |
| 1975 |
} |
| 1976 |
}); |
| 1977 |
} |
| 1978 |
|
| 1979 |
return contentOutlinePage; |
| 1980 |
} |
| 1981 |
|
| 1982 |
/** |
| 1983 |
* This accesses a cached version of the property sheet. |
| 1984 |
* <!-- begin-user-doc --> |
| 1985 |
* <!-- end-user-doc --> |
| 1986 |
* @generated |
| 1987 |
*/ |
| 1988 |
public IPropertySheetPage getPropertySheetPage() |
| 1989 |
{ |
| 1990 |
PropertySheetPage propertySheetPage = |
| 1991 |
new ExtendedPropertySheetPage(editingDomain<%if (genModel.getDecoration() == GenDecoration.MANUAL) {%>, ExtendedPropertySheetPage.Decoration.MANUAL<%} else if (genModel.getDecoration() == GenDecoration.LIVE) {%>, ExtendedPropertySheetPage.Decoration.LIVE, <%=genPackage.getImportedEditorPluginClassName()%>.getPlugin().getDialogSettings()<%}%><%if (genModel.getRuntimeVersion().getValue() >= GenRuntimeVersion.EMF214_VALUE) {%>, <%if (genModel.getDecoration() == GenDecoration.NONE) {%>ExtendedPropertySheetPage.Decoration.NONE, <%}%><%if (genModel.getDecoration() != GenDecoration.LIVE) {%>null, <%}%><%=genModel.getAutoExpandProperties()%>, <%=genModel.isAutoResizeProperties()%><%}%>) |
| 1992 |
{ |
| 1993 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 1994 |
@Override |
| 1995 |
<%}%> |
| 1996 |
public void setSelectionToViewer(<%=_ListOfAnything%> selection) |
| 1997 |
{ |
| 1998 |
<%=genPackage.getEditorClassName()%>.this.setSelectionToViewer(selection); |
| 1999 |
<%=genPackage.getEditorClassName()%>.this.setFocus(); |
| 2000 |
} |
| 2001 |
|
| 2002 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 2003 |
@Override |
| 2004 |
<%}%> |
| 2005 |
public void setActionBars(IActionBars actionBars) |
| 2006 |
{ |
| 2007 |
super.setActionBars(actionBars); |
| 2008 |
getActionBarContributor().shareGlobalActions(this, actionBars); |
| 2009 |
} |
| 2010 |
}; |
| 2011 |
propertySheetPage.setPropertySourceProvider(new AdapterFactoryContentProvider(adapterFactory)); |
| 2012 |
propertySheetPages.add(propertySheetPage); |
| 2013 |
|
| 2014 |
return propertySheetPage; |
| 2015 |
} |
| 2016 |
|
| 2017 |
/** |
| 2018 |
* This deals with how we want selection in the outliner to affect the other views. |
| 2019 |
* <!-- begin-user-doc --> |
| 2020 |
* <!-- end-user-doc --> |
| 2021 |
* @generated |
| 2022 |
*/ |
| 2023 |
public void handleContentOutlineSelection(ISelection selection) |
| 2024 |
{ |
| 2025 |
<%if (genPackage.isMultipleEditorPages()) {%> |
| 2026 |
if (currentViewerPane != null && !selection.isEmpty() && selection instanceof IStructuredSelection) |
| 2027 |
<%} else {%> |
| 2028 |
if (selectionViewer != null && !selection.isEmpty() && selection instanceof IStructuredSelection) |
| 2029 |
<%}%> |
| 2030 |
{ |
| 2031 |
Iterator<%if (genModel.useGenerics()) {%><?><%}%> selectedElements = ((IStructuredSelection)selection).iterator(); |
| 2032 |
if (selectedElements.hasNext()) |
| 2033 |
{ |
| 2034 |
// Get the first selected element. |
| 2035 |
// |
| 2036 |
Object selectedElement = selectedElements.next(); |
| 2037 |
|
| 2038 |
<%if (genPackage.isMultipleEditorPages()) {%> |
| 2039 |
// If it's the selection viewer, then we want it to select the same selection as this selection. |
| 2040 |
// |
| 2041 |
if (currentViewerPane.getViewer() == selectionViewer) |
| 2042 |
{ |
| 2043 |
<%=_ArrayListOfObject%> selectionList = new <%=_ArrayListOfObject%>(); |
| 2044 |
selectionList.add(selectedElement); |
| 2045 |
while (selectedElements.hasNext()) |
| 2046 |
{ |
| 2047 |
selectionList.add(selectedElements.next()); |
| 2048 |
} |
| 2049 |
|
| 2050 |
// Set the selection to the widget. |
| 2051 |
// |
| 2052 |
selectionViewer.setSelection(new StructuredSelection(selectionList)); |
| 2053 |
} |
| 2054 |
else |
| 2055 |
{ |
| 2056 |
// Set the input to the widget. |
| 2057 |
// |
| 2058 |
if (currentViewerPane.getViewer().getInput() != selectedElement) |
| 2059 |
{ |
| 2060 |
currentViewerPane.getViewer().setInput(selectedElement); |
| 2061 |
currentViewerPane.setTitle(selectedElement); |
| 2062 |
} |
| 2063 |
} |
| 2064 |
<%} else {%> |
| 2065 |
<%=_ArrayListOfObject%> selectionList = new <%=_ArrayListOfObject%>(); |
| 2066 |
selectionList.add(selectedElement); |
| 2067 |
while (selectedElements.hasNext()) |
| 2068 |
{ |
| 2069 |
selectionList.add(selectedElements.next()); |
| 2070 |
} |
| 2071 |
|
| 2072 |
// Set the selection to the widget. |
| 2073 |
// |
| 2074 |
selectionViewer.setSelection(new StructuredSelection(selectionList)); |
| 2075 |
<%}%> |
| 2076 |
} |
| 2077 |
} |
| 2078 |
} |
| 2079 |
|
| 2080 |
/** |
| 2081 |
* This is for implementing {@link IEditorPart} and simply tests the command stack. |
| 2082 |
* <!-- begin-user-doc --> |
| 2083 |
* <!-- end-user-doc --> |
| 2084 |
* @generated |
| 2085 |
*/ |
| 2086 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 2087 |
@Override |
| 2088 |
<%}%> |
| 2089 |
public boolean isDirty() |
| 2090 |
{ |
| 2091 |
return ((BasicCommandStack)editingDomain.getCommandStack()).isSaveNeeded(); |
| 2092 |
} |
| 2093 |
|
| 2094 |
<%if (genModel.isRevertAction()) {%> |
| 2095 |
/** |
| 2096 |
* This is for implementing {@link IRevertablePart}. |
| 2097 |
* <!-- begin-user-doc --> |
| 2098 |
* <!-- end-user-doc --> |
| 2099 |
* @generated |
| 2100 |
*/ |
| 2101 |
<%if (genModel.useInterfaceOverrideAnnotation()) {%> |
| 2102 |
@Override |
| 2103 |
<%}%> |
| 2104 |
public void doRevert() |
| 2105 |
{ |
| 2106 |
<%if (genModel.getDecoration() == GenDecoration.LIVE) {%> |
| 2107 |
DiagnosticDecorator.cancel(editingDomain); |
| 2108 |
|
| 2109 |
<%}%> |
| 2110 |
ResourceSet resourceSet = editingDomain.getResourceSet(); |
| 2111 |
<%=_ListOfResource%> resources = resourceSet.getResources(); |
| 2112 |
<%=_ListOfResource%> unloadedResources = new <%=_ArrayListOfResource%>(); |
| 2113 |
updateProblemIndication = false; |
| 2114 |
for (int i = 0; i < resources.size(); ++i) |
| 2115 |
{ |
| 2116 |
Resource resource = resources.get(i); |
| 2117 |
if (resource.isLoaded()) |
| 2118 |
{ |
| 2119 |
resource.unload(); |
| 2120 |
unloadedResources.add(resource); |
| 2121 |
} |
| 2122 |
} |
| 2123 |
|
| 2124 |
resourceToDiagnosticMap.clear(); |
| 2125 |
<%if (genModel.useGenerics()) {%> |
| 2126 |
for (Resource resource : unloadedResources) |
| 2127 |
<%} else {%> |
| 2128 |
for (Iterator i = unloadedResources.iterator(); i.hasNext(); ) |
| 2129 |
<%}%> |
| 2130 |
{ |
| 2131 |
<%if (!genModel.useGenerics()) {%> |
| 2132 |
Resource resource = (Resource)i.next(); |
| 2133 |
<%}%> |
| 2134 |
try |
| 2135 |
{ |
| 2136 |
resource.load(resourceSet.getLoadOptions()); |
| 2137 |
} |
| 2138 |
catch (IOException exception) |
| 2139 |
{ |
| 2140 |
if (!resourceToDiagnosticMap.containsKey(resource)) |
| 2141 |
{ |
| 2142 |
resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception)); |
| 2143 |
} |
| 2144 |
} |
| 2145 |
} |
| 2146 |
|
| 2147 |
editingDomain.getCommandStack().flush(); |
| 2148 |
|
| 2149 |
if (AdapterFactoryEditingDomain.isStale(editorSelection)) |
| 2150 |
{ |
| 2151 |
setSelection(StructuredSelection.EMPTY); |
| 2152 |
} |
| 2153 |
|
| 2154 |
updateProblemIndication = true; |
| 2155 |
updateProblemIndication(); |
| 2156 |
} |
| 2157 |
|
| 2158 |
<%}%> |
| 2159 |
/** |
| 2160 |
* This is for implementing {@link IEditorPart} and simply saves the model file. |
| 2161 |
* <!-- begin-user-doc --> |
| 2162 |
* <!-- end-user-doc --> |
| 2163 |
* @generated |
| 2164 |
*/ |
| 2165 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 2166 |
@Override |
| 2167 |
<%}%> |
| 2168 |
public void doSave(IProgressMonitor progressMonitor) |
| 2169 |
{ |
| 2170 |
// Save only resources that have actually changed. |
| 2171 |
// |
| 2172 |
final <%=_MapOfObjectToObject%> saveOptions = new <%=_HashMapOfObjectToObject%>(); |
| 2173 |
<%if (genModel.getRuntimeVersion().getValue() >= GenRuntimeVersion.EMF23_VALUE) {%> |
| 2174 |
saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER); |
| 2175 |
<%}%> |
| 2176 |
<%if (genModel.getRuntimeVersion().getValue() >= GenRuntimeVersion.EMF29_VALUE) {%> |
| 2177 |
saveOptions.put(Resource.OPTION_LINE_DELIMITER, Resource.OPTION_LINE_DELIMITER_UNSPECIFIED); |
| 2178 |
<%}%> |
| 2179 |
|
| 2180 |
// Do the work within an operation because this is a long running activity that modifies the workbench. |
| 2181 |
// |
| 2182 |
<%=importedOperationClassName%> operation = |
| 2183 |
new <%=importedOperationClassName%>() |
| 2184 |
{ |
| 2185 |
// This is the method that gets invoked when the operation runs. |
| 2186 |
// |
| 2187 |
<%if (genModel.useInterfaceOverrideAnnotation() || !genModel.isRichClientPlatform() && genModel.useClassOverrideAnnotation()) {%> |
| 2188 |
@Override |
| 2189 |
<%}%> |
| 2190 |
public void <%=operationMethodName%>(IProgressMonitor monitor) |
| 2191 |
{ |
| 2192 |
// Save the resources to the file system. |
| 2193 |
// |
| 2194 |
boolean first = true; |
| 2195 |
<%=_ListOfResource%> resources = editingDomain.getResourceSet().getResources(); |
| 2196 |
for (int i = 0; i < resources.size(); ++i) |
| 2197 |
{ |
| 2198 |
Resource resource = <%if (!genModel.useGenerics()) {%>(Resource)<%}%>resources.get(i); |
| 2199 |
if ((first || !resource.getContents().isEmpty() || isPersisted(resource)) && !editingDomain.isReadOnly(resource)) |
| 2200 |
{ |
| 2201 |
try |
| 2202 |
{ |
| 2203 |
<%if (genModel.getRuntimeVersion().getValue() >= GenRuntimeVersion.EMF24_VALUE) {%> |
| 2204 |
long timeStamp = resource.getTimeStamp(); |
| 2205 |
resource.save(saveOptions); |
| 2206 |
if (resource.getTimeStamp() != timeStamp) |
| 2207 |
{ |
| 2208 |
savedResources.add(resource); |
| 2209 |
} |
| 2210 |
<%} else {%> |
| 2211 |
resource.save(saveOptions); |
| 2212 |
savedResources.add(resource); |
| 2213 |
<%}%> |
| 2214 |
} |
| 2215 |
catch (Exception exception) |
| 2216 |
{ |
| 2217 |
resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception)); |
| 2218 |
} |
| 2219 |
first = false; |
| 2220 |
} |
| 2221 |
} |
| 2222 |
} |
| 2223 |
}; |
| 2224 |
|
| 2225 |
updateProblemIndication = false; |
| 2226 |
try |
| 2227 |
{ |
| 2228 |
// This runs the options, and shows progress. |
| 2229 |
// |
| 2230 |
new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation); |
| 2231 |
|
| 2232 |
// Refresh the necessary state. |
| 2233 |
// |
| 2234 |
((BasicCommandStack)editingDomain.getCommandStack()).saveIsDone(); |
| 2235 |
firePropertyChange(IEditorPart.PROP_DIRTY); |
| 2236 |
} |
| 2237 |
catch (Exception exception) |
| 2238 |
{ |
| 2239 |
// Something went wrong that shouldn't. |
| 2240 |
// |
| 2241 |
<%=genPackage.getImportedEditorPluginClassName()%>.INSTANCE.log(exception); |
| 2242 |
} |
| 2243 |
updateProblemIndication = true; |
| 2244 |
updateProblemIndication(); |
| 2245 |
} |
| 2246 |
|
| 2247 |
/** |
| 2248 |
* This returns whether something has been persisted to the URI of the specified resource. |
| 2249 |
* The implementation uses the URI converter from the editor's resource set to try to open an input stream. |
| 2250 |
* <!-- begin-user-doc --> |
| 2251 |
* <!-- end-user-doc --> |
| 2252 |
* @generated |
| 2253 |
*/ |
| 2254 |
protected boolean isPersisted(Resource resource) |
| 2255 |
{ |
| 2256 |
boolean result = false; |
| 2257 |
try |
| 2258 |
{ |
| 2259 |
InputStream stream = editingDomain.getResourceSet().getURIConverter().createInputStream(resource.getURI()); |
| 2260 |
if (stream != null) |
| 2261 |
{ |
| 2262 |
result = true; |
| 2263 |
stream.close(); |
| 2264 |
} |
| 2265 |
} |
| 2266 |
catch (IOException e) |
| 2267 |
{ |
| 2268 |
// Ignore |
| 2269 |
} |
| 2270 |
return result; |
| 2271 |
} |
| 2272 |
|
| 2273 |
/** |
| 2274 |
* This always returns true because it is not currently supported. |
| 2275 |
* <!-- begin-user-doc --> |
| 2276 |
* <!-- end-user-doc --> |
| 2277 |
* @generated |
| 2278 |
*/ |
| 2279 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 2280 |
@Override |
| 2281 |
<%}%> |
| 2282 |
public boolean isSaveAsAllowed() |
| 2283 |
{ |
| 2284 |
return true; |
| 2285 |
} |
| 2286 |
|
| 2287 |
/** |
| 2288 |
* This also changes the editor's input. |
| 2289 |
* <!-- begin-user-doc --> |
| 2290 |
* <!-- end-user-doc --> |
| 2291 |
* @generated |
| 2292 |
*/ |
| 2293 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 2294 |
@Override |
| 2295 |
<%}%> |
| 2296 |
public void doSaveAs() |
| 2297 |
{ |
| 2298 |
<%if (genModel.isRichClientPlatform()) {%> |
| 2299 |
<%if (genModel.isRichAjaxPlatform()) {%> |
| 2300 |
new <%=genModel.getImportedName("org.eclipse.emf.common.ui.dialogs.ResourceDialog")%>(getSite().getShell(), null, SWT.NONE) |
| 2301 |
{ |
| 2302 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 2303 |
@Override |
| 2304 |
<%}%> |
| 2305 |
protected boolean isSave() |
| 2306 |
{ |
| 2307 |
return true; |
| 2308 |
} |
| 2309 |
|
| 2310 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 2311 |
@Override |
| 2312 |
<%}%> |
| 2313 |
protected boolean processResources() |
| 2314 |
{ |
| 2315 |
<%="List" + (genModel.useGenerics() ? "<URI>" : "")%> uris = getURIs(); |
| 2316 |
if (uris.size() > 0) |
| 2317 |
{ |
| 2318 |
URI uri = <%=genModel.useGenerics() ? "": "(URI)"%>uris.get(0); |
| 2319 |
doSaveAs(uri, new <%=genModel.getImportedName("org.eclipse.emf.common.ui.URIEditorInput")%>(uri)); |
| 2320 |
return true; |
| 2321 |
} |
| 2322 |
else |
| 2323 |
{ |
| 2324 |
return false; |
| 2325 |
} |
| 2326 |
} |
| 2327 |
}.open(); |
| 2328 |
<%} else {%> |
| 2329 |
String[] filters = <%if (!genModel.useGenerics()) {%>(String[])<%}%>FILE_EXTENSION_FILTERS.toArray(new String[FILE_EXTENSION_FILTERS.size()]); |
| 2330 |
String[] files = <%=genModel.getImportedName(genModel.getQualifiedEditorAdvisorClassName())%>.openFilePathDialog(getSite().getShell(), <%=genModel.getImportedName("org.eclipse.swt.SWT")%>.SAVE, filters); |
| 2331 |
if (files.length > 0) |
| 2332 |
{ |
| 2333 |
URI uri = URI.createFileURI(files[0]); |
| 2334 |
doSaveAs(uri, new <%=genModel.getImportedName("org.eclipse.emf.common.ui.URIEditorInput")%>(uri)); |
| 2335 |
} |
| 2336 |
<%}%> |
| 2337 |
<%} else {%> |
| 2338 |
SaveAsDialog saveAsDialog = new SaveAsDialog(getSite().getShell()); |
| 2339 |
saveAsDialog.open(); |
| 2340 |
IPath path = saveAsDialog.getResult(); |
| 2341 |
if (path != null) |
| 2342 |
{ |
| 2343 |
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); |
| 2344 |
if (file != null) |
| 2345 |
{ |
| 2346 |
doSaveAs(URI.createPlatformResourceURI(file.getFullPath().toString(), true), new FileEditorInput(file)); |
| 2347 |
} |
| 2348 |
} |
| 2349 |
<%}%> |
| 2350 |
} |
| 2351 |
|
| 2352 |
/** |
| 2353 |
* <!-- begin-user-doc --> |
| 2354 |
* <!-- end-user-doc --> |
| 2355 |
* @generated |
| 2356 |
*/ |
| 2357 |
protected void doSaveAs(URI uri, IEditorInput editorInput) |
| 2358 |
{ |
| 2359 |
(<%if (!genModel.useGenerics()) {%>(Resource)<%}%>editingDomain.getResourceSet().getResources().get(0)).setURI(uri); |
| 2360 |
setInputWithNotify(editorInput); |
| 2361 |
setPartName(editorInput.getName()); |
| 2362 |
IProgressMonitor progressMonitor = |
| 2363 |
getActionBars().getStatusLineManager() != null ? |
| 2364 |
getActionBars().getStatusLineManager().getProgressMonitor() : |
| 2365 |
new <%=genModel.getImportedName("org.eclipse.core.runtime.NullProgressMonitor")%>(); |
| 2366 |
doSave(progressMonitor); |
| 2367 |
} |
| 2368 |
<%if (!genModel.isRichClientPlatform()) {%> |
| 2369 |
|
| 2370 |
/** |
| 2371 |
* <!-- begin-user-doc --> |
| 2372 |
* <!-- end-user-doc --> |
| 2373 |
* @generated |
| 2374 |
*/ |
| 2375 |
<%if (genModel.useInterfaceOverrideAnnotation()) {%> |
| 2376 |
@Override |
| 2377 |
<%}%> |
| 2378 |
public void gotoMarker(IMarker marker) |
| 2379 |
{ |
| 2380 |
<%if (genModel.getRuntimeVersion().getValue() >= GenRuntimeVersion.EMF23_VALUE) {%> |
| 2381 |
<%=_ListOfAnything%> targetObjects = markerHelper.getTargetObjects(editingDomain, marker); |
| 2382 |
if (!targetObjects.isEmpty()) |
| 2383 |
{ |
| 2384 |
setSelectionToViewer(targetObjects); |
| 2385 |
} |
| 2386 |
<%} else {%> |
| 2387 |
try |
| 2388 |
{ |
| 2389 |
if (marker.isSubtypeOf(EValidator.MARKER)) |
| 2390 |
{ |
| 2391 |
String uriAttribute = marker.getAttribute(EValidator.URI_ATTRIBUTE, null); |
| 2392 |
if (uriAttribute != null) |
| 2393 |
{ |
| 2394 |
URI uri = URI.createURI(uriAttribute); |
| 2395 |
EObject eObject = editingDomain.getResourceSet().getEObject(uri, true); |
| 2396 |
if (eObject != null) |
| 2397 |
{ |
| 2398 |
setSelectionToViewer(Collections.singleton(editingDomain.getWrapper(eObject))); |
| 2399 |
} |
| 2400 |
} |
| 2401 |
} |
| 2402 |
} |
| 2403 |
catch (CoreException exception) |
| 2404 |
{ |
| 2405 |
<%=genPackage.getImportedEditorPluginClassName()%>.INSTANCE.log(exception); |
| 2406 |
} |
| 2407 |
<%}%> |
| 2408 |
} |
| 2409 |
<%}%> |
| 2410 |
|
| 2411 |
/** |
| 2412 |
* This is called during startup. |
| 2413 |
* <!-- begin-user-doc --> |
| 2414 |
* <!-- end-user-doc --> |
| 2415 |
* @generated |
| 2416 |
*/ |
| 2417 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 2418 |
@Override |
| 2419 |
<%}%> |
| 2420 |
public void init(IEditorSite site, IEditorInput editorInput) |
| 2421 |
{ |
| 2422 |
setSite(site); |
| 2423 |
setInputWithNotify(editorInput); |
| 2424 |
setPartName(editorInput.getName()); |
| 2425 |
site.setSelectionProvider(this); |
| 2426 |
site.getPage().addPartListener(partListener); |
| 2427 |
<%if (!genModel.isRichClientPlatform()) {%> |
| 2428 |
ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener, IResourceChangeEvent.POST_CHANGE); |
| 2429 |
<%}%> |
| 2430 |
} |
| 2431 |
|
| 2432 |
/** |
| 2433 |
* <!-- begin-user-doc --> |
| 2434 |
* <!-- end-user-doc --> |
| 2435 |
* @generated |
| 2436 |
*/ |
| 2437 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 2438 |
@Override |
| 2439 |
<%}%> |
| 2440 |
public void setFocus() |
| 2441 |
{ |
| 2442 |
<%if (genPackage.isMultipleEditorPages()) {%> |
| 2443 |
if (currentViewerPane != null) |
| 2444 |
{ |
| 2445 |
currentViewerPane.setFocus(); |
| 2446 |
} |
| 2447 |
else |
| 2448 |
{ |
| 2449 |
getControl(getActivePage()).setFocus(); |
| 2450 |
} |
| 2451 |
<%} else {%> |
| 2452 |
getControl(getActivePage()).setFocus(); |
| 2453 |
<%}%> |
| 2454 |
} |
| 2455 |
|
| 2456 |
/** |
| 2457 |
* This implements {@link org.eclipse.jface.viewers.ISelectionProvider}. |
| 2458 |
* <!-- begin-user-doc --> |
| 2459 |
* <!-- end-user-doc --> |
| 2460 |
* @generated |
| 2461 |
*/ |
| 2462 |
<%if (genModel.useInterfaceOverrideAnnotation()) {%> |
| 2463 |
@Override |
| 2464 |
<%}%> |
| 2465 |
public void addSelectionChangedListener(ISelectionChangedListener listener) |
| 2466 |
{ |
| 2467 |
selectionChangedListeners.add(listener); |
| 2468 |
} |
| 2469 |
|
| 2470 |
/** |
| 2471 |
* This implements {@link org.eclipse.jface.viewers.ISelectionProvider}. |
| 2472 |
* <!-- begin-user-doc --> |
| 2473 |
* <!-- end-user-doc --> |
| 2474 |
* @generated |
| 2475 |
*/ |
| 2476 |
<%if (genModel.useInterfaceOverrideAnnotation()) {%> |
| 2477 |
@Override |
| 2478 |
<%}%> |
| 2479 |
public void removeSelectionChangedListener(ISelectionChangedListener listener) |
| 2480 |
{ |
| 2481 |
selectionChangedListeners.remove(listener); |
| 2482 |
} |
| 2483 |
|
| 2484 |
/** |
| 2485 |
* This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to return this editor's overall selection. |
| 2486 |
* <!-- begin-user-doc --> |
| 2487 |
* <!-- end-user-doc --> |
| 2488 |
* @generated |
| 2489 |
*/ |
| 2490 |
<%if (genModel.useInterfaceOverrideAnnotation()) {%> |
| 2491 |
@Override |
| 2492 |
<%}%> |
| 2493 |
public ISelection getSelection() |
| 2494 |
{ |
| 2495 |
return editorSelection; |
| 2496 |
} |
| 2497 |
|
| 2498 |
/** |
| 2499 |
* This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to set this editor's overall selection. |
| 2500 |
* Calling this result will notify the listeners. |
| 2501 |
* <!-- begin-user-doc --> |
| 2502 |
* <!-- end-user-doc --> |
| 2503 |
* @generated |
| 2504 |
*/ |
| 2505 |
<%if (genModel.useInterfaceOverrideAnnotation()) {%> |
| 2506 |
@Override |
| 2507 |
<%}%> |
| 2508 |
public void setSelection(ISelection selection) |
| 2509 |
{ |
| 2510 |
editorSelection = selection; |
| 2511 |
|
| 2512 |
<%if (genModel.useGenerics()) {%> |
| 2513 |
for (ISelectionChangedListener listener : selectionChangedListeners) |
| 2514 |
<%} else {%> |
| 2515 |
for (Iterator listeners = selectionChangedListeners.iterator(); listeners.hasNext(); ) |
| 2516 |
<%}%> |
| 2517 |
{ |
| 2518 |
<%if (!genModel.useGenerics()) {%> |
| 2519 |
ISelectionChangedListener listener = (ISelectionChangedListener)listeners.next(); |
| 2520 |
<%}%> |
| 2521 |
listener.selectionChanged(new SelectionChangedEvent(this, selection)); |
| 2522 |
} |
| 2523 |
setStatusLineManager(selection); |
| 2524 |
} |
| 2525 |
|
| 2526 |
/** |
| 2527 |
* <!-- begin-user-doc --> |
| 2528 |
* <!-- end-user-doc --> |
| 2529 |
* @generated |
| 2530 |
*/ |
| 2531 |
public void setStatusLineManager(ISelection selection) |
| 2532 |
{ |
| 2533 |
IStatusLineManager statusLineManager = currentViewer != null && currentViewer == contentOutlineViewer ? |
| 2534 |
contentOutlineStatusLineManager : getActionBars().getStatusLineManager(); |
| 2535 |
|
| 2536 |
if (statusLineManager != null) |
| 2537 |
{ |
| 2538 |
if (selection instanceof IStructuredSelection) |
| 2539 |
{ |
| 2540 |
<%=_CollectionOfAnything%> collection = ((IStructuredSelection)selection).toList(); |
| 2541 |
switch (collection.size()) |
| 2542 |
{ |
| 2543 |
case 0: |
| 2544 |
{ |
| 2545 |
statusLineManager.setMessage(getString("_UI_NoObjectSelected"));<%=genModel.getNonNLS()%> |
| 2546 |
break; |
| 2547 |
} |
| 2548 |
case 1: |
| 2549 |
{ |
| 2550 |
String text = new AdapterFactoryItemDelegator(adapterFactory).getText(collection.iterator().next()); |
| 2551 |
statusLineManager.setMessage(getString("_UI_SingleObjectSelected", text));<%=genModel.getNonNLS()%> |
| 2552 |
break; |
| 2553 |
} |
| 2554 |
default: |
| 2555 |
{ |
| 2556 |
statusLineManager.setMessage(getString("_UI_MultiObjectSelected", Integer.toString(collection.size())));<%=genModel.getNonNLS()%> |
| 2557 |
break; |
| 2558 |
} |
| 2559 |
} |
| 2560 |
} |
| 2561 |
else |
| 2562 |
{ |
| 2563 |
statusLineManager.setMessage("");<%=genModel.getNonNLS()%> |
| 2564 |
} |
| 2565 |
} |
| 2566 |
} |
| 2567 |
|
| 2568 |
/** |
| 2569 |
* This looks up a string in the plugin's plugin.properties file. |
| 2570 |
* <!-- begin-user-doc --> |
| 2571 |
* <!-- end-user-doc --> |
| 2572 |
* @generated |
| 2573 |
*/ |
| 2574 |
private static String getString(String key) |
| 2575 |
{ |
| 2576 |
return <%=genPackage.getImportedEditorPluginClassName()%>.INSTANCE.getString(key); |
| 2577 |
} |
| 2578 |
|
| 2579 |
/** |
| 2580 |
* This looks up a string in plugin.properties, making a substitution. |
| 2581 |
* <!-- begin-user-doc --> |
| 2582 |
* <!-- end-user-doc --> |
| 2583 |
* @generated |
| 2584 |
*/ |
| 2585 |
private static String getString(String key, Object s1) |
| 2586 |
{ |
| 2587 |
return <%=genPackage.getImportedEditorPluginClassName()%>.INSTANCE.getString(key, new Object [] { s1 }); |
| 2588 |
} |
| 2589 |
|
| 2590 |
/** |
| 2591 |
* This implements {@link org.eclipse.jface.action.IMenuListener} to help fill the context menus with contributions from the Edit menu. |
| 2592 |
* <!-- begin-user-doc --> |
| 2593 |
* <!-- end-user-doc --> |
| 2594 |
* @generated |
| 2595 |
*/ |
| 2596 |
<%if (genModel.useInterfaceOverrideAnnotation()) {%> |
| 2597 |
@Override |
| 2598 |
<%}%> |
| 2599 |
public void menuAboutToShow(IMenuManager menuManager) |
| 2600 |
{ |
| 2601 |
((IMenuListener)getEditorSite().getActionBarContributor()).menuAboutToShow(menuManager); |
| 2602 |
} |
| 2603 |
|
| 2604 |
/** |
| 2605 |
* <!-- begin-user-doc --> |
| 2606 |
* <!-- end-user-doc --> |
| 2607 |
* @generated |
| 2608 |
*/ |
| 2609 |
public EditingDomainActionBarContributor getActionBarContributor() |
| 2610 |
{ |
| 2611 |
return (EditingDomainActionBarContributor)getEditorSite().getActionBarContributor(); |
| 2612 |
} |
| 2613 |
|
| 2614 |
/** |
| 2615 |
* <!-- begin-user-doc --> |
| 2616 |
* <!-- end-user-doc --> |
| 2617 |
* @generated |
| 2618 |
*/ |
| 2619 |
public IActionBars getActionBars() |
| 2620 |
{ |
| 2621 |
return getActionBarContributor().getActionBars(); |
| 2622 |
} |
| 2623 |
|
| 2624 |
/** |
| 2625 |
* <!-- begin-user-doc --> |
| 2626 |
* <!-- end-user-doc --> |
| 2627 |
* @generated |
| 2628 |
*/ |
| 2629 |
public AdapterFactory getAdapterFactory() |
| 2630 |
{ |
| 2631 |
return adapterFactory; |
| 2632 |
} |
| 2633 |
|
| 2634 |
/** |
| 2635 |
* <!-- begin-user-doc --> |
| 2636 |
* <!-- end-user-doc --> |
| 2637 |
* @generated |
| 2638 |
*/ |
| 2639 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 2640 |
@Override |
| 2641 |
<%}%> |
| 2642 |
public void dispose() |
| 2643 |
{ |
| 2644 |
updateProblemIndication = false; |
| 2645 |
|
| 2646 |
<%if (!genModel.isRichClientPlatform()) {%> |
| 2647 |
ResourcesPlugin.getWorkspace().removeResourceChangeListener(resourceChangeListener); |
| 2648 |
|
| 2649 |
<%}%> |
| 2650 |
getSite().getPage().removePartListener(partListener); |
| 2651 |
|
| 2652 |
adapterFactory.dispose(); |
| 2653 |
|
| 2654 |
if (getActionBarContributor().getActiveEditor() == this) |
| 2655 |
{ |
| 2656 |
getActionBarContributor().setActiveEditor(null); |
| 2657 |
} |
| 2658 |
|
| 2659 |
<%if (genModel.useGenerics()) {%> |
| 2660 |
for (PropertySheetPage propertySheetPage : propertySheetPages) |
| 2661 |
<%} else {%> |
| 2662 |
for (Iterator i = propertySheetPages.iterator(); i.hasNext(); ) |
| 2663 |
<%}%> |
| 2664 |
{ |
| 2665 |
<%if (!genModel.useGenerics()) {%> |
| 2666 |
PropertySheetPage propertySheetPage = (PropertySheetPage)i.next(); |
| 2667 |
<%}%> |
| 2668 |
propertySheetPage.dispose(); |
| 2669 |
} |
| 2670 |
|
| 2671 |
if (contentOutlinePage != null) |
| 2672 |
{ |
| 2673 |
contentOutlinePage.dispose(); |
| 2674 |
} |
| 2675 |
|
| 2676 |
super.dispose(); |
| 2677 |
} |
| 2678 |
|
| 2679 |
/** |
| 2680 |
* Returns whether the outline view should be presented to the user. |
| 2681 |
* <!-- begin-user-doc --> |
| 2682 |
* <!-- end-user-doc --> |
| 2683 |
* @generated |
| 2684 |
*/ |
| 2685 |
protected boolean showOutlineView() |
| 2686 |
{ |
| 2687 |
return <%=genPackage.isMultipleEditorPages()%>; |
| 2688 |
} |
| 2689 |
} |
| 2690 |
<%genModel.emitSortedImports();%> |