Search in sources :

Example 1 with WSMenu

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()));
        }
    }
}
Also used : WSGetStoredProcedure(com.amalto.workbench.webservices.WSGetStoredProcedure) WSMenuPK(com.amalto.workbench.webservices.WSMenuPK) WSGetTransformerV2(com.amalto.workbench.webservices.WSGetTransformerV2) WSStoredProcedurePK(com.amalto.workbench.webservices.WSStoredProcedurePK) XObjectEditorInput(com.amalto.workbench.providers.XObjectEditorInput) URL(java.net.URL) WSView(com.amalto.workbench.webservices.WSView) WSGetDataModel(com.amalto.workbench.webservices.WSGetDataModel) WSDataCluster(com.amalto.workbench.webservices.WSDataCluster) WSDataClusterPK(com.amalto.workbench.webservices.WSDataClusterPK) TMDMService(com.amalto.workbench.webservices.TMDMService) WSRoutingRule(com.amalto.workbench.webservices.WSRoutingRule) WSStoredProcedure(com.amalto.workbench.webservices.WSStoredProcedure) WSGetView(com.amalto.workbench.webservices.WSGetView) WSGetMenu(com.amalto.workbench.webservices.WSGetMenu) WSRoutingRulePK(com.amalto.workbench.webservices.WSRoutingRulePK) WSGetRoutingRule(com.amalto.workbench.webservices.WSGetRoutingRule) WSMenu(com.amalto.workbench.webservices.WSMenu) WSDataModel(com.amalto.workbench.webservices.WSDataModel) WSGetDataCluster(com.amalto.workbench.webservices.WSGetDataCluster) WSTransformerV2(com.amalto.workbench.webservices.WSTransformerV2) WSTransformerV2PK(com.amalto.workbench.webservices.WSTransformerV2PK) WSDataModelPK(com.amalto.workbench.webservices.WSDataModelPK) WSViewPK(com.amalto.workbench.webservices.WSViewPK)

Example 2 with WSMenu

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()));
    }
}
Also used : WSMenu(com.amalto.workbench.webservices.WSMenu)

Example 3 with WSMenu

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);
    }
}
Also used : ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) ModifyListener(org.eclipse.swt.events.ModifyListener) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Label(org.eclipse.swt.widgets.Label) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Viewer(org.eclipse.jface.viewers.Viewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) EImage(com.amalto.workbench.image.EImage) Image(org.eclipse.swt.graphics.Image) ModifyEvent(org.eclipse.swt.events.ModifyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) List(org.eclipse.swt.widgets.List) ArrayList(java.util.ArrayList) WSMenu(com.amalto.workbench.webservices.WSMenu) Menu(org.eclipse.swt.widgets.Menu) WSMenuEntry(com.amalto.workbench.webservices.WSMenuEntry) Composite(org.eclipse.swt.widgets.Composite) WSMenuMenuEntriesDescriptions(com.amalto.workbench.webservices.WSMenuMenuEntriesDescriptions) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) IMenuListener(org.eclipse.jface.action.IMenuListener) WSMenu(com.amalto.workbench.webservices.WSMenu) GridData(org.eclipse.swt.layout.GridData) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) TreeObject(com.amalto.workbench.models.TreeObject) DropTarget(org.eclipse.swt.dnd.DropTarget) IMenuManager(org.eclipse.jface.action.IMenuManager) LabelProvider(org.eclipse.jface.viewers.LabelProvider) Separator(org.eclipse.jface.action.Separator)

Example 4 with WSMenu

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));
    }
}
Also used : WSMenu(com.amalto.workbench.webservices.WSMenu) EObject(org.eclipse.emf.ecore.EObject) WSMenuE(org.talend.mdm.repository.model.mdmserverobject.WSMenuE) WSMenuEntryE(org.talend.mdm.repository.model.mdmserverobject.WSMenuEntryE) WSMenuEntry(com.amalto.workbench.webservices.WSMenuEntry) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 5 with WSMenu

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()));
    }
}
Also used : WSMenu(com.amalto.workbench.webservices.WSMenu)

Aggregations

WSMenu (com.amalto.workbench.webservices.WSMenu)8 TreeObject (com.amalto.workbench.models.TreeObject)3 TMDMService (com.amalto.workbench.webservices.TMDMService)3 WSDataCluster (com.amalto.workbench.webservices.WSDataCluster)3 WSDataClusterPK (com.amalto.workbench.webservices.WSDataClusterPK)3 WSDataModel (com.amalto.workbench.webservices.WSDataModel)3 WSDataModelPK (com.amalto.workbench.webservices.WSDataModelPK)3 WSGetDataCluster (com.amalto.workbench.webservices.WSGetDataCluster)3 WSGetDataModel (com.amalto.workbench.webservices.WSGetDataModel)3 WSGetMenu (com.amalto.workbench.webservices.WSGetMenu)3 WSGetRoutingRule (com.amalto.workbench.webservices.WSGetRoutingRule)3 WSGetStoredProcedure (com.amalto.workbench.webservices.WSGetStoredProcedure)3 WSGetTransformerV2 (com.amalto.workbench.webservices.WSGetTransformerV2)3 WSGetView (com.amalto.workbench.webservices.WSGetView)3 WSMenuEntry (com.amalto.workbench.webservices.WSMenuEntry)3 WSMenuPK (com.amalto.workbench.webservices.WSMenuPK)3 WSRoutingRule (com.amalto.workbench.webservices.WSRoutingRule)3 WSRoutingRulePK (com.amalto.workbench.webservices.WSRoutingRulePK)3 WSStoredProcedure (com.amalto.workbench.webservices.WSStoredProcedure)3 WSStoredProcedurePK (com.amalto.workbench.webservices.WSStoredProcedurePK)3