eclipse plugin: Remove redundant accessors/mutators...

...since the 'ConfigFile' class is just a POD
This commit is contained in:
Timotei Dolean 2011-06-20 15:33:37 +00:00
parent 88a748a99e
commit bfcdb641ce
7 changed files with 37 additions and 72 deletions

View file

@ -31,6 +31,7 @@ import org.wesnoth.ui.WMLUiModule;
import org.wesnoth.ui.WMLUtil;
import org.wesnoth.ui.labeling.WMLLabelProvider;
import org.wesnoth.utils.ProjectUtils;
import org.wesnoth.utils.StringUtils;
import org.wesnoth.wml.WMLKey;
import org.wesnoth.wml.WMLTag;
import org.wesnoth.wml.core.ConfigFile;
@ -165,11 +166,10 @@ public class WMLProposalProvider extends AbstractWMLProposalProvider
for(ConfigFile config : ProjectUtils.
getCacheForProject(file.getProject()).getConfigs().values())
{
if (config.getScenarioId() == null ||
config.getScenarioId().isEmpty())
if (StringUtils.isNullOrEmpty( config.ScenarioId ))
continue;
acceptor.accept(createCompletionProposal(config.getScenarioId(),
config.getScenarioId(), WMLLabelProvider.getImageByName("scenario.png"), //$NON-NLS-1$
acceptor.accept(createCompletionProposal(config.ScenarioId,
config.ScenarioId, WMLLabelProvider.getImageByName("scenario.png"), //$NON-NLS-1$
context, 1700));
}
}

View file

@ -212,12 +212,11 @@ public class WesnothProjectBuilder extends IncrementalProjectBuilder
{
ConfigFile cfg = handler.getConfigFile();
projCache.getConfigs().put(file.getName(), cfg);
if (cfg.isScenario())
if (cfg.IsScenario)
{
if (cfg.getScenarioId() != null &&
cfg.getScenarioId().isEmpty() == false)
if ( StringUtils.isNullOrEmpty( cfg.ScenarioId ) )
{
Logger.getInstance().log("added scenarioId [" + cfg.getScenarioId() + //$NON-NLS-1$
Logger.getInstance().log("added scenarioId [" + cfg.ScenarioId + //$NON-NLS-1$
"] for file: " + file.getName()); //$NON-NLS-1$
}
else

View file

@ -70,11 +70,11 @@ public class GameUtils
String scenarioId = null;
campaignId = ProjectUtils.getCacheForProject(selectedResource.getProject()).
getConfig("_main.cfg").getCampaignId();
getConfig("_main.cfg").CampaignId;
if (scenario == true && selectedResource instanceof IFile)
scenarioId = ProjectUtils.getCacheForProject(selectedResource.getProject()).
getConfig(selectedResource.getName()).getScenarioId();
getConfig(selectedResource.getName()).ScenarioId;
if (campaignId == null)
{

View file

@ -66,6 +66,7 @@ public class ProjectCache
if (force == false &&
wesnothFile_.lastModified() <= propertiesTimetamp_)
return;
try
{
ResourceUtils.createWesnothFile(wesnothFile_.getAbsolutePath(), false);
@ -91,8 +92,8 @@ public class ProjectCache
continue;
ConfigFile tmp = new ConfigFile(config.get("filename")); //$NON-NLS-1$
tmp.setScenarioId(config.get("scenario_id")); //$NON-NLS-1$
tmp.setCampaignId(config.get("campaign_id")); //$NON-NLS-1$
tmp.ScenarioId = config.get( "scenario_id" ); //$NON-NLS-1$
tmp.CampaignId = config.get( "campaign_id" ); //$NON-NLS-1$
for(IDialogSettings variable : config.getSection("variables").getSections()) //$NON-NLS-1$
{
@ -169,8 +170,8 @@ public class ProjectCache
for(ConfigFile config : configFiles_.values())
{
IDialogSettings configSection = configsSection.addNewSection("config" + configCnt); //$NON-NLS-1$
configSection.put("scenario_id", config.getScenarioId()); //$NON-NLS-1$
configSection.put("campaign_id", config.getCampaignId()); //$NON-NLS-1$
configSection.put("scenario_id", config.ScenarioId); //$NON-NLS-1$
configSection.put("campaign_id", config.CampaignId); //$NON-NLS-1$
configSection.put("filename", config.getFilename()); //$NON-NLS-1$
IDialogSettings variablesSection = configSection.addNewSection("variables"); //$NON-NLS-1$

View file

@ -402,7 +402,7 @@ public class ResourceUtils
new WMLSaxHandler(resource.getLocation().toOSString()));
if (handler == null)
return null;
return handler.getConfigFile().getCampaignId();
return handler.getConfigFile().CampaignId;
}
/**
@ -417,7 +417,7 @@ public class ResourceUtils
new WMLSaxHandler(file.getLocation().toOSString()));
if (handler == null)
return null;
return handler.getConfigFile().getScenarioId();
return handler.getConfigFile().ScenarioId;
}
/**

View file

@ -60,11 +60,11 @@ public class WMLSaxHandler extends DefaultHandler
}
else if (rawName.equals("campaign")) //$NON-NLS-1$
{
cfg_.setIsCampaign(true);
cfg_.IsCampaign = true;
}
else if (rawName.equals("scenario")) //$NON-NLS-1$
{
cfg_.setIsScenario(true);
cfg_.IsScenario = true;
}
}
@ -78,9 +78,9 @@ public class WMLSaxHandler extends DefaultHandler
if (peek.equals("id")) //$NON-NLS-1$
{
if (stack_.get(stack_.size() - 2).equals("campaign")) //$NON-NLS-1$
cfg_.setCampaignId(new String(ch, start, length));
cfg_.CampaignId = new String( ch, start, length );
else if (stack_.get(stack_.size() - 2).equals("scenario")) //$NON-NLS-1$
cfg_.setScenarioId(new String(ch, start, length));
cfg_.ScenarioId = new String( ch, start, length );
}
if (STATUS == SET_VARIABLE ||

View file

@ -17,10 +17,23 @@ import java.util.List;
public class ConfigFile
{
private String filename_;
private String scenarioId_;
private boolean isScenario_;
private String campaignId_;
private boolean isCampaign_;
public String ScenarioId;
/**
* True if there was a [scenario] tag present in the file.
*
* However The {@link ConfigFile#ScenarioId} may be null
*/
public boolean IsScenario;
public String CampaignId;
/**
* True if there was a [campaign] tag present in the file.
*
* However The {@link ConfigFile#CampaignId} may be null
*/
public boolean IsCampaign;
private List<Variable> variables_;
public ConfigFile(String filename)
@ -38,52 +51,4 @@ public class ConfigFile
{
return variables_;
}
public String getScenarioId()
{
return scenarioId_;
}
public void setScenarioId(String id)
{
scenarioId_ = id;
}
public String getCampaignId()
{
return campaignId_;
}
public void setCampaignId(String campaignId)
{
campaignId_ = campaignId;
}
public void setIsScenario(boolean isScenario)
{
isScenario_ = isScenario;
}
/**
* Returns true if there was a [scenario] tag present in the file.
*
* However the {@link ConfigFile#getScenarioId()} may return nul
*/
public boolean isScenario()
{
return isScenario_;
}
public void setIsCampaign(boolean isCampaign)
{
isCampaign_ = isCampaign;
}
/**
* Returns true if there was a [campaign] tag present in the file.
* However the {@link ConfigFile#getCampaignId()} may return null
* @return
*/
public boolean isCampaign()
{
return isCampaign_;
}
}