/* (non-Javadoc) * @see org.ebayopensource.turmeric.eclipse.ui.wizards.pages.AbstractElementManagementWizardPage#dialogChanged() */ @Override public boolean dialogChanged() { if (super.dialogChanged() == false) return false; boolean addButtonEnabled = true; if (getPreviousPage() instanceof ComplexTypeCCWizardGeneralPage) { final ComplexTypeCCWizardGeneralPage ccPage = (ComplexTypeCCWizardGeneralPage) getPreviousPage(); if (ccPage.getRawBaseType() == null || StringUtils.isBlank(ccPage.getRawBaseType().toString())) { updatePageStatus( null, EclipseMessageUtils.createStatus( "The extension type of the previous page need to be selected in order to add elements", IStatus.WARNING)); addButtonEnabled = false; } } if (super.typesViewer != null) { super.typesViewer.setAddButtonsEnabled(addButtonEnabled); if (addButtonEnabled == false) return false; } final Set<String> elementNames = new HashSet<String>(); for (final IParameterElement elementModel : elements) { if (elementModel instanceof ElementTableModel) { final String elementValue = ((ElementTableModel) elementModel).getElementName(); final int minOccursValue = ((ElementTableModel) elementModel).getMinOccurs(); final int maxOccursValue = ((ElementTableModel) elementModel).getMaxOccurs(); if (!StringUtils.isAlphanumeric(elementValue)) { updateStatus(super.typesViewer.getControl(), "Element name should be alphanumeric"); return false; } if (minOccursValue < 0) { updateStatus(super.typesViewer.getControl(), "The min occurs must be greater than zero"); return false; } if (maxOccursValue != -1) { if (maxOccursValue >= 0 && minOccursValue > maxOccursValue) { updateStatus( super.typesViewer.getControl(), "The min occurs " + minOccursValue + " cannot be greater than max occurs " + maxOccursValue); return false; } } if (elementNames.contains(elementValue)) { updateStatus(super.typesViewer.getControl(), "Duplicate element name - " + elementValue); return false; } else { updateStatus(null); } elementNames.add(elementValue); } } return true; }
/* (non-Javadoc) * @see org.ebayopensource.turmeric.eclipse.ui.wizards.pages.AbstractElementManagementWizardPage#createControl(org.eclipse.swt.widgets.Composite) */ @Override public void createControl(Composite parent) { super.createControl(parent); dialogChanged(); }