1
/*******************************************************************************
2
* Copyright (C) 2003-2006, 2013, Guillaume Brocker
4
* All rights reserved. This program and the accompanying materials
5
* are made available under the terms of the Eclipse Public License v1.0
6
* which accompanies this distribution, and is available at
7
* http://www.eclipse.org/legal/epl-v10.html
10
* Guillaume Brocker - Initial API and implementation
12
******************************************************************************/
14
package eclox.core.doxygen;
17
import java.util.Collection;
18
import java.util.Vector;
20
import org.eclipse.core.runtime.FileLocator;
21
import org.eclipse.core.runtime.IConfigurationElement;
22
import org.eclipse.core.runtime.IExtension;
23
import org.eclipse.core.runtime.IExtensionPoint;
24
import org.eclipse.core.runtime.IExtensionRegistry;
25
import org.eclipse.core.runtime.Path;
26
import org.eclipse.core.runtime.Platform;
28
import eclox.core.Plugin;
30
public final class BundledDoxygen extends Doxygen {
35
* Retrieves all available bundled doxygen binaries.
37
* @return a collection with all collected bundled doxygen wrappers
39
public static Collection getAll() {
40
Collection doxygens = new Vector();
41
IExtensionRegistry registry = Platform.getExtensionRegistry();
42
IExtensionPoint point = registry.getExtensionPoint("org.gna.eclox.core.doxygen");
43
IExtension[] extensions = point.getExtensions();
45
for (int i = 0; i < extensions.length; i++) {
46
IExtension extension = extensions[i];
47
IConfigurationElement[] elements = extension.getConfigurationElements();
49
for (int j = 0; j < elements.length; j++) {
50
final String arch = elements[j].getAttribute("arch");
51
final String os = elements[j].getAttribute("os");
53
if( Platform.getOS().equals(os) && Platform.getOSArch().equals(arch) ) {
54
final Path path = new Path( elements[j].getAttribute("path") );
55
URL url = FileLocator.find(Plugin.getDefault().getBundle(), path, null);
58
doxygens.add( new BundledDoxygen(url) );
61
Plugin.getDefault().logError( path.toString() + ": not a valid doxygen path." );
70
* Creates a bundled doxygen instance from the given identifier
72
* @param identifier a string containing an identifier
74
* @return a new bundled doxygen wrapper
76
public static BundledDoxygen createFromIdentifier( final String identifier ) {
77
BundledDoxygen doxygen = null;
79
if( identifier.startsWith( BundledDoxygen.class.getName() ) ) {
80
final String location = identifier.substring( identifier.indexOf(' ') + 1 );
83
doxygen = new BundledDoxygen( new URL(location) );
85
catch( Throwable t ) {
94
* @see eclox.core.doxygen.Doxygen#getCommand()
96
public String getCommand() {
98
return FileLocator.resolve( location ).getPath();
100
catch( Throwable t ) {
107
* @see eclox.core.doxygen.Doxygen#getDescription()
109
public String getDescription() {
114
* @see eclox.core.doxygen.Doxygen#getIdentifier()
116
public String getIdentifier() {
117
return this.getClass().getName() + " " + location;
123
* @param location an url giving the location a doxygen binary
125
private BundledDoxygen( URL location ) {
126
this.location = location;
128
assert( location != null );