Search in sources :

Example 16 with IEditorInput

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

the class EditPropertiesAction method getCorrespondingEditor.

/**
     * Find the editor that is related to the node.
     * 
     * @param node
     * @return
     */
protected IEditorPart getCorrespondingEditor(final IRepositoryNode node) {
    IEditorReference[] eidtors = getActivePage().getEditorReferences();
    for (IEditorReference eidtor : eidtors) {
        try {
            IEditorInput input = eidtor.getEditorInput();
            if (!(input instanceof RepositoryEditorInput)) {
                continue;
            }
            RepositoryEditorInput repositoryInput = (RepositoryEditorInput) input;
            if (node.getId() != null && node.getId().equals(repositoryInput.getId())) {
                IPath path = repositoryInput.getFile().getLocation();
                return eidtor.getEditor(false);
            }
        } catch (PartInitException e) {
            continue;
        }
    }
    return null;
}
Also used : IEditorReference(org.eclipse.ui.IEditorReference) RepositoryEditorInput(org.talend.core.repository.ui.editor.RepositoryEditorInput) IPath(org.eclipse.core.runtime.IPath) PartInitException(org.eclipse.ui.PartInitException) IEditorInput(org.eclipse.ui.IEditorInput)

Example 17 with IEditorInput

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

the class OpenExistVersionProcessAction method getCorrespondingEditor.

@Override
protected IEditorPart getCorrespondingEditor(IRepositoryNode node) {
    IEditorReference[] eidtors = getActivePage().getEditorReferences();
    for (IEditorReference eidtor : eidtors) {
        try {
            IEditorInput input = eidtor.getEditorInput();
            if (!(input instanceof JobEditorInput)) {
                continue;
            }
            JobEditorInput repositoryInput = (JobEditorInput) input;
            checkUnLoadedNodeForProcess(repositoryInput);
            if (repositoryInput.getItem().equals(node.getObject().getProperty().getItem())) {
                IPath path = repositoryInput.getFile().getLocation();
                return eidtor.getEditor(false);
            }
        } catch (PartInitException e) {
            continue;
        }
    }
    return null;
}
Also used : JobEditorInput(org.talend.core.ui.editor.JobEditorInput) IEditorReference(org.eclipse.ui.IEditorReference) IPath(org.eclipse.core.runtime.IPath) PartInitException(org.eclipse.ui.PartInitException) IEditorInput(org.eclipse.ui.IEditorInput)

Example 18 with IEditorInput

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

the class ProcessPart method getAdapter.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#getAdapter(java.lang.Class)
     */
@Override
public Object getAdapter(final Class adapter) {
    if (adapter.equals(RepositoryNode.class)) {
        if (node == null) {
            RootEditPart rootEditPart = getRoot();
            if (rootEditPart instanceof TalendScalableFreeformRootEditPart) {
                TalendScalableFreeformRootEditPart rootEditPart2 = (TalendScalableFreeformRootEditPart) rootEditPart;
                IEditorInput editorInput = rootEditPart2.getEditorInput();
                if (editorInput instanceof ProcessEditorInput) {
                    ProcessEditorInput processEditorInput = (ProcessEditorInput) editorInput;
                    node = processEditorInput.getRepositoryNode();
                }
            }
        }
        return node;
    }
    if (adapter == SnapToHelper.class) {
        List<Object> snapStrategies = new ArrayList<Object>();
        Boolean val = (Boolean) getViewer().getProperty(RulerProvider.PROPERTY_RULER_VISIBILITY);
        val = (Boolean) getViewer().getProperty(NodeSnapToGeometry.PROPERTY_SNAP_ENABLED);
        if (val != null && val.booleanValue()) {
            snapStrategies.add(new NodeSnapToGeometry(this));
        }
        val = (Boolean) getViewer().getProperty(SnapToGrid.PROPERTY_GRID_ENABLED);
        if (val != null && val.booleanValue()) {
            snapStrategies.add(new SnapToGrid(this));
        }
        if (snapStrategies.size() == 0) {
            return null;
        }
        if (snapStrategies.size() == 1) {
            return snapStrategies.get(0);
        }
        SnapToHelper[] ss = new SnapToHelper[snapStrategies.size()];
        for (int i = 0; i < snapStrategies.size(); i++) {
            ss[i] = (SnapToHelper) snapStrategies.get(i);
        }
        return new CompoundSnapToHelper(ss);
    }
    return super.getAdapter(adapter);
}
Also used : SnapToHelper(org.eclipse.gef.SnapToHelper) CompoundSnapToHelper(org.eclipse.gef.CompoundSnapToHelper) ArrayList(java.util.ArrayList) ProcessEditorInput(org.talend.designer.core.ui.editor.ProcessEditorInput) SnapToGrid(org.eclipse.gef.SnapToGrid) TalendScalableFreeformRootEditPart(org.talend.designer.core.ui.editor.TalendScalableFreeformRootEditPart) CompoundSnapToHelper(org.eclipse.gef.CompoundSnapToHelper) IEditorInput(org.eclipse.ui.IEditorInput) TalendScalableFreeformRootEditPart(org.talend.designer.core.ui.editor.TalendScalableFreeformRootEditPart) RootEditPart(org.eclipse.gef.RootEditPart)

Example 19 with IEditorInput

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

the class TalendJavaSourceViewer method initializeModel.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.ui.viewer.ReconcilerViewer#initializeModel(IDocument document)
     */
@Override
protected void initializeModel() {
    getSourceViewerDecorationSupport().install(JavaPlugin.getDefault().getCombinedPreferenceStore());
    this.setRangeIndicator(new DefaultRangeIndicator());
    IAnnotationModel model;
    IDocument document;
    if (checkCode) {
        IDocumentProvider provider = JavaPlugin.getDefault().getCompilationUnitDocumentProvider();
        IEditorInput ei = new FileEditorInput(file);
        try {
            provider.connect(ei);
        } catch (CoreException e) {
            ExceptionHandler.process(e);
        }
        document = provider.getDocument(ei);
        model = provider.getAnnotationModel(ei);
    } else {
        model = new AnnotationModel();
        document = getDocument();
        model.connect(document);
    }
    if (document != null) {
        setDocument(document, model);
        showAnnotations(model != null && checkCode);
    }
    super.initializeModel();
}
Also used : DefaultRangeIndicator(org.eclipse.ui.texteditor.DefaultRangeIndicator) IDocumentProvider(org.eclipse.ui.texteditor.IDocumentProvider) CoreException(org.eclipse.core.runtime.CoreException) FileEditorInput(org.eclipse.ui.part.FileEditorInput) IAnnotationModel(org.eclipse.jface.text.source.IAnnotationModel) AnnotationModel(org.eclipse.jface.text.source.AnnotationModel) IAnnotationModel(org.eclipse.jface.text.source.IAnnotationModel) IDocument(org.eclipse.jface.text.IDocument) IEditorInput(org.eclipse.ui.IEditorInput)

Example 20 with IEditorInput

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

the class ResourceEditorListener method partClosed.

@Override
public void partClosed(IWorkbenchPartReference partRef) {
    IWorkbenchPart part = partRef.getPart(true);
    if (part instanceof IEditorPart) {
        IEditorInput input = ((IEditorPart) part).getEditorInput();
        if (input instanceof RouteResourceInput) {
            Item item = ((RouteResourceInput) input).getItem();
            if (item.getProperty().getId().equals(editorInput.getItem().getProperty().getId())) {
                try {
                    ProxyRepositoryFactory.getInstance().unlock(item);
                    page.getWorkbenchWindow().getPartService().removePartListener(this);
                    IResourceChangeListener l = editorInput.getListener();
                    if (null != l) {
                        ResourcesPlugin.getWorkspace().removeResourceChangeListener(l);
                    }
                } catch (Exception e) {
                    ExceptionHandler.process(e);
                }
            }
        }
    }
}
Also used : RouteResourceInput(org.talend.designer.camel.resource.editors.input.RouteResourceInput) Item(org.talend.core.model.properties.Item) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) IEditorPart(org.eclipse.ui.IEditorPart) IResourceChangeListener(org.eclipse.core.resources.IResourceChangeListener) 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