Skip to content

Commit

Permalink
Merge pull request #112 from elvisisking/td-627-1601-1602
Browse files Browse the repository at this point in the history
TEIIDDES-627 File > Save As action results in validation errors in new model if model is virtual and folder location different than original location.
  • Loading branch information
blafond committed Feb 21, 2013
2 parents 3df78da + d69d9b9 commit 685e4f0
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.teiid.core.designer.id.IDGenerator;
import org.teiid.core.designer.plugin.PluginUtilities;
import org.teiid.designer.core.ModelerCore;
import org.teiid.designer.core.builder.ModelBuildUtil;
import org.teiid.designer.core.resource.EmfResource;
import org.teiid.designer.core.types.DatatypeConstants;
import org.teiid.designer.core.util.ConcurrentModelVisitorProcessor;
Expand Down Expand Up @@ -619,7 +620,8 @@ protected void executeXmiCopy( final IProgressMonitor monitor ) {
}

// Save the resulting target resource
try {
try {
ModelBuildUtil.rebuildImports(target, true);
modelResource.save(monitor, true);
} catch (Throwable e) {
final Object[] params = new Object[] {modelResource};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ protected void applyTableExtensionProperties(RelationalTable tableRef, BaseTable
tableRef.getNativeQuery() );

} catch (Exception ex) {
RelationalPlugin.Util.log(IStatus.ERROR,
RelationalPlugin.Util.log(IStatus.ERROR, ex,
NLS.bind(Messages.relationalModelFactory_error_setting_extension_props_on_0, tableRef.getName()));
}
}
Expand Down Expand Up @@ -828,7 +828,7 @@ protected void applyProcedureExtensionProperties(RelationalProcedure procedureRe
}
}
} catch (Exception ex) {
RelationalPlugin.Util.log(IStatus.ERROR,
RelationalPlugin.Util.log(IStatus.ERROR, ex,
NLS.bind(Messages.relationalModelFactory_error_setting_extension_props_on_0, procedureRef.getName()));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.8.0,4.0.0)",
org.teiid.datatools.connectivity.ui;bundle-version="[8.1.0,9.0.0)",
org.teiid.designer.datatools.ui;bundle-version="[8.1.0,9.0.0)",
org.eclipse.datatools.connectivity.ui;bundle-version="[1.2.3,2.0.0)",
org.teiid.designer.spi;bundle-version="[8.1.0,9.0.0)"
org.teiid.designer.spi;bundle-version="[8.1.0,9.0.0)",
org.eclipse.search;bundle-version="3.8.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.apache.xerces.parsers
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.search.ui.ISearchResultViewPart;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPart;
import org.teiid.designer.core.ModelerCore;
Expand Down Expand Up @@ -68,6 +69,10 @@ public class AddTransformationSourceAction extends TransformationAction {
// CONSTRUCTORS
///////////////////////////////////////////////////////////////////////////////////////////////

/**
* @param transformationEObject the SQL transformation root (cannot be <code>null</code>)
* @param diagram the diagram where this action is installed (cannot be <code>null</code>)
*/
public AddTransformationSourceAction(EObject transformationEObject, Diagram diagram) {
super(transformationEObject, diagram);
setImageDescriptor(UiPlugin.getDefault().getImageDescriptor(UiConstants.Images.ADD_SOURCES));
Expand All @@ -81,28 +86,33 @@ public AddTransformationSourceAction(EObject transformationEObject, Diagram diag
* @see org.eclipse.ui.ISelectionListener#selectionChanged(IWorkbenchPart, ISelection)
*/
@Override
public void selectionChanged(IWorkbenchPart thePart, ISelection theSelection) {
// Save off current selection to old if part is ModelEditor and selection == null
// This indicates a focus change and part activation.
if (thePart != null && thePart instanceof ModelEditor) {
oldSelection = getSelection();
}

public void selectionChanged(final IWorkbenchPart thePart,
ISelection theSelection) {
ISelection selection = theSelection;
// Now we see if the selection is from Search Results?
List searchResults = SearchPageUtil.getEObjectsFromSearchSelection(theSelection);
if( searchResults != null ) {
if( searchResults.isEmpty() ) {
selection = new StructuredSelection();

if (wasToolBarItemSelected()) {
if (!(thePart instanceof ModelEditor)) {
selection = this.focusedSelection;
}
} else {
if (thePart instanceof ISearchResultViewPart) {
final List searchResults = SearchPageUtil.getEObjectsFromSearchSelection(theSelection);

if (searchResults != null) {
if (searchResults.isEmpty()) {
selection = StructuredSelection.EMPTY;
} else {
selection = new StructuredSelection(searchResults);
}
}

this.focusedSelection = selection;
} else {
selection = new StructuredSelection(searchResults);
this.focusedSelection = theSelection;
}
}
// initialize abstract base class info

super.selectionChanged(thePart, selection);

setFocusedSelection();

setEnabled(shouldEnable());
}

Expand Down Expand Up @@ -241,7 +251,7 @@ private boolean shouldEnable() {
}
}
}

return enable;
}

Expand Down Expand Up @@ -278,7 +288,7 @@ private TransformationObjectEditorPage getTransObjectEditorPage() {
return transOEP;
}

public boolean wasToolBarItemSelected() {
private boolean wasToolBarItemSelected() {
if( toolBarManager != null ) {
if( toolBarManager.getFocusedToolItem() != null && thisToolItem != null ) {
if( thisToolItem.equals(toolBarManager.getFocusedToolItem()))
Expand All @@ -289,6 +299,9 @@ public boolean wasToolBarItemSelected() {
return false;
}

/**
* @param aci the contribution item associated with this action (cannot be <code>null</code>)
*/
public void setItem(ActionContributionItem aci) {
if( toolBarManager != null ) {
thisToolItem = aci;
Expand All @@ -301,27 +314,29 @@ private void setFocusedSelection() {
}else {
focusedSelection = getSelection();
}

setEnabled(shouldEnable());
}

/**
* @param tbManager the toolbar where this action is installed (cannot be <code>null</code>)
*/
public void setToolBarManager(DiagramToolBarManager tbManager) {
toolBarManager = tbManager;
}

/**
* Gets a string representation of the properties of the given <code>Notification</code>.
* @param theNotification the notification being processed
* @return the string representation
*/
public String getActionString() {

return new StringBuffer()
.append("\n Action State ---------------------------------------------- = ") //$NON-NLS-1$
.append("\n oldSelection = ").append(oldSelection) //$NON-NLS-1$
.append("\n focusedSelection = ").append(focusedSelection) //$NON-NLS-1$
.append("\n currentSelection = ").append(getSelection()) //$NON-NLS-1$
.append("\n enabled = ").append(this.isEnabled()) //$NON-NLS-1$
.append("\n -----------------------------------------------------------") //$NON-NLS-1$
.toString();
}
// private String getActionString() {
//
// return new StringBuffer()
// .append("\n Action State ---------------------------------------------- = ") //$NON-NLS-1$
// .append("\n oldSelection = ").append(oldSelection) //$NON-NLS-1$
// .append("\n focusedSelection = ").append(focusedSelection) //$NON-NLS-1$
// .append("\n currentSelection = ").append(getSelection()) //$NON-NLS-1$
// .append("\n enabled = ").append(this.isEnabled()) //$NON-NLS-1$
// .append("\n shouldEnable = ").append(shouldEnable()) //$NON-NLS-1$
// .append("\n wasToolBarItemSelected = ").append(wasToolBarItemSelected()) //$NON-NLS-1$
// .append("\n -----------------------------------------------------------") //$NON-NLS-1$
// .toString();
// }

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.search.ui.ISearchResultViewPart;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPart;
import org.teiid.designer.core.ModelerCore;
Expand All @@ -28,6 +30,7 @@
import org.teiid.designer.ui.editors.ModelEditor;
import org.teiid.designer.ui.editors.ModelObjectEditorPage;
import org.teiid.designer.ui.editors.MultiPageModelEditor;
import org.teiid.designer.ui.search.SearchPageUtil;
import org.teiid.designer.ui.undo.ModelerUndoManager;

/**
Expand Down Expand Up @@ -68,6 +71,10 @@ public class AddUnionSourceAction extends TransformationAction {
// CONSTRUCTORS
///////////////////////////////////////////////////////////////////////////////////////////////

/**
* @param transformationEObject the SQL transformation root (cannot be <code>null</code>)
* @param diagram the diagram where this action is installed (cannot be <code>null</code>)
*/
public AddUnionSourceAction(EObject transformationEObject, Diagram diagram) {
super(transformationEObject, diagram);
setImageDescriptor(UiPlugin.getDefault().getImageDescriptor(UiConstants.Images.ADD_UNION_SOURCES));
Expand All @@ -82,17 +89,31 @@ public AddUnionSourceAction(EObject transformationEObject, Diagram diagram) {
*/
@Override
public void selectionChanged(IWorkbenchPart thePart, ISelection theSelection) {
// Save off current selection to old if part is ModelEditor and selection == null
// This indicates a focus change and part activation.
if (thePart != null && thePart instanceof ModelEditor) {
oldSelection = getSelection();
ISelection selection = theSelection;

if (wasToolBarItemSelected()) {
if (!(thePart instanceof ModelEditor)) {
selection = this.focusedSelection;
}
} else {
if (thePart instanceof ISearchResultViewPart) {
final List searchResults = SearchPageUtil.getEObjectsFromSearchSelection(theSelection);

if (searchResults != null) {
if (searchResults.isEmpty()) {
selection = StructuredSelection.EMPTY;
} else {
selection = new StructuredSelection(searchResults);
}
}

this.focusedSelection = selection;
} else {
this.focusedSelection = theSelection;
}
}

// initialize abstract base class info
super.selectionChanged(thePart, theSelection);

setFocusedSelection();


super.selectionChanged(thePart, selection);
setEnabled(shouldEnable());
}

Expand Down Expand Up @@ -282,7 +303,7 @@ private TransformationObjectEditorPage getTransObjectEditorPage() {
return transOEP;
}

public boolean wasToolBarItemSelected() {
private boolean wasToolBarItemSelected() {
if( toolBarManager != null ) {
if( toolBarManager.getFocusedToolItem() != null && thisToolItem != null ) {
if( thisToolItem.equals(toolBarManager.getFocusedToolItem()))
Expand All @@ -293,6 +314,9 @@ public boolean wasToolBarItemSelected() {
return false;
}

/**
* @param aci the contribution item associated with this action (cannot be <code>null</code>)
*/
public void setItem(ActionContributionItem aci) {
if( toolBarManager != null ) {
thisToolItem = aci;
Expand All @@ -304,27 +328,34 @@ private void setFocusedSelection() {
focusedSelection = oldSelection;
else
focusedSelection = getSelection();

setEnabled(shouldEnable());
}

/**
* @param tbManager the toolbar where this action is installed (cannot be <code>null</code>)
*/
public void setToolBarManager(DiagramToolBarManager tbManager) {
toolBarManager = tbManager;
}

/**
* Gets a string representation of the properties of the given <code>Notification</code>.
* @param theNotification the notification being processed
* @return the string representation
*/
public String getActionString() {

return new StringBuffer()
.append("\n Action State ---------------------------------------------- = ") //$NON-NLS-1$
.append("\n oldSelection = ").append(oldSelection) //$NON-NLS-1$
.append("\n focusedSelection = ").append(focusedSelection) //$NON-NLS-1$
.append("\n currentSelection = ").append(getSelection()) //$NON-NLS-1$
.append("\n enabled = ").append(this.isEnabled()) //$NON-NLS-1$
.append("\n -----------------------------------------------------------") //$NON-NLS-1$
.toString();
}
// private String getActionString() {
//
// return new StringBuffer()
// .append("\n Action State ---------------------------------------------- = ") //$NON-NLS-1$
// .append("\n oldSelection = ").append(oldSelection) //$NON-NLS-1$
// .append("\n focusedSelection = ").append(focusedSelection) //$NON-NLS-1$
// .append("\n currentSelection = ").append(getSelection()) //$NON-NLS-1$
// .append("\n enabled = ").append(this.isEnabled()) //$NON-NLS-1$
// .append("\n shouldEnable = ").append(shouldEnable()) //$NON-NLS-1$
// .append("\n wasToolBarItemSelected = ").append(wasToolBarItemSelected()) //$NON-NLS-1$
// .append("\n -----------------------------------------------------------") //$NON-NLS-1$
// .toString();
// }

}
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public EObject buildObject( RelationalReference obj,
// Create the Table
EObject baseTable = createBaseTable(obj, modelResource);
modelResource.getEmfResource().getContents().add(baseTable);
applyTableExtensionProperties((RelationalTable)obj, (BaseTable)baseTable, false);
applyTableExtensionProperties((RelationalTable)obj, (BaseTable)baseTable, true);

// Set the transformation SQL
RelationalViewTable viewTable = (RelationalViewTable)obj;
Expand Down
2 changes: 1 addition & 1 deletion plugins/teiid/org.teiid.7.7.x
Submodule org.teiid.7.7.x updated 1 files
+19 −0 pom.xml
2 changes: 1 addition & 1 deletion plugins/teiid/org.teiid.8.2.x
Submodule org.teiid.8.2.x updated 1 files
+19 −0 pom.xml

0 comments on commit 685e4f0

Please sign in to comment.