use of com.amalto.workbench.availablemodel.IAvailableModel in project tmdm-studio-se by Talend.
the class DataModelMainPage method fillContextMenu.
protected void fillContextMenu(IMenuManager manager, boolean isType) {
IStructuredSelection selection;
if (!isType) {
selection = ((IStructuredSelection) viewer.getSelection());
} else {
selection = ((IStructuredSelection) typesViewer.getSelection());
}
Object[] selectedObjs = selection.toArray();
Object obj = selection.getFirstElement();
if (!isType) {
manager.add(newConceptAction);
} else {
manager.add(newComplexTypeAction);
manager.add(newSimpleTypeAction);
// add by ymli; fix the bug:0012228. Made the multiple types can be deleted.
XSDDeleteTypeDefinition deleteTypeDefinition1;
if (selectedObjs.length > 1) {
deleteTypeDefinition1 = new XSDDeleteTypeDefinition(this, true);
} else {
deleteTypeDefinition1 = new XSDDeleteTypeDefinition(this, false);
}
if (selectedObjs.length >= 1 && deleteTypeDefinition1.isTypeDefinition(selectedObjs)) {
manager.add(deleteTypeDefinition1);
}
deleteConceptWrapAction.regisExtraClassToDel(XSDComplexTypeDefinitionImpl.class);
if (selectedObjs.length > 1 && deleteConceptWrapAction.checkInDeletableType(selectedObjs)) {
deleteConceptWrapAction.prepareToDelSelectedItems(selection, viewer);
}
if (selectedObjs.length > 1 && deleteConceptWrapAction.outPutDeleteActions() != null) {
manager.add(deleteConceptWrapAction.outPutDeleteActions());
if (deleteConceptWrapAction.checkOutAllConcept(selectedObjs)) {
manager.add(newBrowseItemAction);
}
}
if (exAdapter != null && obj instanceof XSDComplexTypeDefinition && selectedObjs.length == 1) {
exAdapter.fillContextMenu(manager);
}
}
manager.add(new Separator());
if (!isType && ((selection == null) || (selection.getFirstElement() == null))) {
if (WorkbenchClipboard.getWorkbenchClipboard().getConcepts().size() > 0) {
manager.add(new Separator(ADDITIONMENUID));
// add by ymli, fix bug 0009770
// $NON-NLS-1$
String title = "";
if (WorkbenchClipboard.getWorkbenchClipboard().getConcepts().size() == 1) {
title = Messages.PasteEntityText;
} else if (WorkbenchClipboard.getWorkbenchClipboard().getConcepts().size() > 1) {
title = Messages.PasteEntitiesText;
}
XSDPasteConceptAction pasteConceptAction = new XSDPasteConceptAction(this, title);
if (pasteConceptAction.checkInPasteType()) {
manager.add(new Separator());
manager.add(pasteConceptAction);
}
}
return;
}
// Element Declaration
if (obj instanceof XSDElementDeclaration && selectedObjs.length == 1) {
// check if concept or "just" element
XSDElementDeclaration decl = (XSDElementDeclaration) obj;
boolean isConcept = Util.checkConcept(decl);
if (!Util.IsAImporedElement(decl, xsdSchema)) {
if (isConcept) {
manager.add(editConceptAction);
manager.add(deleteConceptAction);
manager.add(newBrowseItemAction);
} else {
manager.add(editElementAction);
manager.add(deleteElementAction);
}
// add by ymli. fix bug 0009770 add the copy of concepts
copyConceptAction.setText(Messages.CopyEntityText);
if (Util.checkInCopy(selectedObjs)) {
manager.add(new Separator());
manager.add(copyConceptAction);
}
/*
* boolean isMulti = false; if(WorkbenchClipboard.getWorkbenchClipboard().getConcepts().size()>1)
* isMulti = true;
*/
// $NON-NLS-1$
String title = "";
if (WorkbenchClipboard.getWorkbenchClipboard().getConcepts().size() > 1) {
title = Messages.PasteEntitiesText;
} else if (WorkbenchClipboard.getWorkbenchClipboard().getConcepts().size() == 1) {
title = Messages.PasteEntityText;
} else if (WorkbenchClipboard.getWorkbenchClipboard().getParticles().size() > 1) {
title = Messages.PasteElementsText;
} else if (WorkbenchClipboard.getWorkbenchClipboard().getParticles().size() == 1) {
title = Messages.PasteElement;
}
XSDPasteConceptAction pasteConceptAction = new XSDPasteConceptAction(this, title);
if (pasteConceptAction.checkInPasteType()) {
manager.add(pasteConceptAction);
}
manager.add(new Separator());
manager.add(newElementAction);
manager.add(new Separator());
manager.add(changeToComplexTypeAction);
manager.add(changeToSimpleTypeAction);
// add by fliu, see bugID:0009157
if (((XSDElementDeclaration) obj).getTypeDefinition() instanceof XSDSimpleTypeDefinition) {
manager.add(setFacetMsgAction);
manager.add(setAnnotationDisplayFomatAction);
}
manager.add(new Separator());
manager.add(newIdentityConstraintAction);
} else {
if (isConcept) {
manager.add(newBrowseItemAction);
}
manager.add(newElementAction);
}
// Annotations
if (!Util.IsAImporedElement(decl, xsdSchema) || !Util.IsAImporedElement(decl.getTypeDefinition(), xsdSchema)) {
setAnnotationActions2(obj, manager);
}
}
// add by rhou.fix bug 0012073: Enable to create element from sub element group
if (obj instanceof XSDModelGroup) {
manager.add(new Separator());
manager.add(getAddElementMenuForTypeClass(XSDModelGroup.class, Messages._AddElement));
manager.add(new Separator());
manager.add(changeSubElementGroupAction);
manager.add(new Separator());
manager.add(setAnnotationLabelAction);
addPasteElementAction(manager);
}
if (obj instanceof XSDAttributeUse && selectedObjs.length == 1) {
manager.add(deleteAttributeAction);
}
if (obj instanceof XSDAttributeDeclaration && selectedObjs.length == 1) {
manager.add(deleteAttributeAction);
}
if (obj instanceof XSDParticle && selectedObjs.length == 1) {
XSDTerm term = ((XSDParticle) obj).getTerm();
if (!(term instanceof XSDWildcard)) {
if (term instanceof XSDElementDeclaration) {
manager.add(editParticleAction);
if (!Util.IsAImporedElement(term, xsdSchema) || term.getContainer() instanceof XSDSchema) {
manager.add(getAddElementMenuForTypeClass(XSDParticle.class, Messages._AddElementAfter));
if (term instanceof XSDModelGroup) {
manager.add(getAddElementMenuForTypeClass(XSDModelGroup.class, Messages._AddElement));
manager.add(newGroupFromTypeAction);
}
manager.add(deleteParticleAction);
// edit by ymli. fix the bug:0011523
copyConceptAction.setText(Messages.CopyElementText);
manager.add(copyConceptAction);
if (((XSDElementDeclaration) term).getTypeDefinition() instanceof XSDComplexTypeDefinition) {
addPasteElementAction(manager);
}
manager.add(new Separator());
manager.add(changeToComplexTypeAction);
manager.add(changeToSimpleTypeAction);
// add by fliu, see bugID:0009157
manager.add(new Separator());
// Annotations
XSDTypeDefinition type = ((XSDElementDeclaration) term).getTypeDefinition();
setAnnotationActions(obj, manager);
if (((XSDElementDeclaration) term).getTypeDefinition() instanceof XSDSimpleTypeDefinition) {
manager.add(setFacetMsgAction);
manager.add(setAnnotationDisplayFomatAction);
}
// Xpath
manager.add(new Separator());
manager.add(getXPathAction);
}
}
}
}
if (obj instanceof XSDComplexTypeDefinition && selectedObjs.length == 1 && ((XSDComplexTypeDefinition) obj).getTargetNamespace() == null) {
if (!isType && !Util.IsAImporedElement((XSDParticle) obj, xsdSchema)) {
manager.add(getAddElementMenuForTypeClass(XSDComplexTypeDefinition.class, Messages._AddElement));
manager.add(newGroupFromTypeAction);
}
if (!Util.IsAImporedElement((XSDComplexTypeDefinition) obj, xsdSchema)) {
// add by rhou.fix bug 0012073: Enable to create element from sub element group
manager.add(new Separator());
manager.add(getAddElementMenuForTypeClass(XSDComplexTypeDefinition.class, Messages._AddElement));
manager.add(new Separator());
manager.add(editComplexTypeAction);
}
manager.add(setAnnotationLabelAction);
addPasteElementAction(manager);
}
if (obj instanceof XSDIdentityConstraintDefinition && selectedObjs.length == 1 && ((XSDIdentityConstraintDefinition) obj).getTargetNamespace() == null && !Util.IsAImporedElement((XSDIdentityConstraintDefinition) obj, xsdSchema)) {
manager.add(deleteIdentityConstraintAction);
manager.add(new Separator());
manager.add(newXPathAction);
}
if (obj instanceof XSDXPathDefinition && selectedObjs.length == 1 && ((XSDXPathDefinition) obj).getSchema().getTargetNamespace() == null && !Util.IsAImporedElement((XSDXPathDefinition) obj, xsdSchema)) {
manager.add(editXPathAction);
manager.add(newXPathAction);
XSDXPathDefinition xpath = (XSDXPathDefinition) obj;
if (xpath.getVariety().equals(XSDXPathVariety.FIELD_LITERAL)) {
manager.add(deleteXPathAction);
}
}
// for the anonymous simpleType
if (obj instanceof XSDSimpleTypeDefinition && selectedObjs.length == 1 && (!Util.IsAImporedElement((XSDSimpleTypeDefinition) obj, xsdSchema) || ((XSDSimpleTypeDefinition) obj).getName() == null)) {
XSDSimpleTypeDefinition typedef = (XSDSimpleTypeDefinition) obj;
manager.add(changeBaseTypeAction);
manager.add(new Separator());
if (typedef.getBaseTypeDefinition() != null) {
EList list = typedef.getBaseTypeDefinition().getValidFacets();
for (Iterator iter = list.iterator(); iter.hasNext(); ) {
String element = (String) iter.next();
manager.add(new XSDEditFacetAction(this, element));
}
}
}
if (selectedObjs.length > 1 && deleteConceptWrapAction.checkInDeletableType(selectedObjs)) {
deleteConceptWrapAction.prepareToDelSelectedItems(selection, viewer);
}
if (selectedObjs.length > 1 && deleteConceptWrapAction.checkInAllElementType(selectedObjs)) {
manager.add(newBrowseItemAction);
}
if (selectedObjs.length > 1 && deleteConceptWrapAction.outPutDeleteActions() != null) {
if (!isType) {
manager.add(deleteConceptWrapAction.outPutDeleteActions());
}
// $NON-NLS-1$
String title = "";
if (Util.checkInCopyTypeElement(selectedObjs)) {
title = Messages.CopyEntitiesText;
} else if (Util.checkInCOpyTypeParticle(selectedObjs)) {
title = Messages.CopyElements;
}
copyConceptAction.setText(title);
if (Util.checkInCopy(selectedObjs)) {
manager.add(copyConceptAction);
}
// add by ymli; fix bug:0016645
if (selectedObjs.length > 1 && isXSDParticles(selectedObjs)) {
manager.add(getAddElementMenuForTypeClass(XSDParticle.class, Messages._AddElementAfter));
}
}
if (exAdapter != null) {
exAdapter.fillContextMenu(manager, selectedObjs);
}
// available models
java.util.List<IAvailableModel> availablemodels = AvailableModelUtil.getAvailableModels(isLocalInput());
for (int i = 0; i < availablemodels.size(); i++) {
IAvailableModel model = availablemodels.get(i);
model.fillContextMenu(obj, manager, this, dataModelName);
if (i == 1) {
manager.add(new Separator());
}
}
//
manager.add(new Separator());
drillDownAdapter.addNavigationActions(manager);
// Other plug-ins can contribute there actions here
manager.add(new Separator(ADDITIONMENUID));
deleteConceptWrapAction.clearExtraClassToDel();
}
use of com.amalto.workbench.availablemodel.IAvailableModel in project tmdm-studio-se by Talend.
the class XObjectEditor method addPages.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.forms.editor.FormEditor#addPages()
*/
@Override
protected void addPages() {
updateTitle();
TreeObject xobject = (TreeObject) ((XObjectEditorInput) this.getEditorInput()).getModel();
// backup initial object
this.initialXObject = new TreeObject(xobject.getDisplayName(), xobject.getServerRoot(), xobject.getType(), xobject.getWsKey(), xobject.getWsObject(), xobject.getAdditionalInfo());
if (!xobject.isXObject()) {
return;
}
// register model listener
xobject.addListener(this);
// available models
java.util.List<IAvailableModel> availablemodels = AvailableModelUtil.getAvailableModels(isLocalInput());
for (IAvailableModel model : availablemodels) {
model.addPage(xobject, this);
}
addPageForXObject(xobject);
}
use of com.amalto.workbench.availablemodel.IAvailableModel in project tmdm-studio-se by Talend.
the class ObjectRetriever method run.
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
// $NON-NLS-1$
monitor.beginTask(Messages.bind(Messages.ObjectRetriever_TaskName, IConstants.TALEND), "admin".equals(username) ? 12 : 9);
try {
switch(parentObject.getType()) {
case TreeObject.WORKFLOW:
// $NON-NLS-1$
objectName = "WorkflowAvailableModel";
break;
case TreeObject.JOB_REGISTRY:
// $NON-NLS-1$
objectName = "JobAvailableModel";
break;
}
TMDMService service = Util.getMDMService(new URL(endpointaddress), username, password);
// commented this by jsxie to fix bug 21371
// parentObject.getServerRoot().removeChildFromUI(parentObject);
List<IAvailableModel> availablemodels = AvailableModelUtil.getAvailableModels();
for (IAvailableModel model : availablemodels) {
if (model.toString().indexOf(objectName) > 0) {
model.addTreeObjects(service, monitor, parentObject.getServerRoot());
}
}
} catch (MalformedURLException e) {
log.error(e.getMessage(), e);
} catch (XtentisException e) {
log.error(e.getMessage(), e);
}
}
use of com.amalto.workbench.availablemodel.IAvailableModel in project tmdm-studio-se by Talend.
the class DataClusterBrowserMainPage method hookContextMenu.
protected void hookContextMenu() {
MenuManager menuMgr = new MenuManager();
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
// ViewBrowserMainPage.this.fillContextMenu(manager);
manager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
manager.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, new NewItemAction(getShell(), resultsViewer));
IStructuredSelection selection = ((IStructuredSelection) resultsViewer.getSelection());
if (exAdapter != null) {
exAdapter.menuAboutToShow(manager, IWorkbenchActionConstants.MB_ADDITIONS, resultsViewer, selection, getShell(), getXObject());
}
if (selection.size() == 1) {
manager.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, new EditItemAction(getShell(), resultsViewer));
}
if (selection.size() > 0) {
manager.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, new PhysicalDeleteItemsAction(getShell(), resultsViewer));
manager.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, new LogicalDeleteItemsAction(getShell(), resultsViewer));
manager.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, new SubmitItemsAction(getShell(), resultsViewer));
}
// compare item with each other
if (selection.size() == 2) {
manager.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, new CompareItemWithEachOtherAction(getShell(), resultsViewer));
}
// available models
if (selection.size() == 1) {
java.util.List<IAvailableModel> availablemodels = AvailableModelUtil.getAvailableModels();
for (IAvailableModel model : availablemodels) {
model.menuAboutToShow(manager, DataClusterBrowserMainPage.this);
}
}
}
});
Menu menu = menuMgr.createContextMenu(resultsViewer.getControl());
resultsViewer.getControl().setMenu(menu);
getSite().registerContextMenu(menuMgr, resultsViewer);
}
use of com.amalto.workbench.availablemodel.IAvailableModel in project tmdm-studio-se by Talend.
the class XObjectBrowser method addPages.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.forms.editor.FormEditor#addPages()
*/
@Override
protected void addPages() {
try {
updateTitle();
TreeObject xobject = (TreeObject) ((XObjectBrowserInput) this.getEditorInput()).getModel();
if (!xobject.isXObject()) {
return;
}
// register model listener in order to close the browser when object is removed
xobject.addListener(this);
// available models
java.util.List<IAvailableModel> availablemodels = AvailableModelUtil.getAvailableModels(isLocalInput());
;
for (IAvailableModel model : availablemodels) {
model.addPage(xobject, this);
}
addPageForXObject(xobject);
} catch (PartInitException e) {
MessageDialog.openError(this.getSite().getShell(), Messages._Error, Messages.bind(Messages.XObjectBrowser_ErrorMsg, e.getLocalizedMessage()));
}
}
Aggregations