Search in sources :

Example 81 with IWorkbench

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

the class JavaCodeProblemsChecker method retrieveDetailedProblems.

/**
     * DOC amaumont Comment method "retrieveDetailedProblems".
     * 
     * @return
     */
private List<DetailedProblem> retrieveDetailedProblems(final IAloneProcessNodeConfigurer nodeConfigurer) {
    final ArrayList<DetailedProblem> iproblems = new ArrayList<DetailedProblem>();
    final IWorkbench workbench = PlatformUI.getWorkbench();
    Display display = workbench.getDisplay();
    if (display != null) {
        display.syncExec(new Runnable() {

            public void run() {
                IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
                IEditorPart editorPart = page.getActiveEditor();
                if (editorPart instanceof AbstractMultiPageTalendEditor) {
                    AbstractMultiPageTalendEditor multiPageTalendEditor = ((AbstractMultiPageTalendEditor) editorPart);
                    AbstractTalendEditor talendEditor = multiPageTalendEditor.getTalendEditor();
                    TalendJavaEditor codeEditor = (TalendJavaEditor) multiPageTalendEditor.getCodeEditor();
                    org.eclipse.jdt.core.ICompilationUnit compilationUnit = (org.eclipse.jdt.core.ICompilationUnit) codeEditor.getUnit();
                    IProcess process = talendEditor.getProcess();
                    if (AbstractProcessProvider.isExtensionProcessForJoblet(process)) {
                        // joblet
                        return;
                    }
                    String selectedNodeName = multiPageTalendEditor.getSelectedNodeName();
                    if (selectedNodeName == null) {
                        return;
                    }
                    String uniqueNodeName = null;
                    boolean found = false;
                    List<? extends INode> generatingNodes = process.getGeneratingNodes();
                    int generatingNodesListSize = generatingNodes.size();
                    for (int i = 0; i < generatingNodesListSize; i++) {
                        INode node = generatingNodes.get(i);
                        /* startsWith method used in case of virtual component such as 'tMap_1_TMAP_OUT' */
                        if (node.getUniqueName().equals(selectedNodeName) || node.getUniqueName().startsWith(selectedNodeName + "_")) {
                            //$NON-NLS-1$
                            uniqueNodeName = node.getUniqueName();
                            found = true;
                            break;
                        }
                    }
                    if (!found) {
                        // in case the component doesn't exist
                        return;
                    }
                    final String code = retrieveCode(process, uniqueNodeName, nodeConfigurer);
                    // System.out.println(code);
                    // create requestor for accumulating discovered problems
                    MyProblemRequestor problemRequestor = new MyProblemRequestor(code, iproblems, selectedNodeName);
                    // use working copy to hold source with error
                    org.eclipse.jdt.core.ICompilationUnit workingCopy = null;
                    try {
                        JavaProcessorUtilities.computeLibrariesPath(process.getNeededModules(false), process);
                        try {
                            WorkingCopyOwner workingCopyOwner = new WorkingCopyOwner() {
                            };
                            workingCopy = ((org.eclipse.jdt.core.ICompilationUnit) compilationUnit).getWorkingCopy(workingCopyOwner, problemRequestor, null);
                            problemRequestor.setReportProblems(true);
                            ((IOpenable) workingCopy).getBuffer().setContents(code);
                            ((org.eclipse.jdt.core.ICompilationUnit) workingCopy).reconcile(ICompilationUnit.NO_AST, true, null, null);
                            problemRequestor.setReportProblems(false);
                        } finally {
                            if (workingCopy != null) {
                                workingCopy.discardWorkingCopy();
                            }
                        }
                    } catch (JavaModelException e) {
                        ExceptionHandler.process(e);
                    } catch (CoreException e) {
                        ExceptionHandler.process(e);
                    }
                }
            }
        });
    }
    return iproblems;
}
Also used : INode(org.talend.core.model.process.INode) IOpenable(org.eclipse.jdt.core.IOpenable) JavaModelException(org.eclipse.jdt.core.JavaModelException) TalendJavaEditor(org.talend.designer.core.ui.editor.TalendJavaEditor) ArrayList(java.util.ArrayList) DetailedProblem(org.talend.designer.core.ui.editor.DetailedProblem) WorkingCopyOwner(org.eclipse.jdt.core.WorkingCopyOwner) AbstractTalendEditor(org.talend.designer.core.ui.editor.AbstractTalendEditor) ArrayList(java.util.ArrayList) List(java.util.List) IProcess(org.talend.core.model.process.IProcess) ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) IEditorPart(org.eclipse.ui.IEditorPart) IWorkbench(org.eclipse.ui.IWorkbench) CoreException(org.eclipse.core.runtime.CoreException) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) Display(org.eclipse.swt.widgets.Display)

Example 82 with IWorkbench

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

the class GenerateDocAsHTMLAction method doRun.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
protected void doRun() {
    GenerateDocAsHTMLWizard processWizard = new GenerateDocAsHTMLWizard();
    IWorkbench workbench = getWorkbench();
    processWizard.setWindowTitle(GENERATE_DOC_AS_HTML);
    processWizard.init(workbench, (IStructuredSelection) this.getSelection());
    Shell activeShell = Display.getCurrent().getActiveShell();
    WizardDialog dialog = new WizardDialog(activeShell, processWizard);
    dialog.open();
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) Shell(org.eclipse.swt.widgets.Shell) GenerateDocAsHTMLWizard(org.talend.designer.documentation.generation.wizards.GenerateDocAsHTMLWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 83 with IWorkbench

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

the class ExportItemAction method doRun.

@Override
protected void doRun() {
    if (toolbarAction) {
        this.setWorkbenchPart(null);
    }
    IRepositoryView repositoryView = getViewPart();
    if (repositoryView != null && repositoryView.getViewer() instanceof TreeViewer) {
        ((TreeViewer) repositoryView.getViewer()).getTree().setFocus();
    }
    ExportItemWizard wizard = new ExportItemWizard((repositoryView != null ? repositoryView.getViewSite().getId() : null));
    IWorkbench workbench = getWorkbench();
    wizard.setWindowTitle(EXPORT_ITEM);
    if (!toolbarAction) {
        wizard.init(workbench, (IStructuredSelection) this.getSelection());
    } else {
        if (repositoryView != null) {
            IStructuredSelection selection = (IStructuredSelection) repositoryView.getViewer().getSelection();
            wizard.init(workbench, selection);
        }
    }
    Shell activeShell = Display.getCurrent().getActiveShell();
    WizardDialog dialog = new WizardDialog(activeShell, wizard);
    dialog.open();
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) Shell(org.eclipse.swt.widgets.Shell) TreeViewer(org.eclipse.jface.viewers.TreeViewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IRepositoryView(org.talend.repository.ui.views.IRepositoryView) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 84 with IWorkbench

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

the class ExportJobScriptAction method doRun.

@Override
protected void doRun() {
    JobScriptsExportWizard processWizard = new JobScriptsExportWizard();
    IWorkbench workbench = getWorkbench();
    processWizard.setWindowTitle(EXPORTJOBSCRIPTS);
    processWizard.init(workbench, (IStructuredSelection) this.getSelection());
    Shell activeShell = Display.getCurrent().getActiveShell();
    WizardDialog dialog = new WizardDialog(activeShell, processWizard);
    if (checkDirtyPart(workbench)) {
        MessageDialog messageDialog = new //$NON-NLS-1$
        MessageDialog(//$NON-NLS-1$
        new Shell(), //$NON-NLS-1$
        "", //$NON-NLS-1$
        null, //$NON-NLS-1$
        Messages.getString("ExportJobScriptAction.confirmMessage"), MessageDialog.CONFIRM, new String[] { Messages.getString("ExportJobScriptAction.confirmContiune"), IDialogConstants.CANCEL_LABEL }, //$NON-NLS-1$
        0);
        if (messageDialog.open() != 0) {
            // don't do anything
            return;
        }
    }
    dialog.setPageSize(830, 580);
    dialog.open();
    // collector
    IPreferenceStore preferenceStore = RepositoryPlugin.getDefault().getPreferenceStore();
    int num = preferenceStore.getInt(ExportJobTokenCollector.TOS_COUNT_JOB_EXPORTS.getPrefKey());
    preferenceStore.setValue(ExportJobTokenCollector.TOS_COUNT_JOB_EXPORTS.getPrefKey(), num + 1);
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) JobScriptsExportWizard(org.talend.repository.ui.wizards.exportjob.JobScriptsExportWizard) Shell(org.eclipse.swt.widgets.Shell) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 85 with IWorkbench

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

the class DeployOnSpagicAction method doRun.

protected void doRun() {
    SpagicDeployWizard processWizard = new SpagicDeployWizard();
    IWorkbench workbench = getWorkbench();
    processWizard.setWindowTitle(DEPLOYONSPAGIC);
    processWizard.init(workbench, (IStructuredSelection) this.getSelection());
    Shell activeShell = Display.getCurrent().getActiveShell();
    WizardDialog dialog = new WizardDialog(activeShell, processWizard);
    workbench.saveAllEditors(true);
    dialog.open();
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) Shell(org.eclipse.swt.widgets.Shell) SpagicDeployWizard(org.talend.spagic.engines.client.ui.wizards.SpagicDeployWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Aggregations

IWorkbench (org.eclipse.ui.IWorkbench)105 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)32 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)31 IEditorPart (org.eclipse.ui.IEditorPart)21 PartInitException (org.eclipse.ui.PartInitException)20 WizardDialog (org.eclipse.jface.wizard.WizardDialog)15 CoreException (org.eclipse.core.runtime.CoreException)12 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)12 Shell (org.eclipse.swt.widgets.Shell)11 IResource (org.eclipse.core.resources.IResource)9 ISelection (org.eclipse.jface.viewers.ISelection)9 Display (org.eclipse.swt.widgets.Display)8 ArrayList (java.util.ArrayList)7 IFile (org.eclipse.core.resources.IFile)7 IEditorDescriptor (org.eclipse.ui.IEditorDescriptor)7 IProject (org.eclipse.core.resources.IProject)6 TreeViewer (org.eclipse.jface.viewers.TreeViewer)6 TableEditorInput (com.cubrid.common.ui.cubrid.table.editor.TableEditorInput)5 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)5 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)5