|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2009, 2012 IBM Corporation and others. |
2 |
* Copyright (c) 2009, 2014 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 7-12
Link Here
|
| 7 |
* |
7 |
* |
| 8 |
* Contributors: |
8 |
* Contributors: |
| 9 |
* IBM Corporation - initial API and implementation |
9 |
* IBM Corporation - initial API and implementation |
|
|
10 |
* Terry Parker <tparker@google.com> - Bug 416673 |
| 10 |
******************************************************************************/ |
11 |
******************************************************************************/ |
| 11 |
|
12 |
|
| 12 |
package org.eclipse.e4.ui.internal.workbench; |
13 |
package org.eclipse.e4.ui.internal.workbench; |
|
Lines 121-126
public class ResourceHandler implements IModelResourceHandler {
Link Here
|
| 121 |
|
122 |
|
| 122 |
} |
123 |
} |
| 123 |
|
124 |
|
|
|
125 |
/** |
| 126 |
* @return {@code true} if the current application model has top-level windows. |
| 127 |
*/ |
| 128 |
public boolean hasTopLevelWindows() { |
| 129 |
return hasTopLevelWindows(resource); |
| 130 |
} |
| 131 |
|
| 132 |
/** |
| 133 |
* @return {@code true} if the specified application model has top-level windows. |
| 134 |
*/ |
| 135 |
private boolean hasTopLevelWindows(Resource applicationResource) { |
| 136 |
if (applicationResource == null || applicationResource.getContents() == null) { |
| 137 |
// If the application resource doesn't exist or has no contents, then it has no |
| 138 |
// top-level windows (and we are in an error state). |
| 139 |
return false; |
| 140 |
} |
| 141 |
MApplication application = (MApplication) applicationResource.getContents().get(0); |
| 142 |
return !application.getChildren().isEmpty(); |
| 143 |
} |
| 144 |
|
| 124 |
public Resource loadMostRecentModel() { |
145 |
public Resource loadMostRecentModel() { |
| 125 |
File baseLocation; |
146 |
File baseLocation; |
| 126 |
try { |
147 |
try { |
|
Lines 173-180
public class ResourceHandler implements IModelResourceHandler {
Link Here
|
| 173 |
logger.error(e); |
194 |
logger.error(e); |
| 174 |
} |
195 |
} |
| 175 |
} |
196 |
} |
| 176 |
if (appElement != null) |
197 |
if (appElement != null) { |
| 177 |
resource.getContents().add((EObject) appElement); |
198 |
resource.getContents().add((EObject) appElement); |
|
|
199 |
if (!hasTopLevelWindows(resource) && logger != null) { |
| 200 |
logger.error("No top-level windows seen when migrating from existing delta files"); //$NON-NLS-1$ |
| 201 |
} |
| 202 |
} |
| 178 |
return resource; |
203 |
return resource; |
| 179 |
} |
204 |
} |
| 180 |
} |
205 |
} |
|
Lines 200-205
public class ResourceHandler implements IModelResourceHandler {
Link Here
|
| 200 |
resource = null; |
225 |
resource = null; |
| 201 |
if (restore && saveAndRestore) { |
226 |
if (restore && saveAndRestore) { |
| 202 |
resource = loadResource(restoreLocation); |
227 |
resource = loadResource(restoreLocation); |
|
|
228 |
// If the saved model does not have any top-level windows, Eclipse will exit |
| 229 |
// immediately, so throw out the persisted state and reinitialize with the defaults. |
| 230 |
if (!hasTopLevelWindows(resource)) { |
| 231 |
if (logger != null) { |
| 232 |
logger.error(new Exception(), // log a stack trace to help debug the corruption |
| 233 |
"The persisted workbench has no top-level windows, so reinitializing with defaults."); //$NON-NLS-1$ |
| 234 |
} |
| 235 |
resource = null; |
| 236 |
} |
| 203 |
} |
237 |
} |
| 204 |
if (resource == null) { |
238 |
if (resource == null) { |
| 205 |
Resource applicationResource = loadResource(applicationDefinitionInstance); |
239 |
Resource applicationResource = loadResource(applicationDefinitionInstance); |
|
Lines 220-225
public class ResourceHandler implements IModelResourceHandler {
Link Here
|
| 220 |
context); |
254 |
context); |
| 221 |
contribProcessor.processModel(); |
255 |
contribProcessor.processModel(); |
| 222 |
|
256 |
|
|
|
257 |
if (!hasTopLevelWindows(resource) && logger != null) { |
| 258 |
logger.error(new Exception(), // log a stack trace to help debug the |
| 259 |
// corruption |
| 260 |
"Initializing from the application definition instance yields no top-level windows! " //$NON-NLS-1$ |
| 261 |
+ "Continuing execution, but the missing windows may cause other initialization failures."); //$NON-NLS-1$ |
| 262 |
} |
| 263 |
|
| 223 |
return resource; |
264 |
return resource; |
| 224 |
} |
265 |
} |
| 225 |
|
266 |
|