eclipse plugin: Add a link to the data/core directory for each project

This commit is contained in:
Timotei Dolean 2011-08-09 19:00:51 +00:00
parent 13e68b4733
commit 5cdb6b2f2c
8 changed files with 109 additions and 12 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 772 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -217,6 +217,7 @@
id="org.wesnoth.views">
</category>
<view
allowMultiple="false"
category="org.wesnoth.views"
class="org.wesnoth.views.WesnothProjectsExplorer"
icon="icons/wesnoth-icon_16.png"
@ -304,13 +305,13 @@
<navigatorContent
activeByDefault="true"
appearsBefore="org.eclipse.ui.navigator.resourceContent"
contentProvider="org.eclipse.ui.internal.navigator.resources.workbench.ResourceExtensionContentProvider"
contentProvider="org.wesnoth.views.WesnothProjectsExplorerContentProvider"
icon="icons/wesnoth-icon_16.png"
id="org.wesnoth.wesnothNavigatorContent"
labelProvider="org.eclipse.ui.internal.navigator.resources.workbench.ResourceExtensionLabelProvider"
labelProvider="org.wesnoth.views.WesnothProjectsExplorerLabelProvider"
name="Wesnoth Resources"
priority="highest"
sortOnly="true">
priority="lowest"
sortOnly="false">
<enablement>
<or>
<instanceof
@ -323,11 +324,18 @@
<parentExpression>
<or>
<instanceof
value="org.wesnoth.views.WesnothProjectsExplorer">
value="org.eclipse.core.resources.IProject">
</instanceof>
</or>
</parentExpression>
</commonSorter>
<triggerPoints>
<or>
<instanceof
value="org.eclipse.core.resources.IContainer">
</instanceof>
</or>
</triggerPoints>
</navigatorContent>
</extension>
<extension

View file

@ -12,8 +12,10 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
@ -29,6 +31,7 @@ import org.wesnoth.templates.ReplaceableParameter;
import org.wesnoth.templates.TemplateProvider;
import org.wesnoth.utils.ResourceUtils;
import org.wesnoth.utils.StringUtils;
import org.wesnoth.views.WesnothProjectsExplorer;
public class ProjectUtils
{
@ -170,13 +173,8 @@ public class ProjectUtils
monitor.subTask( Messages.ProjectUtils_6 );
// add wesnoth nature
IProjectDescription tmpDescription = handle.getDescription( );
tmpDescription
.setNatureIds( new String[] { Constants.NATURE_WESNOTH /*
* ,
* Constants
* .
* NATURE_XTEXT
*/} );
tmpDescription.setNatureIds( new String[] {
Constants.NATURE_WESNOTH /* , Constants.NATURE_XTEXT */} );
handle.setDescription( tmpDescription, monitor );
monitor.worked( 5 );
@ -188,6 +186,7 @@ public class ProjectUtils
.getCampaignDir( ) ) )
&& ! normalizedPath.contains( StringUtils
.normalizePath( paths.getAddonsDir( ) ) ) ) {
ArrayList< ReplaceableParameter > param = new ArrayList< ReplaceableParameter >( );
param.add( new ReplaceableParameter(
"$$project_name", handle.getName( ) ) ); //$NON-NLS-1$
@ -200,11 +199,20 @@ public class ProjectUtils
}
monitor.worked( 10 );
// create the Core library link
IFolder coreLibrary = handle
.getFolder( WesnothProjectsExplorer.CORE_LIBRARY_NAME );
coreLibrary.createLink( new Path( paths.getCoreDir( ) ),
IResource.NONE, monitor );
monitor.worked( 10 );
// save the install name
ProjectCache cache = new ProjectCache( handle );
cache.setInstallName( installName );
cache.loadCache( );
projectCache_.put( handle, cache );
handle.refreshLocal( IResource.DEPTH_ONE, monitor );
} catch( CoreException e ) {
Logger.getInstance( ).logException( e );
return 1;

View file

@ -9,13 +9,17 @@
package org.wesnoth.views;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.ui.IElementFactory;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IPersistableElement;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.model.IWorkbenchAdapter;
import org.eclipse.ui.navigator.CommonNavigator;
import org.wesnoth.Logger;
public class WesnothProjectsExplorer extends CommonNavigator implements
IPersistableElement, IElementFactory
{
@ -25,6 +29,12 @@ public class WesnothProjectsExplorer extends CommonNavigator implements
public WesnothProjectsExplorer( )
{
try {
PlatformUI.getWorkbench( ).getDecoratorManager( )
.setEnabled( "org.eclipse.ui.LinkedResourceDecorator", false );
} catch( CoreException e ) {
Logger.getInstance( ).logException( e );
}
}
@Override

View file

@ -0,0 +1,16 @@
/*******************************************************************************
* Copyright (c) 2011 by Timotei Dolean <timotei21@gmail.com>
*
* 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
*******************************************************************************/
package org.wesnoth.views;
import org.eclipse.ui.model.WorkbenchContentProvider;
public class WesnothProjectsExplorerContentProvider extends
WorkbenchContentProvider
{
}

View file

@ -0,0 +1,47 @@
package org.wesnoth.views;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.wesnoth.WesnothPlugin;
public class WesnothProjectsExplorerLabelProvider extends LabelProvider
{
private static Image CORE_LIBRARY_IMAGE = null;
@Override
public String getText( Object element )
{
if( element instanceof IResource ) {
return ( ( IResource ) element ).getName( );
}
return super.getText( element );
}
@Override
public Image getImage( Object element )
{
if( element instanceof IContainer ) {
IContainer container = ( ( IContainer ) element );
if( container.getName( ).equals(
WesnothProjectsExplorer.CORE_LIBRARY_NAME ) ) {
return getCoreLibraryImage( );
}
}
return super.getImage( element );
}
private Image getCoreLibraryImage( )
{
if( CORE_LIBRARY_IMAGE == null ) {
CORE_LIBRARY_IMAGE = WesnothPlugin.getImageDescriptor(
"icons/closed_book_16.png" ).createImage( );
}
return CORE_LIBRARY_IMAGE;
}
}

View file

@ -45,6 +45,14 @@ public class WesnothProjectsExplorerViewerSorter extends ViewerSorter
return 1;
}
if( e1 instanceof IContainer && ! ( e2 instanceof IContainer ) ) {
return - 1;
}
if( e2 instanceof IContainer && ! ( e1 instanceof IContainer ) ) {
return 1;
}
return result;
}
}