use of com.amalto.workbench.webservices.WSMenu in project tmdm-studio-se by Talend.
the class EditXObjectAction method run.
@Override
public void run() {
try {
super.run();
if (xobject == null || !xobject.isXObject()) {
return;
}
// Access to server and get port
TMDMService service = Util.getMDMService(new URL(xobject.getEndpointAddress()), xobject.getUsername(), xobject.getPassword());
switch(xobject.getType()) {
case TreeObject.DATA_MODEL:
WSDataModel wsDataModel = service.getDataModel(new WSGetDataModel((WSDataModelPK) xobject.getWsKey()));
xobject.setWsObject(wsDataModel);
// XSDEditorUtil.openDataModel(xobject, false);
return;
case TreeObject.VIEW:
WSView wsView = service.getView(new WSGetView((WSViewPK) xobject.getWsKey()));
xobject.setWsObject(wsView);
break;
case TreeObject.DATA_CLUSTER:
WSDataCluster wsDataCluster = service.getDataCluster(new WSGetDataCluster((WSDataClusterPK) xobject.getWsKey()));
xobject.setWsObject(wsDataCluster);
break;
case TreeObject.STORED_PROCEDURE:
WSStoredProcedure wsStoredProcedure = service.getStoredProcedure(new WSGetStoredProcedure((WSStoredProcedurePK) xobject.getWsKey()));
xobject.setWsObject(wsStoredProcedure);
break;
case TreeObject.ROUTING_RULE:
WSRoutingRule wsRoutingRule = service.getRoutingRule(new WSGetRoutingRule((WSRoutingRulePK) xobject.getWsKey()));
xobject.setWsObject(wsRoutingRule);
break;
case TreeObject.TRANSFORMER:
WSTransformerV2 wsTranformer = service.getTransformerV2(new WSGetTransformerV2((WSTransformerV2PK) xobject.getWsKey()));
xobject.setWsObject(wsTranformer);
break;
case TreeObject.MENU:
WSMenu wsMenu = service.getMenu(new WSGetMenu((WSMenuPK) xobject.getWsKey()));
xobject.setWsObject(wsMenu);
break;
case TreeObject.SERVICE_CONFIGURATION:
break;
case TreeObject.JOB_REGISTRY:
// System.out.println("JOB_REGISTRY "+ xobject.getDisplayName());
break;
case TreeObject.JOB:
// System.out.println("JOB "+ xobject.getDisplayName()+" "+xobject.getWsKey());
xobject.setWsObject(xobject.getDisplayName());
break;
case TreeObject.ROLE:
if (exAdapter != null) {
exAdapter.run(service, xobject);
}
break;
case TreeObject.RESOURCES:
case TreeObject.CUSTOM_TYPE:
case TreeObject.DATA_MODEL_RESOURCE:
case TreeObject.DATA_MODEL_TYPES_RESOURCE:
case TreeObject.CUSTOM_TYPES_RESOURCE:
case TreeObject.PICTURES_RESOURCE:
break;
default:
MessageDialog.openError(getShell(), Messages._Error, Messages.bind(Messages.EditXObjectAction_ErrorMsg1, IConstants.TALEND, xobject.getType()));
return;
}
if (page == null) {
this.page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
}
this.page.openEditor(new XObjectEditorInput(xobject, xobject.getDisplayName()), // $NON-NLS-1$
"com.amalto.workbench.editors.XObjectEditor");
} catch (Exception e) {
log.error(e.getMessage(), e);
if (!Util.handleConnectionException(getShell(), e, Messages.EditXObjectAction_ErrorMsg2)) {
MessageDialog.openError(getShell(), Messages._Error, Messages.bind(Messages.EditXObjectAction_ErrorMsg2, e.getLocalizedMessage()));
}
}
}
use of com.amalto.workbench.webservices.WSMenu in project tmdm-studio-se by Talend.
the class MenuMainPage method refreshData.
// createCharacteristicsContent
@Override
protected void refreshData() {
try {
// System.out.println("refreshData() ");
if (this.comitting) {
return;
}
this.refreshing = true;
WSMenu wsMenu = (WSMenu) (getXObject().getWsObject());
// $NON-NLS-1$
descriptionText.setText(wsMenu.getDescription() == null ? "" : wsMenu.getDescription());
menuTree.setInput(wsMenu);
this.refreshing = false;
} catch (Exception e) {
log.error(e.getMessage(), e);
MessageDialog.openError(this.getSite().getShell(), Messages.MenuMainPage_ErrorRefreshingPage, Messages.bind(Messages.MenuMainPage_ErrorRefreshingPageXX, e.getLocalizedMessage()));
}
}
use of com.amalto.workbench.webservices.WSMenu in project tmdm-studio-se by Talend.
the class MenuMainPage method createCharacteristicsContent.
@Override
protected void createCharacteristicsContent(FormToolkit toolkit, Composite mainComposite) {
try {
// description
Label descriptionLabel = toolkit.createLabel(mainComposite, Messages.MenuMainPage_Description, SWT.NULL);
descriptionLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 1, 1));
// $NON-NLS-1$
descriptionText = toolkit.createText(mainComposite, "", SWT.BORDER);
descriptionText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
((GridData) descriptionText.getLayoutData()).minimumHeight = 30;
descriptionText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
if (refreshing) {
return;
}
markDirtyWithoutCommit();
}
});
// Util.createCompDropTarget(descriptionText);
// make the Page window a DropTarget - we need to dispose it
windowTarget = new DropTarget(this.getPartControl(), DND.DROP_MOVE);
windowTarget.setTransfer(new Transfer[] { TextTransfer.getInstance() });
windowTarget.addDropListener(new DCDropTargetListener());
Composite composite = toolkit.createComposite(mainComposite, SWT.BORDER);
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
composite.setLayout(new GridLayout(1, false));
menuTree = new TreeViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
menuTree.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
((GridData) menuTree.getControl().getLayoutData()).heightHint = 150;
menuTree.setContentProvider(new ITreeContentProvider() {
public void dispose() {
}
public Object[] getChildren(Object parentElement) {
if (parentElement instanceof TreeEntry) {
WSMenuEntry wsEntry = ((TreeEntry) parentElement).getWSMenuEntry();
if (wsEntry.getSubMenus() != null) {
TreeEntry[] children = new TreeEntry[wsEntry.getSubMenus().size()];
for (int i = 0; i < wsEntry.getSubMenus().size(); i++) {
children[i] = new TreeEntry((TreeEntry) parentElement, wsEntry.getSubMenus().get(i));
}
return children;
}
return null;
}
if (parentElement instanceof WSMenu) {
// the root
java.util.List<WSMenuEntry> menuEntries = ((WSMenu) parentElement).getMenuEntries();
if (menuEntries != null) {
TreeEntry[] children = new TreeEntry[menuEntries.size()];
for (int i = 0; i < menuEntries.size(); i++) {
children[i] = new TreeEntry(null, menuEntries.get(i));
}
return children;
}
return null;
}
// ??!!?
return null;
}
public Object[] getElements(Object inputElement) {
return getChildren(inputElement);
}
public Object getParent(Object element) {
return null;
}
public boolean hasChildren(Object element) {
return ((getChildren(element) == null) || (getChildren(element).length > 0));
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
menuTree.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
WSMenuEntry wsMenuEntry = ((TreeEntry) element).getWSMenuEntry();
// $NON-NLS-1$
StringBuffer label = new StringBuffer(wsMenuEntry.getId() + " - ");
for (WSMenuMenuEntriesDescriptions description : wsMenuEntry.getDescriptions()) {
// $NON-NLS-1$//$NON-NLS-2$
label.append("[").append(description.getLanguage()).append(": ").append(description.getLabel()).append(// $NON-NLS-1$
"] ");
}
if (label.length() > 200) {
// $NON-NLS-1$
return label.substring(0, 197) + "...";
}
return label.toString();
}
@Override
public Image getImage(Object element) {
return ImageCache.getCreatedImage(EImage.MENU.getPath());
}
});
menuTreeMgr = new MenuManager();
menuTreeMgr.setRemoveAllWhenShown(true);
menuTreeMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
IStructuredSelection selection = ((IStructuredSelection) menuTree.getSelection());
if ((selection == null) || (selection.getFirstElement() == null)) {
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
return;
}
// TreeEntry entry = (TreeEntry)selection.getFirstElement();
menuTreeMgr.add(new TreeEntryEditAction(menuTree));
menuTreeMgr.add(new TreeEntryAddAction(menuTree, LOCATION_BEFORE));
menuTreeMgr.add(new TreeEntryAddAction(menuTree, LOCATION_AFTER));
menuTreeMgr.add(new TreeEntryAddAction(menuTree, LOCATION_UNDER));
menuTreeMgr.add(new TreeEntryDeleteAction(menuTree));
menuTreeMgr.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
}
});
menuTree.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
(new TreeEntryEditAction(menuTree)).run();
}
});
Menu menu = menuTreeMgr.createContextMenu(menuTree.getControl());
menuTree.getControl().setMenu(menu);
getSite().registerContextMenu(menuTreeMgr, menuTree);
refreshData();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
use of com.amalto.workbench.webservices.WSMenu in project tmdm-studio-se by Talend.
the class Bean2EObjUtilTest method testConvertFromBean2EObj.
/**
* Test method for {@link Bean2EObjUtil#convertFromBean2EObj(java.lang.Object)}.
*/
@Test
public void testConvertFromBean2EObj() {
WSMenu menu = new WSMenu();
initBean(menu);
Bean2EObjUtil util = Bean2EObjUtil.getInstance();
util.registerClassMap(WSMenu.class);
EObject eObject = util.convertFromBean2EObj(menu, null);
assertNotNull(eObject);
WSMenuE menuE = (WSMenuE) eObject;
//
assertEquals(menu.getName(), menuE.getName());
assertEquals(menu.getDescription(), menuE.getDescription());
//
List<WSMenuEntry> menuEntries = menu.getMenuEntries();
EList<WSMenuEntryE> menuEntriesE = menuE.getMenuEntries();
for (int i = 0; i < menuEntries.size(); i++) {
checkMenuEntry(menuEntries.get(i), menuEntriesE.get(i));
}
}
use of com.amalto.workbench.webservices.WSMenu in project tmdm-studio-se by Talend.
the class MenuMainPage method commit.
@Override
protected void commit() {
try {
// System.out.println("commit() ROLE\n"+role.toString());
if (this.refreshing) {
return;
}
this.comitting = true;
// commit as we go
WSMenu wsMenu = ((WSMenu) getXObject().getWsObject());
wsMenu.setDescription(descriptionText.getText());
this.comitting = false;
} catch (Exception e) {
log.error(e.getMessage(), e);
MessageDialog.openError(this.getSite().getShell(), Messages.MenuMainPage_ErrorCommitingPage, Messages.bind(Messages.MenuMainPage_ErrorCommitingPageXX, e.getLocalizedMessage()));
}
}
Aggregations