[nobug] Adding facet cont
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.jst.server.tomcat.core/META-INF/MANIFEST.MF
index d6a4808..c3bc683 100644
--- a/plugins/org.eclipse.jst.server.tomcat.core/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.jst.server.tomcat.core/META-INF/MANIFEST.MF
@@ -8,6 +8,7 @@
Bundle-Localization: plugin
Export-Package: org.eclipse.jst.server.tomcat.core.internal;x-friends:="org.eclipse.jst.server.tomcat.ui",
org.eclipse.jst.server.tomcat.core.internal.command;x-friends:="org.eclipse.jst.server.tomcat.ui",
+ org.eclipse.jst.server.tomcat.core.internal.project.facet,
org.eclipse.jst.server.tomcat.core.internal.xml;x-friends:="org.eclipse.jst.server.tomcat.ui",
org.eclipse.jst.server.tomcat.core.internal.xml.server32;x-friends:="org.eclipse.jst.server.tomcat.ui",
org.eclipse.jst.server.tomcat.core.internal.xml.server40;x-friends:="org.eclipse.jst.server.tomcat.ui"
@@ -18,5 +19,6 @@
org.eclipse.jdt.core,
org.eclipse.jdt.launching,
org.eclipse.wst.server.core,
- org.eclipse.jst.server.core
+ org.eclipse.jst.server.core,
+ org.eclipse.wst.common.project.facet.core
Eclipse-AutoStart: true
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/project/facet/RuntimeBridge.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/project/facet/RuntimeBridge.java
new file mode 100644
index 0000000..fc53c38
--- /dev/null
+++ b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/project/facet/RuntimeBridge.java
@@ -0,0 +1,148 @@
+/******************************************************************************
+ * Copyright (c) 2005 BEA Systems, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Konstantin Komissarchik - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.jst.server.tomcat.core.internal.project.facet;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.launching.IVMInstall2;
+import org.eclipse.jdt.launching.IVMInstallType;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.jst.server.core.ClasspathRuntimeTargetHandler;
+import org.eclipse.wst.common.project.facet.core.runtime.IRuntimeComponentVersion;
+import org.eclipse.wst.common.project.facet.core.runtime.RuntimeManager;
+import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.server.core.IRuntimeTargetHandler;
+import org.eclipse.wst.server.core.ServerCore;
+
+/**
+ * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a>
+ */
+
+public final class RuntimeBridge
+{
+ private static Map mappings = new HashMap();
+
+ static
+ {
+ mappings.put( "org.eclipse.jst.server.tomcat.runtime.55",
+ RuntimeManager.get().getRuntimeComponentType( "tomcat" ).getVersion( "5.5" ) );
+
+ mappings.put( "org.eclipse.jst.server.tomcat.runtime.41",
+ RuntimeManager.get().getRuntimeComponentType( "tomcat" ).getVersion( "4.1" ) );
+ }
+
+ public static void port()
+ {
+ final IRuntime[] runtimes = ServerCore.getRuntimes();
+
+ for( int i = 0; i < runtimes.length; i++ )
+ {
+ final IRuntime runtime = runtimes[ i ];
+ final String name = runtime.getName();
+
+ if( ! RuntimeManager.get().isRuntimeDefined( name ) )
+ {
+ final String type = runtime.getRuntimeType().getId();
+
+ final IRuntimeComponentVersion mapped
+ = (IRuntimeComponentVersion) mappings.get( type );
+
+ if( mapped != null )
+ {
+ final List components = new ArrayList();
+
+ Map properties;
+
+ properties = new HashMap();
+ properties.put( "location", runtime.getLocation().toPortableString() );
+ properties.put( "name", name );
+
+ components.add( RuntimeManager.get().createRuntimeComponent( mapped, properties ) );
+
+ final ClasspathRuntimeTargetHandler cphandler
+ = getClasspathHandler( runtime );
+
+ final IPath jrecontainer
+ = findJreContainer( cphandler.getDelegateClasspathEntries( runtime, null ) );
+
+ final IVMInstallType vminstalltype
+ = JavaRuntime.getVMInstallType( jrecontainer.segment( 1 ) );
+
+ final IVMInstall2 vminstall
+ = (IVMInstall2) vminstalltype.findVMInstallByName( jrecontainer.segment( 2 ) );
+
+ final String jvmver = vminstall.getJavaVersion();
+ final IRuntimeComponentVersion rcv;
+
+ if( jvmver.startsWith( "1.4" ) )
+ {
+ rcv = RuntimeManager.get().getRuntimeComponentType( "standard.jre" ).getVersion( "1.4" );
+ }
+ else if( jvmver.startsWith( "1.5" ) )
+ {
+ rcv = RuntimeManager.get().getRuntimeComponentType( "standard.jre" ).getVersion( "5.0" );
+ }
+ else
+ {
+ continue;
+ }
+
+ properties = new HashMap();
+ properties.put( "name", jrecontainer.segment( 2 ) );
+
+ components.add( RuntimeManager.get().createRuntimeComponent( rcv, properties ) );
+
+ RuntimeManager.get().defineRuntime( name, components, null );
+ }
+ }
+ }
+ }
+
+ private static ClasspathRuntimeTargetHandler getClasspathHandler( final IRuntime r )
+ {
+ final IRuntimeTargetHandler[] handlers
+ = ServerCore.getRuntimeTargetHandlers();
+
+ for( int j = 0; j < handlers.length; j++ )
+ {
+ final IRuntimeTargetHandler handler = handlers[ j ];
+
+ if( handler.supportsRuntimeType( r.getRuntimeType() ) )
+ {
+ return (ClasspathRuntimeTargetHandler) handler.getAdapter( ClasspathRuntimeTargetHandler.class );
+ }
+ }
+
+ throw new IllegalStateException();
+ }
+
+ private static IPath findJreContainer( final IClasspathEntry[] cpentries )
+ {
+ for( int i = 0; i < cpentries.length; i++ )
+ {
+ final IPath path = cpentries[ i ].getPath();
+
+ if( path.segment( 0 ).equals( JavaRuntime.JRE_CONTAINER ) )
+ {
+ return path;
+ }
+ }
+
+ throw new IllegalStateException();
+ }
+
+}
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/project/facet/StandardJreClasspathProvider.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/project/facet/StandardJreClasspathProvider.java
new file mode 100644
index 0000000..ec1614b
--- /dev/null
+++ b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/project/facet/StandardJreClasspathProvider.java
@@ -0,0 +1,90 @@
+/******************************************************************************
+ * Copyright (c) 2005 BEA Systems, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Konstantin Komissarchik - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.jst.server.tomcat.core.internal.project.facet;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.eclipse.wst.common.project.facet.core.runtime.IRuntimeComponent;
+import org.eclipse.wst.common.project.facet.core.runtime.classpath.IClasspathProvider;
+
+/**
+ * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a>
+ */
+
+public final class StandardJreClasspathProvider
+
+ implements IClasspathProvider
+
+{
+ private static final IProjectFacet JAVA_FEATURE
+ = ProjectFacetsManager.getProjectFacet( "java" );
+
+ private static final String STANDARD_VM_TYPE
+ = "org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType";
+
+
+ private final IRuntimeComponent rc;
+
+ public StandardJreClasspathProvider( final IRuntimeComponent rc )
+ {
+ this.rc = rc;
+ }
+
+ public List getClasspathEntries( final IProjectFacetVersion fv )
+ {
+ if( fv.getProjectFacet() == JAVA_FEATURE )
+ {
+ IPath path = new Path( JavaRuntime.JRE_CONTAINER );
+ path = path.append( STANDARD_VM_TYPE );
+ path = path.append( rc.getProperty( "name" ) );
+
+ final IClasspathEntry cpentry = JavaCore.newContainerEntry( path );
+
+ return Collections.singletonList( cpentry );
+ }
+
+ return null;
+ }
+
+ public static final class Factory
+
+ implements IAdapterFactory
+
+ {
+ private static final Class[] ADAPTER_TYPES
+ = { IClasspathProvider.class };
+
+ public Object getAdapter( final Object adaptable,
+ final Class adapterType )
+ {
+ final IRuntimeComponent rc = (IRuntimeComponent) adaptable;
+ return new StandardJreClasspathProvider( rc );
+ }
+
+ public Class[] getAdapterList()
+ {
+ return ADAPTER_TYPES;
+ }
+ }
+
+
+}
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/project/facet/TomcatClasspathProvider.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/project/facet/TomcatClasspathProvider.java
new file mode 100644
index 0000000..210b157
--- /dev/null
+++ b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/project/facet/TomcatClasspathProvider.java
@@ -0,0 +1,83 @@
+/******************************************************************************
+ * Copyright (c) 2005 BEA Systems, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Konstantin Komissarchik - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.jst.server.tomcat.core.internal.project.facet;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.eclipse.wst.common.project.facet.core.runtime.IRuntimeComponent;
+import org.eclipse.wst.common.project.facet.core.runtime.classpath.IClasspathProvider;
+
+/**
+ * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a>
+ */
+
+public final class TomcatClasspathProvider
+
+ implements IClasspathProvider
+
+{
+ private static final IProjectFacet WEB_FEATURE
+ = ProjectFacetsManager.getProjectFacet( "web" );
+
+ private final IRuntimeComponent rc;
+
+ public TomcatClasspathProvider( final IRuntimeComponent rc )
+ {
+ this.rc = rc;
+ }
+
+ public List getClasspathEntries( final IProjectFacetVersion fv )
+ {
+ if( fv.getProjectFacet() == WEB_FEATURE )
+ {
+ IPath path = new Path( "org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget" );
+ path = path.append( rc.getProperty( "name" ) );
+
+ final IClasspathEntry cpentry = JavaCore.newContainerEntry( path );
+
+ return Collections.singletonList( cpentry );
+ }
+
+ return null;
+ }
+
+ public static final class Factory
+
+ implements IAdapterFactory
+
+ {
+ private static final Class[] ADAPTER_TYPES
+ = { IClasspathProvider.class };
+
+ public Object getAdapter( final Object adaptable,
+ final Class adapterType )
+ {
+ final IRuntimeComponent rc = (IRuntimeComponent) adaptable;
+ return new TomcatClasspathProvider( rc );
+ }
+
+ public Class[] getAdapterList()
+ {
+ return ADAPTER_TYPES;
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.jst.server.tomcat.ui/META-INF/MANIFEST.MF
index 75c8d8b..92749a6 100644
--- a/plugins/org.eclipse.jst.server.tomcat.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.jst.server.tomcat.ui/META-INF/MANIFEST.MF
@@ -7,7 +7,8 @@
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: org.eclipse.jst.server.tomcat.ui.internal;x-internal:=true,
- org.eclipse.jst.server.tomcat.ui.internal.editor;x-internal:=true
+ org.eclipse.jst.server.tomcat.ui.internal.editor;x-internal:=true,
+ org.eclipse.jst.server.tomcat.ui.internal.project.facet
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.expressions,
org.eclipse.ui,
@@ -19,5 +20,7 @@
org.eclipse.wst.server.core,
org.eclipse.wst.server.ui,
org.eclipse.jst.server.core,
- org.eclipse.jst.server.tomcat.core
+ org.eclipse.jst.server.tomcat.core,
+ org.eclipse.wst.common.project.facet.core,
+ org.eclipse.wst.common.project.facet.ui
Eclipse-AutoStart: true
diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/icons/obj16/jre.GIF b/plugins/org.eclipse.jst.server.tomcat.ui/icons/obj16/jre.GIF
new file mode 100644
index 0000000..2038b22
--- /dev/null
+++ b/plugins/org.eclipse.jst.server.tomcat.ui/icons/obj16/jre.GIF
Binary files differ
diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/plugin.xml b/plugins/org.eclipse.jst.server.tomcat.ui/plugin.xml
index eafb85b..a680762 100644
--- a/plugins/org.eclipse.jst.server.tomcat.ui/plugin.xml
+++ b/plugins/org.eclipse.jst.server.tomcat.ui/plugin.xml
@@ -136,5 +136,82 @@
class="org.eclipse.jst.server.tomcat.ui.internal.TomcatLaunchConfigurationTabGroup">
</launchConfigurationTabGroup>
</extension>
+
+ <extension point="org.eclipse.wst.common.project.facet.core.runtimes">
+
+ <runtime-component-type id="standard.jre">
+ <icon>icons/obj16/jre.gif</icon>
+ </runtime-component-type>
+
+ <runtime-component-version type="standard.jre" version="1.4">
+ <delegate class="org.eclipse.wst.common.project.facet.base.StandardJreRuntimeComponentDelegate"/>
+ </runtime-component-version>
+
+ <runtime-component-version type="standard.jre" version="5.0">
+ <delegate class="org.eclipse.wst.common.project.facet.base.StandardJreRuntimeComponentDelegate"/>
+ </runtime-component-version>
+
+ <adapter>
+ <runtime-component id="standard.jre"/>
+ <factory class="org.eclipse.jst.server.tomcat.core.internal.project.facet.StandardJreClasspathProvider$Factory"/>
+ <type class="org.eclipse.wst.common.project.facet.core.runtime.classpath.IClasspathProvider"/>
+ </adapter>
+
+ <adapter>
+ <runtime-component id="standard.jre"/>
+ <factory class="org.eclipse.jst.server.tomcat.ui.internal.project.facet.StandardJreLabelProvider$Factory"/>
+ <type class="org.eclipse.wst.common.project.facet.ui.IRuntimeComponentLabelProvider"/>
+ </adapter>
+
+ <supported>
+ <runtime-component id="standard.jre" version="1.4"/>
+ <facet id="java" version="1.4"/>
+ </supported>
+
+ <supported>
+ <runtime-component id="standard.jre" version="5.0"/>
+ <facet id="java" version="5.0"/>
+ </supported>
+
+ <runtime-component-type id="tomcat">
+ <icon>icons/obj16/tomcat.gif</icon>
+ </runtime-component-type>
+
+ <runtime-component-version type="tomcat" version="5.5">
+ <delegate class="org.eclipse.jst.server.tomcat.core.internal.project.facet.TomcatRuntimeComponentDelegate"/>
+ </runtime-component-version>
+
+ <runtime-component-version type="tomcat" version="4.1">
+ <delegate class="org.eclipse.jst.server.tomcat.core.internal.project.facet.TomcatRuntimeComponentDelegate"/>
+ </runtime-component-version>
+
+ <adapter>
+ <runtime-component id="tomcat"/>
+ <factory class="org.eclipse.jst.server.tomcat.core.internal.project.facet.TomcatClasspathProvider$Factory"/>
+ <type class="org.eclipse.wst.common.project.facet.core.runtime.classpath.IClasspathProvider"/>
+ </adapter>
+
+ <adapter>
+ <runtime-component id="tomcat"/>
+ <factory class="org.eclipse.jst.server.tomcat.ui.internal.project.facet.TomcatLabelProvider$Factory"/>
+ <type class="org.eclipse.wst.common.project.facet.ui.IRuntimeComponentLabelProvider"/>
+ </adapter>
+
+ <supported>
+ <runtime-component id="tomcat" version="5.5" allow-newer="true"/>
+ <facet id="web" version="2.4"/>
+ </supported>
+
+ <supported>
+ <runtime-component id="tomcat" version="4.1" allow-newer="true"/>
+ <facet id="web" version="2.3"/>
+ </supported>
+
+ <supported>
+ <runtime-component any="true"/>
+ <facet id="utility"/>
+ </supported>
+
+ </extension>
</plugin>
\ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/project/facet/StandardJreLabelProvider.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/project/facet/StandardJreLabelProvider.java
new file mode 100644
index 0000000..86bd351
--- /dev/null
+++ b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/project/facet/StandardJreLabelProvider.java
@@ -0,0 +1,79 @@
+/******************************************************************************
+ * Copyright (c) 2005 BEA Systems, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Konstantin Komissarchik - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.jst.server.tomcat.ui.internal.project.facet;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.jdt.launching.IVMInstall;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.wst.common.project.facet.core.runtime.IRuntimeComponent;
+import org.eclipse.wst.common.project.facet.ui.IRuntimeComponentLabelProvider;
+
+/**
+ * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a>
+ */
+
+public final class StandardJreLabelProvider
+
+ implements IRuntimeComponentLabelProvider
+
+{
+ private static final String TYPE
+ = "org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType";
+
+ private final IRuntimeComponent rc;
+
+ public StandardJreLabelProvider( final IRuntimeComponent rc )
+ {
+ this.rc = rc;
+ }
+
+ public String getLabel()
+ {
+ final String name = this.rc.getProperty( "name" );
+
+ final IVMInstall install
+ = JavaRuntime.getVMInstallType( TYPE ).findVMInstallByName( name );
+
+ final StringBuffer buf = new StringBuffer();
+
+ buf.append( "Standard JRE " );
+ buf.append( this.rc.getRuntimeComponentVersion().getVersionString() );
+ buf.append( " [" );
+ buf.append( install.getInstallLocation().toString() );
+ buf.append( "]" );
+
+ return buf.toString();
+ }
+
+ public static final class Factory
+
+ implements IAdapterFactory
+
+ {
+ private static final Class[] ADAPTER_TYPES
+ = { IRuntimeComponentLabelProvider.class };
+
+ public Object getAdapter( final Object adaptable,
+ final Class adapterType )
+ {
+ final IRuntimeComponent rc = (IRuntimeComponent) adaptable;
+ return new StandardJreLabelProvider( rc );
+ }
+
+ public Class[] getAdapterList()
+ {
+ return ADAPTER_TYPES;
+ }
+ }
+
+
+}
diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/project/facet/TomcatLabelProvider.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/project/facet/TomcatLabelProvider.java
new file mode 100644
index 0000000..f0414af
--- /dev/null
+++ b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/project/facet/TomcatLabelProvider.java
@@ -0,0 +1,73 @@
+/******************************************************************************
+ * Copyright (c) 2005 BEA Systems, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Konstantin Komissarchik - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.jst.server.tomcat.ui.internal.project.facet;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.common.project.facet.core.runtime.IRuntimeComponent;
+import org.eclipse.wst.common.project.facet.ui.IRuntimeComponentLabelProvider;
+
+/**
+ * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a>
+ */
+
+public final class TomcatLabelProvider
+
+ implements IRuntimeComponentLabelProvider
+
+{
+ private final IRuntimeComponent rc;
+
+ public TomcatLabelProvider( final IRuntimeComponent rc )
+ {
+ this.rc = rc;
+ }
+
+ public String getLabel()
+ {
+ final IPath location
+ = Path.fromPortableString( this.rc.getProperty( "location" ) );
+
+ final StringBuffer buf = new StringBuffer();
+
+ buf.append( "Apache Tomcat " );
+ buf.append( this.rc.getRuntimeComponentVersion().getVersionString() );
+ buf.append( " [" );
+ buf.append( location.toOSString() );
+ buf.append( "]" );
+
+ return buf.toString();
+ }
+
+ public static final class Factory
+
+ implements IAdapterFactory
+
+ {
+ private static final Class[] ADAPTER_TYPES
+ = { IRuntimeComponentLabelProvider.class };
+
+ public Object getAdapter( final Object adaptable,
+ final Class adapterType )
+ {
+ final IRuntimeComponent rc = (IRuntimeComponent) adaptable;
+ return new TomcatLabelProvider( rc );
+ }
+
+ public Class[] getAdapterList()
+ {
+ return ADAPTER_TYPES;
+ }
+ }
+
+}