Skip to content

Commit

Permalink
TEIIDDES-2221 Changed duplicate model/xsd file checks when adding to …
Browse files Browse the repository at this point in the history
…VDB.
  • Loading branch information
blafond committed Jun 18, 2014
1 parent d94da44 commit 697a198
Showing 1 changed file with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,37 @@ public IStatus validate( final Object[] selection ) {
return new Status(IStatus.ERROR, VdbUiConstants.PLUGIN_ID, 0, ADD_FILE_DIALOG_VDB_SOURCE_MODEL_SELECTED_MESSAGE, null);
}

// Check for duplicate model and/or user file names
if( !ModelUtil.isXsdFile(file) && VdbUtil.modelAlreadyExistsInVdb(file.getFullPath().removeFileExtension().lastSegment(), file.getFullPath(), getVdb()) ) {
return new Status(IStatus.ERROR, VdbUiConstants.PLUGIN_ID, 0,
ADD_FILE_DIALOG_MODEL_WITH_SAME_NAME_EXISTS_SELECTED_MESSAGE, null);
}
}
}

return new Status(IStatus.OK, VdbUiConstants.PLUGIN_ID, 0, EMPTY_STRING, null);
}
};

private final ISelectionStatusValidator schemaSelectionValidator = new ISelectionStatusValidator() {
/**
* {@inheritDoc}
*
* @see org.eclipse.ui.dialogs.ISelectionStatusValidator#validate(java.lang.Object[])
*/
@Override
public IStatus validate( final Object[] selection ) {
for (int ndx = selection.length; --ndx >= 0;) {
Object obj = selection[ndx];
if (obj instanceof IContainer) {
return new Status(IStatus.ERROR, VdbUiConstants.PLUGIN_ID, 0, ADD_FILE_DIALOG_INVALID_SELECTION_MESSAGE, null);
} else if( obj instanceof IFile ) {
IFile file = (IFile)obj;

if ( !ModelUtil.isXsdFile(file) ) {
return new Status(IStatus.ERROR, VdbUiConstants.PLUGIN_ID, 0, ADD_FILE_DIALOG_NON_MODEL_SELECTED_MESSAGE, null);
}

// Check for duplicate model and/or user file names
if( VdbUtil.modelAlreadyExistsInVdb(file.getFullPath().removeFileExtension().lastSegment(), file.getFullPath(), getVdb()) ) {
return new Status(IStatus.ERROR, VdbUiConstants.PLUGIN_ID, 0,
Expand Down Expand Up @@ -2265,6 +2296,10 @@ ISelectionStatusValidator getValidator() {
ISelectionStatusValidator getModelSelectionValidator() {
return this.modelSelectionValidator;
}

ISelectionStatusValidator getSchemaSelectionValidator() {
return this.schemaSelectionValidator;
}

/**
* {@inheritDoc}
Expand Down

0 comments on commit 697a198

Please sign in to comment.