diff --git a/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/wizards/generator/WizardGeneratorPageKey.java b/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/wizards/generator/WizardGeneratorPageKey.java index 8e6d176c715..9a3d3350f8e 100644 --- a/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/wizards/generator/WizardGeneratorPageKey.java +++ b/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/wizards/generator/WizardGeneratorPageKey.java @@ -57,13 +57,13 @@ public class WizardGeneratorPageKey extends NewWizardPageTemplate { TagKey key = keys_.get(i); - if (key.getCardinality() == '-') + if (key.isForbidden()) continue; Label label = new Label(container_, SWT.NONE); label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); // add star to required items - label.setText(key.getName() + (key.getCardinality()== '1' ? "*" : "") + ":"); + label.setText(key.getName() + (key.isRequired() ? "*" : "") + ":"); // if the is an enum create a combobox instead of textbox if (key.getIsEnum()) @@ -84,7 +84,7 @@ public class WizardGeneratorPageKey extends NewWizardPageTemplate textBox.setData("valType", key.getValueType()); textBox.setData("card", key.getCardinality()); textBox.setData("trans", key.getIsTranslatable()); - if (key.getCardinality() == '1') + if (key.isRequired()) textBox.setData("comp", false); // is textbox complete textBox.addModifyListener(new ModifyListener() { diff --git a/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/wizards/generator/WizardGeneratorPageTag.java b/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/wizards/generator/WizardGeneratorPageTag.java index 04c4c00c7bc..39073aed575 100644 --- a/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/wizards/generator/WizardGeneratorPageTag.java +++ b/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/wizards/generator/WizardGeneratorPageTag.java @@ -63,7 +63,7 @@ public class WizardGeneratorPageTag extends NewWizardPageTemplate for (int i = startIndex_; i <= endIndex_; i++) { final Tag tag = tags_.get(i); - if (tag.getCardinality() == '-') + if (tag.isForbidden()) continue; Group tagGroup = new Group(container_, SWT.NONE); @@ -116,7 +116,7 @@ public class WizardGeneratorPageTag extends NewWizardPageTemplate private void addNewItem(List targetList, Tag tag) { - if ((tag.getCardinality() == '1' || tag.getCardinality() == '?') && + if ((tag.isOptional() || tag.isRequired()) && targetList.getItemCount() == 1) { GUIUtils.showWarnMessageBox("You can't add more than one item."); @@ -158,7 +158,7 @@ public class WizardGeneratorPageTag extends NewWizardPageTemplate int cnt = ((List)control.getData("list")).getItemCount(); Tag tag = (Tag)control.getData("tag"); - if (cnt == 0 && tag.getCardinality() == '1') + if (cnt == 0 && tag.isRequired()) { setErrorMessage("You need to have a [" + tag.getName() + "] defined."); return; diff --git a/utils/java/org.wesnoth.wml.ui/src/org/wesnoth/ui/contentassist/WMLProposalProvider.java b/utils/java/org.wesnoth.wml.ui/src/org/wesnoth/ui/contentassist/WMLProposalProvider.java index 3de2e991390..9e59db93dc3 100644 --- a/utils/java/org.wesnoth.wml.ui/src/org/wesnoth/ui/contentassist/WMLProposalProvider.java +++ b/utils/java/org.wesnoth.wml.ui/src/org/wesnoth/ui/contentassist/WMLProposalProvider.java @@ -145,11 +145,19 @@ public class WMLProposalProvider extends AbstractWMLProposalProvider for(TagKey key : SchemaParser.getInstance(). getTags().get(tag.getName()).getKeyChildren()) { + // skip forbidden keys + if (key.isForbidden()) + continue; + found = false; - // don't suggest already completed keys - for(WMLKey eKey: tag.getKeys()) - if (eKey.getName().equals(key.getName())) + // check only non-repeatable keys + if (key.isRepeatable() == false) + { + // don't suggest already completed keys + for(WMLKey eKey: tag.getKeys()) + if (eKey.getName().equals(key.getName())) found = true; + } if (found == false) acceptor.accept(createCompletionProposal(key.getName() + "=", @@ -195,14 +203,22 @@ public class WMLProposalProvider extends AbstractWMLProposalProvider boolean found = false; for(Tag tag : tagChildren.getTagChildren()) { + // skip forbidden tags + if (tag.isForbidden()) + continue; + found = false; - for(WMLTag wmlTag : parentTag.getTags()) - if (wmlTag.getName().equals(tag.getName())) - { - found = true; - break; - } + // check only non-repeatable tags + if (tag.isRepeatable() == false) + { + for(WMLTag wmlTag : parentTag.getTags()) + if (wmlTag.getName().equals(tag.getName())) + { + found = true; + break; + } + } if (found == false) acceptor.accept(tagProposal(tag, parentIndent, @@ -248,7 +264,7 @@ public class WMLProposalProvider extends AbstractWMLProposalProvider proposal.append("]\n"); for(TagKey key : tag.getKeyChildren()) { - if (key.getCardinality() == '1') + if (key.isRequired()) proposal.append(String.format("\t%s%s=\n", indent, key.getName())); }