eclipse plugin: Apply the formatting rules & organize import
This commit is contained in:
parent
06aeb27b84
commit
020800ef20
157 changed files with 13332 additions and 12234 deletions
|
@ -1,4 +1,4 @@
|
|||
#Sat Aug 06 15:40:55 EEST 2011
|
||||
#Sat Aug 06 15:51:03 EEST 2011
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.codeComplete.argumentPrefixes=
|
||||
org.eclipse.jdt.core.codeComplete.argumentSuffixes=
|
||||
|
@ -303,21 +303,21 @@ org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declara
|
|||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
|
||||
|
|
|
@ -8,6 +8,8 @@ import java.util.List;
|
|||
import org.antlr.runtime.ANTLRStringStream;
|
||||
import org.antlr.runtime.CharStream;
|
||||
import org.antlr.runtime.Token;
|
||||
import org.junit.Ignore;
|
||||
|
||||
import org.eclipse.xtext.ParserRule;
|
||||
import org.eclipse.xtext.junit.AbstractXtextTests;
|
||||
import org.eclipse.xtext.nodemodel.INode;
|
||||
|
@ -16,7 +18,7 @@ import org.eclipse.xtext.parser.IParser;
|
|||
import org.eclipse.xtext.parser.antlr.ITokenDefProvider;
|
||||
import org.eclipse.xtext.parser.antlr.Lexer;
|
||||
import org.eclipse.xtext.parser.antlr.XtextTokenStream;
|
||||
import org.junit.Ignore;
|
||||
|
||||
import org.wesnoth.WMLStandaloneSetup;
|
||||
import org.wesnoth.services.WMLGrammarAccess;
|
||||
import org.wesnoth.utils.StringUtils;
|
||||
|
@ -25,34 +27,35 @@ import org.wesnoth.utils.StringUtils;
|
|||
public abstract class WMLTests extends AbstractXtextTests
|
||||
{
|
||||
protected WMLGrammarAccess grammar_;
|
||||
protected String dataPath_ = "";
|
||||
protected String dataPath_ = "";
|
||||
|
||||
private Lexer lexer;
|
||||
private ITokenDefProvider tokenDefProvider;
|
||||
private IParser parser;
|
||||
private Lexer lexer;
|
||||
private ITokenDefProvider tokenDefProvider;
|
||||
private IParser parser;
|
||||
|
||||
protected Lexer getLexer()
|
||||
protected Lexer getLexer( )
|
||||
{
|
||||
return lexer;
|
||||
}
|
||||
|
||||
protected ITokenDefProvider getTokenDefProvider()
|
||||
protected ITokenDefProvider getTokenDefProvider( )
|
||||
{
|
||||
return tokenDefProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IParser getParser()
|
||||
protected IParser getParser( )
|
||||
{
|
||||
return parser;
|
||||
}
|
||||
|
||||
Class getStandaloneSetupClass() {
|
||||
Class getStandaloneSetupClass( )
|
||||
{
|
||||
return WMLStandaloneSetup.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception
|
||||
protected void setUp( ) throws Exception
|
||||
{
|
||||
super.setUp( );
|
||||
with( getStandaloneSetupClass( ) );
|
||||
|
@ -63,14 +66,16 @@ public abstract class WMLTests extends AbstractXtextTests
|
|||
|
||||
// get the wesnoth data path from the user
|
||||
dataPath_ = System.getProperty( "wesnothDataDir" );
|
||||
if ( StringUtils.isNullOrEmpty( dataPath_ ) || ! new File( dataPath_ ).exists( ) ) {
|
||||
System.out.println( "Please set the wesnoth data dir before testing!." );
|
||||
if( StringUtils.isNullOrEmpty( dataPath_ )
|
||||
|| ! new File( dataPath_ ).exists( ) ) {
|
||||
System.out
|
||||
.println( "Please set the wesnoth data dir before testing!." );
|
||||
assertTrue( false );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception
|
||||
protected void tearDown( ) throws Exception
|
||||
{
|
||||
super.tearDown( );
|
||||
|
||||
|
@ -84,12 +89,13 @@ public abstract class WMLTests extends AbstractXtextTests
|
|||
/**
|
||||
* return the list of tokens created by the lexer from the given input
|
||||
*/
|
||||
protected List<Token> getTokens( String input )
|
||||
protected List< Token > getTokens( String input )
|
||||
{
|
||||
CharStream stream = new ANTLRStringStream( input );
|
||||
getLexer( ).setCharStream( stream );
|
||||
XtextTokenStream tokenStream = new XtextTokenStream( getLexer( ), getTokenDefProvider( ) );
|
||||
List<Token> tokens = tokenStream.getTokens( );
|
||||
XtextTokenStream tokenStream = new XtextTokenStream( getLexer( ),
|
||||
getTokenDefProvider( ) );
|
||||
List< Token > tokens = tokenStream.getTokens( );
|
||||
return tokens;
|
||||
}
|
||||
|
||||
|
@ -104,11 +110,12 @@ public abstract class WMLTests extends AbstractXtextTests
|
|||
/**
|
||||
* check whether an input is chopped into a list of expected token types
|
||||
*/
|
||||
protected void checkTokenisation( String input, String... expectedTokenTypes )
|
||||
protected void checkTokenisation( String input,
|
||||
String... expectedTokenTypes )
|
||||
{
|
||||
List<Token> tokens = getTokens( input );
|
||||
List< Token > tokens = getTokens( input );
|
||||
assertEquals( input, expectedTokenTypes.length, tokens.size( ) );
|
||||
for ( int i = 0; i < tokens.size( ); i++ ) {
|
||||
for( int i = 0; i < tokens.size( ); i++ ) {
|
||||
Token token = tokens.get( i );
|
||||
assertEquals( input, expectedTokenTypes[i], getTokenType( token ) );
|
||||
}
|
||||
|
@ -116,8 +123,8 @@ public abstract class WMLTests extends AbstractXtextTests
|
|||
|
||||
protected void showTokenisation( String input )
|
||||
{
|
||||
List<Token> tokens = getTokens( input );
|
||||
for ( int i = 0; i < tokens.size( ); i++ ) {
|
||||
List< Token > tokens = getTokens( input );
|
||||
for( int i = 0; i < tokens.size( ); i++ ) {
|
||||
Token token = tokens.get( i );
|
||||
System.out.println( getTokenType( token ) );
|
||||
}
|
||||
|
@ -128,7 +135,7 @@ public abstract class WMLTests extends AbstractXtextTests
|
|||
*/
|
||||
protected void failTokenisation( String input, String unExpectedTokenType )
|
||||
{
|
||||
List<Token> tokens = getTokens( input );
|
||||
List< Token > tokens = getTokens( input );
|
||||
assertEquals( input, 1, tokens.size( ) );
|
||||
Token token = tokens.get( 0 );
|
||||
assertNotSame( input, unExpectedTokenType, getTokenType( token ) );
|
||||
|
@ -158,8 +165,9 @@ public abstract class WMLTests extends AbstractXtextTests
|
|||
*/
|
||||
protected void checkParsing( Reader reader )
|
||||
{
|
||||
IParseResult la = getParser( ).parse( reader );;
|
||||
for ( INode node : la.getSyntaxErrors( ) ) {
|
||||
IParseResult la = getParser( ).parse( reader );
|
||||
;
|
||||
for( INode node: la.getSyntaxErrors( ) ) {
|
||||
System.out.println( node.getSyntaxErrorMessage( ).getMessage( ) );
|
||||
}
|
||||
assertEquals( false, la.hasSyntaxErrors( ) );
|
||||
|
@ -172,7 +180,7 @@ public abstract class WMLTests extends AbstractXtextTests
|
|||
protected void checkParsing( String input, ParserRule entryRule )
|
||||
{
|
||||
IParseResult la = getParseResult( input, entryRule );
|
||||
for ( INode node : la.getSyntaxErrors( ) ) {
|
||||
for( INode node: la.getSyntaxErrors( ) ) {
|
||||
System.out.println( node.getSyntaxErrorMessage( ).getMessage( ) );
|
||||
}
|
||||
assertEquals( input, false, la.hasSyntaxErrors( ) );
|
||||
|
@ -196,7 +204,7 @@ public abstract class WMLTests extends AbstractXtextTests
|
|||
// the rule name for a keyword is usually
|
||||
// the keyword enclosed in single quotes
|
||||
String rule = new StringBuilder( "'" ).append( input ).append( "'" ) //$NON-NLS-1$ //$NON-NLS-2$
|
||||
.toString( );
|
||||
.toString( );
|
||||
checkTokenisation( input, rule );
|
||||
}
|
||||
|
||||
|
@ -205,7 +213,7 @@ public abstract class WMLTests extends AbstractXtextTests
|
|||
*/
|
||||
protected void failKeyword( String keyword )
|
||||
{
|
||||
List<Token> tokens = getTokens( keyword );
|
||||
List< Token > tokens = getTokens( keyword );
|
||||
assertEquals( keyword, 1, tokens.size( ) );
|
||||
String type = getTokenType( tokens.get( 0 ) );
|
||||
assertFalse( keyword, type.charAt( 0 ) == '\'' );
|
||||
|
@ -216,22 +224,23 @@ public abstract class WMLTests extends AbstractXtextTests
|
|||
{
|
||||
File theFile = new File( path );
|
||||
|
||||
if ( ! theFile.exists( ) ) {
|
||||
if( ! theFile.exists( ) ) {
|
||||
System.out.println( "Skipping non-existent path:" + path );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( theFile.isFile( ) )
|
||||
if( theFile.isFile( ) )
|
||||
testFile( path );
|
||||
else {
|
||||
for ( File file : theFile.listFiles( ) ) {
|
||||
for( File file: theFile.listFiles( ) ) {
|
||||
testPath( file.getAbsolutePath( ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
public void testFile( String path ) {
|
||||
public void testFile( String path )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,17 +10,14 @@ package org.wesnoth.tests;
|
|||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Suite;
|
||||
|
||||
import org.wesnoth.tests.grammar.WMLFilesTests;
|
||||
import org.wesnoth.tests.grammar.WMLGrammarTokensTests;
|
||||
import org.wesnoth.tests.plugin.WMLParsingCampaignsConfigs;
|
||||
|
||||
@RunWith( Suite.class )
|
||||
@Suite.SuiteClasses(
|
||||
{
|
||||
WMLGrammarTokensTests.class,
|
||||
WMLFilesTests.class,
|
||||
WMLParsingCampaignsConfigs.class,
|
||||
} )
|
||||
@Suite.SuiteClasses( { WMLGrammarTokensTests.class, WMLFilesTests.class,
|
||||
WMLParsingCampaignsConfigs.class, } )
|
||||
public class WMLTestsSuite
|
||||
{
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import java.io.FileNotFoundException;
|
|||
import java.io.FileReader;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import org.wesnoth.tests.WMLTests;
|
||||
|
||||
/**
|
||||
|
@ -19,9 +20,9 @@ import org.wesnoth.tests.WMLTests;
|
|||
*/
|
||||
public class WMLFilesTests extends WMLTests
|
||||
{
|
||||
public void testCoreFiles() throws FileNotFoundException
|
||||
public void testCoreFiles( ) throws FileNotFoundException
|
||||
{
|
||||
testPath( dataPath_ + "/core/" );
|
||||
testPath( dataPath_ + "/core/" );
|
||||
}
|
||||
|
||||
public void testCampaignAOI( ) throws FileNotFoundException
|
||||
|
@ -119,7 +120,7 @@ public class WMLFilesTests extends WMLTests
|
|||
public void testFile( String path )
|
||||
{
|
||||
// just config files
|
||||
if ( ! path.endsWith( ".cfg" ) )
|
||||
if( ! path.endsWith( ".cfg" ) )
|
||||
return;
|
||||
|
||||
System.out.print( "\nTesting file: " + path + "..." );
|
||||
|
@ -127,10 +128,9 @@ public class WMLFilesTests extends WMLTests
|
|||
try {
|
||||
checkParsing( new FileReader( path ) );
|
||||
System.out.print( " OK" );
|
||||
}
|
||||
catch ( FileNotFoundException e ) {
|
||||
e.printStackTrace();
|
||||
//should not reach here.
|
||||
} catch( FileNotFoundException e ) {
|
||||
e.printStackTrace( );
|
||||
// should not reach here.
|
||||
assertTrue( false );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,10 +11,10 @@ public class WMLGrammarTokensTests extends WMLTests
|
|||
// rule names in your grammar
|
||||
// the names of terminal rules will be capitalised
|
||||
// and "RULE_" will be appended to the front
|
||||
private static final String ID = "RULE_ID";
|
||||
private static final String ID = "RULE_ID";
|
||||
private static final String SL_COMMENT = "RULE_SL_COMMENT";
|
||||
|
||||
public void testID()
|
||||
public void testID( )
|
||||
{
|
||||
checkTokenisation( "1", ID );
|
||||
checkTokenisation( "a", ID );
|
||||
|
@ -23,14 +23,14 @@ public class WMLGrammarTokensTests extends WMLTests
|
|||
checkTokenisation( "abc_123", ID );
|
||||
}
|
||||
|
||||
public void testSLCOMMENT()
|
||||
public void testSLCOMMENT( )
|
||||
{
|
||||
checkTokenisation( "#comment", SL_COMMENT );
|
||||
checkTokenisation( "#comment\n", SL_COMMENT );
|
||||
checkTokenisation( "# comment \t\t comment\r\n", SL_COMMENT );
|
||||
}
|
||||
|
||||
public void testTokenParsing()
|
||||
public void testTokenParsing( )
|
||||
{
|
||||
checkParsing( "amount=+$random\r\n", grammar_.getWMLKeyRule( ) );
|
||||
checkParsing( "name={VALUE}\n", grammar_.getWMLKeyRule( ) );
|
||||
|
@ -39,4 +39,4 @@ public class WMLGrammarTokensTests extends WMLTests
|
|||
failParsing( "name=value", grammar_.getWMLKeyRule( ) );
|
||||
failParsing( "name=\n", grammar_.getWMLKeyRule( ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
import org.wesnoth.tests.WMLTests;
|
||||
import org.wesnoth.utils.StringUtils;
|
||||
import org.wesnoth.wml.SimpleWMLParser;
|
||||
|
@ -31,35 +32,34 @@ import org.wesnoth.wml.WMLConfig;
|
|||
@RunWith( value = Parameterized.class )
|
||||
public class WMLParsingCampaignsConfigs extends WMLTests
|
||||
{
|
||||
private String campaignDir_;
|
||||
private String campaignId;
|
||||
private List<String> scenarioIds_;
|
||||
private String campaignDir_;
|
||||
private String campaignId;
|
||||
private List< String > scenarioIds_;
|
||||
|
||||
private List<String> parsedCampaignIds_;
|
||||
private List<String> parsedScenarioIds_;
|
||||
private List< String > parsedCampaignIds_;
|
||||
private List< String > parsedScenarioIds_;
|
||||
|
||||
public WMLParsingCampaignsConfigs( String[] data )
|
||||
{
|
||||
try {
|
||||
setUp( );
|
||||
}
|
||||
catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
assertTrue ( false );
|
||||
} catch( Exception e ) {
|
||||
e.printStackTrace( );
|
||||
assertTrue( false );
|
||||
}
|
||||
|
||||
campaignDir_ = data[0];
|
||||
campaignId = data[1];
|
||||
scenarioIds_ = new ArrayList<String>();
|
||||
scenarioIds_ = new ArrayList< String >( );
|
||||
|
||||
parsedCampaignIds_ = new ArrayList<String>();
|
||||
parsedScenarioIds_ = new ArrayList<String>();
|
||||
parsedCampaignIds_ = new ArrayList< String >( );
|
||||
parsedScenarioIds_ = new ArrayList< String >( );
|
||||
|
||||
for( int i = data.length - 1 ; i > 1; --i )
|
||||
for( int i = data.length - 1; i > 1; --i )
|
||||
scenarioIds_.add( data[i] );
|
||||
|
||||
// gather all info
|
||||
testPath( dataPath_ + "/campaigns/" + campaignDir_ + "/" );
|
||||
testPath( dataPath_ + "/campaigns/" + campaignDir_ + "/" );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -67,36 +67,36 @@ public class WMLParsingCampaignsConfigs extends WMLTests
|
|||
public void testFile( String path )
|
||||
{
|
||||
// just config files
|
||||
if ( ! path.endsWith( ".cfg" ) )
|
||||
if( ! path.endsWith( ".cfg" ) )
|
||||
return;
|
||||
|
||||
try {
|
||||
SimpleWMLParser wmlParser = new SimpleWMLParser( new File( path ), getParser( ) );
|
||||
SimpleWMLParser wmlParser = new SimpleWMLParser( new File( path ),
|
||||
getParser( ) );
|
||||
wmlParser.parse( );
|
||||
WMLConfig config = wmlParser.getParsedConfig( );
|
||||
|
||||
if ( !StringUtils.isNullOrEmpty( config.ScenarioId ) )
|
||||
if( ! StringUtils.isNullOrEmpty( config.ScenarioId ) )
|
||||
parsedScenarioIds_.add( config.ScenarioId );
|
||||
|
||||
if ( !StringUtils.isNullOrEmpty( config.CampaignId ) )
|
||||
if( ! StringUtils.isNullOrEmpty( config.CampaignId ) )
|
||||
parsedCampaignIds_.add( config.CampaignId );
|
||||
|
||||
}
|
||||
catch ( FileNotFoundException e ) {
|
||||
e.printStackTrace();
|
||||
} catch( FileNotFoundException e ) {
|
||||
e.printStackTrace( );
|
||||
assertTrue( false );
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCampaignId()
|
||||
public void testCampaignId( )
|
||||
{
|
||||
assertTrue( parsedCampaignIds_.size( ) == 1 );
|
||||
assertEquals( campaignId, parsedCampaignIds_.get( 0 ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScenarioIds()
|
||||
public void testScenarioIds( )
|
||||
{
|
||||
assertEquals( scenarioIds_.size( ), parsedScenarioIds_.size( ) );
|
||||
|
||||
|
@ -107,11 +107,18 @@ public class WMLParsingCampaignsConfigs extends WMLTests
|
|||
}
|
||||
|
||||
@Parameters
|
||||
public static Collection< Object[] > data()
|
||||
public static Collection< Object[] > data( )
|
||||
{
|
||||
return Arrays.asList( new Object[][] {
|
||||
{ new String[]{ "An_Orcish_Incursion", "An_Orcish_Incursion", "01_Defend_the_Forest", "02_Assassins", "03_Wasteland", "04_Valley_of_Trolls", "05_Linaera_the_Quick", "06_A_Detour_through_the_Swamp", "07_Showdown" } },
|
||||
{ new String[]{ "Dead_Water", "Dead_Water", "01_Invasion", "02_Flight", "03_Wolf_Coast", "04_Slavers", "05_Tirigaz", "06_Uncharted_Islands", "07_Bilheld", "08_Talking_to_Tyegea", "09_The_Mage", "10_The_Flaming_Sword", "11_Getting_Help", "12_Revenge", "13_Epilogue" } }
|
||||
} );
|
||||
{ new String[] { "An_Orcish_Incursion", "An_Orcish_Incursion",
|
||||
"01_Defend_the_Forest", "02_Assassins", "03_Wasteland",
|
||||
"04_Valley_of_Trolls", "05_Linaera_the_Quick",
|
||||
"06_A_Detour_through_the_Swamp", "07_Showdown" } },
|
||||
{ new String[] { "Dead_Water", "Dead_Water", "01_Invasion",
|
||||
"02_Flight", "03_Wolf_Coast", "04_Slavers",
|
||||
"05_Tirigaz", "06_Uncharted_Islands", "07_Bilheld",
|
||||
"08_Talking_to_Tyegea", "09_The_Mage",
|
||||
"10_The_Flaming_Sword", "11_Getting_Help",
|
||||
"12_Revenge", "13_Epilogue" } } } );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#Sat Aug 06 15:40:55 EEST 2011
|
||||
#Sat Aug 06 15:51:03 EEST 2011
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.codeComplete.argumentPrefixes=
|
||||
org.eclipse.jdt.core.codeComplete.argumentSuffixes=
|
||||
|
@ -303,21 +303,21 @@ org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declara
|
|||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
|
||||
|
|
|
@ -12,33 +12,32 @@ import org.eclipse.osgi.util.NLS;
|
|||
|
||||
public class Messages extends NLS
|
||||
{
|
||||
private static final String BUNDLE_NAME = "org.wesnoth.ui.messages"; //$NON-NLS-1$
|
||||
public static String WMLDocMacro_0;
|
||||
public static String WMLDocMacro_1;
|
||||
public static String WMLDocMacro_2;
|
||||
public static String WMLDocTag_0;
|
||||
public static String WMLDocTag_1;
|
||||
public static String WMLEditor_0;
|
||||
public static String WMLEditor_1;
|
||||
public static String WMLEditor_2;
|
||||
public static String WMLEditor_3;
|
||||
public static String WMLEditor_4;
|
||||
public static String WMLEditor_5;
|
||||
public static String WMLHighlightingConfiguration_10;
|
||||
public static String WMLHighlightingConfiguration_11;
|
||||
public static String WMLHighlightingConfiguration_12;
|
||||
public static String WMLHighlightingConfiguration_13;
|
||||
public static String WMLHighlightingConfiguration_7;
|
||||
public static String WMLHighlightingConfiguration_8;
|
||||
public static String WMLHighlightingConfiguration_9;
|
||||
public static String WMLHyperlinkHelper_0;
|
||||
static
|
||||
{
|
||||
// initialize resource bundle
|
||||
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
|
||||
}
|
||||
private static final String BUNDLE_NAME = "org.wesnoth.ui.messages"; //$NON-NLS-1$
|
||||
public static String WMLDocMacro_0;
|
||||
public static String WMLDocMacro_1;
|
||||
public static String WMLDocMacro_2;
|
||||
public static String WMLDocTag_0;
|
||||
public static String WMLDocTag_1;
|
||||
public static String WMLEditor_0;
|
||||
public static String WMLEditor_1;
|
||||
public static String WMLEditor_2;
|
||||
public static String WMLEditor_3;
|
||||
public static String WMLEditor_4;
|
||||
public static String WMLEditor_5;
|
||||
public static String WMLHighlightingConfiguration_10;
|
||||
public static String WMLHighlightingConfiguration_11;
|
||||
public static String WMLHighlightingConfiguration_12;
|
||||
public static String WMLHighlightingConfiguration_13;
|
||||
public static String WMLHighlightingConfiguration_7;
|
||||
public static String WMLHighlightingConfiguration_8;
|
||||
public static String WMLHighlightingConfiguration_9;
|
||||
public static String WMLHyperlinkHelper_0;
|
||||
static {
|
||||
// initialize resource bundle
|
||||
NLS.initializeMessages( BUNDLE_NAME, Messages.class );
|
||||
}
|
||||
|
||||
private Messages()
|
||||
{
|
||||
}
|
||||
private Messages( )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
*******************************************************************************/
|
||||
package org.wesnoth.ui;
|
||||
|
||||
import com.google.inject.Binder;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
|
||||
import org.eclipse.jface.text.source.ICharacterPairMatcher;
|
||||
import org.eclipse.jface.viewers.ILabelProvider;
|
||||
|
@ -25,6 +28,7 @@ import org.eclipse.xtext.ui.editor.syntaxcoloring.AbstractAntlrTokenToAttributeI
|
|||
import org.eclipse.xtext.ui.editor.syntaxcoloring.IHighlightingConfiguration;
|
||||
import org.eclipse.xtext.ui.editor.syntaxcoloring.IHighlightingHelper;
|
||||
import org.eclipse.xtext.ui.editor.syntaxcoloring.ISemanticHighlightingCalculator;
|
||||
|
||||
import org.wesnoth.ui.autoedit.WMLAutoEditStrategy;
|
||||
import org.wesnoth.ui.contentassist.WMLContentAssistContext;
|
||||
import org.wesnoth.ui.contentassist.WMLProposalComparator;
|
||||
|
@ -40,109 +44,108 @@ import org.wesnoth.ui.syntax.WMLCharacterPairMatcher;
|
|||
import org.wesnoth.ui.syntax.WMLHighlightingConfiguration;
|
||||
import org.wesnoth.ui.syntax.WMLSemanticHighlightingCalculator;
|
||||
|
||||
import com.google.inject.Binder;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
/**
|
||||
* Use this class to register components to be used within the IDE.
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
@SuppressWarnings( "all" )
|
||||
public class WMLUiModule extends org.wesnoth.ui.AbstractWMLUiModule
|
||||
{
|
||||
public WMLUiModule(AbstractUIPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(Binder binder)
|
||||
{
|
||||
super.configure(binder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends IHighlightingHelper> bindIHighlightingHelper()
|
||||
{
|
||||
return WMLHighlightingHelper.class;
|
||||
}
|
||||
|
||||
public Class<? extends IHighlightingConfiguration> bindIHighlightingConfiguration()
|
||||
{
|
||||
return WMLHighlightingConfiguration.class;
|
||||
}
|
||||
|
||||
public Class<? extends AbstractAntlrTokenToAttributeIdMapper> bindTokenToAttributeIdMapper()
|
||||
{
|
||||
return WMLAntlrTokenToAttributeIdMapper.class;
|
||||
}
|
||||
|
||||
public Class<? extends ISemanticHighlightingCalculator> bindISemanticHighlightingCalculator()
|
||||
{
|
||||
return WMLSemanticHighlightingCalculator.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICharacterPairMatcher bindICharacterPairMatcher()
|
||||
public WMLUiModule( AbstractUIPlugin plugin )
|
||||
{
|
||||
return new WMLCharacterPairMatcher( new char[] { '(', ')', '{', '}', '[', ']' } );
|
||||
super( plugin );
|
||||
}
|
||||
|
||||
public Class<? extends XtextEditor> bindEditor()
|
||||
{
|
||||
return WMLEditor.class;
|
||||
}
|
||||
@Override
|
||||
public void configure( Binder binder )
|
||||
{
|
||||
super.configure( binder );
|
||||
}
|
||||
|
||||
public Class<? extends ILocationInFileProvider> bindILocationInFileProvider()
|
||||
{
|
||||
return WMLLocationInFileProvider.class;
|
||||
}
|
||||
@Override
|
||||
public Class< ? extends IHighlightingHelper > bindIHighlightingHelper( )
|
||||
{
|
||||
return WMLHighlightingHelper.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends IHyperlinkDetector> bindIHyperlinkDetector()
|
||||
{
|
||||
return super.bindIHyperlinkDetector();
|
||||
}
|
||||
public Class< ? extends IHighlightingConfiguration > bindIHighlightingConfiguration( )
|
||||
{
|
||||
return WMLHighlightingConfiguration.class;
|
||||
}
|
||||
|
||||
public Class<? extends HyperlinkHelper> bindHyperlinkHelper()
|
||||
{
|
||||
return WMLHyperlinkHelper.class;
|
||||
}
|
||||
public Class< ? extends AbstractAntlrTokenToAttributeIdMapper > bindTokenToAttributeIdMapper( )
|
||||
{
|
||||
return WMLAntlrTokenToAttributeIdMapper.class;
|
||||
}
|
||||
|
||||
public Class<? extends ContentAssistContext> bindContentAssistContext()
|
||||
{
|
||||
return WMLContentAssistContext.class;
|
||||
}
|
||||
public Class< ? extends ISemanticHighlightingCalculator > bindISemanticHighlightingCalculator( )
|
||||
{
|
||||
return WMLSemanticHighlightingCalculator.class;
|
||||
}
|
||||
|
||||
public Class<? extends ICompletionProposalComparator> bindICompletionProposalComparator()
|
||||
{
|
||||
return WMLProposalComparator.class;
|
||||
}
|
||||
@Override
|
||||
public ICharacterPairMatcher bindICharacterPairMatcher( )
|
||||
{
|
||||
return new WMLCharacterPairMatcher( new char[] { '(', ')', '{', '}',
|
||||
'[', ']' } );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends AbstractEditStrategyProvider> bindAbstractEditStrategyProvider()
|
||||
{
|
||||
return WMLAutoEditStrategy.class;
|
||||
}
|
||||
public Class< ? extends XtextEditor > bindEditor( )
|
||||
{
|
||||
return WMLEditor.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends ILabelProvider> bindILabelProvider()
|
||||
{
|
||||
return WMLLabelProvider.class;
|
||||
}
|
||||
public Class< ? extends ILocationInFileProvider > bindILocationInFileProvider( )
|
||||
{
|
||||
return WMLLocationInFileProvider.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends IXtextEditorCallback> bindIXtextEditorCallback()
|
||||
{
|
||||
return WMLAbstractDirtyEditorCallback.class;
|
||||
}
|
||||
@Override
|
||||
public Class< ? extends IHyperlinkDetector > bindIHyperlinkDetector( )
|
||||
{
|
||||
return super.bindIHyperlinkDetector( );
|
||||
}
|
||||
|
||||
public Class<? extends DefaultFoldingRegionProvider> bindDefaultFoldingRegionProvider()
|
||||
{
|
||||
return WMLFoldingRegionProvider.class;
|
||||
}
|
||||
public Class< ? extends HyperlinkHelper > bindHyperlinkHelper( )
|
||||
{
|
||||
return WMLHyperlinkHelper.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Provider<IAllContainersState> provideIAllContainersState()
|
||||
{
|
||||
return org.eclipse.xtext.ui.shared.Access.getWorkspaceProjectsState();
|
||||
}
|
||||
public Class< ? extends ContentAssistContext > bindContentAssistContext( )
|
||||
{
|
||||
return WMLContentAssistContext.class;
|
||||
}
|
||||
|
||||
public Class< ? extends ICompletionProposalComparator > bindICompletionProposalComparator( )
|
||||
{
|
||||
return WMLProposalComparator.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class< ? extends AbstractEditStrategyProvider > bindAbstractEditStrategyProvider( )
|
||||
{
|
||||
return WMLAutoEditStrategy.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class< ? extends ILabelProvider > bindILabelProvider( )
|
||||
{
|
||||
return WMLLabelProvider.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class< ? extends IXtextEditorCallback > bindIXtextEditorCallback( )
|
||||
{
|
||||
return WMLAbstractDirtyEditorCallback.class;
|
||||
}
|
||||
|
||||
public Class< ? extends DefaultFoldingRegionProvider > bindDefaultFoldingRegionProvider( )
|
||||
{
|
||||
return WMLFoldingRegionProvider.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Provider< IAllContainersState > provideIAllContainersState( )
|
||||
{
|
||||
return org.eclipse.xtext.ui.shared.Access.getWorkspaceProjectsState( );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.eclipse.xtext.resource.XtextResource;
|
|||
import org.eclipse.xtext.ui.editor.XtextEditor;
|
||||
import org.eclipse.xtext.ui.editor.utils.EditorUtils;
|
||||
import org.eclipse.xtext.util.concurrent.IUnitOfWork;
|
||||
|
||||
import org.wesnoth.utils.StringUtils;
|
||||
import org.wesnoth.wml.WMLTag;
|
||||
|
||||
|
@ -27,46 +28,51 @@ import org.wesnoth.wml.WMLTag;
|
|||
*/
|
||||
public class ClosingEndTagAutoEditStrategy implements IAutoEditStrategy
|
||||
{
|
||||
public void customizeDocumentCommand(final IDocument document,
|
||||
final DocumentCommand command)
|
||||
public void customizeDocumentCommand( final IDocument document,
|
||||
final DocumentCommand command )
|
||||
{
|
||||
try
|
||||
{
|
||||
if (command.text.equals("/") && document.get(command.offset-1, 1).equals("[")) //$NON-NLS-1$ //$NON-NLS-2$
|
||||
try {
|
||||
if( command.text.equals( "/" ) && document.get( command.offset - 1, 1 ).equals( "[" ) ) //$NON-NLS-1$ //$NON-NLS-2$
|
||||
{
|
||||
XtextEditor editor = EditorUtils.getActiveXtextEditor();
|
||||
if (editor == null)
|
||||
XtextEditor editor = EditorUtils.getActiveXtextEditor( );
|
||||
if( editor == null )
|
||||
return;
|
||||
|
||||
editor.getDocument().readOnly(new IUnitOfWork.Void<XtextResource>(){
|
||||
@Override
|
||||
public void process(XtextResource state) throws Exception
|
||||
{
|
||||
ILeafNode currentNode = NodeModelUtils.findLeafNodeAtOffset(
|
||||
state.getParseResult( ).getRootNode( ), command.offset);
|
||||
editor.getDocument( ).readOnly(
|
||||
new IUnitOfWork.Void< XtextResource >( ) {
|
||||
@Override
|
||||
public void process( XtextResource state )
|
||||
throws Exception
|
||||
{
|
||||
ILeafNode currentNode = NodeModelUtils
|
||||
.findLeafNodeAtOffset( state
|
||||
.getParseResult( )
|
||||
.getRootNode( ), command.offset );
|
||||
|
||||
if ( currentNode == null )
|
||||
return;
|
||||
if( currentNode == null )
|
||||
return;
|
||||
|
||||
EObject semanticElement = currentNode.getSemanticElement( );
|
||||
if ( semanticElement == null )
|
||||
return;
|
||||
EObject semanticElement = currentNode
|
||||
.getSemanticElement( );
|
||||
if( semanticElement == null )
|
||||
return;
|
||||
|
||||
String tagName = ""; //$NON-NLS-1$
|
||||
EObject container = semanticElement.eContainer( );
|
||||
if ( container instanceof WMLTag ){
|
||||
tagName = ( ( WMLTag ) container ).getName( );
|
||||
}
|
||||
String tagName = ""; //$NON-NLS-1$
|
||||
EObject container = semanticElement
|
||||
.eContainer( );
|
||||
if( container instanceof WMLTag ) {
|
||||
tagName = ( ( WMLTag ) container )
|
||||
.getName( );
|
||||
}
|
||||
|
||||
if ( !StringUtils.isNullOrEmpty( tagName ) )
|
||||
{
|
||||
command.shiftsCaret = true;
|
||||
command.text = ( "/" + tagName ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
}
|
||||
});
|
||||
if( ! StringUtils.isNullOrEmpty( tagName ) ) {
|
||||
command.shiftsCaret = true;
|
||||
command.text = ( "/" + tagName ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
} catch (BadLocationException e) {
|
||||
} catch( BadLocationException e ) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,17 +13,17 @@ import org.eclipse.xtext.ui.editor.autoedit.DefaultAutoEditStrategyProvider;
|
|||
|
||||
public class WMLAutoEditStrategy extends DefaultAutoEditStrategyProvider
|
||||
{
|
||||
public WMLAutoEditStrategy()
|
||||
{
|
||||
super();
|
||||
}
|
||||
public WMLAutoEditStrategy( )
|
||||
{
|
||||
super( );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure( IEditStrategyAcceptor acceptor )
|
||||
{
|
||||
super.configure( acceptor );
|
||||
configureStringLiteral(acceptor);
|
||||
acceptor.accept( new ClosingEndTagAutoEditStrategy(),
|
||||
IDocument.DEFAULT_CONTENT_TYPE );
|
||||
}
|
||||
@Override
|
||||
protected void configure( IEditStrategyAcceptor acceptor )
|
||||
{
|
||||
super.configure( acceptor );
|
||||
configureStringLiteral( acceptor );
|
||||
acceptor.accept( new ClosingEndTagAutoEditStrategy( ),
|
||||
IDocument.DEFAULT_CONTENT_TYPE );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,15 +8,15 @@
|
|||
*******************************************************************************/
|
||||
package org.wesnoth.ui.contentassist;
|
||||
|
||||
import org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext;
|
||||
|
||||
public class WMLContentAssistContext extends ContentAssistContext
|
||||
{
|
||||
@Inject
|
||||
public WMLContentAssistContext()
|
||||
{
|
||||
super();
|
||||
}
|
||||
@Inject
|
||||
public WMLContentAssistContext( )
|
||||
{
|
||||
super( );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,15 +14,14 @@ import org.eclipse.xtext.ui.editor.contentassist.ICompletionProposalComparator;
|
|||
|
||||
public class WMLProposalComparator implements ICompletionProposalComparator
|
||||
{
|
||||
public int compare(ICompletionProposal arg0, ICompletionProposal arg1)
|
||||
{
|
||||
if (arg0 instanceof ConfigurableCompletionProposal &&
|
||||
arg1 instanceof ConfigurableCompletionProposal)
|
||||
{
|
||||
ConfigurableCompletionProposal tmp0 = (ConfigurableCompletionProposal)arg0;
|
||||
ConfigurableCompletionProposal tmp1 = (ConfigurableCompletionProposal)arg1;
|
||||
return tmp0.compareTo(tmp1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public int compare( ICompletionProposal arg0, ICompletionProposal arg1 )
|
||||
{
|
||||
if( arg0 instanceof ConfigurableCompletionProposal
|
||||
&& arg1 instanceof ConfigurableCompletionProposal ) {
|
||||
ConfigurableCompletionProposal tmp0 = ( ConfigurableCompletionProposal ) arg0;
|
||||
ConfigurableCompletionProposal tmp1 = ( ConfigurableCompletionProposal ) arg1;
|
||||
return tmp0.compareTo( tmp1 );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,10 @@
|
|||
*******************************************************************************/
|
||||
package org.wesnoth.ui.contentassist;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Collections2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
@ -24,6 +28,7 @@ import org.eclipse.xtext.nodemodel.ICompositeNode;
|
|||
import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
|
||||
import org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext;
|
||||
import org.eclipse.xtext.ui.editor.contentassist.ICompletionProposalAcceptor;
|
||||
|
||||
import org.wesnoth.installs.WesnothInstallsUtils;
|
||||
import org.wesnoth.preprocessor.Define;
|
||||
import org.wesnoth.projects.ProjectCache;
|
||||
|
@ -42,364 +47,364 @@ import org.wesnoth.wml.WMLTag;
|
|||
import org.wesnoth.wml.WMLVariable;
|
||||
import org.wesnoth.wml.WMLVariable.Scope;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Collections2;
|
||||
|
||||
public class WMLProposalProvider extends AbstractWMLProposalProvider
|
||||
{
|
||||
protected SchemaParser schemaParser_;
|
||||
protected ProjectCache projectCache_;
|
||||
protected int dependencyIndex_;
|
||||
protected SchemaParser schemaParser_;
|
||||
protected ProjectCache projectCache_;
|
||||
protected int dependencyIndex_;
|
||||
|
||||
protected static final int KEY_VALUE_PRIORITY = 1700;
|
||||
protected static final int KEY_NAME_PRIORITY = 1500;
|
||||
protected static final int TAG_PRIORITY = 1000;
|
||||
protected static final int MACRO_CALL_PRIORITY = 100;
|
||||
protected static final int KEY_VALUE_PRIORITY = 1700;
|
||||
protected static final int KEY_NAME_PRIORITY = 1500;
|
||||
protected static final int TAG_PRIORITY = 1000;
|
||||
protected static final int MACRO_CALL_PRIORITY = 100;
|
||||
|
||||
private static Image MACRO_CALL_IMAGE = null;
|
||||
private static Image SCENARIO_VALUE_IMAGE = null;
|
||||
private static Image WML_KEY_IMAGE = null;
|
||||
private static Image WML_TAG_IMAGE = null;
|
||||
private static Image MACRO_CALL_IMAGE = null;
|
||||
private static Image SCENARIO_VALUE_IMAGE = null;
|
||||
private static Image WML_KEY_IMAGE = null;
|
||||
private static Image WML_TAG_IMAGE = null;
|
||||
|
||||
/**
|
||||
* For priorities, see:
|
||||
* {@link #KEY_NAME_PRIORITY}
|
||||
* {@link #KEY_VALUE_PRIORITY}
|
||||
* {@link #TAG_PRIORITY}
|
||||
* {@link #MACRO_CALL_PRIORITY}
|
||||
*/
|
||||
public WMLProposalProvider()
|
||||
{
|
||||
super();
|
||||
/**
|
||||
* For priorities, see: {@link #KEY_NAME_PRIORITY}
|
||||
* {@link #KEY_VALUE_PRIORITY} {@link #TAG_PRIORITY}
|
||||
* {@link #MACRO_CALL_PRIORITY}
|
||||
*/
|
||||
public WMLProposalProvider( )
|
||||
{
|
||||
super( );
|
||||
|
||||
MACRO_CALL_IMAGE = WMLLabelProvider.getImageByName("macrocall.png");
|
||||
SCENARIO_VALUE_IMAGE = WMLLabelProvider.getImageByName("scenario.png");
|
||||
WML_KEY_IMAGE = WMLLabelProvider.getImageByName("wmlkey.png");
|
||||
WML_TAG_IMAGE = WMLLabelProvider.getImageByName("wmltag.png");
|
||||
}
|
||||
MACRO_CALL_IMAGE = WMLLabelProvider.getImageByName( "macrocall.png" );
|
||||
SCENARIO_VALUE_IMAGE = WMLLabelProvider.getImageByName( "scenario.png" );
|
||||
WML_KEY_IMAGE = WMLLabelProvider.getImageByName( "wmlkey.png" );
|
||||
WML_TAG_IMAGE = WMLLabelProvider.getImageByName( "wmltag.png" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes the current project cache/schema based
|
||||
* on the file opened
|
||||
*/
|
||||
private void refresh()
|
||||
{
|
||||
if ( projectCache_ != null )
|
||||
return;
|
||||
/**
|
||||
* Refreshes the current project cache/schema based
|
||||
* on the file opened
|
||||
*/
|
||||
private void refresh( )
|
||||
{
|
||||
if( projectCache_ != null )
|
||||
return;
|
||||
|
||||
IFile file = WMLEditor.getActiveEditorFile();
|
||||
IFile file = WMLEditor.getActiveEditorFile( );
|
||||
projectCache_ = ProjectUtils.getCacheForProject( file.getProject( ) );
|
||||
|
||||
// load the schema so we know what to suggest for autocomplete
|
||||
schemaParser_ = SchemaParser.getInstance( WesnothInstallsUtils.getInstallNameForResource( file ) );
|
||||
schemaParser_ = SchemaParser.getInstance( WesnothInstallsUtils
|
||||
.getInstallNameForResource( file ) );
|
||||
|
||||
dependencyIndex_ = ResourceUtils.getDependencyIndex( file );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void completeWMLKey_Name(EObject model, Assignment assignment,
|
||||
ContentAssistContext context, ICompletionProposalAcceptor acceptor)
|
||||
{
|
||||
super.completeWMLKey_Name(model, assignment, context, acceptor);
|
||||
refresh( );
|
||||
@Override
|
||||
public void completeWMLKey_Name( EObject model, Assignment assignment,
|
||||
ContentAssistContext context, ICompletionProposalAcceptor acceptor )
|
||||
{
|
||||
super.completeWMLKey_Name( model, assignment, context, acceptor );
|
||||
refresh( );
|
||||
|
||||
addKeyNameProposals(model, context, acceptor);
|
||||
}
|
||||
addKeyNameProposals( model, context, acceptor );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void complete_WMLKeyValue(EObject model, RuleCall ruleCall,
|
||||
ContentAssistContext context, ICompletionProposalAcceptor acceptor)
|
||||
{
|
||||
super.complete_WMLKeyValue(model, ruleCall, context, acceptor);
|
||||
refresh( );
|
||||
@Override
|
||||
public void complete_WMLKeyValue( EObject model, RuleCall ruleCall,
|
||||
ContentAssistContext context, ICompletionProposalAcceptor acceptor )
|
||||
{
|
||||
super.complete_WMLKeyValue( model, ruleCall, context, acceptor );
|
||||
refresh( );
|
||||
|
||||
addKeyValueProposals(model, context, acceptor);
|
||||
}
|
||||
addKeyValueProposals( model, context, acceptor );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void complete_WMLTag(EObject model, RuleCall ruleCall,
|
||||
ContentAssistContext context, ICompletionProposalAcceptor acceptor)
|
||||
{
|
||||
super.complete_WMLTag(model, ruleCall, context, acceptor);
|
||||
refresh( );
|
||||
@Override
|
||||
public void complete_WMLTag( EObject model, RuleCall ruleCall,
|
||||
ContentAssistContext context, ICompletionProposalAcceptor acceptor )
|
||||
{
|
||||
super.complete_WMLTag( model, ruleCall, context, acceptor );
|
||||
refresh( );
|
||||
|
||||
addTagProposals(model, true, context, acceptor);
|
||||
}
|
||||
addTagProposals( model, true, context, acceptor );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void completeWMLTag_Name(EObject model, Assignment assignment,
|
||||
ContentAssistContext context, ICompletionProposalAcceptor acceptor)
|
||||
{
|
||||
super.completeWMLTag_Name(model, assignment, context, acceptor);
|
||||
refresh( );
|
||||
@Override
|
||||
public void completeWMLTag_Name( EObject model, Assignment assignment,
|
||||
ContentAssistContext context, ICompletionProposalAcceptor acceptor )
|
||||
{
|
||||
super.completeWMLTag_Name( model, assignment, context, acceptor );
|
||||
refresh( );
|
||||
|
||||
addTagProposals(model, false, context, acceptor);
|
||||
}
|
||||
addTagProposals( model, false, context, acceptor );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void completeWMLMacroCall_Name(EObject model, Assignment assignment,
|
||||
ContentAssistContext context, ICompletionProposalAcceptor acceptor)
|
||||
{
|
||||
super.completeWMLMacroCall_Name(model, assignment, context, acceptor);
|
||||
refresh( );
|
||||
@Override
|
||||
public void completeWMLMacroCall_Name( EObject model,
|
||||
Assignment assignment, ContentAssistContext context,
|
||||
ICompletionProposalAcceptor acceptor )
|
||||
{
|
||||
super.completeWMLMacroCall_Name( model, assignment, context, acceptor );
|
||||
refresh( );
|
||||
|
||||
addMacroCallProposals(model, false, context, acceptor);
|
||||
}
|
||||
addMacroCallProposals( model, false, context, acceptor );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void complete_WMLMacroCall(EObject model, RuleCall ruleCall,
|
||||
ContentAssistContext context, ICompletionProposalAcceptor acceptor)
|
||||
{
|
||||
super.complete_WMLMacroCall(model, ruleCall, context, acceptor);
|
||||
refresh( );
|
||||
@Override
|
||||
public void complete_WMLMacroCall( EObject model, RuleCall ruleCall,
|
||||
ContentAssistContext context, ICompletionProposalAcceptor acceptor )
|
||||
{
|
||||
super.complete_WMLMacroCall( model, ruleCall, context, acceptor );
|
||||
refresh( );
|
||||
|
||||
addMacroCallProposals(model, true, context, acceptor);
|
||||
}
|
||||
addMacroCallProposals( model, true, context, acceptor );
|
||||
}
|
||||
|
||||
private void addMacroCallProposals(EObject model, boolean ruleProposal,
|
||||
ContentAssistContext context, ICompletionProposalAcceptor acceptor)
|
||||
{
|
||||
for(Entry<String, Define> define : projectCache_.getDefines().entrySet())
|
||||
{
|
||||
StringBuilder proposal = new StringBuilder(10);
|
||||
if (ruleProposal == true)
|
||||
proposal.append("{"); //$NON-NLS-1$
|
||||
proposal.append(define.getKey());
|
||||
private void addMacroCallProposals( EObject model, boolean ruleProposal,
|
||||
ContentAssistContext context, ICompletionProposalAcceptor acceptor )
|
||||
{
|
||||
for( Entry< String, Define > define: projectCache_.getDefines( )
|
||||
.entrySet( ) ) {
|
||||
StringBuilder proposal = new StringBuilder( 10 );
|
||||
if( ruleProposal == true )
|
||||
proposal.append( "{" ); //$NON-NLS-1$
|
||||
proposal.append( define.getKey( ) );
|
||||
|
||||
for(String arg : define.getValue().getArguments())
|
||||
proposal.append(" " + arg); //$NON-NLS-1$
|
||||
proposal.append("}"); //$NON-NLS-1$
|
||||
for( String arg: define.getValue( ).getArguments( ) )
|
||||
proposal.append( " " + arg ); //$NON-NLS-1$
|
||||
proposal.append( "}" ); //$NON-NLS-1$
|
||||
|
||||
acceptor.accept(createCompletionProposal(proposal.toString(), define.getKey(),
|
||||
MACRO_CALL_IMAGE, context, MACRO_CALL_PRIORITY)); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
acceptor.accept( createCompletionProposal( proposal.toString( ),
|
||||
define.getKey( ), MACRO_CALL_IMAGE, context,
|
||||
MACRO_CALL_PRIORITY ) ); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
private void addKeyValueProposals(EObject model,
|
||||
ContentAssistContext context, ICompletionProposalAcceptor acceptor)
|
||||
{
|
||||
if ( model == null || !( model instanceof WMLKey ) )
|
||||
return;
|
||||
WMLKey key = (WMLKey)model;
|
||||
String keyName = key.getName( );
|
||||
private void addKeyValueProposals( EObject model,
|
||||
ContentAssistContext context, ICompletionProposalAcceptor acceptor )
|
||||
{
|
||||
if( model == null || ! ( model instanceof WMLKey ) )
|
||||
return;
|
||||
WMLKey key = ( WMLKey ) model;
|
||||
String keyName = key.getName( );
|
||||
|
||||
// handle the next_scenario and first_scenario
|
||||
if ( keyName.equals("next_scenario") || //$NON-NLS-1$
|
||||
keyName.equals("first_scenario")) //$NON-NLS-1$
|
||||
{
|
||||
for(WMLConfig config : projectCache_.getWMLConfigs().values())
|
||||
{
|
||||
if (StringUtils.isNullOrEmpty( config.ScenarioId ))
|
||||
continue;
|
||||
acceptor.accept(createCompletionProposal(config.ScenarioId,
|
||||
config.ScenarioId, SCENARIO_VALUE_IMAGE, //$NON-NLS-1$
|
||||
context, KEY_VALUE_PRIORITY));
|
||||
}
|
||||
}
|
||||
else if (model.eContainer() != null && model.eContainer() instanceof WMLTag)
|
||||
{
|
||||
WMLTag parent = (WMLTag) model.eContainer();
|
||||
String tagName = parent.getName();
|
||||
WMLTag tag = schemaParser_.getTags().get( tagName );
|
||||
if (tag != null)
|
||||
{
|
||||
WMLKey tagKey = WMLUtils.getKeyByName( tag, keyName );
|
||||
if ( tagKey != null && tagKey.is_Enum() )
|
||||
{
|
||||
for(WMLKeyValue val : tagKey.getValues( ) )
|
||||
{
|
||||
acceptor.accept(createCompletionProposal(
|
||||
val.toString( ), context, KEY_VALUE_PRIORITY ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
// handle the next_scenario and first_scenario
|
||||
if( keyName.equals( "next_scenario" ) || //$NON-NLS-1$
|
||||
keyName.equals( "first_scenario" ) ) //$NON-NLS-1$
|
||||
{
|
||||
for( WMLConfig config: projectCache_.getWMLConfigs( ).values( ) ) {
|
||||
if( StringUtils.isNullOrEmpty( config.ScenarioId ) )
|
||||
continue;
|
||||
acceptor.accept( createCompletionProposal( config.ScenarioId,
|
||||
config.ScenarioId, SCENARIO_VALUE_IMAGE, //$NON-NLS-1$
|
||||
context, KEY_VALUE_PRIORITY ) );
|
||||
}
|
||||
}
|
||||
else if( model.eContainer( ) != null
|
||||
&& model.eContainer( ) instanceof WMLTag ) {
|
||||
WMLTag parent = ( WMLTag ) model.eContainer( );
|
||||
String tagName = parent.getName( );
|
||||
WMLTag tag = schemaParser_.getTags( ).get( tagName );
|
||||
if( tag != null ) {
|
||||
WMLKey tagKey = WMLUtils.getKeyByName( tag, keyName );
|
||||
if( tagKey != null && tagKey.is_Enum( ) ) {
|
||||
for( WMLKeyValue val: tagKey.getValues( ) ) {
|
||||
acceptor.accept( createCompletionProposal(
|
||||
val.toString( ), context, KEY_VALUE_PRIORITY ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ( tagName.equals( "event" ) || tagName.equals( "fire_event" ) )
|
||||
&& keyName.equals( "name" ) ) {
|
||||
// add events
|
||||
List<String> events = new ArrayList<String>( );
|
||||
events.addAll( TemplateProvider.getInstance( ).getCAC( "events" ) );
|
||||
events.addAll( projectCache_.getEvents( ) );
|
||||
if( ( tagName.equals( "event" ) || tagName.equals( "fire_event" ) )
|
||||
&& keyName.equals( "name" ) ) {
|
||||
// add events
|
||||
List< String > events = new ArrayList< String >( );
|
||||
events.addAll( TemplateProvider.getInstance( )
|
||||
.getCAC( "events" ) );
|
||||
events.addAll( projectCache_.getEvents( ) );
|
||||
|
||||
for ( String event : events ) {
|
||||
acceptor.accept( createCompletionProposal( event, context ) );
|
||||
}
|
||||
} else {
|
||||
final int nodeOffset = NodeModelUtils.getNode( model ).getTotalOffset( );
|
||||
List<String> variables = new ArrayList<String>();
|
||||
for( String event: events ) {
|
||||
acceptor.accept( createCompletionProposal( event, context ) );
|
||||
}
|
||||
}
|
||||
else {
|
||||
final int nodeOffset = NodeModelUtils.getNode( model )
|
||||
.getTotalOffset( );
|
||||
List< String > variables = new ArrayList< String >( );
|
||||
|
||||
// add CAC variables
|
||||
variables.addAll( TemplateProvider.getInstance( ).getCAC( "variables" ) );
|
||||
variables.addAll( TemplateProvider.getInstance( ).getCAC(
|
||||
"variables" ) );
|
||||
|
||||
// filter variables by index
|
||||
Collection<String> projectVariables = Collections2.transform(
|
||||
projectCache_.getVariables( ).values( ),
|
||||
new Function<WMLVariable, String> () {
|
||||
// filter variables by index
|
||||
Collection< String > projectVariables = Collections2.transform(
|
||||
projectCache_.getVariables( ).values( ),
|
||||
new Function< WMLVariable, String >( ) {
|
||||
|
||||
@Override
|
||||
public String apply( WMLVariable from )
|
||||
{
|
||||
for ( Scope scope : from.getScopes( ) ) {
|
||||
if ( scope.contains( dependencyIndex_, nodeOffset ) )
|
||||
return from.getName( );
|
||||
}
|
||||
@Override
|
||||
public String apply( WMLVariable from )
|
||||
{
|
||||
for( Scope scope: from.getScopes( ) ) {
|
||||
if( scope.contains( dependencyIndex_,
|
||||
nodeOffset ) )
|
||||
return from.getName( );
|
||||
}
|
||||
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
} );
|
||||
|
||||
variables.addAll( Collections2.filter( projectVariables,
|
||||
Predicates.notNull( ) ) );
|
||||
|
||||
for( String variable: variables ) {
|
||||
acceptor.accept( createCompletionProposal( "$" + variable,
|
||||
context ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addKeyNameProposals( EObject model,
|
||||
ContentAssistContext context, ICompletionProposalAcceptor acceptor )
|
||||
{
|
||||
WMLTag tag = null;
|
||||
if( model instanceof WMLTag )
|
||||
tag = ( WMLTag ) model;
|
||||
else if( model.eContainer( ) instanceof WMLTag )
|
||||
tag = ( WMLTag ) model.eContainer( );
|
||||
|
||||
if( tag != null ) {
|
||||
WMLTag schemaTag = schemaParser_.getTags( ).get( tag.getName( ) );
|
||||
// try getting the custom ones
|
||||
if( schemaTag == null ) {
|
||||
schemaTag = projectCache_.getWMLTags( ).get( tag.getName( ) );
|
||||
}
|
||||
|
||||
if( schemaTag != null ) {
|
||||
for( WMLKey key: schemaTag.getWMLKeys( ) ) {
|
||||
// skip forbidden keys
|
||||
if( key.is_Forbidden( ) )
|
||||
continue;
|
||||
|
||||
boolean toAdd = true;
|
||||
// check only non-repeatable keys
|
||||
if( ! key.is_Repeatable( ) ) {
|
||||
// don't suggest already completed keys
|
||||
toAdd = ( WMLUtils.getKeyByName( tag, key.getName( ) ) != null );
|
||||
}
|
||||
} );
|
||||
|
||||
variables.addAll( Collections2.filter( projectVariables,
|
||||
Predicates.notNull( ) ) );
|
||||
if( toAdd )
|
||||
acceptor.accept( createCompletionProposal(
|
||||
key.getName( ) + "=", //$NON-NLS-1$
|
||||
key.getName( ), WML_KEY_IMAGE, context,
|
||||
KEY_NAME_PRIORITY ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ( String variable : variables ) {
|
||||
acceptor.accept( createCompletionProposal( "$" + variable, context ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void addTagProposals( EObject model, boolean ruleProposal,
|
||||
ContentAssistContext context, ICompletionProposalAcceptor acceptor )
|
||||
{
|
||||
WMLTag parentTag = null;
|
||||
if( model instanceof WMLTag )
|
||||
parentTag = ( WMLTag ) model;
|
||||
else if( model.eContainer( ) instanceof WMLTag )
|
||||
parentTag = ( WMLTag ) model.eContainer( );
|
||||
|
||||
private void addKeyNameProposals(EObject model,
|
||||
ContentAssistContext context, ICompletionProposalAcceptor acceptor)
|
||||
{
|
||||
WMLTag tag = null;
|
||||
if (model instanceof WMLTag)
|
||||
tag = (WMLTag)model;
|
||||
else if (model.eContainer() instanceof WMLTag)
|
||||
tag = (WMLTag)model.eContainer();
|
||||
if( parentTag != null ) {
|
||||
ICompositeNode node = NodeModelUtils.getNode( model );
|
||||
|
||||
if (tag != null)
|
||||
{
|
||||
WMLTag schemaTag = schemaParser_.getTags().get( tag.getName() );
|
||||
// try getting the custom ones
|
||||
if ( schemaTag == null ) {
|
||||
schemaTag = projectCache_.getWMLTags( ).get( tag.getName( ) );
|
||||
}
|
||||
String parentIndent = ""; //$NON-NLS-1$
|
||||
if( context.getCurrentNode( ).getOffset( ) > 0 )
|
||||
parentIndent = NodeModelUtils.findLeafNodeAtOffset( node,
|
||||
context.getCurrentNode( ).getOffset( ) -
|
||||
// if we have a non-rule proposal, subtract 1
|
||||
( ruleProposal ? 0: 1 ) ).getText( );
|
||||
|
||||
if ( schemaTag != null)
|
||||
{
|
||||
for( WMLKey key : schemaTag.getWMLKeys( ) )
|
||||
{
|
||||
// skip forbidden keys
|
||||
if ( key.is_Forbidden( ) )
|
||||
continue;
|
||||
// remove ugly new lines that break indentation
|
||||
parentIndent = parentIndent.replace( "\r", "" ).replace( "\n", "" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
|
||||
boolean toAdd = true;
|
||||
// check only non-repeatable keys
|
||||
if ( ! key.is_Repeatable() ) {
|
||||
// don't suggest already completed keys
|
||||
toAdd = ( WMLUtils.getKeyByName( tag, key.getName( ) ) != null );
|
||||
}
|
||||
WMLTag tagChildren = schemaParser_.getTags( ).get(
|
||||
parentTag.getName( ) );
|
||||
if( tagChildren != null ) {
|
||||
boolean toAdd = true;
|
||||
for( WMLTag tag: tagChildren.getWMLTags( ) ) {
|
||||
// skip forbidden tags
|
||||
if( tag.is_Forbidden( ) )
|
||||
continue;
|
||||
|
||||
if ( toAdd )
|
||||
acceptor.accept(createCompletionProposal(key.getName() + "=", //$NON-NLS-1$
|
||||
key.getName(), WML_KEY_IMAGE, context, KEY_NAME_PRIORITY));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
toAdd = true;
|
||||
|
||||
private void addTagProposals(EObject model, boolean ruleProposal,
|
||||
ContentAssistContext context, ICompletionProposalAcceptor acceptor)
|
||||
{
|
||||
WMLTag parentTag = null;
|
||||
if (model instanceof WMLTag)
|
||||
parentTag = (WMLTag)model;
|
||||
else if (model.eContainer() instanceof WMLTag)
|
||||
parentTag = (WMLTag)model.eContainer();
|
||||
// check only non-repeatable tags
|
||||
if( ! tag.is_Repeatable( ) ) {
|
||||
toAdd = ( WMLUtils.getTagByName( parentTag,
|
||||
tag.getName( ) ) == null );
|
||||
}
|
||||
|
||||
if (parentTag != null)
|
||||
{
|
||||
ICompositeNode node = NodeModelUtils.getNode(model);
|
||||
|
||||
String parentIndent = ""; //$NON-NLS-1$
|
||||
if (context.getCurrentNode().getOffset() > 0)
|
||||
parentIndent = NodeModelUtils.findLeafNodeAtOffset(node,
|
||||
context.getCurrentNode().getOffset() -
|
||||
// if we have a non-rule proposal, subtract 1
|
||||
(ruleProposal ? 0 : 1) ).getText();
|
||||
|
||||
// remove ugly new lines that break indentation
|
||||
parentIndent = parentIndent.replace("\r", "").replace("\n", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
|
||||
WMLTag tagChildren = schemaParser_.getTags().get(parentTag.getName());
|
||||
if (tagChildren != null)
|
||||
{
|
||||
boolean toAdd = true;
|
||||
for( WMLTag tag : tagChildren.getWMLTags( ) )
|
||||
{
|
||||
// skip forbidden tags
|
||||
if ( tag.is_Forbidden( ) )
|
||||
continue;
|
||||
|
||||
toAdd = true;
|
||||
|
||||
// check only non-repeatable tags
|
||||
if ( ! tag.is_Repeatable() )
|
||||
{
|
||||
toAdd = ( WMLUtils.getTagByName( parentTag, tag.getName( ) ) == null );
|
||||
}
|
||||
|
||||
if ( toAdd )
|
||||
acceptor.accept(createTagProposal( tag.asWMLTag( ), parentIndent,
|
||||
ruleProposal, context));
|
||||
}
|
||||
}
|
||||
}
|
||||
else // we are at the root
|
||||
{
|
||||
WMLTag rootTag = schemaParser_.getTags().get("root"); //$NON-NLS-1$
|
||||
for( WMLTag tag : rootTag.getWMLTags( ) )
|
||||
{
|
||||
acceptor.accept( createTagProposal( tag, "", ruleProposal, context ) ); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
if( toAdd )
|
||||
acceptor.accept( createTagProposal( tag.asWMLTag( ),
|
||||
parentIndent, ruleProposal, context ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
else // we are at the root
|
||||
{
|
||||
WMLTag rootTag = schemaParser_.getTags( ).get( "root" ); //$NON-NLS-1$
|
||||
for( WMLTag tag: rootTag.getWMLTags( ) ) {
|
||||
acceptor.accept( createTagProposal( tag,
|
||||
"", ruleProposal, context ) ); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
// parsed custom tags
|
||||
for( WMLTag tag : projectCache_.getWMLTags( ).values( ) )
|
||||
{
|
||||
for( WMLTag tag: projectCache_.getWMLTags( ).values( ) ) {
|
||||
acceptor.accept( createTagProposal( tag, "", ruleProposal, context ) ); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the proposal for the specified tag, usign the specified indent
|
||||
* @param tag The tag from which to construct the proposal
|
||||
* @param indent The indent used to indent the tag and subsequent keys
|
||||
* @param ruleProposal Whether this is a proposal for an entire rule or not
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
private ICompletionProposal createTagProposal( WMLTag tag, String indent,
|
||||
boolean ruleProposal, ContentAssistContext context)
|
||||
{
|
||||
StringBuilder proposal = new StringBuilder();
|
||||
if (ruleProposal)
|
||||
proposal.append("["); //$NON-NLS-1$
|
||||
proposal.append(tag.getName());
|
||||
proposal.append("]\n"); //$NON-NLS-1$
|
||||
for( WMLKey key : tag.getWMLKeys( ) )
|
||||
{
|
||||
if ( key.is_Required() )
|
||||
proposal.append(String.format("\t%s%s=\n", //$NON-NLS-1$
|
||||
indent, key.getName()));
|
||||
}
|
||||
proposal.append(String.format("%s[/%s",indent, tag.getName())); //$NON-NLS-1$
|
||||
return createCompletionProposal(proposal.toString(), tag.getName(),
|
||||
WML_TAG_IMAGE, context, TAG_PRIORITY);
|
||||
}
|
||||
/**
|
||||
* Returns the proposal for the specified tag, usign the specified indent
|
||||
*
|
||||
* @param tag
|
||||
* The tag from which to construct the proposal
|
||||
* @param indent
|
||||
* The indent used to indent the tag and subsequent keys
|
||||
* @param ruleProposal
|
||||
* Whether this is a proposal for an entire rule or not
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
private ICompletionProposal createTagProposal( WMLTag tag, String indent,
|
||||
boolean ruleProposal, ContentAssistContext context )
|
||||
{
|
||||
StringBuilder proposal = new StringBuilder( );
|
||||
if( ruleProposal )
|
||||
proposal.append( "[" ); //$NON-NLS-1$
|
||||
proposal.append( tag.getName( ) );
|
||||
proposal.append( "]\n" ); //$NON-NLS-1$
|
||||
for( WMLKey key: tag.getWMLKeys( ) ) {
|
||||
if( key.is_Required( ) )
|
||||
proposal.append( String.format( "\t%s%s=\n", //$NON-NLS-1$
|
||||
indent, key.getName( ) ) );
|
||||
}
|
||||
proposal.append( String.format( "%s[/%s", indent, tag.getName( ) ) ); //$NON-NLS-1$
|
||||
return createCompletionProposal( proposal.toString( ), tag.getName( ),
|
||||
WML_TAG_IMAGE, context, TAG_PRIORITY );
|
||||
}
|
||||
|
||||
private ICompletionProposal createCompletionProposal(String proposal,
|
||||
ContentAssistContext context, int priority)
|
||||
{
|
||||
return createCompletionProposal(proposal, null, null, priority,
|
||||
context.getPrefix(), context);
|
||||
}
|
||||
private ICompletionProposal createCompletionProposal( String proposal,
|
||||
ContentAssistContext context, int priority )
|
||||
{
|
||||
return createCompletionProposal( proposal, null, null, priority,
|
||||
context.getPrefix( ), context );
|
||||
}
|
||||
|
||||
public ICompletionProposal createCompletionProposal(String proposal, String displayString, Image image,
|
||||
ContentAssistContext contentAssistContext, int priority)
|
||||
{
|
||||
return createCompletionProposal(proposal, new StyledString(displayString),
|
||||
image, priority, contentAssistContext.getPrefix(), contentAssistContext);
|
||||
}
|
||||
public ICompletionProposal createCompletionProposal( String proposal,
|
||||
String displayString, Image image,
|
||||
ContentAssistContext contentAssistContext, int priority )
|
||||
{
|
||||
return createCompletionProposal( proposal, new StyledString(
|
||||
displayString ), image, priority,
|
||||
contentAssistContext.getPrefix( ), contentAssistContext );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,8 +10,11 @@ package org.wesnoth.ui.editor;
|
|||
|
||||
import org.eclipse.jface.action.IMenuManager;
|
||||
|
||||
public class DefaultExtXtextEditorCustomizer implements IExtXtextEditorCustomizer {
|
||||
public void customizeEditorContextMenu(IMenuManager menuManager) {
|
||||
// do nothing
|
||||
}
|
||||
public class DefaultExtXtextEditorCustomizer implements
|
||||
IExtXtextEditorCustomizer
|
||||
{
|
||||
public void customizeEditorContextMenu( IMenuManager menuManager )
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,15 +8,16 @@
|
|||
|
||||
package org.wesnoth.ui.editor;
|
||||
|
||||
import org.eclipse.jface.action.IMenuManager;
|
||||
|
||||
import com.google.inject.ImplementedBy;
|
||||
|
||||
import org.eclipse.jface.action.IMenuManager;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
@ImplementedBy(DefaultExtXtextEditorCustomizer.class)
|
||||
public interface IExtXtextEditorCustomizer {
|
||||
public void customizeEditorContextMenu(IMenuManager menuManager);
|
||||
@ImplementedBy( DefaultExtXtextEditorCustomizer.class )
|
||||
public interface IExtXtextEditorCustomizer
|
||||
{
|
||||
public void customizeEditorContextMenu( IMenuManager menuManager );
|
||||
}
|
||||
|
|
|
@ -20,34 +20,32 @@ import org.eclipse.ui.part.FileEditorInput;
|
|||
*/
|
||||
public class LinkedFileEditorInput extends FileEditorInput
|
||||
{
|
||||
public LinkedFileEditorInput(IFile file)
|
||||
{
|
||||
super(file);
|
||||
}
|
||||
public LinkedFileEditorInput( IFile file )
|
||||
{
|
||||
super( file );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
String targetUri = ""; //$NON-NLS-1$
|
||||
if (!(obj instanceof IFileEditorInput))
|
||||
{
|
||||
if (obj instanceof FileStoreEditorInput)
|
||||
{
|
||||
FileStoreEditorInput other = (FileStoreEditorInput)obj;
|
||||
targetUri = other.getURI().toString();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IFileEditorInput other = (IFileEditorInput) obj;
|
||||
targetUri = other.getFile().getLocationURI().toString();
|
||||
}
|
||||
if (targetUri.isEmpty())
|
||||
return false;
|
||||
return getFile().getLocationURI().toString().toLowerCase(Locale.ENGLISH).
|
||||
equals(targetUri.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
@Override
|
||||
public boolean equals( Object obj )
|
||||
{
|
||||
if( this == obj ) {
|
||||
return true;
|
||||
}
|
||||
String targetUri = ""; //$NON-NLS-1$
|
||||
if( ! ( obj instanceof IFileEditorInput ) ) {
|
||||
if( obj instanceof FileStoreEditorInput ) {
|
||||
FileStoreEditorInput other = ( FileStoreEditorInput ) obj;
|
||||
targetUri = other.getURI( ).toString( );
|
||||
}
|
||||
}
|
||||
else {
|
||||
IFileEditorInput other = ( IFileEditorInput ) obj;
|
||||
targetUri = other.getFile( ).getLocationURI( ).toString( );
|
||||
}
|
||||
if( targetUri.isEmpty( ) )
|
||||
return false;
|
||||
return getFile( ).getLocationURI( ).toString( )
|
||||
.toLowerCase( Locale.ENGLISH )
|
||||
.equals( targetUri.toLowerCase( Locale.ENGLISH ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,11 +15,12 @@ import org.eclipse.xtext.ui.editor.XtextEditor;
|
|||
* We use this class to suppress the default one which asks for adding
|
||||
* a xtext nature on non-xtext project. We don't want that (yet)
|
||||
*/
|
||||
public class WMLAbstractDirtyEditorCallback extends AbstractDirtyStateAwareEditorCallback
|
||||
public class WMLAbstractDirtyEditorCallback extends
|
||||
AbstractDirtyStateAwareEditorCallback
|
||||
{
|
||||
@Override
|
||||
public void afterCreatePartControl(XtextEditor editor)
|
||||
{
|
||||
super.afterCreatePartControl(editor);
|
||||
}
|
||||
@Override
|
||||
public void afterCreatePartControl( XtextEditor editor )
|
||||
{
|
||||
super.afterCreatePartControl( editor );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
*******************************************************************************/
|
||||
package org.wesnoth.ui.editor;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.wesnoth.Logger;
|
||||
import org.wesnoth.WesnothPlugin;
|
||||
import org.wesnoth.ui.Messages;
|
||||
import org.apache.log4j.Level;
|
||||
|
||||
import org.eclipse.core.filesystem.EFS;
|
||||
import org.eclipse.core.filesystem.IFileStore;
|
||||
|
@ -54,335 +54,375 @@ import org.eclipse.xtext.ui.editor.XtextEditor;
|
|||
import org.eclipse.xtext.ui.editor.syntaxcoloring.HighlightingHelper;
|
||||
import org.eclipse.xtext.ui.editor.utils.EditorUtils;
|
||||
|
||||
import org.apache.log4j.Level;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import org.wesnoth.Logger;
|
||||
import org.wesnoth.WesnothPlugin;
|
||||
import org.wesnoth.ui.Messages;
|
||||
|
||||
public class WMLEditor extends XtextEditor
|
||||
{
|
||||
private final static boolean DEBUG = false;
|
||||
private final static boolean DEBUG = false;
|
||||
|
||||
protected static final String AUTOLINK_PROJECT_NAME = "_AutoLinked_CFGExternalFiles_"; //$NON-NLS-1$
|
||||
protected static final String ENCODING_UTF8 = "utf-8"; //$NON-NLS-1$
|
||||
protected static final String AUTOLINK_PROJECT_NAME = "_AutoLinked_CFGExternalFiles_"; //$NON-NLS-1$
|
||||
protected static final String ENCODING_UTF8 = "utf-8"; //$NON-NLS-1$
|
||||
|
||||
@Inject
|
||||
private IExtXtextEditorCustomizer editorCustomizer;
|
||||
@Inject
|
||||
private IExtXtextEditorCustomizer editorCustomizer;
|
||||
|
||||
protected HighlightingHelper highlightingHelper_;
|
||||
protected HighlightingHelper highlightingHelper_;
|
||||
|
||||
public WMLEditor()
|
||||
{
|
||||
super();
|
||||
if ( DEBUG )
|
||||
org.apache.log4j.Logger.getLogger(XtextEditor.class).setLevel(Level.DEBUG);
|
||||
// activate the wesnoth plugin
|
||||
WesnothPlugin.getDefault();
|
||||
}
|
||||
public WMLEditor( )
|
||||
{
|
||||
super( );
|
||||
if( DEBUG )
|
||||
org.apache.log4j.Logger.getLogger( XtextEditor.class ).setLevel(
|
||||
Level.DEBUG );
|
||||
// activate the wesnoth plugin
|
||||
WesnothPlugin.getDefault( );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createPartControl(Composite parent)
|
||||
{
|
||||
super.createPartControl(parent);
|
||||
}
|
||||
@Override
|
||||
public void createPartControl( Composite parent )
|
||||
{
|
||||
super.createPartControl( parent );
|
||||
}
|
||||
|
||||
public HighlightingHelper getHighlightingHelper()
|
||||
public HighlightingHelper getHighlightingHelper( )
|
||||
{
|
||||
return highlightingHelper_;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if ((obj instanceof XtextEditor) == false)
|
||||
return false;
|
||||
if (getEditorInput() == null ||
|
||||
((XtextEditor)obj).getEditorInput() == null)
|
||||
return false;
|
||||
java.net.URI u1 = ((IURIEditorInput)getEditorInput()).getURI();
|
||||
java.net.URI u2 = ((IURIEditorInput)((XtextEditor)obj).getEditorInput()).getURI();
|
||||
if (u1 == null || u2 == null)
|
||||
return false;
|
||||
return u1.toString().equals(u2.toString());
|
||||
}
|
||||
@Override
|
||||
public boolean equals( Object obj )
|
||||
{
|
||||
if( ( obj instanceof XtextEditor ) == false )
|
||||
return false;
|
||||
if( getEditorInput( ) == null
|
||||
|| ( ( XtextEditor ) obj ).getEditorInput( ) == null )
|
||||
return false;
|
||||
java.net.URI u1 = ( ( IURIEditorInput ) getEditorInput( ) ).getURI( );
|
||||
java.net.URI u2 = ( ( IURIEditorInput ) ( ( XtextEditor ) obj )
|
||||
.getEditorInput( ) ).getURI( );
|
||||
if( u1 == null || u2 == null )
|
||||
return false;
|
||||
return u1.toString( ).equals( u2.toString( ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets current edited file.
|
||||
*
|
||||
* @return An IFile instance
|
||||
*/
|
||||
public static IFile getActiveEditorFile()
|
||||
public static IFile getActiveEditorFile( )
|
||||
{
|
||||
return getEditorFile( EditorUtils.getActiveXtextEditor() );
|
||||
return getEditorFile( EditorUtils.getActiveXtextEditor( ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the edited file from the specified editor
|
||||
* @param editor The editor to get the file from
|
||||
*
|
||||
* @param editor
|
||||
* The editor to get the file from
|
||||
* @return An IFile instance
|
||||
*/
|
||||
public static IFile getEditorFile( XtextEditor editor )
|
||||
{
|
||||
if ( editor == null )
|
||||
if( editor == null )
|
||||
return null;
|
||||
return ( IFile ) editor.getEditorInput( ).getAdapter( IFile.class );
|
||||
}
|
||||
|
||||
/**
|
||||
* Here it comes the part that handles external files
|
||||
* (from outside the workspace)
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* Copyright (c) 2010, Cloudsmith Inc.
|
||||
* The code, documentation and other materials contained herein have been
|
||||
* licensed under the Eclipse Public License - v 1.0 by the copyright holder
|
||||
* listed above, as the Initial Contributor under such license. The text of
|
||||
* such license is available at www.eclipse.org.
|
||||
*/
|
||||
/**
|
||||
* Here it comes the part that handles external files
|
||||
* (from outside the workspace)
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* Copyright (c) 2010, Cloudsmith Inc.
|
||||
* The code, documentation and other materials contained herein have been
|
||||
* licensed under the Eclipse Public License - v 1.0 by the copyright holder
|
||||
* listed above, as the Initial Contributor under such license. The text of
|
||||
* such license is available at www.eclipse.org.
|
||||
*/
|
||||
|
||||
private void createLink(IProject project, IFile linkFile, java.net.URI uri) throws CoreException {
|
||||
IPath path = linkFile.getFullPath();
|
||||
private void createLink( IProject project, IFile linkFile, java.net.URI uri )
|
||||
throws CoreException
|
||||
{
|
||||
IPath path = linkFile.getFullPath( );
|
||||
|
||||
IPath folders = path.removeLastSegments(1).removeFirstSegments(1);
|
||||
IPath checkPath = Path.ROOT;
|
||||
int segmentCount = folders.segmentCount();
|
||||
for(int i = 0; i < segmentCount; i++) {
|
||||
checkPath = checkPath.addTrailingSeparator().append(folders.segment(i));
|
||||
IFolder folder = project.getFolder(checkPath);
|
||||
if(!folder.exists())
|
||||
folder.create(true, true, null);
|
||||
}
|
||||
linkFile.createLink(uri, IResource.ALLOW_MISSING_LOCAL, null);
|
||||
}
|
||||
IPath folders = path.removeLastSegments( 1 ).removeFirstSegments( 1 );
|
||||
IPath checkPath = Path.ROOT;
|
||||
int segmentCount = folders.segmentCount( );
|
||||
for( int i = 0; i < segmentCount; i++ ) {
|
||||
checkPath = checkPath.addTrailingSeparator( ).append(
|
||||
folders.segment( i ) );
|
||||
IFolder folder = project.getFolder( checkPath );
|
||||
if( ! folder.exists( ) )
|
||||
folder.create( true, true, null );
|
||||
}
|
||||
linkFile.createLink( uri, IResource.ALLOW_MISSING_LOCAL, null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
// Unlink the input if it was linked
|
||||
IEditorInput input = getEditorInput();
|
||||
if(input instanceof IFileEditorInput) {
|
||||
IFile file = ((IFileEditorInput) input).getFile();
|
||||
if(file.isLinked()) {
|
||||
file.getProject().getName().equals(AUTOLINK_PROJECT_NAME);
|
||||
try {
|
||||
// if the editor is disposed because workbench is shutting down, it is NOT a good
|
||||
// idea to delete the link
|
||||
if(PlatformUI.isWorkbenchRunning() && !PlatformUI.getWorkbench().isClosing())
|
||||
file.delete(true, null);
|
||||
}
|
||||
catch(CoreException e) {
|
||||
// Nothing to do really, it will be recreated/refreshed later if ever used - some garbage may stay behind...
|
||||
Logger.getInstance().logException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
super.dispose();
|
||||
}
|
||||
@Override
|
||||
public void dispose( )
|
||||
{
|
||||
// Unlink the input if it was linked
|
||||
IEditorInput input = getEditorInput( );
|
||||
if( input instanceof IFileEditorInput ) {
|
||||
IFile file = ( ( IFileEditorInput ) input ).getFile( );
|
||||
if( file.isLinked( ) ) {
|
||||
file.getProject( ).getName( ).equals( AUTOLINK_PROJECT_NAME );
|
||||
try {
|
||||
// if the editor is disposed because workbench is shutting
|
||||
// down, it is NOT a good
|
||||
// idea to delete the link
|
||||
if( PlatformUI.isWorkbenchRunning( )
|
||||
&& ! PlatformUI.getWorkbench( ).isClosing( ) )
|
||||
file.delete( true, null );
|
||||
} catch( CoreException e ) {
|
||||
// Nothing to do really, it will be recreated/refreshed
|
||||
// later if ever used - some garbage may stay behind...
|
||||
Logger.getInstance( ).logException( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
super.dispose( );
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden to allow customization of editor context menu via injected handler
|
||||
*
|
||||
* @see org.eclipse.ui.editors.text.TextEditor#editorContextMenuAboutToShow(org.eclipse.jface.action.IMenuManager)
|
||||
*/
|
||||
@Override
|
||||
protected void editorContextMenuAboutToShow(IMenuManager menu) {
|
||||
super.editorContextMenuAboutToShow(menu);
|
||||
editorCustomizer.customizeEditorContextMenu(menu);
|
||||
}
|
||||
/**
|
||||
* Overridden to allow customization of editor context menu via injected
|
||||
* handler
|
||||
*
|
||||
* @see org.eclipse.ui.editors.text.TextEditor#editorContextMenuAboutToShow(org.eclipse.jface.action.IMenuManager)
|
||||
*/
|
||||
@Override
|
||||
protected void editorContextMenuAboutToShow( IMenuManager menu )
|
||||
{
|
||||
super.editorContextMenuAboutToShow( menu );
|
||||
editorCustomizer.customizeEditorContextMenu( menu );
|
||||
}
|
||||
|
||||
private IFile getWorkspaceFile(IFileStore fileStore) {
|
||||
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
|
||||
IFile[] files = workspaceRoot.findFilesForLocationURI(fileStore.toURI());
|
||||
if(files != null && files.length == 1)
|
||||
return files[0];
|
||||
return null;
|
||||
}
|
||||
private IFile getWorkspaceFile( IFileStore fileStore )
|
||||
{
|
||||
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace( )
|
||||
.getRoot( );
|
||||
IFile[] files = workspaceRoot.findFilesForLocationURI( fileStore
|
||||
.toURI( ) );
|
||||
if( files != null && files.length == 1 )
|
||||
return files[0];
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates an incoming IEditorInput being an FilestoreEditorInput, or IURIEditorInput
|
||||
* that is not also a IFileEditorInput.
|
||||
* FilestoreEditorInput is used when opening external files in an IDE environment.
|
||||
* The result is that the regular XtextEditor gets an IEFSEditorInput which is also an
|
||||
* IStorageEditorInput.
|
||||
*/
|
||||
@Override
|
||||
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
|
||||
// THE ISSUE HERE:
|
||||
// In the IDE, the File Open Dialog (and elsewhere) uses a FilestoreEditorInput class
|
||||
// which is an IDE specific implementation.
|
||||
// The state at this point:
|
||||
// 1. When creating a file, the IEditorInput is an IURIEditorInput
|
||||
// 2. The only (non IDE specific) interface implemented by FilestoreEditorInput is IURIEditorInput
|
||||
// 3. The creation of a file is however also an IFileEditorInput
|
||||
//
|
||||
// Remedy:
|
||||
if(input instanceof IURIEditorInput && !(input instanceof IFileEditorInput)) {
|
||||
java.net.URI uri = ((IURIEditorInput) input).getURI();
|
||||
String name = ((IURIEditorInput) input).getName();
|
||||
// Check if this is linkable input
|
||||
if(uri.getScheme().equals("file")) { //$NON-NLS-1$
|
||||
IFile linkedFile = obtainLink(uri);
|
||||
IFileEditorInput linkedInput = new LinkedFileEditorInput(linkedFile);
|
||||
super.init(site, linkedInput);
|
||||
/**
|
||||
* Translates an incoming IEditorInput being an FilestoreEditorInput, or
|
||||
* IURIEditorInput
|
||||
* that is not also a IFileEditorInput.
|
||||
* FilestoreEditorInput is used when opening external files in an IDE
|
||||
* environment.
|
||||
* The result is that the regular XtextEditor gets an IEFSEditorInput which
|
||||
* is also an
|
||||
* IStorageEditorInput.
|
||||
*/
|
||||
@Override
|
||||
public void init( IEditorSite site, IEditorInput input )
|
||||
throws PartInitException
|
||||
{
|
||||
// THE ISSUE HERE:
|
||||
// In the IDE, the File Open Dialog (and elsewhere) uses a
|
||||
// FilestoreEditorInput class
|
||||
// which is an IDE specific implementation.
|
||||
// The state at this point:
|
||||
// 1. When creating a file, the IEditorInput is an IURIEditorInput
|
||||
// 2. The only (non IDE specific) interface implemented by
|
||||
// FilestoreEditorInput is IURIEditorInput
|
||||
// 3. The creation of a file is however also an IFileEditorInput
|
||||
//
|
||||
// Remedy:
|
||||
if( input instanceof IURIEditorInput
|
||||
&& ! ( input instanceof IFileEditorInput ) ) {
|
||||
java.net.URI uri = ( ( IURIEditorInput ) input ).getURI( );
|
||||
String name = ( ( IURIEditorInput ) input ).getName( );
|
||||
// Check if this is linkable input
|
||||
if( uri.getScheme( ).equals( "file" ) ) { //$NON-NLS-1$
|
||||
IFile linkedFile = obtainLink( uri );
|
||||
IFileEditorInput linkedInput = new LinkedFileEditorInput(
|
||||
linkedFile );
|
||||
super.init( site, linkedInput );
|
||||
|
||||
}
|
||||
else {
|
||||
// use EMF URI (readonly) input - will open without validation though...
|
||||
// (Could be improved, i.e. perform a download, make readonly, and keep in project,
|
||||
// or stored in tmp, and processed as the other linked resources..
|
||||
URIEditorInput uriInput = new URIEditorInput(URI.createURI(uri.toString()), name);
|
||||
super.init(site, uriInput);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
super.init(site, input);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// use EMF URI (readonly) input - will open without validation
|
||||
// though...
|
||||
// (Could be improved, i.e. perform a download, make readonly,
|
||||
// and keep in project,
|
||||
// or stored in tmp, and processed as the other linked
|
||||
// resources..
|
||||
URIEditorInput uriInput = new URIEditorInput(
|
||||
URI.createURI( uri.toString( ) ), name );
|
||||
super.init( site, uriInput );
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
super.init( site, input );
|
||||
}
|
||||
|
||||
/**
|
||||
* Throws WrappedException - the URI must refer to an existing file!
|
||||
*
|
||||
* @param uri
|
||||
* @return
|
||||
*/
|
||||
private IFile obtainLink(java.net.URI uri) {
|
||||
try {
|
||||
IWorkspace ws = ResourcesPlugin.getWorkspace();
|
||||
// get, or create project if non existing
|
||||
IProject project = ws.getRoot().getProject(AUTOLINK_PROJECT_NAME);
|
||||
boolean newProject = false;
|
||||
if(!project.exists()) {
|
||||
project.create(null);
|
||||
newProject = true;
|
||||
}
|
||||
if(!project.isOpen()) {
|
||||
project.open(null);
|
||||
project.setHidden(true);
|
||||
}
|
||||
/**
|
||||
* Throws WrappedException - the URI must refer to an existing file!
|
||||
*
|
||||
* @param uri
|
||||
* @return
|
||||
*/
|
||||
private IFile obtainLink( java.net.URI uri )
|
||||
{
|
||||
try {
|
||||
IWorkspace ws = ResourcesPlugin.getWorkspace( );
|
||||
// get, or create project if non existing
|
||||
IProject project = ws.getRoot( ).getProject( AUTOLINK_PROJECT_NAME );
|
||||
boolean newProject = false;
|
||||
if( ! project.exists( ) ) {
|
||||
project.create( null );
|
||||
newProject = true;
|
||||
}
|
||||
if( ! project.isOpen( ) ) {
|
||||
project.open( null );
|
||||
project.setHidden( true );
|
||||
}
|
||||
|
||||
if(newProject)
|
||||
project.setDefaultCharset(ENCODING_UTF8, new NullProgressMonitor());
|
||||
if( newProject )
|
||||
project.setDefaultCharset( ENCODING_UTF8,
|
||||
new NullProgressMonitor( ) );
|
||||
|
||||
// path in project that is the same as the external file's path
|
||||
IFile linkFile = project.getFile(uri.getPath());
|
||||
if(linkFile.exists())
|
||||
linkFile.refreshLocal(1, null); // don't know if needed (or should be avoided...)
|
||||
else {
|
||||
// create the link
|
||||
createLink(project, linkFile, uri);
|
||||
// linkFile.createLink(uri, IResource.ALLOW_MISSING_LOCAL, null);
|
||||
}
|
||||
return linkFile;
|
||||
// path in project that is the same as the external file's path
|
||||
IFile linkFile = project.getFile( uri.getPath( ) );
|
||||
if( linkFile.exists( ) )
|
||||
linkFile.refreshLocal( 1, null ); // don't know if needed (or
|
||||
// should be avoided...)
|
||||
else {
|
||||
// create the link
|
||||
createLink( project, linkFile, uri );
|
||||
// linkFile.createLink(uri, IResource.ALLOW_MISSING_LOCAL,
|
||||
// null);
|
||||
}
|
||||
return linkFile;
|
||||
|
||||
// IPath location = new Path(name);
|
||||
// IFile file = project.getFile(location.lastSegment());
|
||||
// file.createLink(location, IResource.NONE, null);
|
||||
}
|
||||
catch(CoreException e) {
|
||||
throw new WrappedException(e);
|
||||
}
|
||||
}
|
||||
// IPath location = new Path(name);
|
||||
// IFile file = project.getFile(location.lastSegment());
|
||||
// file.createLink(location, IResource.NONE, null);
|
||||
} catch( CoreException e ) {
|
||||
throw new WrappedException( e );
|
||||
}
|
||||
}
|
||||
|
||||
// SaveAs support for linked files - saves them on local disc, not to workspace if file is in special
|
||||
// hidden external file link project.
|
||||
@Override
|
||||
protected void performSaveAs(IProgressMonitor progressMonitor) {
|
||||
// SaveAs support for linked files - saves them on local disc, not to
|
||||
// workspace if file is in special
|
||||
// hidden external file link project.
|
||||
@Override
|
||||
protected void performSaveAs( IProgressMonitor progressMonitor )
|
||||
{
|
||||
|
||||
Shell shell = getSite().getShell();
|
||||
final IEditorInput input = getEditorInput();
|
||||
Shell shell = getSite( ).getShell( );
|
||||
final IEditorInput input = getEditorInput( );
|
||||
|
||||
// Customize save as if the file is linked, and it is in the special external link project
|
||||
//
|
||||
if(input instanceof IFileEditorInput && ((IFileEditorInput) input).getFile().isLinked() &&
|
||||
((IFileEditorInput) input).getFile().getProject().getName().equals(AUTOLINK_PROJECT_NAME)) {
|
||||
final IEditorInput newInput;
|
||||
IDocumentProvider provider = getDocumentProvider();
|
||||
// Customize save as if the file is linked, and it is in the special
|
||||
// external link project
|
||||
//
|
||||
if( input instanceof IFileEditorInput
|
||||
&& ( ( IFileEditorInput ) input ).getFile( ).isLinked( )
|
||||
&& ( ( IFileEditorInput ) input ).getFile( ).getProject( )
|
||||
.getName( ).equals( AUTOLINK_PROJECT_NAME ) ) {
|
||||
final IEditorInput newInput;
|
||||
IDocumentProvider provider = getDocumentProvider( );
|
||||
|
||||
FileDialog dialog = new FileDialog(shell, SWT.SAVE);
|
||||
IPath oldPath = URIUtil.toPath(((IURIEditorInput) input).getURI());
|
||||
if(oldPath != null) {
|
||||
dialog.setFileName(oldPath.lastSegment());
|
||||
dialog.setFilterPath(oldPath.toOSString());
|
||||
}
|
||||
FileDialog dialog = new FileDialog( shell, SWT.SAVE );
|
||||
IPath oldPath = URIUtil.toPath( ( ( IURIEditorInput ) input )
|
||||
.getURI( ) );
|
||||
if( oldPath != null ) {
|
||||
dialog.setFileName( oldPath.lastSegment( ) );
|
||||
dialog.setFilterPath( oldPath.toOSString( ) );
|
||||
}
|
||||
|
||||
dialog.setFilterExtensions(new String[] { "*.b3", "*.*" }); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
String path = dialog.open();
|
||||
if(path == null) {
|
||||
if(progressMonitor != null)
|
||||
progressMonitor.setCanceled(true);
|
||||
return;
|
||||
}
|
||||
dialog.setFilterExtensions( new String[] { "*.b3", "*.*" } ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
String path = dialog.open( );
|
||||
if( path == null ) {
|
||||
if( progressMonitor != null )
|
||||
progressMonitor.setCanceled( true );
|
||||
return;
|
||||
}
|
||||
|
||||
// Check whether file exists and if so, confirm overwrite
|
||||
final File localFile = new File(path);
|
||||
if(localFile.exists()) {
|
||||
MessageDialog overwriteDialog = new MessageDialog(shell, Messages.WMLEditor_0, null, path +
|
||||
Messages.WMLEditor_1, MessageDialog.WARNING, new String[] {
|
||||
IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1); // 'No' is the default
|
||||
if(overwriteDialog.open() != Window.OK) {
|
||||
if(progressMonitor != null) {
|
||||
progressMonitor.setCanceled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Check whether file exists and if so, confirm overwrite
|
||||
final File localFile = new File( path );
|
||||
if( localFile.exists( ) ) {
|
||||
MessageDialog overwriteDialog = new MessageDialog( shell,
|
||||
Messages.WMLEditor_0, null,
|
||||
path + Messages.WMLEditor_1, MessageDialog.WARNING,
|
||||
new String[] { IDialogConstants.YES_LABEL,
|
||||
IDialogConstants.NO_LABEL }, 1 ); // 'No' is the
|
||||
// default
|
||||
if( overwriteDialog.open( ) != Window.OK ) {
|
||||
if( progressMonitor != null ) {
|
||||
progressMonitor.setCanceled( true );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IFileStore fileStore;
|
||||
try {
|
||||
fileStore = EFS.getStore(localFile.toURI());
|
||||
}
|
||||
catch(CoreException ex) {
|
||||
Logger.getInstance().logException(ex);
|
||||
String title = Messages.WMLEditor_2;
|
||||
String msg = Messages.WMLEditor_3 + ex.getMessage();
|
||||
MessageDialog.openError(shell, title, msg);
|
||||
return;
|
||||
}
|
||||
IFileStore fileStore;
|
||||
try {
|
||||
fileStore = EFS.getStore( localFile.toURI( ) );
|
||||
} catch( CoreException ex ) {
|
||||
Logger.getInstance( ).logException( ex );
|
||||
String title = Messages.WMLEditor_2;
|
||||
String msg = Messages.WMLEditor_3 + ex.getMessage( );
|
||||
MessageDialog.openError( shell, title, msg );
|
||||
return;
|
||||
}
|
||||
|
||||
IFile file = getWorkspaceFile(fileStore);
|
||||
if(file != null)
|
||||
newInput = new FileEditorInput(file);
|
||||
else {
|
||||
IURIEditorInput uriInput = new FileStoreEditorInput(fileStore);
|
||||
java.net.URI uri = uriInput.getURI();
|
||||
IFile linkedFile = obtainLink(uri);
|
||||
IFile file = getWorkspaceFile( fileStore );
|
||||
if( file != null )
|
||||
newInput = new FileEditorInput( file );
|
||||
else {
|
||||
IURIEditorInput uriInput = new FileStoreEditorInput( fileStore );
|
||||
java.net.URI uri = uriInput.getURI( );
|
||||
IFile linkedFile = obtainLink( uri );
|
||||
|
||||
newInput = new FileEditorInput(linkedFile);
|
||||
}
|
||||
newInput = new FileEditorInput( linkedFile );
|
||||
}
|
||||
|
||||
if(provider == null) {
|
||||
// editor has programmatically been closed while the dialog was open
|
||||
return;
|
||||
}
|
||||
if( provider == null ) {
|
||||
// editor has programmatically been closed while the dialog was
|
||||
// open
|
||||
return;
|
||||
}
|
||||
|
||||
boolean success = false;
|
||||
try {
|
||||
boolean success = false;
|
||||
try {
|
||||
|
||||
provider.aboutToChange(newInput);
|
||||
provider.saveDocument(progressMonitor, newInput, provider.getDocument(input), true);
|
||||
success = true;
|
||||
provider.aboutToChange( newInput );
|
||||
provider.saveDocument( progressMonitor, newInput,
|
||||
provider.getDocument( input ), true );
|
||||
success = true;
|
||||
|
||||
}
|
||||
catch(CoreException x) {
|
||||
Logger.getInstance().logException(x);
|
||||
final IStatus status = x.getStatus();
|
||||
if(status == null || status.getSeverity() != IStatus.CANCEL) {
|
||||
String title = Messages.WMLEditor_4;
|
||||
String msg = Messages.WMLEditor_5 + x.getMessage();
|
||||
MessageDialog.openError(shell, title, msg);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
provider.changed(newInput);
|
||||
if(success)
|
||||
setInput(newInput);
|
||||
}
|
||||
} catch( CoreException x ) {
|
||||
Logger.getInstance( ).logException( x );
|
||||
final IStatus status = x.getStatus( );
|
||||
if( status == null || status.getSeverity( ) != IStatus.CANCEL ) {
|
||||
String title = Messages.WMLEditor_4;
|
||||
String msg = Messages.WMLEditor_5 + x.getMessage( );
|
||||
MessageDialog.openError( shell, title, msg );
|
||||
}
|
||||
} finally {
|
||||
provider.changed( newInput );
|
||||
if( success )
|
||||
setInput( newInput );
|
||||
}
|
||||
|
||||
if(progressMonitor != null)
|
||||
progressMonitor.setCanceled(!success);
|
||||
if( progressMonitor != null )
|
||||
progressMonitor.setCanceled( ! success );
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
super.performSaveAs(progressMonitor);
|
||||
}
|
||||
super.performSaveAs( progressMonitor );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ public class WMLHighlightingHelper extends HighlightingHelper
|
|||
// set the highlighting helper in our editor
|
||||
// so we can access the highlightingReconcilier in order
|
||||
// to be able to refresh the semantic highlighting
|
||||
if ( editor instanceof WMLEditor ) {
|
||||
if( editor instanceof WMLEditor ) {
|
||||
( ( WMLEditor ) editor ).highlightingHelper_ = this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,18 +8,19 @@
|
|||
*******************************************************************************/
|
||||
package org.wesnoth.ui.folding;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import org.eclipse.emf.ecore.EObject;
|
||||
import org.eclipse.xtext.resource.ILocationInFileProvider;
|
||||
import org.eclipse.xtext.ui.editor.folding.DefaultFoldingRegionProvider;
|
||||
import org.eclipse.xtext.ui.editor.folding.IFoldingRegionAcceptor;
|
||||
import org.eclipse.xtext.util.ITextRegion;
|
||||
|
||||
import org.wesnoth.wml.WMLKey;
|
||||
import org.wesnoth.wml.WMLMacroDefine;
|
||||
import org.wesnoth.wml.WMLPreprocIF;
|
||||
import org.wesnoth.wml.WMLTextdomain;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
public class WMLFoldingRegionProvider extends DefaultFoldingRegionProvider
|
||||
{
|
||||
@Inject
|
||||
|
@ -28,11 +29,11 @@ public class WMLFoldingRegionProvider extends DefaultFoldingRegionProvider
|
|||
@Override
|
||||
protected boolean isHandled( EObject eObject )
|
||||
{
|
||||
if ( eObject instanceof WMLTextdomain )
|
||||
if( eObject instanceof WMLTextdomain )
|
||||
return false;
|
||||
else if ( eObject instanceof WMLKey ) {
|
||||
else if( eObject instanceof WMLKey ) {
|
||||
WMLKey key = ( WMLKey ) eObject;
|
||||
if ( !key.getEol( ).isEmpty( ) )
|
||||
if( ! key.getEol( ).isEmpty( ) )
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -40,29 +41,32 @@ public class WMLFoldingRegionProvider extends DefaultFoldingRegionProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void computeObjectFolding( EObject eObject, IFoldingRegionAcceptor<ITextRegion> foldingRegionAcceptor )
|
||||
protected void computeObjectFolding( EObject eObject,
|
||||
IFoldingRegionAcceptor< ITextRegion > foldingRegionAcceptor )
|
||||
{
|
||||
// copied from "DefaultFoldingRegionProvider
|
||||
ITextRegion region = locationInFileProvider.getFullTextRegion(eObject);
|
||||
if (region != null) {
|
||||
ITextRegion significant = locationInFileProvider.getSignificantTextRegion(eObject);
|
||||
if (significant == null)
|
||||
throw new NullPointerException("significant region may not be null");
|
||||
int offset = region.getOffset();
|
||||
ITextRegion region = locationInFileProvider.getFullTextRegion( eObject );
|
||||
if( region != null ) {
|
||||
ITextRegion significant = locationInFileProvider
|
||||
.getSignificantTextRegion( eObject );
|
||||
if( significant == null )
|
||||
throw new NullPointerException(
|
||||
"significant region may not be null" );
|
||||
int offset = region.getOffset( );
|
||||
int length = region.getLength( );
|
||||
|
||||
String endName = "";
|
||||
if ( eObject instanceof WMLPreprocIF )
|
||||
if( eObject instanceof WMLPreprocIF )
|
||||
endName = ( ( WMLPreprocIF ) eObject ).getEndName( );
|
||||
else if ( eObject instanceof WMLMacroDefine )
|
||||
else if( eObject instanceof WMLMacroDefine )
|
||||
endName = ( ( WMLMacroDefine ) eObject ).getEndName( );
|
||||
|
||||
if ( endName.endsWith( "\r\n" ) )
|
||||
if( endName.endsWith( "\r\n" ) )
|
||||
length -= 2;
|
||||
else if ( endName.endsWith( "\n" ) )
|
||||
-- length;
|
||||
else if( endName.endsWith( "\n" ) )
|
||||
--length;
|
||||
|
||||
foldingRegionAcceptor.accept(offset, length, significant);
|
||||
foldingRegionAcceptor.accept( offset, length, significant );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,21 +12,24 @@ import org.eclipse.xtext.ui.label.DefaultDescriptionLabelProvider;
|
|||
|
||||
/**
|
||||
* Provides labels for a IEObjectDescriptions and IResourceDescriptions.
|
||||
*
|
||||
* see http://www.eclipse.org/Xtext/documentation/latest/xtext.html#labelProvider
|
||||
*
|
||||
* see
|
||||
* http://www.eclipse.org/Xtext/documentation/latest/xtext.html#labelProvider
|
||||
*/
|
||||
public class WMLDescriptionLabelProvider extends DefaultDescriptionLabelProvider {
|
||||
public class WMLDescriptionLabelProvider extends
|
||||
DefaultDescriptionLabelProvider
|
||||
{
|
||||
|
||||
/*
|
||||
//Labels and icons can be computed like this:
|
||||
|
||||
String text(IEObjectDescription ele) {
|
||||
return "my "+ele.getName();
|
||||
}
|
||||
|
||||
String image(IEObjectDescription ele) {
|
||||
return ele.getEClass().getName() + ".gif";
|
||||
}
|
||||
*/
|
||||
/*
|
||||
* //Labels and icons can be computed like this:
|
||||
*
|
||||
* String text(IEObjectDescription ele) {
|
||||
* return "my "+ele.getName();
|
||||
* }
|
||||
*
|
||||
* String image(IEObjectDescription ele) {
|
||||
* return ele.getEClass().getName() + ".gif";
|
||||
* }
|
||||
*/
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
*******************************************************************************/
|
||||
package org.wesnoth.ui.labeling;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.eclipse.emf.ecore.EClass;
|
||||
|
@ -16,51 +18,51 @@ import org.eclipse.swt.graphics.Image;
|
|||
import org.eclipse.xtext.ui.editor.model.XtextDocument;
|
||||
import org.eclipse.xtext.ui.label.DefaultEObjectLabelProvider;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
/**
|
||||
* Provides labels for a EObjects.
|
||||
*
|
||||
* see http://www.eclipse.org/Xtext/documentation/latest/xtext.html#labelProvider
|
||||
*
|
||||
* see
|
||||
* http://www.eclipse.org/Xtext/documentation/latest/xtext.html#labelProvider
|
||||
*/
|
||||
public class WMLLabelProvider extends DefaultEObjectLabelProvider
|
||||
{
|
||||
private static WMLLabelProvider instance_;
|
||||
private static WMLLabelProvider instance_;
|
||||
|
||||
@Inject
|
||||
public WMLLabelProvider(AdapterFactoryLabelProvider delegate) {
|
||||
super(delegate);
|
||||
instance_ = this;
|
||||
}
|
||||
@Inject
|
||||
public WMLLabelProvider( AdapterFactoryLabelProvider delegate )
|
||||
{
|
||||
super( delegate );
|
||||
instance_ = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object doGetImage(Object element)
|
||||
{
|
||||
if (element instanceof EClass)
|
||||
{
|
||||
return ((EClass)element).getName().toLowerCase(Locale.ENGLISH) + ".png"; //$NON-NLS-1$
|
||||
}
|
||||
else if (element instanceof String)
|
||||
{
|
||||
return element;
|
||||
}
|
||||
return super.doGetImage(element);
|
||||
}
|
||||
@Override
|
||||
protected Object doGetImage( Object element )
|
||||
{
|
||||
if( element instanceof EClass ) {
|
||||
return ( ( EClass ) element ).getName( ).toLowerCase(
|
||||
Locale.ENGLISH )
|
||||
+ ".png"; //$NON-NLS-1$
|
||||
}
|
||||
else if( element instanceof String ) {
|
||||
return element;
|
||||
}
|
||||
return super.doGetImage( element );
|
||||
}
|
||||
|
||||
public static Image getImageByName(String fileName)
|
||||
{
|
||||
if (instance_ == null)
|
||||
return null;
|
||||
return instance_.getImage(fileName);
|
||||
}
|
||||
public static Image getImageByName( String fileName )
|
||||
{
|
||||
if( instance_ == null )
|
||||
return null;
|
||||
return instance_.getImage( fileName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText( Object element )
|
||||
{
|
||||
if ( element instanceof XtextDocument ) {
|
||||
return "Document";
|
||||
}
|
||||
@Override
|
||||
public String getText( Object element )
|
||||
{
|
||||
if( element instanceof XtextDocument ) {
|
||||
return "Document";
|
||||
}
|
||||
|
||||
return super.getText( element );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,25 +15,32 @@ import org.eclipse.swt.custom.StyleRange;
|
|||
*/
|
||||
public interface IWMLDocProvider
|
||||
{
|
||||
/**
|
||||
* Gets the title of the wmldoc dialog
|
||||
* @return
|
||||
*/
|
||||
public String getTitle();
|
||||
/**
|
||||
* Gets the text to be written in the info statusbar
|
||||
* @return
|
||||
*/
|
||||
public String getInfoText();
|
||||
/**
|
||||
* Gets the contents to be written into the
|
||||
* styledtext control of the wmldoc dialog
|
||||
* @return
|
||||
*/
|
||||
public String getContents();
|
||||
/**
|
||||
* Gets an array of StyleRange used to style the contents
|
||||
* @return
|
||||
*/
|
||||
public StyleRange[] getStyleRanges();
|
||||
/**
|
||||
* Gets the title of the wmldoc dialog
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getTitle( );
|
||||
|
||||
/**
|
||||
* Gets the text to be written in the info statusbar
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getInfoText( );
|
||||
|
||||
/**
|
||||
* Gets the contents to be written into the
|
||||
* styledtext control of the wmldoc dialog
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getContents( );
|
||||
|
||||
/**
|
||||
* Gets an array of StyleRange used to style the contents
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public StyleRange[] getStyleRanges( );
|
||||
}
|
||||
|
|
|
@ -8,15 +8,6 @@
|
|||
*******************************************************************************/
|
||||
package org.wesnoth.ui.labeling.wmldoc;
|
||||
|
||||
import org.wesnoth.Logger;
|
||||
import org.wesnoth.installs.WesnothInstallsUtils;
|
||||
import org.wesnoth.preprocessor.Define;
|
||||
import org.wesnoth.projects.ProjectUtils;
|
||||
import org.wesnoth.ui.editor.WMLEditor;
|
||||
import org.wesnoth.utils.WMLUtils;
|
||||
import org.wesnoth.wml.WMLMacroCall;
|
||||
import org.wesnoth.wml.WMLTag;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
|
@ -29,70 +20,87 @@ import org.eclipse.xtext.ui.editor.XtextEditor;
|
|||
import org.eclipse.xtext.ui.editor.utils.EditorUtils;
|
||||
import org.eclipse.xtext.util.concurrent.IUnitOfWork;
|
||||
|
||||
import org.wesnoth.Logger;
|
||||
import org.wesnoth.installs.WesnothInstallsUtils;
|
||||
import org.wesnoth.preprocessor.Define;
|
||||
import org.wesnoth.projects.ProjectUtils;
|
||||
import org.wesnoth.ui.editor.WMLEditor;
|
||||
import org.wesnoth.utils.WMLUtils;
|
||||
import org.wesnoth.wml.WMLMacroCall;
|
||||
import org.wesnoth.wml.WMLTag;
|
||||
|
||||
/**
|
||||
* A handler that handles pressing F2 on a resource in the editor
|
||||
*/
|
||||
public class WMLDocHandler extends AbstractHandler
|
||||
{
|
||||
public Object execute(ExecutionEvent event) throws ExecutionException
|
||||
public Object execute( ExecutionEvent event ) throws ExecutionException
|
||||
{
|
||||
try
|
||||
{
|
||||
final XtextEditor editor = EditorUtils.getActiveXtextEditor(event);
|
||||
try {
|
||||
final XtextEditor editor = EditorUtils.getActiveXtextEditor( event );
|
||||
final IFile editedFile = WMLEditor.getEditorFile( editor );
|
||||
final String installName = WesnothInstallsUtils.getInstallNameForResource( editedFile );
|
||||
final String installName = WesnothInstallsUtils
|
||||
.getInstallNameForResource( editedFile );
|
||||
|
||||
editor.getDocument().readOnly(new IUnitOfWork.Void<XtextResource>()
|
||||
{
|
||||
@Override
|
||||
public void process(XtextResource resource) throws Exception
|
||||
{
|
||||
WMLDocInformationPresenter presenter_ = null;
|
||||
|
||||
ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection();
|
||||
Point positionRelative = editor.getInternalSourceViewer().getTextWidget().getLocationAtOffset(selection.getOffset());
|
||||
Point positionAbsolute = editor.getInternalSourceViewer().getTextWidget().toDisplay(positionRelative);
|
||||
positionAbsolute.y += 20;
|
||||
|
||||
EObject grammarElement = WMLUtils.resolveElementAt( resource, selection.getOffset( ) );
|
||||
if ( grammarElement == null )
|
||||
return;
|
||||
|
||||
if ( grammarElement instanceof WMLMacroCall )
|
||||
{
|
||||
WMLMacroCall macro = (WMLMacroCall) grammarElement;
|
||||
Define define = ProjectUtils.getCacheForProject(
|
||||
editedFile.getProject()).getDefines().get(macro.getName());
|
||||
if (define != null)
|
||||
editor.getDocument( ).readOnly(
|
||||
new IUnitOfWork.Void< XtextResource >( ) {
|
||||
@Override
|
||||
public void process( XtextResource resource )
|
||||
throws Exception
|
||||
{
|
||||
if (presenter_ == null)
|
||||
{
|
||||
presenter_ = new WMLDocInformationPresenter(
|
||||
editor.getSite().getShell(), new WMLDocMacro(define),
|
||||
positionAbsolute);
|
||||
presenter_.create();
|
||||
WMLDocInformationPresenter presenter_ = null;
|
||||
|
||||
ITextSelection selection = ( ITextSelection ) editor
|
||||
.getSelectionProvider( ).getSelection( );
|
||||
Point positionRelative = editor
|
||||
.getInternalSourceViewer( )
|
||||
.getTextWidget( )
|
||||
.getLocationAtOffset( selection.getOffset( ) );
|
||||
Point positionAbsolute = editor
|
||||
.getInternalSourceViewer( ).getTextWidget( )
|
||||
.toDisplay( positionRelative );
|
||||
positionAbsolute.y += 20;
|
||||
|
||||
EObject grammarElement = WMLUtils.resolveElementAt(
|
||||
resource, selection.getOffset( ) );
|
||||
if( grammarElement == null )
|
||||
return;
|
||||
|
||||
if( grammarElement instanceof WMLMacroCall ) {
|
||||
WMLMacroCall macro = ( WMLMacroCall ) grammarElement;
|
||||
Define define = ProjectUtils
|
||||
.getCacheForProject(
|
||||
editedFile.getProject( ) )
|
||||
.getDefines( ).get( macro.getName( ) );
|
||||
if( define != null ) {
|
||||
if( presenter_ == null ) {
|
||||
presenter_ = new WMLDocInformationPresenter(
|
||||
editor.getSite( ).getShell( ),
|
||||
new WMLDocMacro( define ),
|
||||
positionAbsolute );
|
||||
presenter_.create( );
|
||||
}
|
||||
presenter_.open( );
|
||||
}
|
||||
}
|
||||
else if( grammarElement instanceof WMLTag ) {
|
||||
if( presenter_ == null ) {
|
||||
presenter_ = new WMLDocInformationPresenter(
|
||||
editor.getSite( ).getShell( ),
|
||||
new WMLDocTag(
|
||||
editedFile,
|
||||
installName,
|
||||
( ( WMLTag ) grammarElement )
|
||||
.getName( ) ),
|
||||
positionAbsolute );
|
||||
presenter_.create( );
|
||||
}
|
||||
presenter_.open( );
|
||||
}
|
||||
presenter_.open();
|
||||
}
|
||||
}
|
||||
else if ( grammarElement instanceof WMLTag)
|
||||
{
|
||||
if (presenter_ == null)
|
||||
{
|
||||
presenter_ = new WMLDocInformationPresenter(
|
||||
editor.getSite().getShell(),
|
||||
new WMLDocTag( editedFile, installName,
|
||||
( ( WMLTag ) grammarElement ).getName() ),
|
||||
positionAbsolute);
|
||||
presenter_.create();
|
||||
}
|
||||
presenter_.open();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception e) {
|
||||
Logger.getInstance().logException(e);
|
||||
} );
|
||||
} catch( Exception e ) {
|
||||
Logger.getInstance( ).logException( e );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -20,58 +20,60 @@ import org.eclipse.swt.widgets.Shell;
|
|||
|
||||
public class WMLDocInformationPresenter extends PopupDialog
|
||||
{
|
||||
private Point bounds_;
|
||||
private IWMLDocProvider currentDocProvider_;
|
||||
private Composite panel_;
|
||||
private Point bounds_;
|
||||
private IWMLDocProvider currentDocProvider_;
|
||||
private Composite panel_;
|
||||
|
||||
/**
|
||||
* Creates a new WMLDocumentation information presenter
|
||||
*/
|
||||
public WMLDocInformationPresenter(Shell parent, IWMLDocProvider docProvider,
|
||||
Point bounds)
|
||||
{
|
||||
super(parent, PopupDialog.INFOPOPUPRESIZE_SHELLSTYLE, true, true, true,
|
||||
false, false, docProvider.getTitle( ),
|
||||
docProvider.getInfoText( ) );
|
||||
/**
|
||||
* Creates a new WMLDocumentation information presenter
|
||||
*/
|
||||
public WMLDocInformationPresenter( Shell parent,
|
||||
IWMLDocProvider docProvider, Point bounds )
|
||||
{
|
||||
super( parent, PopupDialog.INFOPOPUPRESIZE_SHELLSTYLE, true, true,
|
||||
true, false, false, docProvider.getTitle( ), docProvider
|
||||
.getInfoText( ) );
|
||||
|
||||
bounds_ = bounds;
|
||||
currentDocProvider_ = docProvider;
|
||||
}
|
||||
bounds_ = bounds;
|
||||
currentDocProvider_ = docProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Control createDialogArea(Composite parent)
|
||||
{
|
||||
panel_ = new Composite(parent, SWT.None);
|
||||
panel_.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
|
||||
panel_.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
|
||||
@Override
|
||||
protected Control createDialogArea( Composite parent )
|
||||
{
|
||||
panel_ = new Composite( parent, SWT.None );
|
||||
panel_.setBackground( parent.getDisplay( ).getSystemColor(
|
||||
SWT.COLOR_INFO_BACKGROUND ) );
|
||||
panel_.setForeground( parent.getDisplay( ).getSystemColor(
|
||||
SWT.COLOR_INFO_FOREGROUND ) );
|
||||
|
||||
GridLayout grid = new GridLayout();
|
||||
grid.numColumns = 5;
|
||||
panel_.setLayout(grid);
|
||||
GridLayout grid = new GridLayout( );
|
||||
grid.numColumns = 5;
|
||||
panel_.setLayout( grid );
|
||||
|
||||
StyledText text = new StyledText(panel_, SWT.NONE);
|
||||
StyledText text = new StyledText( panel_, SWT.NONE );
|
||||
|
||||
text.setText(currentDocProvider_.getContents());
|
||||
text.setEditable(false);
|
||||
text.setStyleRanges(currentDocProvider_.getStyleRanges());
|
||||
text.setText( currentDocProvider_.getContents( ) );
|
||||
text.setEditable( false );
|
||||
text.setStyleRanges( currentDocProvider_.getStyleRanges( ) );
|
||||
|
||||
text.setLayoutData(createDefaultGridData(4));
|
||||
return panel_;
|
||||
}
|
||||
text.setLayoutData( createDefaultGridData( 4 ) );
|
||||
return panel_;
|
||||
}
|
||||
|
||||
private GridData createDefaultGridData(int columnspan) {
|
||||
GridData gd = new GridData();
|
||||
gd.horizontalSpan = columnspan;
|
||||
gd.verticalAlignment = SWT.BEGINNING;
|
||||
gd.verticalIndent = 0;
|
||||
gd.horizontalIndent = 5;
|
||||
return gd;
|
||||
}
|
||||
private GridData createDefaultGridData( int columnspan )
|
||||
{
|
||||
GridData gd = new GridData( );
|
||||
gd.horizontalSpan = columnspan;
|
||||
gd.verticalAlignment = SWT.BEGINNING;
|
||||
gd.verticalIndent = 0;
|
||||
gd.horizontalIndent = 5;
|
||||
return gd;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Point getInitialLocation(Point initialSize)
|
||||
{
|
||||
return bounds_;
|
||||
}
|
||||
@Override
|
||||
protected Point getInitialLocation( Point initialSize )
|
||||
{
|
||||
return bounds_;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,113 +11,114 @@ package org.wesnoth.ui.labeling.wmldoc;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.wesnoth.preprocessor.Define;
|
||||
import org.wesnoth.ui.Messages;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.StyleRange;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
|
||||
import org.wesnoth.preprocessor.Define;
|
||||
import org.wesnoth.ui.Messages;
|
||||
|
||||
|
||||
/**
|
||||
* Provides WMLDoc info for a macro
|
||||
*/
|
||||
public class WMLDocMacro implements IWMLDocProvider
|
||||
{
|
||||
private Define macro_;
|
||||
private String title_;
|
||||
private String contents_;
|
||||
private List<StyleRange> styleRanges_;
|
||||
private boolean docGenerated_;
|
||||
private Define macro_;
|
||||
private String title_;
|
||||
private String contents_;
|
||||
private List< StyleRange > styleRanges_;
|
||||
private boolean docGenerated_;
|
||||
|
||||
public WMLDocMacro(Define macro)
|
||||
{
|
||||
macro_ = macro;
|
||||
docGenerated_ = false;
|
||||
}
|
||||
public WMLDocMacro( Define macro )
|
||||
{
|
||||
macro_ = macro;
|
||||
docGenerated_ = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* A method used for lazly generating the documentation
|
||||
*/
|
||||
private void generateDoc()
|
||||
{
|
||||
if ( docGenerated_ )
|
||||
return;
|
||||
/**
|
||||
* A method used for lazly generating the documentation
|
||||
*/
|
||||
private void generateDoc( )
|
||||
{
|
||||
if( docGenerated_ )
|
||||
return;
|
||||
|
||||
styleRanges_ = new ArrayList<StyleRange>();
|
||||
title_ = Messages.WMLDocMacro_0 + macro_.getName();
|
||||
StringBuilder content = new StringBuilder();
|
||||
styleRanges_ = new ArrayList< StyleRange >( );
|
||||
title_ = Messages.WMLDocMacro_0 + macro_.getName( );
|
||||
StringBuilder content = new StringBuilder( );
|
||||
|
||||
content.append(Messages.WMLDocMacro_1);
|
||||
addStyleRange(0, content.length() - 1, SWT.BOLD);
|
||||
content.append(macro_.getValue());
|
||||
content.append( Messages.WMLDocMacro_1 );
|
||||
addStyleRange( 0, content.length( ) - 1, SWT.BOLD );
|
||||
content.append( macro_.getValue( ) );
|
||||
|
||||
content.append('\n');
|
||||
if (macro_.getArguments().isEmpty() == false)
|
||||
{
|
||||
int len = content.length() - 1;
|
||||
content.append(Messages.WMLDocMacro_2);
|
||||
content.append( '\n' );
|
||||
if( macro_.getArguments( ).isEmpty( ) == false ) {
|
||||
int len = content.length( ) - 1;
|
||||
content.append( Messages.WMLDocMacro_2 );
|
||||
|
||||
addStyleRange(len, content.length() - len - 1, SWT.BOLD);
|
||||
addStyleRange( len, content.length( ) - len - 1, SWT.BOLD );
|
||||
|
||||
len = content.length() - 1;
|
||||
for(String arg : macro_.getArguments())
|
||||
{
|
||||
content.append('\t' + arg + '\n');
|
||||
}
|
||||
addStyleRange(len, content.length() - len - 1, SWT.ITALIC);
|
||||
}
|
||||
len = content.length( ) - 1;
|
||||
for( String arg: macro_.getArguments( ) ) {
|
||||
content.append( '\t' + arg + '\n' );
|
||||
}
|
||||
addStyleRange( len, content.length( ) - len - 1, SWT.ITALIC );
|
||||
}
|
||||
|
||||
contents_ = content.toString();
|
||||
contents_ = content.toString( );
|
||||
|
||||
docGenerated_ = true;
|
||||
}
|
||||
docGenerated_ = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a style range to current list
|
||||
* @param offset
|
||||
* @param length
|
||||
* @param style
|
||||
*/
|
||||
private void addStyleRange(int offset, int length, int style)
|
||||
{
|
||||
styleRanges_.add(new StyleRange(offset, length,
|
||||
Display.getDefault().getSystemColor(SWT.COLOR_INFO_FOREGROUND),
|
||||
Display.getDefault().getSystemColor(SWT.COLOR_INFO_BACKGROUND),
|
||||
style));
|
||||
}
|
||||
/**
|
||||
* Adds a style range to current list
|
||||
*
|
||||
* @param offset
|
||||
* @param length
|
||||
* @param style
|
||||
*/
|
||||
private void addStyleRange( int offset, int length, int style )
|
||||
{
|
||||
styleRanges_.add( new StyleRange( offset, length, Display.getDefault( )
|
||||
.getSystemColor( SWT.COLOR_INFO_FOREGROUND ), Display
|
||||
.getDefault( ).getSystemColor( SWT.COLOR_INFO_BACKGROUND ),
|
||||
style ) );
|
||||
}
|
||||
|
||||
public String getTitle()
|
||||
{
|
||||
generateDoc();
|
||||
return title_;
|
||||
}
|
||||
public String getTitle( )
|
||||
{
|
||||
generateDoc( );
|
||||
return title_;
|
||||
}
|
||||
|
||||
public String getContents()
|
||||
{
|
||||
generateDoc();
|
||||
return contents_;
|
||||
}
|
||||
public String getContents( )
|
||||
{
|
||||
generateDoc( );
|
||||
return contents_;
|
||||
}
|
||||
|
||||
public StyleRange[] getStyleRanges()
|
||||
{
|
||||
generateDoc();
|
||||
return styleRanges_.toArray(new StyleRange[styleRanges_.size()]);
|
||||
}
|
||||
public StyleRange[] getStyleRanges( )
|
||||
{
|
||||
generateDoc( );
|
||||
return styleRanges_.toArray( new StyleRange[styleRanges_.size( )] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the associated macro
|
||||
* @return
|
||||
*/
|
||||
public Define getMacro()
|
||||
{
|
||||
return macro_;
|
||||
}
|
||||
/**
|
||||
* Gets the associated macro
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Define getMacro( )
|
||||
{
|
||||
return macro_;
|
||||
}
|
||||
|
||||
public String getInfoText()
|
||||
{
|
||||
if ( macro_.getLocation( ) == null )
|
||||
return null;
|
||||
return "Defined in: " + macro_.getLocation( ) + " : " + macro_.getLineNum( );
|
||||
}
|
||||
public String getInfoText( )
|
||||
{
|
||||
if( macro_.getLocation( ) == null )
|
||||
return null;
|
||||
return "Defined in: " + macro_.getLocation( ) + " : "
|
||||
+ macro_.getLineNum( );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,41 +11,41 @@ package org.wesnoth.ui.labeling.wmldoc;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.StyleRange;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
|
||||
import org.wesnoth.projects.ProjectUtils;
|
||||
import org.wesnoth.schema.SchemaParser;
|
||||
import org.wesnoth.ui.Messages;
|
||||
import org.wesnoth.wml.WMLTag;
|
||||
import org.wesnoth.wml.WmlFactory2;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.StyleRange;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
|
||||
/**
|
||||
* Displays wml doc for a tag [tag] or [/tag]
|
||||
*/
|
||||
public class WMLDocTag implements IWMLDocProvider
|
||||
{
|
||||
private WMLTag tag_;
|
||||
private String title_;
|
||||
private String contents_;
|
||||
private List<StyleRange> styleRanges_;
|
||||
private WMLTag tag_;
|
||||
private String title_;
|
||||
private String contents_;
|
||||
private List< StyleRange > styleRanges_;
|
||||
|
||||
private boolean docGenerated_;
|
||||
private boolean docGenerated_;
|
||||
|
||||
public WMLDocTag( IFile currentFile, String installName, String name )
|
||||
{
|
||||
tag_ = SchemaParser.getInstance( installName ).getTags( ).get( name );
|
||||
|
||||
// try to get it from the Project Cache ( lua parsed ones )
|
||||
if ( tag_ == null ) {
|
||||
tag_ = ProjectUtils.getCacheForProject( currentFile.getProject( ) ).
|
||||
getWMLTags( ).get( name );
|
||||
if( tag_ == null ) {
|
||||
tag_ = ProjectUtils.getCacheForProject( currentFile.getProject( ) )
|
||||
.getWMLTags( ).get( name );
|
||||
}
|
||||
|
||||
// Create a default one
|
||||
if ( tag_ == null ) {
|
||||
if( tag_ == null ) {
|
||||
tag_ = WmlFactory2.eINSTANCE.createWMLTag( name );
|
||||
}
|
||||
|
||||
|
@ -55,18 +55,18 @@ public class WMLDocTag implements IWMLDocProvider
|
|||
/**
|
||||
* A method used for lazly generating the documentation
|
||||
*/
|
||||
private void generateDoc()
|
||||
private void generateDoc( )
|
||||
{
|
||||
if ( docGenerated_ )
|
||||
if( docGenerated_ )
|
||||
return;
|
||||
|
||||
styleRanges_ = new ArrayList<StyleRange>( );
|
||||
styleRanges_ = new ArrayList< StyleRange >( );
|
||||
|
||||
title_ = Messages.WMLDocTag_0 + tag_.getName( ) + "':"; //$NON-NLS-1$
|
||||
|
||||
contents_ = null;
|
||||
|
||||
if ( !tag_.get_Description( ).isEmpty( ) ) {
|
||||
if( ! tag_.get_Description( ).isEmpty( ) ) {
|
||||
StringBuilder content = new StringBuilder( );
|
||||
content.append( Messages.WMLDocTag_1 );
|
||||
addStyleRange( 0, content.length( ) - 1, SWT.BOLD );
|
||||
|
@ -79,42 +79,45 @@ public class WMLDocTag implements IWMLDocProvider
|
|||
|
||||
/**
|
||||
* Adds a style range to current list
|
||||
*
|
||||
*
|
||||
* @param offset
|
||||
* @param length
|
||||
* @param style
|
||||
*/
|
||||
private void addStyleRange( int offset, int length, int style )
|
||||
{
|
||||
styleRanges_.add( new StyleRange( offset, length, Display.getDefault( ).getSystemColor( SWT.COLOR_INFO_FOREGROUND ), Display.getDefault( ).getSystemColor( SWT.COLOR_INFO_BACKGROUND ), style ) );
|
||||
styleRanges_.add( new StyleRange( offset, length, Display.getDefault( )
|
||||
.getSystemColor( SWT.COLOR_INFO_FOREGROUND ), Display
|
||||
.getDefault( ).getSystemColor( SWT.COLOR_INFO_BACKGROUND ),
|
||||
style ) );
|
||||
}
|
||||
|
||||
public String getTitle()
|
||||
public String getTitle( )
|
||||
{
|
||||
generateDoc( );
|
||||
return title_;
|
||||
}
|
||||
|
||||
public String getInfoText()
|
||||
{
|
||||
public String getInfoText( )
|
||||
{
|
||||
String infoText = "";
|
||||
if ( tag_.is_LuaBased( ) )
|
||||
infoText += "[Lua tag] ";
|
||||
if( tag_.is_LuaBased( ) )
|
||||
infoText += "[Lua tag] ";
|
||||
|
||||
if ( ! tag_.get_DefinitionLocation( ).isEmpty( ) ) {
|
||||
infoText += "Defined in: " + tag_.get_DefinitionLocation( );
|
||||
infoText += " : " + tag_.get_DefinitionOffset( );
|
||||
}
|
||||
return infoText.isEmpty( ) ? null : infoText;
|
||||
}
|
||||
if( ! tag_.get_DefinitionLocation( ).isEmpty( ) ) {
|
||||
infoText += "Defined in: " + tag_.get_DefinitionLocation( );
|
||||
infoText += " : " + tag_.get_DefinitionOffset( );
|
||||
}
|
||||
return infoText.isEmpty( ) ? null: infoText;
|
||||
}
|
||||
|
||||
public String getContents()
|
||||
public String getContents( )
|
||||
{
|
||||
generateDoc( );
|
||||
return contents_;
|
||||
}
|
||||
|
||||
public StyleRange[] getStyleRanges()
|
||||
public StyleRange[] getStyleRanges( )
|
||||
{
|
||||
generateDoc( );
|
||||
return styleRanges_.toArray( new StyleRange[styleRanges_.size( )] );
|
||||
|
|
|
@ -13,6 +13,7 @@ import org.eclipse.jface.text.IDocument;
|
|||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.texteditor.ITextEditor;
|
||||
import org.eclipse.xtext.ui.editor.hyperlinking.XtextHyperlink;
|
||||
|
||||
import org.wesnoth.utils.EditorUtils;
|
||||
|
||||
|
||||
|
@ -22,46 +23,46 @@ import org.wesnoth.utils.EditorUtils;
|
|||
*/
|
||||
public class FileLocationOpenerHyperlink extends XtextHyperlink
|
||||
{
|
||||
private String filePath_;
|
||||
private int linenum_;
|
||||
private String filePath_;
|
||||
private int linenum_;
|
||||
|
||||
@Override
|
||||
public void open()
|
||||
{
|
||||
IEditorPart part = EditorUtils.openEditor(filePath_);
|
||||
if (part != null)
|
||||
{
|
||||
@Override
|
||||
public void open( )
|
||||
{
|
||||
IEditorPart part = EditorUtils.openEditor( filePath_ );
|
||||
if( part != null ) {
|
||||
|
||||
ITextEditor editor = EditorUtils.getTextEditor(part);
|
||||
IDocument doc = editor.getDocumentProvider().
|
||||
getDocument(editor.getEditorInput());
|
||||
int offset = 0;
|
||||
try
|
||||
{
|
||||
// compute offset based on linenum_
|
||||
offset = doc.getLineOffset(linenum_);
|
||||
}
|
||||
catch (BadLocationException e) {
|
||||
//ignore
|
||||
}
|
||||
EditorUtils.getTextEditor(part).selectAndReveal(offset, 0);
|
||||
}
|
||||
}
|
||||
ITextEditor editor = EditorUtils.getTextEditor( part );
|
||||
IDocument doc = editor.getDocumentProvider( ).getDocument(
|
||||
editor.getEditorInput( ) );
|
||||
int offset = 0;
|
||||
try {
|
||||
// compute offset based on linenum_
|
||||
offset = doc.getLineOffset( linenum_ );
|
||||
} catch( BadLocationException e ) {
|
||||
// ignore
|
||||
}
|
||||
EditorUtils.getTextEditor( part ).selectAndReveal( offset, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
public void setLinenumber(int linenum)
|
||||
{
|
||||
linenum_ = linenum;
|
||||
}
|
||||
public int getLinenumber()
|
||||
{
|
||||
return linenum_;
|
||||
}
|
||||
public void setFilePath(String filePath)
|
||||
{
|
||||
filePath_ = filePath;
|
||||
}
|
||||
public String getFilePath()
|
||||
{
|
||||
return filePath_;
|
||||
}
|
||||
public void setLinenumber( int linenum )
|
||||
{
|
||||
linenum_ = linenum;
|
||||
}
|
||||
|
||||
public int getLinenumber( )
|
||||
{
|
||||
return linenum_;
|
||||
}
|
||||
|
||||
public void setFilePath( String filePath )
|
||||
{
|
||||
filePath_ = filePath;
|
||||
}
|
||||
|
||||
public String getFilePath( )
|
||||
{
|
||||
return filePath_;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import java.io.IOException;
|
|||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.xtext.ui.editor.hyperlinking.XtextHyperlink;
|
||||
|
||||
import org.wesnoth.Logger;
|
||||
import org.wesnoth.templates.TemplateProvider;
|
||||
import org.wesnoth.utils.GUIUtils;
|
||||
|
@ -22,40 +23,40 @@ import org.wesnoth.utils.GameUtils;
|
|||
|
||||
public class MapOpenerHyperlink extends XtextHyperlink
|
||||
{
|
||||
private String location_;
|
||||
private String location_;
|
||||
|
||||
public void setLocation(String location)
|
||||
{
|
||||
location_ = location;
|
||||
}
|
||||
public void setLocation( String location )
|
||||
{
|
||||
location_ = location;
|
||||
}
|
||||
|
||||
public String getLocation()
|
||||
{
|
||||
return location_;
|
||||
}
|
||||
public String getLocation( )
|
||||
{
|
||||
return location_;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open()
|
||||
{
|
||||
if ( !new File(location_).exists() )
|
||||
{
|
||||
if ( GUIUtils.showMessageBox(
|
||||
"The map doesn't exist. Do you want to create a default one and open that?",
|
||||
SWT.YES | SWT.NO ) == SWT.NO )
|
||||
return;
|
||||
@Override
|
||||
public void open( )
|
||||
{
|
||||
if( ! new File( location_ ).exists( ) ) {
|
||||
if( GUIUtils
|
||||
.showMessageBox(
|
||||
"The map doesn't exist. Do you want to create a default one and open that?",
|
||||
SWT.YES | SWT.NO ) == SWT.NO )
|
||||
return;
|
||||
|
||||
// go ahead, create the map
|
||||
FileWriter writer;
|
||||
// go ahead, create the map
|
||||
FileWriter writer;
|
||||
try {
|
||||
writer = new FileWriter( location_ );
|
||||
writer.write( TemplateProvider.getInstance( ).getTemplate( "map" ) );
|
||||
writer.write( TemplateProvider.getInstance( ).getTemplate(
|
||||
"map" ) );
|
||||
writer.close( );
|
||||
}
|
||||
catch ( IOException e ) {
|
||||
} catch( IOException e ) {
|
||||
Logger.getInstance( ).logException( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GameUtils.startEditor(location_);
|
||||
}
|
||||
GameUtils.startEditor( location_ );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,15 @@
|
|||
*******************************************************************************/
|
||||
package org.wesnoth.ui.navigation;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.emf.ecore.EObject;
|
||||
import org.eclipse.jface.text.Region;
|
||||
import org.eclipse.xtext.nodemodel.ICompositeNode;
|
||||
import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
|
||||
import org.eclipse.xtext.resource.XtextResource;
|
||||
import org.eclipse.xtext.ui.editor.hyperlinking.HyperlinkHelper;
|
||||
import org.eclipse.xtext.ui.editor.hyperlinking.IHyperlinkAcceptor;
|
||||
|
||||
import org.wesnoth.Logger;
|
||||
import org.wesnoth.installs.WesnothInstallsUtils;
|
||||
import org.wesnoth.preferences.Preferences;
|
||||
|
@ -19,35 +28,28 @@ import org.wesnoth.utils.WMLUtils;
|
|||
import org.wesnoth.wml.WMLKey;
|
||||
import org.wesnoth.wml.WMLMacroCall;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.emf.ecore.EObject;
|
||||
import org.eclipse.jface.text.Region;
|
||||
import org.eclipse.xtext.nodemodel.ICompositeNode;
|
||||
import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
|
||||
import org.eclipse.xtext.resource.XtextResource;
|
||||
import org.eclipse.xtext.ui.editor.hyperlinking.HyperlinkHelper;
|
||||
import org.eclipse.xtext.ui.editor.hyperlinking.IHyperlinkAcceptor;
|
||||
|
||||
public class WMLHyperlinkHelper extends HyperlinkHelper
|
||||
{
|
||||
@Override
|
||||
public void createHyperlinksByOffset(XtextResource resource, int offset,
|
||||
IHyperlinkAcceptor acceptor)
|
||||
public void createHyperlinksByOffset( XtextResource resource, int offset,
|
||||
IHyperlinkAcceptor acceptor )
|
||||
{
|
||||
super.createHyperlinksByOffset(resource, offset, acceptor);
|
||||
super.createHyperlinksByOffset( resource, offset, acceptor );
|
||||
|
||||
EObject object = WMLUtils.resolveElementAt( resource, offset );
|
||||
|
||||
if ( object == null )
|
||||
if( object == null )
|
||||
return;
|
||||
|
||||
IFile file = WMLEditor.getActiveEditorFile();
|
||||
if ( file == null ){
|
||||
Logger.getInstance().logError( "FATAL! file is null (and it shouldn't) ");
|
||||
IFile file = WMLEditor.getActiveEditorFile( );
|
||||
if( file == null ) {
|
||||
Logger.getInstance( ).logError(
|
||||
"FATAL! file is null (and it shouldn't) " );
|
||||
return;
|
||||
}
|
||||
|
||||
Paths paths = Preferences.getPaths( WesnothInstallsUtils.getInstallNameForResource( file ) );
|
||||
Paths paths = Preferences.getPaths( WesnothInstallsUtils
|
||||
.getInstallNameForResource( file ) );
|
||||
|
||||
ICompositeNode node = NodeModelUtils.getNode( object );
|
||||
|
||||
|
@ -57,99 +59,115 @@ public class WMLHyperlinkHelper extends HyperlinkHelper
|
|||
|
||||
/**
|
||||
* Creates a hyperlink for opening the macro definition
|
||||
* @param paths The paths variable for the current install
|
||||
* @param file The current edited file
|
||||
* @param object The current object
|
||||
* @param acceptor The hyperlink acceptor
|
||||
* @param node The node model representation of the macro
|
||||
*
|
||||
* @param paths
|
||||
* The paths variable for the current install
|
||||
* @param file
|
||||
* The current edited file
|
||||
* @param object
|
||||
* The current object
|
||||
* @param acceptor
|
||||
* The hyperlink acceptor
|
||||
* @param node
|
||||
* The node model representation of the macro
|
||||
*/
|
||||
private void createMacroHyperlink( Paths paths, IFile file, EObject object,
|
||||
IHyperlinkAcceptor acceptor, ICompositeNode node )
|
||||
{
|
||||
if ( object instanceof WMLMacroCall == false )
|
||||
if( object instanceof WMLMacroCall == false )
|
||||
return;
|
||||
|
||||
WMLMacroCall macro = ( WMLMacroCall ) object;
|
||||
|
||||
// get the define for the macro
|
||||
Define define = ProjectUtils.getCacheForProject(
|
||||
file.getProject() ).getDefines().get( macro.getName() );
|
||||
if ( define == null ||
|
||||
define.getLocation( ).length( ) <= 2 )
|
||||
Define define = ProjectUtils.getCacheForProject( file.getProject( ) )
|
||||
.getDefines( ).get( macro.getName( ) );
|
||||
if( define == null || define.getLocation( ).length( ) <= 2 )
|
||||
return;
|
||||
|
||||
String filePath = define.getLocation();
|
||||
String filePath = define.getLocation( );
|
||||
|
||||
if ( filePath.charAt( 0 ) == '~' ) {
|
||||
if( filePath.charAt( 0 ) == '~' ) {
|
||||
// expand the '~' character to user data dir
|
||||
filePath = filePath.replaceFirst( "~", paths.getUserDataDir( ) );
|
||||
} else if ( filePath.startsWith( "core/" ) ) {
|
||||
}
|
||||
else if( filePath.startsWith( "core/" ) ) {
|
||||
// expand the data/core path
|
||||
filePath = filePath.replaceFirst( "core/", paths.getCoreDir( ) );
|
||||
}
|
||||
|
||||
FileLocationOpenerHyperlink macroTarget = new FileLocationOpenerHyperlink();
|
||||
macroTarget.setHyperlinkRegion( new Region( node.getOffset( ), node.getLength( ) ) );
|
||||
macroTarget.setFilePath(filePath);
|
||||
macroTarget.setLinenumber(define.getLineNum());
|
||||
acceptor.accept(macroTarget);
|
||||
FileLocationOpenerHyperlink macroTarget = new FileLocationOpenerHyperlink( );
|
||||
macroTarget.setHyperlinkRegion( new Region( node.getOffset( ), node
|
||||
.getLength( ) ) );
|
||||
macroTarget.setFilePath( filePath );
|
||||
macroTarget.setLinenumber( define.getLineNum( ) );
|
||||
acceptor.accept( macroTarget );
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a hyperlink for opening the map ( if applying )
|
||||
* @param paths The paths variable for the current install
|
||||
* @param object The current object
|
||||
* @param acceptor The hyperlink acceptor
|
||||
* @param node The node model representation of the macro
|
||||
*
|
||||
* @param paths
|
||||
* The paths variable for the current install
|
||||
* @param object
|
||||
* The current object
|
||||
* @param acceptor
|
||||
* The hyperlink acceptor
|
||||
* @param node
|
||||
* The node model representation of the macro
|
||||
*/
|
||||
private void createMapHyperlink( Paths paths, EObject object,
|
||||
IHyperlinkAcceptor acceptor, ICompositeNode node )
|
||||
{
|
||||
EObject container = object.eContainer( );
|
||||
|
||||
if ( !( container instanceof WMLKey ) ||
|
||||
!( ( WMLKey ) container ).getName( ).equals( "map_data" ) )
|
||||
if( ! ( container instanceof WMLKey )
|
||||
|| ! ( ( WMLKey ) container ).getName( ).equals( "map_data" ) )
|
||||
return;
|
||||
|
||||
String mapLocation = node.getText();
|
||||
String mapLocation = node.getText( );
|
||||
|
||||
// too few characters
|
||||
if ( mapLocation.length( ) <= 2 )
|
||||
if( mapLocation.length( ) <= 2 )
|
||||
return;
|
||||
|
||||
// trim the " and the { (if any exist)
|
||||
int indexStart = 0;
|
||||
int indexEnd = 0;
|
||||
|
||||
if ( mapLocation.charAt( 0 ) == '"' ) {
|
||||
if( mapLocation.charAt( 0 ) == '"' ) {
|
||||
indexStart = 1;
|
||||
|
||||
if ( mapLocation.charAt( 1 ) == '{' ){
|
||||
if( mapLocation.charAt( 1 ) == '{' ) {
|
||||
indexStart = 2;
|
||||
}
|
||||
}
|
||||
|
||||
if ( mapLocation.charAt( mapLocation.length( ) - 1 ) == '"') {
|
||||
if( mapLocation.charAt( mapLocation.length( ) - 1 ) == '"' ) {
|
||||
indexEnd = mapLocation.length( ) - 1;
|
||||
|
||||
if ( mapLocation.charAt( mapLocation.length( ) - 2 ) == '}' ) {
|
||||
if( mapLocation.charAt( mapLocation.length( ) - 2 ) == '}' ) {
|
||||
indexEnd = mapLocation.length( ) - 2;
|
||||
}
|
||||
}
|
||||
|
||||
mapLocation = mapLocation.substring( indexStart, indexEnd );
|
||||
|
||||
if ( mapLocation.charAt( 0 ) == '~' ) {
|
||||
if( mapLocation.charAt( 0 ) == '~' ) {
|
||||
// expand the '~' character to user data dir
|
||||
mapLocation = mapLocation.replaceFirst( "~", paths.getUserDataDir( ) );
|
||||
} else if ( mapLocation.startsWith( "campaigns/" ) ) {
|
||||
mapLocation = mapLocation
|
||||
.replaceFirst( "~", paths.getUserDataDir( ) );
|
||||
}
|
||||
else if( mapLocation.startsWith( "campaigns/" ) ) {
|
||||
// expand the campaigns path
|
||||
mapLocation = mapLocation.replaceFirst( "campaigns/", paths.getCampaignDir( ) );
|
||||
mapLocation = mapLocation.replaceFirst( "campaigns/",
|
||||
paths.getCampaignDir( ) );
|
||||
}
|
||||
|
||||
MapOpenerHyperlink hyperlink = new MapOpenerHyperlink();
|
||||
hyperlink.setHyperlinkRegion( new Region(node.getOffset( ), node.getLength( ) ) );
|
||||
hyperlink.setLocation(mapLocation);
|
||||
acceptor.accept(hyperlink);
|
||||
MapOpenerHyperlink hyperlink = new MapOpenerHyperlink( );
|
||||
hyperlink.setHyperlinkRegion( new Region( node.getOffset( ), node
|
||||
.getLength( ) ) );
|
||||
hyperlink.setLocation( mapLocation );
|
||||
acceptor.accept( hyperlink );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,23 +1,24 @@
|
|||
/*
|
||||
* generated by Xtext
|
||||
*/
|
||||
* generated by Xtext
|
||||
*/
|
||||
package org.wesnoth.ui.outline;
|
||||
|
||||
import org.wesnoth.wml.WMLRoot;
|
||||
|
||||
import org.eclipse.xtext.ui.editor.outline.impl.DefaultOutlineTreeProvider;
|
||||
|
||||
import org.wesnoth.wml.WMLRoot;
|
||||
|
||||
/**
|
||||
* customization of the default outline structure
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class WMLOutlineTreeProvider extends DefaultOutlineTreeProvider {
|
||||
@Override
|
||||
protected Object _text( Object modelElement )
|
||||
{
|
||||
if ( modelElement instanceof WMLRoot ) {
|
||||
return "Root";
|
||||
}
|
||||
return super._text( modelElement );
|
||||
}
|
||||
public class WMLOutlineTreeProvider extends DefaultOutlineTreeProvider
|
||||
{
|
||||
@Override
|
||||
protected Object _text( Object modelElement )
|
||||
{
|
||||
if( modelElement instanceof WMLRoot ) {
|
||||
return "Root";
|
||||
}
|
||||
return super._text( modelElement );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,17 +10,21 @@ package org.wesnoth.ui.quickfix;
|
|||
|
||||
import org.eclipse.xtext.ui.editor.quickfix.DefaultQuickfixProvider;
|
||||
|
||||
public class WMLQuickfixProvider extends DefaultQuickfixProvider {
|
||||
public class WMLQuickfixProvider extends DefaultQuickfixProvider
|
||||
{
|
||||
|
||||
// @Fix(MyJavaValidator.INVALID_NAME)
|
||||
// public void capitalizeName(final Issue issue, IssueResolutionAcceptor acceptor) {
|
||||
// acceptor.accept(issue, "Capitalize name", "Capitalize the name.", "upcase.png", new IModification() {
|
||||
// public void apply(IModificationContext context) throws BadLocationException {
|
||||
// IXtextDocument xtextDocument = context.getXtextDocument();
|
||||
// String firstLetter = xtextDocument.get(issue.getOffset(), 1);
|
||||
// xtextDocument.replace(issue.getOffset(), 1, firstLetter.toUpperCase());
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// @Fix(MyJavaValidator.INVALID_NAME)
|
||||
// public void capitalizeName(final Issue issue, IssueResolutionAcceptor
|
||||
// acceptor) {
|
||||
// acceptor.accept(issue, "Capitalize name", "Capitalize the name.",
|
||||
// "upcase.png", new IModification() {
|
||||
// public void apply(IModificationContext context) throws
|
||||
// BadLocationException {
|
||||
// IXtextDocument xtextDocument = context.getXtextDocument();
|
||||
// String firstLetter = xtextDocument.get(issue.getOffset(), 1);
|
||||
// xtextDocument.replace(issue.getOffset(), 1, firstLetter.toUpperCase());
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
@ -15,15 +15,15 @@ import org.eclipse.xtext.resource.DefaultLocationInFileProvider;
|
|||
|
||||
public class WMLLocationInFileProvider extends DefaultLocationInFileProvider
|
||||
{
|
||||
@Override
|
||||
protected boolean useKeyword(Keyword keyword, EObject context)
|
||||
{
|
||||
return super.useKeyword(keyword, context);
|
||||
}
|
||||
@Override
|
||||
protected boolean useKeyword( Keyword keyword, EObject context )
|
||||
{
|
||||
return super.useKeyword( keyword, context );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EStructuralFeature getIdentifierFeature(EObject obj)
|
||||
{
|
||||
return super.getIdentifierFeature(obj);
|
||||
}
|
||||
@Override
|
||||
protected EStructuralFeature getIdentifierFeature( EObject obj )
|
||||
{
|
||||
return super.getIdentifierFeature( obj );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,24 +10,22 @@ package org.wesnoth.ui.syntax;
|
|||
|
||||
import org.eclipse.xtext.ui.editor.syntaxcoloring.DefaultAntlrTokenToAttributeIdMapper;
|
||||
|
||||
public class WMLAntlrTokenToAttributeIdMapper extends DefaultAntlrTokenToAttributeIdMapper
|
||||
public class WMLAntlrTokenToAttributeIdMapper extends
|
||||
DefaultAntlrTokenToAttributeIdMapper
|
||||
{
|
||||
@Override
|
||||
protected String calculateId(String tokenName, int tokenType)
|
||||
protected String calculateId( String tokenName, int tokenType )
|
||||
{
|
||||
if ( tokenName.equals( "'+'" ) ||
|
||||
tokenName.equals("'['") ||
|
||||
tokenName.equals("'[/'") ||
|
||||
tokenName.equals("']'")) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
if( tokenName.equals( "'+'" ) || tokenName.equals( "'['" )
|
||||
|| tokenName.equals( "'[/'" ) || tokenName.equals( "']'" ) ) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
{
|
||||
return WMLHighlightingConfiguration.RULE_WML_TAG;
|
||||
}
|
||||
if ( tokenName.equals( "'~'" ) ||
|
||||
tokenName.equals("'{'") ||
|
||||
tokenName.equals("'}'") ) //$NON-NLS-1$ //$NON-NLS-2$
|
||||
if( tokenName.equals( "'~'" ) || tokenName.equals( "'{'" )
|
||||
|| tokenName.equals( "'}'" ) ) //$NON-NLS-1$ //$NON-NLS-2$
|
||||
{
|
||||
return WMLHighlightingConfiguration.RULE_WML_MACRO_CALL;
|
||||
}
|
||||
return super.calculateId(tokenName, tokenType);
|
||||
return super.calculateId( tokenName, tokenType );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,10 +10,6 @@ package org.wesnoth.ui.syntax;
|
|||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.wesnoth.ui.editor.WMLEditor;
|
||||
import org.wesnoth.utils.WMLUtils;
|
||||
import org.wesnoth.wml.WMLTag;
|
||||
|
||||
import org.eclipse.emf.common.notify.Adapter;
|
||||
import org.eclipse.emf.ecore.EObject;
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
|
@ -24,11 +20,15 @@ import org.eclipse.xtext.ui.editor.model.XtextDocument;
|
|||
import org.eclipse.xtext.ui.editor.utils.EditorUtils;
|
||||
import org.eclipse.xtext.util.concurrent.IUnitOfWork;
|
||||
|
||||
import org.wesnoth.ui.editor.WMLEditor;
|
||||
import org.wesnoth.utils.WMLUtils;
|
||||
import org.wesnoth.wml.WMLTag;
|
||||
|
||||
public class WMLCharacterPairMatcher extends DefaultCharacterPairMatcher
|
||||
{
|
||||
private WMLTag currentTag_;
|
||||
|
||||
private int matchCnt = 0;
|
||||
private int matchCnt = 0;
|
||||
|
||||
public WMLCharacterPairMatcher( char[] chars )
|
||||
{
|
||||
|
@ -39,63 +39,72 @@ public class WMLCharacterPairMatcher extends DefaultCharacterPairMatcher
|
|||
@Override
|
||||
public IRegion match( IDocument doc, final int offset )
|
||||
{
|
||||
++ matchCnt;
|
||||
++matchCnt;
|
||||
IRegion region = super.match( doc, offset );
|
||||
|
||||
if ( region == null && doc instanceof XtextDocument &&
|
||||
doc.getLength( ) > 0 ) {
|
||||
if ( matchCnt == 2 ) {
|
||||
if( region == null && doc instanceof XtextDocument
|
||||
&& doc.getLength( ) > 0 ) {
|
||||
if( matchCnt == 2 ) {
|
||||
matchCnt = 0;
|
||||
} else {
|
||||
( ( XtextDocument ) doc ).readOnly( new IUnitOfWork<Boolean, XtextResource>(){
|
||||
}
|
||||
else {
|
||||
( ( XtextDocument ) doc )
|
||||
.readOnly( new IUnitOfWork< Boolean, XtextResource >( ) {
|
||||
|
||||
@Override
|
||||
public Boolean exec( XtextResource state ) throws Exception
|
||||
{
|
||||
computeMatchingRegion( state, offset );
|
||||
return true;
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public Boolean exec( XtextResource state )
|
||||
throws Exception
|
||||
{
|
||||
computeMatchingRegion( state, offset );
|
||||
return true;
|
||||
}
|
||||
} );
|
||||
|
||||
// refresh the highlighting
|
||||
WMLEditor currentEditor = ( WMLEditor ) EditorUtils.getActiveXtextEditor( );
|
||||
if ( currentEditor != null &&
|
||||
currentEditor.getHighlightingHelper( ) != null &&
|
||||
currentEditor.getHighlightingHelper( ).getReconciler( ) != null )
|
||||
currentEditor.getHighlightingHelper( ).getReconciler( ).refresh( );
|
||||
WMLEditor currentEditor = ( WMLEditor ) EditorUtils
|
||||
.getActiveXtextEditor( );
|
||||
if( currentEditor != null
|
||||
&& currentEditor.getHighlightingHelper( ) != null
|
||||
&& currentEditor.getHighlightingHelper( )
|
||||
.getReconciler( ) != null )
|
||||
currentEditor.getHighlightingHelper( ).getReconciler( )
|
||||
.refresh( );
|
||||
}
|
||||
}
|
||||
|
||||
return region;
|
||||
}
|
||||
|
||||
public synchronized void computeMatchingRegion(XtextResource state, int offset)
|
||||
public synchronized void computeMatchingRegion( XtextResource state,
|
||||
int offset )
|
||||
{
|
||||
EObject object = WMLUtils.resolveElementAt( state, offset );
|
||||
|
||||
// do nothing if we clicked the same tag
|
||||
if ( currentTag_ == object )
|
||||
if( currentTag_ == object )
|
||||
return;
|
||||
|
||||
if ( object instanceof WMLTag ) {
|
||||
if( object instanceof WMLTag ) {
|
||||
WMLTag tag = ( WMLTag ) object;
|
||||
|
||||
currentTag_ = tag;
|
||||
for ( Adapter adapter : state.eAdapters( ) ) {
|
||||
if ( adapter instanceof WMLSyntaxColoringAdapter ){
|
||||
for( Adapter adapter: state.eAdapters( ) ) {
|
||||
if( adapter instanceof WMLSyntaxColoringAdapter ) {
|
||||
|
||||
( ( WMLSyntaxColoringAdapter ) adapter ).TargetEObject = object;
|
||||
return; // done here
|
||||
}
|
||||
}
|
||||
|
||||
state.eAdapters( ).add( new WMLSyntaxColoringAdapter(
|
||||
WMLHighlightingConfiguration.RULE_MATCH_TAG, object ) );
|
||||
} else {
|
||||
state.eAdapters( )
|
||||
.add( new WMLSyntaxColoringAdapter(
|
||||
WMLHighlightingConfiguration.RULE_MATCH_TAG, object ) );
|
||||
}
|
||||
else {
|
||||
// nothing new selected, just remove current adapter
|
||||
Iterator<Adapter> itor = state.eAdapters( ).iterator( );
|
||||
while ( itor.hasNext( ) ) {
|
||||
if ( itor.next( ) instanceof WMLSyntaxColoringAdapter ) {
|
||||
Iterator< Adapter > itor = state.eAdapters( ).iterator( );
|
||||
while( itor.hasNext( ) ) {
|
||||
if( itor.next( ) instanceof WMLSyntaxColoringAdapter ) {
|
||||
itor.remove( );
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -13,75 +13,83 @@ import org.eclipse.swt.graphics.RGB;
|
|||
import org.eclipse.xtext.ui.editor.syntaxcoloring.DefaultHighlightingConfiguration;
|
||||
import org.eclipse.xtext.ui.editor.syntaxcoloring.IHighlightingConfigurationAcceptor;
|
||||
import org.eclipse.xtext.ui.editor.utils.TextStyle;
|
||||
|
||||
import org.wesnoth.ui.Messages;
|
||||
|
||||
public class WMLHighlightingConfiguration extends DefaultHighlightingConfiguration
|
||||
public class WMLHighlightingConfiguration extends
|
||||
DefaultHighlightingConfiguration
|
||||
{
|
||||
public static final String RULE_WML_TAG = "wmlTag"; //$NON-NLS-1$
|
||||
public static final String RULE_WML_KEY = "wmlKey"; //$NON-NLS-1$
|
||||
public static final String RULE_WML_MACRO_CALL = "wmlMacroCall"; //$NON-NLS-1$
|
||||
public static final String RULE_WML_TAG = "wmlTag"; //$NON-NLS-1$
|
||||
public static final String RULE_WML_KEY = "wmlKey"; //$NON-NLS-1$
|
||||
public static final String RULE_WML_MACRO_CALL = "wmlMacroCall"; //$NON-NLS-1$
|
||||
|
||||
public static final String RULE_WML_MACRO_DEFINE = "wmlMacroDefine"; //$NON-NLS-1$
|
||||
public static final String RULE_WML_IF = "wmlIF"; //$NON-NLS-1$
|
||||
public static final String RULE_WML_TEXTDOMAIN = "wmlTextdomain"; //$NON-NLS-1$
|
||||
public static final String RULE_WML_MACRO_DEFINE = "wmlMacroDefine"; //$NON-NLS-1$
|
||||
public static final String RULE_WML_IF = "wmlIF"; //$NON-NLS-1$
|
||||
public static final String RULE_WML_TEXTDOMAIN = "wmlTextdomain"; //$NON-NLS-1$
|
||||
|
||||
public static final String RULE_MATCH_TAG = "wmlMatchTag"; //$NON-NLS-1$
|
||||
public static final String RULE_MATCH_TAG = "wmlMatchTag"; //$NON-NLS-1$
|
||||
|
||||
@Override
|
||||
public void configure(IHighlightingConfigurationAcceptor acceptor)
|
||||
{
|
||||
super.configure(acceptor);
|
||||
acceptor.acceptDefaultHighlighting(RULE_WML_TAG, Messages.WMLHighlightingConfiguration_7, tagTextStyle());
|
||||
acceptor.acceptDefaultHighlighting(RULE_WML_KEY, Messages.WMLHighlightingConfiguration_8, keyTextStyle());
|
||||
acceptor.acceptDefaultHighlighting(RULE_WML_MACRO_CALL, Messages.WMLHighlightingConfiguration_9, macroTextStyle());
|
||||
@Override
|
||||
public void configure( IHighlightingConfigurationAcceptor acceptor )
|
||||
{
|
||||
super.configure( acceptor );
|
||||
acceptor.acceptDefaultHighlighting( RULE_WML_TAG,
|
||||
Messages.WMLHighlightingConfiguration_7, tagTextStyle( ) );
|
||||
acceptor.acceptDefaultHighlighting( RULE_WML_KEY,
|
||||
Messages.WMLHighlightingConfiguration_8, keyTextStyle( ) );
|
||||
acceptor.acceptDefaultHighlighting( RULE_WML_MACRO_CALL,
|
||||
Messages.WMLHighlightingConfiguration_9, macroTextStyle( ) );
|
||||
|
||||
acceptor.acceptDefaultHighlighting(RULE_MATCH_TAG,
|
||||
Messages.WMLHighlightingConfiguration_10, startEndTextStyle());
|
||||
acceptor.acceptDefaultHighlighting( RULE_MATCH_TAG,
|
||||
Messages.WMLHighlightingConfiguration_10, startEndTextStyle( ) );
|
||||
|
||||
// preproc
|
||||
acceptor.acceptDefaultHighlighting(RULE_WML_MACRO_DEFINE, Messages.WMLHighlightingConfiguration_11, preprocTextStyle());
|
||||
acceptor.acceptDefaultHighlighting(RULE_WML_IF, Messages.WMLHighlightingConfiguration_12, preprocTextStyle());
|
||||
acceptor.acceptDefaultHighlighting(RULE_WML_TEXTDOMAIN, Messages.WMLHighlightingConfiguration_13, preprocTextStyle());
|
||||
}
|
||||
// preproc
|
||||
acceptor.acceptDefaultHighlighting( RULE_WML_MACRO_DEFINE,
|
||||
Messages.WMLHighlightingConfiguration_11, preprocTextStyle( ) );
|
||||
acceptor.acceptDefaultHighlighting( RULE_WML_IF,
|
||||
Messages.WMLHighlightingConfiguration_12, preprocTextStyle( ) );
|
||||
acceptor.acceptDefaultHighlighting( RULE_WML_TEXTDOMAIN,
|
||||
Messages.WMLHighlightingConfiguration_13, preprocTextStyle( ) );
|
||||
}
|
||||
|
||||
public TextStyle preprocTextStyle()
|
||||
{
|
||||
TextStyle textStyle = defaultTextStyle().copy();
|
||||
textStyle.setColor(new RGB(31, 209, 241));
|
||||
textStyle.setStyle(SWT.BOLD);
|
||||
return textStyle;
|
||||
}
|
||||
public TextStyle preprocTextStyle( )
|
||||
{
|
||||
TextStyle textStyle = defaultTextStyle( ).copy( );
|
||||
textStyle.setColor( new RGB( 31, 209, 241 ) );
|
||||
textStyle.setStyle( SWT.BOLD );
|
||||
return textStyle;
|
||||
}
|
||||
|
||||
public TextStyle macroTextStyle()
|
||||
{
|
||||
TextStyle textStyle = defaultTextStyle().copy();
|
||||
textStyle.setColor(new RGB(197, 137, 23));
|
||||
textStyle.setStyle(SWT.ITALIC);
|
||||
return textStyle;
|
||||
}
|
||||
public TextStyle macroTextStyle( )
|
||||
{
|
||||
TextStyle textStyle = defaultTextStyle( ).copy( );
|
||||
textStyle.setColor( new RGB( 197, 137, 23 ) );
|
||||
textStyle.setStyle( SWT.ITALIC );
|
||||
return textStyle;
|
||||
}
|
||||
|
||||
public TextStyle startEndTextStyle()
|
||||
{
|
||||
TextStyle textStyle = defaultTextStyle().copy();
|
||||
textStyle.setColor(new RGB(128, 128, 128));
|
||||
textStyle.setBackgroundColor(new RGB(128, 0, 0));
|
||||
textStyle.setStyle(SWT.BOLD | SWT.ITALIC);
|
||||
return textStyle;
|
||||
}
|
||||
public TextStyle startEndTextStyle( )
|
||||
{
|
||||
TextStyle textStyle = defaultTextStyle( ).copy( );
|
||||
textStyle.setColor( new RGB( 128, 128, 128 ) );
|
||||
textStyle.setBackgroundColor( new RGB( 128, 0, 0 ) );
|
||||
textStyle.setStyle( SWT.BOLD | SWT.ITALIC );
|
||||
return textStyle;
|
||||
}
|
||||
|
||||
public TextStyle tagTextStyle()
|
||||
{
|
||||
TextStyle textStyle = defaultTextStyle().copy();
|
||||
textStyle.setColor(new RGB(128, 0, 0));
|
||||
textStyle.setStyle(SWT.BOLD);
|
||||
return textStyle;
|
||||
}
|
||||
public TextStyle tagTextStyle( )
|
||||
{
|
||||
TextStyle textStyle = defaultTextStyle( ).copy( );
|
||||
textStyle.setColor( new RGB( 128, 0, 0 ) );
|
||||
textStyle.setStyle( SWT.BOLD );
|
||||
return textStyle;
|
||||
}
|
||||
|
||||
public TextStyle keyTextStyle()
|
||||
{
|
||||
TextStyle textStyle = defaultTextStyle().copy();
|
||||
textStyle.setColor(new RGB(0, 128, 128));
|
||||
textStyle.setStyle(SWT.BOLD);
|
||||
return textStyle;
|
||||
}
|
||||
public TextStyle keyTextStyle( )
|
||||
{
|
||||
TextStyle textStyle = defaultTextStyle( ).copy( );
|
||||
textStyle.setColor( new RGB( 0, 128, 128 ) );
|
||||
textStyle.setStyle( SWT.BOLD );
|
||||
return textStyle;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
|
|||
import org.eclipse.xtext.resource.XtextResource;
|
||||
import org.eclipse.xtext.ui.editor.syntaxcoloring.IHighlightedPositionAcceptor;
|
||||
import org.eclipse.xtext.ui.editor.syntaxcoloring.ISemanticHighlightingCalculator;
|
||||
|
||||
import org.wesnoth.utils.Pair;
|
||||
import org.wesnoth.wml.WMLKey;
|
||||
import org.wesnoth.wml.WMLMacroCall;
|
||||
|
@ -31,71 +32,85 @@ import org.wesnoth.wml.WMLTag;
|
|||
import org.wesnoth.wml.WMLTextdomain;
|
||||
import org.wesnoth.wml.WmlPackage;
|
||||
|
||||
public class WMLSemanticHighlightingCalculator implements ISemanticHighlightingCalculator
|
||||
public class WMLSemanticHighlightingCalculator implements
|
||||
ISemanticHighlightingCalculator
|
||||
{
|
||||
@Override
|
||||
public void provideHighlightingFor(XtextResource resource, IHighlightedPositionAcceptor acceptor)
|
||||
public void provideHighlightingFor( XtextResource resource,
|
||||
IHighlightedPositionAcceptor acceptor )
|
||||
{
|
||||
if (resource == null)
|
||||
if( resource == null )
|
||||
return;
|
||||
|
||||
Iterator<EObject> iter = EcoreUtil.getAllContents(resource, true);
|
||||
while (iter.hasNext()) {
|
||||
EObject current = iter.next();
|
||||
Iterator< EObject > iter = EcoreUtil.getAllContents( resource, true );
|
||||
while( iter.hasNext( ) ) {
|
||||
EObject current = iter.next( );
|
||||
|
||||
List< Pair< INode, String > > toColor = new ArrayList< Pair< INode,String > >();
|
||||
List< Pair< INode, String > > toColor = new ArrayList< Pair< INode, String > >( );
|
||||
|
||||
if (current instanceof WMLTag) {
|
||||
if( current instanceof WMLTag ) {
|
||||
toColor.add( Pair.create(
|
||||
getFirstFeatureNode( current, WmlPackage.Literals.WML_EXPRESSION__NAME ),
|
||||
getFirstFeatureNode( current,
|
||||
WmlPackage.Literals.WML_EXPRESSION__NAME ),
|
||||
WMLHighlightingConfiguration.RULE_WML_TAG ) );
|
||||
|
||||
toColor.add( Pair.create(
|
||||
getFirstFeatureNode( current, WmlPackage.Literals.WML_TAG__END_NAME ),
|
||||
getFirstFeatureNode( current,
|
||||
WmlPackage.Literals.WML_TAG__END_NAME ),
|
||||
WMLHighlightingConfiguration.RULE_WML_TAG ) );
|
||||
}
|
||||
else if (current instanceof WMLKey) {
|
||||
else if( current instanceof WMLKey ) {
|
||||
toColor.add( Pair.create(
|
||||
getFirstFeatureNode( current, WmlPackage.Literals.WML_EXPRESSION__NAME ),
|
||||
getFirstFeatureNode( current,
|
||||
WmlPackage.Literals.WML_EXPRESSION__NAME ),
|
||||
WMLHighlightingConfiguration.RULE_WML_KEY ) );
|
||||
}
|
||||
else if (current instanceof WMLMacroCall) {
|
||||
else if( current instanceof WMLMacroCall ) {
|
||||
toColor.add( Pair.create(
|
||||
getFirstFeatureNode( current, WmlPackage.Literals.WML_EXPRESSION__NAME ),
|
||||
getFirstFeatureNode( current,
|
||||
WmlPackage.Literals.WML_EXPRESSION__NAME ),
|
||||
WMLHighlightingConfiguration.RULE_WML_MACRO_CALL ) );
|
||||
}
|
||||
else if (current instanceof WMLTextdomain) {
|
||||
else if( current instanceof WMLTextdomain ) {
|
||||
toColor.add( Pair.create(
|
||||
getFirstFeatureNode( current, WmlPackage.Literals.WML_EXPRESSION__NAME ),
|
||||
getFirstFeatureNode( current,
|
||||
WmlPackage.Literals.WML_EXPRESSION__NAME ),
|
||||
WMLHighlightingConfiguration.RULE_WML_TEXTDOMAIN ) );
|
||||
}
|
||||
else if (current instanceof WMLPreprocIF) {
|
||||
else if( current instanceof WMLPreprocIF ) {
|
||||
toColor.add( Pair.create(
|
||||
getFirstFeatureNode( current, WmlPackage.Literals.WML_EXPRESSION__NAME ),
|
||||
getFirstFeatureNode( current,
|
||||
WmlPackage.Literals.WML_EXPRESSION__NAME ),
|
||||
WMLHighlightingConfiguration.RULE_WML_IF ) );
|
||||
|
||||
toColor.add( Pair.create(
|
||||
getFirstFeatureNode( current, WmlPackage.Literals.WML_EXPRESSION__NAME ),
|
||||
getFirstFeatureNode( current,
|
||||
WmlPackage.Literals.WML_EXPRESSION__NAME ),
|
||||
WMLHighlightingConfiguration.RULE_WML_IF ) );
|
||||
}
|
||||
else if (current instanceof WMLMacroDefine) {
|
||||
else if( current instanceof WMLMacroDefine ) {
|
||||
toColor.add( Pair.create(
|
||||
getFirstFeatureNode( current, WmlPackage.Literals.WML_EXPRESSION__NAME ),
|
||||
getFirstFeatureNode( current,
|
||||
WmlPackage.Literals.WML_EXPRESSION__NAME ),
|
||||
WMLHighlightingConfiguration.RULE_WML_MACRO_DEFINE ) );
|
||||
|
||||
toColor.add( Pair.create(
|
||||
getFirstFeatureNode( current, WmlPackage.Literals.WML_MACRO_DEFINE__END_NAME ),
|
||||
WMLHighlightingConfiguration.RULE_WML_MACRO_DEFINE ) );
|
||||
toColor.add( Pair
|
||||
.create(
|
||||
getFirstFeatureNode(
|
||||
current,
|
||||
WmlPackage.Literals.WML_MACRO_DEFINE__END_NAME ),
|
||||
WMLHighlightingConfiguration.RULE_WML_MACRO_DEFINE ) );
|
||||
}
|
||||
|
||||
// check if we have any information specific information for highlighting
|
||||
for ( Adapter adapter : resource.eAdapters( ) ) {
|
||||
if ( adapter instanceof WMLSyntaxColoringAdapter ) {
|
||||
// check if we have any information specific information for
|
||||
// highlighting
|
||||
for( Adapter adapter: resource.eAdapters( ) ) {
|
||||
if( adapter instanceof WMLSyntaxColoringAdapter ) {
|
||||
WMLSyntaxColoringAdapter wmlAdapter = ( WMLSyntaxColoringAdapter ) adapter;
|
||||
|
||||
if ( wmlAdapter.TargetEObject == current ) {
|
||||
if( wmlAdapter.TargetEObject == current ) {
|
||||
|
||||
for ( Pair<INode, String> pair : toColor ) {
|
||||
for( Pair< INode, String > pair: toColor ) {
|
||||
pair.Second = wmlAdapter.ColorId;
|
||||
}
|
||||
|
||||
|
@ -105,44 +120,60 @@ public class WMLSemanticHighlightingCalculator implements ISemanticHighlightingC
|
|||
}
|
||||
}
|
||||
|
||||
for ( Pair<INode, String> pair : toColor ) {
|
||||
for( Pair< INode, String > pair: toColor ) {
|
||||
highlightNode( pair.First, pair.Second, acceptor );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copied from org.eclipse.xtext.xtext.ui.editor.syntaxcoloring.SemanticHighlightingCalculator
|
||||
* @param node The node to highlight
|
||||
* @param id The id of the coloring
|
||||
* @param acceptor The acceptor to add the node to
|
||||
* Copied from org.eclipse.xtext.xtext.ui.editor.syntaxcoloring.
|
||||
* SemanticHighlightingCalculator
|
||||
*
|
||||
* @param node
|
||||
* The node to highlight
|
||||
* @param id
|
||||
* The id of the coloring
|
||||
* @param acceptor
|
||||
* The acceptor to add the node to
|
||||
*/
|
||||
private void highlightNode(INode node, String id, IHighlightedPositionAcceptor acceptor) {
|
||||
if (node == null)
|
||||
private void highlightNode( INode node, String id,
|
||||
IHighlightedPositionAcceptor acceptor )
|
||||
{
|
||||
if( node == null )
|
||||
return;
|
||||
if (node instanceof ILeafNode) {
|
||||
acceptor.addPosition(node.getOffset(), node.getLength(), id);
|
||||
} else {
|
||||
for(ILeafNode leaf: node.getLeafNodes()) {
|
||||
if (!leaf.isHidden()) {
|
||||
acceptor.addPosition(leaf.getOffset(), leaf.getLength(), id);
|
||||
if( node instanceof ILeafNode ) {
|
||||
acceptor.addPosition( node.getOffset( ), node.getLength( ), id );
|
||||
}
|
||||
else {
|
||||
for( ILeafNode leaf: node.getLeafNodes( ) ) {
|
||||
if( ! leaf.isHidden( ) ) {
|
||||
acceptor.addPosition( leaf.getOffset( ), leaf.getLength( ),
|
||||
id );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copied from org.eclipse.xtext.xtext.ui.editor.syntaxcoloring.SemanticHighlightingCalculator
|
||||
* @param semantic The object to search in
|
||||
* @param feature The feature to search for
|
||||
* Copied from org.eclipse.xtext.xtext.ui.editor.syntaxcoloring.
|
||||
* SemanticHighlightingCalculator
|
||||
*
|
||||
* @param semantic
|
||||
* The object to search in
|
||||
* @param feature
|
||||
* The feature to search for
|
||||
* @return Null if there is no feature, or an {@link INode} node
|
||||
*/
|
||||
public INode getFirstFeatureNode(EObject semantic, EStructuralFeature feature) {
|
||||
if (feature == null)
|
||||
return NodeModelUtils.findActualNodeFor(semantic);
|
||||
List<INode> nodes = NodeModelUtils.findNodesForFeature(semantic, feature);
|
||||
if (!nodes.isEmpty())
|
||||
return nodes.get(0);
|
||||
public INode getFirstFeatureNode( EObject semantic,
|
||||
EStructuralFeature feature )
|
||||
{
|
||||
if( feature == null )
|
||||
return NodeModelUtils.findActualNodeFor( semantic );
|
||||
List< INode > nodes = NodeModelUtils.findNodesForFeature( semantic,
|
||||
feature );
|
||||
if( ! nodes.isEmpty( ) )
|
||||
return nodes.get( 0 );
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,16 +17,17 @@ import org.eclipse.emf.ecore.EObject;
|
|||
public class WMLSyntaxColoringAdapter extends AdapterImpl
|
||||
{
|
||||
/**
|
||||
* A color id from the {@link org.wesnoth.ui.syntax.WMLHighlightingConfiguration}
|
||||
* A color id from the
|
||||
* {@link org.wesnoth.ui.syntax.WMLHighlightingConfiguration}
|
||||
*/
|
||||
public String ColorId;
|
||||
public String ColorId;
|
||||
|
||||
/**
|
||||
* The object to color
|
||||
*/
|
||||
public EObject TargetEObject;
|
||||
|
||||
public WMLSyntaxColoringAdapter( String id, EObject target)
|
||||
public WMLSyntaxColoringAdapter( String id, EObject target )
|
||||
{
|
||||
ColorId = id;
|
||||
TargetEObject = target;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#Sat Aug 06 15:40:55 EEST 2011
|
||||
#Sat Aug 06 15:51:03 EEST 2011
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.codeComplete.argumentPrefixes=
|
||||
org.eclipse.jdt.core.codeComplete.argumentSuffixes=
|
||||
|
@ -303,21 +303,21 @@ org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declara
|
|||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
|
||||
|
|
|
@ -17,77 +17,81 @@ import org.eclipse.xtext.ui.XtextProjectHelper;
|
|||
*/
|
||||
public class Constants
|
||||
{
|
||||
/** Plugin related */
|
||||
public static final String PLUGIN_FULL_PATH =
|
||||
Constants.class.getProtectionDomain().getCodeSource().getLocation().getPath() + "/"; //$NON-NLS-1$
|
||||
public static final String PLUGIN_ID = "org.wesnoth"; //$NON-NLS-1$
|
||||
/** Plugin related */
|
||||
public static final String PLUGIN_FULL_PATH = Constants.class
|
||||
.getProtectionDomain( )
|
||||
.getCodeSource( )
|
||||
.getLocation( )
|
||||
.getPath( )
|
||||
+ "/"; //$NON-NLS-1$
|
||||
public static final String PLUGIN_ID = "org.wesnoth"; //$NON-NLS-1$
|
||||
|
||||
public static final String MACHINE_OS =
|
||||
System.getProperty("os.name").toLowerCase(Locale.ENGLISH); //$NON-NLS-1$
|
||||
/**
|
||||
* The boolean value whether this machine is running windows or not
|
||||
*/
|
||||
public static final boolean IS_WINDOWS_MACHINE =
|
||||
MACHINE_OS.contains("windows"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
/**
|
||||
* The boolean value whether this machine is running Machintosh or not
|
||||
*/
|
||||
public static final boolean IS_MAC_MACHINE =
|
||||
MACHINE_OS.contains("mac"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
public static final String MACHINE_OS = System.getProperty(
|
||||
"os.name" ).toLowerCase( Locale.ENGLISH ); //$NON-NLS-1$
|
||||
/**
|
||||
* The boolean value whether this machine is running windows or not
|
||||
*/
|
||||
public static final boolean IS_WINDOWS_MACHINE = MACHINE_OS
|
||||
.contains( "windows" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
/**
|
||||
* The boolean value whether this machine is running Machintosh or not
|
||||
*/
|
||||
public static final boolean IS_MAC_MACHINE = MACHINE_OS
|
||||
.contains( "mac" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
/** Preferences Constants **/
|
||||
public static final String P_WESNOTH_EXEC_PATH = "wesnoth_exec_path"; //$NON-NLS-1$
|
||||
public static final String P_WESNOTH_WORKING_DIR = "wesnoth_working_dir"; //$NON-NLS-1$
|
||||
public static final String P_WESNOTH_WMLTOOLS_DIR = "wesnoth_wmltools_dir"; //$NON-NLS-1$
|
||||
/** Preferences Constants **/
|
||||
public static final String P_WESNOTH_EXEC_PATH = "wesnoth_exec_path"; //$NON-NLS-1$
|
||||
public static final String P_WESNOTH_WORKING_DIR = "wesnoth_working_dir"; //$NON-NLS-1$
|
||||
public static final String P_WESNOTH_WMLTOOLS_DIR = "wesnoth_wmltools_dir"; //$NON-NLS-1$
|
||||
|
||||
public static final String P_WESNOTH_USER_DIR = "wesnoth_user_dir"; //$NON-NLS-1$
|
||||
public static final String P_WESNOTH_USER_DIR = "wesnoth_user_dir"; //$NON-NLS-1$
|
||||
|
||||
public static final String P_PYTHON_PATH = "python_path"; //$NON-NLS-1$
|
||||
public static final String P_PYTHON_PATH = "python_path"; //$NON-NLS-1$
|
||||
|
||||
/** WML Tools preferences constants **/
|
||||
public static final String P_WMLINDENT_VERBOSE = "wmlindent_verbose"; //$NON-NLS-1$
|
||||
public static final String P_WMLINDENT_DRYRUN = "wmlindent_dry_run"; //$NON-NLS-1$
|
||||
/** WML Tools preferences constants **/
|
||||
public static final String P_WMLINDENT_VERBOSE = "wmlindent_verbose"; //$NON-NLS-1$
|
||||
public static final String P_WMLINDENT_DRYRUN = "wmlindent_dry_run"; //$NON-NLS-1$
|
||||
|
||||
public static final String P_WMLLINT_DRYRUN = "wmllint_dry_run"; //$NON-NLS-1$
|
||||
public static final String P_WMLLINT_SPELL_CHECK = "wmllint_spell_check"; //$NON-NLS-1$
|
||||
public static final String P_WMLLINT_VERBOSE_LEVEL = "wmllint_verbose_level"; //$NON-NLS-1$
|
||||
public static final String P_WMLLINT_DRYRUN = "wmllint_dry_run"; //$NON-NLS-1$
|
||||
public static final String P_WMLLINT_SPELL_CHECK = "wmllint_spell_check"; //$NON-NLS-1$
|
||||
public static final String P_WMLLINT_VERBOSE_LEVEL = "wmllint_verbose_level"; //$NON-NLS-1$
|
||||
|
||||
public static final String P_WMLSCOPE_VERBOSE_LEVEL= "wmlscope_verbose_level"; //$NON-NLS-1$
|
||||
public static final String P_WMLSCOPE_COLLISIONS = "wmlscope_collisions"; //$NON-NLS-1$
|
||||
public static final String P_WMLSCOPE_VERBOSE_LEVEL = "wmlscope_verbose_level"; //$NON-NLS-1$
|
||||
public static final String P_WMLSCOPE_COLLISIONS = "wmlscope_collisions"; //$NON-NLS-1$
|
||||
|
||||
/** Wesnoth addon uploader preferences */
|
||||
public static final String P_WAU_PASSWORD = "wau_password"; //$NON-NLS-1$
|
||||
public static final String P_WAU_VERBOSE = "wau_verbose"; //$NON-NLS-1$
|
||||
public static final String P_WAU_ADDRESS = "wau_address"; //$NON-NLS-1$
|
||||
public static final String P_WAU_PORT = "wau_port"; //$NON-NLS-1$
|
||||
/** Wesnoth addon uploader preferences */
|
||||
public static final String P_WAU_PASSWORD = "wau_password"; //$NON-NLS-1$
|
||||
public static final String P_WAU_VERBOSE = "wau_verbose"; //$NON-NLS-1$
|
||||
public static final String P_WAU_ADDRESS = "wau_address"; //$NON-NLS-1$
|
||||
public static final String P_WAU_PORT = "wau_port"; //$NON-NLS-1$
|
||||
|
||||
/** Advanced preferences */
|
||||
public static final String P_NO_TERRAIN_GFX = "adv_no_terrain_gfx"; //$NON-NLS-1$
|
||||
public static final String P_WML_VALIDATION = "adv_wml_validation"; //$NON-NLS-1$
|
||||
/** Advanced preferences */
|
||||
public static final String P_NO_TERRAIN_GFX = "adv_no_terrain_gfx"; //$NON-NLS-1$
|
||||
public static final String P_WML_VALIDATION = "adv_wml_validation"; //$NON-NLS-1$
|
||||
|
||||
/** Install preferences */
|
||||
public static final String P_INST_DEFAULT_INSTALL = "inst_default"; //$NON-NLS-1$
|
||||
public static final String P_INST_INSTALL_LIST = "inst_list"; //$NON-NLS-1$
|
||||
public static final String P_INST_NAME_PREFIX = "inst_name"; //$NON-NLS-1$
|
||||
/** Install preferences */
|
||||
public static final String P_INST_DEFAULT_INSTALL = "inst_default"; //$NON-NLS-1$
|
||||
public static final String P_INST_INSTALL_LIST = "inst_list"; //$NON-NLS-1$
|
||||
public static final String P_INST_NAME_PREFIX = "inst_name"; //$NON-NLS-1$
|
||||
|
||||
/** Wizards Constants **/
|
||||
public static final int WIZ_TextBoxHeight = 21;
|
||||
public static final int WIZ_MaxTextBoxesOnPage = 10;
|
||||
public static final int WIZ_MaxGroupsOnPage = 4;
|
||||
public static final int WIZ_MaxWizardPageHeight = 220;
|
||||
/** Wizards Constants **/
|
||||
public static final int WIZ_TextBoxHeight = 21;
|
||||
public static final int WIZ_MaxTextBoxesOnPage = 10;
|
||||
public static final int WIZ_MaxGroupsOnPage = 4;
|
||||
public static final int WIZ_MaxWizardPageHeight = 220;
|
||||
|
||||
/** Builder Constants **/
|
||||
public static final String BUIILDER_WESNOTH = "org.wesnoth.builders.wesnoth"; //$NON-NLS-1$
|
||||
public static final String BUILDER_XTEXT = XtextProjectHelper.BUILDER_ID;
|
||||
/** Builder Constants **/
|
||||
public static final String BUIILDER_WESNOTH = "org.wesnoth.builders.wesnoth"; //$NON-NLS-1$
|
||||
public static final String BUILDER_XTEXT = XtextProjectHelper.BUILDER_ID;
|
||||
|
||||
/** Markers **/
|
||||
public static final String MARKER_WMLSCOPE = "org.wesnoth.marker.wmlscope"; //$NON-NLS-1$
|
||||
public static final String MARKER_WMLLINT = "org.wesnoth.marker.wmllint"; //$NON-NLS-1$
|
||||
/** Markers **/
|
||||
public static final String MARKER_WMLSCOPE = "org.wesnoth.marker.wmlscope"; //$NON-NLS-1$
|
||||
public static final String MARKER_WMLLINT = "org.wesnoth.marker.wmllint"; //$NON-NLS-1$
|
||||
|
||||
/** Nature Constants **/
|
||||
public static final String NATURE_WESNOTH = "org.wesnoth.natures.wesnoth"; //$NON-NLS-1$
|
||||
public static final String NATURE_XTEXT = XtextProjectHelper.NATURE_ID;
|
||||
/** Nature Constants **/
|
||||
public static final String NATURE_WESNOTH = "org.wesnoth.natures.wesnoth"; //$NON-NLS-1$
|
||||
public static final String NATURE_XTEXT = XtextProjectHelper.NATURE_ID;
|
||||
|
||||
/** Templates related */
|
||||
public static final String TEMPLATES_FILENAME = "templatesIndex.txt"; //$NON-NLS-1$
|
||||
/** Templates related */
|
||||
public static final String TEMPLATES_FILENAME = "templatesIndex.txt"; //$NON-NLS-1$
|
||||
}
|
||||
|
|
|
@ -20,119 +20,139 @@ import java.util.Date;
|
|||
import javax.swing.JOptionPane;
|
||||
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
|
||||
import org.wesnoth.utils.GUIUtils;
|
||||
import org.wesnoth.utils.WorkspaceUtils;
|
||||
|
||||
/**
|
||||
* A class that logs activities in a file
|
||||
*/
|
||||
public class Logger {
|
||||
public class Logger
|
||||
{
|
||||
|
||||
private static class LoggerInstance{
|
||||
private static Logger instance_ = new Logger();
|
||||
private static class LoggerInstance
|
||||
{
|
||||
private static Logger instance_ = new Logger( );
|
||||
}
|
||||
|
||||
private Logger() { }
|
||||
private Logger( )
|
||||
{
|
||||
}
|
||||
|
||||
private BufferedWriter logWriter_;
|
||||
private BufferedWriter toolLaunchLogWriter_;
|
||||
private BufferedWriter logWriter_;
|
||||
private BufferedWriter toolLaunchLogWriter_;
|
||||
|
||||
public static Logger getInstance()
|
||||
{
|
||||
return LoggerInstance.instance_;
|
||||
}
|
||||
public static Logger getInstance( )
|
||||
{
|
||||
return LoggerInstance.instance_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the logger - creates the log file in the temporary directory
|
||||
*/
|
||||
public void startLogger()
|
||||
{
|
||||
if (logWriter_ != null)
|
||||
return;
|
||||
try
|
||||
{
|
||||
if (WorkspaceUtils.getTemporaryFolder() == null)
|
||||
throw new IOException("Could not create the temporary folder."); //$NON-NLS-1$
|
||||
/**
|
||||
* Starts the logger - creates the log file in the temporary directory
|
||||
*/
|
||||
public void startLogger( )
|
||||
{
|
||||
if( logWriter_ != null )
|
||||
return;
|
||||
try {
|
||||
if( WorkspaceUtils.getTemporaryFolder( ) == null )
|
||||
throw new IOException( "Could not create the temporary folder." ); //$NON-NLS-1$
|
||||
|
||||
String logFilePath = String.format("%s/logs/log%s.txt", //$NON-NLS-1$
|
||||
WorkspaceUtils.getTemporaryFolder(), WorkspaceUtils.getCurrentDateTime());
|
||||
String toolsLogFilePath = String.format("%s/logs/tools_log%s.txt", //$NON-NLS-1$
|
||||
WorkspaceUtils.getTemporaryFolder(), WorkspaceUtils.getCurrentDateTime());
|
||||
String logFilePath = String.format(
|
||||
"%s/logs/log%s.txt", //$NON-NLS-1$
|
||||
WorkspaceUtils.getTemporaryFolder( ),
|
||||
WorkspaceUtils.getCurrentDateTime( ) );
|
||||
String toolsLogFilePath = String.format(
|
||||
"%s/logs/tools_log%s.txt", //$NON-NLS-1$
|
||||
WorkspaceUtils.getTemporaryFolder( ),
|
||||
WorkspaceUtils.getCurrentDateTime( ) );
|
||||
|
||||
new File(WorkspaceUtils.getTemporaryFolder() + "/logs/").mkdirs(); //$NON-NLS-1$
|
||||
new File( WorkspaceUtils.getTemporaryFolder( ) + "/logs/" ).mkdirs( ); //$NON-NLS-1$
|
||||
|
||||
logWriter_ = new BufferedWriter(new FileWriter(logFilePath));
|
||||
log("Logging started."); //$NON-NLS-1$
|
||||
log("Error codes: 1 - INFO, 2 - WARNING, 4 - ERROR"); //$NON-NLS-1$
|
||||
logWriter_ = new BufferedWriter( new FileWriter( logFilePath ) );
|
||||
log( "Logging started." ); //$NON-NLS-1$
|
||||
log( "Error codes: 1 - INFO, 2 - WARNING, 4 - ERROR" ); //$NON-NLS-1$
|
||||
|
||||
toolLaunchLogWriter_ = new BufferedWriter( new FileWriter( toolsLogFilePath ) );
|
||||
logTool("Logging started."); //$NON-NLS-1$
|
||||
logTool("Error codes: 1 - INFO, 2 - WARNING, 4 - ERROR"); //$NON-NLS-1$
|
||||
toolLaunchLogWriter_ = new BufferedWriter( new FileWriter(
|
||||
toolsLogFilePath ) );
|
||||
logTool( "Logging started." ); //$NON-NLS-1$
|
||||
logTool( "Error codes: 1 - INFO, 2 - WARNING, 4 - ERROR" ); //$NON-NLS-1$
|
||||
|
||||
} catch (IOException e)
|
||||
{
|
||||
JOptionPane.showMessageDialog(null, "There was an error trying to open the log." + e.getMessage()); //$NON-NLS-1$
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} catch( IOException e ) {
|
||||
JOptionPane
|
||||
.showMessageDialog(
|
||||
null,
|
||||
"There was an error trying to open the log." + e.getMessage( ) ); //$NON-NLS-1$
|
||||
e.printStackTrace( );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the logger
|
||||
*/
|
||||
public void stopLogger()
|
||||
{
|
||||
if (logWriter_ == null)
|
||||
return;
|
||||
try
|
||||
{
|
||||
log("Logging ended."); //$NON-NLS-1$
|
||||
logTool( "Logging Ended" );
|
||||
logWriter_.close();
|
||||
toolLaunchLogWriter_.close( );
|
||||
} catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Stops the logger
|
||||
*/
|
||||
public void stopLogger( )
|
||||
{
|
||||
if( logWriter_ == null )
|
||||
return;
|
||||
try {
|
||||
log( "Logging ended." ); //$NON-NLS-1$
|
||||
logTool( "Logging Ended" );
|
||||
logWriter_.close( );
|
||||
toolLaunchLogWriter_.close( );
|
||||
} catch( IOException e ) {
|
||||
e.printStackTrace( );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a message to the error log (severity: info)
|
||||
* @param message The message to log
|
||||
*/
|
||||
public void log(String message)
|
||||
{
|
||||
log(message, IStatus.INFO);
|
||||
}
|
||||
/**
|
||||
* Prints a message to the error log (severity: info)
|
||||
*
|
||||
* @param message
|
||||
* The message to log
|
||||
*/
|
||||
public void log( String message )
|
||||
{
|
||||
log( message, IStatus.INFO );
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs a warning message
|
||||
* @param message The message to log
|
||||
*/
|
||||
public void logWarn(String message)
|
||||
{
|
||||
log(message,IStatus.WARNING);
|
||||
}
|
||||
/**
|
||||
* Logs an error message
|
||||
* @param message The message to log
|
||||
*/
|
||||
public void logError(String message)
|
||||
{
|
||||
log(message,IStatus.ERROR);
|
||||
}
|
||||
/**
|
||||
* Logs a warning message
|
||||
*
|
||||
* @param message
|
||||
* The message to log
|
||||
*/
|
||||
public void logWarn( String message )
|
||||
{
|
||||
log( message, IStatus.WARNING );
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the specified exception, providing the stacktrace to the console
|
||||
* @param e The exception to log
|
||||
*/
|
||||
public void logException(Exception e)
|
||||
{
|
||||
logExceptionToWriter( logWriter_, e );
|
||||
}
|
||||
/**
|
||||
* Logs an error message
|
||||
*
|
||||
* @param message
|
||||
* The message to log
|
||||
*/
|
||||
public void logError( String message )
|
||||
{
|
||||
log( message, IStatus.ERROR );
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the specified exception, providing the stacktrace to the console
|
||||
* @param e The exception to log
|
||||
*
|
||||
* @param e
|
||||
* The exception to log
|
||||
*/
|
||||
public void logException( Exception e )
|
||||
{
|
||||
logExceptionToWriter( logWriter_, e );
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the specified exception, providing the stacktrace to the console
|
||||
*
|
||||
* @param e
|
||||
* The exception to log
|
||||
*/
|
||||
public void logToolException( Exception e )
|
||||
{
|
||||
|
@ -141,67 +161,75 @@ public class Logger {
|
|||
|
||||
private void logExceptionToWriter( BufferedWriter writer, Exception e )
|
||||
{
|
||||
if (e == null)
|
||||
if( e == null )
|
||||
return;
|
||||
|
||||
// put the stack trace in a string
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
e.printStackTrace(pw);
|
||||
StringWriter sw = new StringWriter( );
|
||||
PrintWriter pw = new PrintWriter( sw );
|
||||
e.printStackTrace( pw );
|
||||
|
||||
logToWriter( writer, e.getLocalizedMessage(), IStatus.ERROR );
|
||||
logToWriter( writer, sw.toString(), IStatus.ERROR );
|
||||
logToWriter( writer, e.getLocalizedMessage( ), IStatus.ERROR );
|
||||
logToWriter( writer, sw.toString( ), IStatus.ERROR );
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the message (severity: info) showing also a messagebox to the user
|
||||
* @param message The message to log
|
||||
* @param guiMessage The message to show to the user
|
||||
*
|
||||
* @param message
|
||||
* The message to log
|
||||
* @param guiMessage
|
||||
* The message to show to the user
|
||||
*/
|
||||
public void log(String message, String guiMessage)
|
||||
public void log( String message, String guiMessage )
|
||||
{
|
||||
log(message,IStatus.INFO);
|
||||
GUIUtils.showInfoMessageBox(guiMessage);
|
||||
log( message, IStatus.INFO );
|
||||
GUIUtils.showInfoMessageBox( guiMessage );
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a message to the error log with the specified severity
|
||||
* @param message the message to log
|
||||
* @param severity the severity level from IStatus enum
|
||||
*/
|
||||
public void log(String message, int severity)
|
||||
{
|
||||
logToWriter( logWriter_, message, severity );
|
||||
}
|
||||
/**
|
||||
* Prints a message to the error log with the specified severity
|
||||
*
|
||||
* @param message
|
||||
* the message to log
|
||||
* @param severity
|
||||
* the severity level from IStatus enum
|
||||
*/
|
||||
public void log( String message, int severity )
|
||||
{
|
||||
logToWriter( logWriter_, message, severity );
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a message to the tool launch log (severity: info)
|
||||
* @param message The message to log
|
||||
*/
|
||||
public void logTool( String message )
|
||||
{
|
||||
logToWriter( toolLaunchLogWriter_, message, IStatus.INFO );
|
||||
}
|
||||
/**
|
||||
* Prints a message to the tool launch log (severity: info)
|
||||
*
|
||||
* @param message
|
||||
* The message to log
|
||||
*/
|
||||
public void logTool( String message )
|
||||
{
|
||||
logToWriter( toolLaunchLogWriter_, message, IStatus.INFO );
|
||||
}
|
||||
|
||||
private void logToWriter( BufferedWriter writer, String message, int severity )
|
||||
{
|
||||
if (writer != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
writer.write(String.format("%s | %d | %s\n", //$NON-NLS-1$
|
||||
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()), //$NON-NLS-1$
|
||||
severity, message));
|
||||
writer.flush();
|
||||
} catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
private void logToWriter( BufferedWriter writer, String message,
|
||||
int severity )
|
||||
{
|
||||
if( writer != null ) {
|
||||
try {
|
||||
writer.write( String
|
||||
.format(
|
||||
"%s | %d | %s\n", //$NON-NLS-1$
|
||||
new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ).format( new Date( ) ), //$NON-NLS-1$
|
||||
severity, message ) );
|
||||
writer.flush( );
|
||||
} catch( IOException e ) {
|
||||
e.printStackTrace( );
|
||||
}
|
||||
}
|
||||
|
||||
// don't print to console the tools if there was no error/warning
|
||||
if ( writer != toolLaunchLogWriter_ ||
|
||||
( writer == toolLaunchLogWriter_ && severity != IStatus.INFO ) )
|
||||
System.out.println(message);
|
||||
}
|
||||
if( writer != toolLaunchLogWriter_
|
||||
|| ( writer == toolLaunchLogWriter_ && severity != IStatus.INFO ) )
|
||||
System.out.println( message );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,316 +12,315 @@ import org.eclipse.osgi.util.NLS;
|
|||
|
||||
public class Messages extends NLS
|
||||
{
|
||||
private static final String BUNDLE_NAME = "org.wesnoth.messages"; //$NON-NLS-1$
|
||||
public static String ActionWiper_6;
|
||||
public static String WorkspaceUtils_0;
|
||||
public static String AddonUploadPreferencePage_10;
|
||||
public static String AddonUploadPreferencePage_11;
|
||||
public static String AddonUploadPreferencePage_12;
|
||||
public static String AddonUploadPreferencePage_13;
|
||||
public static String AddonUploadPreferencePage_14;
|
||||
public static String AddonUploadPreferencePage_15;
|
||||
public static String AddonUploadPreferencePage_16;
|
||||
public static String AddonUploadPreferencePage_17;
|
||||
public static String AddonUploadPreferencePage_22;
|
||||
public static String AddonUploadPreferencePage_23;
|
||||
public static String AddonUploadPreferencePage_24;
|
||||
public static String AddonUploadPreferencePage_25;
|
||||
public static String AdvancedPreferencePage_0;
|
||||
public static String AdvancedPreferencePage_1;
|
||||
public static String AdvancedPreferencePage_2;
|
||||
public static String CampaignNewWizard_0;
|
||||
public static String CampaignNewWizard_1;
|
||||
public static String CampaignPage0_1;
|
||||
public static String CampaignPage0_2;
|
||||
public static String CampaignPage1_1;
|
||||
public static String CampaignPage1_10;
|
||||
public static String CampaignPage1_11;
|
||||
public static String CampaignPage1_12;
|
||||
public static String CampaignPage1_13;
|
||||
public static String CampaignPage1_14;
|
||||
public static String CampaignPage1_15;
|
||||
public static String CampaignPage1_16;
|
||||
public static String CampaignPage1_17;
|
||||
public static String CampaignPage1_18;
|
||||
public static String CampaignPage1_19;
|
||||
public static String CampaignPage1_2;
|
||||
public static String CampaignPage1_21;
|
||||
public static String CampaignPage1_3;
|
||||
public static String CampaignPage1_4;
|
||||
public static String CampaignPage1_5;
|
||||
public static String CampaignPage1_6;
|
||||
public static String CampaignPage1_7;
|
||||
public static String CampaignPage1_8;
|
||||
public static String CampaignPage1_9;
|
||||
public static String CampaignPage2_1;
|
||||
public static String CampaignPage2_12;
|
||||
public static String CampaignPage2_13;
|
||||
public static String CampaignPage2_14;
|
||||
public static String CampaignPage2_15;
|
||||
public static String CampaignPage2_2;
|
||||
public static String CampaignPage2_5;
|
||||
public static String CampaignPage2_6;
|
||||
public static String CampaignPage2_7;
|
||||
public static String CampaignPage2_8;
|
||||
public static String EmptyProjectNewWizard_0;
|
||||
public static String EmptyProjectNewWizard_1;
|
||||
public static String EmptyProjectPage0_1;
|
||||
public static String EmptyProjectPage0_2;
|
||||
public static String EmptyProjectPage1_1;
|
||||
public static String EmptyProjectPage1_14;
|
||||
public static String EmptyProjectPage1_15;
|
||||
public static String EmptyProjectPage1_16;
|
||||
public static String EmptyProjectPage1_17;
|
||||
public static String EmptyProjectPage1_18;
|
||||
public static String EmptyProjectPage1_19;
|
||||
public static String EmptyProjectPage1_2;
|
||||
public static String EmptyProjectPage1_20;
|
||||
public static String EmptyProjectPage1_21;
|
||||
public static String EmptyProjectPage1_22;
|
||||
public static String EmptyProjectPage1_23;
|
||||
public static String EmptyProjectPage1_3;
|
||||
public static String EmptyProjectPage1_32;
|
||||
public static String EmptyProjectPage1_33;
|
||||
public static String EmptyProjectPage1_35;
|
||||
public static String EmptyProjectPage1_4;
|
||||
public static String EmptyProjectPage1_5;
|
||||
public static String EmptyProjectPage1_6;
|
||||
public static String EmptyProjectPage1_7;
|
||||
public static String EmptyProjectPage1_8;
|
||||
public static String EraNewWizard_0;
|
||||
public static String EraNewWizard_1;
|
||||
public static String EraNewWizard_2;
|
||||
public static String EraNewWizard_8;
|
||||
public static String EraPage0_1;
|
||||
public static String EraPage0_10;
|
||||
public static String EraPage0_11;
|
||||
public static String EraPage0_12;
|
||||
public static String EraPage0_13;
|
||||
public static String EraPage0_15;
|
||||
public static String EraPage0_16;
|
||||
public static String EraPage0_17;
|
||||
public static String EraPage0_2;
|
||||
public static String EraPage0_3;
|
||||
public static String EraPage0_4;
|
||||
public static String EraPage0_5;
|
||||
public static String EraPage0_6;
|
||||
public static String EraPage0_7;
|
||||
public static String EraPage0_8;
|
||||
public static String EraPage0_9;
|
||||
public static String FactionNewWizard_0;
|
||||
public static String FactionNewWizard_1;
|
||||
public static String FactionNewWizard_14;
|
||||
public static String FactionNewWizard_2;
|
||||
public static String FactionPage0_1;
|
||||
public static String FactionPage0_10;
|
||||
public static String FactionPage0_11;
|
||||
public static String FactionPage0_12;
|
||||
public static String FactionPage0_13;
|
||||
public static String FactionPage0_14;
|
||||
public static String FactionPage0_15;
|
||||
public static String FactionPage0_16;
|
||||
public static String FactionPage0_18;
|
||||
public static String FactionPage0_19;
|
||||
public static String FactionPage0_2;
|
||||
public static String FactionPage0_20;
|
||||
public static String FactionPage0_3;
|
||||
public static String FactionPage0_4;
|
||||
public static String FactionPage0_5;
|
||||
public static String FactionPage0_6;
|
||||
public static String FactionPage0_7;
|
||||
public static String FactionPage0_8;
|
||||
public static String FactionPage0_9;
|
||||
public static String FactionPage1_1;
|
||||
public static String FactionPage1_2;
|
||||
public static String FactionPage1_3;
|
||||
public static String FactionPage1_4;
|
||||
public static String FactionPage1_5;
|
||||
public static String GameUtils_0;
|
||||
public static String GameUtils_12;
|
||||
public static String GameUtils_2;
|
||||
public static String GameUtils_4;
|
||||
public static String GameUtils_7;
|
||||
public static String GameUtils_9;
|
||||
public static String ImportMapHandler_1;
|
||||
public static String ImportMapHandler_3;
|
||||
public static String MapUtils_1;
|
||||
public static String MapUtils_2;
|
||||
public static String MapUtils_4;
|
||||
public static String NewConfigFilePage0_1;
|
||||
public static String NewConfigFilePage0_10;
|
||||
public static String NewConfigFilePage0_11;
|
||||
public static String NewConfigFilePage0_12;
|
||||
public static String NewConfigFilePage0_14;
|
||||
public static String NewConfigFilePage0_2;
|
||||
public static String NewConfigFilePage0_3;
|
||||
public static String NewConfigFilePage0_4;
|
||||
public static String NewConfigFilePage0_5;
|
||||
public static String NewConfigFilePage0_7;
|
||||
public static String NewConfigFilePage0_8;
|
||||
public static String NewConfigFilePage0_9;
|
||||
public static String NewConfigFileWizard_0;
|
||||
public static String NewConfigFileWizard_4;
|
||||
public static String NewWizardPageTemplate_1;
|
||||
public static String OpenMapInEditorHandler_1;
|
||||
public static String OpenMapInEditorHandler_4;
|
||||
public static String PreprocessorUtils_12;
|
||||
public static String ProjectUtils_0;
|
||||
public static String ProjectUtils_4;
|
||||
public static String ProjectUtils_6;
|
||||
public static String ReloadFilesHandler_0;
|
||||
public static String ResourceUtils_5;
|
||||
public static String ScenarioNewWizard_0;
|
||||
public static String ScenarioNewWizard_2;
|
||||
public static String ScenarioNewWizard_20;
|
||||
public static String ScenarioNewWizard_5;
|
||||
public static String ScenarioPage0_1;
|
||||
public static String ScenarioPage0_10;
|
||||
public static String ScenarioPage0_11;
|
||||
public static String ScenarioPage0_12;
|
||||
public static String ScenarioPage0_14;
|
||||
public static String ScenarioPage0_15;
|
||||
public static String ScenarioPage0_16;
|
||||
public static String ScenarioPage0_18;
|
||||
public static String ScenarioPage0_19;
|
||||
public static String ScenarioPage0_2;
|
||||
public static String ScenarioPage0_20;
|
||||
public static String ScenarioPage0_22;
|
||||
public static String ScenarioPage0_23;
|
||||
public static String ScenarioPage0_26;
|
||||
public static String ScenarioPage0_3;
|
||||
public static String ScenarioPage0_4;
|
||||
public static String ScenarioPage0_5;
|
||||
public static String ScenarioPage0_6;
|
||||
public static String ScenarioPage0_7;
|
||||
public static String ScenarioPage0_8;
|
||||
public static String ScenarioPage0_9;
|
||||
public static String ScenarioPage1_1;
|
||||
public static String ScenarioPage1_2;
|
||||
public static String ScenarioPage1_3;
|
||||
public static String ScenarioPage2_1;
|
||||
public static String ScenarioPage2_2;
|
||||
public static String ScenarioPage2_3;
|
||||
public static String ScenarioPage2_4;
|
||||
public static String UploadAddon_0;
|
||||
public static String UploadAddon_1;
|
||||
public static String WesnothInstallsPage_0;
|
||||
public static String WesnothInstallsPage_10;
|
||||
public static String WesnothInstallsPage_11;
|
||||
public static String WesnothInstallsPage_12;
|
||||
public static String WesnothInstallsPage_13;
|
||||
public static String WesnothInstallsPage_19;
|
||||
public static String WesnothInstallsPage_20;
|
||||
public static String WesnothInstallsPage_21;
|
||||
public static String WesnothInstallsPage_5;
|
||||
public static String WesnothInstallsPage_6;
|
||||
public static String WesnothInstallsPage_7;
|
||||
public static String WesnothInstallsPage_8;
|
||||
public static String WesnothInstallsPage_9;
|
||||
public static String WesnothInstallsUtils_1;
|
||||
public static String WesnothPreferencesPage_0;
|
||||
public static String WesnothPreferencesPage_10;
|
||||
public static String WesnothPreferencesPage_11;
|
||||
public static String WesnothPreferencesPage_12;
|
||||
public static String WesnothPreferencesPage_13;
|
||||
public static String WesnothPreferencesPage_14;
|
||||
public static String WesnothPreferencesPage_24;
|
||||
public static String WesnothPreferencesPage_5;
|
||||
public static String WesnothPreferencesPage_6;
|
||||
public static String WesnothPreferencesPage_7;
|
||||
public static String WesnothPreferencesPage_8;
|
||||
public static String WesnothPreferencesPage_9;
|
||||
public static String WesnothProjectBuilder_1;
|
||||
public static String WesnothProjectBuilder_13;
|
||||
public static String WesnothProjectBuilder_19;
|
||||
public static String WesnothProjectBuilder_22;
|
||||
public static String WesnothProjectBuilder_3;
|
||||
public static String WesnothProjectBuilder_6;
|
||||
public static String WesnothProjectBuilder_7;
|
||||
public static String WesnothProjectBuilder_8;
|
||||
public static String WesnothProjectPage_0;
|
||||
public static String WesnothProjectPage_1;
|
||||
public static String WesnothProjectPage_2;
|
||||
public static String WesnothProjectReport_0;
|
||||
public static String WesnothProjectReport_4;
|
||||
public static String WizardGeneratorPage404_1;
|
||||
public static String WizardGeneratorPage404_3;
|
||||
public static String WizardGeneratorPage404_4;
|
||||
public static String WizardGeneratorPage404_5;
|
||||
public static String WizardGeneratorPageKey_0;
|
||||
public static String WizardGeneratorPageKey_1;
|
||||
public static String WizardGeneratorPageKey_22;
|
||||
public static String WizardGeneratorPageTag_0;
|
||||
public static String WizardGeneratorPageTag_1;
|
||||
public static String WizardGeneratorPageTag_12;
|
||||
public static String WizardGeneratorPageTag_13;
|
||||
public static String WizardGeneratorPageTag_14;
|
||||
public static String WizardGeneratorPageTag_4;
|
||||
public static String WizardGeneratorPageTag_7;
|
||||
public static String WizardLauncher_0;
|
||||
public static String WizardLauncher_1;
|
||||
public static String WizardLauncher_2;
|
||||
public static String WizardLauncher_3;
|
||||
public static String WizardLauncherPage0_1;
|
||||
public static String WizardLauncherPage0_10;
|
||||
public static String WizardLauncherPage0_11;
|
||||
public static String WizardLauncherPage0_12;
|
||||
public static String WizardLauncherPage0_13;
|
||||
public static String WizardLauncherPage0_15;
|
||||
public static String WizardLauncherPage0_16;
|
||||
public static String WizardLauncherPage0_17;
|
||||
public static String WizardLauncherPage0_18;
|
||||
public static String WizardLauncherPage0_19;
|
||||
public static String WizardLauncherPage0_2;
|
||||
public static String WizardLauncherPage0_3;
|
||||
public static String WizardLauncherPage0_4;
|
||||
public static String WizardLauncherPage0_5;
|
||||
public static String WizardLauncherPage0_6;
|
||||
public static String WizardLauncherPage0_7;
|
||||
public static String WizardLauncherPage0_8;
|
||||
public static String WizardLauncherPage1_1;
|
||||
public static String WizardLauncherPage1_11;
|
||||
public static String WizardLauncherPage1_12;
|
||||
public static String WizardLauncherPage1_13;
|
||||
public static String WizardLauncherPage1_14;
|
||||
public static String WizardLauncherPage1_2;
|
||||
public static String WizardLauncherPage1_7;
|
||||
public static String WMLJavaValidator_0;
|
||||
public static String WMLJavaValidator_1;
|
||||
public static String WMLJavaValidator_2;
|
||||
public static String WMLTools_28;
|
||||
public static String WMLTools_29;
|
||||
public static String WMLTools_42;
|
||||
public static String WMLTools_45;
|
||||
public static String WMLTools_47;
|
||||
public static String WMLToolsPreferencePage_0;
|
||||
public static String WMLToolsPreferencePage_1;
|
||||
public static String WMLToolsPreferencePage_10;
|
||||
public static String WMLToolsPreferencePage_11;
|
||||
public static String WMLToolsPreferencePage_12;
|
||||
public static String WMLToolsPreferencePage_2;
|
||||
public static String WMLToolsPreferencePage_3;
|
||||
public static String WMLToolsPreferencePage_5;
|
||||
public static String WMLToolsPreferencePage_6;
|
||||
public static String WMLToolsPreferencePage_7;
|
||||
public static String WMLToolsPreferencePage_9;
|
||||
public static String WorkspaceUtils_13;
|
||||
public static String WorkspaceUtils_18;
|
||||
public static String WorkspaceUtils_20;
|
||||
public static String WorkspaceUtils_22;
|
||||
public static String WorkspaceUtils_25;
|
||||
public static String WorkspaceUtils_29;
|
||||
public static String WorkspaceUtils_30;
|
||||
public static String WorkspaceUtils_33;
|
||||
public static String WorkspaceUtils_7;
|
||||
public static String WorkspaceUtils_9;
|
||||
static
|
||||
{
|
||||
// initialize resource bundle
|
||||
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
|
||||
}
|
||||
private static final String BUNDLE_NAME = "org.wesnoth.messages"; //$NON-NLS-1$
|
||||
public static String ActionWiper_6;
|
||||
public static String WorkspaceUtils_0;
|
||||
public static String AddonUploadPreferencePage_10;
|
||||
public static String AddonUploadPreferencePage_11;
|
||||
public static String AddonUploadPreferencePage_12;
|
||||
public static String AddonUploadPreferencePage_13;
|
||||
public static String AddonUploadPreferencePage_14;
|
||||
public static String AddonUploadPreferencePage_15;
|
||||
public static String AddonUploadPreferencePage_16;
|
||||
public static String AddonUploadPreferencePage_17;
|
||||
public static String AddonUploadPreferencePage_22;
|
||||
public static String AddonUploadPreferencePage_23;
|
||||
public static String AddonUploadPreferencePage_24;
|
||||
public static String AddonUploadPreferencePage_25;
|
||||
public static String AdvancedPreferencePage_0;
|
||||
public static String AdvancedPreferencePage_1;
|
||||
public static String AdvancedPreferencePage_2;
|
||||
public static String CampaignNewWizard_0;
|
||||
public static String CampaignNewWizard_1;
|
||||
public static String CampaignPage0_1;
|
||||
public static String CampaignPage0_2;
|
||||
public static String CampaignPage1_1;
|
||||
public static String CampaignPage1_10;
|
||||
public static String CampaignPage1_11;
|
||||
public static String CampaignPage1_12;
|
||||
public static String CampaignPage1_13;
|
||||
public static String CampaignPage1_14;
|
||||
public static String CampaignPage1_15;
|
||||
public static String CampaignPage1_16;
|
||||
public static String CampaignPage1_17;
|
||||
public static String CampaignPage1_18;
|
||||
public static String CampaignPage1_19;
|
||||
public static String CampaignPage1_2;
|
||||
public static String CampaignPage1_21;
|
||||
public static String CampaignPage1_3;
|
||||
public static String CampaignPage1_4;
|
||||
public static String CampaignPage1_5;
|
||||
public static String CampaignPage1_6;
|
||||
public static String CampaignPage1_7;
|
||||
public static String CampaignPage1_8;
|
||||
public static String CampaignPage1_9;
|
||||
public static String CampaignPage2_1;
|
||||
public static String CampaignPage2_12;
|
||||
public static String CampaignPage2_13;
|
||||
public static String CampaignPage2_14;
|
||||
public static String CampaignPage2_15;
|
||||
public static String CampaignPage2_2;
|
||||
public static String CampaignPage2_5;
|
||||
public static String CampaignPage2_6;
|
||||
public static String CampaignPage2_7;
|
||||
public static String CampaignPage2_8;
|
||||
public static String EmptyProjectNewWizard_0;
|
||||
public static String EmptyProjectNewWizard_1;
|
||||
public static String EmptyProjectPage0_1;
|
||||
public static String EmptyProjectPage0_2;
|
||||
public static String EmptyProjectPage1_1;
|
||||
public static String EmptyProjectPage1_14;
|
||||
public static String EmptyProjectPage1_15;
|
||||
public static String EmptyProjectPage1_16;
|
||||
public static String EmptyProjectPage1_17;
|
||||
public static String EmptyProjectPage1_18;
|
||||
public static String EmptyProjectPage1_19;
|
||||
public static String EmptyProjectPage1_2;
|
||||
public static String EmptyProjectPage1_20;
|
||||
public static String EmptyProjectPage1_21;
|
||||
public static String EmptyProjectPage1_22;
|
||||
public static String EmptyProjectPage1_23;
|
||||
public static String EmptyProjectPage1_3;
|
||||
public static String EmptyProjectPage1_32;
|
||||
public static String EmptyProjectPage1_33;
|
||||
public static String EmptyProjectPage1_35;
|
||||
public static String EmptyProjectPage1_4;
|
||||
public static String EmptyProjectPage1_5;
|
||||
public static String EmptyProjectPage1_6;
|
||||
public static String EmptyProjectPage1_7;
|
||||
public static String EmptyProjectPage1_8;
|
||||
public static String EraNewWizard_0;
|
||||
public static String EraNewWizard_1;
|
||||
public static String EraNewWizard_2;
|
||||
public static String EraNewWizard_8;
|
||||
public static String EraPage0_1;
|
||||
public static String EraPage0_10;
|
||||
public static String EraPage0_11;
|
||||
public static String EraPage0_12;
|
||||
public static String EraPage0_13;
|
||||
public static String EraPage0_15;
|
||||
public static String EraPage0_16;
|
||||
public static String EraPage0_17;
|
||||
public static String EraPage0_2;
|
||||
public static String EraPage0_3;
|
||||
public static String EraPage0_4;
|
||||
public static String EraPage0_5;
|
||||
public static String EraPage0_6;
|
||||
public static String EraPage0_7;
|
||||
public static String EraPage0_8;
|
||||
public static String EraPage0_9;
|
||||
public static String FactionNewWizard_0;
|
||||
public static String FactionNewWizard_1;
|
||||
public static String FactionNewWizard_14;
|
||||
public static String FactionNewWizard_2;
|
||||
public static String FactionPage0_1;
|
||||
public static String FactionPage0_10;
|
||||
public static String FactionPage0_11;
|
||||
public static String FactionPage0_12;
|
||||
public static String FactionPage0_13;
|
||||
public static String FactionPage0_14;
|
||||
public static String FactionPage0_15;
|
||||
public static String FactionPage0_16;
|
||||
public static String FactionPage0_18;
|
||||
public static String FactionPage0_19;
|
||||
public static String FactionPage0_2;
|
||||
public static String FactionPage0_20;
|
||||
public static String FactionPage0_3;
|
||||
public static String FactionPage0_4;
|
||||
public static String FactionPage0_5;
|
||||
public static String FactionPage0_6;
|
||||
public static String FactionPage0_7;
|
||||
public static String FactionPage0_8;
|
||||
public static String FactionPage0_9;
|
||||
public static String FactionPage1_1;
|
||||
public static String FactionPage1_2;
|
||||
public static String FactionPage1_3;
|
||||
public static String FactionPage1_4;
|
||||
public static String FactionPage1_5;
|
||||
public static String GameUtils_0;
|
||||
public static String GameUtils_12;
|
||||
public static String GameUtils_2;
|
||||
public static String GameUtils_4;
|
||||
public static String GameUtils_7;
|
||||
public static String GameUtils_9;
|
||||
public static String ImportMapHandler_1;
|
||||
public static String ImportMapHandler_3;
|
||||
public static String MapUtils_1;
|
||||
public static String MapUtils_2;
|
||||
public static String MapUtils_4;
|
||||
public static String NewConfigFilePage0_1;
|
||||
public static String NewConfigFilePage0_10;
|
||||
public static String NewConfigFilePage0_11;
|
||||
public static String NewConfigFilePage0_12;
|
||||
public static String NewConfigFilePage0_14;
|
||||
public static String NewConfigFilePage0_2;
|
||||
public static String NewConfigFilePage0_3;
|
||||
public static String NewConfigFilePage0_4;
|
||||
public static String NewConfigFilePage0_5;
|
||||
public static String NewConfigFilePage0_7;
|
||||
public static String NewConfigFilePage0_8;
|
||||
public static String NewConfigFilePage0_9;
|
||||
public static String NewConfigFileWizard_0;
|
||||
public static String NewConfigFileWizard_4;
|
||||
public static String NewWizardPageTemplate_1;
|
||||
public static String OpenMapInEditorHandler_1;
|
||||
public static String OpenMapInEditorHandler_4;
|
||||
public static String PreprocessorUtils_12;
|
||||
public static String ProjectUtils_0;
|
||||
public static String ProjectUtils_4;
|
||||
public static String ProjectUtils_6;
|
||||
public static String ReloadFilesHandler_0;
|
||||
public static String ResourceUtils_5;
|
||||
public static String ScenarioNewWizard_0;
|
||||
public static String ScenarioNewWizard_2;
|
||||
public static String ScenarioNewWizard_20;
|
||||
public static String ScenarioNewWizard_5;
|
||||
public static String ScenarioPage0_1;
|
||||
public static String ScenarioPage0_10;
|
||||
public static String ScenarioPage0_11;
|
||||
public static String ScenarioPage0_12;
|
||||
public static String ScenarioPage0_14;
|
||||
public static String ScenarioPage0_15;
|
||||
public static String ScenarioPage0_16;
|
||||
public static String ScenarioPage0_18;
|
||||
public static String ScenarioPage0_19;
|
||||
public static String ScenarioPage0_2;
|
||||
public static String ScenarioPage0_20;
|
||||
public static String ScenarioPage0_22;
|
||||
public static String ScenarioPage0_23;
|
||||
public static String ScenarioPage0_26;
|
||||
public static String ScenarioPage0_3;
|
||||
public static String ScenarioPage0_4;
|
||||
public static String ScenarioPage0_5;
|
||||
public static String ScenarioPage0_6;
|
||||
public static String ScenarioPage0_7;
|
||||
public static String ScenarioPage0_8;
|
||||
public static String ScenarioPage0_9;
|
||||
public static String ScenarioPage1_1;
|
||||
public static String ScenarioPage1_2;
|
||||
public static String ScenarioPage1_3;
|
||||
public static String ScenarioPage2_1;
|
||||
public static String ScenarioPage2_2;
|
||||
public static String ScenarioPage2_3;
|
||||
public static String ScenarioPage2_4;
|
||||
public static String UploadAddon_0;
|
||||
public static String UploadAddon_1;
|
||||
public static String WesnothInstallsPage_0;
|
||||
public static String WesnothInstallsPage_10;
|
||||
public static String WesnothInstallsPage_11;
|
||||
public static String WesnothInstallsPage_12;
|
||||
public static String WesnothInstallsPage_13;
|
||||
public static String WesnothInstallsPage_19;
|
||||
public static String WesnothInstallsPage_20;
|
||||
public static String WesnothInstallsPage_21;
|
||||
public static String WesnothInstallsPage_5;
|
||||
public static String WesnothInstallsPage_6;
|
||||
public static String WesnothInstallsPage_7;
|
||||
public static String WesnothInstallsPage_8;
|
||||
public static String WesnothInstallsPage_9;
|
||||
public static String WesnothInstallsUtils_1;
|
||||
public static String WesnothPreferencesPage_0;
|
||||
public static String WesnothPreferencesPage_10;
|
||||
public static String WesnothPreferencesPage_11;
|
||||
public static String WesnothPreferencesPage_12;
|
||||
public static String WesnothPreferencesPage_13;
|
||||
public static String WesnothPreferencesPage_14;
|
||||
public static String WesnothPreferencesPage_24;
|
||||
public static String WesnothPreferencesPage_5;
|
||||
public static String WesnothPreferencesPage_6;
|
||||
public static String WesnothPreferencesPage_7;
|
||||
public static String WesnothPreferencesPage_8;
|
||||
public static String WesnothPreferencesPage_9;
|
||||
public static String WesnothProjectBuilder_1;
|
||||
public static String WesnothProjectBuilder_13;
|
||||
public static String WesnothProjectBuilder_19;
|
||||
public static String WesnothProjectBuilder_22;
|
||||
public static String WesnothProjectBuilder_3;
|
||||
public static String WesnothProjectBuilder_6;
|
||||
public static String WesnothProjectBuilder_7;
|
||||
public static String WesnothProjectBuilder_8;
|
||||
public static String WesnothProjectPage_0;
|
||||
public static String WesnothProjectPage_1;
|
||||
public static String WesnothProjectPage_2;
|
||||
public static String WesnothProjectReport_0;
|
||||
public static String WesnothProjectReport_4;
|
||||
public static String WizardGeneratorPage404_1;
|
||||
public static String WizardGeneratorPage404_3;
|
||||
public static String WizardGeneratorPage404_4;
|
||||
public static String WizardGeneratorPage404_5;
|
||||
public static String WizardGeneratorPageKey_0;
|
||||
public static String WizardGeneratorPageKey_1;
|
||||
public static String WizardGeneratorPageKey_22;
|
||||
public static String WizardGeneratorPageTag_0;
|
||||
public static String WizardGeneratorPageTag_1;
|
||||
public static String WizardGeneratorPageTag_12;
|
||||
public static String WizardGeneratorPageTag_13;
|
||||
public static String WizardGeneratorPageTag_14;
|
||||
public static String WizardGeneratorPageTag_4;
|
||||
public static String WizardGeneratorPageTag_7;
|
||||
public static String WizardLauncher_0;
|
||||
public static String WizardLauncher_1;
|
||||
public static String WizardLauncher_2;
|
||||
public static String WizardLauncher_3;
|
||||
public static String WizardLauncherPage0_1;
|
||||
public static String WizardLauncherPage0_10;
|
||||
public static String WizardLauncherPage0_11;
|
||||
public static String WizardLauncherPage0_12;
|
||||
public static String WizardLauncherPage0_13;
|
||||
public static String WizardLauncherPage0_15;
|
||||
public static String WizardLauncherPage0_16;
|
||||
public static String WizardLauncherPage0_17;
|
||||
public static String WizardLauncherPage0_18;
|
||||
public static String WizardLauncherPage0_19;
|
||||
public static String WizardLauncherPage0_2;
|
||||
public static String WizardLauncherPage0_3;
|
||||
public static String WizardLauncherPage0_4;
|
||||
public static String WizardLauncherPage0_5;
|
||||
public static String WizardLauncherPage0_6;
|
||||
public static String WizardLauncherPage0_7;
|
||||
public static String WizardLauncherPage0_8;
|
||||
public static String WizardLauncherPage1_1;
|
||||
public static String WizardLauncherPage1_11;
|
||||
public static String WizardLauncherPage1_12;
|
||||
public static String WizardLauncherPage1_13;
|
||||
public static String WizardLauncherPage1_14;
|
||||
public static String WizardLauncherPage1_2;
|
||||
public static String WizardLauncherPage1_7;
|
||||
public static String WMLJavaValidator_0;
|
||||
public static String WMLJavaValidator_1;
|
||||
public static String WMLJavaValidator_2;
|
||||
public static String WMLTools_28;
|
||||
public static String WMLTools_29;
|
||||
public static String WMLTools_42;
|
||||
public static String WMLTools_45;
|
||||
public static String WMLTools_47;
|
||||
public static String WMLToolsPreferencePage_0;
|
||||
public static String WMLToolsPreferencePage_1;
|
||||
public static String WMLToolsPreferencePage_10;
|
||||
public static String WMLToolsPreferencePage_11;
|
||||
public static String WMLToolsPreferencePage_12;
|
||||
public static String WMLToolsPreferencePage_2;
|
||||
public static String WMLToolsPreferencePage_3;
|
||||
public static String WMLToolsPreferencePage_5;
|
||||
public static String WMLToolsPreferencePage_6;
|
||||
public static String WMLToolsPreferencePage_7;
|
||||
public static String WMLToolsPreferencePage_9;
|
||||
public static String WorkspaceUtils_13;
|
||||
public static String WorkspaceUtils_18;
|
||||
public static String WorkspaceUtils_20;
|
||||
public static String WorkspaceUtils_22;
|
||||
public static String WorkspaceUtils_25;
|
||||
public static String WorkspaceUtils_29;
|
||||
public static String WorkspaceUtils_30;
|
||||
public static String WorkspaceUtils_33;
|
||||
public static String WorkspaceUtils_7;
|
||||
public static String WorkspaceUtils_9;
|
||||
static {
|
||||
// initialize resource bundle
|
||||
NLS.initializeMessages( BUNDLE_NAME, Messages.class );
|
||||
}
|
||||
|
||||
private Messages()
|
||||
{
|
||||
}
|
||||
private Messages( )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,23 +9,24 @@
|
|||
package org.wesnoth;
|
||||
|
||||
import org.antlr.runtime.CharStream;
|
||||
|
||||
import org.wesnoth.parser.antlr.internal.InternalWMLLexer;
|
||||
|
||||
public class WMLLexer extends InternalWMLLexer
|
||||
{
|
||||
public WMLLexer()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public WMLLexer(CharStream input)
|
||||
{
|
||||
super(input);
|
||||
public WMLLexer( )
|
||||
{
|
||||
super( );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCharStream(CharStream arg0)
|
||||
{
|
||||
super.setCharStream(arg0);
|
||||
}
|
||||
public WMLLexer( CharStream input )
|
||||
{
|
||||
super( input );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCharStream( CharStream arg0 )
|
||||
{
|
||||
super.setCharStream( arg0 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,12 +11,14 @@ package org.wesnoth;
|
|||
import org.eclipse.xtext.parser.antlr.Lexer;
|
||||
|
||||
/**
|
||||
* Use this class to register components to be used at runtime / without the Equinox extension registry.
|
||||
* Use this class to register components to be used at runtime / without the
|
||||
* Equinox extension registry.
|
||||
*/
|
||||
public class WMLRuntimeModule extends org.wesnoth.AbstractWMLRuntimeModule {
|
||||
@Override
|
||||
public Class<? extends Lexer> bindLexer()
|
||||
{
|
||||
return WMLLexer.class;
|
||||
}
|
||||
public class WMLRuntimeModule extends org.wesnoth.AbstractWMLRuntimeModule
|
||||
{
|
||||
@Override
|
||||
public Class< ? extends Lexer > bindLexer( )
|
||||
{
|
||||
return WMLLexer.class;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,10 +16,10 @@ import org.wesnoth.schema.SchemaParser;
|
|||
*/
|
||||
public class WMLStandaloneSetup extends WMLStandaloneSetupGenerated
|
||||
{
|
||||
public static void doSetup() {
|
||||
new WMLStandaloneSetup().createInjectorAndDoEMFRegistration();
|
||||
public static void doSetup( )
|
||||
{
|
||||
new WMLStandaloneSetup( ).createInjectorAndDoEMFRegistration( );
|
||||
|
||||
SchemaParser.reloadSchemas( false );
|
||||
}
|
||||
SchemaParser.reloadSchemas( false );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@ package org.wesnoth;
|
|||
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.wizard.WizardDialog;
|
||||
|
@ -17,7 +19,7 @@ import org.eclipse.swt.widgets.Display;
|
|||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
import org.wesnoth.preprocessor.PreprocessorUtils;
|
||||
import org.wesnoth.projects.ProjectCache;
|
||||
import org.wesnoth.projects.ProjectUtils;
|
||||
|
@ -28,84 +30,84 @@ import org.wesnoth.utils.WorkspaceUtils;
|
|||
*/
|
||||
public class WesnothPlugin extends AbstractUIPlugin
|
||||
{
|
||||
// The shared instance
|
||||
private static WesnothPlugin plugin;
|
||||
// The shared instance
|
||||
private static WesnothPlugin plugin;
|
||||
|
||||
/**
|
||||
* The constructor
|
||||
*/
|
||||
public WesnothPlugin() {
|
||||
}
|
||||
/**
|
||||
* The constructor
|
||||
*/
|
||||
public WesnothPlugin( )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(BundleContext context) throws Exception
|
||||
{
|
||||
super.start(context);
|
||||
plugin = this;
|
||||
Logger.getInstance().startLogger();
|
||||
@Override
|
||||
public void start( BundleContext context ) throws Exception
|
||||
{
|
||||
super.start( context );
|
||||
plugin = this;
|
||||
Logger.getInstance( ).startLogger( );
|
||||
|
||||
if (PlatformUI.isWorkbenchRunning()){
|
||||
if (WorkspaceUtils.checkPathsAreSet( null, false) == false)
|
||||
{
|
||||
Display.getDefault().asyncExec(new Runnable() {
|
||||
if( PlatformUI.isWorkbenchRunning( ) ) {
|
||||
if( WorkspaceUtils.checkPathsAreSet( null, false ) == false ) {
|
||||
Display.getDefault( ).asyncExec( new Runnable( ) {
|
||||
@Override
|
||||
public void run()
|
||||
public void run( )
|
||||
{
|
||||
WorkspaceUtils.setupWorkspace(true);
|
||||
WorkspaceUtils.setupWorkspace( true );
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
WizardDialog.setDialogHelpAvailable( true );
|
||||
}
|
||||
WizardDialog.setDialogHelpAvailable( true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop(BundleContext context) throws Exception
|
||||
{
|
||||
// save the caches of the projects on disk
|
||||
for(Entry<IProject, ProjectCache> cache :
|
||||
ProjectUtils.getProjectCaches().entrySet())
|
||||
{
|
||||
cache.getValue().saveCache();
|
||||
}
|
||||
PreprocessorUtils.getInstance().saveTimestamps();
|
||||
@Override
|
||||
public void stop( BundleContext context ) throws Exception
|
||||
{
|
||||
// save the caches of the projects on disk
|
||||
for( Entry< IProject, ProjectCache > cache: ProjectUtils
|
||||
.getProjectCaches( ).entrySet( ) ) {
|
||||
cache.getValue( ).saveCache( );
|
||||
}
|
||||
PreprocessorUtils.getInstance( ).saveTimestamps( );
|
||||
|
||||
Logger.getInstance().stopLogger();
|
||||
Logger.getInstance( ).stopLogger( );
|
||||
|
||||
plugin = null;
|
||||
super.stop(context);
|
||||
}
|
||||
plugin = null;
|
||||
super.stop( context );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the shared instance
|
||||
*
|
||||
* @return the shared instance
|
||||
*/
|
||||
public static WesnothPlugin getDefault()
|
||||
{
|
||||
return plugin;
|
||||
}
|
||||
/**
|
||||
* Returns the shared instance
|
||||
*
|
||||
* @return the shared instance
|
||||
*/
|
||||
public static WesnothPlugin getDefault( )
|
||||
{
|
||||
return plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an image descriptor for the image file at the given plug-in
|
||||
* relative path
|
||||
*
|
||||
* @param path the path
|
||||
* @return the image descriptor
|
||||
*/
|
||||
public static ImageDescriptor getImageDescriptor(String path)
|
||||
{
|
||||
return imageDescriptorFromPlugin(Constants.PLUGIN_ID, path);
|
||||
}
|
||||
/**
|
||||
* Returns an image descriptor for the image file at the given plug-in
|
||||
* relative path
|
||||
*
|
||||
* @param path
|
||||
* the path
|
||||
* @return the image descriptor
|
||||
*/
|
||||
public static ImageDescriptor getImageDescriptor( String path )
|
||||
{
|
||||
return imageDescriptorFromPlugin( Constants.PLUGIN_ID, path );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the plugin's shell
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Shell getShell()
|
||||
{
|
||||
return plugin.getWorkbench().getDisplay().getActiveShell();
|
||||
}
|
||||
/**
|
||||
* Returns the plugin's shell
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Shell getShell( )
|
||||
{
|
||||
return plugin.getWorkbench( ).getDisplay( ).getActiveShell( );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,16 +9,17 @@
|
|||
package org.wesnoth.action;
|
||||
|
||||
import org.eclipse.jface.action.IAction;
|
||||
|
||||
import org.wesnoth.utils.MapUtils;
|
||||
|
||||
public class ImportMap extends ObjectActionDelegate
|
||||
{
|
||||
/**
|
||||
* This method is runned *ONLY* if the user selected a "maps" folder
|
||||
*/
|
||||
@Override
|
||||
public void run(IAction action)
|
||||
{
|
||||
MapUtils.importMap();
|
||||
}
|
||||
/**
|
||||
* This method is runned *ONLY* if the user selected a "maps" folder
|
||||
*/
|
||||
@Override
|
||||
public void run( IAction action )
|
||||
{
|
||||
MapUtils.importMap( );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,21 +16,21 @@ import org.eclipse.ui.IWorkbenchPart;
|
|||
|
||||
public abstract class ObjectActionDelegate implements IObjectActionDelegate
|
||||
{
|
||||
protected ISelection selection_;
|
||||
protected IStructuredSelection structuredSelection_;
|
||||
protected IAction action_;
|
||||
protected ISelection selection_;
|
||||
protected IStructuredSelection structuredSelection_;
|
||||
protected IAction action_;
|
||||
|
||||
@Override
|
||||
public void selectionChanged(IAction action, ISelection selection)
|
||||
{
|
||||
selection_ = selection;
|
||||
action_ = action;
|
||||
if (selection instanceof IStructuredSelection)
|
||||
structuredSelection_ = (IStructuredSelection)selection;
|
||||
}
|
||||
@Override
|
||||
public void selectionChanged( IAction action, ISelection selection )
|
||||
{
|
||||
selection_ = selection;
|
||||
action_ = action;
|
||||
if( selection instanceof IStructuredSelection )
|
||||
structuredSelection_ = ( IStructuredSelection ) selection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActivePart(IAction action, IWorkbenchPart targetPart)
|
||||
{
|
||||
}
|
||||
@Override
|
||||
public void setActivePart( IAction action, IWorkbenchPart targetPart )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,14 +9,15 @@
|
|||
package org.wesnoth.action;
|
||||
|
||||
import org.eclipse.jface.action.IAction;
|
||||
|
||||
import org.wesnoth.utils.GameUtils;
|
||||
|
||||
|
||||
public class OpenCampaignInGame extends ObjectActionDelegate
|
||||
{
|
||||
@Override
|
||||
public void run(IAction action)
|
||||
{
|
||||
GameUtils.runCampaign();
|
||||
}
|
||||
@Override
|
||||
public void run( IAction action )
|
||||
{
|
||||
GameUtils.runCampaign( );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,15 +9,16 @@
|
|||
package org.wesnoth.action;
|
||||
|
||||
import org.eclipse.jface.action.IAction;
|
||||
|
||||
import org.wesnoth.utils.GameUtils;
|
||||
import org.wesnoth.utils.WorkspaceUtils;
|
||||
|
||||
|
||||
public class OpenMapInEditor extends ObjectActionDelegate
|
||||
{
|
||||
@Override
|
||||
public void run(IAction action)
|
||||
{
|
||||
GameUtils.startEditor(WorkspaceUtils.getSelectedFile());
|
||||
}
|
||||
@Override
|
||||
public void run( IAction action )
|
||||
{
|
||||
GameUtils.startEditor( WorkspaceUtils.getSelectedFile( ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,14 +9,15 @@
|
|||
package org.wesnoth.action;
|
||||
|
||||
import org.eclipse.jface.action.IAction;
|
||||
|
||||
import org.wesnoth.utils.GameUtils;
|
||||
|
||||
|
||||
public class OpenScenarioInGame extends ObjectActionDelegate
|
||||
{
|
||||
@Override
|
||||
public void run(IAction action)
|
||||
{
|
||||
GameUtils.runScenario();
|
||||
}
|
||||
@Override
|
||||
public void run( IAction action )
|
||||
{
|
||||
GameUtils.runScenario( );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import org.eclipse.core.resources.IResource;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
|
||||
import org.wesnoth.Logger;
|
||||
import org.wesnoth.templates.ReplaceableParameter;
|
||||
import org.wesnoth.templates.TemplateProvider;
|
||||
|
@ -16,34 +17,36 @@ import org.wesnoth.utils.ResourceUtils;
|
|||
|
||||
public class RegenerateBuildFiles extends ObjectActionDelegate
|
||||
{
|
||||
public RegenerateBuildFiles() { }
|
||||
public RegenerateBuildFiles( )
|
||||
{
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public void run(IAction action)
|
||||
{
|
||||
if (structuredSelection_ == null)
|
||||
return;
|
||||
@SuppressWarnings( "rawtypes" )
|
||||
@Override
|
||||
public void run( IAction action )
|
||||
{
|
||||
if( structuredSelection_ == null )
|
||||
return;
|
||||
|
||||
for (Iterator it = structuredSelection_.iterator(); it.hasNext();)
|
||||
{
|
||||
Object element = it.next();
|
||||
if (element instanceof IProject)
|
||||
{
|
||||
ArrayList<ReplaceableParameter> param = new ArrayList<ReplaceableParameter>();
|
||||
param.add(new ReplaceableParameter("$$project_name", (((IProject)element).getName()))); //$NON-NLS-1$
|
||||
param.add(new ReplaceableParameter("$$project_dir_name", ((IProject)element).getName())); //$NON-NLS-1$
|
||||
ResourceUtils.createFile((IProject)element, "build.xml", //$NON-NLS-1$
|
||||
TemplateProvider.getInstance().getProcessedTemplate("build_xml", param), true); //$NON-NLS-1$
|
||||
try
|
||||
{
|
||||
((IProject)element).refreshLocal(IResource.DEPTH_ONE, new NullProgressMonitor());
|
||||
}
|
||||
catch (CoreException e)
|
||||
{
|
||||
Logger.getInstance().logException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for( Iterator it = structuredSelection_.iterator( ); it.hasNext( ); ) {
|
||||
Object element = it.next( );
|
||||
if( element instanceof IProject ) {
|
||||
ArrayList< ReplaceableParameter > param = new ArrayList< ReplaceableParameter >( );
|
||||
param.add( new ReplaceableParameter(
|
||||
"$$project_name", ( ( ( IProject ) element ).getName( ) ) ) ); //$NON-NLS-1$
|
||||
param.add( new ReplaceableParameter(
|
||||
"$$project_dir_name", ( ( IProject ) element ).getName( ) ) ); //$NON-NLS-1$
|
||||
ResourceUtils.createFile( ( IProject ) element,
|
||||
"build.xml", //$NON-NLS-1$
|
||||
TemplateProvider.getInstance( ).getProcessedTemplate(
|
||||
"build_xml", param ), true ); //$NON-NLS-1$
|
||||
try {
|
||||
( ( IProject ) element ).refreshLocal( IResource.DEPTH_ONE,
|
||||
new NullProgressMonitor( ) );
|
||||
} catch( CoreException e ) {
|
||||
Logger.getInstance( ).logException( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,15 +9,16 @@
|
|||
package org.wesnoth.action;
|
||||
|
||||
import org.eclipse.jface.action.IAction;
|
||||
|
||||
import org.wesnoth.utils.WMLTools;
|
||||
import org.wesnoth.utils.WMLTools.Tools;
|
||||
|
||||
|
||||
public class RunWMLIndentOnSelection extends ObjectActionDelegate
|
||||
{
|
||||
@Override
|
||||
public void run(IAction action)
|
||||
{
|
||||
WMLTools.runWMLToolAsWorkspaceJob(Tools.WMLINDENT, null);
|
||||
}
|
||||
@Override
|
||||
public void run( IAction action )
|
||||
{
|
||||
WMLTools.runWMLToolAsWorkspaceJob( Tools.WMLINDENT, null );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,15 +9,16 @@
|
|||
package org.wesnoth.action;
|
||||
|
||||
import org.eclipse.jface.action.IAction;
|
||||
|
||||
import org.wesnoth.utils.WMLTools;
|
||||
import org.wesnoth.utils.WMLTools.Tools;
|
||||
|
||||
|
||||
public class RunWMLLintOnSelection extends ObjectActionDelegate
|
||||
{
|
||||
@Override
|
||||
public void run(IAction action)
|
||||
{
|
||||
WMLTools.runWMLToolAsWorkspaceJob(Tools.WMLLINT, null);
|
||||
}
|
||||
@Override
|
||||
public void run( IAction action )
|
||||
{
|
||||
WMLTools.runWMLToolAsWorkspaceJob( Tools.WMLLINT, null );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,15 +9,16 @@
|
|||
package org.wesnoth.action;
|
||||
|
||||
import org.eclipse.jface.action.IAction;
|
||||
|
||||
import org.wesnoth.utils.WMLTools;
|
||||
import org.wesnoth.utils.WMLTools.Tools;
|
||||
|
||||
|
||||
public class RunWMLScopeOnSelection extends ObjectActionDelegate
|
||||
{
|
||||
@Override
|
||||
public void run(IAction action)
|
||||
{
|
||||
WMLTools.runWMLToolAsWorkspaceJob(Tools.WMLSCOPE, null);
|
||||
}
|
||||
@Override
|
||||
public void run( IAction action )
|
||||
{
|
||||
WMLTools.runWMLToolAsWorkspaceJob( Tools.WMLSCOPE, null );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,17 +9,18 @@
|
|||
package org.wesnoth.action;
|
||||
|
||||
import org.eclipse.jface.action.IAction;
|
||||
|
||||
import org.wesnoth.preprocessor.PreprocessorUtils;
|
||||
import org.wesnoth.utils.WorkspaceUtils;
|
||||
|
||||
|
||||
public class ShowPlainPreprocessedConfig extends ObjectActionDelegate
|
||||
{
|
||||
@Override
|
||||
public void run(IAction action)
|
||||
{
|
||||
PreprocessorUtils.getInstance().openPreprocessedFileInEditor(
|
||||
WorkspaceUtils.getSelectedFile(WorkspaceUtils.getWorkbenchWindow()),
|
||||
true);
|
||||
}
|
||||
@Override
|
||||
public void run( IAction action )
|
||||
{
|
||||
PreprocessorUtils.getInstance( ).openPreprocessedFileInEditor(
|
||||
WorkspaceUtils.getSelectedFile( WorkspaceUtils
|
||||
.getWorkbenchWindow( ) ), true );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,15 +9,17 @@
|
|||
package org.wesnoth.action;
|
||||
|
||||
import org.eclipse.jface.action.IAction;
|
||||
|
||||
import org.wesnoth.preprocessor.PreprocessorUtils;
|
||||
import org.wesnoth.utils.WorkspaceUtils;
|
||||
|
||||
|
||||
public class ShowPreprocessedConfig extends ObjectActionDelegate
|
||||
{
|
||||
@Override
|
||||
public void run(IAction action)
|
||||
{
|
||||
PreprocessorUtils.getInstance().openPreprocessedFileInEditor(WorkspaceUtils.getSelectedFile(), false);
|
||||
}
|
||||
@Override
|
||||
public void run( IAction action )
|
||||
{
|
||||
PreprocessorUtils.getInstance( ).openPreprocessedFileInEditor(
|
||||
WorkspaceUtils.getSelectedFile( ), false );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,9 +15,10 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
|||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||
import org.wesnoth.WesnothPlugin;
|
||||
|
||||
import org.wesnoth.Logger;
|
||||
import org.wesnoth.Messages;
|
||||
import org.wesnoth.WesnothPlugin;
|
||||
import org.wesnoth.utils.GUIUtils;
|
||||
import org.wesnoth.utils.WMLTools;
|
||||
import org.wesnoth.utils.WorkspaceUtils;
|
||||
|
@ -25,33 +26,34 @@ import org.wesnoth.utils.WorkspaceUtils;
|
|||
|
||||
public class UploadAddon extends ObjectActionDelegate
|
||||
{
|
||||
@Override
|
||||
public void run(IAction action)
|
||||
{
|
||||
final String fullPath = WorkspaceUtils.getSelectedResource().getLocation().toOSString();
|
||||
ProgressMonitorDialog dialog = new ProgressMonitorDialog(WesnothPlugin.getShell());
|
||||
try
|
||||
{
|
||||
dialog.run(false, false, new IRunnableWithProgress() {
|
||||
@Override
|
||||
public void run(IProgressMonitor monitor)
|
||||
throws InvocationTargetException, InterruptedException
|
||||
{
|
||||
monitor.beginTask(Messages.UploadAddon_0, 50);
|
||||
monitor.worked(10);
|
||||
OutputStream consoleStream = GUIUtils.
|
||||
createConsole(Messages.UploadAddon_1, null, true).newOutputStream();
|
||||
WMLTools.uploadWesnothAddon(fullPath,
|
||||
new OutputStream[] { consoleStream }, new OutputStream[] { consoleStream });
|
||||
monitor.worked(40);
|
||||
monitor.done();
|
||||
}
|
||||
});
|
||||
} catch (InvocationTargetException e)
|
||||
{
|
||||
Logger.getInstance().logException(e);
|
||||
} catch (InterruptedException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void run( IAction action )
|
||||
{
|
||||
final String fullPath = WorkspaceUtils.getSelectedResource( )
|
||||
.getLocation( ).toOSString( );
|
||||
ProgressMonitorDialog dialog = new ProgressMonitorDialog(
|
||||
WesnothPlugin.getShell( ) );
|
||||
try {
|
||||
dialog.run( false, false, new IRunnableWithProgress( ) {
|
||||
@Override
|
||||
public void run( IProgressMonitor monitor )
|
||||
throws InvocationTargetException, InterruptedException
|
||||
{
|
||||
monitor.beginTask( Messages.UploadAddon_0, 50 );
|
||||
monitor.worked( 10 );
|
||||
OutputStream consoleStream = GUIUtils.createConsole(
|
||||
Messages.UploadAddon_1, null, true )
|
||||
.newOutputStream( );
|
||||
WMLTools.uploadWesnothAddon( fullPath,
|
||||
new OutputStream[] { consoleStream },
|
||||
new OutputStream[] { consoleStream } );
|
||||
monitor.worked( 40 );
|
||||
monitor.done( );
|
||||
}
|
||||
} );
|
||||
} catch( InvocationTargetException e ) {
|
||||
Logger.getInstance( ).logException( e );
|
||||
} catch( InterruptedException e ) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import java.io.File;
|
|||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
|
||||
import org.wesnoth.Messages;
|
||||
import org.wesnoth.utils.GUIUtils;
|
||||
import org.wesnoth.utils.WorkspaceUtils;
|
||||
|
@ -20,41 +21,44 @@ import org.wesnoth.utils.WorkspaceUtils;
|
|||
|
||||
public class WesnothProjectReport extends ObjectActionDelegate
|
||||
{
|
||||
@Override
|
||||
public void run(IAction action)
|
||||
{
|
||||
IProject project = WorkspaceUtils.getSelectedProject();
|
||||
if (project == null)
|
||||
{
|
||||
GUIUtils.showWarnMessageBox(Messages.WesnothProjectReport_0);
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public void run( IAction action )
|
||||
{
|
||||
IProject project = WorkspaceUtils.getSelectedProject( );
|
||||
if( project == null ) {
|
||||
GUIUtils.showWarnMessageBox( Messages.WesnothProjectReport_0 );
|
||||
return;
|
||||
}
|
||||
|
||||
GUIUtils.showInfoMessageBox(getReportForContainer(project));
|
||||
}
|
||||
GUIUtils.showInfoMessageBox( getReportForContainer( project ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the report for specified container (sceanarios, maps, units)
|
||||
* @param container
|
||||
* @return
|
||||
*/
|
||||
private String getReportForContainer(IContainer container)
|
||||
{
|
||||
int[] statistics = new int[3];
|
||||
/**
|
||||
* Gets the report for specified container (sceanarios, maps, units)
|
||||
*
|
||||
* @param container
|
||||
* @return
|
||||
*/
|
||||
private String getReportForContainer( IContainer container )
|
||||
{
|
||||
int[] statistics = new int[3];
|
||||
|
||||
File scenariosFolder = new File(container.getLocation().toOSString() + "/scenarios"); //$NON-NLS-1$
|
||||
if (scenariosFolder.exists())
|
||||
statistics[0] = scenariosFolder.listFiles().length;
|
||||
File scenariosFolder = new File( container.getLocation( ).toOSString( )
|
||||
+ "/scenarios" ); //$NON-NLS-1$
|
||||
if( scenariosFolder.exists( ) )
|
||||
statistics[0] = scenariosFolder.listFiles( ).length;
|
||||
|
||||
File mapsFolder = new File(container.getLocation().toOSString() + "/maps"); //$NON-NLS-1$
|
||||
if (mapsFolder.exists())
|
||||
statistics[1] = mapsFolder.listFiles().length;
|
||||
File mapsFolder = new File( container.getLocation( ).toOSString( )
|
||||
+ "/maps" ); //$NON-NLS-1$
|
||||
if( mapsFolder.exists( ) )
|
||||
statistics[1] = mapsFolder.listFiles( ).length;
|
||||
|
||||
File unitsFolder = new File(container.getLocation().toOSString() + "/units"); //$NON-NLS-1$
|
||||
if (unitsFolder.exists())
|
||||
statistics[2] = unitsFolder.listFiles().length;
|
||||
File unitsFolder = new File( container.getLocation( ).toOSString( )
|
||||
+ "/units" ); //$NON-NLS-1$
|
||||
if( unitsFolder.exists( ) )
|
||||
statistics[2] = unitsFolder.listFiles( ).length;
|
||||
|
||||
return String.format(Messages.WesnothProjectReport_4,
|
||||
statistics[0],statistics[1], statistics[2]);
|
||||
}
|
||||
return String.format( Messages.WesnothProjectReport_4, statistics[0],
|
||||
statistics[1], statistics[2] );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.eclipse.core.resources.IFile;
|
|||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
import org.wesnoth.Logger;
|
||||
import org.wesnoth.utils.ResourceUtils;
|
||||
import org.wesnoth.utils.ResourceUtils.WMLFilesComparator;
|
||||
|
@ -29,18 +30,18 @@ import org.wesnoth.utils.StringUtils;
|
|||
|
||||
public class DependencyListBuilder implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 6007509520015856611L;
|
||||
private static final long serialVersionUID = 6007509520015856611L;
|
||||
/**
|
||||
* The key by which the root node of the list is memorized
|
||||
* in the list.
|
||||
*/
|
||||
public static final String ROOT_NODE_KEY = "_ROOT_";
|
||||
public static final String ROOT_NODE_KEY = "_ROOT_";
|
||||
|
||||
private transient IProject project_;
|
||||
private transient IProject project_;
|
||||
|
||||
private boolean isCreated_;
|
||||
private int currentIndex_;
|
||||
private DependencyListNode previous_;
|
||||
private boolean isCreated_;
|
||||
private int currentIndex_;
|
||||
private DependencyListNode previous_;
|
||||
|
||||
private Map< String, DependencyListNode > list_;
|
||||
|
||||
|
@ -49,15 +50,15 @@ public class DependencyListBuilder implements Serializable
|
|||
* (that is, they don't have a _main.cfg in them) and
|
||||
* the value is the first node in that directory existing in the list
|
||||
*/
|
||||
private List< String > directories_;
|
||||
private List< ListDirectoryEntry > directoriesEntries_;
|
||||
private List< String > directories_;
|
||||
private List< ListDirectoryEntry > directoriesEntries_;
|
||||
|
||||
public DependencyListBuilder( IProject project )
|
||||
{
|
||||
list_ = new HashMap<String, DependencyListNode>();
|
||||
directories_ = new ArrayList<String>();
|
||||
list_ = new HashMap< String, DependencyListNode >( );
|
||||
directories_ = new ArrayList< String >( );
|
||||
|
||||
directoriesEntries_ = new ArrayList<ListDirectoryEntry>();
|
||||
directoriesEntries_ = new ArrayList< ListDirectoryEntry >( );
|
||||
|
||||
previous_ = null;
|
||||
|
||||
|
@ -68,14 +69,17 @@ public class DependencyListBuilder implements Serializable
|
|||
|
||||
/**
|
||||
* Create the whole dependency list from scratch.
|
||||
* @param force True for force re-creating the list even if it
|
||||
* was previously created
|
||||
*
|
||||
* @param force
|
||||
* True for force re-creating the list even if it
|
||||
* was previously created
|
||||
*/
|
||||
public void createDependencyList( boolean force )
|
||||
{
|
||||
if ( isCreated_ && !force ) {
|
||||
Logger.getInstance( ).log( "Skipping depedency list for project " +
|
||||
project_.getName( ) );
|
||||
if( isCreated_ && ! force ) {
|
||||
Logger.getInstance( )
|
||||
.log( "Skipping depedency list for project "
|
||||
+ project_.getName( ) );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -91,18 +95,21 @@ public class DependencyListBuilder implements Serializable
|
|||
|
||||
/**
|
||||
* Adds a new node in the PDL
|
||||
* @param file The file to add
|
||||
*
|
||||
* @param file
|
||||
* The file to add
|
||||
* @return The newly created node
|
||||
*/
|
||||
public DependencyListNode addNode( IFile file )
|
||||
{
|
||||
//TODO: create better heuristics for the indexes
|
||||
// TODO: create better heuristics for the indexes
|
||||
// in case we need to add multiple subsequent files...
|
||||
DependencyListNode backupPrevious = previous_, newNode = null;
|
||||
String fileParentProjectPath = file.getParent( ).getProjectRelativePath( ).toString( );
|
||||
String fileParentProjectPath = file.getParent( )
|
||||
.getProjectRelativePath( ).toString( );
|
||||
|
||||
// we add a file in an existing processed directory.
|
||||
if ( directories_.contains( fileParentProjectPath ) ) {
|
||||
if( directories_.contains( fileParentProjectPath ) ) {
|
||||
|
||||
int dirEntryIndex = directories_.indexOf( fileParentProjectPath );
|
||||
|
||||
|
@ -110,14 +117,15 @@ public class DependencyListBuilder implements Serializable
|
|||
DependencyListNode tmpNode = entry.FirstNode;
|
||||
|
||||
// had any files in dir?
|
||||
if ( tmpNode != null ) {
|
||||
if( tmpNode != null ) {
|
||||
String fileName = file.getName( );
|
||||
|
||||
/* check if the file is _main.cfg. If yes,
|
||||
/*
|
||||
* check if the file is _main.cfg. If yes,
|
||||
* all current nodes from this directory need to be erased
|
||||
* and processed by the includes from other _main.cfg
|
||||
*/
|
||||
if ( fileName.equals( "_main.cfg" ) ) {
|
||||
if( fileName.equals( "_main.cfg" ) ) {
|
||||
|
||||
// save the previous
|
||||
previous_ = tmpNode.getPrevious( );
|
||||
|
@ -126,14 +134,15 @@ public class DependencyListBuilder implements Serializable
|
|||
|
||||
// create the node
|
||||
newNode = internal_addNode( file );
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// search for the correct place in current dir
|
||||
DependencyListNode prevTmpNode = null;
|
||||
while ( tmpNode != null ) {
|
||||
while( tmpNode != null ) {
|
||||
|
||||
// we found the place?
|
||||
if ( ResourceUtils.wmlFileNameCompare(
|
||||
tmpNode.getFile( ).getName( ), fileName ) > 0 ) {
|
||||
if( ResourceUtils.wmlFileNameCompare( tmpNode.getFile( )
|
||||
.getName( ), fileName ) > 0 ) {
|
||||
|
||||
previous_ = tmpNode.getPrevious( );
|
||||
|
||||
|
@ -146,18 +155,19 @@ public class DependencyListBuilder implements Serializable
|
|||
}
|
||||
|
||||
// we arrived at the end
|
||||
if ( newNode == null ) {
|
||||
if( newNode == null ) {
|
||||
previous_ = prevTmpNode;
|
||||
newNode = internal_addNode( file );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
|
||||
// previous_ should be the first non-null node in previous
|
||||
// directories.
|
||||
|
||||
while ( dirEntryIndex > 0 && tmpNode == null ) {
|
||||
-- dirEntryIndex;
|
||||
while( dirEntryIndex > 0 && tmpNode == null ) {
|
||||
--dirEntryIndex;
|
||||
tmpNode = directoriesEntries_.get( dirEntryIndex ).FirstNode;
|
||||
}
|
||||
|
||||
|
@ -167,7 +177,8 @@ public class DependencyListBuilder implements Serializable
|
|||
|
||||
// now, parse the file to check if we should include other dirs
|
||||
internal_addContainers( newNode.getIncludes( true ) );
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// didn't found any place to put it. where shall we?
|
||||
// the place should be dictated by other cfg,
|
||||
// by getting the included directory
|
||||
|
@ -181,103 +192,112 @@ public class DependencyListBuilder implements Serializable
|
|||
|
||||
/**
|
||||
* Adds the containers and their contents to the list
|
||||
* @param containerList The list of container paths
|
||||
*
|
||||
* @param containerList
|
||||
* The list of container paths
|
||||
*/
|
||||
private void internal_addContainers( Collection<String> containerList )
|
||||
private void internal_addContainers( Collection< String > containerList )
|
||||
{
|
||||
for ( String container : containerList ) {
|
||||
for( String container: containerList ) {
|
||||
internal_addContainer( container );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the container and it's contents to the list
|
||||
* @param containerPath The path of the container
|
||||
*
|
||||
* @param containerPath
|
||||
* The path of the container
|
||||
*/
|
||||
private void internal_addContainer( String containerPath )
|
||||
{
|
||||
IContainer container = null ;
|
||||
if ( StringUtils.isNullOrEmpty( containerPath ) )
|
||||
IContainer container = null;
|
||||
if( StringUtils.isNullOrEmpty( containerPath ) )
|
||||
container = project_;
|
||||
else
|
||||
container = project_.getFolder( containerPath );
|
||||
|
||||
IResource main_cfg = container.findMember( "_main.cfg" ); //$NON-NLS-1$
|
||||
if ( main_cfg != null ) {
|
||||
if( main_cfg != null ) {
|
||||
// add main.cfg to list
|
||||
DependencyListNode newNode = internal_addNode( (IFile) main_cfg );
|
||||
DependencyListNode newNode = internal_addNode( ( IFile ) main_cfg );
|
||||
|
||||
// add any included containers
|
||||
internal_addContainers( newNode.getIncludes( true ) );
|
||||
}else {
|
||||
}
|
||||
else {
|
||||
// no main.cfg, just follow WML reading rules
|
||||
List<IResource> members = null;
|
||||
List< IResource > members = null;
|
||||
try {
|
||||
members = Arrays.asList( container.members( ) );
|
||||
}
|
||||
catch ( CoreException e ) {
|
||||
} catch( CoreException e ) {
|
||||
Logger.getInstance( ).logException( e );
|
||||
return;
|
||||
}
|
||||
|
||||
Collections.sort( members, new WMLFilesComparator() );
|
||||
Collections.sort( members, new WMLFilesComparator( ) );
|
||||
|
||||
boolean toAddDirectoryEntry = false;
|
||||
if ( ! directories_.contains( containerPath ) ) {
|
||||
if( ! directories_.contains( containerPath ) ) {
|
||||
directories_.add( containerPath );
|
||||
directoriesEntries_.add( new ListDirectoryEntry( containerPath, null, null ) );
|
||||
directoriesEntries_.add( new ListDirectoryEntry( containerPath,
|
||||
null, null ) );
|
||||
|
||||
toAddDirectoryEntry = true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// update the includes
|
||||
directoriesEntries_.get( directoriesEntries_.indexOf( containerPath ) )
|
||||
.Includes ++ ;
|
||||
directoriesEntries_.get( directoriesEntries_
|
||||
.indexOf( containerPath ) ).Includes++;
|
||||
}
|
||||
|
||||
if ( members.isEmpty( ) )
|
||||
if( members.isEmpty( ) )
|
||||
return;
|
||||
|
||||
DependencyListNode firstNewNode = null;
|
||||
DependencyListNode lastNode = null;
|
||||
|
||||
for ( IResource resource : members ) {
|
||||
if ( resource instanceof IContainer )
|
||||
internal_addContainer( resource.getProjectRelativePath( ).toString( ) );
|
||||
for( IResource resource: members ) {
|
||||
if( resource instanceof IContainer )
|
||||
internal_addContainer( resource.getProjectRelativePath( )
|
||||
.toString( ) );
|
||||
else {
|
||||
// just config files.
|
||||
if ( !ResourceUtils.isConfigFile( resource ) )
|
||||
if( ! ResourceUtils.isConfigFile( resource ) )
|
||||
continue;
|
||||
|
||||
lastNode = internal_addNode( ( IFile ) resource );
|
||||
if ( firstNewNode == null )
|
||||
if( firstNewNode == null )
|
||||
firstNewNode = lastNode;
|
||||
}
|
||||
}
|
||||
|
||||
if ( firstNewNode != null && lastNode != null ) {
|
||||
if ( toAddDirectoryEntry ) {
|
||||
if( firstNewNode != null && lastNode != null ) {
|
||||
if( toAddDirectoryEntry ) {
|
||||
// update the first directory node
|
||||
directoriesEntries_.set( directories_.size( ) - 1,
|
||||
new ListDirectoryEntry( containerPath, firstNewNode, lastNode ));
|
||||
} else {
|
||||
new ListDirectoryEntry( containerPath,
|
||||
firstNewNode, lastNode ) );
|
||||
}
|
||||
else {
|
||||
// if the current entry has null nodes
|
||||
// or the indexes are greater/lower than the current ones
|
||||
// we need to update the references nodes
|
||||
|
||||
ListDirectoryEntry entry = directoriesEntries_.get(
|
||||
directories_.indexOf( containerPath ) );
|
||||
ListDirectoryEntry entry = directoriesEntries_
|
||||
.get( directories_.indexOf( containerPath ) );
|
||||
|
||||
if ( entry.FirstNode == null ||
|
||||
( entry.FirstNode != null &&
|
||||
firstNewNode.getIndex( ) < entry.FirstNode.getIndex( ) ) ) {
|
||||
if( entry.FirstNode == null
|
||||
|| ( entry.FirstNode != null && firstNewNode
|
||||
.getIndex( ) < entry.FirstNode.getIndex( ) ) ) {
|
||||
entry.FirstNode = firstNewNode;
|
||||
}
|
||||
|
||||
if ( entry.LastNode == null ||
|
||||
( entry.LastNode != null &&
|
||||
lastNode.getIndex( ) > entry.LastNode.getIndex( ) ) ) {
|
||||
entry.LastNode = lastNode;
|
||||
}
|
||||
if( entry.LastNode == null
|
||||
|| ( entry.LastNode != null && lastNode.getIndex( ) > entry.LastNode
|
||||
.getIndex( ) ) ) {
|
||||
entry.LastNode = lastNode;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -285,46 +305,54 @@ public class DependencyListBuilder implements Serializable
|
|||
|
||||
/**
|
||||
* Adds a new node to this list
|
||||
* @param file The file to add
|
||||
*
|
||||
* @param file
|
||||
* The file to add
|
||||
* @return The newly created node
|
||||
*/
|
||||
private DependencyListNode internal_addNode( IFile file )
|
||||
{
|
||||
DependencyListNode newNode = new DependencyListNode( file, -1 );
|
||||
DependencyListNode newNode = new DependencyListNode( file, - 1 );
|
||||
|
||||
if ( previous_ != null ){
|
||||
if( previous_ != null ) {
|
||||
|
||||
// inserting is done between 2 nodes
|
||||
if ( previous_.getNext( ) != null ) {
|
||||
int newIndex = (previous_.getIndex( ) +
|
||||
previous_.getNext( ).getIndex( )) / 2;
|
||||
if( previous_.getNext( ) != null ) {
|
||||
int newIndex = ( previous_.getIndex( ) + previous_.getNext( )
|
||||
.getIndex( ) ) / 2;
|
||||
|
||||
if ( newIndex > previous_.getIndex( ) + DependencyListNode.INDEX_STEP )
|
||||
newIndex = previous_.getIndex( ) + DependencyListNode.INDEX_STEP ;
|
||||
if( newIndex > previous_.getIndex( )
|
||||
+ DependencyListNode.INDEX_STEP )
|
||||
newIndex = previous_.getIndex( )
|
||||
+ DependencyListNode.INDEX_STEP;
|
||||
|
||||
newNode.setIndex( newIndex);
|
||||
newNode.setIndex( newIndex );
|
||||
|
||||
newNode.setNext( previous_.getNext( ) );
|
||||
previous_.getNext( ).setPrevious( newNode );
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
newNode.setIndex( currentIndex_ );
|
||||
currentIndex_ += DependencyListNode.INDEX_STEP;
|
||||
}
|
||||
|
||||
previous_.setNext( newNode );
|
||||
newNode.setPrevious( previous_ );
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// no previous yet (== null)
|
||||
// so we're making this the root node for this list
|
||||
|
||||
// check if we had a previous root node
|
||||
DependencyListNode root = list_.get( ROOT_NODE_KEY );
|
||||
if ( root != null ) {
|
||||
if( root != null ) {
|
||||
root.setPrevious( newNode );
|
||||
newNode.setNext( root );
|
||||
|
||||
newNode.setIndex( root.getIndex( ) - DependencyListNode.INDEX_STEP );
|
||||
} else {
|
||||
newNode.setIndex( root.getIndex( )
|
||||
- DependencyListNode.INDEX_STEP );
|
||||
}
|
||||
else {
|
||||
newNode.setIndex( currentIndex_ );
|
||||
currentIndex_ += DependencyListNode.INDEX_STEP;
|
||||
}
|
||||
|
@ -339,7 +367,9 @@ public class DependencyListBuilder implements Serializable
|
|||
|
||||
/**
|
||||
* Removes a node specified by the file
|
||||
* @param file The file to remove from the list
|
||||
*
|
||||
* @param file
|
||||
* The file to remove from the list
|
||||
*/
|
||||
public void removeNode( IFile file )
|
||||
{
|
||||
|
@ -348,32 +378,37 @@ public class DependencyListBuilder implements Serializable
|
|||
|
||||
/**
|
||||
* Removes the specified node from the list
|
||||
* @param node The node to remove from the list
|
||||
*
|
||||
* @param node
|
||||
* The node to remove from the list
|
||||
*/
|
||||
public void removeNode( DependencyListNode node )
|
||||
{
|
||||
// the node didn't even exist in the list!?
|
||||
if ( node == null )
|
||||
if( node == null )
|
||||
return;
|
||||
|
||||
if ( node.getPrevious( ) != null )
|
||||
if( node.getPrevious( ) != null )
|
||||
node.getPrevious( ).setNext( node.getNext( ) );
|
||||
if ( node.getNext( ) != null )
|
||||
if( node.getNext( ) != null )
|
||||
node.getNext( ).setPrevious( node.getPrevious( ) );
|
||||
|
||||
String fileParentProjectPath = node.getFile( ).getParent( ).getProjectRelativePath( ).toString( );
|
||||
String fileParentProjectPath = node.getFile( ).getParent( )
|
||||
.getProjectRelativePath( ).toString( );
|
||||
|
||||
list_.remove( node.getFile( ).getProjectRelativePath( ).toString( ) );
|
||||
|
||||
// if we're at last node, decrease currentIndex_ to make economy on indexes
|
||||
if ( node.getNext( ) == null ) {
|
||||
if ( node.getPrevious( ) != null )
|
||||
currentIndex_ = node.getPrevious( ).getIndex( ) + DependencyListNode.INDEX_STEP;
|
||||
// if we're at last node, decrease currentIndex_ to make economy on
|
||||
// indexes
|
||||
if( node.getNext( ) == null ) {
|
||||
if( node.getPrevious( ) != null )
|
||||
currentIndex_ = node.getPrevious( ).getIndex( )
|
||||
+ DependencyListNode.INDEX_STEP;
|
||||
}
|
||||
|
||||
// removing a _main.cfg, add the parent container
|
||||
// back to the list along with it's directories_ entry
|
||||
if ( node.getFile( ).getName( ).equals( "_main.cfg" ) ) {
|
||||
if( node.getFile( ).getName( ).equals( "_main.cfg" ) ) {
|
||||
DependencyListNode backupPrevious = previous_;
|
||||
|
||||
previous_ = node.getPrevious( );
|
||||
|
@ -385,30 +420,32 @@ public class DependencyListBuilder implements Serializable
|
|||
|
||||
/**
|
||||
* Removes the container and all it's contents from the list
|
||||
* @param path The container's path
|
||||
*
|
||||
* @param path
|
||||
* The container's path
|
||||
*/
|
||||
private void internal_removeContainer( String path )
|
||||
{
|
||||
int dirEntryIndex = directories_.indexOf( path );
|
||||
if ( dirEntryIndex == -1 )
|
||||
if( dirEntryIndex == - 1 )
|
||||
return;
|
||||
|
||||
ListDirectoryEntry entry = directoriesEntries_.get( dirEntryIndex );
|
||||
|
||||
if ( entry == null )
|
||||
if( entry == null )
|
||||
return;
|
||||
|
||||
-- entry.Includes;
|
||||
--entry.Includes;
|
||||
|
||||
// we shouldn't delete entries that are used more than 1 time
|
||||
if ( entry.Includes > 0 )
|
||||
if( entry.Includes > 0 )
|
||||
return;
|
||||
|
||||
DependencyListNode firstNode = entry.FirstNode;
|
||||
DependencyListNode lastNode = entry.LastNode.getNext( );
|
||||
|
||||
// now delete all nodes that are in the same folder
|
||||
while ( firstNode != null && firstNode != lastNode) {
|
||||
while( firstNode != null && firstNode != lastNode ) {
|
||||
removeNode( firstNode );
|
||||
firstNode = firstNode.getNext( );
|
||||
}
|
||||
|
@ -420,47 +457,51 @@ public class DependencyListBuilder implements Serializable
|
|||
|
||||
/**
|
||||
* Updates the current node in the list
|
||||
* @param node The node to update
|
||||
*
|
||||
* @param node
|
||||
* The node to update
|
||||
*/
|
||||
public void updateNode( DependencyListNode node )
|
||||
{
|
||||
// check the includes, to see if they changed
|
||||
List<String> previousIncludes = node.getIncludes( false );
|
||||
List< String > previousIncludes = node.getIncludes( false );
|
||||
int prevLength = previousIncludes.size( );
|
||||
|
||||
List<String> newIncludes = node.getIncludes( true );
|
||||
List< String > newIncludes = node.getIncludes( true );
|
||||
int newLength = newIncludes.size( );
|
||||
|
||||
List<String> processedIncludes = new ArrayList<String>();
|
||||
List< String > processedIncludes = new ArrayList< String >( );
|
||||
|
||||
for ( int prevIndex = 0, newIndex = 0
|
||||
; prevIndex < prevLength && newIndex < newLength; ) {
|
||||
for( int prevIndex = 0, newIndex = 0; prevIndex < prevLength
|
||||
&& newIndex < newLength; ) {
|
||||
String prevIncl = previousIncludes.get( prevIndex );
|
||||
String newIncl = newIncludes.get( prevIndex );
|
||||
|
||||
// nothing changed
|
||||
if ( prevIncl.equals( newIncl ) ) {
|
||||
++ prevIndex;
|
||||
++ newIndex;
|
||||
if( prevIncl.equals( newIncl ) ) {
|
||||
++prevIndex;
|
||||
++newIndex;
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean newIsNew = !previousIncludes.contains( newIncl );
|
||||
boolean prevDeleted = !newIncludes.contains( prevIncl );
|
||||
boolean newIsNew = ! previousIncludes.contains( newIncl );
|
||||
boolean prevDeleted = ! newIncludes.contains( prevIncl );
|
||||
|
||||
if ( newIsNew ) {
|
||||
// add the new directory before the previous included dir (if any)
|
||||
if( newIsNew ) {
|
||||
// add the new directory before the previous included dir (if
|
||||
// any)
|
||||
|
||||
DependencyListNode backupPrevious = previous_;
|
||||
|
||||
previous_ = null;
|
||||
|
||||
// get the directory entry for the previous include
|
||||
if ( newIndex > 0 ) {
|
||||
ListDirectoryEntry entry = directoriesEntries_.get(
|
||||
directories_.indexOf( newIncludes.get( newIndex - 1 ) ) );
|
||||
if( newIndex > 0 ) {
|
||||
ListDirectoryEntry entry = directoriesEntries_
|
||||
.get( directories_.indexOf( newIncludes
|
||||
.get( newIndex - 1 ) ) );
|
||||
|
||||
if ( entry != null )
|
||||
if( entry != null )
|
||||
previous_ = entry.FirstNode;
|
||||
}
|
||||
|
||||
|
@ -468,31 +509,35 @@ public class DependencyListBuilder implements Serializable
|
|||
|
||||
previous_ = backupPrevious;
|
||||
++newIndex;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
|
||||
if ( prevDeleted ) {
|
||||
if( prevDeleted ) {
|
||||
// the previous include was deleted
|
||||
internal_removeContainer( prevIncl );
|
||||
} else {
|
||||
// the previous included has changed it's index (in the includes list)
|
||||
}
|
||||
else {
|
||||
// the previous included has changed it's index (in the
|
||||
// includes list)
|
||||
|
||||
// don't reprocess this pair if we already did
|
||||
if ( !processedIncludes.contains( prevIncl ) ) {
|
||||
if( ! processedIncludes.contains( prevIncl ) ) {
|
||||
|
||||
ListDirectoryEntry prevEntry = directoriesEntries_.get(
|
||||
directories_.indexOf( prevIncl ) );
|
||||
ListDirectoryEntry newEntry = directoriesEntries_.get(
|
||||
directories_.indexOf( newIncl ) );
|
||||
ListDirectoryEntry prevEntry = directoriesEntries_
|
||||
.get( directories_.indexOf( prevIncl ) );
|
||||
ListDirectoryEntry newEntry = directoriesEntries_
|
||||
.get( directories_.indexOf( newIncl ) );
|
||||
|
||||
if ( prevEntry != null && newEntry != null &&
|
||||
prevEntry.FirstNode != null && newEntry.FirstNode != null) {
|
||||
if( prevEntry != null && newEntry != null
|
||||
&& prevEntry.FirstNode != null
|
||||
&& newEntry.FirstNode != null ) {
|
||||
|
||||
// create a list for easier swap
|
||||
List<DependencyListNode> nodes = new ArrayList<DependencyListNode>();
|
||||
List< DependencyListNode > nodes = new ArrayList< DependencyListNode >( );
|
||||
nodes.add( prevEntry.FirstNode.getPrevious( ) );
|
||||
nodes.add( prevEntry.FirstNode );
|
||||
nodes.add( prevEntry.LastNode );
|
||||
if ( prevEntry.LastNode.getNext( ) != newEntry.FirstNode ) {
|
||||
if( prevEntry.LastNode.getNext( ) != newEntry.FirstNode ) {
|
||||
nodes.add( prevEntry.LastNode.getNext( ) );
|
||||
nodes.add( newEntry.FirstNode.getPrevious( ) );
|
||||
}
|
||||
|
@ -502,14 +547,14 @@ public class DependencyListBuilder implements Serializable
|
|||
|
||||
int nodesSize = nodes.size( );
|
||||
|
||||
int swapIndex = ( nodesSize == 8 ? 5 : 3 );
|
||||
int swapIndex = ( nodesSize == 8 ? 5: 3 );
|
||||
|
||||
// now swap the nodes
|
||||
DependencyListNode tmp = nodes.get( swapIndex );
|
||||
nodes.set( swapIndex, nodes.get( 1 ) );
|
||||
nodes.set( 1, tmp );
|
||||
|
||||
swapIndex = ( nodesSize == 8 ? 6 : 4 );
|
||||
swapIndex = ( nodesSize == 8 ? 6: 4 );
|
||||
|
||||
tmp = nodes.get( swapIndex );
|
||||
nodes.set( swapIndex, nodes.get( 2 ) );
|
||||
|
@ -517,22 +562,24 @@ public class DependencyListBuilder implements Serializable
|
|||
|
||||
// update the links
|
||||
|
||||
for ( int i = 0; i < nodesSize - 1; i += 2 ) {
|
||||
for( int i = 0; i < nodesSize - 1; i += 2 ) {
|
||||
DependencyListNode fst = nodes.get( i );
|
||||
DependencyListNode lst = nodes.get( i + 1 );
|
||||
|
||||
if ( fst != null )
|
||||
if( fst != null )
|
||||
fst.setNext( lst );
|
||||
|
||||
if ( lst != null )
|
||||
if( lst != null )
|
||||
lst.setPrevious( fst );
|
||||
}
|
||||
|
||||
processedIncludes.add( prevIncl );
|
||||
processedIncludes.add( newIncl );
|
||||
} else {
|
||||
Logger.getInstance( ).log( "Null directory entry for" +
|
||||
"includes: " + prevIncl + " and " + newIncl );
|
||||
}
|
||||
else {
|
||||
Logger.getInstance( ).log(
|
||||
"Null directory entry for" + "includes: "
|
||||
+ prevIncl + " and " + newIncl );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -545,7 +592,9 @@ public class DependencyListBuilder implements Serializable
|
|||
|
||||
/**
|
||||
* Returns the node specified by the file
|
||||
* @param file The file to get the depedency node for
|
||||
*
|
||||
* @param file
|
||||
* The file to get the depedency node for
|
||||
* @return An instance of {@link DependencyListNode}
|
||||
*/
|
||||
public DependencyListNode getNode( IFile file )
|
||||
|
@ -557,19 +606,22 @@ public class DependencyListBuilder implements Serializable
|
|||
* Returns the node specified by the key. The keys are
|
||||
* usually project-relative paths for project's files, or
|
||||
* the {@link #ROOT_NODE_KEY}
|
||||
* @param key The key to get the node by
|
||||
*
|
||||
* @param key
|
||||
* The key to get the node by
|
||||
* @return An instance of {@link DependencyListNode}
|
||||
*/
|
||||
public DependencyListNode getNode ( String key )
|
||||
public DependencyListNode getNode( String key )
|
||||
{
|
||||
return list_.get( key );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the list was already created, false otherwise
|
||||
*
|
||||
* @return A boolean value
|
||||
*/
|
||||
public boolean getIsCreated()
|
||||
public boolean getIsCreated( )
|
||||
{
|
||||
return isCreated_;
|
||||
}
|
||||
|
@ -582,17 +634,17 @@ public class DependencyListBuilder implements Serializable
|
|||
project_ = project;
|
||||
|
||||
// now, refill the dependency nodes
|
||||
for ( DependencyListNode node : list_.values( ) ) {
|
||||
for( DependencyListNode node: list_.values( ) ) {
|
||||
node.file_ = project_.getFile( node.fileName_ );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
public String toString( )
|
||||
{
|
||||
StringBuilder str = new StringBuilder( );
|
||||
str.append( "list: \n" ); //$NON-NLS-1$
|
||||
if ( !list_.isEmpty( ) ) {
|
||||
if( ! list_.isEmpty( ) ) {
|
||||
DependencyListNode node = list_.get( ROOT_NODE_KEY );
|
||||
|
||||
do {
|
||||
|
@ -600,7 +652,7 @@ public class DependencyListBuilder implements Serializable
|
|||
|
||||
node = node.getNext( );
|
||||
str.append( "\n" ); //$NON-NLS-1$
|
||||
}while ( node != null );
|
||||
} while( node != null );
|
||||
}
|
||||
else {
|
||||
str.append( "Empty\n" ); //$NON-NLS-1$
|
||||
|
@ -611,7 +663,7 @@ public class DependencyListBuilder implements Serializable
|
|||
|
||||
/**
|
||||
* The class that represents the entry in the list of included directories
|
||||
*
|
||||
*
|
||||
*/
|
||||
protected static class ListDirectoryEntry implements Serializable
|
||||
{
|
||||
|
@ -620,7 +672,7 @@ public class DependencyListBuilder implements Serializable
|
|||
/**
|
||||
* The project relative path of the directory
|
||||
*/
|
||||
public String Name;
|
||||
public String Name;
|
||||
|
||||
/**
|
||||
* The first node in this directory existing in the list
|
||||
|
@ -635,7 +687,7 @@ public class DependencyListBuilder implements Serializable
|
|||
/**
|
||||
* Numbers of times this directory is included.
|
||||
*/
|
||||
public int Includes;
|
||||
public int Includes;
|
||||
|
||||
public ListDirectoryEntry( String name, DependencyListNode firstNode,
|
||||
DependencyListNode lastNode )
|
||||
|
|
|
@ -15,6 +15,7 @@ import java.util.List;
|
|||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.QualifiedName;
|
||||
|
||||
import org.wesnoth.Constants;
|
||||
import org.wesnoth.Logger;
|
||||
import org.wesnoth.utils.ResourceUtils;
|
||||
|
@ -22,39 +23,41 @@ import org.wesnoth.utils.ResourceUtils;
|
|||
/**
|
||||
* This class represents a node in the Project's Depedency list,
|
||||
* which is constructed on a full build of the project.
|
||||
*
|
||||
*
|
||||
* Alternatively, a list node is created
|
||||
* when a new resource is added.
|
||||
*/
|
||||
public class DependencyListNode implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = -9140173740211465384L;
|
||||
private static final long serialVersionUID = - 9140173740211465384L;
|
||||
|
||||
/**
|
||||
* This integer represents the default step between 2 file indexes.
|
||||
* Since int it's on 4 bytes, it can hold values between
|
||||
* -2,147,483,648 and 2,147,483,647.
|
||||
*
|
||||
*
|
||||
* With an increment of 100k, we could have 2 * 21,474 config files.
|
||||
*/
|
||||
public static final int INDEX_STEP = 100000;
|
||||
public static final int INDEX_STEP = 100000;
|
||||
|
||||
public static final QualifiedName PDL_INDEX = new QualifiedName( Constants.PLUGIN_ID, "pdl_index" ); //$NON-NLS-1$
|
||||
public static final QualifiedName PDL_INDEX = new QualifiedName(
|
||||
Constants.PLUGIN_ID,
|
||||
"pdl_index" ); //$NON-NLS-1$
|
||||
|
||||
private DependencyListNode previous_;
|
||||
private DependencyListNode next_;
|
||||
private DependencyListNode previous_;
|
||||
private DependencyListNode next_;
|
||||
|
||||
protected transient IFile file_;
|
||||
protected String fileName_;
|
||||
protected List<String> includes_;
|
||||
protected transient IFile file_;
|
||||
protected String fileName_;
|
||||
protected List< String > includes_;
|
||||
|
||||
private int index_;
|
||||
private int index_;
|
||||
|
||||
public DependencyListNode( IFile file, int index )
|
||||
{
|
||||
previous_ = next_ = null;
|
||||
|
||||
includes_ = new ArrayList<String>();
|
||||
includes_ = new ArrayList< String >( );
|
||||
|
||||
file_ = file;
|
||||
fileName_ = file.getProjectRelativePath( ).toString( );
|
||||
|
@ -63,23 +66,27 @@ public class DependencyListNode implements Serializable
|
|||
|
||||
/**
|
||||
* Gets this node's file
|
||||
*
|
||||
* @return A IFile resource
|
||||
*/
|
||||
public IFile getFile()
|
||||
public IFile getFile( )
|
||||
{
|
||||
return file_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the includes from this node
|
||||
* @param refresh True to force reloading the current file and return
|
||||
* the newly parsed ones
|
||||
*
|
||||
* @param refresh
|
||||
* True to force reloading the current file and return
|
||||
* the newly parsed ones
|
||||
* @return A set with string paths for included directories
|
||||
*/
|
||||
public List<String> getIncludes ( boolean refresh )
|
||||
public List< String > getIncludes( boolean refresh )
|
||||
{
|
||||
if ( includes_ == null || refresh ) {
|
||||
includes_ = new ArrayList<String>( ResourceUtils.getContainers( file_ ) );
|
||||
if( includes_ == null || refresh ) {
|
||||
includes_ = new ArrayList< String >(
|
||||
ResourceUtils.getContainers( file_ ) );
|
||||
}
|
||||
|
||||
return includes_;
|
||||
|
@ -87,16 +94,19 @@ public class DependencyListNode implements Serializable
|
|||
|
||||
/**
|
||||
* Returns the index of this node in the whole dependency list
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getIndex()
|
||||
public int getIndex( )
|
||||
{
|
||||
return index_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a new index for this node
|
||||
* @param index The index to set
|
||||
*
|
||||
* @param index
|
||||
* The index to set
|
||||
*/
|
||||
protected void setIndex( int index )
|
||||
{
|
||||
|
@ -104,24 +114,26 @@ public class DependencyListNode implements Serializable
|
|||
|
||||
try {
|
||||
file_.setPersistentProperty( PDL_INDEX, Integer.toString( index ) );
|
||||
}
|
||||
catch ( CoreException e ) {
|
||||
} catch( CoreException e ) {
|
||||
Logger.getInstance( ).logException( e );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the node before the current node
|
||||
*
|
||||
* @return A node or null if there is no parent
|
||||
*/
|
||||
public DependencyListNode getPrevious()
|
||||
public DependencyListNode getPrevious( )
|
||||
{
|
||||
return previous_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a new previous node for this node
|
||||
* @param previous The new previous node to set
|
||||
*
|
||||
* @param previous
|
||||
* The new previous node to set
|
||||
*/
|
||||
public void setPrevious( DependencyListNode previous )
|
||||
{
|
||||
|
@ -130,16 +142,19 @@ public class DependencyListNode implements Serializable
|
|||
|
||||
/**
|
||||
* Gets the node after the current node
|
||||
*
|
||||
* @return A node or null if there is no parent
|
||||
*/
|
||||
public DependencyListNode getNext()
|
||||
public DependencyListNode getNext( )
|
||||
{
|
||||
return next_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a new next node for this node
|
||||
* @param next The new next node to set
|
||||
*
|
||||
* @param next
|
||||
* The new next node to set
|
||||
*/
|
||||
public void setNext( DependencyListNode next )
|
||||
{
|
||||
|
@ -147,8 +162,8 @@ public class DependencyListNode implements Serializable
|
|||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
public String toString( )
|
||||
{
|
||||
return ( file_ == null ? "" : fileName_ ) + "_" + index_; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
return ( file_ == null ? "": fileName_ ) + "_" + index_; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,75 +17,74 @@ import org.eclipse.core.runtime.CoreException;
|
|||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
|
||||
import org.wesnoth.Constants;
|
||||
import org.wesnoth.Logger;
|
||||
import org.wesnoth.action.ObjectActionDelegate;
|
||||
|
||||
public class ToggleWesnothNatureAction extends ObjectActionDelegate
|
||||
{
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void run(IAction action)
|
||||
{
|
||||
if(structuredSelection_ == null)
|
||||
return;
|
||||
for (Iterator it = structuredSelection_.iterator(); it.hasNext();)
|
||||
{
|
||||
Object element = it.next();
|
||||
IProject project = null;
|
||||
if (element instanceof IProject)
|
||||
{
|
||||
project = (IProject) element;
|
||||
}
|
||||
else if (element instanceof IAdaptable)
|
||||
{
|
||||
project = (IProject) ((IAdaptable) element).getAdapter(IProject.class);
|
||||
}
|
||||
if (project != null)
|
||||
{
|
||||
toggleNature(project);
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
@SuppressWarnings( "rawtypes" )
|
||||
public void run( IAction action )
|
||||
{
|
||||
if( structuredSelection_ == null )
|
||||
return;
|
||||
for( Iterator it = structuredSelection_.iterator( ); it.hasNext( ); ) {
|
||||
Object element = it.next( );
|
||||
IProject project = null;
|
||||
if( element instanceof IProject ) {
|
||||
project = ( IProject ) element;
|
||||
}
|
||||
else if( element instanceof IAdaptable ) {
|
||||
project = ( IProject ) ( ( IAdaptable ) element )
|
||||
.getAdapter( IProject.class );
|
||||
}
|
||||
if( project != null ) {
|
||||
toggleNature( project );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles sample nature on a project
|
||||
*
|
||||
* @param project to have sample nature added or removed
|
||||
*/
|
||||
public void toggleNature(IProject project)
|
||||
{
|
||||
try
|
||||
{
|
||||
IProjectDescription description = project.getDescription();
|
||||
String[] natures = description.getNatureIds();
|
||||
/**
|
||||
* Toggles sample nature on a project
|
||||
*
|
||||
* @param project
|
||||
* to have sample nature added or removed
|
||||
*/
|
||||
public void toggleNature( IProject project )
|
||||
{
|
||||
try {
|
||||
IProjectDescription description = project.getDescription( );
|
||||
String[] natures = description.getNatureIds( );
|
||||
|
||||
for (int i = 0; i < natures.length; ++i)
|
||||
{
|
||||
if (Constants.NATURE_WESNOTH.equals(natures[i]))
|
||||
{
|
||||
// Remove the nature
|
||||
String[] newNatures = new String[natures.length - 1];
|
||||
System.arraycopy(natures, 0, newNatures, 0, i);
|
||||
System.arraycopy(natures, i + 1, newNatures, i, natures.length - i - 1);
|
||||
description.setNatureIds(newNatures);
|
||||
project.setDescription(description, new NullProgressMonitor());
|
||||
project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
|
||||
return;
|
||||
}
|
||||
}
|
||||
for( int i = 0; i < natures.length; ++i ) {
|
||||
if( Constants.NATURE_WESNOTH.equals( natures[i] ) ) {
|
||||
// Remove the nature
|
||||
String[] newNatures = new String[natures.length - 1];
|
||||
System.arraycopy( natures, 0, newNatures, 0, i );
|
||||
System.arraycopy( natures, i + 1, newNatures, i,
|
||||
natures.length - i - 1 );
|
||||
description.setNatureIds( newNatures );
|
||||
project.setDescription( description,
|
||||
new NullProgressMonitor( ) );
|
||||
project.refreshLocal( IResource.DEPTH_INFINITE,
|
||||
new NullProgressMonitor( ) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Add the natures
|
||||
String[] newNatures = new String[natures.length + 1];
|
||||
System.arraycopy(natures, 0, newNatures, 0, natures.length);
|
||||
newNatures[natures.length] = Constants.NATURE_WESNOTH;
|
||||
description.setNatureIds(newNatures);
|
||||
project.setDescription(description, new NullProgressMonitor());
|
||||
project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
|
||||
} catch (CoreException e)
|
||||
{
|
||||
Logger.getInstance().logException(e);
|
||||
}
|
||||
}
|
||||
// Add the natures
|
||||
String[] newNatures = new String[natures.length + 1];
|
||||
System.arraycopy( natures, 0, newNatures, 0, natures.length );
|
||||
newNatures[natures.length] = Constants.NATURE_WESNOTH;
|
||||
description.setNatureIds( newNatures );
|
||||
project.setDescription( description, new NullProgressMonitor( ) );
|
||||
project.refreshLocal( IResource.DEPTH_INFINITE,
|
||||
new NullProgressMonitor( ) );
|
||||
} catch( CoreException e ) {
|
||||
Logger.getInstance( ).logException( e );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,75 +17,74 @@ import org.eclipse.core.runtime.CoreException;
|
|||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
|
||||
import org.wesnoth.Constants;
|
||||
import org.wesnoth.Logger;
|
||||
import org.wesnoth.action.ObjectActionDelegate;
|
||||
|
||||
public class ToggleXtextNatureAction extends ObjectActionDelegate
|
||||
{
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void run(IAction action)
|
||||
{
|
||||
if(structuredSelection_ == null)
|
||||
return;
|
||||
for (Iterator it = structuredSelection_.iterator(); it.hasNext();)
|
||||
{
|
||||
Object element = it.next();
|
||||
IProject project = null;
|
||||
if (element instanceof IProject)
|
||||
{
|
||||
project = (IProject) element;
|
||||
}
|
||||
else if (element instanceof IAdaptable)
|
||||
{
|
||||
project = (IProject) ((IAdaptable) element).getAdapter(IProject.class);
|
||||
}
|
||||
if (project != null)
|
||||
{
|
||||
toggleNature(project);
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
@SuppressWarnings( "rawtypes" )
|
||||
public void run( IAction action )
|
||||
{
|
||||
if( structuredSelection_ == null )
|
||||
return;
|
||||
for( Iterator it = structuredSelection_.iterator( ); it.hasNext( ); ) {
|
||||
Object element = it.next( );
|
||||
IProject project = null;
|
||||
if( element instanceof IProject ) {
|
||||
project = ( IProject ) element;
|
||||
}
|
||||
else if( element instanceof IAdaptable ) {
|
||||
project = ( IProject ) ( ( IAdaptable ) element )
|
||||
.getAdapter( IProject.class );
|
||||
}
|
||||
if( project != null ) {
|
||||
toggleNature( project );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles sample nature on a project
|
||||
*
|
||||
* @param project to have sample nature added or removed
|
||||
*/
|
||||
public void toggleNature(IProject project)
|
||||
{
|
||||
try
|
||||
{
|
||||
IProjectDescription description = project.getDescription();
|
||||
String[] natures = description.getNatureIds();
|
||||
/**
|
||||
* Toggles sample nature on a project
|
||||
*
|
||||
* @param project
|
||||
* to have sample nature added or removed
|
||||
*/
|
||||
public void toggleNature( IProject project )
|
||||
{
|
||||
try {
|
||||
IProjectDescription description = project.getDescription( );
|
||||
String[] natures = description.getNatureIds( );
|
||||
|
||||
for (int i = 0; i < natures.length; ++i)
|
||||
{
|
||||
if (Constants.NATURE_XTEXT.equals(natures[i]))
|
||||
{
|
||||
// Remove the nature
|
||||
String[] newNatures = new String[natures.length - 1];
|
||||
System.arraycopy(natures, 0, newNatures, 0, i);
|
||||
System.arraycopy(natures, i + 1, newNatures, i, natures.length - i - 1);
|
||||
description.setNatureIds(newNatures);
|
||||
project.setDescription(description, new NullProgressMonitor());
|
||||
project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
|
||||
return;
|
||||
}
|
||||
}
|
||||
for( int i = 0; i < natures.length; ++i ) {
|
||||
if( Constants.NATURE_XTEXT.equals( natures[i] ) ) {
|
||||
// Remove the nature
|
||||
String[] newNatures = new String[natures.length - 1];
|
||||
System.arraycopy( natures, 0, newNatures, 0, i );
|
||||
System.arraycopy( natures, i + 1, newNatures, i,
|
||||
natures.length - i - 1 );
|
||||
description.setNatureIds( newNatures );
|
||||
project.setDescription( description,
|
||||
new NullProgressMonitor( ) );
|
||||
project.refreshLocal( IResource.DEPTH_INFINITE,
|
||||
new NullProgressMonitor( ) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Add the natures
|
||||
String[] newNatures = new String[natures.length + 1];
|
||||
System.arraycopy(natures, 0, newNatures, 0, natures.length);
|
||||
newNatures[natures.length] = Constants.NATURE_XTEXT;
|
||||
description.setNatureIds(newNatures);
|
||||
project.setDescription(description, new NullProgressMonitor());
|
||||
project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
|
||||
} catch (CoreException e)
|
||||
{
|
||||
Logger.getInstance().logException(e);
|
||||
}
|
||||
}
|
||||
// Add the natures
|
||||
String[] newNatures = new String[natures.length + 1];
|
||||
System.arraycopy( natures, 0, newNatures, 0, natures.length );
|
||||
newNatures[natures.length] = Constants.NATURE_XTEXT;
|
||||
description.setNatureIds( newNatures );
|
||||
project.setDescription( description, new NullProgressMonitor( ) );
|
||||
project.refreshLocal( IResource.DEPTH_INFINITE,
|
||||
new NullProgressMonitor( ) );
|
||||
} catch( CoreException e ) {
|
||||
Logger.getInstance( ).logException( e );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,6 +19,14 @@ import java.util.Map;
|
|||
import java.util.Queue;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IResourceDelta;
|
||||
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
import org.wesnoth.Constants;
|
||||
import org.wesnoth.Logger;
|
||||
import org.wesnoth.Messages;
|
||||
|
@ -37,18 +45,10 @@ import org.wesnoth.utils.WorkspaceUtils;
|
|||
import org.wesnoth.wml.SimpleWMLParser;
|
||||
import org.wesnoth.wml.WMLConfig;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IResourceDelta;
|
||||
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
/**
|
||||
* The builder does the following steps in order to create and ensure
|
||||
* a correct PDL (Project Dependency Lits)
|
||||
*
|
||||
*
|
||||
* 1) remove REMOVED files from the PDL
|
||||
* 2) parse ADDED or CHANGED files, to check if new directory/file includes
|
||||
* happened
|
||||
|
@ -57,94 +57,102 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
|||
public class WesnothProjectBuilder extends IncrementalProjectBuilder
|
||||
{
|
||||
private ProjectCache projectCache_;
|
||||
private IProject project_;
|
||||
private IProject project_;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
protected IProject[] build(int kind, Map args, IProgressMonitor monitor)
|
||||
throws CoreException
|
||||
{
|
||||
project_ = getProject( );
|
||||
if ( WesnothInstallsUtils.setupInstallForResource( project_ ) == false )
|
||||
return null;
|
||||
@SuppressWarnings( "rawtypes" )
|
||||
@Override
|
||||
protected IProject[] build( int kind, Map args, IProgressMonitor monitor )
|
||||
throws CoreException
|
||||
{
|
||||
project_ = getProject( );
|
||||
if( WesnothInstallsUtils.setupInstallForResource( project_ ) == false )
|
||||
return null;
|
||||
|
||||
if ( projectCache_ == null )
|
||||
projectCache_ = ProjectUtils.getCacheForProject( project_ );
|
||||
if( projectCache_ == null )
|
||||
projectCache_ = ProjectUtils.getCacheForProject( project_ );
|
||||
|
||||
Logger.getInstance().log( "Building project " + getProject( ).getName( ) + " ..." ); //$NON-NLS-1$
|
||||
monitor.beginTask(String.format(Messages.WesnothProjectBuilder_1, project_.getName()), 100);
|
||||
Logger.getInstance( ).log(
|
||||
"Building project " + getProject( ).getName( ) + " ..." ); //$NON-NLS-1$
|
||||
monitor.beginTask(
|
||||
String.format( Messages.WesnothProjectBuilder_1,
|
||||
project_.getName( ) ), 100 );
|
||||
|
||||
String installName = WesnothInstallsUtils.getInstallNameForResource( project_ );
|
||||
Paths paths = Preferences.getPaths( installName );
|
||||
String installName = WesnothInstallsUtils
|
||||
.getInstallNameForResource( project_ );
|
||||
Paths paths = Preferences.getPaths( installName );
|
||||
|
||||
monitor.subTask(Messages.WesnothProjectBuilder_3);
|
||||
if ( WorkspaceUtils.checkPathsAreSet( installName, true ) == false )
|
||||
return null;
|
||||
monitor.worked(5);
|
||||
monitor.subTask( Messages.WesnothProjectBuilder_3 );
|
||||
if( WorkspaceUtils.checkPathsAreSet( installName, true ) == false )
|
||||
return null;
|
||||
monitor.worked( 5 );
|
||||
|
||||
monitor.subTask( "Creating the project list ..." );
|
||||
monitor.subTask( "Creating the project list ..." );
|
||||
projectCache_.getDependencyList( ).createDependencyList( false );
|
||||
monitor.worked( 10 );
|
||||
|
||||
// create the temporary directory used by the plugin if not created
|
||||
monitor.subTask(Messages.WesnothProjectBuilder_6);
|
||||
WorkspaceUtils.getTemporaryFolder();
|
||||
monitor.worked(2);
|
||||
// create the temporary directory used by the plugin if not created
|
||||
monitor.subTask( Messages.WesnothProjectBuilder_6 );
|
||||
WorkspaceUtils.getTemporaryFolder( );
|
||||
monitor.worked( 2 );
|
||||
|
||||
|
||||
if ( runAntJob(paths, monitor ) == false )
|
||||
return null;
|
||||
if( runAntJob( paths, monitor ) == false )
|
||||
return null;
|
||||
|
||||
boolean readDefines = false;
|
||||
boolean readDefines = false;
|
||||
|
||||
monitor.subTask( "Build started..." );
|
||||
monitor.subTask( "Build started..." );
|
||||
|
||||
if (kind == FULL_BUILD)
|
||||
readDefines = fullBuild(monitor);
|
||||
else
|
||||
{
|
||||
IResourceDelta delta = getDelta(project_);
|
||||
if (delta == null)
|
||||
readDefines = fullBuild(monitor);
|
||||
else
|
||||
readDefines = incrementalBuild(delta, monitor);
|
||||
}
|
||||
if( kind == FULL_BUILD )
|
||||
readDefines = fullBuild( monitor );
|
||||
else {
|
||||
IResourceDelta delta = getDelta( project_ );
|
||||
if( delta == null )
|
||||
readDefines = fullBuild( monitor );
|
||||
else
|
||||
readDefines = incrementalBuild( delta, monitor );
|
||||
}
|
||||
|
||||
if (readDefines)
|
||||
{
|
||||
// we read the defines at the end of the build
|
||||
// to speed up things (and only if we had any .cfg files processed)
|
||||
projectCache_.readDefines( true );
|
||||
projectCache_.saveCache( );
|
||||
if( readDefines ) {
|
||||
// we read the defines at the end of the build
|
||||
// to speed up things (and only if we had any .cfg files processed)
|
||||
projectCache_.readDefines( true );
|
||||
projectCache_.saveCache( );
|
||||
|
||||
monitor.worked(10);
|
||||
}
|
||||
monitor.done();
|
||||
monitor.worked( 10 );
|
||||
}
|
||||
monitor.done( );
|
||||
|
||||
Logger.getInstance( ).log( "Done building project " + getProject( ).getName( ) );
|
||||
return null;
|
||||
}
|
||||
Logger.getInstance( ).log(
|
||||
"Done building project " + getProject( ).getName( ) );
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Does a full build on this project
|
||||
* @param monitor The monitor used to signal progress
|
||||
*
|
||||
* @param monitor
|
||||
* The monitor used to signal progress
|
||||
* @return True if there were config files processed
|
||||
* @throws CoreException
|
||||
*/
|
||||
protected boolean fullBuild(final IProgressMonitor monitor) throws CoreException
|
||||
protected boolean fullBuild( final IProgressMonitor monitor )
|
||||
throws CoreException
|
||||
{
|
||||
// clean all project cache
|
||||
projectCache_.clear( );
|
||||
PreprocessorUtils.getInstance( ).clearTimestampsForPath( project_.getLocation( ).toOSString( ) );
|
||||
PreprocessorUtils.getInstance( ).clearTimestampsForPath(
|
||||
project_.getLocation( ).toOSString( ) );
|
||||
|
||||
projectCache_.getDependencyList( ).createDependencyList( true );
|
||||
boolean foundCfg = false;
|
||||
|
||||
DependencyListNode node = null;
|
||||
|
||||
node = projectCache_.getDependencyList( ).getNode( DependencyListBuilder.ROOT_NODE_KEY );
|
||||
node = projectCache_.getDependencyList( ).getNode(
|
||||
DependencyListBuilder.ROOT_NODE_KEY );
|
||||
|
||||
if ( node != null ) {
|
||||
if( node != null ) {
|
||||
|
||||
do {
|
||||
foundCfg = true;
|
||||
|
@ -152,7 +160,7 @@ public class WesnothProjectBuilder extends IncrementalProjectBuilder
|
|||
// process the node
|
||||
checkResource( node.getFile( ), monitor );
|
||||
node = node.getNext( );
|
||||
} while ( node != null );
|
||||
} while( node != null );
|
||||
}
|
||||
|
||||
return foundCfg;
|
||||
|
@ -160,82 +168,96 @@ public class WesnothProjectBuilder extends IncrementalProjectBuilder
|
|||
|
||||
/**
|
||||
* Does an incremental build on this project
|
||||
* @param delta The delta which contains the project modifications
|
||||
* @param monitor The monitor used to signal progress
|
||||
*
|
||||
* @param delta
|
||||
* The delta which contains the project modifications
|
||||
* @param monitor
|
||||
* The monitor used to signal progress
|
||||
* @return True if there were config files processed
|
||||
* @throws CoreException
|
||||
*/
|
||||
protected boolean incrementalBuild(IResourceDelta delta, IProgressMonitor monitor)
|
||||
throws CoreException
|
||||
protected boolean incrementalBuild( IResourceDelta delta,
|
||||
IProgressMonitor monitor ) throws CoreException
|
||||
{
|
||||
boolean foundCfg = false;
|
||||
|
||||
//TODO: unprocessed files should be reprocessed on each build
|
||||
// TODO: unprocessed files should be reprocessed on each build
|
||||
// until they get so.
|
||||
|
||||
DependencyListBuilder list = projectCache_.getDependencyList( );
|
||||
Queue<IResourceDelta> deltasQueue = new LinkedBlockingDeque<IResourceDelta>();
|
||||
List< DependencyListNode > nodesToProcess = new ArrayList<DependencyListNode>();
|
||||
Queue< IResourceDelta > deltasQueue = new LinkedBlockingDeque< IResourceDelta >( );
|
||||
List< DependencyListNode > nodesToProcess = new ArrayList< DependencyListNode >( );
|
||||
|
||||
// gather the list of configs modified
|
||||
deltasQueue.add( delta );
|
||||
|
||||
while( !deltasQueue.isEmpty( ) ) {
|
||||
while( ! deltasQueue.isEmpty( ) ) {
|
||||
IResourceDelta deltaItem = deltasQueue.poll( );
|
||||
IResource resource = deltaItem.getResource( );
|
||||
|
||||
// process just config files
|
||||
if ( ResourceUtils.isConfigFile( resource ) ) {
|
||||
IFile file = (IFile) resource;
|
||||
if( ResourceUtils.isConfigFile( resource ) ) {
|
||||
IFile file = ( IFile ) resource;
|
||||
int deltaKind = deltaItem.getKind( );
|
||||
|
||||
if ( deltaKind == IResourceDelta.REMOVED ) {
|
||||
if( deltaKind == IResourceDelta.REMOVED ) {
|
||||
projectCache_.getDependencyList( ).removeNode( file );
|
||||
projectCache_.getWMLConfigs().remove( file.getProjectRelativePath( ).toString( ) );
|
||||
projectCache_.getWMLConfigs( ).remove(
|
||||
file.getProjectRelativePath( ).toString( ) );
|
||||
|
||||
} else if ( deltaKind == IResourceDelta.ADDED ){
|
||||
}
|
||||
else if( deltaKind == IResourceDelta.ADDED ) {
|
||||
DependencyListNode newNode = list.addNode( file );
|
||||
if ( newNode == null )
|
||||
Logger.getInstance( ).logError( "Couldn't create a new" +
|
||||
"PDL node for file: " + file.getFullPath( ).toString( ) );
|
||||
if( newNode == null )
|
||||
Logger.getInstance( ).logError(
|
||||
"Couldn't create a new" + "PDL node for file: "
|
||||
+ file.getFullPath( ).toString( ) );
|
||||
else {
|
||||
nodesToProcess.add( newNode );
|
||||
}
|
||||
} else if ( deltaKind == IResourceDelta.CHANGED ) {
|
||||
}
|
||||
else if( deltaKind == IResourceDelta.CHANGED ) {
|
||||
DependencyListNode node = list.getNode( file );
|
||||
if ( node == null )
|
||||
Logger.getInstance( ).logError( "Couldn't find file "
|
||||
+ file.getFullPath( ).toString( ) + " in PDL!." );
|
||||
if( node == null )
|
||||
Logger.getInstance( ).logError(
|
||||
"Couldn't find file "
|
||||
+ file.getFullPath( ).toString( )
|
||||
+ " in PDL!." );
|
||||
else {
|
||||
nodesToProcess.add( node );
|
||||
list.updateNode( node );
|
||||
}
|
||||
} else {
|
||||
Logger.getInstance( ).log( "unknown delta kind: " + deltaKind );
|
||||
}
|
||||
else {
|
||||
Logger.getInstance( ).log(
|
||||
"unknown delta kind: " + deltaKind );
|
||||
}
|
||||
}
|
||||
|
||||
deltasQueue.addAll( Arrays.asList( deltaItem.getAffectedChildren( ) ) );
|
||||
deltasQueue
|
||||
.addAll( Arrays.asList( deltaItem.getAffectedChildren( ) ) );
|
||||
}
|
||||
|
||||
// sort the list by index (ascending)
|
||||
Collections.sort( nodesToProcess, new Comparator<DependencyListNode> () {
|
||||
Collections.sort( nodesToProcess,
|
||||
new Comparator< DependencyListNode >( ) {
|
||||
|
||||
@Override
|
||||
public int compare( DependencyListNode o1, DependencyListNode o2 )
|
||||
{
|
||||
if ( o1.getIndex( ) < o2.getIndex( ) )
|
||||
return -1;
|
||||
else if ( o1.getIndex( ) == o2.getIndex( ) )
|
||||
return 0;
|
||||
@Override
|
||||
public int compare( DependencyListNode o1,
|
||||
DependencyListNode o2 )
|
||||
{
|
||||
if( o1.getIndex( ) < o2.getIndex( ) )
|
||||
return - 1;
|
||||
else if( o1.getIndex( ) == o2.getIndex( ) )
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
return 1;
|
||||
}
|
||||
} );
|
||||
|
||||
foundCfg = ( !nodesToProcess.isEmpty( ) );
|
||||
foundCfg = ( ! nodesToProcess.isEmpty( ) );
|
||||
// process nodes
|
||||
for ( DependencyListNode node : nodesToProcess ) {
|
||||
for( DependencyListNode node: nodesToProcess ) {
|
||||
checkResource( node.getFile( ), monitor );
|
||||
}
|
||||
|
||||
|
@ -244,132 +266,142 @@ public class WesnothProjectBuilder extends IncrementalProjectBuilder
|
|||
|
||||
/**
|
||||
* Runs the ant job that copies the project in user add-ons directory
|
||||
* @param paths The paths instance which contains the paths to wesnoth
|
||||
* utilities
|
||||
* @param monitor The monitor used to signal progress
|
||||
*
|
||||
* @param paths
|
||||
* The paths instance which contains the paths to wesnoth
|
||||
* utilities
|
||||
* @param monitor
|
||||
* The monitor used to signal progress
|
||||
* @return true or false whether the job completed successfully
|
||||
*/
|
||||
private boolean runAntJob( Paths paths, IProgressMonitor monitor )
|
||||
{
|
||||
String buildXMLPath = project_.getLocation().toOSString() + "/build.xml";
|
||||
private boolean runAntJob( Paths paths, IProgressMonitor monitor )
|
||||
{
|
||||
String buildXMLPath = project_.getLocation( ).toOSString( )
|
||||
+ "/build.xml";
|
||||
// check for 'build.xml' existance
|
||||
if ( new File( buildXMLPath ).exists() == true )
|
||||
{
|
||||
if( new File( buildXMLPath ).exists( ) == true ) {
|
||||
// run the ant job to copy the whole project
|
||||
// in the user add-ons directory (incremental)
|
||||
monitor.subTask(Messages.WesnothProjectBuilder_8);
|
||||
Map<String, String> properties = new HashMap<String, String>();
|
||||
properties.put("wesnoth.user.dir", paths.getUserDir( )); //$NON-NLS-1$
|
||||
Logger.getInstance().log("Ant result:"); //$NON-NLS-1$
|
||||
monitor.subTask( Messages.WesnothProjectBuilder_8 );
|
||||
Map< String, String > properties = new HashMap< String, String >( );
|
||||
properties.put( "wesnoth.user.dir", paths.getUserDir( ) ); //$NON-NLS-1$
|
||||
Logger.getInstance( ).log( "Ant result:" ); //$NON-NLS-1$
|
||||
|
||||
String result = AntUtils.runAnt( buildXMLPath, properties, true );
|
||||
Logger.getInstance().logTool( result );
|
||||
monitor.worked(10);
|
||||
Logger.getInstance( ).logTool( result );
|
||||
monitor.worked( 10 );
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
Logger.getInstance().log("error running the ant job", //$NON-NLS-1$
|
||||
Messages.WesnothProjectBuilder_13);
|
||||
if( result == null ) {
|
||||
Logger.getInstance( ).log( "error running the ant job", //$NON-NLS-1$
|
||||
Messages.WesnothProjectBuilder_13 );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
monitor.worked(2);
|
||||
monitor.worked( 2 );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean checkResource( IResource resource, IProgressMonitor monitor )
|
||||
{
|
||||
monitor.worked(5);
|
||||
if ( resource.exists() == false ||
|
||||
monitor.isCanceled() )
|
||||
return false;
|
||||
protected boolean checkResource( IResource resource,
|
||||
IProgressMonitor monitor )
|
||||
{
|
||||
monitor.worked( 5 );
|
||||
if( resource.exists( ) == false || monitor.isCanceled( ) )
|
||||
return false;
|
||||
|
||||
// config files
|
||||
if ( ResourceUtils.isConfigFile( resource ) )
|
||||
{
|
||||
IFile file = (IFile) resource;
|
||||
// config files
|
||||
if( ResourceUtils.isConfigFile( resource ) ) {
|
||||
IFile file = ( IFile ) resource;
|
||||
String filePath = file.getProjectRelativePath( ).toString( );
|
||||
String macrosFilePath = PreprocessorUtils.getInstance( ).getMacrosLocation( file );
|
||||
String macrosFilePath = PreprocessorUtils.getInstance( )
|
||||
.getMacrosLocation( file );
|
||||
|
||||
Logger.getInstance().log( "Resource: " + filePath ); //$NON-NLS-1$
|
||||
Logger.getInstance( ).log( "Resource: " + filePath ); //$NON-NLS-1$
|
||||
|
||||
try
|
||||
{
|
||||
monitor.subTask( String.format( Messages.WesnothProjectBuilder_19 ,filePath ) );
|
||||
try {
|
||||
monitor.subTask( String.format(
|
||||
Messages.WesnothProjectBuilder_19, filePath ) );
|
||||
|
||||
List<String> defines = new ArrayList<String>();
|
||||
// parse the core only if we don't have any macros file
|
||||
if ( !new File( macrosFilePath ).exists( ) )
|
||||
defines.add("SKIP_CORE"); //$NON-NLS-1$
|
||||
List< String > defines = new ArrayList< String >( );
|
||||
// parse the core only if we don't have any macros file
|
||||
if( ! new File( macrosFilePath ).exists( ) )
|
||||
defines.add( "SKIP_CORE" ); //$NON-NLS-1$
|
||||
|
||||
// we use a single _MACROS_.cfg file for each project
|
||||
PreprocessorUtils.getInstance().preprocessFile(file, macrosFilePath, defines);
|
||||
monitor.worked(5);
|
||||
// we use a single _MACROS_.cfg file for each project
|
||||
PreprocessorUtils.getInstance( ).preprocessFile( file,
|
||||
macrosFilePath, defines );
|
||||
monitor.worked( 5 );
|
||||
|
||||
// process the AST ( Abstract Syntax Tree ) to get info for the file
|
||||
monitor.subTask( String.format( Messages.WesnothProjectBuilder_22, filePath ) );
|
||||
// process the AST ( Abstract Syntax Tree ) to get info for the
|
||||
// file
|
||||
monitor.subTask( String.format(
|
||||
Messages.WesnothProjectBuilder_22, filePath ) );
|
||||
|
||||
WMLConfig config = projectCache_.getWMLConfig( filePath );
|
||||
SimpleWMLParser parser = new SimpleWMLParser( file, config, projectCache_ );
|
||||
parser.parse( );
|
||||
WMLConfig config = projectCache_.getWMLConfig( filePath );
|
||||
SimpleWMLParser parser = new SimpleWMLParser( file, config,
|
||||
projectCache_ );
|
||||
parser.parse( );
|
||||
|
||||
monitor.worked(10);
|
||||
monitor.worked( 10 );
|
||||
|
||||
} catch (Exception e)
|
||||
{
|
||||
Logger.getInstance().logException(e);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings( "unused" )
|
||||
private void runWMLLint( String installName, IProgressMonitor monitor, IFile file )
|
||||
{
|
||||
monitor.subTask( String.format( "Running WMLlint on file %s ...", file.getName( ) ) );
|
||||
ExternalToolInvoker tool = WMLTools.runWMLLint( installName,
|
||||
file.getLocation().toOSString(), false, false );
|
||||
tool.waitForTool();
|
||||
|
||||
try {
|
||||
file.deleteMarkers(Constants.MARKER_WMLLINT, false, IResource.DEPTH_INFINITE);
|
||||
}
|
||||
catch ( CoreException e ) {
|
||||
Logger.getInstance( ).logException( e );
|
||||
} catch( Exception e ) {
|
||||
Logger.getInstance( ).logException( e );
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
String[] output = StringUtils.getLines(tool.getErrorContent());
|
||||
for(String line : output)
|
||||
WMLTools.parseAndAddMarkers( line, Constants.MARKER_WMLLINT );
|
||||
|
||||
monitor.worked(20);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the wmlscope for the specified file
|
||||
* @param monitor
|
||||
* @param file
|
||||
* @throws CoreException
|
||||
*/
|
||||
@SuppressWarnings( "unused" )
|
||||
private void runWMLScope( String installName, IProgressMonitor monitor, IFile file )
|
||||
{
|
||||
monitor.subTask( String.format( "Running WMLScope on file %s ...", file.getName( ) ) );
|
||||
ExternalToolInvoker tool = WMLTools.runWMLScope( installName,
|
||||
file.getLocation().toOSString(), false );
|
||||
tool.waitForTool();
|
||||
@SuppressWarnings( "unused" )
|
||||
private void runWMLLint( String installName, IProgressMonitor monitor,
|
||||
IFile file )
|
||||
{
|
||||
monitor.subTask( String.format( "Running WMLlint on file %s ...",
|
||||
file.getName( ) ) );
|
||||
ExternalToolInvoker tool = WMLTools.runWMLLint( installName, file
|
||||
.getLocation( ).toOSString( ), false, false );
|
||||
tool.waitForTool( );
|
||||
|
||||
try {
|
||||
file.deleteMarkers(Constants.MARKER_WMLSCOPE, false, IResource.DEPTH_INFINITE);
|
||||
}
|
||||
catch ( CoreException e ) {
|
||||
file.deleteMarkers( Constants.MARKER_WMLLINT, false,
|
||||
IResource.DEPTH_INFINITE );
|
||||
} catch( CoreException e ) {
|
||||
Logger.getInstance( ).logException( e );
|
||||
}
|
||||
|
||||
String[] output = StringUtils.getLines(tool.getErrorContent());
|
||||
for(String line : output)
|
||||
String[] output = StringUtils.getLines( tool.getErrorContent( ) );
|
||||
for( String line: output )
|
||||
WMLTools.parseAndAddMarkers( line, Constants.MARKER_WMLLINT );
|
||||
|
||||
monitor.worked( 20 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the wmlscope for the specified file
|
||||
*
|
||||
* @param monitor
|
||||
* @param file
|
||||
* @throws CoreException
|
||||
*/
|
||||
@SuppressWarnings( "unused" )
|
||||
private void runWMLScope( String installName, IProgressMonitor monitor,
|
||||
IFile file )
|
||||
{
|
||||
monitor.subTask( String.format( "Running WMLScope on file %s ...",
|
||||
file.getName( ) ) );
|
||||
ExternalToolInvoker tool = WMLTools.runWMLScope( installName, file
|
||||
.getLocation( ).toOSString( ), false );
|
||||
tool.waitForTool( );
|
||||
|
||||
try {
|
||||
file.deleteMarkers( Constants.MARKER_WMLSCOPE, false,
|
||||
IResource.DEPTH_INFINITE );
|
||||
} catch( CoreException e ) {
|
||||
Logger.getInstance( ).logException( e );
|
||||
}
|
||||
|
||||
String[] output = StringUtils.getLines( tool.getErrorContent( ) );
|
||||
for( String line: output )
|
||||
WMLTools.parseAndAddMarkers( line, Constants.MARKER_WMLSCOPE );
|
||||
monitor.worked(20);
|
||||
}
|
||||
monitor.worked( 20 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,86 +13,84 @@ import org.eclipse.core.resources.IProject;
|
|||
import org.eclipse.core.resources.IProjectDescription;
|
||||
import org.eclipse.core.resources.IProjectNature;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
import org.wesnoth.Constants;
|
||||
|
||||
|
||||
public class WesnothProjectNature implements IProjectNature
|
||||
{
|
||||
private IProject project;
|
||||
private IProject project;
|
||||
|
||||
@Override
|
||||
public void configure() throws CoreException
|
||||
{
|
||||
IProjectDescription desc = project.getDescription();
|
||||
ICommand[] commands = desc.getBuildSpec();
|
||||
@Override
|
||||
public void configure( ) throws CoreException
|
||||
{
|
||||
IProjectDescription desc = project.getDescription( );
|
||||
ICommand[] commands = desc.getBuildSpec( );
|
||||
|
||||
boolean wesnothConfigured = false;
|
||||
boolean xtextConfigured = false;
|
||||
int configured = 0;
|
||||
for (int i = 0; i < commands.length; ++i)
|
||||
{
|
||||
if (commands[i].getBuilderName().equals(Constants.BUIILDER_WESNOTH))
|
||||
{
|
||||
wesnothConfigured = true;
|
||||
configured++;
|
||||
}
|
||||
if (commands[i].getBuilderName().equals(Constants.BUILDER_XTEXT))
|
||||
{
|
||||
xtextConfigured = true;
|
||||
configured++;
|
||||
}
|
||||
}
|
||||
if (configured == 2)
|
||||
return;
|
||||
boolean wesnothConfigured = false;
|
||||
boolean xtextConfigured = false;
|
||||
int configured = 0;
|
||||
for( int i = 0; i < commands.length; ++i ) {
|
||||
if( commands[i].getBuilderName( ).equals(
|
||||
Constants.BUIILDER_WESNOTH ) ) {
|
||||
wesnothConfigured = true;
|
||||
configured++;
|
||||
}
|
||||
if( commands[i].getBuilderName( ).equals( Constants.BUILDER_XTEXT ) ) {
|
||||
xtextConfigured = true;
|
||||
configured++;
|
||||
}
|
||||
}
|
||||
if( configured == 2 )
|
||||
return;
|
||||
|
||||
ICommand[] newCommands = new ICommand[commands.length + (2 - configured)];
|
||||
System.arraycopy(commands, 0, newCommands, 0, commands.length);
|
||||
if (wesnothConfigured == false)
|
||||
{
|
||||
ICommand command = desc.newCommand();
|
||||
command.setBuilderName(Constants.BUIILDER_WESNOTH);
|
||||
newCommands[newCommands.length - 1] = command;
|
||||
}
|
||||
if (xtextConfigured == false)
|
||||
{
|
||||
ICommand command = desc.newCommand();
|
||||
command.setBuilderName(Constants.BUILDER_XTEXT);
|
||||
newCommands[newCommands.length - (2 - configured)] = command;
|
||||
}
|
||||
desc.setBuildSpec(newCommands);
|
||||
project.setDescription(desc, null);
|
||||
}
|
||||
ICommand[] newCommands = new ICommand[commands.length
|
||||
+ ( 2 - configured )];
|
||||
System.arraycopy( commands, 0, newCommands, 0, commands.length );
|
||||
if( wesnothConfigured == false ) {
|
||||
ICommand command = desc.newCommand( );
|
||||
command.setBuilderName( Constants.BUIILDER_WESNOTH );
|
||||
newCommands[newCommands.length - 1] = command;
|
||||
}
|
||||
if( xtextConfigured == false ) {
|
||||
ICommand command = desc.newCommand( );
|
||||
command.setBuilderName( Constants.BUILDER_XTEXT );
|
||||
newCommands[newCommands.length - ( 2 - configured )] = command;
|
||||
}
|
||||
desc.setBuildSpec( newCommands );
|
||||
project.setDescription( desc, null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deconfigure() throws CoreException
|
||||
{
|
||||
IProjectDescription description = getProject().getDescription();
|
||||
ICommand[] commands = description.getBuildSpec();
|
||||
for (int i = 0; i < commands.length; ++i)
|
||||
{
|
||||
if (commands[i].getBuilderName().equals(Constants.BUIILDER_WESNOTH) ||
|
||||
commands[i].getBuilderName().equals(Constants.BUILDER_XTEXT))
|
||||
{
|
||||
ICommand[] newCommands = new ICommand[commands.length - 1];
|
||||
System.arraycopy(commands, 0, newCommands, 0, i);
|
||||
System.arraycopy(commands, i + 1, newCommands, i,
|
||||
commands.length - i - 1);
|
||||
description.setBuildSpec(newCommands);
|
||||
project.setDescription(description, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void deconfigure( ) throws CoreException
|
||||
{
|
||||
IProjectDescription description = getProject( ).getDescription( );
|
||||
ICommand[] commands = description.getBuildSpec( );
|
||||
for( int i = 0; i < commands.length; ++i ) {
|
||||
if( commands[i].getBuilderName( ).equals(
|
||||
Constants.BUIILDER_WESNOTH )
|
||||
|| commands[i].getBuilderName( ).equals(
|
||||
Constants.BUILDER_XTEXT ) ) {
|
||||
ICommand[] newCommands = new ICommand[commands.length - 1];
|
||||
System.arraycopy( commands, 0, newCommands, 0, i );
|
||||
System.arraycopy( commands, i + 1, newCommands, i,
|
||||
commands.length - i - 1 );
|
||||
description.setBuildSpec( newCommands );
|
||||
project.setDescription( description, null );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IProject getProject()
|
||||
{
|
||||
return project;
|
||||
}
|
||||
@Override
|
||||
public IProject getProject( )
|
||||
{
|
||||
return project;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProject(IProject project)
|
||||
{
|
||||
this.project = project;
|
||||
}
|
||||
@Override
|
||||
public void setProject( IProject project )
|
||||
{
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,13 +2,14 @@ package org.wesnoth.editors;
|
|||
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.ui.IEditorLauncher;
|
||||
|
||||
import org.wesnoth.utils.GameUtils;
|
||||
|
||||
public class MapFileEditor implements IEditorLauncher
|
||||
{
|
||||
@Override
|
||||
public void open(IPath file)
|
||||
{
|
||||
GameUtils.startEditor(file.toOSString());
|
||||
}
|
||||
@Override
|
||||
public void open( IPath file )
|
||||
{
|
||||
GameUtils.startEditor( file.toOSString( ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,45 +13,52 @@ import org.eclipse.xtext.formatting.impl.FormattingConfig;
|
|||
|
||||
/**
|
||||
* This class contains custom formatting description.
|
||||
*
|
||||
*
|
||||
* see : http://www.eclipse.org/Xtext/documentation/latest/xtext.html#formatting
|
||||
* on how and when to use it
|
||||
*
|
||||
* Also see {@link org.eclipse.xtext.xtext.XtextFormattingTokenSerializer} as an example
|
||||
*
|
||||
* Also see {@link org.eclipse.xtext.xtext.XtextFormattingTokenSerializer} as an
|
||||
* example
|
||||
*/
|
||||
public class WMLFormatter extends AbstractDeclarativeFormatter
|
||||
{
|
||||
|
||||
public WMLFormatter()
|
||||
{
|
||||
super();
|
||||
}
|
||||
public WMLFormatter( )
|
||||
{
|
||||
super( );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configureFormatting(FormattingConfig c)
|
||||
{
|
||||
org.wesnoth.services.WMLGrammarAccess f = (org.wesnoth.services.WMLGrammarAccess) getGrammarAccess();
|
||||
@Override
|
||||
protected void configureFormatting( FormattingConfig c )
|
||||
{
|
||||
org.wesnoth.services.WMLGrammarAccess f = ( org.wesnoth.services.WMLGrammarAccess ) getGrammarAccess( );
|
||||
|
||||
// disable autoline-wrap for now
|
||||
c.setAutoLinewrap(500);
|
||||
// disable autoline-wrap for now
|
||||
c.setAutoLinewrap( 500 );
|
||||
|
||||
// no space after '[' and '[/'
|
||||
c.setNoSpace().after(f.getWMLTagAccess().getLeftSquareBracketKeyword_0());
|
||||
c.setNoSpace().after(f.getWMLTagAccess().getLeftSquareBracketSolidusKeyword_5());
|
||||
// no space after '[' and '[/'
|
||||
c.setNoSpace( ).after(
|
||||
f.getWMLTagAccess( ).getLeftSquareBracketKeyword_0( ) );
|
||||
c.setNoSpace( ).after(
|
||||
f.getWMLTagAccess( ).getLeftSquareBracketSolidusKeyword_5( ) );
|
||||
|
||||
// no space before and after ']'
|
||||
c.setNoSpace().around(f.getWMLTagAccess().getRightSquareBracketKeyword_3());
|
||||
c.setNoSpace().around(f.getWMLTagAccess().getRightSquareBracketKeyword_7());
|
||||
// no space before and after ']'
|
||||
c.setNoSpace( ).around(
|
||||
f.getWMLTagAccess( ).getRightSquareBracketKeyword_3( ) );
|
||||
c.setNoSpace( ).around(
|
||||
f.getWMLTagAccess( ).getRightSquareBracketKeyword_7( ) );
|
||||
|
||||
// no space before and after the '=' in 'key=value'
|
||||
c.setNoSpace().around(f.getWMLKeyAccess().getEqualsSignKeyword_1());
|
||||
// no space before and after the '=' in 'key=value'
|
||||
c.setNoSpace( ).around( f.getWMLKeyAccess( ).getEqualsSignKeyword_1( ) );
|
||||
|
||||
// one indentation after tag ...
|
||||
c.setIndentationIncrement().before(f.getWMLTagAccess().getExpressionsAssignment_4( ));
|
||||
// one indentation after tag ...
|
||||
c.setIndentationIncrement( ).before(
|
||||
f.getWMLTagAccess( ).getExpressionsAssignment_4( ) );
|
||||
|
||||
// but get back the [/<tagname>]
|
||||
c.setIndentationDecrement().before(f.getWMLTagAccess().getLeftSquareBracketSolidusKeyword_5());
|
||||
// but get back the [/<tagname>]
|
||||
c.setIndentationDecrement( ).before(
|
||||
f.getWMLTagAccess( ).getLeftSquareBracketSolidusKeyword_5( ) );
|
||||
|
||||
c.setLinewrap(0, 1, 2).before(f.getSL_COMMENTRule());
|
||||
}
|
||||
c.setLinewrap( 0, 1, 2 ).before( f.getSL_COMMENTRule( ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.eclipse.core.commands.AbstractHandler;
|
|||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.swt.SWT;
|
||||
|
||||
import org.wesnoth.Logger;
|
||||
import org.wesnoth.Messages;
|
||||
import org.wesnoth.utils.GUIUtils;
|
||||
|
@ -21,23 +22,23 @@ import org.wesnoth.utils.WorkspaceUtils;
|
|||
|
||||
public class ImportMapHandler extends AbstractHandler
|
||||
{
|
||||
@Override
|
||||
public Object execute(ExecutionEvent event)
|
||||
{
|
||||
IFolder selectedFolder = WorkspaceUtils.getSelectedFolder();
|
||||
if (selectedFolder == null)
|
||||
{
|
||||
Logger.getInstance().log("no directory selected (importMapHandler)", //$NON-NLS-1$
|
||||
Messages.ImportMapHandler_1);
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Object execute( ExecutionEvent event )
|
||||
{
|
||||
IFolder selectedFolder = WorkspaceUtils.getSelectedFolder( );
|
||||
if( selectedFolder == null ) {
|
||||
Logger.getInstance( ).log(
|
||||
"no directory selected (importMapHandler)", //$NON-NLS-1$
|
||||
Messages.ImportMapHandler_1 );
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!selectedFolder.getName().equals("maps") && //$NON-NLS-1$
|
||||
GUIUtils.showMessageBox(Messages.ImportMapHandler_3,
|
||||
SWT.ICON_QUESTION | SWT.YES | SWT.NO) == SWT.NO)
|
||||
return null;
|
||||
if( ! selectedFolder.getName( ).equals( "maps" ) && //$NON-NLS-1$
|
||||
GUIUtils.showMessageBox( Messages.ImportMapHandler_3,
|
||||
SWT.ICON_QUESTION | SWT.YES | SWT.NO ) == SWT.NO )
|
||||
return null;
|
||||
|
||||
MapUtils.importMap();
|
||||
return null;
|
||||
}
|
||||
MapUtils.importMap( );
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,15 +10,16 @@ package org.wesnoth.handlers;
|
|||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
|
||||
import org.wesnoth.utils.GameUtils;
|
||||
|
||||
|
||||
public class OpenEditorHandler extends AbstractHandler
|
||||
{
|
||||
@Override
|
||||
public Object execute(ExecutionEvent event)
|
||||
{
|
||||
GameUtils.startEditor();
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Object execute( ExecutionEvent event )
|
||||
{
|
||||
GameUtils.startEditor( );
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,15 +10,16 @@ package org.wesnoth.handlers;
|
|||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
|
||||
import org.wesnoth.utils.GameUtils;
|
||||
|
||||
|
||||
public class OpenGameHandler extends AbstractHandler
|
||||
{
|
||||
@Override
|
||||
public Object execute(ExecutionEvent event)
|
||||
{
|
||||
GameUtils.startGame();
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Object execute( ExecutionEvent event )
|
||||
{
|
||||
GameUtils.startGame( );
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ package org.wesnoth.handlers;
|
|||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
|
||||
import org.wesnoth.Logger;
|
||||
import org.wesnoth.Messages;
|
||||
import org.wesnoth.utils.GameUtils;
|
||||
|
@ -19,25 +20,25 @@ import org.wesnoth.utils.WorkspaceUtils;
|
|||
|
||||
public class OpenMapInEditorHandler extends AbstractHandler
|
||||
{
|
||||
@Override
|
||||
public Object execute(ExecutionEvent event)
|
||||
{
|
||||
IFile selectedFile = WorkspaceUtils.getSelectedFile();
|
||||
if (selectedFile == null)
|
||||
{
|
||||
Logger.getInstance().log("file null (open map handler)", //$NON-NLS-1$
|
||||
Messages.OpenMapInEditorHandler_1);
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Object execute( ExecutionEvent event )
|
||||
{
|
||||
IFile selectedFile = WorkspaceUtils.getSelectedFile( );
|
||||
if( selectedFile == null ) {
|
||||
Logger.getInstance( ).log( "file null (open map handler)", //$NON-NLS-1$
|
||||
Messages.OpenMapInEditorHandler_1 );
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!selectedFile.getName().endsWith(".map")) //$NON-NLS-1$
|
||||
{
|
||||
Logger.getInstance().log("non-map file selected: "+selectedFile.getName(), //$NON-NLS-1$
|
||||
Messages.OpenMapInEditorHandler_4);
|
||||
return null;
|
||||
}
|
||||
if( ! selectedFile.getName( ).endsWith( ".map" ) ) //$NON-NLS-1$
|
||||
{
|
||||
Logger.getInstance( ).log(
|
||||
"non-map file selected: " + selectedFile.getName( ), //$NON-NLS-1$
|
||||
Messages.OpenMapInEditorHandler_4 );
|
||||
return null;
|
||||
}
|
||||
|
||||
GameUtils.startEditor(selectedFile.getLocation().toOSString());
|
||||
return null;
|
||||
}
|
||||
GameUtils.startEditor( selectedFile.getLocation( ).toOSString( ) );
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import java.util.Map.Entry;
|
|||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
||||
import org.wesnoth.Messages;
|
||||
import org.wesnoth.projects.ProjectCache;
|
||||
import org.wesnoth.projects.ProjectUtils;
|
||||
|
@ -22,21 +23,20 @@ import org.wesnoth.utils.GUIUtils;
|
|||
|
||||
public class ReloadFilesHandler extends AbstractHandler
|
||||
{
|
||||
@Override
|
||||
public Object execute(ExecutionEvent event)
|
||||
{
|
||||
SchemaParser.reloadSchemas( true );
|
||||
@Override
|
||||
public Object execute( ExecutionEvent event )
|
||||
{
|
||||
SchemaParser.reloadSchemas( true );
|
||||
|
||||
TemplateProvider.getInstance().loadTemplates();
|
||||
TemplateProvider.getInstance( ).loadTemplates( );
|
||||
|
||||
// reload the cache only for already loaded files
|
||||
for(Entry<IProject, ProjectCache> cache :
|
||||
ProjectUtils.getProjectCaches().entrySet())
|
||||
{
|
||||
cache.getValue().readDefines(true);
|
||||
}
|
||||
// reload the cache only for already loaded files
|
||||
for( Entry< IProject, ProjectCache > cache: ProjectUtils
|
||||
.getProjectCaches( ).entrySet( ) ) {
|
||||
cache.getValue( ).readDefines( true );
|
||||
}
|
||||
|
||||
GUIUtils.showInfoMessageBox(Messages.ReloadFilesHandler_0);
|
||||
return null;
|
||||
}
|
||||
GUIUtils.showInfoMessageBox( Messages.ReloadFilesHandler_0 );
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,14 +10,16 @@ package org.wesnoth.handlers;
|
|||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
|
||||
import org.wesnoth.utils.WorkspaceUtils;
|
||||
|
||||
|
||||
public class SetupWorkspaceHandler extends AbstractHandler
|
||||
{
|
||||
@Override
|
||||
public Object execute(ExecutionEvent event) {
|
||||
WorkspaceUtils.setupWorkspace(true);
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Object execute( ExecutionEvent event )
|
||||
{
|
||||
WorkspaceUtils.setupWorkspace( true );
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.eclipse.core.commands.AbstractHandler;
|
|||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
|
||||
import org.wesnoth.utils.ResourceUtils;
|
||||
import org.wesnoth.utils.WorkspaceUtils;
|
||||
|
||||
|
@ -21,223 +22,235 @@ import org.wesnoth.utils.WorkspaceUtils;
|
|||
@Deprecated
|
||||
public class TestHandler extends AbstractHandler
|
||||
{
|
||||
@Override
|
||||
public Object execute(ExecutionEvent event) throws ExecutionException
|
||||
{
|
||||
IFile file = WorkspaceUtils.getSelectedFile( );
|
||||
System.out.println( ResourceUtils.getWMLRoot( file ));
|
||||
@Override
|
||||
public Object execute( ExecutionEvent event ) throws ExecutionException
|
||||
{
|
||||
IFile file = WorkspaceUtils.getSelectedFile( );
|
||||
System.out.println( ResourceUtils.getWMLRoot( file ) );
|
||||
|
||||
// IFile file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(new Path("E:\\work\\java\\runtime-EclipseApplication\\A_Simple_Campaign\\scenarios\\atemplate.cfg"));
|
||||
// try
|
||||
// {
|
||||
// file.deleteMarkers(Constants.MARKER_WMLSCOPE, false, IResource.DEPTH_INFINITE);
|
||||
// IMarker a= file.createMarker(Constants.MARKER_WMLLINT);
|
||||
// a.setAttribute(IMarker.LINE_NUMBER, 3);
|
||||
// a.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
|
||||
// }
|
||||
// catch (CoreException e)
|
||||
// {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// IFile file =
|
||||
// ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(new
|
||||
// Path("E:\\work\\java\\runtime-EclipseApplication\\A_Simple_Campaign\\scenarios\\atemplate.cfg"));
|
||||
// try
|
||||
// {
|
||||
// file.deleteMarkers(Constants.MARKER_WMLSCOPE, false,
|
||||
// IResource.DEPTH_INFINITE);
|
||||
// IMarker a= file.createMarker(Constants.MARKER_WMLLINT);
|
||||
// a.setAttribute(IMarker.LINE_NUMBER, 3);
|
||||
// a.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
|
||||
// }
|
||||
// catch (CoreException e)
|
||||
// {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
|
||||
// DialogSettings set = new DialogSettings("proj");
|
||||
// IDialogSettings section2 = set.addNewSection("scenario");
|
||||
// section2.put("filename", "name");
|
||||
// IDialogSettings section3 = set.addNewSection("scenario2");
|
||||
// section3.put("filename", "name2");
|
||||
// try
|
||||
// {
|
||||
// set.save("D:/timo.txt");
|
||||
// }
|
||||
// catch (IOException e)
|
||||
// {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// IWorkingSet set = WorkspaceUtils.getWorkingSetManager().getWorkingSet("Default");
|
||||
// WorkingSetFilterActionGroup action = new WorkingSetFilterActionGroup(Activator.getShell(),
|
||||
// null);
|
||||
// action.setWorkingSet(set);
|
||||
// DefinesSAXHandler handler = (DefinesSAXHandler) ResourceUtils.getWMLSAXHandlerFromResource(
|
||||
// "d:/tmp/wesnoth_plugin/a/_MACROS_.cfg",
|
||||
// new DefinesSAXHandler());
|
||||
// System.out.println(handler.getDefines().size());
|
||||
// try
|
||||
// {
|
||||
// BuildCommand c = ((BuildCommand)WorkspaceUtils.getSelectedProject().getDescription().getBuildSpec()[1]);
|
||||
// System.out.println(c);
|
||||
// }
|
||||
// catch (CoreException e)
|
||||
// {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// IFile sel = WorkspaceUtils.getSelectedFile();
|
||||
// if (sel == null)
|
||||
// return null;
|
||||
// ExternalToolInvoker parser = WMLTools.runWMLParser2(sel.getLocation().toOSString());
|
||||
// parser.waitForTool();
|
||||
// ///System.out.println(parser.getOutputContent());
|
||||
// try
|
||||
// {
|
||||
// SAXParser saxparser = SAXParserFactory.newInstance().newSAXParser();
|
||||
// WMLSaxHandler handler = new WMLSaxHandler();
|
||||
// saxparser.parse(new InputSource(new StringReader(parser.getOutputContent())), handler);
|
||||
//
|
||||
//// GUIUtils.showInfoMessageBox("AA: ");
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// try
|
||||
// {
|
||||
// MessageConsole con = GUIUtils.createConsole("BB", null, true);
|
||||
// OutputStream s = con.newMessageStream();
|
||||
// s.write("AAAAAAAAAAAAAA".getBytes());
|
||||
// }
|
||||
// catch (IOException e)
|
||||
// {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// try
|
||||
// {
|
||||
// IProject proj = WorkspaceUtils.getSelectedProject();
|
||||
// String path = proj.getLocation().toOSString() + "/.wesnoth";
|
||||
// Properties config = new Properties();
|
||||
// config.setProperty("diff", "val");
|
||||
// config.storeToXML(new FileOutputStream(path), null);
|
||||
// GUIUtils.showInfoMessageBox(config.getProperty("diff"));
|
||||
//// if (proj != null)
|
||||
//// {
|
||||
//// int go = GUIUtils.showMessageBox("a", SWT.YES | SWT.NO);
|
||||
//// if (go == SWT.YES)
|
||||
//// {
|
||||
//// //org.eclipse.core.resources.textmarkerIMarker.TEXT
|
||||
//// IMarker mark = proj.createMarker("sett");
|
||||
//// mark.setAttribute("diff", "VAL");
|
||||
//// }
|
||||
//// else
|
||||
//// {
|
||||
//// IMarker[] marks = proj.findMarkers("sett", true, IResource.DEPTH_INFINITE);
|
||||
//// System.out.println(marks.length);
|
||||
//// }
|
||||
//// }
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//System.out.println(WorkspaceUtils.getSelectedContainer());
|
||||
// MessageConsole con = GUIUtils.createConsole("TIMO", null, true);
|
||||
// List<String> arguments = new ArrayList<String>();
|
||||
// arguments.add(Preferences.getString(Constants.P_WESNOTH_WORKING_DIR));
|
||||
// if (tool == null)
|
||||
// {
|
||||
// tool = new ExternalToolInvoker("D:/timo/conapp.exe", arguments);
|
||||
// tool.runTool();
|
||||
// tool.startErrorMonitor();
|
||||
// tool.startOutputMonitor();
|
||||
// tool.waitForTool();
|
||||
// System.out.println(tool.getErrorContent());
|
||||
// System.out.println(tool.getOutputContent());
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// tool.kill(true);
|
||||
// }
|
||||
//tool.waitForTool();
|
||||
//System.out.println("Exitt");
|
||||
//String stdin = EditorUtils.getEditorDocument().get();
|
||||
//EditorUtils.replaceEditorText(WMLTools.runWMLIndent(null, stdin, false, false, false));
|
||||
// IEditorReference[] files =
|
||||
// Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getPages()[0].getEditorReferences();
|
||||
// for (IEditorReference file : files)
|
||||
// {
|
||||
// if (file.isDirty())
|
||||
// file.getEditor(false).doSave(null);
|
||||
// }
|
||||
// ProgressMonitorDialog dialog = new ProgressMonitorDialog(Activator.getShell());
|
||||
// try
|
||||
// {
|
||||
// dialog.run(true, true, new IRunnableWithProgress() {
|
||||
// @Override
|
||||
// public void run(IProgressMonitor monitor)
|
||||
// {
|
||||
// monitor.beginTask("Some nice progress message here ...", 100);
|
||||
// // execute the task ...
|
||||
// try
|
||||
// {
|
||||
// Thread.sleep(2000);
|
||||
// } catch (InterruptedException e)
|
||||
// {
|
||||
// Logger.getInstance().logException(e);
|
||||
// }
|
||||
// monitor.done();
|
||||
// }
|
||||
// });
|
||||
// } catch (InvocationTargetException e)
|
||||
// {
|
||||
// Logger.getInstance().logException(e);
|
||||
// } catch (InterruptedException e)
|
||||
// {
|
||||
// Logger.getInstance().logException(e);
|
||||
// }
|
||||
// UIJob job1 = new UIJob("My the job") {
|
||||
//
|
||||
// @Override
|
||||
// public IStatus runInUIThread(IProgressMonitor monitor)
|
||||
// {
|
||||
// monitor.beginTask("Some nice progress message here ...", 100);
|
||||
// // execute the task ...try
|
||||
// try
|
||||
// {
|
||||
// Thread.sleep(2000);
|
||||
// } catch (InterruptedException e)
|
||||
// {
|
||||
// Logger.getInstance().logException(e);
|
||||
// }
|
||||
// monitor.done();
|
||||
// return Status.OK_STATUS;
|
||||
// }
|
||||
// };
|
||||
// //job1.schedule();
|
||||
// WorkbenchJob job2 = new WorkbenchJob("asdasdd ") {
|
||||
//
|
||||
// @Override
|
||||
// public IStatus runInUIThread(IProgressMonitor monitor)
|
||||
// {
|
||||
// monitor.beginTask("Some nice progress message here ...", 100);
|
||||
// // execute the task ...try
|
||||
// try
|
||||
// {
|
||||
// Thread.sleep(2000);
|
||||
// } catch (InterruptedException e)
|
||||
// {
|
||||
// Logger.getInstance().logException(e);
|
||||
// }
|
||||
// monitor.done();
|
||||
// return Status.OK_STATUS;
|
||||
// }
|
||||
// };
|
||||
// job2.schedule();
|
||||
// new WorkspaceJob("My new job") {
|
||||
// @Override
|
||||
// public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException
|
||||
// {
|
||||
// monitor.beginTask("Some nice progress message here ...", 100);
|
||||
// // execute the task ...try
|
||||
// try
|
||||
// {
|
||||
// Thread.sleep(2000);
|
||||
// } catch (InterruptedException e)
|
||||
// {
|
||||
// Logger.getInstance().logException(e);
|
||||
// }
|
||||
// monitor.done();
|
||||
// return Status.OK_STATUS;
|
||||
// }
|
||||
// }.schedule();
|
||||
//job.schedule();
|
||||
return null;
|
||||
}
|
||||
// DialogSettings set = new DialogSettings("proj");
|
||||
// IDialogSettings section2 = set.addNewSection("scenario");
|
||||
// section2.put("filename", "name");
|
||||
// IDialogSettings section3 = set.addNewSection("scenario2");
|
||||
// section3.put("filename", "name2");
|
||||
// try
|
||||
// {
|
||||
// set.save("D:/timo.txt");
|
||||
// }
|
||||
// catch (IOException e)
|
||||
// {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// IWorkingSet set =
|
||||
// WorkspaceUtils.getWorkingSetManager().getWorkingSet("Default");
|
||||
// WorkingSetFilterActionGroup action = new
|
||||
// WorkingSetFilterActionGroup(Activator.getShell(),
|
||||
// null);
|
||||
// action.setWorkingSet(set);
|
||||
// DefinesSAXHandler handler = (DefinesSAXHandler)
|
||||
// ResourceUtils.getWMLSAXHandlerFromResource(
|
||||
// "d:/tmp/wesnoth_plugin/a/_MACROS_.cfg",
|
||||
// new DefinesSAXHandler());
|
||||
// System.out.println(handler.getDefines().size());
|
||||
// try
|
||||
// {
|
||||
// BuildCommand c =
|
||||
// ((BuildCommand)WorkspaceUtils.getSelectedProject().getDescription().getBuildSpec()[1]);
|
||||
// System.out.println(c);
|
||||
// }
|
||||
// catch (CoreException e)
|
||||
// {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// IFile sel = WorkspaceUtils.getSelectedFile();
|
||||
// if (sel == null)
|
||||
// return null;
|
||||
// ExternalToolInvoker parser =
|
||||
// WMLTools.runWMLParser2(sel.getLocation().toOSString());
|
||||
// parser.waitForTool();
|
||||
// ///System.out.println(parser.getOutputContent());
|
||||
// try
|
||||
// {
|
||||
// SAXParser saxparser = SAXParserFactory.newInstance().newSAXParser();
|
||||
// WMLSaxHandler handler = new WMLSaxHandler();
|
||||
// saxparser.parse(new InputSource(new
|
||||
// StringReader(parser.getOutputContent())), handler);
|
||||
//
|
||||
// // GUIUtils.showInfoMessageBox("AA: ");
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// try
|
||||
// {
|
||||
// MessageConsole con = GUIUtils.createConsole("BB", null, true);
|
||||
// OutputStream s = con.newMessageStream();
|
||||
// s.write("AAAAAAAAAAAAAA".getBytes());
|
||||
// }
|
||||
// catch (IOException e)
|
||||
// {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// try
|
||||
// {
|
||||
// IProject proj = WorkspaceUtils.getSelectedProject();
|
||||
// String path = proj.getLocation().toOSString() + "/.wesnoth";
|
||||
// Properties config = new Properties();
|
||||
// config.setProperty("diff", "val");
|
||||
// config.storeToXML(new FileOutputStream(path), null);
|
||||
// GUIUtils.showInfoMessageBox(config.getProperty("diff"));
|
||||
// // if (proj != null)
|
||||
// // {
|
||||
// // int go = GUIUtils.showMessageBox("a", SWT.YES | SWT.NO);
|
||||
// // if (go == SWT.YES)
|
||||
// // {
|
||||
// // //org.eclipse.core.resources.textmarkerIMarker.TEXT
|
||||
// // IMarker mark = proj.createMarker("sett");
|
||||
// // mark.setAttribute("diff", "VAL");
|
||||
// // }
|
||||
// // else
|
||||
// // {
|
||||
// // IMarker[] marks = proj.findMarkers("sett", true,
|
||||
// IResource.DEPTH_INFINITE);
|
||||
// // System.out.println(marks.length);
|
||||
// // }
|
||||
// // }
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// System.out.println(WorkspaceUtils.getSelectedContainer());
|
||||
// MessageConsole con = GUIUtils.createConsole("TIMO", null, true);
|
||||
// List<String> arguments = new ArrayList<String>();
|
||||
// arguments.add(Preferences.getString(Constants.P_WESNOTH_WORKING_DIR));
|
||||
// if (tool == null)
|
||||
// {
|
||||
// tool = new ExternalToolInvoker("D:/timo/conapp.exe", arguments);
|
||||
// tool.runTool();
|
||||
// tool.startErrorMonitor();
|
||||
// tool.startOutputMonitor();
|
||||
// tool.waitForTool();
|
||||
// System.out.println(tool.getErrorContent());
|
||||
// System.out.println(tool.getOutputContent());
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// tool.kill(true);
|
||||
// }
|
||||
// tool.waitForTool();
|
||||
// System.out.println("Exitt");
|
||||
// String stdin = EditorUtils.getEditorDocument().get();
|
||||
// EditorUtils.replaceEditorText(WMLTools.runWMLIndent(null, stdin,
|
||||
// false, false, false));
|
||||
// IEditorReference[] files =
|
||||
// Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getPages()[0].getEditorReferences();
|
||||
// for (IEditorReference file : files)
|
||||
// {
|
||||
// if (file.isDirty())
|
||||
// file.getEditor(false).doSave(null);
|
||||
// }
|
||||
// ProgressMonitorDialog dialog = new
|
||||
// ProgressMonitorDialog(Activator.getShell());
|
||||
// try
|
||||
// {
|
||||
// dialog.run(true, true, new IRunnableWithProgress() {
|
||||
// @Override
|
||||
// public void run(IProgressMonitor monitor)
|
||||
// {
|
||||
// monitor.beginTask("Some nice progress message here ...", 100);
|
||||
// // execute the task ...
|
||||
// try
|
||||
// {
|
||||
// Thread.sleep(2000);
|
||||
// } catch (InterruptedException e)
|
||||
// {
|
||||
// Logger.getInstance().logException(e);
|
||||
// }
|
||||
// monitor.done();
|
||||
// }
|
||||
// });
|
||||
// } catch (InvocationTargetException e)
|
||||
// {
|
||||
// Logger.getInstance().logException(e);
|
||||
// } catch (InterruptedException e)
|
||||
// {
|
||||
// Logger.getInstance().logException(e);
|
||||
// }
|
||||
// UIJob job1 = new UIJob("My the job") {
|
||||
//
|
||||
// @Override
|
||||
// public IStatus runInUIThread(IProgressMonitor monitor)
|
||||
// {
|
||||
// monitor.beginTask("Some nice progress message here ...", 100);
|
||||
// // execute the task ...try
|
||||
// try
|
||||
// {
|
||||
// Thread.sleep(2000);
|
||||
// } catch (InterruptedException e)
|
||||
// {
|
||||
// Logger.getInstance().logException(e);
|
||||
// }
|
||||
// monitor.done();
|
||||
// return Status.OK_STATUS;
|
||||
// }
|
||||
// };
|
||||
// //job1.schedule();
|
||||
// WorkbenchJob job2 = new WorkbenchJob("asdasdd ") {
|
||||
//
|
||||
// @Override
|
||||
// public IStatus runInUIThread(IProgressMonitor monitor)
|
||||
// {
|
||||
// monitor.beginTask("Some nice progress message here ...", 100);
|
||||
// // execute the task ...try
|
||||
// try
|
||||
// {
|
||||
// Thread.sleep(2000);
|
||||
// } catch (InterruptedException e)
|
||||
// {
|
||||
// Logger.getInstance().logException(e);
|
||||
// }
|
||||
// monitor.done();
|
||||
// return Status.OK_STATUS;
|
||||
// }
|
||||
// };
|
||||
// job2.schedule();
|
||||
// new WorkspaceJob("My new job") {
|
||||
// @Override
|
||||
// public IStatus runInWorkspace(IProgressMonitor monitor) throws
|
||||
// CoreException
|
||||
// {
|
||||
// monitor.beginTask("Some nice progress message here ...", 100);
|
||||
// // execute the task ...try
|
||||
// try
|
||||
// {
|
||||
// Thread.sleep(2000);
|
||||
// } catch (InterruptedException e)
|
||||
// {
|
||||
// Logger.getInstance().logException(e);
|
||||
// }
|
||||
// monitor.done();
|
||||
// return Status.OK_STATUS;
|
||||
// }
|
||||
// }.schedule();
|
||||
// job.schedule();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,16 +19,17 @@ import org.eclipse.swt.widgets.Combo;
|
|||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
import org.wesnoth.installs.WesnothInstallsUtils;
|
||||
import org.wesnoth.wizards.WizardPageTemplate;
|
||||
|
||||
public class ImportProjectPage extends WizardPageTemplate
|
||||
{
|
||||
private DirectoryFieldEditor projectPathField_;
|
||||
private Text txtProjectName_;
|
||||
private Combo cmbInstalls_;
|
||||
private Text txtProjectName_;
|
||||
private Combo cmbInstalls_;
|
||||
|
||||
protected ImportProjectPage( )
|
||||
protected ImportProjectPage( )
|
||||
{
|
||||
super( "importProjectPage0" );
|
||||
|
||||
|
@ -41,7 +42,7 @@ public class ImportProjectPage extends WizardPageTemplate
|
|||
public void createControl( Composite parent )
|
||||
{
|
||||
super.createControl( parent );
|
||||
Composite container = new Composite(parent, SWT.NULL);
|
||||
Composite container = new Composite( parent, SWT.NULL );
|
||||
setControl( container );
|
||||
|
||||
ModifyListener listener = new ModifyListener( ) {
|
||||
|
@ -49,40 +50,45 @@ public class ImportProjectPage extends WizardPageTemplate
|
|||
@Override
|
||||
public void modifyText( ModifyEvent e )
|
||||
{
|
||||
updatePageIsComplete();
|
||||
updatePageIsComplete( );
|
||||
}
|
||||
};
|
||||
|
||||
projectPathField_ = new DirectoryFieldEditor( "project_path",
|
||||
"Directory to import:", container );
|
||||
projectPathField_.getTextControl( container ).addModifyListener( listener );
|
||||
projectPathField_.getTextControl( container ).addModifyListener(
|
||||
listener );
|
||||
|
||||
Label lblNewLabel = new Label(container, SWT.NONE);
|
||||
lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
|
||||
lblNewLabel.setText("Project Name:");
|
||||
Label lblNewLabel = new Label( container, SWT.NONE );
|
||||
lblNewLabel.setLayoutData( new GridData( SWT.RIGHT, SWT.CENTER, false,
|
||||
false, 1, 1 ) );
|
||||
lblNewLabel.setText( "Project Name:" );
|
||||
|
||||
txtProjectName_ = new Text(container, SWT.BORDER);
|
||||
txtProjectName_.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
|
||||
txtProjectName_ = new Text( container, SWT.BORDER );
|
||||
txtProjectName_.setLayoutData( new GridData( SWT.FILL, SWT.TOP, true,
|
||||
false, 2, 1 ) );
|
||||
txtProjectName_.addModifyListener( listener );
|
||||
|
||||
Label lblWesnothInstall = new Label(container, SWT.NONE);
|
||||
lblWesnothInstall.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
|
||||
lblWesnothInstall.setText("Wesnoth install:");
|
||||
Label lblWesnothInstall = new Label( container, SWT.NONE );
|
||||
lblWesnothInstall.setLayoutData( new GridData( SWT.RIGHT, SWT.CENTER,
|
||||
false, false, 1, 1 ) );
|
||||
lblWesnothInstall.setText( "Wesnoth install:" );
|
||||
|
||||
cmbInstalls_ = new Combo(container, SWT.READ_ONLY);
|
||||
cmbInstalls_.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
|
||||
cmbInstalls_ = new Combo( container, SWT.READ_ONLY );
|
||||
cmbInstalls_.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true,
|
||||
false, 2, 1 ) );
|
||||
WesnothInstallsUtils.fillComboWithInstalls( cmbInstalls_ );
|
||||
}
|
||||
|
||||
protected void updatePageIsComplete()
|
||||
protected void updatePageIsComplete( )
|
||||
{
|
||||
setPageComplete(
|
||||
! txtProjectName_.getText( ).isEmpty( ) &&
|
||||
new File( projectPathField_.getStringValue( ) ).exists( ) );
|
||||
setPageComplete( ! txtProjectName_.getText( ).isEmpty( )
|
||||
&& new File( projectPathField_.getStringValue( ) ).exists( ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the imported project's path
|
||||
*
|
||||
* @return A string with the project path
|
||||
*/
|
||||
public String getProjectPath( )
|
||||
|
@ -92,6 +98,7 @@ public class ImportProjectPage extends WizardPageTemplate
|
|||
|
||||
/**
|
||||
* Returns the imported project's name
|
||||
*
|
||||
* @return A string with the imported project's name
|
||||
*/
|
||||
public String getProjectName( )
|
||||
|
@ -101,9 +108,10 @@ public class ImportProjectPage extends WizardPageTemplate
|
|||
|
||||
/**
|
||||
* Returns the selected install name
|
||||
*
|
||||
* @return A string with the selected install name
|
||||
*/
|
||||
public String getSelectedInstallName()
|
||||
public String getSelectedInstallName( )
|
||||
{
|
||||
return cmbInstalls_.getText( );
|
||||
}
|
||||
|
|
|
@ -5,21 +5,23 @@ import java.lang.reflect.InvocationTargetException;
|
|||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||
import org.eclipse.ui.IImportWizard;
|
||||
|
||||
import org.wesnoth.Logger;
|
||||
import org.wesnoth.projects.ProjectUtils;
|
||||
import org.wesnoth.wizards.WizardTemplate;
|
||||
|
||||
public class ImportProjectWizard extends WizardTemplate implements IImportWizard
|
||||
public class ImportProjectWizard extends WizardTemplate implements
|
||||
IImportWizard
|
||||
{
|
||||
private ImportProjectPage page0_;
|
||||
|
||||
public ImportProjectWizard()
|
||||
public ImportProjectWizard( )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPages()
|
||||
public void addPages( )
|
||||
{
|
||||
super.addPages( );
|
||||
|
||||
|
@ -28,27 +30,24 @@ public class ImportProjectWizard extends WizardTemplate implements IImportWizard
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean performFinish()
|
||||
public boolean performFinish( )
|
||||
{
|
||||
IRunnableWithProgress op = new IRunnableWithProgress() {
|
||||
IRunnableWithProgress op = new IRunnableWithProgress( ) {
|
||||
@Override
|
||||
public void run(IProgressMonitor monitor)
|
||||
public void run( IProgressMonitor monitor )
|
||||
{
|
||||
ProjectUtils.createWesnothProject( page0_.getProjectName( ),
|
||||
page0_.getProjectPath( ), page0_.getSelectedInstallName(),
|
||||
monitor );
|
||||
monitor.done();
|
||||
page0_.getProjectPath( ),
|
||||
page0_.getSelectedInstallName( ), monitor );
|
||||
monitor.done( );
|
||||
}
|
||||
};
|
||||
try
|
||||
{
|
||||
getContainer().run(false, false, op);
|
||||
} catch (InterruptedException e)
|
||||
{
|
||||
try {
|
||||
getContainer( ).run( false, false, op );
|
||||
} catch( InterruptedException e ) {
|
||||
return false;
|
||||
} catch (InvocationTargetException e)
|
||||
{
|
||||
Logger.getInstance().logException(e);
|
||||
} catch( InvocationTargetException e ) {
|
||||
Logger.getInstance( ).logException( e );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -40,16 +40,18 @@ public class SelectWesnothInstallDialog extends Dialog
|
|||
protected Control createDialogArea( Composite parent )
|
||||
{
|
||||
Composite composite = new Composite( parent, SWT.NONE );
|
||||
composite.setLayout(new GridLayout(2, false));
|
||||
composite.setLayout( new GridLayout( 2, false ) );
|
||||
|
||||
Label lblWesnothInstall = new Label(composite, SWT.NONE);
|
||||
lblWesnothInstall.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
|
||||
lblWesnothInstall.setText("Wesnoth Install:");
|
||||
Label lblWesnothInstall = new Label( composite, SWT.NONE );
|
||||
lblWesnothInstall.setLayoutData( new GridData( SWT.RIGHT, SWT.CENTER,
|
||||
false, false, 1, 1 ) );
|
||||
lblWesnothInstall.setText( "Wesnoth Install:" );
|
||||
|
||||
cmbInstall_ = new Combo( composite, SWT.READ_ONLY );
|
||||
GridData gd_cmbInstall_ = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
|
||||
GridData gd_cmbInstall_ = new GridData( SWT.FILL, SWT.CENTER, true,
|
||||
false, 1, 1 );
|
||||
gd_cmbInstall_.widthHint = 163;
|
||||
cmbInstall_.setLayoutData(gd_cmbInstall_);
|
||||
cmbInstall_.setLayoutData( gd_cmbInstall_ );
|
||||
|
||||
WesnothInstallsUtils.fillComboWithInstalls( cmbInstall_ );
|
||||
|
||||
|
@ -57,15 +59,18 @@ public class SelectWesnothInstallDialog extends Dialog
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Point getInitialSize() {
|
||||
return new Point(291, 123);
|
||||
protected Point getInitialSize( )
|
||||
{
|
||||
return new Point( 291, 123 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the install selected by the user
|
||||
*
|
||||
* @return A string with the name of the install selected
|
||||
*/
|
||||
public String getSelectedInstallName( ){
|
||||
public String getSelectedInstallName( )
|
||||
{
|
||||
return cmbInstall_.getText( );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,21 +13,24 @@ public class WesnothInstall
|
|||
private String name_;
|
||||
private String version_;
|
||||
|
||||
public WesnothInstall(String name, String version)
|
||||
public WesnothInstall( String name, String version )
|
||||
{
|
||||
name_ = name;
|
||||
version_ = version;
|
||||
}
|
||||
|
||||
public String getName( ){
|
||||
public String getName( )
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
public String getVersion( ) {
|
||||
public String getVersion( )
|
||||
{
|
||||
return version_;
|
||||
}
|
||||
|
||||
public void setVersion( String newVersion ){
|
||||
public void setVersion( String newVersion )
|
||||
{
|
||||
version_ = newVersion;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.eclipse.core.resources.IResource;
|
|||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.Combo;
|
||||
|
||||
import org.wesnoth.Constants;
|
||||
import org.wesnoth.Logger;
|
||||
import org.wesnoth.Messages;
|
||||
|
@ -30,21 +31,24 @@ public class WesnothInstallsUtils
|
|||
/**
|
||||
* Returns a list of the current wesnoth installations available
|
||||
* in the preferences store
|
||||
*
|
||||
* @return A list with Wesnoth Installs
|
||||
*/
|
||||
public static List<WesnothInstall> getInstalls()
|
||||
public static List< WesnothInstall > getInstalls( )
|
||||
{
|
||||
List<WesnothInstall> installsList = new ArrayList<WesnothInstall>();
|
||||
List< WesnothInstall > installsList = new ArrayList< WesnothInstall >( );
|
||||
// unpack installs
|
||||
String[] installs = Preferences.getString( Constants.P_INST_INSTALL_LIST ).split( ";" ); //$NON-NLS-1$
|
||||
for ( String str : installs ){
|
||||
if ( str.isEmpty() )
|
||||
String[] installs = Preferences.getString(
|
||||
Constants.P_INST_INSTALL_LIST ).split( ";" ); //$NON-NLS-1$
|
||||
for( String str: installs ) {
|
||||
if( str.isEmpty( ) )
|
||||
continue;
|
||||
|
||||
String[] tokens = str.split( ":" ); //$NON-NLS-1$
|
||||
|
||||
if ( tokens.length != 2 ) {
|
||||
Logger.getInstance().logError( "invalid install [" + str + "] in installs list." ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
if( tokens.length != 2 ) {
|
||||
Logger.getInstance( ).logError(
|
||||
"invalid install [" + str + "] in installs list." ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -56,67 +60,82 @@ public class WesnothInstallsUtils
|
|||
|
||||
/**
|
||||
* Sets the specified Installs list in the preferences store
|
||||
* @param installsList The list to replace / set the installs list
|
||||
*
|
||||
* @param installsList
|
||||
* The list to replace / set the installs list
|
||||
*/
|
||||
public static void setInstalls( Collection<WesnothInstall> installsList )
|
||||
public static void setInstalls( Collection< WesnothInstall > installsList )
|
||||
{
|
||||
// pack back the installs
|
||||
StringBuilder installs = new StringBuilder();
|
||||
for ( WesnothInstall install : installsList ) {
|
||||
if ( installs.length() > 0 )
|
||||
StringBuilder installs = new StringBuilder( );
|
||||
for( WesnothInstall install: installsList ) {
|
||||
if( installs.length( ) > 0 )
|
||||
installs.append( ";" ); //$NON-NLS-1$
|
||||
|
||||
installs.append( install.getName( ) );
|
||||
installs.append( ":" ); //$NON-NLS-1$
|
||||
installs.append( install.getVersion( ) );
|
||||
}
|
||||
Preferences.getPreferences().setValue( Constants.P_INST_INSTALL_LIST, installs.toString() );
|
||||
Preferences.getPreferences( ).setValue( Constants.P_INST_INSTALL_LIST,
|
||||
installs.toString( ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the install name for the specified resource
|
||||
* @param resourcePath The path to the resource
|
||||
*
|
||||
* @param resourcePath
|
||||
* The path to the resource
|
||||
* @return The install name for the resource
|
||||
*/
|
||||
public static String getInstallNameForResource( String resourcePath )
|
||||
{
|
||||
if ( StringUtils.isNullOrEmpty( resourcePath ) )
|
||||
if( StringUtils.isNullOrEmpty( resourcePath ) )
|
||||
return "";
|
||||
|
||||
return getInstallNameForResource( ResourcesPlugin.getWorkspace( ).getRoot( ).
|
||||
findMember( resourcePath ) );
|
||||
return getInstallNameForResource( ResourcesPlugin.getWorkspace( )
|
||||
.getRoot( ).findMember( resourcePath ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the install name for the specified resource
|
||||
* @param resource The resource
|
||||
*
|
||||
* @param resource
|
||||
* The resource
|
||||
* @return The install name for the resource
|
||||
*/
|
||||
public static String getInstallNameForResource( IResource resource )
|
||||
{
|
||||
if ( resource == null || ! resource.exists( ) )
|
||||
if( resource == null || ! resource.exists( ) )
|
||||
return ""; //$NON-NLS-1$
|
||||
|
||||
return ProjectUtils.getCacheForProject( resource.getProject( ) ).getInstallName( );
|
||||
return ProjectUtils.getCacheForProject( resource.getProject( ) )
|
||||
.getInstallName( );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the install name for the specified resource
|
||||
* @param resource The resource to set the install to
|
||||
* @param newInstallName The new install name
|
||||
*
|
||||
* @param resource
|
||||
* The resource to set the install to
|
||||
* @param newInstallName
|
||||
* The new install name
|
||||
*/
|
||||
public static void setInstallNameForResource( IResource resource, String newInstallName )
|
||||
public static void setInstallNameForResource( IResource resource,
|
||||
String newInstallName )
|
||||
{
|
||||
if ( resource == null )
|
||||
if( resource == null )
|
||||
return;
|
||||
|
||||
ProjectUtils.getCacheForProject( resource.getProject( ) ).setInstallName( newInstallName );
|
||||
ProjectUtils.getCacheForProject( resource.getProject( ) )
|
||||
.setInstallName( newInstallName );
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills the specified combo box with all the current installs
|
||||
* and selects the default or the first ( if no default exists )
|
||||
* @param comboBox The combobox to fill
|
||||
*
|
||||
* @param comboBox
|
||||
* The combobox to fill
|
||||
*/
|
||||
public static void fillComboWithInstalls( Combo comboBox )
|
||||
{
|
||||
|
@ -125,17 +144,17 @@ public class WesnothInstallsUtils
|
|||
|
||||
// fill the installs
|
||||
String defaultInstallName = Preferences.getDefaultInstallName( );
|
||||
for ( WesnothInstall install : WesnothInstallsUtils.getInstalls( ) ) {
|
||||
for( WesnothInstall install: WesnothInstallsUtils.getInstalls( ) ) {
|
||||
comboBox.add( install.getName( ) );
|
||||
|
||||
// select the default
|
||||
if ( install.getName( ).equals( defaultInstallName ) )
|
||||
if( install.getName( ).equals( defaultInstallName ) )
|
||||
comboBox.select( comboBox.getItemCount( ) - 1 );
|
||||
}
|
||||
|
||||
// select the first if there is no other selected
|
||||
if ( comboBox.getSelectionIndex( ) == -1 &&
|
||||
comboBox.getItemCount( ) > 0 )
|
||||
if( comboBox.getSelectionIndex( ) == - 1
|
||||
&& comboBox.getItemCount( ) > 0 )
|
||||
comboBox.select( 0 );
|
||||
}
|
||||
|
||||
|
@ -143,30 +162,33 @@ public class WesnothInstallsUtils
|
|||
* Checks whether the Wesnoth Installation is properly setup
|
||||
* for the specified resource. If it is not, it will guide the user
|
||||
* through selecting a proper install (if any).
|
||||
*
|
||||
* @param resource True if the installation is valid, false
|
||||
* otherwise
|
||||
*
|
||||
* @param resource
|
||||
* True if the installation is valid, false
|
||||
* otherwise
|
||||
* @return Boolean flag whether the setup was successfull or failed.
|
||||
*/
|
||||
public static boolean setupInstallForResource( IResource resource )
|
||||
{
|
||||
String installName = getInstallNameForResource( resource );
|
||||
// check if Paths are set for the install.
|
||||
if ( ! WorkspaceUtils.checkPathsAreSet( installName, false ) ) {
|
||||
if( ! WorkspaceUtils.checkPathsAreSet( installName, false ) ) {
|
||||
|
||||
// no defaut - nothing to do.
|
||||
if ( Preferences.getDefaultInstallName( ).isEmpty( ) )
|
||||
if( Preferences.getDefaultInstallName( ).isEmpty( ) )
|
||||
return false;
|
||||
|
||||
if ( GUIUtils.showMessageBox( String.format(
|
||||
Messages.WesnothInstallsUtils_1, resource.getProject( ).getName( ) ),
|
||||
SWT.ICON_QUESTION | SWT.YES | SWT.NO) == SWT.NO )
|
||||
if( GUIUtils
|
||||
.showMessageBox( String.format(
|
||||
Messages.WesnothInstallsUtils_1, resource
|
||||
.getProject( ).getName( ) ),
|
||||
SWT.ICON_QUESTION | SWT.YES | SWT.NO ) == SWT.NO )
|
||||
return false; // no hope :(
|
||||
|
||||
// fallback to default
|
||||
installName = Preferences.getDefaultInstallName( );
|
||||
|
||||
if ( WorkspaceUtils.checkPathsAreSet( installName, true ) ) {
|
||||
if( WorkspaceUtils.checkPathsAreSet( installName, true ) ) {
|
||||
// replace current install with the default
|
||||
setInstallNameForResource( resource, installName );
|
||||
return true;
|
||||
|
|
|
@ -25,81 +25,89 @@ import org.eclipse.swt.widgets.Text;
|
|||
*/
|
||||
public class DoubleInputDialog extends Dialog
|
||||
{
|
||||
private Text txtValue1_;
|
||||
private Text txtValue2_;
|
||||
private Label lblValue1;
|
||||
private Label lblValue2;
|
||||
private Text txtValue1_;
|
||||
private Text txtValue2_;
|
||||
private Label lblValue1;
|
||||
private Label lblValue2;
|
||||
|
||||
private String resStr1 = "", resStr2 = ""; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
private String val1String = "", val2String = ""; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
private String resStr1 = "", resStr2 = ""; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
private String val1String = "", val2String = ""; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
public DoubleInputDialog(Shell parentShell, String value1String, String value2String) {
|
||||
super(parentShell);
|
||||
setShellStyle(SWT.DIALOG_TRIM);
|
||||
val1String = value1String + ":"; //$NON-NLS-1$
|
||||
val2String = value2String + ":"; //$NON-NLS-1$
|
||||
}
|
||||
public DoubleInputDialog( Shell parentShell, String value1String,
|
||||
String value2String )
|
||||
{
|
||||
super( parentShell );
|
||||
setShellStyle( SWT.DIALOG_TRIM );
|
||||
val1String = value1String + ":"; //$NON-NLS-1$
|
||||
val2String = value2String + ":"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Control createDialogArea(Composite parent)
|
||||
{
|
||||
Composite container = (Composite) super.createDialogArea(parent);
|
||||
GridLayout gridLayout = (GridLayout) container.getLayout();
|
||||
gridLayout.numColumns = 3;
|
||||
@Override
|
||||
protected Control createDialogArea( Composite parent )
|
||||
{
|
||||
Composite container = ( Composite ) super.createDialogArea( parent );
|
||||
GridLayout gridLayout = ( GridLayout ) container.getLayout( );
|
||||
gridLayout.numColumns = 3;
|
||||
|
||||
lblValue1 = new Label(container, SWT.NONE);
|
||||
lblValue1.setText(val1String);
|
||||
Label label = new Label(container, SWT.NONE);
|
||||
label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
|
||||
lblValue1 = new Label( container, SWT.NONE );
|
||||
lblValue1.setText( val1String );
|
||||
Label label = new Label( container, SWT.NONE );
|
||||
label.setLayoutData( new GridData( SWT.RIGHT, SWT.CENTER, false, false,
|
||||
1, 1 ) );
|
||||
|
||||
txtValue1_ = new Text(container, SWT.BORDER);
|
||||
txtValue1_.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
|
||||
txtValue1_ = new Text( container, SWT.BORDER );
|
||||
txtValue1_.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true,
|
||||
false, 1, 1 ) );
|
||||
|
||||
lblValue2 = new Label(container, SWT.NONE);
|
||||
lblValue2.setText(val2String);
|
||||
Label label_3 = new Label(container, SWT.NONE);
|
||||
label_3.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
|
||||
lblValue2 = new Label( container, SWT.NONE );
|
||||
lblValue2.setText( val2String );
|
||||
Label label_3 = new Label( container, SWT.NONE );
|
||||
label_3.setLayoutData( new GridData( SWT.RIGHT, SWT.CENTER, false,
|
||||
false, 1, 1 ) );
|
||||
|
||||
txtValue2_ = new Text(container, SWT.BORDER);
|
||||
txtValue2_.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
|
||||
txtValue2_ = new Text( container, SWT.BORDER );
|
||||
txtValue2_.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true,
|
||||
false, 1, 1 ) );
|
||||
|
||||
return container;
|
||||
}
|
||||
return container;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createButtonsForButtonBar(Composite parent)
|
||||
{
|
||||
createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
|
||||
createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
|
||||
}
|
||||
@Override
|
||||
protected void createButtonsForButtonBar( Composite parent )
|
||||
{
|
||||
createButton( parent, IDialogConstants.OK_ID,
|
||||
IDialogConstants.OK_LABEL, true );
|
||||
createButton( parent, IDialogConstants.CANCEL_ID,
|
||||
IDialogConstants.CANCEL_LABEL, false );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean close()
|
||||
{
|
||||
resStr1 = txtValue1_.getText();
|
||||
resStr2 = txtValue2_.getText();
|
||||
return super.close();
|
||||
}
|
||||
@Override
|
||||
public boolean close( )
|
||||
{
|
||||
resStr1 = txtValue1_.getText( );
|
||||
resStr2 = txtValue2_.getText( );
|
||||
return super.close( );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Point getInitialSize()
|
||||
{
|
||||
return new Point(385, 155);
|
||||
}
|
||||
@Override
|
||||
protected Point getInitialSize( )
|
||||
{
|
||||
return new Point( 385, 155 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value in the first textbox
|
||||
*/
|
||||
public String getFirstValue()
|
||||
{
|
||||
return resStr1;
|
||||
}
|
||||
/**
|
||||
* Gets the value in the first textbox
|
||||
*/
|
||||
public String getFirstValue( )
|
||||
{
|
||||
return resStr1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value in the second textbox
|
||||
*/
|
||||
public String getSecondValue()
|
||||
{
|
||||
return resStr2;
|
||||
}
|
||||
/**
|
||||
* Gets the value in the second textbox
|
||||
*/
|
||||
public String getSecondValue( )
|
||||
{
|
||||
return resStr2;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,31 +13,34 @@ import org.eclipse.swt.widgets.Composite;
|
|||
|
||||
public class RegexStringFieldEditor extends StringFieldEditor
|
||||
{
|
||||
protected String regex_;
|
||||
protected String errorMessage_;
|
||||
protected String regex_;
|
||||
protected String errorMessage_;
|
||||
|
||||
/**
|
||||
* An regex matcher string field editor.
|
||||
* @param regex The regex to match this textbox's string
|
||||
* @param errorMessage The message to show as error when field's text
|
||||
* doesn't match the regex
|
||||
*/
|
||||
public RegexStringFieldEditor(String name, String labelText,
|
||||
String regex, String errorMessage, Composite parent)
|
||||
{
|
||||
super(name,labelText,parent);
|
||||
regex_ = regex;
|
||||
errorMessage_ = errorMessage;
|
||||
}
|
||||
/**
|
||||
* An regex matcher string field editor.
|
||||
*
|
||||
* @param regex
|
||||
* The regex to match this textbox's string
|
||||
* @param errorMessage
|
||||
* The message to show as error when field's text
|
||||
* doesn't match the regex
|
||||
*/
|
||||
public RegexStringFieldEditor( String name, String labelText, String regex,
|
||||
String errorMessage, Composite parent )
|
||||
{
|
||||
super( name, labelText, parent );
|
||||
regex_ = regex;
|
||||
errorMessage_ = errorMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean checkState()
|
||||
{
|
||||
if (regex_ == null)
|
||||
return true;
|
||||
boolean matches = getTextControl().getText().matches(regex_);
|
||||
setErrorMessage(matches == false ? errorMessage_ : null);
|
||||
showErrorMessage();
|
||||
return matches;
|
||||
}
|
||||
@Override
|
||||
protected boolean checkState( )
|
||||
{
|
||||
if( regex_ == null )
|
||||
return true;
|
||||
boolean matches = getTextControl( ).getText( ).matches( regex_ );
|
||||
setErrorMessage( matches == false ? errorMessage_: null );
|
||||
showErrorMessage( );
|
||||
return matches;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,31 +13,34 @@ import org.eclipse.jface.preference.FieldEditorPreferencePage;
|
|||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||
|
||||
public abstract class AbstractPreferencePage extends FieldEditorPreferencePage implements
|
||||
IWorkbenchPreferencePage
|
||||
public abstract class AbstractPreferencePage extends FieldEditorPreferencePage
|
||||
implements IWorkbenchPreferencePage
|
||||
{
|
||||
public AbstractPreferencePage(int style)
|
||||
{
|
||||
super(style);
|
||||
}
|
||||
public AbstractPreferencePage()
|
||||
{
|
||||
super();
|
||||
}
|
||||
public AbstractPreferencePage( int style )
|
||||
{
|
||||
super( style );
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the specified field editor with the specified tooltip
|
||||
* @param editor
|
||||
* @param tooltip
|
||||
*/
|
||||
protected void addField(FieldEditor editor, String tooltip)
|
||||
{
|
||||
editor.getLabelControl(getFieldEditorParent()).setToolTipText(tooltip);
|
||||
super.addField(editor);
|
||||
}
|
||||
public AbstractPreferencePage( )
|
||||
{
|
||||
super( );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(IWorkbench workbench)
|
||||
{
|
||||
}
|
||||
/**
|
||||
* Adds the specified field editor with the specified tooltip
|
||||
*
|
||||
* @param editor
|
||||
* @param tooltip
|
||||
*/
|
||||
protected void addField( FieldEditor editor, String tooltip )
|
||||
{
|
||||
editor.getLabelControl( getFieldEditorParent( ) ).setToolTipText(
|
||||
tooltip );
|
||||
super.addField( editor );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( IWorkbench workbench )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import java.util.Map.Entry;
|
|||
import org.eclipse.jface.preference.BooleanFieldEditor;
|
||||
import org.eclipse.jface.preference.StringFieldEditor;
|
||||
import org.eclipse.xtext.ui.editor.preferences.fields.LabelFieldEditor;
|
||||
|
||||
import org.wesnoth.Constants;
|
||||
import org.wesnoth.Messages;
|
||||
import org.wesnoth.WesnothPlugin;
|
||||
|
@ -22,7 +23,7 @@ import org.wesnoth.jface.RegexStringFieldEditor;
|
|||
|
||||
public class AddonUploadPreferencePage extends AbstractPreferencePage
|
||||
{
|
||||
public final static String ID_ADDON_PREFERENCE_PAGE = "org.wesnoth.preferences.AddonPage"; //$NON-NLS-1$
|
||||
public final static String ID_ADDON_PREFERENCE_PAGE = "org.wesnoth.preferences.AddonPage"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Holds the ports for each addon server as a (key, value) pair,
|
||||
|
@ -30,56 +31,64 @@ public class AddonUploadPreferencePage extends AbstractPreferencePage
|
|||
* - key = port
|
||||
* - value = wesnoth server version
|
||||
*/
|
||||
public final static Map<String, String> ADDON_SERVER_PORTS = new HashMap<String, String>( );
|
||||
public final static Map< String, String > ADDON_SERVER_PORTS = new HashMap< String, String >( );
|
||||
|
||||
static {
|
||||
ADDON_SERVER_PORTS.put("15002", "1.9.x"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
ADDON_SERVER_PORTS.put("15001", "1.8.x"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
ADDON_SERVER_PORTS.put("15003", "1.6.x"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
ADDON_SERVER_PORTS.put("15005", "1.4.x"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
ADDON_SERVER_PORTS.put("15004", "trunk"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
static {
|
||||
ADDON_SERVER_PORTS.put( "15002", "1.9.x" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
ADDON_SERVER_PORTS.put( "15001", "1.8.x" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
ADDON_SERVER_PORTS.put( "15003", "1.6.x" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
ADDON_SERVER_PORTS.put( "15005", "1.4.x" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
ADDON_SERVER_PORTS.put( "15004", "trunk" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
public AddonUploadPreferencePage()
|
||||
{
|
||||
super(GRID);
|
||||
public AddonUploadPreferencePage( )
|
||||
{
|
||||
super( GRID );
|
||||
|
||||
setPreferenceStore(WesnothPlugin.getDefault().getPreferenceStore());
|
||||
setDescription(Messages.AddonUploadPreferencePage_10);
|
||||
}
|
||||
setPreferenceStore( WesnothPlugin.getDefault( ).getPreferenceStore( ) );
|
||||
setDescription( Messages.AddonUploadPreferencePage_10 );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createFieldEditors()
|
||||
{
|
||||
addField(new StringFieldEditor(Constants.P_WAU_PASSWORD,
|
||||
Messages.AddonUploadPreferencePage_11, getFieldEditorParent()),
|
||||
Messages.AddonUploadPreferencePage_12);
|
||||
addField(new BooleanFieldEditor(Constants.P_WAU_VERBOSE,
|
||||
Messages.AddonUploadPreferencePage_13, 1, getFieldEditorParent()));
|
||||
@Override
|
||||
protected void createFieldEditors( )
|
||||
{
|
||||
addField(
|
||||
new StringFieldEditor( Constants.P_WAU_PASSWORD,
|
||||
Messages.AddonUploadPreferencePage_11,
|
||||
getFieldEditorParent( ) ),
|
||||
Messages.AddonUploadPreferencePage_12 );
|
||||
addField( new BooleanFieldEditor( Constants.P_WAU_VERBOSE,
|
||||
Messages.AddonUploadPreferencePage_13, 1,
|
||||
getFieldEditorParent( ) ) );
|
||||
|
||||
addField(new RegexStringFieldEditor(Constants.P_WAU_ADDRESS,
|
||||
Messages.AddonUploadPreferencePage_14, Messages.AddonUploadPreferencePage_15,
|
||||
Messages.AddonUploadPreferencePage_16,
|
||||
getFieldEditorParent()),
|
||||
Messages.AddonUploadPreferencePage_17);
|
||||
addField(
|
||||
new RegexStringFieldEditor( Constants.P_WAU_ADDRESS,
|
||||
Messages.AddonUploadPreferencePage_14,
|
||||
Messages.AddonUploadPreferencePage_15,
|
||||
Messages.AddonUploadPreferencePage_16,
|
||||
getFieldEditorParent( ) ),
|
||||
Messages.AddonUploadPreferencePage_17 );
|
||||
|
||||
StringBuilder ports = new StringBuilder();
|
||||
StringBuilder portsRegex = new StringBuilder();
|
||||
portsRegex.append("("); //$NON-NLS-1$
|
||||
for (Entry<String, String> item : ADDON_SERVER_PORTS.entrySet())
|
||||
{
|
||||
portsRegex.append(item.getKey() + "|"); //$NON-NLS-1$
|
||||
ports.append(String.format("\t%s - %s\n", item.getKey(), item.getValue())); //$NON-NLS-1$
|
||||
}
|
||||
portsRegex.deleteCharAt(portsRegex.length() - 1);
|
||||
portsRegex.append(")*"); //$NON-NLS-1$
|
||||
StringBuilder ports = new StringBuilder( );
|
||||
StringBuilder portsRegex = new StringBuilder( );
|
||||
portsRegex.append( "(" ); //$NON-NLS-1$
|
||||
for( Entry< String, String > item: ADDON_SERVER_PORTS.entrySet( ) ) {
|
||||
portsRegex.append( item.getKey( ) + "|" ); //$NON-NLS-1$
|
||||
ports.append( String.format(
|
||||
"\t%s - %s\n", item.getKey( ), item.getValue( ) ) ); //$NON-NLS-1$
|
||||
}
|
||||
portsRegex.deleteCharAt( portsRegex.length( ) - 1 );
|
||||
portsRegex.append( ")*" ); //$NON-NLS-1$
|
||||
|
||||
//System.out.println(portsRegex.toString());
|
||||
addField(new RegexStringFieldEditor(Constants.P_WAU_PORT,
|
||||
Messages.AddonUploadPreferencePage_22, portsRegex.toString(),
|
||||
Messages.AddonUploadPreferencePage_23, getFieldEditorParent()),
|
||||
Messages.AddonUploadPreferencePage_24);
|
||||
addField(new LabelFieldEditor(Messages.AddonUploadPreferencePage_25 +
|
||||
ports.toString(), getFieldEditorParent()));
|
||||
}
|
||||
// System.out.println(portsRegex.toString());
|
||||
addField(
|
||||
new RegexStringFieldEditor( Constants.P_WAU_PORT,
|
||||
Messages.AddonUploadPreferencePage_22,
|
||||
portsRegex.toString( ),
|
||||
Messages.AddonUploadPreferencePage_23,
|
||||
getFieldEditorParent( ) ),
|
||||
Messages.AddonUploadPreferencePage_24 );
|
||||
addField( new LabelFieldEditor( Messages.AddonUploadPreferencePage_25
|
||||
+ ports.toString( ), getFieldEditorParent( ) ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,36 +8,34 @@
|
|||
*******************************************************************************/
|
||||
package org.wesnoth.preferences;
|
||||
|
||||
import org.eclipse.jface.preference.BooleanFieldEditor;
|
||||
|
||||
import org.wesnoth.Constants;
|
||||
import org.wesnoth.Messages;
|
||||
import org.wesnoth.WesnothPlugin;
|
||||
|
||||
import org.eclipse.jface.preference.BooleanFieldEditor;
|
||||
|
||||
public class AdvancedPreferencePage extends AbstractPreferencePage
|
||||
{
|
||||
public AdvancedPreferencePage()
|
||||
{
|
||||
super(GRID);
|
||||
public AdvancedPreferencePage( )
|
||||
{
|
||||
super( GRID );
|
||||
|
||||
setPreferenceStore(WesnothPlugin.getDefault().getPreferenceStore());
|
||||
setDescription(Messages.AdvancedPreferencePage_0);
|
||||
}
|
||||
setPreferenceStore( WesnothPlugin.getDefault( ).getPreferenceStore( ) );
|
||||
setDescription( Messages.AdvancedPreferencePage_0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createFieldEditors()
|
||||
{
|
||||
addField( new BooleanFieldEditor(
|
||||
Constants.P_NO_TERRAIN_GFX, Messages.AdvancedPreferencePage_1,
|
||||
BooleanFieldEditor.SEPARATE_LABEL,
|
||||
getFieldEditorParent( ) ),
|
||||
Messages.AdvancedPreferencePage_2 );
|
||||
@Override
|
||||
protected void createFieldEditors( )
|
||||
{
|
||||
addField( new BooleanFieldEditor( Constants.P_NO_TERRAIN_GFX,
|
||||
Messages.AdvancedPreferencePage_1,
|
||||
BooleanFieldEditor.SEPARATE_LABEL, getFieldEditorParent( ) ),
|
||||
Messages.AdvancedPreferencePage_2 );
|
||||
|
||||
addField( new BooleanFieldEditor(
|
||||
Constants.P_WML_VALIDATION, "WML Validation, parent",
|
||||
BooleanFieldEditor.SEPARATE_LABEL,
|
||||
getFieldEditorParent( ) ),
|
||||
"If checked, the WML Editor will validate some of the " +
|
||||
"written WML to check for semantic errors." );
|
||||
}
|
||||
addField( new BooleanFieldEditor( Constants.P_WML_VALIDATION,
|
||||
"WML Validation, parent", BooleanFieldEditor.SEPARATE_LABEL,
|
||||
getFieldEditorParent( ) ),
|
||||
"If checked, the WML Editor will validate some of the "
|
||||
+ "written WML to check for semantic errors." );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,14 +11,14 @@ package org.wesnoth.preferences;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.wesnoth.Constants;
|
||||
import org.wesnoth.WesnothPlugin;
|
||||
import org.wesnoth.utils.StringUtils;
|
||||
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
|
||||
import org.wesnoth.Constants;
|
||||
import org.wesnoth.WesnothPlugin;
|
||||
import org.wesnoth.utils.StringUtils;
|
||||
|
||||
/**
|
||||
* Class used to initialize default preference values.
|
||||
*/
|
||||
|
@ -27,211 +27,226 @@ public class Preferences extends AbstractPreferenceInitializer
|
|||
/**
|
||||
* A map for storing the paths for the current session
|
||||
*/
|
||||
protected final static Map< String, Paths > paths_ =
|
||||
new HashMap< String, Paths > ();
|
||||
protected final static Map< String, Paths > paths_ = new HashMap< String, Paths >( );
|
||||
|
||||
public static void initializeToDefault()
|
||||
public static void initializeToDefault( )
|
||||
{
|
||||
IPreferenceStore store = WesnothPlugin.getDefault().getPreferenceStore();
|
||||
IPreferenceStore store = WesnothPlugin.getDefault( )
|
||||
.getPreferenceStore( );
|
||||
// general settings
|
||||
store.setDefault(Constants.P_WESNOTH_EXEC_PATH, ""); //$NON-NLS-1$
|
||||
store.setDefault(Constants.P_WESNOTH_WORKING_DIR, ""); //$NON-NLS-1$
|
||||
store.setDefault(Constants.P_WESNOTH_USER_DIR, ""); //$NON-NLS-1$
|
||||
store.setDefault(Constants.P_WESNOTH_WMLTOOLS_DIR, ""); //$NON-NLS-1$
|
||||
store.setDefault(Constants.P_PYTHON_PATH, ""); //$NON-NLS-1$
|
||||
store.setDefault( Constants.P_WESNOTH_EXEC_PATH, "" ); //$NON-NLS-1$
|
||||
store.setDefault( Constants.P_WESNOTH_WORKING_DIR, "" ); //$NON-NLS-1$
|
||||
store.setDefault( Constants.P_WESNOTH_USER_DIR, "" ); //$NON-NLS-1$
|
||||
store.setDefault( Constants.P_WESNOTH_WMLTOOLS_DIR, "" ); //$NON-NLS-1$
|
||||
store.setDefault( Constants.P_PYTHON_PATH, "" ); //$NON-NLS-1$
|
||||
|
||||
// wml tools
|
||||
store.setDefault(Constants.P_WMLINDENT_VERBOSE, true);
|
||||
store.setDefault(Constants.P_WMLINDENT_DRYRUN, true);
|
||||
store.setDefault( Constants.P_WMLINDENT_VERBOSE, true );
|
||||
store.setDefault( Constants.P_WMLINDENT_DRYRUN, true );
|
||||
|
||||
store.setDefault(Constants.P_WMLLINT_DRYRUN, true);
|
||||
store.setDefault(Constants.P_WMLLINT_SPELL_CHECK, false);
|
||||
store.setDefault(Constants.P_WMLLINT_VERBOSE_LEVEL, 0);
|
||||
store.setDefault( Constants.P_WMLLINT_DRYRUN, true );
|
||||
store.setDefault( Constants.P_WMLLINT_SPELL_CHECK, false );
|
||||
store.setDefault( Constants.P_WMLLINT_VERBOSE_LEVEL, 0 );
|
||||
|
||||
store.setDefault(Constants.P_WMLSCOPE_VERBOSE_LEVEL, 0);
|
||||
store.setDefault(Constants.P_WMLSCOPE_COLLISIONS, false);
|
||||
store.setDefault( Constants.P_WMLSCOPE_VERBOSE_LEVEL, 0 );
|
||||
store.setDefault( Constants.P_WMLSCOPE_COLLISIONS, false );
|
||||
|
||||
// upload manager
|
||||
store.setDefault(Constants.P_WAU_PASSWORD, ""); //$NON-NLS-1$
|
||||
store.setDefault(Constants.P_WAU_VERBOSE, false);
|
||||
store.setDefault(Constants.P_WAU_ADDRESS, "add-ons.wesnoth.org"); //$NON-NLS-1$
|
||||
store.setDefault(Constants.P_WAU_PORT, 15002);
|
||||
store.setDefault( Constants.P_WAU_PASSWORD, "" ); //$NON-NLS-1$
|
||||
store.setDefault( Constants.P_WAU_VERBOSE, false );
|
||||
store.setDefault( Constants.P_WAU_ADDRESS, "add-ons.wesnoth.org" ); //$NON-NLS-1$
|
||||
store.setDefault( Constants.P_WAU_PORT, 15002 );
|
||||
|
||||
// advanced
|
||||
store.setDefault(Constants.P_NO_TERRAIN_GFX, true);
|
||||
store.setDefault( Constants.P_NO_TERRAIN_GFX, true );
|
||||
store.setDefault( Constants.P_WML_VALIDATION, false );
|
||||
|
||||
// installs
|
||||
store.setDefault(Constants.P_INST_DEFAULT_INSTALL, ""); //$NON-NLS-1$
|
||||
store.setDefault(Constants.P_INST_INSTALL_LIST, ""); //$NON-NLS-1$
|
||||
store.setDefault( Constants.P_INST_DEFAULT_INSTALL, "" ); //$NON-NLS-1$
|
||||
store.setDefault( Constants.P_INST_INSTALL_LIST, "" ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeDefaultPreferences()
|
||||
{
|
||||
initializeToDefault( );
|
||||
}
|
||||
@Override
|
||||
public void initializeDefaultPreferences( )
|
||||
{
|
||||
initializeToDefault( );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The preferences store of the plugin
|
||||
*/
|
||||
public static IPreferenceStore getPreferences()
|
||||
{
|
||||
return WesnothPlugin.getDefault().getPreferenceStore();
|
||||
}
|
||||
/**
|
||||
* @return The preferences store of the plugin
|
||||
*/
|
||||
public static IPreferenceStore getPreferences( )
|
||||
{
|
||||
return WesnothPlugin.getDefault( ).getPreferenceStore( );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the contents of the specified preference as a string
|
||||
* or empty string ("") if there is no such preference set
|
||||
*/
|
||||
public static String getString(String prefName)
|
||||
{
|
||||
return getPreferences().getString(prefName);
|
||||
}
|
||||
/**
|
||||
* Returns the contents of the specified preference as a string
|
||||
* or empty string ("") if there is no such preference set
|
||||
*/
|
||||
public static String getString( String prefName )
|
||||
{
|
||||
return getPreferences( ).getString( prefName );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the contents of the specified preference as an int
|
||||
* or zero (0) if there is no such preference set
|
||||
*/
|
||||
public static int getInt(String prefName)
|
||||
{
|
||||
return getPreferences().getInt(prefName);
|
||||
}
|
||||
/**
|
||||
* Returns the contents of the specified preference as a boolean
|
||||
* or false if there is no such preference set
|
||||
*/
|
||||
public static boolean getBool(String prefName)
|
||||
{
|
||||
return getPreferences().getBoolean(prefName);
|
||||
}
|
||||
/**
|
||||
* Returns the contents of the specified preference as an int
|
||||
* or zero (0) if there is no such preference set
|
||||
*/
|
||||
public static int getInt( String prefName )
|
||||
{
|
||||
return getPreferences( ).getInt( prefName );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the install preference prefix for the specified install name.
|
||||
*
|
||||
* @param installName The name of the install. If the parameter is null,
|
||||
* the default install prefix is returned
|
||||
*/
|
||||
public static String getInstallPrefix(String installName)
|
||||
{
|
||||
if ( StringUtils.isNullOrEmpty( installName ) )
|
||||
/**
|
||||
* Returns the contents of the specified preference as a boolean
|
||||
* or false if there is no such preference set
|
||||
*/
|
||||
public static boolean getBool( String prefName )
|
||||
{
|
||||
return getPreferences( ).getBoolean( prefName );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the install preference prefix for the specified install name.
|
||||
*
|
||||
* @param installName
|
||||
* The name of the install. If the parameter is null,
|
||||
* the default install prefix is returned
|
||||
*/
|
||||
public static String getInstallPrefix( String installName )
|
||||
{
|
||||
if( StringUtils.isNullOrEmpty( installName ) )
|
||||
installName = getDefaultInstallName( );
|
||||
|
||||
return "inst_" + installName + "_"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the default install
|
||||
* @return Returns the name of the default install
|
||||
*/
|
||||
public static String getDefaultInstallName()
|
||||
{
|
||||
return getString( Constants.P_INST_DEFAULT_INSTALL );
|
||||
}
|
||||
/**
|
||||
* Returns the name of the default install
|
||||
*
|
||||
* @return Returns the name of the default install
|
||||
*/
|
||||
public static String getDefaultInstallName( )
|
||||
{
|
||||
return getString( Constants.P_INST_DEFAULT_INSTALL );
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Sets the default install name
|
||||
* @param newInstallName The new install name
|
||||
*
|
||||
* @param newInstallName
|
||||
* The new install name
|
||||
*/
|
||||
public static void setDefaultInstallName( String newInstallName )
|
||||
{
|
||||
getPreferences( ).setValue( Constants.P_INST_DEFAULT_INSTALL, newInstallName );
|
||||
getPreferences( ).setValue( Constants.P_INST_DEFAULT_INSTALL,
|
||||
newInstallName );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new Paths object based on the specified install name
|
||||
* @param installName The install name used for the paths
|
||||
* @return A new Paths object
|
||||
*/
|
||||
public static Paths getPaths( String installName )
|
||||
{
|
||||
// no null allowed -> fallback to ""
|
||||
if ( installName == null )
|
||||
installName = ""; //$NON-NLS-1$
|
||||
/**
|
||||
* Returns a new Paths object based on the specified install name
|
||||
*
|
||||
* @param installName
|
||||
* The install name used for the paths
|
||||
* @return A new Paths object
|
||||
*/
|
||||
public static Paths getPaths( String installName )
|
||||
{
|
||||
// no null allowed -> fallback to ""
|
||||
if( installName == null )
|
||||
installName = ""; //$NON-NLS-1$
|
||||
|
||||
Paths paths = paths_.get( installName );
|
||||
if ( paths == null ) {
|
||||
paths = new Paths( installName, getInstallPrefix( installName ) );
|
||||
paths_.put( installName, paths );
|
||||
}
|
||||
Paths paths = paths_.get( installName );
|
||||
if( paths == null ) {
|
||||
paths = new Paths( installName, getInstallPrefix( installName ) );
|
||||
paths_.put( installName, paths );
|
||||
}
|
||||
|
||||
return paths;
|
||||
}
|
||||
return paths;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper for accessing the paths used in the plugin based
|
||||
* on the install
|
||||
*/
|
||||
public static class Paths
|
||||
{
|
||||
private String installPrefix_;
|
||||
private String installName_;
|
||||
/**
|
||||
* Helper for accessing the paths used in the plugin based
|
||||
* on the install
|
||||
*/
|
||||
public static class Paths
|
||||
{
|
||||
private String installPrefix_;
|
||||
private String installName_;
|
||||
|
||||
public Paths( String installName, String installPrefix )
|
||||
{
|
||||
installPrefix_ = installPrefix;
|
||||
installName_ = installName;
|
||||
}
|
||||
public Paths( String installName, String installPrefix )
|
||||
{
|
||||
installPrefix_ = installPrefix;
|
||||
installName_ = installName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the install name associated with this instance
|
||||
* @return A string representing the install name
|
||||
*/
|
||||
public String getInstallName()
|
||||
{
|
||||
return installName_;
|
||||
}
|
||||
/**
|
||||
* Returns the install name associated with this instance
|
||||
*
|
||||
* @return A string representing the install name
|
||||
*/
|
||||
public String getInstallName( )
|
||||
{
|
||||
return installName_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the addons directory
|
||||
* @return Returns the addons directory
|
||||
*/
|
||||
public String getAddonsDir()
|
||||
{
|
||||
return getUserDataDir( ) + "add-ons/"; //$NON-NLS-1$
|
||||
}
|
||||
/**
|
||||
* Returns the addons directory
|
||||
*
|
||||
* @return Returns the addons directory
|
||||
*/
|
||||
public String getAddonsDir( )
|
||||
{
|
||||
return getUserDataDir( ) + "add-ons/"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data user directory
|
||||
*
|
||||
* @return Returns the data user directory
|
||||
*/
|
||||
public String getUserDataDir()
|
||||
public String getUserDataDir( )
|
||||
{
|
||||
return getUserDir( ) + "data/" ;
|
||||
return getUserDir( ) + "data/";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the campaign directory
|
||||
*
|
||||
* @return Returns the campaign directory
|
||||
*/
|
||||
public String getCampaignDir()
|
||||
public String getCampaignDir( )
|
||||
{
|
||||
return getWorkingDir( ) + "data/campaigns/"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the 'data/core' directory
|
||||
*
|
||||
* @return Returns the 'data/core' directory
|
||||
*/
|
||||
public String getCoreDir()
|
||||
public String getCoreDir( )
|
||||
{
|
||||
return getWorkingDir( ) + "data/core/"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <b>schema.cfg</b> file path
|
||||
*
|
||||
* @return Returns the schema.cfg file path
|
||||
*/
|
||||
public String getSchemaPath()
|
||||
public String getSchemaPath( )
|
||||
{
|
||||
return getWorkingDir( ) + "data/schema.cfg"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the user's directory
|
||||
*
|
||||
* @return Returns the user's directory
|
||||
*/
|
||||
public String getUserDir()
|
||||
public String getUserDir( )
|
||||
{
|
||||
return getString( installPrefix_ + Constants.P_WESNOTH_USER_DIR )
|
||||
.replace( '\\', '/' ) + Path.SEPARATOR;
|
||||
|
@ -240,9 +255,10 @@ public class Preferences extends AbstractPreferenceInitializer
|
|||
/**
|
||||
* Returns the working directory that contains the
|
||||
* <b>data</b> folder
|
||||
*
|
||||
* @return Returns the working directory
|
||||
*/
|
||||
public String getWorkingDir()
|
||||
public String getWorkingDir( )
|
||||
{
|
||||
return getString( installPrefix_ + Constants.P_WESNOTH_WORKING_DIR )
|
||||
.replace( '\\', '/' ) + Path.SEPARATOR;
|
||||
|
@ -251,9 +267,10 @@ public class Preferences extends AbstractPreferenceInitializer
|
|||
/**
|
||||
* Returns the directory that contains the wml tools
|
||||
* ( wmlscope, wmllint, wmlindent, wesnoth_addons_manager, etc)
|
||||
*
|
||||
* @return Returns the directory that contains the wml tools
|
||||
*/
|
||||
public String getWMLToolsDir()
|
||||
public String getWMLToolsDir( )
|
||||
{
|
||||
return getString( installPrefix_ + Constants.P_WESNOTH_WMLTOOLS_DIR )
|
||||
.replace( '\\', '/' ) + Path.SEPARATOR;
|
||||
|
@ -261,12 +278,13 @@ public class Preferences extends AbstractPreferenceInitializer
|
|||
|
||||
/**
|
||||
* Returns the path to the wesnoth executable
|
||||
*
|
||||
* @return Returns the path to the wesnoth executable
|
||||
*/
|
||||
public String getWesnothExecutablePath()
|
||||
public String getWesnothExecutablePath( )
|
||||
{
|
||||
return getString( installPrefix_ + Constants.P_WESNOTH_EXEC_PATH )
|
||||
.replace( '\\', '/' );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,44 +11,50 @@ package org.wesnoth.preferences;
|
|||
import org.eclipse.jface.preference.BooleanFieldEditor;
|
||||
import org.eclipse.jface.preference.ScaleFieldEditor;
|
||||
import org.eclipse.xtext.ui.editor.preferences.fields.LabelFieldEditor;
|
||||
import org.wesnoth.WesnothPlugin;
|
||||
|
||||
import org.wesnoth.Constants;
|
||||
import org.wesnoth.Messages;
|
||||
import org.wesnoth.WesnothPlugin;
|
||||
|
||||
public class WMLToolsPreferencePage extends AbstractPreferencePage
|
||||
{
|
||||
public WMLToolsPreferencePage()
|
||||
{
|
||||
super(GRID);
|
||||
public WMLToolsPreferencePage( )
|
||||
{
|
||||
super( GRID );
|
||||
|
||||
setPreferenceStore(WesnothPlugin.getDefault().getPreferenceStore());
|
||||
setDescription(Messages.WMLToolsPreferencePage_0);
|
||||
}
|
||||
setPreferenceStore( WesnothPlugin.getDefault( ).getPreferenceStore( ) );
|
||||
setDescription( Messages.WMLToolsPreferencePage_0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createFieldEditors()
|
||||
{
|
||||
addField(new LabelFieldEditor(Messages.WMLToolsPreferencePage_1, getFieldEditorParent()));
|
||||
addField(new BooleanFieldEditor(Constants.P_WMLINDENT_DRYRUN, Messages.WMLToolsPreferencePage_2, 1,
|
||||
getFieldEditorParent()));
|
||||
addField(new BooleanFieldEditor(Constants.P_WMLINDENT_VERBOSE, Messages.WMLToolsPreferencePage_3, 1,
|
||||
getFieldEditorParent()));
|
||||
addField(new LabelFieldEditor("", getFieldEditorParent())); //$NON-NLS-1$
|
||||
@Override
|
||||
protected void createFieldEditors( )
|
||||
{
|
||||
addField( new LabelFieldEditor( Messages.WMLToolsPreferencePage_1,
|
||||
getFieldEditorParent( ) ) );
|
||||
addField( new BooleanFieldEditor( Constants.P_WMLINDENT_DRYRUN,
|
||||
Messages.WMLToolsPreferencePage_2, 1, getFieldEditorParent( ) ) );
|
||||
addField( new BooleanFieldEditor( Constants.P_WMLINDENT_VERBOSE,
|
||||
Messages.WMLToolsPreferencePage_3, 1, getFieldEditorParent( ) ) );
|
||||
addField( new LabelFieldEditor( "", getFieldEditorParent( ) ) ); //$NON-NLS-1$
|
||||
|
||||
addField(new LabelFieldEditor(Messages.WMLToolsPreferencePage_5, getFieldEditorParent()));
|
||||
addField(new ScaleFieldEditor(Constants.P_WMLSCOPE_VERBOSE_LEVEL, Messages.WMLToolsPreferencePage_6,
|
||||
getFieldEditorParent(), 0, 2, 1, 1));
|
||||
addField(new BooleanFieldEditor(Constants.P_WMLSCOPE_COLLISIONS, Messages.WMLToolsPreferencePage_7, 1,
|
||||
getFieldEditorParent()));
|
||||
addField(new LabelFieldEditor("", getFieldEditorParent())); //$NON-NLS-1$
|
||||
addField( new LabelFieldEditor( Messages.WMLToolsPreferencePage_5,
|
||||
getFieldEditorParent( ) ) );
|
||||
addField( new ScaleFieldEditor( Constants.P_WMLSCOPE_VERBOSE_LEVEL,
|
||||
Messages.WMLToolsPreferencePage_6, getFieldEditorParent( ), 0,
|
||||
2, 1, 1 ) );
|
||||
addField( new BooleanFieldEditor( Constants.P_WMLSCOPE_COLLISIONS,
|
||||
Messages.WMLToolsPreferencePage_7, 1, getFieldEditorParent( ) ) );
|
||||
addField( new LabelFieldEditor( "", getFieldEditorParent( ) ) ); //$NON-NLS-1$
|
||||
|
||||
addField(new LabelFieldEditor(Messages.WMLToolsPreferencePage_9, getFieldEditorParent()));
|
||||
addField(new BooleanFieldEditor(Constants.P_WMLLINT_DRYRUN, Messages.WMLToolsPreferencePage_10, 1,
|
||||
getFieldEditorParent()));
|
||||
addField(new BooleanFieldEditor(Constants.P_WMLLINT_SPELL_CHECK, Messages.WMLToolsPreferencePage_11, 1,
|
||||
getFieldEditorParent()));
|
||||
addField(new ScaleFieldEditor(Constants.P_WMLLINT_VERBOSE_LEVEL, Messages.WMLToolsPreferencePage_12,
|
||||
getFieldEditorParent(), 0, 3, 1, 1));
|
||||
addField(new LabelFieldEditor("", getFieldEditorParent())); //$NON-NLS-1$
|
||||
}
|
||||
addField( new LabelFieldEditor( Messages.WMLToolsPreferencePage_9,
|
||||
getFieldEditorParent( ) ) );
|
||||
addField( new BooleanFieldEditor( Constants.P_WMLLINT_DRYRUN,
|
||||
Messages.WMLToolsPreferencePage_10, 1, getFieldEditorParent( ) ) );
|
||||
addField( new BooleanFieldEditor( Constants.P_WMLLINT_SPELL_CHECK,
|
||||
Messages.WMLToolsPreferencePage_11, 1, getFieldEditorParent( ) ) );
|
||||
addField( new ScaleFieldEditor( Constants.P_WMLLINT_VERBOSE_LEVEL,
|
||||
Messages.WMLToolsPreferencePage_12, getFieldEditorParent( ), 0,
|
||||
3, 1, 1 ) );
|
||||
addField( new LabelFieldEditor( "", getFieldEditorParent( ) ) ); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ import org.eclipse.swt.widgets.Table;
|
|||
import org.eclipse.swt.widgets.TableColumn;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.xtext.ui.editor.preferences.fields.LabelFieldEditor;
|
||||
|
||||
import org.wesnoth.Constants;
|
||||
import org.wesnoth.Messages;
|
||||
import org.wesnoth.WesnothPlugin;
|
||||
|
@ -62,268 +63,282 @@ import org.wesnoth.utils.StringUtils;
|
|||
|
||||
public class WesnothInstallsPage extends AbstractPreferencePage
|
||||
{
|
||||
private Text txtInstallName_;
|
||||
private Combo cmbVersion_;
|
||||
private Text txtInstallName_;
|
||||
private Combo cmbVersion_;
|
||||
|
||||
private Map<String, WesnothInstall> installs_;
|
||||
private Table installsTable_;
|
||||
private TableViewer installsTableViewer_;
|
||||
private Map< String, WesnothInstall > installs_;
|
||||
private Table installsTable_;
|
||||
private TableViewer installsTableViewer_;
|
||||
|
||||
|
||||
private DirectoryFieldEditor wmlToolsField_;
|
||||
private DirectoryFieldEditor wesnothWorkingDirField_;
|
||||
private DirectoryFieldEditor wesnothUserDirField_;
|
||||
private FileFieldEditor wesnothExecutableField_;
|
||||
private DirectoryFieldEditor wmlToolsField_;
|
||||
private DirectoryFieldEditor wesnothWorkingDirField_;
|
||||
private DirectoryFieldEditor wesnothUserDirField_;
|
||||
private FileFieldEditor wesnothExecutableField_;
|
||||
|
||||
private List<String> wmlToolsList_;
|
||||
private Composite parentComposite_;
|
||||
private List< String > wmlToolsList_;
|
||||
private Composite parentComposite_;
|
||||
|
||||
public WesnothInstallsPage()
|
||||
public WesnothInstallsPage( )
|
||||
{
|
||||
super(GRID);
|
||||
setPreferenceStore(WesnothPlugin.getDefault().getPreferenceStore());
|
||||
setTitle(Messages.WesnothInstallsPage_0);
|
||||
super( GRID );
|
||||
setPreferenceStore( WesnothPlugin.getDefault( ).getPreferenceStore( ) );
|
||||
setTitle( Messages.WesnothInstallsPage_0 );
|
||||
|
||||
wmlToolsList_ = new ArrayList<String>();
|
||||
wmlToolsList_.add("wmllint"); //$NON-NLS-1$
|
||||
wmlToolsList_.add("wmlindent"); //$NON-NLS-1$
|
||||
wmlToolsList_.add("wmlscope"); //$NON-NLS-1$
|
||||
wmlToolsList_.add("wesnoth_addon_manager"); //$NON-NLS-1$
|
||||
wmlToolsList_ = new ArrayList< String >( );
|
||||
wmlToolsList_.add( "wmllint" ); //$NON-NLS-1$
|
||||
wmlToolsList_.add( "wmlindent" ); //$NON-NLS-1$
|
||||
wmlToolsList_.add( "wmlscope" ); //$NON-NLS-1$
|
||||
wmlToolsList_.add( "wesnoth_addon_manager" ); //$NON-NLS-1$
|
||||
|
||||
installs_ = new HashMap<String, WesnothInstall>();
|
||||
installs_ = new HashMap< String, WesnothInstall >( );
|
||||
|
||||
List<WesnothInstall> installs = WesnothInstallsUtils.getInstalls( );
|
||||
for ( WesnothInstall wesnothInstall : installs )
|
||||
{
|
||||
List< WesnothInstall > installs = WesnothInstallsUtils.getInstalls( );
|
||||
for( WesnothInstall wesnothInstall: installs ) {
|
||||
installs_.put( wesnothInstall.getName( ), wesnothInstall );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createFieldEditors()
|
||||
protected void createFieldEditors( )
|
||||
{
|
||||
ModifyListener listener = new ModifyListener() {
|
||||
ModifyListener listener = new ModifyListener( ) {
|
||||
|
||||
@Override
|
||||
public void modifyText(ModifyEvent e)
|
||||
public void modifyText( ModifyEvent e )
|
||||
{
|
||||
checkState();
|
||||
guessDefaultPaths();
|
||||
checkState( );
|
||||
guessDefaultPaths( );
|
||||
}
|
||||
};
|
||||
|
||||
wesnothExecutableField_ = new FileFieldEditor( "", //$NON-NLS-1$
|
||||
Messages.WesnothPreferencesPage_5, getFieldEditorParent());
|
||||
wesnothExecutableField_.getTextControl(getFieldEditorParent()).
|
||||
addFocusListener(new FocusListener() {
|
||||
@Override
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
checkState();
|
||||
}
|
||||
@Override
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
}
|
||||
});
|
||||
wesnothExecutableField_.getTextControl(getFieldEditorParent()).
|
||||
addModifyListener(new ModifyListener() {
|
||||
Messages.WesnothPreferencesPage_5, getFieldEditorParent( ) );
|
||||
wesnothExecutableField_.getTextControl( getFieldEditorParent( ) )
|
||||
.addFocusListener( new FocusListener( ) {
|
||||
@Override
|
||||
public void focusLost( FocusEvent e )
|
||||
{
|
||||
checkState( );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyText(ModifyEvent e)
|
||||
{
|
||||
checkState();
|
||||
}
|
||||
});
|
||||
addField(wesnothExecutableField_, Messages.WesnothPreferencesPage_6);
|
||||
@Override
|
||||
public void focusGained( FocusEvent e )
|
||||
{
|
||||
}
|
||||
} );
|
||||
wesnothExecutableField_.getTextControl( getFieldEditorParent( ) )
|
||||
.addModifyListener( new ModifyListener( ) {
|
||||
|
||||
@Override
|
||||
public void modifyText( ModifyEvent e )
|
||||
{
|
||||
checkState( );
|
||||
}
|
||||
} );
|
||||
addField( wesnothExecutableField_, Messages.WesnothPreferencesPage_6 );
|
||||
|
||||
wesnothWorkingDirField_ = new DirectoryFieldEditor( "", //$NON-NLS-1$
|
||||
Messages.WesnothPreferencesPage_7, getFieldEditorParent());
|
||||
wesnothWorkingDirField_.getTextControl(getFieldEditorParent()).
|
||||
addModifyListener(listener);
|
||||
addField(wesnothWorkingDirField_, Messages.WesnothPreferencesPage_8);
|
||||
Messages.WesnothPreferencesPage_7, getFieldEditorParent( ) );
|
||||
wesnothWorkingDirField_.getTextControl( getFieldEditorParent( ) )
|
||||
.addModifyListener( listener );
|
||||
addField( wesnothWorkingDirField_, Messages.WesnothPreferencesPage_8 );
|
||||
|
||||
wesnothUserDirField_ = new DirectoryFieldEditor( "", //$NON-NLS-1$
|
||||
Messages.WesnothPreferencesPage_9, getFieldEditorParent());
|
||||
addField(wesnothUserDirField_, Messages.WesnothPreferencesPage_10);
|
||||
Messages.WesnothPreferencesPage_9, getFieldEditorParent( ) );
|
||||
addField( wesnothUserDirField_, Messages.WesnothPreferencesPage_10 );
|
||||
|
||||
wmlToolsField_ = new DirectoryFieldEditor( "", //$NON-NLS-1$
|
||||
Messages.WesnothPreferencesPage_11, getFieldEditorParent());
|
||||
addField(wmlToolsField_, Messages.WesnothPreferencesPage_12);
|
||||
Messages.WesnothPreferencesPage_11, getFieldEditorParent( ) );
|
||||
addField( wmlToolsField_, Messages.WesnothPreferencesPage_12 );
|
||||
|
||||
addField(new FileFieldEditor(Constants.P_PYTHON_PATH,
|
||||
Messages.WesnothPreferencesPage_13, getFieldEditorParent()));
|
||||
addField( new FileFieldEditor( Constants.P_PYTHON_PATH,
|
||||
Messages.WesnothPreferencesPage_13, getFieldEditorParent( ) ) );
|
||||
|
||||
addField(new LabelFieldEditor(Messages.WesnothPreferencesPage_14,
|
||||
getFieldEditorParent()));
|
||||
addField( new LabelFieldEditor( Messages.WesnothPreferencesPage_14,
|
||||
getFieldEditorParent( ) ) );
|
||||
|
||||
// update the default
|
||||
updateInterface( installs_.get( Preferences.getDefaultInstallName( ) ) );
|
||||
guessDefaultPaths();
|
||||
guessDefaultPaths( );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Control createContents(Composite parent)
|
||||
protected Control createContents( Composite parent )
|
||||
{
|
||||
Composite installComposite = new Composite(parent, 0);
|
||||
installComposite.setLayout(new GridLayout(2, false));
|
||||
installComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
|
||||
Composite installComposite = new Composite( parent, 0 );
|
||||
installComposite.setLayout( new GridLayout( 2, false ) );
|
||||
installComposite.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true,
|
||||
true, 1, 1 ) );
|
||||
|
||||
// create install manager
|
||||
installsTableViewer_ = new TableViewer(installComposite, SWT.BORDER | SWT.FULL_SELECTION);
|
||||
installsTable_ = installsTableViewer_.getTable();
|
||||
installsTable_.addMouseListener(new MouseAdapter() {
|
||||
installsTableViewer_ = new TableViewer( installComposite, SWT.BORDER
|
||||
| SWT.FULL_SELECTION );
|
||||
installsTable_ = installsTableViewer_.getTable( );
|
||||
installsTable_.addMouseListener( new MouseAdapter( ) {
|
||||
@Override
|
||||
public void mouseDown(MouseEvent e)
|
||||
public void mouseDown( MouseEvent e )
|
||||
{
|
||||
updateInterface(getSelectedInstall());
|
||||
updateInterface( getSelectedInstall( ) );
|
||||
}
|
||||
});
|
||||
installsTable_.setHeaderVisible(true);
|
||||
installsTable_.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
|
||||
} );
|
||||
installsTable_.setHeaderVisible( true );
|
||||
installsTable_.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true,
|
||||
true, 1, 1 ) );
|
||||
|
||||
TableColumn tblclmnName = new TableColumn(installsTable_, SWT.NONE);
|
||||
tblclmnName.setWidth(150);
|
||||
tblclmnName.setText(Messages.WesnothInstallsPage_5);
|
||||
TableColumn tblclmnName = new TableColumn( installsTable_, SWT.NONE );
|
||||
tblclmnName.setWidth( 150 );
|
||||
tblclmnName.setText( Messages.WesnothInstallsPage_5 );
|
||||
|
||||
TableColumn tblclmnWesnothVersion = new TableColumn(installsTable_, SWT.NONE);
|
||||
tblclmnWesnothVersion.setWidth(70);
|
||||
tblclmnWesnothVersion.setText(Messages.WesnothInstallsPage_6);
|
||||
TableColumn tblclmnWesnothVersion = new TableColumn( installsTable_,
|
||||
SWT.NONE );
|
||||
tblclmnWesnothVersion.setWidth( 70 );
|
||||
tblclmnWesnothVersion.setText( Messages.WesnothInstallsPage_6 );
|
||||
|
||||
TableColumn tblclmnIsDefault = new TableColumn(installsTable_, SWT.NONE);
|
||||
tblclmnIsDefault.setWidth(70);
|
||||
tblclmnIsDefault.setText(Messages.WesnothInstallsPage_7);
|
||||
TableColumn tblclmnIsDefault = new TableColumn( installsTable_,
|
||||
SWT.NONE );
|
||||
tblclmnIsDefault.setWidth( 70 );
|
||||
tblclmnIsDefault.setText( Messages.WesnothInstallsPage_7 );
|
||||
|
||||
installsTableViewer_.setContentProvider(new ArrayContentProvider());
|
||||
installsTableViewer_.setLabelProvider(new TableLabelProvider());
|
||||
installsTableViewer_.setInput(installs_.values());
|
||||
installsTableViewer_.setContentProvider( new ArrayContentProvider( ) );
|
||||
installsTableViewer_.setLabelProvider( new TableLabelProvider( ) );
|
||||
installsTableViewer_.setInput( installs_.values( ) );
|
||||
|
||||
Composite composite = new Composite(installComposite, SWT.NONE);
|
||||
FillLayout fl_composite = new FillLayout(SWT.VERTICAL);
|
||||
Composite composite = new Composite( installComposite, SWT.NONE );
|
||||
FillLayout fl_composite = new FillLayout( SWT.VERTICAL );
|
||||
fl_composite.spacing = 10;
|
||||
fl_composite.marginHeight = 10;
|
||||
composite.setLayout(fl_composite);
|
||||
GridData gd_composite = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
|
||||
composite.setLayout( fl_composite );
|
||||
GridData gd_composite = new GridData( SWT.FILL, SWT.CENTER, true,
|
||||
false, 1, 1 );
|
||||
gd_composite.widthHint = 80;
|
||||
composite.setLayoutData(gd_composite);
|
||||
composite.setLayoutData( gd_composite );
|
||||
|
||||
Button btnNew = new Button(composite, SWT.NONE);
|
||||
btnNew.addSelectionListener(new SelectionAdapter() {
|
||||
Button btnNew = new Button( composite, SWT.NONE );
|
||||
btnNew.addSelectionListener( new SelectionAdapter( ) {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
newInstall();
|
||||
public void widgetSelected( SelectionEvent e )
|
||||
{
|
||||
newInstall( );
|
||||
}
|
||||
});
|
||||
btnNew.setText(Messages.WesnothInstallsPage_8);
|
||||
} );
|
||||
btnNew.setText( Messages.WesnothInstallsPage_8 );
|
||||
|
||||
Button btnRemove = new Button(composite, SWT.NONE);
|
||||
btnRemove.addSelectionListener(new SelectionAdapter() {
|
||||
Button btnRemove = new Button( composite, SWT.NONE );
|
||||
btnRemove.addSelectionListener( new SelectionAdapter( ) {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
public void widgetSelected( SelectionEvent e )
|
||||
{
|
||||
removeInstall( getSelectedInstall( ) );
|
||||
}
|
||||
});
|
||||
btnRemove.setText(Messages.WesnothInstallsPage_9);
|
||||
} );
|
||||
btnRemove.setText( Messages.WesnothInstallsPage_9 );
|
||||
|
||||
Button btnSetAsDefault = new Button(composite, SWT.NONE);
|
||||
btnSetAsDefault.addSelectionListener(new SelectionAdapter() {
|
||||
Button btnSetAsDefault = new Button( composite, SWT.NONE );
|
||||
btnSetAsDefault.addSelectionListener( new SelectionAdapter( ) {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
public void widgetSelected( SelectionEvent e )
|
||||
{
|
||||
setInstallAsDefault( getSelectedInstall( ) );
|
||||
}
|
||||
});
|
||||
btnSetAsDefault.setText(Messages.WesnothInstallsPage_10);
|
||||
} );
|
||||
btnSetAsDefault.setText( Messages.WesnothInstallsPage_10 );
|
||||
|
||||
Label lblInstallName = new Label(parent, SWT.NONE);
|
||||
lblInstallName.setText(Messages.WesnothInstallsPage_11);
|
||||
Label lblInstallName = new Label( parent, SWT.NONE );
|
||||
lblInstallName.setText( Messages.WesnothInstallsPage_11 );
|
||||
|
||||
txtInstallName_ = new Text(parent, SWT.SINGLE);
|
||||
txtInstallName_ = new Text( parent, SWT.SINGLE );
|
||||
txtInstallName_.setText( Messages.WesnothInstallsPage_12 );
|
||||
txtInstallName_.setEditable( false );
|
||||
txtInstallName_.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
|
||||
txtInstallName_.addVerifyListener(new VerifyListener() {
|
||||
txtInstallName_.setLayoutData( new GridData( SWT.FILL, SWT.CENTER,
|
||||
false, false, 1, 1 ) );
|
||||
txtInstallName_.addVerifyListener( new VerifyListener( ) {
|
||||
|
||||
private boolean isCharOk( char character )
|
||||
{
|
||||
return ( character >= 'a' && character <= 'z' ) ||
|
||||
( character >= 'A' && character <= 'Z' ) ||
|
||||
( character >= '0' && character <= '9' );
|
||||
return ( character >= 'a' && character <= 'z' )
|
||||
|| ( character >= 'A' && character <= 'Z' )
|
||||
|| ( character >= '0' && character <= '9' );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void verifyText(VerifyEvent e)
|
||||
public void verifyText( VerifyEvent e )
|
||||
{
|
||||
if ( e.character == 0 )
|
||||
{
|
||||
if( e.character == 0 ) {
|
||||
// we got a text copied. Check for invalid chars.
|
||||
for ( int index = e.text.length() - 1; index >= 0; --index ) {
|
||||
if ( isCharOk( e.text.charAt(index) ) == false ) {
|
||||
for( int index = e.text.length( ) - 1; index >= 0; --index ) {
|
||||
if( isCharOk( e.text.charAt( index ) ) == false ) {
|
||||
e.doit = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
e.doit = isCharOk( e.character ) ||
|
||||
e.keyCode == SWT.BS ||
|
||||
e.keyCode == SWT.ARROW_LEFT ||
|
||||
e.keyCode == SWT.ARROW_RIGHT ||
|
||||
e.keyCode == SWT.DEL;
|
||||
}
|
||||
else {
|
||||
e.doit = isCharOk( e.character ) || e.keyCode == SWT.BS
|
||||
|| e.keyCode == SWT.ARROW_LEFT
|
||||
|| e.keyCode == SWT.ARROW_RIGHT
|
||||
|| e.keyCode == SWT.DEL;
|
||||
}
|
||||
}
|
||||
});
|
||||
} );
|
||||
|
||||
Label lblVersion = new Label(parent, SWT.NONE);
|
||||
lblVersion.setText(Messages.WesnothInstallsPage_13);
|
||||
Label lblVersion = new Label( parent, SWT.NONE );
|
||||
lblVersion.setText( Messages.WesnothInstallsPage_13 );
|
||||
|
||||
cmbVersion_ = new Combo(parent, SWT.READ_ONLY);
|
||||
cmbVersion_.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
|
||||
cmbVersion_ = new Combo( parent, SWT.READ_ONLY );
|
||||
cmbVersion_.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true,
|
||||
false, 1, 1 ) );
|
||||
|
||||
cmbVersion_.add( "1.9.x" ); //$NON-NLS-1$
|
||||
cmbVersion_.add( "trunk" ); //$NON-NLS-1$
|
||||
cmbVersion_.select( 0 );
|
||||
|
||||
// create fields
|
||||
parentComposite_ = (Composite) super.createContents(parent);
|
||||
parentComposite_ = ( Composite ) super.createContents( parent );
|
||||
|
||||
return parentComposite_;
|
||||
}
|
||||
|
||||
protected void newInstall()
|
||||
protected void newInstall( )
|
||||
{
|
||||
updateInterface(null);
|
||||
updateInterface( null );
|
||||
}
|
||||
|
||||
protected void setInstallAsDefault( WesnothInstall install )
|
||||
{
|
||||
if (install != null) {
|
||||
if( install != null ) {
|
||||
Preferences.setDefaultInstallName( install.getName( ) );
|
||||
installsTableViewer_.refresh();
|
||||
installsTableViewer_.refresh( );
|
||||
}
|
||||
}
|
||||
|
||||
protected void removeInstall( WesnothInstall install )
|
||||
{
|
||||
if ( install != null ){
|
||||
if( install != null ) {
|
||||
installs_.remove( install.getName( ) );
|
||||
installsTableViewer_.refresh();
|
||||
installsTableViewer_.refresh( );
|
||||
|
||||
// unset all settings.
|
||||
IPreferenceStore prefs = Preferences.getPreferences( );
|
||||
String installPrefix = Preferences.getInstallPrefix( install.getName( ) );
|
||||
IPreferenceStore prefs = Preferences.getPreferences( );
|
||||
String installPrefix = Preferences.getInstallPrefix( install
|
||||
.getName( ) );
|
||||
prefs.setToDefault( installPrefix + Constants.P_WESNOTH_EXEC_PATH );
|
||||
prefs.setToDefault( installPrefix + Constants.P_WESNOTH_USER_DIR );
|
||||
prefs.setToDefault( installPrefix + Constants.P_WESNOTH_WMLTOOLS_DIR );
|
||||
prefs.setToDefault( installPrefix
|
||||
+ Constants.P_WESNOTH_WMLTOOLS_DIR );
|
||||
prefs.setToDefault( installPrefix + Constants.P_WESNOTH_WORKING_DIR );
|
||||
|
||||
// unset the default install if this was that
|
||||
// and select another one (the first) - if any - as default
|
||||
if ( install.getName( ).equals( Preferences.getDefaultInstallName( ) ) ) {
|
||||
if( install.getName( )
|
||||
.equals( Preferences.getDefaultInstallName( ) ) ) {
|
||||
Preferences.setDefaultInstallName( "" ); //$NON-NLS-1$
|
||||
|
||||
if ( ! installs_.isEmpty( ) ){
|
||||
if( ! installs_.isEmpty( ) ) {
|
||||
// get the first item from the iterator
|
||||
Iterator<WesnothInstall> itor = installs_.values( ).iterator( );
|
||||
Iterator< WesnothInstall > itor = installs_.values( )
|
||||
.iterator( );
|
||||
setInstallAsDefault( itor.next( ) );
|
||||
}
|
||||
}
|
||||
|
@ -333,157 +348,165 @@ public class WesnothInstallsPage extends AbstractPreferencePage
|
|||
}
|
||||
}
|
||||
|
||||
private WesnothInstall getSelectedInstall()
|
||||
private WesnothInstall getSelectedInstall( )
|
||||
{
|
||||
if (installsTable_.getSelectionIndex() == -1)
|
||||
if( installsTable_.getSelectionIndex( ) == - 1 )
|
||||
return null;
|
||||
return installs_.get(installsTable_.getSelection()[0].getText(0));
|
||||
return installs_.get( installsTable_.getSelection( )[0].getText( 0 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the interface with the specified install
|
||||
* @param install The install
|
||||
*
|
||||
* @param install
|
||||
* The install
|
||||
*/
|
||||
private void updateInterface(WesnothInstall install)
|
||||
private void updateInterface( WesnothInstall install )
|
||||
{
|
||||
txtInstallName_.setText( install == null ? "" : install.getName( ) ); //$NON-NLS-1$
|
||||
txtInstallName_.setEditable( install == null ? true : false );
|
||||
txtInstallName_.setText( install == null ? "": install.getName( ) ); //$NON-NLS-1$
|
||||
txtInstallName_.setEditable( install == null ? true: false );
|
||||
|
||||
cmbVersion_.setText( install == null ? "" : install.getVersion( ) ); //$NON-NLS-1$
|
||||
cmbVersion_.setText( install == null ? "": install.getVersion( ) ); //$NON-NLS-1$
|
||||
|
||||
setFieldsPreferenceName(
|
||||
install == null ? "" : Preferences.getInstallPrefix( install.getName( ) ), //$NON-NLS-1$
|
||||
install == null ? "": Preferences.getInstallPrefix( install.getName( ) ), //$NON-NLS-1$
|
||||
true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the fields's internal preference name based on the installPrefix
|
||||
* @param installPrefix The install prefix
|
||||
* @param loadPreferences True to load the current stored preference
|
||||
*
|
||||
* @param installPrefix
|
||||
* The install prefix
|
||||
* @param loadPreferences
|
||||
* True to load the current stored preference
|
||||
*/
|
||||
private void setFieldsPreferenceName( String installPrefix, boolean loadPreferences )
|
||||
private void setFieldsPreferenceName( String installPrefix,
|
||||
boolean loadPreferences )
|
||||
{
|
||||
wesnothExecutableField_.setPreferenceName( installPrefix + Constants.P_WESNOTH_EXEC_PATH );
|
||||
wesnothExecutableField_.setPreferenceName( installPrefix
|
||||
+ Constants.P_WESNOTH_EXEC_PATH );
|
||||
|
||||
wesnothUserDirField_.setPreferenceName( installPrefix + Constants.P_WESNOTH_USER_DIR );
|
||||
wesnothUserDirField_.setPreferenceName( installPrefix
|
||||
+ Constants.P_WESNOTH_USER_DIR );
|
||||
|
||||
wesnothWorkingDirField_.setPreferenceName( installPrefix + Constants.P_WESNOTH_WORKING_DIR );
|
||||
wesnothWorkingDirField_.setPreferenceName( installPrefix
|
||||
+ Constants.P_WESNOTH_WORKING_DIR );
|
||||
|
||||
wmlToolsField_.setPreferenceName( installPrefix + Constants.P_WESNOTH_WMLTOOLS_DIR );
|
||||
wmlToolsField_.setPreferenceName( installPrefix
|
||||
+ Constants.P_WESNOTH_WMLTOOLS_DIR );
|
||||
|
||||
if ( loadPreferences ) {
|
||||
if( loadPreferences ) {
|
||||
wesnothUserDirField_.setStringValue( "" ); //$NON-NLS-1$
|
||||
wesnothWorkingDirField_.setStringValue( "" ); //$NON-NLS-1$
|
||||
wesnothExecutableField_.setStringValue( "" ); //$NON-NLS-1$
|
||||
wmlToolsField_.setStringValue( "" ); //$NON-NLS-1$
|
||||
|
||||
wesnothUserDirField_.load();
|
||||
wesnothWorkingDirField_.load();
|
||||
wesnothExecutableField_.load();
|
||||
wmlToolsField_.load();
|
||||
wesnothUserDirField_.load( );
|
||||
wesnothWorkingDirField_.load( );
|
||||
wesnothExecutableField_.load( );
|
||||
wmlToolsField_.load( );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkState()
|
||||
protected void checkState( )
|
||||
{
|
||||
super.checkState();
|
||||
setValid(true);
|
||||
super.checkState( );
|
||||
setValid( true );
|
||||
|
||||
String wesnothExec = wesnothExecutableField_.getStringValue();
|
||||
if ( new File( wesnothExec ).exists() ){
|
||||
String wesnothExecName = new File( wesnothExec ).getName();
|
||||
String wesnothExec = wesnothExecutableField_.getStringValue( );
|
||||
if( new File( wesnothExec ).exists( ) ) {
|
||||
String wesnothExecName = new File( wesnothExec ).getName( );
|
||||
|
||||
if (wesnothWorkingDirField_.getStringValue().isEmpty() &&
|
||||
!wesnothExec.isEmpty() &&
|
||||
new File(wesnothExec.substring(0,
|
||||
wesnothExec.lastIndexOf(wesnothExecName))).exists())
|
||||
{
|
||||
wesnothWorkingDirField_.setStringValue(wesnothExec.substring(0,
|
||||
wesnothExec.lastIndexOf(wesnothExecName)));
|
||||
if( wesnothWorkingDirField_.getStringValue( ).isEmpty( )
|
||||
&& ! wesnothExec.isEmpty( )
|
||||
&& new File( wesnothExec.substring( 0,
|
||||
wesnothExec.lastIndexOf( wesnothExecName ) ) )
|
||||
.exists( ) ) {
|
||||
wesnothWorkingDirField_.setStringValue( wesnothExec.substring(
|
||||
0, wesnothExec.lastIndexOf( wesnothExecName ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
testWMLToolsPath(wmlToolsField_.getStringValue());
|
||||
setErrorMessage(null);
|
||||
testWMLToolsPath( wmlToolsField_.getStringValue( ) );
|
||||
setErrorMessage( null );
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries the list of available paths for current os
|
||||
*/
|
||||
private void guessDefaultPaths()
|
||||
private void guessDefaultPaths( )
|
||||
{
|
||||
String os = "linux"; //$NON-NLS-1$
|
||||
if (Constants.IS_MAC_MACHINE)
|
||||
if( Constants.IS_MAC_MACHINE )
|
||||
os = "mac"; //$NON-NLS-1$
|
||||
else if (Constants.IS_WINDOWS_MACHINE)
|
||||
else if( Constants.IS_WINDOWS_MACHINE )
|
||||
os = "windows"; //$NON-NLS-1$
|
||||
|
||||
List<ReplaceableParameter> params = new ArrayList<ReplaceableParameter>();
|
||||
params.add(new ReplaceableParameter("$$home_path", System.getProperty("user.home"))); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
List< ReplaceableParameter > params = new ArrayList< ReplaceableParameter >( );
|
||||
params.add( new ReplaceableParameter(
|
||||
"$$home_path", System.getProperty( "user.home" ) ) ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
testPaths(StringUtils.getLines(
|
||||
TemplateProvider.getInstance().getProcessedTemplate(os + "_exec", params)), //$NON-NLS-1$
|
||||
wesnothExecutableField_);
|
||||
testPaths(StringUtils.getLines(
|
||||
TemplateProvider.getInstance().getProcessedTemplate(os + "_data", params)), //$NON-NLS-1$
|
||||
wesnothWorkingDirField_);
|
||||
testPaths(StringUtils.getLines(
|
||||
TemplateProvider.getInstance().getProcessedTemplate(os + "_user", params)), //$NON-NLS-1$
|
||||
wesnothUserDirField_);
|
||||
testPaths( StringUtils.getLines( TemplateProvider.getInstance( )
|
||||
.getProcessedTemplate( os + "_exec", params ) ), //$NON-NLS-1$
|
||||
wesnothExecutableField_ );
|
||||
testPaths( StringUtils.getLines( TemplateProvider.getInstance( )
|
||||
.getProcessedTemplate( os + "_data", params ) ), //$NON-NLS-1$
|
||||
wesnothWorkingDirField_ );
|
||||
testPaths( StringUtils.getLines( TemplateProvider.getInstance( )
|
||||
.getProcessedTemplate( os + "_user", params ) ), //$NON-NLS-1$
|
||||
wesnothUserDirField_ );
|
||||
|
||||
// guess the working dir based on executable's path
|
||||
Text textControl = wesnothWorkingDirField_.getTextControl(
|
||||
getFieldEditorParent());
|
||||
Text textControl = wesnothWorkingDirField_
|
||||
.getTextControl( getFieldEditorParent( ) );
|
||||
|
||||
String workingDirValue = wesnothWorkingDirField_.getStringValue();
|
||||
String wesnothExecValue = wesnothExecutableField_.getStringValue();
|
||||
String workingDirValue = wesnothWorkingDirField_.getStringValue( );
|
||||
String wesnothExecValue = wesnothExecutableField_.getStringValue( );
|
||||
|
||||
if ( workingDirValue.isEmpty() &&
|
||||
! wesnothExecValue.isEmpty() &&
|
||||
new File(wesnothExecValue.substring(0,
|
||||
wesnothExecValue.lastIndexOf(new File(wesnothExecValue).getName()))).exists())
|
||||
{
|
||||
textControl.setText(wesnothExecValue.substring(0,
|
||||
wesnothExecValue.lastIndexOf(new File(wesnothExecValue).getName()))
|
||||
);
|
||||
if( workingDirValue.isEmpty( )
|
||||
&& ! wesnothExecValue.isEmpty( )
|
||||
&& new File(
|
||||
wesnothExecValue.substring( 0, wesnothExecValue
|
||||
.lastIndexOf( new File( wesnothExecValue )
|
||||
.getName( ) ) ) ).exists( ) ) {
|
||||
textControl.setText( wesnothExecValue.substring( 0,
|
||||
wesnothExecValue.lastIndexOf( new File( wesnothExecValue )
|
||||
.getName( ) ) ) );
|
||||
}
|
||||
|
||||
// guess the wmltools path
|
||||
if ( wmlToolsField_.getStringValue().isEmpty() &&
|
||||
! workingDirValue.isEmpty() )
|
||||
{
|
||||
if( wmlToolsField_.getStringValue( ).isEmpty( )
|
||||
&& ! workingDirValue.isEmpty( ) ) {
|
||||
String path = workingDirValue + "/data/tools"; //$NON-NLS-1$
|
||||
if ( testWMLToolsPath( path ) ) {
|
||||
if( testWMLToolsPath( path ) ) {
|
||||
wmlToolsField_.setStringValue( path );
|
||||
}
|
||||
}
|
||||
|
||||
String userDirValue = wesnothUserDirField_.getStringValue();
|
||||
String userDirValue = wesnothUserDirField_.getStringValue( );
|
||||
// guess the userdata path
|
||||
if ( userDirValue.isEmpty() &&
|
||||
! workingDirValue.isEmpty() )
|
||||
{
|
||||
if( userDirValue.isEmpty( ) && ! workingDirValue.isEmpty( ) ) {
|
||||
String path = workingDirValue + "/userdata"; //$NON-NLS-1$
|
||||
testPaths( new String[] { path }, wesnothUserDirField_ );
|
||||
}
|
||||
|
||||
checkState();
|
||||
checkState( );
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests for wmltools in the specified path
|
||||
*
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
private boolean testWMLToolsPath(String path)
|
||||
private boolean testWMLToolsPath( String path )
|
||||
{
|
||||
for(String tool : wmlToolsList_)
|
||||
{
|
||||
if (!(new File(path + Path.SEPARATOR + tool).exists()))
|
||||
{
|
||||
setErrorMessage(String.format(Messages.WesnothPreferencesPage_24,
|
||||
tool));
|
||||
for( String tool: wmlToolsList_ ) {
|
||||
if( ! ( new File( path + Path.SEPARATOR + tool ).exists( ) ) ) {
|
||||
setErrorMessage( String.format(
|
||||
Messages.WesnothPreferencesPage_24, tool ) );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -494,19 +517,20 @@ public class WesnothInstallsPage extends AbstractPreferencePage
|
|||
* Tests the list of paths and if any path exists it will
|
||||
* set it as the string value to the field editor
|
||||
* if the field editor value is empty
|
||||
* @param list The list to search in
|
||||
* @param field The field to put the path in
|
||||
*
|
||||
* @param list
|
||||
* The list to search in
|
||||
* @param field
|
||||
* The field to put the path in
|
||||
*/
|
||||
private void testPaths(String[] list, StringFieldEditor field)
|
||||
private void testPaths( String[] list, StringFieldEditor field )
|
||||
{
|
||||
if (!(field.getStringValue().isEmpty()))
|
||||
if( ! ( field.getStringValue( ).isEmpty( ) ) )
|
||||
return;
|
||||
|
||||
for(String path : list)
|
||||
{
|
||||
if (new File(path).exists())
|
||||
{
|
||||
field.setStringValue(path);
|
||||
for( String path: list ) {
|
||||
if( new File( path ).exists( ) ) {
|
||||
field.setStringValue( path );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -516,33 +540,35 @@ public class WesnothInstallsPage extends AbstractPreferencePage
|
|||
* Checks whether the fields are empty (contain no text)
|
||||
* and the combobox/name don't have any values also
|
||||
* (the user doesn't create a new install)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private boolean isFieldsEmpty()
|
||||
private boolean isFieldsEmpty( )
|
||||
{
|
||||
return wmlToolsField_.getStringValue( ).isEmpty( ) &&
|
||||
wesnothExecutableField_.getStringValue( ).isEmpty( ) &&
|
||||
wesnothUserDirField_.getStringValue( ).isEmpty( ) &&
|
||||
wesnothWorkingDirField_.getStringValue( ).isEmpty( ) &&
|
||||
txtInstallName_.getText( ).isEmpty( );
|
||||
return wmlToolsField_.getStringValue( ).isEmpty( )
|
||||
&& wesnothExecutableField_.getStringValue( ).isEmpty( )
|
||||
&& wesnothUserDirField_.getStringValue( ).isEmpty( )
|
||||
&& wesnothWorkingDirField_.getStringValue( ).isEmpty( )
|
||||
&& txtInstallName_.getText( ).isEmpty( );
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the current install
|
||||
*
|
||||
* @return true if the save was successfully, false otherwise
|
||||
*/
|
||||
private boolean saveInstall()
|
||||
private boolean saveInstall( )
|
||||
{
|
||||
String installName = txtInstallName_.getText();
|
||||
String installName = txtInstallName_.getText( );
|
||||
|
||||
// if it's editable, it means we are creating a new install
|
||||
if ( txtInstallName_.getEditable() ) {
|
||||
if( txtInstallName_.getEditable( ) ) {
|
||||
boolean isFieldsEmpty = isFieldsEmpty( );
|
||||
|
||||
if ( installName.isEmpty() == true ) {
|
||||
if( installName.isEmpty( ) == true ) {
|
||||
// if we haven't completed anything,
|
||||
// we can skip the saving without alerting the user.
|
||||
if ( !isFieldsEmpty )
|
||||
if( ! isFieldsEmpty )
|
||||
GUIUtils.showErrorMessageBox( Messages.WesnothInstallsPage_19 );
|
||||
|
||||
// we consider successfully save if the fields are all
|
||||
|
@ -550,27 +576,29 @@ public class WesnothInstallsPage extends AbstractPreferencePage
|
|||
return isFieldsEmpty;
|
||||
}
|
||||
|
||||
if ( cmbVersion_.getText().isEmpty() == true ) {
|
||||
if( cmbVersion_.getText( ).isEmpty( ) == true ) {
|
||||
GUIUtils.showErrorMessageBox( Messages.WesnothInstallsPage_20 );
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
// update the fields preferences names
|
||||
setFieldsPreferenceName( Preferences.getInstallPrefix( installName ), false );
|
||||
setFieldsPreferenceName(
|
||||
Preferences.getInstallPrefix( installName ), false );
|
||||
|
||||
WesnothInstall newInstall = new WesnothInstall(installName,
|
||||
cmbVersion_.getText());
|
||||
WesnothInstall newInstall = new WesnothInstall( installName,
|
||||
cmbVersion_.getText( ) );
|
||||
|
||||
installs_.put( installName, newInstall );
|
||||
|
||||
// if there is not any install set as default, set this one
|
||||
if ( Preferences.getDefaultInstallName( ).isEmpty( ) )
|
||||
if( Preferences.getDefaultInstallName( ).isEmpty( ) )
|
||||
setInstallAsDefault( newInstall );
|
||||
|
||||
// we are creating a new install. Clear the editable
|
||||
// flag after we save it, to prevent renaming.
|
||||
txtInstallName_.setEditable( false );
|
||||
} else if ( getSelectedInstall( ) != null ) { // just saving
|
||||
}
|
||||
else if( getSelectedInstall( ) != null ) { // just saving
|
||||
// the fields are automatically saved by Eclipse.
|
||||
// we just need to save the new version.
|
||||
getSelectedInstall( ).setVersion( cmbVersion_.getText( ) );
|
||||
|
@ -585,18 +613,18 @@ public class WesnothInstallsPage extends AbstractPreferencePage
|
|||
* This method will unset invalid properties's values,
|
||||
* and saving only valid ones.
|
||||
*/
|
||||
private boolean savePreferences()
|
||||
private boolean savePreferences( )
|
||||
{
|
||||
if (!wesnothExecutableField_.isValid())
|
||||
wesnothExecutableField_.setStringValue(""); //$NON-NLS-1$
|
||||
if (!wesnothUserDirField_.isValid())
|
||||
wesnothUserDirField_.setStringValue(""); //$NON-NLS-1$
|
||||
if (!wesnothWorkingDirField_.isValid())
|
||||
wesnothWorkingDirField_.setStringValue(""); //$NON-NLS-1$
|
||||
if (!wmlToolsField_.isValid())
|
||||
wmlToolsField_.setStringValue(""); //$NON-NLS-1$
|
||||
if( ! wesnothExecutableField_.isValid( ) )
|
||||
wesnothExecutableField_.setStringValue( "" ); //$NON-NLS-1$
|
||||
if( ! wesnothUserDirField_.isValid( ) )
|
||||
wesnothUserDirField_.setStringValue( "" ); //$NON-NLS-1$
|
||||
if( ! wesnothWorkingDirField_.isValid( ) )
|
||||
wesnothWorkingDirField_.setStringValue( "" ); //$NON-NLS-1$
|
||||
if( ! wmlToolsField_.isValid( ) )
|
||||
wmlToolsField_.setStringValue( "" ); //$NON-NLS-1$
|
||||
|
||||
if ( saveInstall() == false )
|
||||
if( saveInstall( ) == false )
|
||||
return false;
|
||||
|
||||
WesnothInstallsUtils.setInstalls( installs_.values( ) );
|
||||
|
@ -604,34 +632,42 @@ public class WesnothInstallsPage extends AbstractPreferencePage
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean performOk()
|
||||
public boolean performOk( )
|
||||
{
|
||||
return savePreferences() && super.performOk();
|
||||
return savePreferences( ) && super.performOk( );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent event)
|
||||
public void propertyChange( PropertyChangeEvent event )
|
||||
{
|
||||
super.propertyChange(event);
|
||||
if (event.getProperty().equals(FieldEditor.VALUE))
|
||||
checkState();
|
||||
super.propertyChange( event );
|
||||
if( event.getProperty( ).equals( FieldEditor.VALUE ) )
|
||||
checkState( );
|
||||
}
|
||||
|
||||
private static class TableLabelProvider extends LabelProvider implements ITableLabelProvider {
|
||||
public Image getColumnImage(Object element, int columnIndex) {
|
||||
private static class TableLabelProvider extends LabelProvider implements
|
||||
ITableLabelProvider
|
||||
{
|
||||
public Image getColumnImage( Object element, int columnIndex )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public String getColumnText(Object element, int columnIndex) {
|
||||
if (element instanceof WesnothInstall){
|
||||
|
||||
public String getColumnText( Object element, int columnIndex )
|
||||
{
|
||||
if( element instanceof WesnothInstall ) {
|
||||
WesnothInstall install = ( WesnothInstall ) element;
|
||||
|
||||
if (columnIndex == 0) { // name
|
||||
return install.getName( );
|
||||
} else if (columnIndex == 1) { // version
|
||||
if( columnIndex == 0 ) { // name
|
||||
return install.getName( );
|
||||
}
|
||||
else if( columnIndex == 1 ) { // version
|
||||
return install.getVersion( );
|
||||
} else if ( columnIndex == 2 ) { // is Default ?
|
||||
}
|
||||
else if( columnIndex == 2 ) { // is Default ?
|
||||
|
||||
if ( install.getName( ).equals( Preferences.getDefaultInstallName( ) ) )
|
||||
if( install.getName( ).equals(
|
||||
Preferences.getDefaultInstallName( ) ) )
|
||||
return Messages.WesnothInstallsPage_21;
|
||||
|
||||
return ""; //$NON-NLS-1$
|
||||
|
|
|
@ -10,12 +10,7 @@ package org.wesnoth.preferences;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
import org.wesnoth.Logger;
|
||||
import org.wesnoth.Messages;
|
||||
import org.wesnoth.WesnothPlugin;
|
||||
import org.wesnoth.utils.GUIUtils;
|
||||
import org.wesnoth.utils.ResourceUtils;
|
||||
import org.wesnoth.utils.WorkspaceUtils;
|
||||
import org.osgi.service.prefs.BackingStoreException;
|
||||
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||
|
@ -28,60 +23,69 @@ import org.eclipse.swt.widgets.Composite;
|
|||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
|
||||
import org.osgi.service.prefs.BackingStoreException;
|
||||
import org.wesnoth.Logger;
|
||||
import org.wesnoth.Messages;
|
||||
import org.wesnoth.WesnothPlugin;
|
||||
import org.wesnoth.utils.GUIUtils;
|
||||
import org.wesnoth.utils.ResourceUtils;
|
||||
import org.wesnoth.utils.WorkspaceUtils;
|
||||
|
||||
public class WesnothPreferencesPage extends AbstractPreferencePage
|
||||
{
|
||||
public WesnothPreferencesPage() {
|
||||
super(GRID);
|
||||
public WesnothPreferencesPage( )
|
||||
{
|
||||
super( GRID );
|
||||
|
||||
setPreferenceStore(WesnothPlugin.getDefault().getPreferenceStore());
|
||||
setDescription(Messages.WesnothPreferencesPage_0);
|
||||
}
|
||||
setPreferenceStore( WesnothPlugin.getDefault( ).getPreferenceStore( ) );
|
||||
setDescription( Messages.WesnothPreferencesPage_0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createFieldEditors()
|
||||
{
|
||||
}
|
||||
@Override
|
||||
public void createFieldEditors( )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Control createContents( Composite parent )
|
||||
{
|
||||
Composite composite = new Composite( parent, SWT.NONE );
|
||||
composite.setLayout(new GridLayout(2, false));
|
||||
@Override
|
||||
protected Control createContents( Composite parent )
|
||||
{
|
||||
Composite composite = new Composite( parent, SWT.NONE );
|
||||
composite.setLayout( new GridLayout( 2, false ) );
|
||||
|
||||
Label lblPlugin = new Label( composite, SWT.NONE );
|
||||
lblPlugin.setText( "Reset all plugin's preferences: " );
|
||||
Label lblPlugin = new Label( composite, SWT.NONE );
|
||||
lblPlugin.setText( "Reset all plugin's preferences: " );
|
||||
|
||||
Button buttonPlugin = new Button ( composite, SWT.NONE );
|
||||
buttonPlugin.setText( "Reset" );
|
||||
buttonPlugin.addSelectionListener( new SelectionListener( ) {
|
||||
Button buttonPlugin = new Button( composite, SWT.NONE );
|
||||
buttonPlugin.setText( "Reset" );
|
||||
buttonPlugin.addSelectionListener( new SelectionListener( ) {
|
||||
|
||||
@Override
|
||||
public void widgetSelected( SelectionEvent e )
|
||||
{
|
||||
if ( GUIUtils.showMessageBox(
|
||||
"Are you sure you want to clear the plugin preferences?",
|
||||
SWT.YES | SWT.NO ) == SWT.NO )
|
||||
return;
|
||||
@Override
|
||||
public void widgetSelected( SelectionEvent e )
|
||||
{
|
||||
if( GUIUtils
|
||||
.showMessageBox(
|
||||
"Are you sure you want to clear the plugin preferences?",
|
||||
SWT.YES | SWT.NO ) == SWT.NO )
|
||||
return;
|
||||
|
||||
// clear the preferences
|
||||
IEclipsePreferences root = Platform.getPreferencesService( ).getRootNode( );
|
||||
IEclipsePreferences root = Platform.getPreferencesService( )
|
||||
.getRootNode( );
|
||||
try {
|
||||
for ( String rootName : root.childrenNames( ) ) {
|
||||
for( String rootName: root.childrenNames( ) ) {
|
||||
|
||||
org.osgi.service.prefs.Preferences childNode = root.node( rootName );
|
||||
for ( String childName : childNode.childrenNames( ) ) {
|
||||
org.osgi.service.prefs.Preferences childNode = root
|
||||
.node( rootName );
|
||||
for( String childName: childNode.childrenNames( ) ) {
|
||||
|
||||
org.osgi.service.prefs.Preferences node = childNode.node( childName );
|
||||
org.osgi.service.prefs.Preferences node = childNode
|
||||
.node( childName );
|
||||
|
||||
if ( childName.startsWith( "org.wesnoth" ) ) {
|
||||
if( childName.startsWith( "org.wesnoth" ) ) {
|
||||
try {
|
||||
node.clear( );
|
||||
node.flush( );
|
||||
node.sync( );
|
||||
}
|
||||
catch ( BackingStoreException e1 ) {
|
||||
} catch( BackingStoreException e1 ) {
|
||||
Logger.getInstance( ).logException( e1 );
|
||||
}
|
||||
}
|
||||
|
@ -90,38 +94,37 @@ public class WesnothPreferencesPage extends AbstractPreferencePage
|
|||
}
|
||||
|
||||
Preferences.initializeToDefault( );
|
||||
}
|
||||
catch ( BackingStoreException e1 ) {
|
||||
e1.printStackTrace();
|
||||
} catch( BackingStoreException e1 ) {
|
||||
e1.printStackTrace( );
|
||||
}
|
||||
|
||||
// clear the plugin's dirs
|
||||
File pluginDir = WesnothPlugin.getDefault( ).
|
||||
getStateLocation( ).toFile( ).getParentFile( );
|
||||
ResourceUtils.deleteDirectory(
|
||||
pluginDir.getAbsolutePath( ) + "/org.wesnoth" );
|
||||
ResourceUtils.deleteDirectory(
|
||||
pluginDir.getAbsolutePath( ) + "/org.wesnoth.ui" );
|
||||
File pluginDir = WesnothPlugin.getDefault( ).getStateLocation( )
|
||||
.toFile( ).getParentFile( );
|
||||
ResourceUtils.deleteDirectory( pluginDir.getAbsolutePath( )
|
||||
+ "/org.wesnoth" );
|
||||
ResourceUtils.deleteDirectory( pluginDir.getAbsolutePath( )
|
||||
+ "/org.wesnoth.ui" );
|
||||
|
||||
// clear the temporary files
|
||||
File[] files =
|
||||
new File( WorkspaceUtils.getTemporaryFolder( ) ).listFiles( );
|
||||
File[] files = new File( WorkspaceUtils.getTemporaryFolder( ) )
|
||||
.listFiles( );
|
||||
|
||||
for ( File file : files ) {
|
||||
for( File file: files ) {
|
||||
// don't remove the logs
|
||||
if ( file.isDirectory( ) && file.getName( ).equals( "logs" ) )
|
||||
if( file.isDirectory( ) && file.getName( ).equals( "logs" ) )
|
||||
continue;
|
||||
|
||||
ResourceUtils.deleteDirectory( file );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void widgetDefaultSelected( SelectionEvent e )
|
||||
{
|
||||
}
|
||||
} );
|
||||
@Override
|
||||
public void widgetDefaultSelected( SelectionEvent e )
|
||||
{
|
||||
}
|
||||
} );
|
||||
|
||||
return super.createContents(parent);
|
||||
}
|
||||
}
|
||||
return super.createContents( parent );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,102 +19,112 @@ import org.wesnoth.utils.ResourceUtils;
|
|||
/**
|
||||
* This represents a WML preprocessor define:
|
||||
* [preproc_define]
|
||||
* name = ""
|
||||
* value = ""
|
||||
* textdomain = ""
|
||||
* linenum = ""
|
||||
* location = ""
|
||||
* name = ""
|
||||
* value = ""
|
||||
* textdomain = ""
|
||||
* linenum = ""
|
||||
* location = ""
|
||||
* [/preproc_define]
|
||||
*/
|
||||
public class Define
|
||||
{
|
||||
private String name_;
|
||||
private String value_;
|
||||
private String textdomain_;
|
||||
private int lineNum_;
|
||||
private String location_;
|
||||
private List<String> args_;
|
||||
private String name_;
|
||||
private String value_;
|
||||
private String textdomain_;
|
||||
private int lineNum_;
|
||||
private String location_;
|
||||
private List< String > args_;
|
||||
|
||||
public Define(String name, String value, String textdomain,
|
||||
int linenum, String location, List<String> args)
|
||||
{
|
||||
name_ = name;
|
||||
value_ = value;
|
||||
textdomain_ = textdomain;
|
||||
lineNum_ = linenum;
|
||||
location_ = location;
|
||||
args_ = args;
|
||||
public Define( String name, String value, String textdomain, int linenum,
|
||||
String location, List< String > args )
|
||||
{
|
||||
name_ = name;
|
||||
value_ = value;
|
||||
textdomain_ = textdomain;
|
||||
lineNum_ = linenum;
|
||||
location_ = location;
|
||||
args_ = args;
|
||||
|
||||
// ensure no NullPointerException exists
|
||||
if (args_ == null)
|
||||
args_ = new ArrayList<String>();
|
||||
}
|
||||
// ensure no NullPointerException exists
|
||||
if( args_ == null )
|
||||
args_ = new ArrayList< String >( );
|
||||
}
|
||||
|
||||
public int getLineNum()
|
||||
{
|
||||
return lineNum_;
|
||||
}
|
||||
public String getLocation()
|
||||
{
|
||||
return location_;
|
||||
}
|
||||
public String getName()
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
public String getTextdomain()
|
||||
{
|
||||
return textdomain_;
|
||||
}
|
||||
public String getValue()
|
||||
{
|
||||
return value_;
|
||||
}
|
||||
public int getLineNum( )
|
||||
{
|
||||
return lineNum_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the arguments of this macro
|
||||
* @return
|
||||
*/
|
||||
public List<String> getArguments()
|
||||
{
|
||||
return args_;
|
||||
}
|
||||
public String getLocation( )
|
||||
{
|
||||
return location_;
|
||||
}
|
||||
|
||||
public String getName( )
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
public String getTextdomain( )
|
||||
{
|
||||
return textdomain_;
|
||||
}
|
||||
|
||||
public String getValue( )
|
||||
{
|
||||
return value_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the arguments of this macro
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List< String > getArguments( )
|
||||
{
|
||||
return args_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string containing the current define, formatted
|
||||
*
|
||||
* @return The string value of the define
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
public String toString( )
|
||||
{
|
||||
StringBuilder res = new StringBuilder();
|
||||
res.append("[preproc_define]"); //$NON-NLS-1$
|
||||
res.append("\tname=\"" + name_ + "\"");
|
||||
res.append("\tvalue=\"" + value_ + "\"");
|
||||
res.append("\ttextdomain=\"" + textdomain_ + "\"");
|
||||
res.append("\tlinenum=\"" + lineNum_ + "\"");
|
||||
res.append("\tlocation=\"" + location_ + "\"");
|
||||
res.append("[/preproc_define]"); //$NON-NLS-1$
|
||||
return res.toString();
|
||||
StringBuilder res = new StringBuilder( );
|
||||
res.append( "[preproc_define]" ); //$NON-NLS-1$
|
||||
res.append( "\tname=\"" + name_ + "\"" );
|
||||
res.append( "\tvalue=\"" + value_ + "\"" );
|
||||
res.append( "\ttextdomain=\"" + textdomain_ + "\"" );
|
||||
res.append( "\tlinenum=\"" + lineNum_ + "\"" );
|
||||
res.append( "\tlocation=\"" + location_ + "\"" );
|
||||
res.append( "[/preproc_define]" ); //$NON-NLS-1$
|
||||
return res.toString( );
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the defines from the specified file
|
||||
* @param file
|
||||
* @return Returns a map of defines
|
||||
*/
|
||||
public static Map<String, Define> readDefines( String installName, String file )
|
||||
{
|
||||
DefinesSAXHandler handler = (DefinesSAXHandler) ResourceUtils.
|
||||
getWMLSAXHandlerFromResource( installName, file,
|
||||
new DefinesSAXHandler( ) );
|
||||
/**
|
||||
* Reads the defines from the specified file
|
||||
*
|
||||
* @param file
|
||||
* @return Returns a map of defines
|
||||
*/
|
||||
public static Map< String, Define > readDefines( String installName,
|
||||
String file )
|
||||
{
|
||||
DefinesSAXHandler handler = ( DefinesSAXHandler ) ResourceUtils
|
||||
.getWMLSAXHandlerFromResource( installName, file,
|
||||
new DefinesSAXHandler( ) );
|
||||
|
||||
if (handler != null){
|
||||
Logger.getInstance().log("loaded " + handler.getDefines().size() + " defines for file:" + file); //$NON-NLS-1$ //$NON-NLS-1$ //$NON-NLS-2$
|
||||
return handler.getDefines();
|
||||
}
|
||||
if( handler != null ) {
|
||||
Logger.getInstance( )
|
||||
.log( "loaded " + handler.getDefines( ).size( ) + " defines for file:" + file ); //$NON-NLS-1$ //$NON-NLS-1$ //$NON-NLS-2$
|
||||
return handler.getDefines( );
|
||||
}
|
||||
|
||||
Logger.getInstance().log("There was an error on creating the Defines SAX handler"); //$NON-NLS-1$
|
||||
return new HashMap<String, Define>(0);
|
||||
}
|
||||
Logger.getInstance( ).log(
|
||||
"There was an error on creating the Defines SAX handler" ); //$NON-NLS-1$
|
||||
return new HashMap< String, Define >( 0 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,107 +23,107 @@ import org.xml.sax.helpers.DefaultHandler;
|
|||
*/
|
||||
public class DefinesSAXHandler extends DefaultHandler
|
||||
{
|
||||
private Stack<String> stack_;
|
||||
private Map<String, Define> defines_;
|
||||
private Stack< String > stack_;
|
||||
private Map< String, Define > defines_;
|
||||
|
||||
// indexes for different define properties
|
||||
private String name_;
|
||||
private String value_;
|
||||
private String textdomain_;
|
||||
private int linenum_;
|
||||
private String location_;
|
||||
private List<String> arguments_;
|
||||
// indexes for different define properties
|
||||
private String name_;
|
||||
private String value_;
|
||||
private String textdomain_;
|
||||
private int linenum_;
|
||||
private String location_;
|
||||
private List< String > arguments_;
|
||||
|
||||
public DefinesSAXHandler()
|
||||
{
|
||||
stack_ = new Stack<String>();
|
||||
defines_ = new HashMap<String, Define>();
|
||||
arguments_ = new ArrayList<String>();
|
||||
}
|
||||
public DefinesSAXHandler( )
|
||||
{
|
||||
stack_ = new Stack< String >( );
|
||||
defines_ = new HashMap< String, Define >( );
|
||||
arguments_ = new ArrayList< String >( );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startElement(String uri, String localName, String qName,
|
||||
Attributes attributes) throws SAXException
|
||||
{
|
||||
super.startElement(uri, localName, qName, attributes);
|
||||
stack_.push(qName);
|
||||
}
|
||||
@Override
|
||||
public void startElement( String uri, String localName, String qName,
|
||||
Attributes attributes ) throws SAXException
|
||||
{
|
||||
super.startElement( uri, localName, qName, attributes );
|
||||
stack_.push( qName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endElement(String uri, String localName, String qName)
|
||||
throws SAXException
|
||||
{
|
||||
super.endElement(uri, localName, qName);
|
||||
stack_.pop();
|
||||
@Override
|
||||
public void endElement( String uri, String localName, String qName )
|
||||
throws SAXException
|
||||
{
|
||||
super.endElement( uri, localName, qName );
|
||||
stack_.pop( );
|
||||
|
||||
if (qName.equals("preproc_define")) //$NON-NLS-1$
|
||||
{
|
||||
// create the define
|
||||
defines_.put(name_, new Define(name_, value_, textdomain_,
|
||||
linenum_, location_, arguments_));
|
||||
// reset values
|
||||
resetValues();
|
||||
}
|
||||
}
|
||||
if( qName.equals( "preproc_define" ) ) //$NON-NLS-1$
|
||||
{
|
||||
// create the define
|
||||
defines_.put( name_, new Define( name_, value_, textdomain_,
|
||||
linenum_, location_, arguments_ ) );
|
||||
// reset values
|
||||
resetValues( );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void characters(char[] ch, int start, int length)
|
||||
throws SAXException
|
||||
{
|
||||
super.characters(ch, start, length);
|
||||
if (stack_.isEmpty())
|
||||
return;
|
||||
String element = stack_.peek();
|
||||
@Override
|
||||
public void characters( char[] ch, int start, int length )
|
||||
throws SAXException
|
||||
{
|
||||
super.characters( ch, start, length );
|
||||
if( stack_.isEmpty( ) )
|
||||
return;
|
||||
String element = stack_.peek( );
|
||||
|
||||
if (element.equals("name")) //$NON-NLS-1$
|
||||
{
|
||||
// we have name at: 1 - preproc_define, 2 - argument
|
||||
if (stack_.get(stack_.size() - 2).equals("argument")) //$NON-NLS-1$
|
||||
{
|
||||
arguments_.add(new String(ch, start, length));
|
||||
}
|
||||
else
|
||||
{
|
||||
name_ = new String(ch, start, length);
|
||||
}
|
||||
}
|
||||
else if (element.equals("value")) //$NON-NLS-1$
|
||||
{
|
||||
value_ = new String(ch, start, length);
|
||||
}
|
||||
else if (element.equals("textdomain")) //$NON-NLS-1$
|
||||
{
|
||||
textdomain_ = new String(ch, start, length);
|
||||
}
|
||||
else if (element.equals("linenum")) //$NON-NLS-1$
|
||||
{
|
||||
linenum_ = Integer.valueOf(new String(ch, start, length));
|
||||
}
|
||||
else if (element.equals("location")) //$NON-NLS-1$
|
||||
{
|
||||
location_ = new String(ch, start, length);
|
||||
}
|
||||
}
|
||||
if( element.equals( "name" ) ) //$NON-NLS-1$
|
||||
{
|
||||
// we have name at: 1 - preproc_define, 2 - argument
|
||||
if( stack_.get( stack_.size( ) - 2 ).equals( "argument" ) ) //$NON-NLS-1$
|
||||
{
|
||||
arguments_.add( new String( ch, start, length ) );
|
||||
}
|
||||
else {
|
||||
name_ = new String( ch, start, length );
|
||||
}
|
||||
}
|
||||
else if( element.equals( "value" ) ) //$NON-NLS-1$
|
||||
{
|
||||
value_ = new String( ch, start, length );
|
||||
}
|
||||
else if( element.equals( "textdomain" ) ) //$NON-NLS-1$
|
||||
{
|
||||
textdomain_ = new String( ch, start, length );
|
||||
}
|
||||
else if( element.equals( "linenum" ) ) //$NON-NLS-1$
|
||||
{
|
||||
linenum_ = Integer.valueOf( new String( ch, start, length ) );
|
||||
}
|
||||
else if( element.equals( "location" ) ) //$NON-NLS-1$
|
||||
{
|
||||
location_ = new String( ch, start, length );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* resets indexes for to be used by the next define
|
||||
*/
|
||||
private void resetValues()
|
||||
{
|
||||
name_ = ""; //$NON-NLS-1$
|
||||
value_ = ""; //$NON-NLS-1$
|
||||
linenum_ = 0;
|
||||
location_ = ""; //$NON-NLS-1$
|
||||
textdomain_ = ""; //$NON-NLS-1$
|
||||
arguments_ = new ArrayList<String>();
|
||||
}
|
||||
/**
|
||||
* resets indexes for to be used by the next define
|
||||
*/
|
||||
private void resetValues( )
|
||||
{
|
||||
name_ = ""; //$NON-NLS-1$
|
||||
value_ = ""; //$NON-NLS-1$
|
||||
linenum_ = 0;
|
||||
location_ = ""; //$NON-NLS-1$
|
||||
textdomain_ = ""; //$NON-NLS-1$
|
||||
arguments_ = new ArrayList< String >( );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the map of defines parsed
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Define> getDefines()
|
||||
{
|
||||
return defines_;
|
||||
}
|
||||
/**
|
||||
* Gets the map of defines parsed
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map< String, Define > getDefines( )
|
||||
{
|
||||
return defines_;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.eclipse.core.resources.IResource;
|
|||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.jface.dialogs.DialogSettings;
|
||||
|
||||
import org.wesnoth.Constants;
|
||||
import org.wesnoth.Logger;
|
||||
import org.wesnoth.Messages;
|
||||
|
@ -38,284 +39,314 @@ import org.wesnoth.utils.WorkspaceUtils;
|
|||
|
||||
public class PreprocessorUtils
|
||||
{
|
||||
private static class PreprocessorUtilsInstance{
|
||||
private static class PreprocessorUtilsInstance
|
||||
{
|
||||
private static PreprocessorUtils instance_ = new PreprocessorUtils( );
|
||||
}
|
||||
|
||||
private Map<String, Long> filesTimeStamps_ = new HashMap<String, Long>();
|
||||
private Map< String, Long > filesTimeStamps_ = new HashMap< String, Long >( );
|
||||
|
||||
private PreprocessorUtils()
|
||||
{
|
||||
filesTimeStamps_ = new HashMap<String, Long>();
|
||||
restoreTimestamps();
|
||||
}
|
||||
private PreprocessorUtils( )
|
||||
{
|
||||
filesTimeStamps_ = new HashMap< String, Long >( );
|
||||
restoreTimestamps( );
|
||||
}
|
||||
|
||||
public static PreprocessorUtils getInstance()
|
||||
{
|
||||
return PreprocessorUtilsInstance.instance_;
|
||||
}
|
||||
public static PreprocessorUtils getInstance( )
|
||||
{
|
||||
return PreprocessorUtilsInstance.instance_;
|
||||
}
|
||||
|
||||
/**
|
||||
* preprocesses a file using the wesnoth's executable, only
|
||||
* if the file was modified since last time checked.
|
||||
* The target directory is the temporary directory + files's path relative to project
|
||||
* @param file the file to process
|
||||
* @param defines the list of additional defines to be added when preprocessing the file
|
||||
* @return
|
||||
*/
|
||||
public int preprocessFile(IFile file, List<String> defines)
|
||||
{
|
||||
return preprocessFile(file, getTemporaryLocation(file),
|
||||
getTemporaryLocation(file) + "/_MACROS_.cfg", defines, true); //$NON-NLS-1$
|
||||
}
|
||||
/**
|
||||
* preprocesses a file using the wesnoth's executable, only
|
||||
* if the file was modified since last time checked.
|
||||
* The target directory is the temporary directory + files's path relative
|
||||
* to project
|
||||
*
|
||||
* @param file
|
||||
* the file to process
|
||||
* @param defines
|
||||
* the list of additional defines to be added when preprocessing
|
||||
* the file
|
||||
* @return
|
||||
*/
|
||||
public int preprocessFile( IFile file, List< String > defines )
|
||||
{
|
||||
return preprocessFile( file, getTemporaryLocation( file ),
|
||||
getTemporaryLocation( file ) + "/_MACROS_.cfg", defines, true ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* preprocesses a file using the wesnoth's executable, only
|
||||
* if the file was modified since last time checked.
|
||||
* The target directory is the temporary directory + files's path relative to project
|
||||
* @param file the file to process
|
||||
* @param macrosFile The file where macros are stored
|
||||
* @param defines the list of additional defines to be added when preprocessing the file
|
||||
* @return
|
||||
*/
|
||||
public int preprocessFile(IFile file, String macrosFile, List<String> defines)
|
||||
{
|
||||
return preprocessFile(file, getTemporaryLocation(file), macrosFile, defines, true);
|
||||
}
|
||||
/**
|
||||
* preprocesses a file using the wesnoth's executable, only
|
||||
* if the file was modified since last time checked.
|
||||
* The target directory is the temporary directory + files's path relative
|
||||
* to project
|
||||
*
|
||||
* @param file
|
||||
* the file to process
|
||||
* @param macrosFile
|
||||
* The file where macros are stored
|
||||
* @param defines
|
||||
* the list of additional defines to be added when preprocessing
|
||||
* the file
|
||||
* @return
|
||||
*/
|
||||
public int preprocessFile( IFile file, String macrosFile,
|
||||
List< String > defines )
|
||||
{
|
||||
return preprocessFile( file, getTemporaryLocation( file ), macrosFile,
|
||||
defines, true );
|
||||
}
|
||||
|
||||
/**
|
||||
* preprocesses a file using the wesnoth's executable, only
|
||||
* if the file was modified since last time checked.
|
||||
* @param file the file to process
|
||||
* @param targetDirectory target directory where should be put the results
|
||||
* @param macrosFile The file where macros are stored
|
||||
* @param defines the list of additional defines to be added when preprocessing the file
|
||||
* @param waitForIt true to wait for the preprocessing to finish
|
||||
* @return
|
||||
* -1 - we skipped preprocessing - file was already preprocessed
|
||||
* 0 - preprocessed succesfully
|
||||
* 1 - there was an error
|
||||
*/
|
||||
public int preprocessFile(IFile file, String targetDirectory,
|
||||
String macrosFile, List<String> defines, boolean waitForIt)
|
||||
{
|
||||
String filePath = file.getLocation().toOSString();
|
||||
if (filesTimeStamps_.containsKey(filePath) &&
|
||||
filesTimeStamps_.get(filePath) >= new File(filePath).lastModified())
|
||||
{
|
||||
Logger.getInstance().logTool("skipped preprocessing a non-modified file: " + filePath); //$NON-NLS-1$
|
||||
return -1;
|
||||
}
|
||||
/**
|
||||
* preprocesses a file using the wesnoth's executable, only
|
||||
* if the file was modified since last time checked.
|
||||
*
|
||||
* @param file
|
||||
* the file to process
|
||||
* @param targetDirectory
|
||||
* target directory where should be put the results
|
||||
* @param macrosFile
|
||||
* The file where macros are stored
|
||||
* @param defines
|
||||
* the list of additional defines to be added when preprocessing
|
||||
* the file
|
||||
* @param waitForIt
|
||||
* true to wait for the preprocessing to finish
|
||||
* @return
|
||||
* -1 - we skipped preprocessing - file was already preprocessed
|
||||
* 0 - preprocessed succesfully
|
||||
* 1 - there was an error
|
||||
*/
|
||||
public int preprocessFile( IFile file, String targetDirectory,
|
||||
String macrosFile, List< String > defines, boolean waitForIt )
|
||||
{
|
||||
String filePath = file.getLocation( ).toOSString( );
|
||||
if( filesTimeStamps_.containsKey( filePath )
|
||||
&& filesTimeStamps_.get( filePath ) >= new File( filePath )
|
||||
.lastModified( ) ) {
|
||||
Logger.getInstance( ).logTool(
|
||||
"skipped preprocessing a non-modified file: " + filePath ); //$NON-NLS-1$
|
||||
return - 1;
|
||||
}
|
||||
|
||||
filesTimeStamps_.put(filePath, new File(filePath).lastModified());
|
||||
filesTimeStamps_.put( filePath, new File( filePath ).lastModified( ) );
|
||||
|
||||
try{
|
||||
try {
|
||||
|
||||
Paths paths = Preferences.getPaths(
|
||||
ProjectUtils.getCacheForProject( file.getProject( ) ).getInstallName( ) );
|
||||
Paths paths = Preferences
|
||||
.getPaths( ProjectUtils.getCacheForProject(
|
||||
file.getProject( ) ).getInstallName( ) );
|
||||
|
||||
List<String> arguments = new ArrayList<String>();
|
||||
List< String > arguments = new ArrayList< String >( );
|
||||
|
||||
arguments.add( "--config-dir" ); //$NON-NLS-1$
|
||||
arguments.add( paths.getUserDir( ) );
|
||||
arguments.add( "--config-dir" ); //$NON-NLS-1$
|
||||
arguments.add( paths.getUserDir( ) );
|
||||
|
||||
arguments.add( "--data-dir" ); //$NON-NLS-1$
|
||||
arguments.add( paths.getWorkingDir( ) );
|
||||
arguments.add( "--data-dir" ); //$NON-NLS-1$
|
||||
arguments.add( paths.getWorkingDir( ) );
|
||||
|
||||
if (macrosFile != null && macrosFile.isEmpty() == false)
|
||||
{
|
||||
ResourceUtils.createNewFile(macrosFile);
|
||||
if( macrosFile != null && macrosFile.isEmpty( ) == false ) {
|
||||
ResourceUtils.createNewFile( macrosFile );
|
||||
|
||||
// add the _MACROS_.cfg file
|
||||
arguments.add("--preprocess-input-macros"); //$NON-NLS-1$
|
||||
arguments.add(macrosFile);
|
||||
// add the _MACROS_.cfg file
|
||||
arguments.add( "--preprocess-input-macros" ); //$NON-NLS-1$
|
||||
arguments.add( macrosFile );
|
||||
|
||||
|
||||
arguments.add("--preprocess-output-macros"); //$NON-NLS-1$
|
||||
arguments.add(macrosFile);
|
||||
}
|
||||
arguments.add( "--preprocess-output-macros" ); //$NON-NLS-1$
|
||||
arguments.add( macrosFile );
|
||||
}
|
||||
|
||||
if (Preferences.getBool(Constants.P_NO_TERRAIN_GFX))
|
||||
{
|
||||
if (defines == null)
|
||||
defines = new ArrayList<String>();
|
||||
defines.add("NO_TERRAIN_GFX"); //$NON-NLS-1$
|
||||
}
|
||||
if( Preferences.getBool( Constants.P_NO_TERRAIN_GFX ) ) {
|
||||
if( defines == null )
|
||||
defines = new ArrayList< String >( );
|
||||
defines.add( "NO_TERRAIN_GFX" ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
// --preprocess
|
||||
arguments.add("-p"); //$NON-NLS-1$
|
||||
arguments.add(filePath);
|
||||
arguments.add(targetDirectory);
|
||||
// --preprocess
|
||||
arguments.add( "-p" ); //$NON-NLS-1$
|
||||
arguments.add( filePath );
|
||||
arguments.add( targetDirectory );
|
||||
|
||||
// --preprocess-defines
|
||||
if (defines != null && !defines.isEmpty())
|
||||
{
|
||||
arguments.add( "--preprocess-defines" ); //$NON-NLS-1$
|
||||
if( defines != null && ! defines.isEmpty( ) ) {
|
||||
arguments.add( "--preprocess-defines" ); //$NON-NLS-1$
|
||||
|
||||
StringBuilder definesArg = new StringBuilder();
|
||||
for( Iterator<String> itor = defines.iterator(); itor.hasNext(); )
|
||||
{
|
||||
if ( definesArg.length() > 0 )
|
||||
definesArg.append( "," ); //$NON-NLS-1$
|
||||
StringBuilder definesArg = new StringBuilder( );
|
||||
for( Iterator< String > itor = defines.iterator( ); itor
|
||||
.hasNext( ); ) {
|
||||
if( definesArg.length( ) > 0 )
|
||||
definesArg.append( "," ); //$NON-NLS-1$
|
||||
|
||||
definesArg.append( itor.next() );
|
||||
}
|
||||
definesArg.append( itor.next( ) );
|
||||
}
|
||||
|
||||
arguments.add( definesArg.toString() );
|
||||
}
|
||||
arguments.add( definesArg.toString( ) );
|
||||
}
|
||||
|
||||
Logger.getInstance().logTool("preprocessing file: " + filePath); //$NON-NLS-1$
|
||||
ExternalToolInvoker wesnoth = new ExternalToolInvoker(
|
||||
paths.getWesnothExecutablePath( ),
|
||||
arguments);
|
||||
wesnoth.runTool();
|
||||
if (waitForIt)
|
||||
return wesnoth.waitForTool();
|
||||
return 0;
|
||||
}
|
||||
catch (Exception e) {
|
||||
Logger.getInstance().logException(e);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
Logger.getInstance( ).logTool( "preprocessing file: " + filePath ); //$NON-NLS-1$
|
||||
ExternalToolInvoker wesnoth = new ExternalToolInvoker(
|
||||
paths.getWesnothExecutablePath( ), arguments );
|
||||
wesnoth.runTool( );
|
||||
if( waitForIt )
|
||||
return wesnoth.waitForTool( );
|
||||
return 0;
|
||||
} catch( Exception e ) {
|
||||
Logger.getInstance( ).logException( e );
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the preprocessed version of the specified file
|
||||
* @param file the file to show preprocessed output
|
||||
* @param openPlain true if it should open the plain preprocessed version
|
||||
* or false for the normal one
|
||||
*/
|
||||
public void openPreprocessedFileInEditor(IFile file, boolean openPlain)
|
||||
{
|
||||
if (file == null || !file.exists())
|
||||
{
|
||||
Logger.getInstance().log("file null or non existent.", //$NON-NLS-1$
|
||||
Messages.PreprocessorUtils_12);
|
||||
return;
|
||||
}
|
||||
EditorUtils.openEditor(getPreprocessedFilePath(file, openPlain, true));
|
||||
}
|
||||
/**
|
||||
* Opens the preprocessed version of the specified file
|
||||
*
|
||||
* @param file
|
||||
* the file to show preprocessed output
|
||||
* @param openPlain
|
||||
* true if it should open the plain preprocessed version
|
||||
* or false for the normal one
|
||||
*/
|
||||
public void openPreprocessedFileInEditor( IFile file, boolean openPlain )
|
||||
{
|
||||
if( file == null || ! file.exists( ) ) {
|
||||
Logger.getInstance( ).log( "file null or non existent.", //$NON-NLS-1$
|
||||
Messages.PreprocessorUtils_12 );
|
||||
return;
|
||||
}
|
||||
EditorUtils
|
||||
.openEditor( getPreprocessedFilePath( file, openPlain, true ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path of the preprocessed file of the specified file
|
||||
* @param file The file whom preprocessed file to get
|
||||
* @param plain True to return the plain version file's file
|
||||
* @param create if this is true, if the target preprocessed file
|
||||
* doesn't exist it will be created.
|
||||
* @return
|
||||
*/
|
||||
public IFileStore getPreprocessedFilePath(IFile file, boolean plain,
|
||||
boolean create)
|
||||
{
|
||||
IFileStore preprocFile =
|
||||
EFS.getLocalFileSystem().getStore(new Path(getTemporaryLocation(file)));
|
||||
preprocFile = preprocFile.getChild(file.getName() + (plain == true? ".plain" : "") ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
if (create && !preprocFile.fetchInfo().exists())
|
||||
preprocessFile(file, null);
|
||||
return preprocFile;
|
||||
}
|
||||
/**
|
||||
* Returns the path of the preprocessed file of the specified file
|
||||
*
|
||||
* @param file
|
||||
* The file whom preprocessed file to get
|
||||
* @param plain
|
||||
* True to return the plain version file's file
|
||||
* @param create
|
||||
* if this is true, if the target preprocessed file
|
||||
* doesn't exist it will be created.
|
||||
* @return
|
||||
*/
|
||||
public IFileStore getPreprocessedFilePath( IFile file, boolean plain,
|
||||
boolean create )
|
||||
{
|
||||
IFileStore preprocFile = EFS.getLocalFileSystem( ).getStore(
|
||||
new Path( getTemporaryLocation( file ) ) );
|
||||
preprocFile = preprocFile.getChild( file.getName( )
|
||||
+ ( plain == true ? ".plain": "" ) ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
if( create && ! preprocFile.fetchInfo( ).exists( ) )
|
||||
preprocessFile( file, null );
|
||||
return preprocFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the temporary location where that file should be preprocessed
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
public String getTemporaryLocation(IFile file)
|
||||
{
|
||||
String targetDirectory = WorkspaceUtils.getTemporaryFolder();
|
||||
targetDirectory += file.getProject().getName() + "/"; //$NON-NLS-1$
|
||||
targetDirectory += file.getParent().getProjectRelativePath().toOSString() + "/"; //$NON-NLS-1$
|
||||
return targetDirectory;
|
||||
}
|
||||
/**
|
||||
* Gets the temporary location where that file should be preprocessed
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
public String getTemporaryLocation( IFile file )
|
||||
{
|
||||
String targetDirectory = WorkspaceUtils.getTemporaryFolder( );
|
||||
targetDirectory += file.getProject( ).getName( ) + "/"; //$NON-NLS-1$
|
||||
targetDirectory += file.getParent( ).getProjectRelativePath( )
|
||||
.toOSString( )
|
||||
+ "/"; //$NON-NLS-1$
|
||||
return targetDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the location where the '_MACROS_.cfg' file is for the
|
||||
* specified resource.
|
||||
*
|
||||
* Currently we store just a defines file per project.
|
||||
* @param resource The resource to get the location for
|
||||
* @return A string that points to the macros file.
|
||||
*/
|
||||
public String getMacrosLocation(IResource resource)
|
||||
{
|
||||
return WorkspaceUtils.getProjectTemporaryFolder( resource.getProject( ) ) +
|
||||
"/_MACROS_.cfg"; //$NON-NLS-1$
|
||||
}
|
||||
/**
|
||||
* Gets the location where the '_MACROS_.cfg' file is for the
|
||||
* specified resource.
|
||||
*
|
||||
* Currently we store just a defines file per project.
|
||||
*
|
||||
* @param resource
|
||||
* The resource to get the location for
|
||||
* @return A string that points to the macros file.
|
||||
*/
|
||||
public String getMacrosLocation( IResource resource )
|
||||
{
|
||||
return WorkspaceUtils
|
||||
.getProjectTemporaryFolder( resource.getProject( ) )
|
||||
+ "/_MACROS_.cfg"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the current timestamps for preprocessed files
|
||||
* to filesystem
|
||||
*/
|
||||
public void saveTimestamps()
|
||||
{
|
||||
String filename = WorkspaceUtils.getTemporaryFolder( ) + "preprocessed.txt"; //$NON-NLS-1$
|
||||
DialogSettings settings = new DialogSettings("preprocessed"); //$NON-NLS-1$
|
||||
try
|
||||
{
|
||||
settings.put("files", filesTimeStamps_.keySet().toArray(new String[0])); //$NON-NLS-1$
|
||||
List<String> timestamps = new ArrayList<String>();
|
||||
for(Long timestamp : filesTimeStamps_.values())
|
||||
{
|
||||
timestamps.add(timestamp.toString());
|
||||
}
|
||||
settings.put("timestamps", timestamps.toArray(new String[timestamps.size( )])); //$NON-NLS-1$
|
||||
settings.save(filename);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.getInstance().logException(e);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Saves the current timestamps for preprocessed files
|
||||
* to filesystem
|
||||
*/
|
||||
public void saveTimestamps( )
|
||||
{
|
||||
String filename = WorkspaceUtils.getTemporaryFolder( )
|
||||
+ "preprocessed.txt"; //$NON-NLS-1$
|
||||
DialogSettings settings = new DialogSettings( "preprocessed" ); //$NON-NLS-1$
|
||||
try {
|
||||
settings.put(
|
||||
"files", filesTimeStamps_.keySet( ).toArray( new String[0] ) ); //$NON-NLS-1$
|
||||
List< String > timestamps = new ArrayList< String >( );
|
||||
for( Long timestamp: filesTimeStamps_.values( ) ) {
|
||||
timestamps.add( timestamp.toString( ) );
|
||||
}
|
||||
settings.put(
|
||||
"timestamps", timestamps.toArray( new String[timestamps.size( )] ) ); //$NON-NLS-1$
|
||||
settings.save( filename );
|
||||
} catch( Exception e ) {
|
||||
Logger.getInstance( ).logException( e );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Restores the timestamps for preprocessed files from
|
||||
* the filesystem
|
||||
*/
|
||||
public void restoreTimestamps()
|
||||
{
|
||||
IPath path = WesnothPlugin.getDefault().getStateLocation();
|
||||
String filename = path.append("preprocessed.txt").toOSString(); //$NON-NLS-1$
|
||||
DialogSettings settings = new DialogSettings("preprocessed"); //$NON-NLS-1$
|
||||
filesTimeStamps_.clear();
|
||||
/**
|
||||
* Restores the timestamps for preprocessed files from
|
||||
* the filesystem
|
||||
*/
|
||||
public void restoreTimestamps( )
|
||||
{
|
||||
IPath path = WesnothPlugin.getDefault( ).getStateLocation( );
|
||||
String filename = path.append( "preprocessed.txt" ).toOSString( ); //$NON-NLS-1$
|
||||
DialogSettings settings = new DialogSettings( "preprocessed" ); //$NON-NLS-1$
|
||||
filesTimeStamps_.clear( );
|
||||
|
||||
try
|
||||
{
|
||||
// ensure the creation of a valid file if it doesn't exist
|
||||
if (new File(filename).exists() == false)
|
||||
settings.save(filename);
|
||||
try {
|
||||
// ensure the creation of a valid file if it doesn't exist
|
||||
if( new File( filename ).exists( ) == false )
|
||||
settings.save( filename );
|
||||
|
||||
settings.load(filename);
|
||||
String[] timestamps = settings.getArray("timestamps"); //$NON-NLS-1$
|
||||
String[] files = settings.getArray("files"); //$NON-NLS-1$
|
||||
if (timestamps != null && files != null &&
|
||||
timestamps.length == files.length)
|
||||
{
|
||||
for(int index = 0 ;index < files.length; ++index)
|
||||
{
|
||||
filesTimeStamps_.put(files[index], Long.valueOf(timestamps[index]));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
Logger.getInstance().logException(e);
|
||||
}
|
||||
}
|
||||
settings.load( filename );
|
||||
String[] timestamps = settings.getArray( "timestamps" ); //$NON-NLS-1$
|
||||
String[] files = settings.getArray( "files" ); //$NON-NLS-1$
|
||||
if( timestamps != null && files != null
|
||||
&& timestamps.length == files.length ) {
|
||||
for( int index = 0; index < files.length; ++index ) {
|
||||
filesTimeStamps_.put( files[index],
|
||||
Long.valueOf( timestamps[index] ) );
|
||||
}
|
||||
}
|
||||
} catch( IOException e ) {
|
||||
Logger.getInstance( ).logException( e );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all timestamps cached for files that are located in that path
|
||||
* @param path The path to match the files to clear their timestamp
|
||||
*/
|
||||
public void clearTimestampsForPath( String path )
|
||||
{
|
||||
Iterator<Entry<String, Long>> itor = filesTimeStamps_.entrySet( ).iterator( );
|
||||
/**
|
||||
* Clears all timestamps cached for files that are located in that path
|
||||
*
|
||||
* @param path
|
||||
* The path to match the files to clear their timestamp
|
||||
*/
|
||||
public void clearTimestampsForPath( String path )
|
||||
{
|
||||
Iterator< Entry< String, Long >> itor = filesTimeStamps_.entrySet( )
|
||||
.iterator( );
|
||||
|
||||
while ( itor.hasNext( ) ) {
|
||||
Entry<String, Long> entry = itor.next( );
|
||||
if ( entry.getKey( ).startsWith( path ) )
|
||||
itor.remove( );
|
||||
}
|
||||
while( itor.hasNext( ) ) {
|
||||
Entry< String, Long > entry = itor.next( );
|
||||
if( entry.getKey( ).startsWith( path ) )
|
||||
itor.remove( );
|
||||
}
|
||||
|
||||
saveTimestamps( );
|
||||
}
|
||||
saveTimestamps( );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,70 +17,67 @@ import org.eclipse.ui.IStartup;
|
|||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
import org.wesnoth.Messages;
|
||||
|
||||
public class ActionWiper implements IStartup, IPerspectiveListener
|
||||
{
|
||||
private static final String[] ACTIONS_2_WIPE = new String[] {
|
||||
"org.eclipse.search.searchActionSet", //$NON-NLS-1$
|
||||
"org.eclipse.debug.ui.breakpointActionSet", //$NON-NLS-1$
|
||||
"org.eclipse.debug.ui.debugActionSet", //$NON-NLS-1$
|
||||
"org.eclipse.debug.ui.launchActionSet", //$NON-NLS-1$
|
||||
"org.eclipse.debug.ui.profileActionSet", //$NON-NLS-1$
|
||||
"org.eclipse.ui.externaltools.ExternalToolsSet" //$NON-NLS-1$
|
||||
// "org.eclipse.ui.edit.text.actionSet.presentation",
|
||||
// "org.eclipse.ui.edit.text.actionSet.openExternalFile",
|
||||
// "org.eclipse.ui.edit.text.actionSet.annotationNavigation",
|
||||
// "org.eclipse.ui.edit.text.actionSet.navigation",
|
||||
// "org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo",
|
||||
// "org.eclipse.update.ui.softwareUpdates"
|
||||
};
|
||||
private static final String[] ACTIONS_2_WIPE = new String[] {
|
||||
"org.eclipse.search.searchActionSet", //$NON-NLS-1$
|
||||
"org.eclipse.debug.ui.breakpointActionSet", //$NON-NLS-1$
|
||||
"org.eclipse.debug.ui.debugActionSet", //$NON-NLS-1$
|
||||
"org.eclipse.debug.ui.launchActionSet", //$NON-NLS-1$
|
||||
"org.eclipse.debug.ui.profileActionSet", //$NON-NLS-1$
|
||||
"org.eclipse.ui.externaltools.ExternalToolsSet" //$NON-NLS-1$
|
||||
// "org.eclipse.ui.edit.text.actionSet.presentation",
|
||||
// "org.eclipse.ui.edit.text.actionSet.openExternalFile",
|
||||
// "org.eclipse.ui.edit.text.actionSet.annotationNavigation",
|
||||
// "org.eclipse.ui.edit.text.actionSet.navigation",
|
||||
// "org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo",
|
||||
// "org.eclipse.update.ui.softwareUpdates"
|
||||
};
|
||||
|
||||
public void earlyStartup()
|
||||
{
|
||||
IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
|
||||
for (int i = 0; i < windows.length; i++)
|
||||
{
|
||||
IWorkbenchPage page = windows[i].getActivePage();
|
||||
if (page != null)
|
||||
{
|
||||
wipeActions(page);
|
||||
}
|
||||
windows[i].addPerspectiveListener(this);
|
||||
}
|
||||
}
|
||||
public void earlyStartup( )
|
||||
{
|
||||
IWorkbenchWindow[] windows = PlatformUI.getWorkbench( )
|
||||
.getWorkbenchWindows( );
|
||||
for( int i = 0; i < windows.length; i++ ) {
|
||||
IWorkbenchPage page = windows[i].getActivePage( );
|
||||
if( page != null ) {
|
||||
wipeActions( page );
|
||||
}
|
||||
windows[i].addPerspectiveListener( this );
|
||||
}
|
||||
}
|
||||
|
||||
private void wipeActions(final IWorkbenchPage page)
|
||||
{
|
||||
Display.getDefault().syncExec(new Runnable() {
|
||||
public void run()
|
||||
{
|
||||
// remove the run menu
|
||||
Menu menu = page.getWorkbenchWindow().getShell().getMenuBar();
|
||||
for (MenuItem item : menu.getItems())
|
||||
{
|
||||
if (item.getText().equals(Messages.ActionWiper_6))
|
||||
{
|
||||
item.dispose();
|
||||
}
|
||||
}
|
||||
private void wipeActions( final IWorkbenchPage page )
|
||||
{
|
||||
Display.getDefault( ).syncExec( new Runnable( ) {
|
||||
public void run( )
|
||||
{
|
||||
// remove the run menu
|
||||
Menu menu = page.getWorkbenchWindow( ).getShell( ).getMenuBar( );
|
||||
for( MenuItem item: menu.getItems( ) ) {
|
||||
if( item.getText( ).equals( Messages.ActionWiper_6 ) ) {
|
||||
item.dispose( );
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < ACTIONS_2_WIPE.length; i++)
|
||||
{
|
||||
page.hideActionSet(ACTIONS_2_WIPE[i]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
for( int i = 0; i < ACTIONS_2_WIPE.length; i++ ) {
|
||||
page.hideActionSet( ACTIONS_2_WIPE[i] );
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
public void perspectiveActivated(IWorkbenchPage page,
|
||||
IPerspectiveDescriptor perspective)
|
||||
{
|
||||
wipeActions(page);
|
||||
}
|
||||
public void perspectiveActivated( IWorkbenchPage page,
|
||||
IPerspectiveDescriptor perspective )
|
||||
{
|
||||
wipeActions( page );
|
||||
}
|
||||
|
||||
public void perspectiveChanged(IWorkbenchPage page,
|
||||
IPerspectiveDescriptor perspective, String changeId)
|
||||
{
|
||||
}
|
||||
public void perspectiveChanged( IWorkbenchPage page,
|
||||
IPerspectiveDescriptor perspective, String changeId )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.eclipse.ui.IFolderLayout;
|
|||
import org.eclipse.ui.IPageLayout;
|
||||
import org.eclipse.ui.IPerspectiveFactory;
|
||||
import org.eclipse.ui.console.IConsoleConstants;
|
||||
|
||||
import org.wesnoth.views.AddonsView;
|
||||
import org.wesnoth.views.WesnothProjectsExplorer;
|
||||
|
||||
|
@ -20,31 +21,34 @@ public class WMLPerspective implements IPerspectiveFactory
|
|||
public static final String WMLPERSPECTIVE_ID = "org.wesnoth.product.WMLPerspective";
|
||||
|
||||
@Override
|
||||
public void createInitialLayout(IPageLayout layout)
|
||||
public void createInitialLayout( IPageLayout layout )
|
||||
{
|
||||
// Add "show views".
|
||||
layout.addShowViewShortcut(IPageLayout.ID_PROJECT_EXPLORER);
|
||||
layout.addShowViewShortcut(IPageLayout.ID_OUTLINE);
|
||||
layout.addShowViewShortcut(IPageLayout.ID_PROBLEM_VIEW);
|
||||
layout.addShowViewShortcut( IPageLayout.ID_PROJECT_EXPLORER );
|
||||
layout.addShowViewShortcut( IPageLayout.ID_OUTLINE );
|
||||
layout.addShowViewShortcut( IPageLayout.ID_PROBLEM_VIEW );
|
||||
layout.addShowViewShortcut( AddonsView.ID_ADDONS_VIEW );
|
||||
|
||||
// Editors are placed for free.
|
||||
String editorArea = layout.getEditorArea();
|
||||
layout.setEditorAreaVisible(true);
|
||||
String editorArea = layout.getEditorArea( );
|
||||
layout.setEditorAreaVisible( true );
|
||||
|
||||
// Place navigator and outline to left of editor area.
|
||||
IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT, (float) 0.26, editorArea); //$NON-NLS-1$
|
||||
left.addView(WesnothProjectsExplorer.ID_PROJECTS_EXPLORER);
|
||||
IFolderLayout left = layout.createFolder(
|
||||
"left", IPageLayout.LEFT, ( float ) 0.26, editorArea ); //$NON-NLS-1$
|
||||
left.addView( WesnothProjectsExplorer.ID_PROJECTS_EXPLORER );
|
||||
|
||||
IFolderLayout bottom = layout.createFolder("bottom", IPageLayout.BOTTOM, 0.76f, editorArea); //$NON-NLS-1$
|
||||
bottom.addView(IPageLayout.ID_PROBLEM_VIEW);
|
||||
bottom.addView(IPageLayout.ID_PROGRESS_VIEW);
|
||||
bottom.addView(IConsoleConstants.ID_CONSOLE_VIEW);
|
||||
IFolderLayout bottom = layout.createFolder(
|
||||
"bottom", IPageLayout.BOTTOM, 0.76f, editorArea ); //$NON-NLS-1$
|
||||
bottom.addView( IPageLayout.ID_PROBLEM_VIEW );
|
||||
bottom.addView( IPageLayout.ID_PROGRESS_VIEW );
|
||||
bottom.addView( IConsoleConstants.ID_CONSOLE_VIEW );
|
||||
bottom.addView( AddonsView.ID_ADDONS_VIEW );
|
||||
bottom.addView("org.eclipse.pde.runtime.LogView"); //$NON-NLS-1$
|
||||
bottom.addView( "org.eclipse.pde.runtime.LogView" ); //$NON-NLS-1$
|
||||
|
||||
IFolderLayout right = layout.createFolder("right", IPageLayout.RIGHT, 0.68f, editorArea); //$NON-NLS-1$
|
||||
right.addView(IPageLayout.ID_OUTLINE);
|
||||
IFolderLayout right = layout.createFolder(
|
||||
"right", IPageLayout.RIGHT, 0.68f, editorArea ); //$NON-NLS-1$
|
||||
right.addView( IPageLayout.ID_OUTLINE );
|
||||
|
||||
layout.addPerspectiveShortcut( WMLPERSPECTIVE_ID );
|
||||
|
||||
|
|
|
@ -15,18 +15,18 @@ import org.eclipse.ui.application.IActionBarConfigurer;
|
|||
public class WesnothActionBarAdvisor extends WorkbenchActionBuilder
|
||||
{
|
||||
|
||||
public WesnothActionBarAdvisor(IActionBarConfigurer configurer)
|
||||
{
|
||||
super(configurer);
|
||||
}
|
||||
public WesnothActionBarAdvisor( IActionBarConfigurer configurer )
|
||||
{
|
||||
super( configurer );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeActions(IWorkbenchWindow window)
|
||||
{
|
||||
super.makeActions( window );
|
||||
@Override
|
||||
protected void makeActions( IWorkbenchWindow window )
|
||||
{
|
||||
super.makeActions( window );
|
||||
|
||||
// add dynamic help hooks
|
||||
register( ActionFactory.HELP_SEARCH.create( window ) );
|
||||
register( ActionFactory.DYNAMIC_HELP.create( window ) );
|
||||
}
|
||||
}
|
||||
register( ActionFactory.HELP_SEARCH.create( window ) );
|
||||
register( ActionFactory.DYNAMIC_HELP.create( window ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,44 +13,45 @@ import org.eclipse.equinox.app.IApplicationContext;
|
|||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
import org.wesnoth.Logger;
|
||||
|
||||
public class WesnothApplication implements IApplication
|
||||
{
|
||||
@Override
|
||||
public Object start(IApplicationContext context)
|
||||
{
|
||||
Display display = PlatformUI.createDisplay();
|
||||
Logger.getInstance().startLogger();
|
||||
try {
|
||||
int returnCode = PlatformUI.createAndRunWorkbench(display, new WesnothWorkbenchAdvisor());
|
||||
if (returnCode == PlatformUI.RETURN_RESTART)
|
||||
return IApplication.EXIT_RESTART;
|
||||
else
|
||||
return IApplication.EXIT_OK;
|
||||
}
|
||||
catch(Exception e){
|
||||
Logger.getInstance().logException(e);
|
||||
return IApplication.EXIT_OK;
|
||||
}
|
||||
finally {
|
||||
display.dispose();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public Object start( IApplicationContext context )
|
||||
{
|
||||
Display display = PlatformUI.createDisplay( );
|
||||
Logger.getInstance( ).startLogger( );
|
||||
try {
|
||||
int returnCode = PlatformUI.createAndRunWorkbench( display,
|
||||
new WesnothWorkbenchAdvisor( ) );
|
||||
if( returnCode == PlatformUI.RETURN_RESTART )
|
||||
return IApplication.EXIT_RESTART;
|
||||
else
|
||||
return IApplication.EXIT_OK;
|
||||
} catch( Exception e ) {
|
||||
Logger.getInstance( ).logException( e );
|
||||
return IApplication.EXIT_OK;
|
||||
} finally {
|
||||
display.dispose( );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop()
|
||||
{
|
||||
if (!PlatformUI.isWorkbenchRunning())
|
||||
return;
|
||||
@Override
|
||||
public void stop( )
|
||||
{
|
||||
if( ! PlatformUI.isWorkbenchRunning( ) )
|
||||
return;
|
||||
|
||||
final IWorkbench workbench = PlatformUI.getWorkbench();
|
||||
final Display display = workbench.getDisplay();
|
||||
display.syncExec(new Runnable() {
|
||||
public void run() {
|
||||
if (!display.isDisposed())
|
||||
workbench.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
final IWorkbench workbench = PlatformUI.getWorkbench( );
|
||||
final Display display = workbench.getDisplay( );
|
||||
display.syncExec( new Runnable( ) {
|
||||
public void run( )
|
||||
{
|
||||
if( ! display.isDisposed( ) )
|
||||
workbench.close( );
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,41 +12,45 @@ import org.eclipse.core.runtime.IAdaptable;
|
|||
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
|
||||
import org.eclipse.ui.application.WorkbenchWindowAdvisor;
|
||||
import org.eclipse.ui.ide.IDE;
|
||||
|
||||
import org.wesnoth.utils.WorkspaceUtils;
|
||||
import org.wesnoth.views.WesnothProjectsExplorer;
|
||||
|
||||
public class WesnothWorkbenchAdvisor extends WorkbenchAdvisorHack {
|
||||
public class WesnothWorkbenchAdvisor extends WorkbenchAdvisorHack
|
||||
{
|
||||
|
||||
private static final String PERSPECTIVE_ID = "org.wesnoth.product.WMLPerspective"; //$NON-NLS-1$
|
||||
private static final String PERSPECTIVE_ID = "org.wesnoth.product.WMLPerspective"; //$NON-NLS-1$
|
||||
|
||||
@Override
|
||||
public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
|
||||
return new WesnothWorkbenchWindowAdvisor(configurer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInitialWindowPerspectiveId() {
|
||||
return PERSPECTIVE_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAdaptable getDefaultPageInput()
|
||||
public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
|
||||
IWorkbenchWindowConfigurer configurer )
|
||||
{
|
||||
return new WesnothProjectsExplorer();
|
||||
return new WesnothWorkbenchWindowAdvisor( configurer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preStartup()
|
||||
public String getInitialWindowPerspectiveId( )
|
||||
{
|
||||
IDE.registerAdapters();
|
||||
return PERSPECTIVE_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postStartup()
|
||||
{
|
||||
if (WorkspaceUtils.checkPathsAreSet( null, false ) == false)
|
||||
{
|
||||
WorkspaceUtils.setupWorkspace(true);
|
||||
public IAdaptable getDefaultPageInput( )
|
||||
{
|
||||
return new WesnothProjectsExplorer( );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preStartup( )
|
||||
{
|
||||
IDE.registerAdapters( );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postStartup( )
|
||||
{
|
||||
if( WorkspaceUtils.checkPathsAreSet( null, false ) == false ) {
|
||||
WorkspaceUtils.setupWorkspace( true );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,44 +15,51 @@ import org.eclipse.ui.application.ActionBarAdvisor;
|
|||
import org.eclipse.ui.application.IActionBarConfigurer;
|
||||
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
|
||||
import org.eclipse.ui.application.WorkbenchWindowAdvisor;
|
||||
|
||||
import org.wesnoth.Logger;
|
||||
|
||||
public class WesnothWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
|
||||
public class WesnothWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor
|
||||
{
|
||||
|
||||
public WesnothWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
|
||||
super(configurer);
|
||||
public WesnothWorkbenchWindowAdvisor( IWorkbenchWindowConfigurer configurer )
|
||||
{
|
||||
super( configurer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) {
|
||||
public ActionBarAdvisor createActionBarAdvisor(
|
||||
IActionBarConfigurer configurer )
|
||||
{
|
||||
return new WesnothActionBarAdvisor( configurer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preWindowOpen() {
|
||||
super.preWindowOpen();
|
||||
IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
|
||||
configurer.setShowMenuBar(true);
|
||||
configurer.setShowProgressIndicator(true);
|
||||
configurer.setShowStatusLine(true);
|
||||
configurer.setShowPerspectiveBar(true);
|
||||
configurer.setShowFastViewBars(true);
|
||||
configurer.setShowCoolBar(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postWindowCreate()
|
||||
public void preWindowOpen( )
|
||||
{
|
||||
getWindowConfigurer().getWindow().getActivePage().hideActionSet("org.eclipse.ui.run"); //$NON-NLS-1$
|
||||
super.preWindowOpen( );
|
||||
IWorkbenchWindowConfigurer configurer = getWindowConfigurer( );
|
||||
configurer.setShowMenuBar( true );
|
||||
configurer.setShowProgressIndicator( true );
|
||||
configurer.setShowStatusLine( true );
|
||||
configurer.setShowPerspectiveBar( true );
|
||||
configurer.setShowFastViewBars( true );
|
||||
configurer.setShowCoolBar( true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preWindowShellClose()
|
||||
public void postWindowCreate( )
|
||||
{
|
||||
getWindowConfigurer( ).getWindow( ).getActivePage( )
|
||||
.hideActionSet( "org.eclipse.ui.run" ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preWindowShellClose( )
|
||||
{
|
||||
try {
|
||||
ResourcesPlugin.getWorkspace( ).save( true , new NullProgressMonitor() );
|
||||
}
|
||||
catch ( CoreException e ) {
|
||||
ResourcesPlugin.getWorkspace( ).save( true,
|
||||
new NullProgressMonitor( ) );
|
||||
} catch( CoreException e ) {
|
||||
Logger.getInstance( ).logException( e );
|
||||
}
|
||||
return true;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2,6 +2,8 @@ package org.wesnoth.product;
|
|||
|
||||
import java.net.URL;
|
||||
|
||||
import org.osgi.framework.Bundle;
|
||||
|
||||
import org.eclipse.core.runtime.FileLocator;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
|
@ -11,22 +13,21 @@ import org.eclipse.ui.application.WorkbenchAdvisor;
|
|||
import org.eclipse.ui.ide.IDE;
|
||||
import org.eclipse.ui.internal.ide.IDEInternalWorkbenchImages;
|
||||
import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
|
||||
import org.osgi.framework.Bundle;
|
||||
|
||||
/**
|
||||
* Methods copied from {@link org.eclipse.ui.internal.ide.IDEWorkbenchAdvisor}
|
||||
*/
|
||||
@SuppressWarnings({ "all" })
|
||||
@SuppressWarnings( { "all" } )
|
||||
public abstract class WorkbenchAdvisorHack extends WorkbenchAdvisor
|
||||
{
|
||||
/**
|
||||
* Declares all IDE-specific workbench images. This includes both "shared"
|
||||
* images (named in {@link IDE.SharedImages}) and internal images (named in
|
||||
* {@link org.eclipse.ui.internal.ide.IDEInternalWorkbenchImages}).
|
||||
*
|
||||
*
|
||||
* @see org.eclipse.ui.internal.ide.IDEWorkbenchAdvisor#declareImage
|
||||
*/
|
||||
protected void declareWorkbenchImages()
|
||||
protected void declareWorkbenchImages( )
|
||||
{
|
||||
|
||||
final String ICONS_PATH = "$nl$/icons/full/";//$NON-NLS-1$
|
||||
|
@ -52,99 +53,100 @@ public abstract class WorkbenchAdvisorHack extends WorkbenchAdvisor
|
|||
// icons
|
||||
|
||||
// View icons
|
||||
final String PATH_EVIEW= ICONS_PATH + "eview16/"; //$NON-NLS-1$
|
||||
final String PATH_EVIEW = ICONS_PATH + "eview16/"; //$NON-NLS-1$
|
||||
|
||||
|
||||
Bundle ideBundle = Platform.getBundle(IDEWorkbenchPlugin.IDE_WORKBENCH);
|
||||
Bundle ideBundle = Platform
|
||||
.getBundle( IDEWorkbenchPlugin.IDE_WORKBENCH );
|
||||
|
||||
declareWorkbenchImage(ideBundle,
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC, PATH_ETOOL
|
||||
+ "build_exec.gif", false); //$NON-NLS-1$
|
||||
declareWorkbenchImage(ideBundle,
|
||||
+ "build_exec.gif", false ); //$NON-NLS-1$
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC_HOVER,
|
||||
PATH_ETOOL + "build_exec.gif", false); //$NON-NLS-1$
|
||||
declareWorkbenchImage(ideBundle,
|
||||
PATH_ETOOL + "build_exec.gif", false ); //$NON-NLS-1$
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC_DISABLED,
|
||||
PATH_DTOOL + "build_exec.gif", false); //$NON-NLS-1$
|
||||
PATH_DTOOL + "build_exec.gif", false ); //$NON-NLS-1$
|
||||
|
||||
declareWorkbenchImage(ideBundle,
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC, PATH_ETOOL
|
||||
+ "search_src.gif", false); //$NON-NLS-1$
|
||||
declareWorkbenchImage(ideBundle,
|
||||
+ "search_src.gif", false ); //$NON-NLS-1$
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC_HOVER,
|
||||
PATH_ETOOL + "search_src.gif", false); //$NON-NLS-1$
|
||||
declareWorkbenchImage(ideBundle,
|
||||
PATH_ETOOL + "search_src.gif", false ); //$NON-NLS-1$
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC_DISABLED,
|
||||
PATH_DTOOL + "search_src.gif", false); //$NON-NLS-1$
|
||||
PATH_DTOOL + "search_src.gif", false ); //$NON-NLS-1$
|
||||
|
||||
declareWorkbenchImage(ideBundle,
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_ETOOL_NEXT_NAV, PATH_ETOOL
|
||||
+ "next_nav.gif", false); //$NON-NLS-1$
|
||||
+ "next_nav.gif", false ); //$NON-NLS-1$
|
||||
|
||||
declareWorkbenchImage(ideBundle,
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_ETOOL_PREVIOUS_NAV, PATH_ETOOL
|
||||
+ "prev_nav.gif", false); //$NON-NLS-1$
|
||||
+ "prev_nav.gif", false ); //$NON-NLS-1$
|
||||
|
||||
declareWorkbenchImage(ideBundle,
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_WIZBAN_NEWPRJ_WIZ, PATH_WIZBAN
|
||||
+ "newprj_wiz.png", false); //$NON-NLS-1$
|
||||
declareWorkbenchImage(ideBundle,
|
||||
+ "newprj_wiz.png", false ); //$NON-NLS-1$
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_WIZBAN_NEWFOLDER_WIZ,
|
||||
PATH_WIZBAN + "newfolder_wiz.png", false); //$NON-NLS-1$
|
||||
declareWorkbenchImage(ideBundle,
|
||||
PATH_WIZBAN + "newfolder_wiz.png", false ); //$NON-NLS-1$
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_WIZBAN_NEWFILE_WIZ, PATH_WIZBAN
|
||||
+ "newfile_wiz.png", false); //$NON-NLS-1$
|
||||
+ "newfile_wiz.png", false ); //$NON-NLS-1$
|
||||
|
||||
declareWorkbenchImage(ideBundle,
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_WIZBAN_IMPORTDIR_WIZ,
|
||||
PATH_WIZBAN + "importdir_wiz.png", false); //$NON-NLS-1$
|
||||
declareWorkbenchImage(ideBundle,
|
||||
PATH_WIZBAN + "importdir_wiz.png", false ); //$NON-NLS-1$
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_WIZBAN_IMPORTZIP_WIZ,
|
||||
PATH_WIZBAN + "importzip_wiz.png", false); //$NON-NLS-1$
|
||||
PATH_WIZBAN + "importzip_wiz.png", false ); //$NON-NLS-1$
|
||||
|
||||
declareWorkbenchImage(ideBundle,
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_WIZBAN_EXPORTDIR_WIZ,
|
||||
PATH_WIZBAN + "exportdir_wiz.png", false); //$NON-NLS-1$
|
||||
declareWorkbenchImage(ideBundle,
|
||||
PATH_WIZBAN + "exportdir_wiz.png", false ); //$NON-NLS-1$
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_WIZBAN_EXPORTZIP_WIZ,
|
||||
PATH_WIZBAN + "exportzip_wiz.png", false); //$NON-NLS-1$
|
||||
PATH_WIZBAN + "exportzip_wiz.png", false ); //$NON-NLS-1$
|
||||
|
||||
declareWorkbenchImage(ideBundle,
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_WIZBAN_RESOURCEWORKINGSET_WIZ,
|
||||
PATH_WIZBAN + "workset_wiz.png", false); //$NON-NLS-1$
|
||||
PATH_WIZBAN + "workset_wiz.png", false ); //$NON-NLS-1$
|
||||
|
||||
declareWorkbenchImage(ideBundle,
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_DLGBAN_SAVEAS_DLG, PATH_WIZBAN
|
||||
+ "saveas_wiz.png", false); //$NON-NLS-1$
|
||||
+ "saveas_wiz.png", false ); //$NON-NLS-1$
|
||||
|
||||
declareWorkbenchImage(ideBundle,
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_DLGBAN_QUICKFIX_DLG, PATH_WIZBAN
|
||||
+ "quick_fix.png", false); //$NON-NLS-1$
|
||||
+ "quick_fix.png", false ); //$NON-NLS-1$
|
||||
|
||||
declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJ_PROJECT,
|
||||
PATH_OBJECT + "prj_obj.gif", true); //$NON-NLS-1$
|
||||
declareWorkbenchImage(ideBundle,
|
||||
declareWorkbenchImage( ideBundle, IDE.SharedImages.IMG_OBJ_PROJECT,
|
||||
PATH_OBJECT + "prj_obj.gif", true ); //$NON-NLS-1$
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED, PATH_OBJECT
|
||||
+ "cprj_obj.gif", true); //$NON-NLS-1$
|
||||
declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OPEN_MARKER,
|
||||
PATH_ELOCALTOOL + "gotoobj_tsk.gif", true); //$NON-NLS-1$
|
||||
+ "cprj_obj.gif", true ); //$NON-NLS-1$
|
||||
declareWorkbenchImage( ideBundle, IDE.SharedImages.IMG_OPEN_MARKER,
|
||||
PATH_ELOCALTOOL + "gotoobj_tsk.gif", true ); //$NON-NLS-1$
|
||||
|
||||
|
||||
// Quick fix icons
|
||||
declareWorkbenchImage(ideBundle,
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_ELCL_QUICK_FIX_ENABLED,
|
||||
PATH_ELOCALTOOL + "smartmode_co.gif", true); //$NON-NLS-1$
|
||||
PATH_ELOCALTOOL + "smartmode_co.gif", true ); //$NON-NLS-1$
|
||||
|
||||
declareWorkbenchImage(ideBundle,
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_DLCL_QUICK_FIX_DISABLED,
|
||||
PATH_DLOCALTOOL + "smartmode_co.gif", true); //$NON-NLS-1$
|
||||
PATH_DLOCALTOOL + "smartmode_co.gif", true ); //$NON-NLS-1$
|
||||
|
||||
declareWorkbenchImage(ideBundle,
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_OBJS_FIXABLE_WARNING,
|
||||
PATH_OBJECT + "quickfix_warning_obj.gif", true); //$NON-NLS-1$
|
||||
declareWorkbenchImage(ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_OBJS_FIXABLE_ERROR,
|
||||
PATH_OBJECT + "quickfix_error_obj.gif", true); //$NON-NLS-1$
|
||||
PATH_OBJECT + "quickfix_warning_obj.gif", true ); //$NON-NLS-1$
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_OBJS_FIXABLE_ERROR, PATH_OBJECT
|
||||
+ "quickfix_error_obj.gif", true ); //$NON-NLS-1$
|
||||
|
||||
|
||||
// task objects
|
||||
|
@ -155,58 +157,58 @@ public abstract class WorkbenchAdvisorHack extends WorkbenchAdvisor
|
|||
// declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_LPRIO_TSK,
|
||||
// PATH_OBJECT+"lprio_tsk.gif");
|
||||
|
||||
declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJS_TASK_TSK,
|
||||
PATH_OBJECT + "taskmrk_tsk.gif", true); //$NON-NLS-1$
|
||||
declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJS_BKMRK_TSK,
|
||||
PATH_OBJECT + "bkmrk_tsk.gif", true); //$NON-NLS-1$
|
||||
declareWorkbenchImage( ideBundle, IDE.SharedImages.IMG_OBJS_TASK_TSK,
|
||||
PATH_OBJECT + "taskmrk_tsk.gif", true ); //$NON-NLS-1$
|
||||
declareWorkbenchImage( ideBundle, IDE.SharedImages.IMG_OBJS_BKMRK_TSK,
|
||||
PATH_OBJECT + "bkmrk_tsk.gif", true ); //$NON-NLS-1$
|
||||
|
||||
declareWorkbenchImage(ideBundle,
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_OBJS_COMPLETE_TSK, PATH_OBJECT
|
||||
+ "complete_tsk.gif", true); //$NON-NLS-1$
|
||||
declareWorkbenchImage(ideBundle,
|
||||
+ "complete_tsk.gif", true ); //$NON-NLS-1$
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_OBJS_INCOMPLETE_TSK, PATH_OBJECT
|
||||
+ "incomplete_tsk.gif", true); //$NON-NLS-1$
|
||||
declareWorkbenchImage(ideBundle,
|
||||
+ "incomplete_tsk.gif", true ); //$NON-NLS-1$
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_OBJS_WELCOME_ITEM, PATH_OBJECT
|
||||
+ "welcome_item.gif", true); //$NON-NLS-1$
|
||||
declareWorkbenchImage(ideBundle,
|
||||
+ "welcome_item.gif", true ); //$NON-NLS-1$
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_OBJS_WELCOME_BANNER, PATH_OBJECT
|
||||
+ "welcome_banner.gif", true); //$NON-NLS-1$
|
||||
declareWorkbenchImage(ideBundle,
|
||||
+ "welcome_banner.gif", true ); //$NON-NLS-1$
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_OBJS_ERROR_PATH, PATH_OBJECT
|
||||
+ "error_tsk.gif", true); //$NON-NLS-1$
|
||||
declareWorkbenchImage(ideBundle,
|
||||
+ "error_tsk.gif", true ); //$NON-NLS-1$
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_OBJS_WARNING_PATH, PATH_OBJECT
|
||||
+ "warn_tsk.gif", true); //$NON-NLS-1$
|
||||
declareWorkbenchImage(ideBundle,
|
||||
+ "warn_tsk.gif", true ); //$NON-NLS-1$
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_OBJS_INFO_PATH, PATH_OBJECT
|
||||
+ "info_tsk.gif", true); //$NON-NLS-1$
|
||||
+ "info_tsk.gif", true ); //$NON-NLS-1$
|
||||
|
||||
declareWorkbenchImage(ideBundle,
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_LCL_FLAT_LAYOUT, PATH_ELOCALTOOL
|
||||
+ "flatLayout.gif", true); //$NON-NLS-1$
|
||||
declareWorkbenchImage(ideBundle,
|
||||
+ "flatLayout.gif", true ); //$NON-NLS-1$
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_LCL_HIERARCHICAL_LAYOUT,
|
||||
PATH_ELOCALTOOL + "hierarchicalLayout.gif", true); //$NON-NLS-1$
|
||||
declareWorkbenchImage(ideBundle,
|
||||
PATH_ELOCALTOOL + "hierarchicalLayout.gif", true ); //$NON-NLS-1$
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_ETOOL_PROBLEM_CATEGORY,
|
||||
PATH_ETOOL + "problem_category.gif", true); //$NON-NLS-1$
|
||||
PATH_ETOOL + "problem_category.gif", true ); //$NON-NLS-1$
|
||||
|
||||
declareWorkbenchImage(ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_ETOOL_PROBLEMS_VIEW,
|
||||
PATH_EVIEW + "problems_view.gif", true); //$NON-NLS-1$
|
||||
declareWorkbenchImage(ideBundle,
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_ETOOL_PROBLEMS_VIEW, PATH_EVIEW
|
||||
+ "problems_view.gif", true ); //$NON-NLS-1$
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_ETOOL_PROBLEMS_VIEW_ERROR,
|
||||
PATH_EVIEW + "problems_view_error.gif", true); //$NON-NLS-1$
|
||||
declareWorkbenchImage(ideBundle,
|
||||
PATH_EVIEW + "problems_view_error.gif", true ); //$NON-NLS-1$
|
||||
declareWorkbenchImage( ideBundle,
|
||||
IDEInternalWorkbenchImages.IMG_ETOOL_PROBLEMS_VIEW_WARNING,
|
||||
PATH_EVIEW + "problems_view_warning.gif", true); //$NON-NLS-1$
|
||||
PATH_EVIEW + "problems_view_warning.gif", true ); //$NON-NLS-1$
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares an IDE-specific workbench image.
|
||||
*
|
||||
*
|
||||
* @param symbolicName
|
||||
* the symbolic name of the image
|
||||
* @param path
|
||||
|
@ -217,18 +219,18 @@ public abstract class WorkbenchAdvisorHack extends WorkbenchAdvisor
|
|||
* <code>false</code> if this is not a shared image
|
||||
* @see org.eclipse.ui.internal.ide.IDEWorkbenchAdvisor#declareImage
|
||||
*/
|
||||
private void declareWorkbenchImage(Bundle ideBundle, String symbolicName, String path,
|
||||
boolean shared)
|
||||
private void declareWorkbenchImage( Bundle ideBundle, String symbolicName,
|
||||
String path, boolean shared )
|
||||
{
|
||||
URL url = FileLocator.find(ideBundle, new Path(path), null);
|
||||
ImageDescriptor desc = ImageDescriptor.createFromURL(url);
|
||||
getWorkbenchConfigurer().declareImage(symbolicName, desc, shared);
|
||||
URL url = FileLocator.find( ideBundle, new Path( path ), null );
|
||||
ImageDescriptor desc = ImageDescriptor.createFromURL( url );
|
||||
getWorkbenchConfigurer( ).declareImage( symbolicName, desc, shared );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(IWorkbenchConfigurer configurer)
|
||||
public void initialize( IWorkbenchConfigurer configurer )
|
||||
{
|
||||
configurer.setSaveAndRestore(true);
|
||||
declareWorkbenchImages();
|
||||
configurer.setSaveAndRestore( true );
|
||||
declareWorkbenchImages( );
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue