KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > core > schema > FileSchemaDescriptor


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

11 package org.eclipse.pde.internal.core.schema;
12
13 import java.net.*;
14
15 import org.eclipse.core.resources.*;
16
17 public class FileSchemaDescriptor extends DevelopmentSchemaDescriptor {
18     private IFile file;
19
20 public FileSchemaDescriptor(IFile file) {
21     this.file = file;
22 }
23
24 protected Schema createSchema() {
25     URL url = getSchemaURL();
26     if (url==null) return null;
27     return new EditableSchema(this, url);
28 }
29 public IFile getFile() {
30     return file;
31 }
32
33 public String JavaDoc getPointId() {
34     IProject project = file.getProject();
35     String JavaDoc projectName = project.getName();
36     String JavaDoc fileName = file.getName();
37     int dotLoc = fileName.lastIndexOf('.');
38     return projectName + "."+fileName.substring(0, dotLoc); //$NON-NLS-1$
39
}
40
41 public URL getSchemaURL() {
42     try {
43 /*
44         return new URL(
45             "file:"
46                 + file.getProject().getLocation().removeLastSegments(1)
47                 + file.getFullPath().toString());
48 */

49         return new URL("file:"+file.getLocation().toOSString()); //$NON-NLS-1$
50
} catch (MalformedURLException e) {
51     }
52     return null;
53 }
54
55 public boolean isEnabled() {
56     return true;
57 }
58 }
59
Popular Tags