-
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.
TEIIDDES-2098 Added New... drop-down action to Model Explorer Toolbar
* Includes New Project, New VDB and New XXXXX Model actions
- Loading branch information
Showing
11 changed files
with
231 additions
and
0 deletions.
There are no files selected for viewing
Binary file added
BIN
+477 Bytes
plugins/org.teiid.designer.ui/icons/full/obj16/new-model-project.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
+631 Bytes
plugins/org.teiid.designer.ui/icons/full/obj16/new-source-model.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
+682 Bytes
plugins/org.teiid.designer.ui/icons/full/obj16/new-web-service-model.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
+626 Bytes
plugins/org.teiid.designer.ui/icons/full/obj16/new-xml-document-model.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
194 changes: 194 additions & 0 deletions
194
plugins/org.teiid.designer.ui/src/org/teiid/designer/ui/explorer/ModelExplorerNewAction.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,194 @@ | ||
package org.teiid.designer.ui.explorer; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Properties; | ||
|
||
import org.eclipse.core.runtime.IStatus; | ||
import org.eclipse.jface.action.Action; | ||
import org.eclipse.jface.action.ActionContributionItem; | ||
import org.eclipse.jface.action.IAction; | ||
import org.eclipse.jface.action.IMenuCreator; | ||
import org.eclipse.jface.dialogs.MessageDialog; | ||
import org.eclipse.jface.viewers.ISelection; | ||
import org.eclipse.jface.viewers.IStructuredSelection; | ||
import org.eclipse.jface.viewers.StructuredSelection; | ||
import org.eclipse.jface.window.Window; | ||
import org.eclipse.jface.wizard.WizardDialog; | ||
import org.eclipse.swt.SWT; | ||
import org.eclipse.swt.widgets.Control; | ||
import org.eclipse.swt.widgets.Menu; | ||
import org.eclipse.ui.IWorkbenchWindow; | ||
import org.teiid.designer.metamodels.core.ModelType; | ||
import org.teiid.designer.ui.PluginConstants; | ||
import org.teiid.designer.ui.UiConstants; | ||
import org.teiid.designer.ui.UiPlugin; | ||
import org.teiid.designer.ui.common.product.ProductCustomizerMgr; | ||
import org.teiid.designer.ui.viewsupport.DesignerPropertiesUtil; | ||
import org.teiid.designer.ui.viewsupport.IPropertiesContext; | ||
import org.teiid.designer.ui.viewsupport.ModelerUiViewUtils; | ||
import org.teiid.designer.ui.wizards.NewModelWizard; | ||
import org.teiid.designer.ui.wizards.NewModelWizardInput; | ||
|
||
public class ModelExplorerNewAction extends Action implements IMenuCreator{ | ||
static final String RELATIONAL = "Relational"; //$NON-NLS-1$ | ||
static final String XML = "XML"; //$NON-NLS-1$ | ||
static final String XML_SCHEMA = "XML Schema (XSD)"; //$NON-NLS-1$ | ||
static final String WEB_SERVICE = "Web Service"; //$NON-NLS-1$ | ||
static final String FUNCTION = "Function"; //$NON-NLS-1$ | ||
|
||
private List<IAction> actions; | ||
|
||
|
||
|
||
public ModelExplorerNewAction() { | ||
super("", SWT.DROP_DOWN); | ||
setImageDescriptor(UiPlugin.getDefault().getImageDescriptor(PluginConstants.Images.NEW_MODEL_PROJECT_ICON)); | ||
actions = createActions(); | ||
setMenuCreator(this); | ||
|
||
setToolTipText("New..."); //$NON-NLS-1$ | ||
} | ||
|
||
@Override | ||
public void run() { | ||
// TODO Auto-generated method stub | ||
ModelerUiViewUtils.launchWizard("newModelProject", new StructuredSelection(), new Properties(), false); //$NON-NLS-1$ | ||
} | ||
|
||
/** | ||
* Helper method that wraps the given action in an ActionContributionItem | ||
* and then adds it to the given menu. | ||
* | ||
* @param parent | ||
* The menu to which the given action is to be added | ||
* @param action | ||
* The action that is to be added to the given menu | ||
*/ | ||
protected void addActionToMenu(Menu parent, IAction action) { | ||
ActionContributionItem item = new ActionContributionItem(action); | ||
item.fill(parent, -1); | ||
} | ||
|
||
/** | ||
* @return A list of actions that can switch to one of the supported layout | ||
* modes | ||
*/ | ||
protected List<IAction> createActions() { | ||
ArrayList<IAction> list = new ArrayList<IAction>(); | ||
|
||
list.add( new Action("New Model Project", UiPlugin.getDefault().getImageDescriptor(PluginConstants.Images.NEW_MODEL_PROJECT_ICON)) { | ||
|
||
@Override | ||
public void run() { | ||
ModelerUiViewUtils.launchWizard("newModelProject", new StructuredSelection(), new Properties(), false); //$NON-NLS-1$ | ||
} | ||
|
||
}); | ||
|
||
list.add( new Action("New Source Model", UiPlugin.getDefault().getImageDescriptor(PluginConstants.Images.NEW_SOURCE_MODEL_ICON)) { | ||
|
||
@Override | ||
public void run() { | ||
launchNewModelWizard(ModelType.PHYSICAL_LITERAL, RELATIONAL, new Properties()); | ||
} | ||
|
||
}); | ||
list.add( new Action("New View Model", UiPlugin.getDefault().getImageDescriptor(PluginConstants.Images.NEW_VIEW_MODEL_ICON)) { | ||
|
||
@Override | ||
public void run() { | ||
launchNewModelWizard(ModelType.VIRTUAL_LITERAL, RELATIONAL, new Properties()); | ||
} | ||
|
||
}); | ||
list.add( new Action("New Web Service Model", UiPlugin.getDefault().getImageDescriptor(PluginConstants.Images.NEW_WEB_SERVICE_MODEL_ICON)) { | ||
|
||
@Override | ||
public void run() { | ||
launchNewModelWizard(ModelType.VIRTUAL_LITERAL, WEB_SERVICE, new Properties()); | ||
} | ||
|
||
}); | ||
list.add( new Action("New XML Document Model", UiPlugin.getDefault().getImageDescriptor(PluginConstants.Images.NEW_XML_DOCUMENT_MODEL_ICON)) { | ||
|
||
@Override | ||
public void run() { | ||
launchNewModelWizard(ModelType.VIRTUAL_LITERAL, XML, new Properties()); | ||
} | ||
|
||
}); | ||
list.add( new Action("New VDB", UiPlugin.getDefault().getImageDescriptor(PluginConstants.Images.NEW_VDB_ICON)) { | ||
|
||
@Override | ||
public void run() { | ||
ModelerUiViewUtils.launchWizard("newVdbWizard", new StructuredSelection(), new Properties(), false); //$NON-NLS-1$ | ||
} | ||
|
||
}); | ||
|
||
return list; | ||
} | ||
|
||
@Override | ||
public void dispose() { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
private Menu fillMenu(Menu menu) { | ||
for (IAction action : actions) { | ||
addActionToMenu(menu, action); | ||
} | ||
|
||
setEnabled(!actions.isEmpty()); | ||
|
||
return menu; | ||
} | ||
|
||
/** | ||
* @see org.eclipse.jface.action.IMenuCreator#getMenu(Control) | ||
*/ | ||
public Menu getMenu(Control parent) { | ||
return fillMenu(new Menu(parent)); | ||
} | ||
|
||
/** | ||
* @see org.eclipse.jface.action.IMenuCreator#getMenu(Menu) | ||
*/ | ||
public Menu getMenu(Menu parent) { | ||
return fillMenu(new Menu(parent)); | ||
} | ||
|
||
void launchNewModelWizard(ModelType type, String modelClass, Properties props) { | ||
final IWorkbenchWindow iww = UiPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow(); | ||
boolean successful = false; | ||
try { | ||
|
||
; | ||
NewModelWizard wizard = new NewModelWizard(new NewModelWizardInput(modelClass, type, null), props); | ||
|
||
String viewId = ProductCustomizerMgr.getInstance().getProductCharacteristics().getPrimaryNavigationViewId(); | ||
ISelection theSelection = iww.getSelectionService().getSelection(viewId); | ||
|
||
wizard.init(iww.getWorkbench(), (IStructuredSelection)theSelection); | ||
WizardDialog dialog = new WizardDialog(iww.getShell(), wizard); | ||
wizard.updateForProperties(); | ||
|
||
String openProjectStatus = DesignerPropertiesUtil.getProjectStatus(props); | ||
if( openProjectStatus == null || !IPropertiesContext.NO_OPEN_PROJECT.equalsIgnoreCase(openProjectStatus) ){ | ||
int result = dialog.open(); | ||
if (result == Window.OK) { | ||
successful = true; | ||
} | ||
} else { | ||
return; | ||
} | ||
} catch (Exception e) { | ||
UiConstants.Util.log(IStatus.ERROR, e, e.getMessage()); | ||
MessageDialog.openError(iww.getShell(), "New Model Error", e.getMessage()); | ||
} finally { | ||
notifyResult(successful); | ||
} | ||
} | ||
} |
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