-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
5,159 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+322 Bytes
plugins/org.teiid.designer.transformation.ui/icons/full/obj16/folder.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+252 Bytes
plugins/org.teiid.designer.transformation.ui/icons/full/obj16/relational-table.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+999 Bytes
plugins/org.teiid.designer.transformation.ui/icons/full/obj16/source-model.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+977 Bytes
plugins/org.teiid.designer.transformation.ui/icons/full/obj16/view-model.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+249 Bytes
....teiid.designer.transformation.ui/icons/full/obj16/virtual-relational-table.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
157 changes: 157 additions & 0 deletions
157
....transformation.ui/src/org/teiid/designer/transformation/ui/actions/CreatePojoAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
package org.teiid.designer.transformation.ui.actions; | ||
|
||
import java.util.Collection; | ||
import java.util.Iterator; | ||
|
||
import org.eclipse.emf.ecore.EObject; | ||
import org.eclipse.emf.ecore.resource.Resource; | ||
import org.eclipse.jface.dialogs.IDialogConstants; | ||
import org.eclipse.jface.dialogs.MessageDialogWithToggle; | ||
import org.eclipse.jface.viewers.ISelection; | ||
import org.eclipse.jface.viewers.StructuredSelection; | ||
import org.eclipse.jface.window.Window; | ||
import org.eclipse.jface.wizard.WizardDialog; | ||
import org.eclipse.swt.widgets.Shell; | ||
import org.eclipse.ui.IWorkbenchWindow; | ||
import org.teiid.designer.core.workspace.ModelResource; | ||
import org.teiid.designer.transformation.ui.UiConstants; | ||
import org.teiid.designer.transformation.ui.UiPlugin; | ||
import org.teiid.designer.transformation.ui.wizards.CreateMaterializedViewWizard; | ||
import org.teiid.designer.transformation.ui.wizards.jdg.CreatePojoWizard; | ||
import org.teiid.designer.transformation.util.TransformationHelper; | ||
import org.teiid.designer.ui.PluginConstants; | ||
import org.teiid.designer.ui.actions.SortableSelectionAction; | ||
import org.teiid.designer.ui.common.eventsupport.SelectionUtilities; | ||
import org.teiid.designer.ui.editors.ModelEditorManager; | ||
import org.teiid.designer.ui.viewsupport.ModelIdentifier; | ||
import org.teiid.designer.ui.viewsupport.ModelUtilities; | ||
|
||
public class CreatePojoAction extends SortableSelectionAction { | ||
|
||
// public static final String OPEN_EDITOR_TITLE = UiConstants.Util.getString("CreatePojoAction.openModelEditorTitle"); //$NON-NLS-1$ | ||
// public static final String OPEN_EDITOR_MESSAGE = UiConstants.Util.getString("CreatePojoAction.openModelEditorMessage"); //$NON-NLS-1$ | ||
// public static final String ALWAY_FORCE_OPEN_MESSAGE = UiConstants.Util.getString("CreatePojoAction.alwaysForceOpenMessage"); //$NON-NLS-1$ | ||
|
||
public CreatePojoAction() { | ||
super(); | ||
setImageDescriptor(UiPlugin.getDefault().getImageDescriptor( | ||
org.teiid.designer.transformation.ui.PluginConstants.Images.CREATE_MATERIALIZED_VIEWS_ICON)); | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
@Override | ||
public boolean isApplicable( final ISelection selection ) { | ||
return isValidSelection(selection); | ||
} | ||
|
||
/** | ||
* Valid selections include only Virtual Relational Tables. | ||
* | ||
* @return | ||
* @since 4.1 | ||
*/ | ||
@Override | ||
protected boolean isValidSelection( final ISelection selection ) { | ||
boolean isValid = true; | ||
if (SelectionUtilities.isEmptySelection(selection) || !SelectionUtilities.isAllEObjects(selection)) isValid = false; | ||
|
||
if (isValid ) { | ||
final Collection objs = SelectionUtilities.getSelectedEObjects(selection); | ||
final Iterator selections = objs.iterator(); | ||
while (selections.hasNext() && isValid) { | ||
final EObject next = (EObject)selections.next(); | ||
|
||
if ( isRelationalVirtualTable(next) && TransformationHelper.isVirtualSqlTable(next) ) { | ||
isValid = true; | ||
} else isValid = false; | ||
|
||
// stop processing if no longer valid: | ||
if (!isValid) break; | ||
} // endwhile -- all selected | ||
} else isValid = false; | ||
|
||
return isValid; | ||
} | ||
|
||
private boolean isRelationalVirtualTable( EObject eObject ) { | ||
// Do a quick object check | ||
if( TransformationHelper.isVirtualSqlTable(eObject)) { | ||
// make sure it's a virtual relational model | ||
final Resource resource = eObject.eResource(); | ||
if (resource != null ) { | ||
ModelResource mr = ModelUtilities.getModelResource(resource, true); | ||
return ModelIdentifier.isRelationalViewModel(mr); | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public void run() { | ||
final IWorkbenchWindow iww = UiPlugin.getDefault().getCurrentWorkbenchWindow(); | ||
|
||
// Present the user a dialog to select or create a new physical relational model to store the materialized views in | ||
// | ||
// EObject firstEObj = (EObject)SelectionUtilities.getSelectedEObjects(getSelection()).get(0); | ||
// | ||
// boolean userCancelled = false; | ||
// | ||
// if (!ModelEditorManager.isOpen(firstEObj)) { | ||
// // Let's get the preferenced value for auto-open-editor | ||
// String autoOpen = UiPlugin.getDefault().getPreferenceStore().getString(PluginConstants.Prefs.General.AUTO_OPEN_EDITOR_IF_NEEDED); | ||
// // if the preference is to auto-open, then set forceOpen so we don't prompt the user | ||
// boolean forceOpen = false; | ||
// if (autoOpen.equals(MessageDialogWithToggle.ALWAYS)) { | ||
// forceOpen = true; | ||
// } else if (autoOpen.equals(MessageDialogWithToggle.NEVER)) { | ||
// forceOpen = false; | ||
// } | ||
// | ||
// if (!forceOpen) { | ||
// // can't modify a property value on an EObject if it's ModelEditor is not open. | ||
// Shell shell = UiPlugin.getDefault().getCurrentWorkbenchWindow().getShell(); | ||
// MessageDialogWithToggle tDialog = MessageDialogWithToggle.openYesNoCancelQuestion(shell, | ||
// OPEN_EDITOR_TITLE, | ||
// OPEN_EDITOR_MESSAGE, | ||
// ALWAY_FORCE_OPEN_MESSAGE, | ||
// false, | ||
// UiPlugin.getDefault().getPreferenceStore(), | ||
// PluginConstants.Prefs.General.AUTO_OPEN_EDITOR_IF_NEEDED); | ||
// int result = tDialog.getReturnCode(); | ||
// switch (result) { | ||
// // yes, ok | ||
// case IDialogConstants.YES_ID: | ||
// case IDialogConstants.OK_ID: | ||
// forceOpen = true; | ||
// break; | ||
// // no | ||
// case IDialogConstants.NO_ID: | ||
// forceOpen = false; | ||
// userCancelled = true; | ||
// break; | ||
// } | ||
// } | ||
// | ||
// if (forceOpen) { | ||
// ModelEditorManager.open(firstEObj, true); | ||
// } | ||
// } | ||
// if( userCancelled ) { | ||
// return; | ||
// | ||
// } | ||
|
||
final CreatePojoWizard wizard = new CreatePojoWizard(); | ||
wizard.init(iww.getWorkbench(), new StructuredSelection(SelectionUtilities.getSelectedObjects(getSelection()))); | ||
final WizardDialog dialog = new WizardDialog(wizard.getShell(), wizard); | ||
final int rc = dialog.open(); | ||
|
||
if( rc == Window.OK ) { | ||
|
||
} | ||
|
||
//runAsJob(selectedTables); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.