Skip to content

Commit

Permalink
Merge pull request #316 from mdrillin/TEIIDDES-1875
Browse files Browse the repository at this point in the history
TEIIDDES-1875 Allows viewing of Built-In MEDS
  • Loading branch information
blafond committed Apr 1, 2014
2 parents 0959cf3 + 86c624e commit f14303f
Show file tree
Hide file tree
Showing 16 changed files with 288 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ public static enum RegistryOption {

private static final String XML_EXTENSIONS_PROJECT_NAME = "XMLExtensionsProject"; //$NON-NLS-1$

private static final String[] RESERVED_PROJECT_NAMES = {USERFILES_FOLDERNAME, UDF_PROJECT_NAME, XML_EXTENSIONS_PROJECT_NAME,};
private static final String BUILTIN_MEDS_PROJECT_NAME = "BuiltInMedsProject"; //$NON-NLS-1$

private static final String[] RESERVED_PROJECT_NAMES = {USERFILES_FOLDERNAME, UDF_PROJECT_NAME, XML_EXTENSIONS_PROJECT_NAME, BUILTIN_MEDS_PROJECT_NAME};
/**
* <p>
* The file extension of Teiid Designer model files.
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public class Messages extends NLS {

public static String cloneMedActionText;
public static String cloneMedActionToolTip;
public static String viewMedActionText;
public static String viewMedActionToolTip;
public static String findMedReferencesActionText;
public static String findMedReferencesActionToolTip;
public static String registerMedActionText;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ interface ImageIds {
String REMOVE_VALUE = FOLDER + "remove-metaclass.png"; //$NON-NLS-1$
String SHOW_REGISTRY_VIEW_ACTION = REGISTRY_VIEW;
String UNREGISTER_MED = FOLDER + "unregister-med.png"; //$NON-NLS-1$
String VIEW_MED_ACTION = FOLDER + "viewMed.gif"; //$NON-NLS-1$
}

interface Form {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,13 @@ private void createMed() throws Exception {
this.medBeingEdited.addPropertyDefinition(metaclassName, copy);
}
}

// If file is in the BuiltInMedsProject, mark as built-in
IFile medFile = getFile();
String projName = medFile.getProject().getName();
if(projName!=null && projName.equals(org.teiid.designer.ui.PluginConstants.BUILTIN_MEDS_PROJECT_NAME)) {
this.medBeingEdited.markAsBuiltIn();
}

// hook selection synchronizer
if (this.selectionSynchronizer == null) {
Expand Down Expand Up @@ -715,7 +722,8 @@ private void refreshReadOnlyState() {

for (MedEditorPage page : this.medEditorPages.keySet()) {
page.setResourceReadOnly(this.readOnly);
page.getManagedForm().refresh();
IManagedForm mf = page.getManagedForm();
if(mf!=null) mf.refresh();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,17 @@
import org.teiid.designer.extension.definition.ModelExtensionDefinition;
import org.teiid.designer.extension.definition.ModelExtensionDefinition.PropertyName;
import org.teiid.designer.extension.definition.ModelExtensionDefinitionValidator;
import org.teiid.designer.extension.definition.ValidationStatus;
import org.teiid.designer.extension.ui.Activator;
import org.teiid.designer.extension.ui.Messages;
import org.teiid.designer.extension.ui.model.MedModelNode;
import org.teiid.designer.extension.ui.model.MedModelNode.ModelType;
import org.teiid.designer.ui.forms.MessageFormDialog;


/**
* Provides general overview editing tab of the ModelExtensionDefinitionEditor
*/
public final class OverviewEditorPage extends MedEditorPage {

private Text txtNamespacePrefix;
Expand All @@ -75,6 +79,10 @@ public final class OverviewEditorPage extends MedEditorPage {
private final ErrorMessage namespacePrefixError;
private final ErrorMessage namespaceUriError;

/**
* Constructor
* @param medEditor the MED editor this page belongs to (cannot be <code>null</code>)
*/
public OverviewEditorPage( ModelExtensionDefinitionEditor medEditor ) {
super(medEditor, MED_OVERVIEW_PAGE, Messages.medEditorOverviewPageTitle);

Expand Down Expand Up @@ -581,6 +589,8 @@ protected void setResourceReadOnly( boolean readOnly ) {
this.txtDescription.setEnabled(!readOnly);
this.txtNamespacePrefix.setEnabled(!readOnly);
this.txtNamespaceUri.setEnabled(!readOnly);
this.txtVersion.setEnabled(!readOnly);
this.modelTypesViewer.getTable().setEnabled(!readOnly);
}

/**
Expand Down Expand Up @@ -623,14 +633,22 @@ private void validateModelTypes() {
}

private void validateNamespacePrefix() {
this.namespacePrefixError.setStatus(ModelExtensionDefinitionValidator.validateNamespacePrefix(getMed().getNamespacePrefix(),
getRegistry().getAllNamespacePrefixes()));
if(getMed().isBuiltIn()) {
this.namespacePrefixError.setStatus(ValidationStatus.OK_STATUS);
} else {
this.namespacePrefixError.setStatus(ModelExtensionDefinitionValidator.validateNamespacePrefix(getMed().getNamespacePrefix(),
getRegistry().getAllNamespacePrefixes()));
}
updateMessage(this.namespacePrefixError);
}

private void validateNamespaceUri() {
this.namespaceUriError.setStatus(ModelExtensionDefinitionValidator.validateNamespaceUri(getMed().getNamespaceUri(),
getRegistry().getAllNamespaceUris()));
if(getMed().isBuiltIn()) {
this.namespaceUriError.setStatus(ValidationStatus.OK_STATUS);
} else {
this.namespaceUriError.setStatus(ModelExtensionDefinitionValidator.validateNamespaceUri(getMed().getNamespaceUri(),
getRegistry().getAllNamespaceUris()));
}
updateMessage(this.namespaceUriError);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@


/**
*
* Provides Properties editing tab of the ModelExtensionDefinitionEditor
*/
public class PropertiesEditorPage extends MedEditorPage {

Expand All @@ -94,6 +94,7 @@ public class PropertiesEditorPage extends MedEditorPage {
private final ErrorMessage propertyError;

/**
* Constructor
* @param medEditor the MED editor this page belongs to (cannot be <code>null</code>)
*/
public PropertiesEditorPage( ModelExtensionDefinitionEditor medEditor ) {
Expand Down Expand Up @@ -720,7 +721,7 @@ public void handleMedReloaded() {
}

void handleMetaclassSelected() {
boolean enable = (getSelectedMetaclass() != null);
boolean enable = (getSelectedMetaclass()!=null && !getMedEditor().isReadOnly());

if (this.btnRemoveMetaclass.getEnabled() != enable) {
this.btnRemoveMetaclass.setEnabled(enable);
Expand Down Expand Up @@ -772,7 +773,7 @@ protected void handlePropertyChanged( PropertyChangeEvent e ) {
}

void handlePropertySelected() {
boolean enable = (getSelectedProperty() != null);
boolean enable = (getSelectedProperty()!=null && !getMedEditor().isReadOnly());

if (this.btnRemoveProperty.getEnabled() != enable) {
this.btnRemoveProperty.setEnabled(enable);
Expand Down Expand Up @@ -881,10 +882,6 @@ private void updateState() {
this.btnRemoveProperty.setEnabled(enable);
}

if (this.metaclassViewer.getTable().getEnabled() != enable) {
this.metaclassViewer.getTable().setEnabled(enable);
}

if (this.propertyViewer.getTable().getEnabled() != enable) {
this.propertyViewer.getTable().setEnabled(enable);
}
Expand All @@ -894,7 +891,15 @@ private void updateState() {
}

private void validateMetaclasses() {
final String[] metaclasses = getMed().getExtendedMetaclasses();
// Suppress errors on BuiltIns - original built-ins dont fully conform
if(getMed().isBuiltIn()) {
this.metaclassError.setStatus(ValidationStatus.OK_STATUS);
updateMessage(this.metaclassError);
validatePropertyDefinitions(); // need to do this to catch when a new metaclass is added
return;
}

final String[] metaclasses = getMed().getExtendedMetaclasses();

// validate with MED validator
MedStatus status = ModelExtensionDefinitionValidator.validateMetaclassNames(metaclasses, true);
Expand Down Expand Up @@ -931,7 +936,12 @@ private void validateMetaclasses() {
}

private void validatePropertyDefinitions() {
this.propertyError.setStatus(ModelExtensionDefinitionValidator.validatePropertyDefinitions(getMed().getPropertyDefinitions()));
// Suppress errors on BuiltIns - original built-ins dont fully conform
if(getMed().isBuiltIn()) {
this.propertyError.setStatus(ValidationStatus.OK_STATUS);
} else {
this.propertyError.setStatus(ModelExtensionDefinitionValidator.validatePropertyDefinitions(getMed().getPropertyDefinitions()));
}
updateMessage(this.propertyError);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ translationLabel = Translation:

cloneMedActionText = Copy
cloneMedActionToolTip = Copy the selected Model Extension Definition to the workspace
viewMedActionText = View MED
viewMedActionToolTip = View the selected Model Extension Definition
findMedReferencesActionText = Find References
findMedReferencesActionToolTip = Find Models which support the selected Model Extension Definition
registerMedActionText = Register
Expand Down

0 comments on commit f14303f

Please sign in to comment.