KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > core > feature > ExternalFeatureModel


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.core.feature;
12
13 import java.io.File JavaDoc;
14 import java.net.MalformedURLException JavaDoc;
15 import java.net.URL JavaDoc;
16
17 import org.eclipse.core.runtime.CoreException;
18 import org.eclipse.pde.internal.core.NLResourceHelper;
19
20 public class ExternalFeatureModel extends AbstractFeatureModel {
21     private static final long serialVersionUID = 1L;
22     private String JavaDoc location;
23     /**
24      * @see AbstractModel#updateTimeStamp()
25      */

26     protected void updateTimeStamp() {
27     }
28
29     /**
30      * @see IModel#isInSync()
31      */

32     public boolean isInSync() {
33         return true;
34     }
35     
36     public boolean isEditable() {
37         return false;
38     }
39
40     /**
41      * @see IModel#load()
42      */

43     public void load() throws CoreException {
44     }
45     
46     public void setInstallLocation(String JavaDoc location) {
47         this.location = location;
48     }
49     public String JavaDoc getInstallLocation() {
50         return location;
51     }
52     
53     protected NLResourceHelper createNLResourceHelper() {
54         if (location != null) {
55             URL JavaDoc url = getNLLookupLocation();
56             return new NLResourceHelper("feature", new URL JavaDoc[] { url }); //$NON-NLS-1$
57
}
58         return null;
59     }
60         
61     public URL JavaDoc getNLLookupLocation() {
62         try {
63             if (location != null && new File JavaDoc(location).isDirectory() && !location.endsWith("/")) //$NON-NLS-1$
64
return new URL JavaDoc("file:" + location + "/"); //$NON-NLS-1$ //$NON-NLS-2$
65
return new URL JavaDoc("file:" + location); //$NON-NLS-1$
66
} catch (MalformedURLException JavaDoc e) {
67             return null;
68         }
69     }
70
71 }
72
Popular Tags