Search in sources :

Example 1 with RepositoryEditorInput

use of org.talend.core.repository.ui.editor.RepositoryEditorInput in project tdi-studio-se by Talend.

the class SaveAsBusinessModelAction method run.

@Override
public void run() {
    SaveAsBusinessModelWizard businessModelWizard = new SaveAsBusinessModelWizard(editorPart);
    WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), businessModelWizard);
    if (dlg.open() == Window.OK) {
        try {
            BusinessProcessItem businessProcessItem = businessModelWizard.getBusinessProcessItem();
            IRepositoryNode repositoryNode = RepositoryNodeUtilities.getRepositoryNode(businessProcessItem.getProperty().getId(), false);
            // because step1, the fresh will unload the resource(EMF), so, assign a new one...
            businessProcessItem = (BusinessProcessItem) repositoryNode.getObject().getProperty().getItem();
            IWorkbenchPage page = getActivePage();
            DiagramResourceManager diagramResourceManager = new DiagramResourceManager(page, new NullProgressMonitor());
            IFile file = businessModelWizard.getTempFile();
            // Set readonly to false since created job will always be editable.
            RepositoryEditorInput newBusinessModelEditorInput = new RepositoryEditorInput(file, businessProcessItem);
            newBusinessModelEditorInput.setRepositoryNode(repositoryNode);
            // here really do the normal save as function
            IDocumentProvider provider = ((BusinessDiagramEditor) this.editorPart).getDocumentProvider();
            provider.aboutToChange(newBusinessModelEditorInput);
            provider.saveDocument(null, newBusinessModelEditorInput, provider.getDocument(this.editorPart.getEditorInput()), true);
            provider.changed(newBusinessModelEditorInput);
            // copy back from the *.business_diagram file to *.item file.
            // @see:BusinessDiagramEditor.doSave(IProgressMonitor progressMonitor)
            diagramResourceManager.updateFromResource(businessProcessItem, newBusinessModelEditorInput.getFile());
            // notice: here, must save it, save the item to disk, otherwise close the editor
            // without any modification, there won't save the
            // model again, so, will lost the graphic when reopen it.
            ProxyRepositoryFactory.getInstance().save(businessProcessItem);
            // close the old editor
            page.closeEditor(this.editorPart, false);
            // open the new editor, because at the same time, there will update the jobSetting/componentSetting view
            IEditorPart openEditor = page.openEditor(newBusinessModelEditorInput, BusinessDiagramEditor.ID, true);
        } catch (Exception e) {
            MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", "Business model could not be saved" + " : " + e.getMessage());
            ExceptionHandler.process(e);
        }
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) RepositoryEditorInput(org.talend.core.repository.ui.editor.RepositoryEditorInput) IRepositoryNode(org.talend.repository.model.IRepositoryNode) BusinessDiagramEditor(org.talend.designer.business.model.business.diagram.part.BusinessDiagramEditor) BusinessProcessItem(org.talend.core.model.properties.BusinessProcessItem) IEditorPart(org.eclipse.ui.IEditorPart) IDocumentProvider(org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 2 with RepositoryEditorInput

use of org.talend.core.repository.ui.editor.RepositoryEditorInput in project tdi-studio-se by Talend.

the class BusinessDiagramEditor method setInput.

@Override
public void setInput(IEditorInput input) {
    super.setInput(input);
    Object obj = input.getAdapter(RepositoryEditorInput.class);
    if (obj instanceof RepositoryEditorInput) {
        repositoryEditorInput = (RepositoryEditorInput) obj;
    }
}
Also used : RepositoryEditorInput(org.talend.core.repository.ui.editor.RepositoryEditorInput) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject)

Example 3 with RepositoryEditorInput

use of org.talend.core.repository.ui.editor.RepositoryEditorInput in project tdi-studio-se by Talend.

the class BusinessDiagramEditor method init.

@Override
public void init(final IEditorSite site, final IEditorInput editorInput) throws PartInitException {
    super.init(site, editorInput);
    if (editorInput instanceof RepositoryEditorInput) {
        RepositoryEditorInput processEditorInput = (RepositoryEditorInput) editorInput;
        processEditorInput.getItem().getProperty().eAdapters().add(dirtyListener);
    }
}
Also used : RepositoryEditorInput(org.talend.core.repository.ui.editor.RepositoryEditorInput)

Example 4 with RepositoryEditorInput

use of org.talend.core.repository.ui.editor.RepositoryEditorInput in project tdi-studio-se by Talend.

the class TalendLaunchToolbarAction method run.

/**
     * Launch the last launch, or open the launch config dialog if none.
     * 
     * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
     */
@Override
public void run(IAction action) {
    // launch the job that is selected in the repository.
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection sel = (IStructuredSelection) selection;
        Object o = sel.getFirstElement();
        if ((o instanceof RepositoryNode)) {
            RepositoryNode node = (RepositoryNode) o;
            if (node.getObject() != null && node.getObject().getRepositoryObjectType().equals(ERepositoryObjectType.PROCESS)) {
                JobLaunchShortcutManager.run(selection);
                return;
            }
        }
    }
    // launch the job that is open in editor
    if (window != null) {
        IWorkbenchPage page = window.getActivePage();
        if (page != null) {
            if (page.getActivePart() == page.getActiveEditor()) {
                IEditorPart editor = page.getActiveEditor();
                IEditorInput input = editor.getEditorInput();
                if (input instanceof RepositoryEditorInput) {
                    JobLaunchShortcutManager.run(editor);
                    return;
                }
            }
        }
    }
    ILaunchConfiguration configuration = getLastLaunch();
    if (configuration == null) {
        // MessageDialog
        // .openInformation(
        // DebugUIPlugin.getShell(),
        //                            Messages.getString("TalendLaunchToolbarAction.information"), Messages.getString("TalendLaunchToolbarAction.noAvailableItem")); //$NON-NLS-1$ //$NON-NLS-2$
        MessageDialog.openInformation(getShell(), Messages.getString("TalendLaunchToolbarAction.information"), //$NON-NLS-1$ //$NON-NLS-2$
        Messages.getString("TalendLaunchToolbarAction.noAvailableItem"));
    // DebugUITools.openLaunchConfigurationDialogOnGroup(DebugUIPlugin.getShell(), new StructuredSelection(),
    // getLaunchGroupIdentifier());
    } else {
        DebugUITools.launch(configuration, getMode());
    }
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) RepositoryEditorInput(org.talend.core.repository.ui.editor.RepositoryEditorInput) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IRepositoryObject(org.talend.core.model.repository.IRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IEditorPart(org.eclipse.ui.IEditorPart) RepositoryNode(org.talend.repository.model.RepositoryNode) IEditorInput(org.eclipse.ui.IEditorInput)

Example 5 with RepositoryEditorInput

use of org.talend.core.repository.ui.editor.RepositoryEditorInput in project tdi-studio-se by Talend.

the class StandAloneTalendJavaEditor method doSetInput.

@Override
public void doSetInput(IEditorInput input) throws CoreException {
    // Lock the process :
    IRepositoryService service = DesignerPlugin.getDefault().getRepositoryService();
    IProxyRepositoryFactory repFactory = service.getProxyRepositoryFactory();
    if (input instanceof RepositoryEditorInput) {
        rEditorInput = (RepositoryEditorInput) input;
    } else {
        FileEditorInput fileInput = (FileEditorInput) input;
        rEditorInput = new RepositoryEditorInput(fileInput.getFile(), rEditorInput.getItem());
    }
    if (rEditorInput.getRepositoryNode() == null) {
        // retrieve node
        rEditorInput.setRepositoryNode(null);
    }
    try {
        // see bug 1321
        item = (FileItem) rEditorInput.getItem();
        if (!rEditorInput.isReadOnly()) {
            if (getRepositoryFactory().getStatus(item).isPotentiallyEditable()) {
                item.getProperty().eAdapters().add(dirtyListener);
                repFactory.lock(item);
            }
        } else {
            rEditorInput.getFile().setReadOnly(true);
        }
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
    rEditorInput.getFile().refreshLocal(IResource.DEPTH_ONE, null);
    super.doSetInput(rEditorInput);
    setName();
    // only for sql template
    if (item instanceof SQLPatternItem) {
        Workspace ws = (Workspace) ResourcesPlugin.getWorkspace();
        ws.broadcastBuildEvent(item, IResourceChangeEvent.POST_CHANGE, 1);
    }
}
Also used : RepositoryEditorInput(org.talend.core.repository.ui.editor.RepositoryEditorInput) FileEditorInput(org.eclipse.ui.part.FileEditorInput) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) LoginException(org.talend.commons.exception.LoginException) InvocationTargetException(java.lang.reflect.InvocationTargetException) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryService(org.talend.repository.model.IRepositoryService) Workspace(org.eclipse.core.internal.resources.Workspace) IWorkspace(org.eclipse.core.resources.IWorkspace)

Aggregations

RepositoryEditorInput (org.talend.core.repository.ui.editor.RepositoryEditorInput)21 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)9 IFile (org.eclipse.core.resources.IFile)7 IEditorPart (org.eclipse.ui.IEditorPart)7 Item (org.talend.core.model.properties.Item)7 SQLPatternItem (org.talend.core.model.properties.SQLPatternItem)7 IEditorInput (org.eclipse.ui.IEditorInput)6 IEditorReference (org.eclipse.ui.IEditorReference)6 PartInitException (org.eclipse.ui.PartInitException)5 ICodeGeneratorService (org.talend.designer.codegen.ICodeGeneratorService)5 ECodeLanguage (org.talend.core.language.ECodeLanguage)4 CoreException (org.eclipse.core.runtime.CoreException)3 PersistenceException (org.talend.commons.exception.PersistenceException)3 BusinessProcessItem (org.talend.core.model.properties.BusinessProcessItem)3 ProcessItem (org.talend.core.model.properties.ProcessItem)3 ISQLPatternSynchronizer (org.talend.designer.codegen.ISQLPatternSynchronizer)3 ITalendSynchronizer (org.talend.designer.codegen.ITalendSynchronizer)3 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)3 IProject (org.eclipse.core.resources.IProject)2 WizardDialog (org.eclipse.jface.wizard.WizardDialog)2