Search in sources :

Example 6 with PartInitException

use of org.eclipse.ui.PartInitException in project tdi-studio-se by Talend.

the class ReadRoutineAction method doRun.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
protected void doRun() {
    if (repositoryNode == null && getSelection() != null) {
        repositoryNode = (RepositoryNode) ((IStructuredSelection) getSelection()).getFirstElement();
    }
    RoutineItem routineItem = (RoutineItem) repositoryNode.getObject().getProperty().getItem();
    Property updatedProperty = null;
    try {
        updatedProperty = ProxyRepositoryFactory.getInstance().getLastVersion(new Project(ProjectManager.getInstance().getProject(routineItem)), routineItem.getProperty().getId()).getProperty();
    // repositoryNode.getObject().setProperty(updatedProperty);
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    }
    routineItem = (RoutineItem) repositoryNode.getObject().getProperty().getItem();
    try {
        openRoutineEditor(routineItem, true);
    } catch (PartInitException e) {
        MessageBoxExceptionHandler.process(e);
    } catch (SystemException e) {
        MessageBoxExceptionHandler.process(e);
    }
}
Also used : Project(org.talend.core.model.general.Project) SystemException(org.talend.commons.exception.SystemException) PersistenceException(org.talend.commons.exception.PersistenceException) RoutineItem(org.talend.core.model.properties.RoutineItem) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) PartInitException(org.eclipse.ui.PartInitException) Property(org.talend.core.model.properties.Property)

Example 7 with PartInitException

use of org.eclipse.ui.PartInitException in project tesb-studio-se by Talend.

the class RouteResourceEditorUtil method findPreferEditor.

/**
	 * find a prefer editor from all existing editors according to the
	 * fileExtensions
	 * 
	 * @param fileExtension
	 * @return
	 */
private String findPreferEditor(RouteResourceInput fileEditorInput) {
    String editorId = RouteResourceEditor.ID;
    Object underlingFile = fileEditorInput.getAdapter(IFile.class);
    if (underlingFile == null) {
        return editorId;
    }
    IEditorDescriptor ed = null;
    try {
        ed = IDE.getEditorDescriptor((IFile) underlingFile, true);
    } catch (PartInitException e) {
        return editorId;
    }
    if (ed == null) {
        return editorId;
    }
    String id = ed.getId();
    if (id == null || id.trim() == null) {
        return editorId;
    }
    return id;
}
Also used : IFile(org.eclipse.core.resources.IFile) IEditorDescriptor(org.eclipse.ui.IEditorDescriptor) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PartInitException(org.eclipse.ui.PartInitException)

Example 8 with PartInitException

use of org.eclipse.ui.PartInitException in project tdi-studio-se by Talend.

the class SQLBuilderTabComposite method createTabItem.

/**
     * Creates tab item. Changed by Marvin Wang on Feb. 24, 2012 for bug TDI-7643, for all SQLBuilderEditorComposite
     * when using <code>editorComposite.getConnParam().getQueryObject()</code> to get the query object, the query every
     * time get is the same object. Caz all <code>SQLBuilderEditorComposite</code>s use the same connection parameter.
     * 
     * @param node
     * @param connParam
     * @param isDefaultEditor
     */
private void createTabItem(RepositoryNode node, ConnectionParameters connParam, boolean isDefaultEditor) {
    //$NON-NLS-1$
    String queryStr = "";
    if (node != null) {
        CTabItem[] tabItems = tabFolder.getItems();
        for (int i = 0; i < tabItems.length; i++) {
            SQLBuilderEditorComposite editorComposite = (SQLBuilderEditorComposite) (((CTabFolder) tabItems[i].getControl()).getItems()[0]).getControl();
            // To get the different query object for each SQLBuilderEditorComposite, use the following method. The
            // queryObject is stored in <code>SQLBuilderEditorComposite.doSaveSQL()</code>
            Query query2 = editorComposite.getQueryObject();
            if ((RepositoryNodeType) node.getProperties(EProperties.CONTENT_TYPE) == RepositoryNodeType.QUERY) {
                Query query = ((QueryRepositoryObject) node.getObject()).getQuery();
                if (query2 == null && tabItems[i].getData() instanceof Query) {
                    query2 = (Query) tabItems[i].getData();
                }
                if (query2 != null && query.getLabel().equals(query2.getLabel())) {
                    if ("".equals(editorComposite.getEditorContent())) {
                        //$NON-NLS-1$
                        editorComposite.setEditorContent(query.getValue());
                    }
                    tabFolder.setSelection(i);
                    return;
                }
                connParam.setQueryObject(query);
                queryStr = query.getValue();
            }
        }
    }
    CTabItem tabItem = null;
    if (connParam.isFromDBNode()) {
        tabItem = new CTabItem(tabFolder, SWT.NULL);
    } else {
        tabItem = new CTabItem(tabFolder, SWT.CLOSE);
    }
    node = SQLBuilderRepositoryNodeManager.getRoot(node);
    if (!"".equals(queryStr)) {
        //$NON-NLS-1$
        try {
            nodesSel = EMFRepositoryNodeManager.getInstance().parseSqlStatement(queryStr, node);
        } catch (Exception e) {
            MessageDialog.openError(new Shell(), Messages.getString("SQLBuilderTabComposite.Notice.title"), //$NON-NLS-1$
            Messages.getString(//$NON-NLS-1$
            "SQLBuilderTabComposite.Notice.Info"));
        }
    }
    MultiPageSqlBuilderEditor builderEditor = new MultiPageSqlBuilderEditor(nodesSel, tabItem, isDefaultEditor, connParam, node, dialog);
    builderEditor.setReadOnly(readOnly);
    try {
        builderEditor.init(new SQLBuilderEditorSite(), new SQLBuilderEditorInput());
    } catch (PartInitException e) {
        ExceptionHandler.process(e);
    }
    builderEditor.createPartControl2(tabFolder);
    tabItem.setControl(builderEditor.getContainer());
    tabItem.setData(TextUtil.KEY, builderEditor);
    if (connParam.isFromRepository() && connParam.getQueryObject() != null) {
        queryStr = connParam.getQueryObject().getValue();
    }
    builderEditor.setSqlText(queryStr);
    if (connParam.isShowDesignerPage()) {
        builderEditor.showDesignerPage();
    }
    // set new tab as the active one.
    tabFolder.setSelection(tabFolder.getItemCount() - 1);
    // refresh view
    tabFolder.layout();
    tabFolder.redraw();
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder) Query(org.talend.core.model.metadata.builder.connection.Query) SQLBuilderEditorInput(org.talend.sqlbuilder.editors.SQLBuilderEditorInput) CTabItem(org.eclipse.swt.custom.CTabItem) PartInitException(org.eclipse.ui.PartInitException) QueryRepositoryObject(org.talend.sqlbuilder.dbstructure.DBTreeProvider.QueryRepositoryObject) Shell(org.eclipse.swt.widgets.Shell) MultiPageSqlBuilderEditor(org.talend.sqlbuilder.editors.MultiPageSqlBuilderEditor) PartInitException(org.eclipse.ui.PartInitException) SQLBuilderEditorSite(org.talend.sqlbuilder.editors.SQLBuilderEditorSite)

Example 9 with PartInitException

use of org.eclipse.ui.PartInitException in project tdi-studio-se by Talend.

the class SQLPatternComposite method resourceChanged.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent
     * )
     */
@Override
public void resourceChanged(IResourceChangeEvent event) {
    boolean needRefresh = false;
    boolean modifySQL = true;
    if (event.getSource() instanceof SQLPatternItem && event.getType() == IResourceChangeEvent.PRE_CLOSE) {
        needRefresh = true;
        modifySQL = false;
        // if still have sql template editor to be opened.
        if (getCurrentOpenedEditors() != null) {
            for (IEditorReference editor : getCurrentOpenedEditors()) {
                ERepositoryObjectType type = null;
                try {
                    type = getCurrentOpenEditorType(editor);
                } catch (PartInitException e) {
                    e.printStackTrace();
                }
                if (type != null && ERepositoryObjectType.SQLPATTERNS.equals(type)) {
                    modifySQL = true;
                }
            }
        }
    }
    if (event.getSource() instanceof SQLPatternItem && event.getType() == IResourceChangeEvent.POST_CHANGE) {
        needRefresh = true;
    }
    if (needRefresh) {
        refreshComboContent(this.tableViewer, modifySQL);
        refresh();
    }
}
Also used : IEditorReference(org.eclipse.ui.IEditorReference) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) PartInitException(org.eclipse.ui.PartInitException) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Example 10 with PartInitException

use of org.eclipse.ui.PartInitException in project tdi-studio-se by Talend.

the class AbstractMultiPageTalendEditor method turnToJobScriptPage.

protected void turnToJobScriptPage(int newPageIndex) {
    if (jobletEditor != getEditor(newPageIndex)) {
        return;
    }
    ICreateXtextProcessService convertJobtoScriptService = CorePlugin.getDefault().getCreateXtextProcessService();
    try {
        final String scriptValue = convertJobtoScriptService.convertJobtoScript(getProcess().saveXmlFile());
        IFile file = (IFile) jobletEditor.getEditorInput().getAdapter(IResource.class);
        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(scriptValue.getBytes());
        if (file.exists()) {
            jobletEditor.getDocumentProvider().getDocument(jobletEditor.getEditorInput()).set(scriptValue);
            boolean isProcessReadOnly = ((JobEditorInput) getEditor(0).getEditorInput()).isReadOnly();
            IProxyRepositoryFactory rFactory = ProxyRepositoryFactory.getInstance();
            if (isProcessReadOnly || rFactory.isUserReadOnlyOnCurrentProject()) {
                IDocumentProvider provider = jobletEditor.getDocumentProvider();
                Class p = provider.getClass();
                Class[] type = new Class[1];
                type[0] = Boolean.TYPE;
                Object[] para = new Object[1];
                para[0] = Boolean.TRUE;
                Method method = p.getMethod("setReadOnly", type);
                method.invoke(provider, para);
            }
            //$NON-NLS-1$
            IAction action = jobletEditor.getAction("FoldingRestore");
            action.run();
            jobletEditor.doSave(null);
        } else {
            file.create(byteArrayInputStream, true, null);
        }
        if (propertyListener == null) {
            propertyListener = new IPropertyListener() {

                @Override
                public void propertyChanged(Object source, int propId) {
                    if (source instanceof IEditorPart && ((IEditorPart) source).isDirty()) {
                        getProcess().setProcessModified(true);
                        getProcess().setNeedRegenerateCode(true);
                    }
                }
            };
            jobletEditor.addPropertyListener(propertyListener);
        }
    } catch (PartInitException e) {
        ExceptionHandler.process(e);
    } catch (CoreException e) {
        ExceptionHandler.process(e);
    } catch (IOException e) {
        ExceptionHandler.process(e);
    } catch (SecurityException e) {
        ExceptionHandler.process(e);
    } catch (NoSuchMethodException e) {
        ExceptionHandler.process(e);
    } catch (IllegalArgumentException e) {
        ExceptionHandler.process(e);
    } catch (IllegalAccessException e) {
        ExceptionHandler.process(e);
    } catch (InvocationTargetException e) {
        ExceptionHandler.process(e);
    }
    changeContextsViewStatus(false);
}
Also used : IFile(org.eclipse.core.resources.IFile) ICreateXtextProcessService(org.talend.core.services.ICreateXtextProcessService) IPropertyListener(org.eclipse.ui.IPropertyListener) PartInitException(org.eclipse.ui.PartInitException) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) IAction(org.eclipse.jface.action.IAction) Method(java.lang.reflect.Method) IEditorPart(org.eclipse.ui.IEditorPart) IOException(java.io.IOException) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) InvocationTargetException(java.lang.reflect.InvocationTargetException) JobEditorInput(org.talend.core.ui.editor.JobEditorInput) IDocumentProvider(org.eclipse.ui.texteditor.IDocumentProvider) CoreException(org.eclipse.core.runtime.CoreException) ByteArrayInputStream(java.io.ByteArrayInputStream) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PlatformObject(org.eclipse.core.runtime.PlatformObject) IResource(org.eclipse.core.resources.IResource)

Aggregations

PartInitException (org.eclipse.ui.PartInitException)720 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)300 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)177 IFile (org.eclipse.core.resources.IFile)146 IEditorPart (org.eclipse.ui.IEditorPart)141 CoreException (org.eclipse.core.runtime.CoreException)94 FileEditorInput (org.eclipse.ui.part.FileEditorInput)88 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)82 IEditorInput (org.eclipse.ui.IEditorInput)74 ISelection (org.eclipse.jface.viewers.ISelection)62 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)60 IResource (org.eclipse.core.resources.IResource)59 IEditorReference (org.eclipse.ui.IEditorReference)53 IViewPart (org.eclipse.ui.IViewPart)53 IOException (java.io.IOException)42 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)41 Point (org.eclipse.swt.graphics.Point)40 IWorkbench (org.eclipse.ui.IWorkbench)40 Path (org.eclipse.core.runtime.Path)39 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)39