mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-01 18:38:37 +00:00
eclipse plugin: take in account of tag/key cardinality when proposing it
This commit is contained in:
parent
d80e739408
commit
91e312a336
@ -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() {
|
||||
|
@ -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;
|
||||
|
@ -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()));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user