01: /*******************************************************************************
02: * Copyright (c) 2006, 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.core;
11:
12: import org.eclipse.core.resources.IResource;
13:
14: public abstract class AbstractNLModel extends AbstractModel {
15: protected transient NLResourceHelper fNLHelper;
16:
17: public NLResourceHelper getNLResourceHelper() {
18: if (fNLHelper == null)
19: fNLHelper = createNLResourceHelper();
20: return fNLHelper;
21: }
22:
23: public void resetNLResourceHelper() {
24: fNLHelper = null;
25: }
26:
27: public void dispose() {
28: if (fNLHelper != null) {
29: fNLHelper.dispose();
30: fNLHelper = null;
31: }
32: super .dispose();
33: }
34:
35: public String getResourceString(String key) {
36: if (key == null)
37: return ""; //$NON-NLS-1$
38:
39: if (fNLHelper == null)
40: fNLHelper = createNLResourceHelper();
41:
42: return fNLHelper != null ? fNLHelper.getResourceString(key)
43: : key;
44: }
45:
46: protected abstract NLResourceHelper createNLResourceHelper();
47:
48: public Object getAdapter(Class adapter) {
49: if (adapter == IResource.class) {
50: IResource resource = getUnderlyingResource();
51: return resource == null ? null : resource.getProject();
52: }
53: return super.getAdapter(adapter);
54: }
55:
56: }
|