Search in sources :

Example 11 with IEditorInput

use of org.eclipse.ui.IEditorInput in project AutoRefactor by JnRouvignac.

the class AutoRefactorHandler method getSelectedJavaElements.

private static List<IJavaElement> getSelectedJavaElements(Shell shell, IEditorPart activeEditor) {
    final IEditorInput editorInput = activeEditor.getEditorInput();
    final IJavaElement javaElement = JavaUI.getEditorInputJavaElement(editorInput);
    if (javaElement instanceof ICompilationUnit) {
        return Collections.singletonList(javaElement);
    }
    showMessage(shell, "This action only works on Java source files");
    return Collections.emptyList();
}
Also used : IJavaElement(org.eclipse.jdt.core.IJavaElement) ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) IEditorInput(org.eclipse.ui.IEditorInput)

Example 12 with IEditorInput

use of org.eclipse.ui.IEditorInput in project KaiZen-OpenAPI-Editor by RepreZen.

the class QuickOutline method setInput.

@Override
public void setInput(Object input) {
    if (input instanceof Model) {
        Model model = (Model) input;
        if (model.getPath() == null) {
            IFile currentFile = null;
            IEditorInput editorInput = editor.getEditorInput();
            if (editorInput instanceof IFileEditorInput) {
                currentFile = ((IFileEditorInput) editorInput).getFile();
            }
            if (currentFile != null) {
                model.setPath(currentFile.getFullPath());
            }
        }
    }
    treeViewer.setInput(input);
    treeViewer.setSelection(null, true);
}
Also used : IFile(org.eclipse.core.resources.IFile) IFileEditorInput(org.eclipse.ui.IFileEditorInput) Model(com.reprezen.swagedit.core.model.Model) IEditorInput(org.eclipse.ui.IEditorInput)

Example 13 with IEditorInput

use of org.eclipse.ui.IEditorInput in project KaiZen-OpenAPI-Editor by RepreZen.

the class JsonEditor method validate.

private void validate(boolean onOpen) {
    IEditorInput editorInput = getEditorInput();
    final IDocument document = getDocumentProvider().getDocument(getEditorInput());
    // such files.
    if (!(editorInput instanceof IFileEditorInput)) {
        YEditLog.logError("Marking errors not supported for files outside of a project.");
        YEditLog.logger.info("editorInput is not a part of a project.");
        return;
    }
    if (document instanceof JsonDocument) {
        final IFileEditorInput fileEditorInput = (IFileEditorInput) editorInput;
        final IFile file = fileEditorInput.getFile();
        if (onOpen) {
            // force parsing of yaml to init parsing errors
            ((JsonDocument) document).onChange();
        }
        clearMarkers(file);
        validateYaml(file, (JsonDocument) document);
        validateSwagger(file, (JsonDocument) document, fileEditorInput);
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) IFileEditorInput(org.eclipse.ui.IFileEditorInput) IEditorInput(org.eclipse.ui.IEditorInput) IDocument(org.eclipse.jface.text.IDocument)

Example 14 with IEditorInput

use of org.eclipse.ui.IEditorInput 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 15 with IEditorInput

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

the class SQLPatternComposite method getCurrentOpenEditorType.

public ERepositoryObjectType getCurrentOpenEditorType(IEditorReference editor) throws PartInitException {
    IEditorInput editorInput = editor.getEditorInput();
    if (editorInput instanceof RepositoryEditorInput) {
        RepositoryEditorInput repoEditorInput = (RepositoryEditorInput) editorInput;
        Item item = repoEditorInput.getItem();
        return ERepositoryObjectType.getItemType(item);
    }
    return null;
}
Also used : Item(org.talend.core.model.properties.Item) ConnectionItem(org.talend.core.model.properties.ConnectionItem) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) TableItem(org.eclipse.swt.widgets.TableItem) RepositoryEditorInput(org.talend.core.repository.ui.editor.RepositoryEditorInput) IEditorInput(org.eclipse.ui.IEditorInput)

Aggregations

IEditorInput (org.eclipse.ui.IEditorInput)71 IFile (org.eclipse.core.resources.IFile)26 PartInitException (org.eclipse.ui.PartInitException)21 IEditorPart (org.eclipse.ui.IEditorPart)19 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)17 IEditorReference (org.eclipse.ui.IEditorReference)14 CoreException (org.eclipse.core.runtime.CoreException)13 ArrayList (java.util.ArrayList)11 IViewPart (org.eclipse.ui.IViewPart)11 FileEditorInput (org.eclipse.ui.part.FileEditorInput)10 Shell (org.eclipse.swt.widgets.Shell)9 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)8 IFileEditorInput (org.eclipse.ui.IFileEditorInput)8 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)8 File (java.io.File)7 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)7 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)7 Item (org.talend.core.model.properties.Item)7 XLIFFEditorImplWithNatTable (net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable)6 IProject (org.eclipse.core.resources.IProject)6