Search in sources :

Example 1 with XObjectEditorInput

use of com.amalto.workbench.providers.XObjectEditorInput in project tmdm-studio-se by Talend.

the class AddBrowseItemsWizard method refreshEditorContent.

private boolean refreshEditorContent(TreeObject obj) {
    IEditorInput xobjectEditorinput = new XObjectEditorInput(obj, obj.getDisplayName());
    final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    IEditorPart currentEditor = activePage.findEditor(xobjectEditorinput);
    if (currentEditor != null) {
        List<IEditorPart> editors = Arrays.asList(activePage.getDirtyEditors());
        activePage.closeEditor(currentEditor, false);
        if (editors.contains(currentEditor)) {
            return true;
        }
    }
    return false;
}
Also used : XObjectEditorInput(com.amalto.workbench.providers.XObjectEditorInput) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) IEditorInput(org.eclipse.ui.IEditorInput)

Example 2 with XObjectEditorInput

use of com.amalto.workbench.providers.XObjectEditorInput 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 3 with XObjectEditorInput

use of com.amalto.workbench.providers.XObjectEditorInput in project tmdm-studio-se by Talend.

the class ImportItemsWizard method closeOpenEditors.

private void closeOpenEditors() {
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    int length = page.getEditors().length;
    String tabEndpointAddress = Messages.ImportItemsWizard_3;
    String unserName = null;
    int j = 0;
    for (int i = 0; i < length; i++) {
        IEditorPart part = page.getEditors()[i - j];
        if (part instanceof XObjectBrowser) {
            TreeObject obj = (TreeObject) ((XObjectBrowserInput) part.getEditorInput()).getModel();
            if (obj != null) {
                tabEndpointAddress = obj.getEndpointAddress();
                unserName = obj.getUsername();
            }
        } else if (part instanceof XObjectEditor) {
            TreeObject obj = (TreeObject) ((XObjectEditorInput) part.getEditorInput()).getModel();
            if (obj != null) {
                tabEndpointAddress = obj.getEndpointAddress();
                unserName = obj.getUsername();
            }
        }
        if (serverRoot != null) {
            if (serverRoot.getEndpointAddress().equals(tabEndpointAddress) && serverRoot.getUsername().equals(unserName)) {
                if (part.isDirty() && isSaveModifiedEditor(part.getTitle())) {
                    part.doSave(new NullProgressMonitor());
                }
                page.closeEditor(part, false);
                j++;
            }
        }
    }
}
Also used : XObjectBrowser(com.amalto.workbench.editors.XObjectBrowser) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) TreeObject(com.amalto.workbench.models.TreeObject) XObjectEditorInput(com.amalto.workbench.providers.XObjectEditorInput) IEditorPart(org.eclipse.ui.IEditorPart) XObjectEditor(com.amalto.workbench.editors.XObjectEditor)

Example 4 with XObjectEditorInput

use of com.amalto.workbench.providers.XObjectEditorInput in project tmdm-studio-se by Talend.

the class AddBrowseItemsWizard method newBrowseItemView.

protected void newBrowseItemView(String browseItem) {
    for (XSDElementDeclaration decl : declList) {
        String fullName = BROWSE_ITEMS + decl.getName();
        if (fullName.equals(browseItem)) {
            TreeParent serverRoot = page.getXObject().getServerRoot();
            TreeParent serverFolder = serverRoot.findServerFolder(TreeObject.VIEW);
            TreeObject obj = serverFolder.findObject(TreeObject.VIEW, browseItem);
            if (obj != null) {
                IEditorInput xobjectEditorinput = new XObjectEditorInput(obj, obj.getDisplayName());
                final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
                IEditorPart currentEditor = activePage.findEditor(xobjectEditorinput);
                if (currentEditor != null) {
                    // editor is opened
                    if (MessageDialog.openConfirm(this.getShell(), Messages.Warning, Messages.AddBrowseItemsWizard_DuplicatedView)) {
                        refreshEditorContent(obj);
                    } else {
                        break;
                    }
                }
            }
            obj = createNewTreeObject(decl, browseItem);
            TreeParent folder = obj.findServerFolder(obj.getType());
            folder.addChild(obj);
        }
    }
}
Also used : TreeParent(com.amalto.workbench.models.TreeParent) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) TreeObject(com.amalto.workbench.models.TreeObject) XObjectEditorInput(com.amalto.workbench.providers.XObjectEditorInput) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) IEditorInput(org.eclipse.ui.IEditorInput)

Aggregations

XObjectEditorInput (com.amalto.workbench.providers.XObjectEditorInput)4 IEditorPart (org.eclipse.ui.IEditorPart)3 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)3 TreeObject (com.amalto.workbench.models.TreeObject)2 IEditorInput (org.eclipse.ui.IEditorInput)2 XObjectBrowser (com.amalto.workbench.editors.XObjectBrowser)1 XObjectEditor (com.amalto.workbench.editors.XObjectEditor)1 TreeParent (com.amalto.workbench.models.TreeParent)1 TMDMService (com.amalto.workbench.webservices.TMDMService)1 WSDataCluster (com.amalto.workbench.webservices.WSDataCluster)1 WSDataClusterPK (com.amalto.workbench.webservices.WSDataClusterPK)1 WSDataModel (com.amalto.workbench.webservices.WSDataModel)1 WSDataModelPK (com.amalto.workbench.webservices.WSDataModelPK)1 WSGetDataCluster (com.amalto.workbench.webservices.WSGetDataCluster)1 WSGetDataModel (com.amalto.workbench.webservices.WSGetDataModel)1 WSGetMenu (com.amalto.workbench.webservices.WSGetMenu)1 WSGetRoutingRule (com.amalto.workbench.webservices.WSGetRoutingRule)1 WSGetStoredProcedure (com.amalto.workbench.webservices.WSGetStoredProcedure)1 WSGetTransformerV2 (com.amalto.workbench.webservices.WSGetTransformerV2)1 WSGetView (com.amalto.workbench.webservices.WSGetView)1