eclipse plugin: use "isEmpty()" instead checking for length

This commit is contained in:
Timotei Dolean 2010-05-23 12:13:39 +00:00
parent fe28bc259a
commit d8606ab938
6 changed files with 12 additions and 12 deletions

View file

@ -95,7 +95,7 @@ public class TemplateProvider {
{
template[i] = template[i].replace(param.paramName, param.paramValue);
if (param.paramValue == null || param.paramValue.length() == 0)
if (param.paramValue == null || param.paramValue.isEmpty())
{
// we don't have any value supplied -
// let's comment that line (if it's not already commented)

View file

@ -24,10 +24,10 @@ public class OpenEditorHandler extends AbstractHandler
String editorPath = PreferenceInitializer.getString(PreferenceConstants.P_WESNOTH_EXEC_PATH);
String workingDir = PreferenceInitializer.getString(PreferenceConstants.P_WESNOTH_WORKING_DIR);
if (workingDir == "")
if (workingDir.isEmpty())
workingDir = editorPath.substring(0,editorPath.lastIndexOf(new File(editorPath).getName()));
if (editorPath == "")
if (editorPath.isEmpty())
{
MessageBox box = new MessageBox(window.getShell());
box.setMessage(String.format("Please set the wesnoth's executable path first."));

View file

@ -151,7 +151,7 @@ public class CampaignNewWizard extends Wizard implements INewWizard {
{
template[i] = template[i].replace(paramName, paramValue);
if (paramValue == null || paramValue.length() == 0)
if (paramValue == null || paramValue.isEmpty())
{
// we don't have any value supplied -
// let's comment that line (if it's not already commented)

View file

@ -147,14 +147,14 @@ public class CampaignPage1 extends WizardPage {
public void updateIsPageComplete()
{
setPageComplete(false);
if (txtCampaignName_.getText().length() == 0)
if (txtCampaignName_.getText().isEmpty())
{
setErrorMessage("Campaign name is mandatory");
return;
}
// match the pattern x.y.z
if (txtVersion_.getText().length() == 0 ||
if (txtVersion_.getText().isEmpty() ||
!(txtVersion_.getText().matches("[\\d]+\\.[\\d]+\\.\\d[\\w\\W\\d\\D\\s\\S]*")))
{
setErrorMessage("The version must have the format: x.y.z");

View file

@ -141,13 +141,13 @@ public class CampaignPage2 extends WizardPage {
{
setPageComplete(false);
if (txtAbbrev_.getText().length() == 0)
if (txtAbbrev_.getText().isEmpty())
{
setErrorMessage("Please specify an abbreviation.");
return;
}
if (txtDefine_.getText().length() == 0)
if (txtDefine_.getText().isEmpty())
{
setErrorMessage("Please specify a define.");
return;

View file

@ -198,7 +198,7 @@ public class ScenarioPage0 extends WizardPage {
String fileName = getFileName();
String warningMessage = "";
if (getProjectName().length() == 0) {
if (getProjectName().isEmpty()) {
setErrorMessage("An existing campaign must be specified");
return;
}
@ -218,7 +218,7 @@ public class ScenarioPage0 extends WizardPage {
warningMessage += "The scenario *should* be created in the \"campaign_project/scenarios\" folder.";
}
if (fileName.length() == 0) {
if (fileName.isEmpty()) {
setErrorMessage("File name must be specified.");
return;
}
@ -236,13 +236,13 @@ public class ScenarioPage0 extends WizardPage {
}
}
if (txtScenarioId_.getText().length() == 0)
if (txtScenarioId_.getText().isEmpty())
{
setErrorMessage("The scenario ID cannot be empty.");
return;
}
setErrorMessage(null);
setMessage(warningMessage == "" ? null : warningMessage, WARNING);
setMessage(warningMessage.isEmpty()? null : warningMessage, WARNING);
setPageComplete(true);
}