mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-03 17:51:05 +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);
|
TagKey key = keys_.get(i);
|
||||||
|
|
||||||
if (key.getCardinality() == '-')
|
if (key.isForbidden())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Label label = new Label(container_, SWT.NONE);
|
Label label = new Label(container_, SWT.NONE);
|
||||||
label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
|
label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
|
||||||
// add star to required items
|
// 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 the is an enum create a combobox instead of textbox
|
||||||
if (key.getIsEnum())
|
if (key.getIsEnum())
|
||||||
@ -84,7 +84,7 @@ public class WizardGeneratorPageKey extends NewWizardPageTemplate
|
|||||||
textBox.setData("valType", key.getValueType());
|
textBox.setData("valType", key.getValueType());
|
||||||
textBox.setData("card", key.getCardinality());
|
textBox.setData("card", key.getCardinality());
|
||||||
textBox.setData("trans", key.getIsTranslatable());
|
textBox.setData("trans", key.getIsTranslatable());
|
||||||
if (key.getCardinality() == '1')
|
if (key.isRequired())
|
||||||
textBox.setData("comp", false); // is textbox complete
|
textBox.setData("comp", false); // is textbox complete
|
||||||
|
|
||||||
textBox.addModifyListener(new ModifyListener() {
|
textBox.addModifyListener(new ModifyListener() {
|
||||||
|
@ -63,7 +63,7 @@ public class WizardGeneratorPageTag extends NewWizardPageTemplate
|
|||||||
for (int i = startIndex_; i <= endIndex_; i++)
|
for (int i = startIndex_; i <= endIndex_; i++)
|
||||||
{
|
{
|
||||||
final Tag tag = tags_.get(i);
|
final Tag tag = tags_.get(i);
|
||||||
if (tag.getCardinality() == '-')
|
if (tag.isForbidden())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Group tagGroup = new Group(container_, SWT.NONE);
|
Group tagGroup = new Group(container_, SWT.NONE);
|
||||||
@ -116,7 +116,7 @@ public class WizardGeneratorPageTag extends NewWizardPageTemplate
|
|||||||
|
|
||||||
private void addNewItem(List targetList, Tag tag)
|
private void addNewItem(List targetList, Tag tag)
|
||||||
{
|
{
|
||||||
if ((tag.getCardinality() == '1' || tag.getCardinality() == '?') &&
|
if ((tag.isOptional() || tag.isRequired()) &&
|
||||||
targetList.getItemCount() == 1)
|
targetList.getItemCount() == 1)
|
||||||
{
|
{
|
||||||
GUIUtils.showWarnMessageBox("You can't add more than one item.");
|
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();
|
int cnt = ((List)control.getData("list")).getItemCount();
|
||||||
Tag tag = (Tag)control.getData("tag");
|
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.");
|
setErrorMessage("You need to have a [" + tag.getName() + "] defined.");
|
||||||
return;
|
return;
|
||||||
|
@ -145,11 +145,19 @@ public class WMLProposalProvider extends AbstractWMLProposalProvider
|
|||||||
for(TagKey key : SchemaParser.getInstance().
|
for(TagKey key : SchemaParser.getInstance().
|
||||||
getTags().get(tag.getName()).getKeyChildren())
|
getTags().get(tag.getName()).getKeyChildren())
|
||||||
{
|
{
|
||||||
|
// skip forbidden keys
|
||||||
|
if (key.isForbidden())
|
||||||
|
continue;
|
||||||
|
|
||||||
found = false;
|
found = false;
|
||||||
// don't suggest already completed keys
|
// check only non-repeatable keys
|
||||||
for(WMLKey eKey: tag.getKeys())
|
if (key.isRepeatable() == false)
|
||||||
if (eKey.getName().equals(key.getName()))
|
{
|
||||||
|
// don't suggest already completed keys
|
||||||
|
for(WMLKey eKey: tag.getKeys())
|
||||||
|
if (eKey.getName().equals(key.getName()))
|
||||||
found = true;
|
found = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (found == false)
|
if (found == false)
|
||||||
acceptor.accept(createCompletionProposal(key.getName() + "=",
|
acceptor.accept(createCompletionProposal(key.getName() + "=",
|
||||||
@ -195,14 +203,22 @@ public class WMLProposalProvider extends AbstractWMLProposalProvider
|
|||||||
boolean found = false;
|
boolean found = false;
|
||||||
for(Tag tag : tagChildren.getTagChildren())
|
for(Tag tag : tagChildren.getTagChildren())
|
||||||
{
|
{
|
||||||
|
// skip forbidden tags
|
||||||
|
if (tag.isForbidden())
|
||||||
|
continue;
|
||||||
|
|
||||||
found = false;
|
found = false;
|
||||||
|
|
||||||
for(WMLTag wmlTag : parentTag.getTags())
|
// check only non-repeatable tags
|
||||||
if (wmlTag.getName().equals(tag.getName()))
|
if (tag.isRepeatable() == false)
|
||||||
{
|
{
|
||||||
found = true;
|
for(WMLTag wmlTag : parentTag.getTags())
|
||||||
break;
|
if (wmlTag.getName().equals(tag.getName()))
|
||||||
}
|
{
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (found == false)
|
if (found == false)
|
||||||
acceptor.accept(tagProposal(tag, parentIndent,
|
acceptor.accept(tagProposal(tag, parentIndent,
|
||||||
@ -248,7 +264,7 @@ public class WMLProposalProvider extends AbstractWMLProposalProvider
|
|||||||
proposal.append("]\n");
|
proposal.append("]\n");
|
||||||
for(TagKey key : tag.getKeyChildren())
|
for(TagKey key : tag.getKeyChildren())
|
||||||
{
|
{
|
||||||
if (key.getCardinality() == '1')
|
if (key.isRequired())
|
||||||
proposal.append(String.format("\t%s%s=\n",
|
proposal.append(String.format("\t%s%s=\n",
|
||||||
indent, key.getName()));
|
indent, key.getName()));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user