Java 类org.eclipse.ui.part.FileEditorInput 实例源码

项目:n4js    文件:CreateNewN4JSElementInModuleHandler.java   
/**
 * Returns the opened file of the currently active editor.
 *
 * Returns null if no editor is open.
 */
private static IFile getActiveEditorFile() {
    IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
            .getActiveEditor();

    if (null == activeEditor) {
        return null;
    }

    IEditorInput input = activeEditor.getEditorInput();

    if (input instanceof FileEditorInput) {
        return ((FileEditorInput) input).getFile();
    } else {
        return null;
    }

}
项目:neoscada    文件:ProtocolEditor.java   
/**
 * This also changes the editor's input.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void doSaveAs ()
{
    SaveAsDialog saveAsDialog = new SaveAsDialog ( getSite ().getShell () );
    saveAsDialog.open ();
    IPath path = saveAsDialog.getResult ();
    if ( path != null )
    {
        IFile file = ResourcesPlugin.getWorkspace ().getRoot ().getFile ( path );
        if ( file != null )
        {
            doSaveAs ( URI.createPlatformResourceURI ( file.getFullPath ().toString (), true ), new FileEditorInput ( file ) );
        }
    }
}
项目:neoscada    文件:ChartEditor.java   
/**
 * This also changes the editor's input.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * 
 * @generated
 */
@Override
public void doSaveAs ()
{
    final SaveAsDialog saveAsDialog = new SaveAsDialog ( getSite ().getShell () );
    saveAsDialog.open ();
    final IPath path = saveAsDialog.getResult ();
    if ( path != null )
    {
        final IFile file = ResourcesPlugin.getWorkspace ().getRoot ().getFile ( path );
        if ( file != null )
        {
            doSaveAs ( URI.createPlatformResourceURI ( file.getFullPath ()
                    .toString (), true ), new FileEditorInput ( file ) );
        }
    }
}
项目:neoscada    文件:DetailViewEditor.java   
/**
 * This also changes the editor's input.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void doSaveAs ()
{
    SaveAsDialog saveAsDialog = new SaveAsDialog ( getSite ().getShell () );
    saveAsDialog.open ();
    IPath path = saveAsDialog.getResult ();
    if ( path != null )
    {
        IFile file = ResourcesPlugin.getWorkspace ().getRoot ().getFile ( path );
        if ( file != null )
        {
            doSaveAs ( URI.createPlatformResourceURI ( file.getFullPath ().toString (), true ), new FileEditorInput ( file ) );
        }
    }
}
项目:neoscada    文件:VisualInterfaceEditor.java   
/**
 * This also changes the editor's input.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void doSaveAs ()
{
    SaveAsDialog saveAsDialog = new SaveAsDialog ( getSite ().getShell () );
    saveAsDialog.open ();
    IPath path = saveAsDialog.getResult ();
    if ( path != null )
    {
        IFile file = ResourcesPlugin.getWorkspace ().getRoot ().getFile ( path );
        if ( file != null )
        {
            doSaveAs ( URI.createPlatformResourceURI ( file.getFullPath ().toString (), true ), new FileEditorInput ( file ) );
        }
    }
}
项目:neoscada    文件:DeploymentEditor.java   
/**
 * This also changes the editor's input.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void doSaveAs ()
{
    SaveAsDialog saveAsDialog = new SaveAsDialog ( getSite ().getShell () );
    saveAsDialog.open ();
    IPath path = saveAsDialog.getResult ();
    if ( path != null )
    {
        IFile file = ResourcesPlugin.getWorkspace ().getRoot ().getFile ( path );
        if ( file != null )
        {
            doSaveAs ( URI.createPlatformResourceURI ( file.getFullPath ().toString (), true ), new FileEditorInput ( file ) );
        }
    }
}
项目:neoscada    文件:SetupEditor.java   
/**
 * This also changes the editor's input.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void doSaveAs ()
{
    SaveAsDialog saveAsDialog = new SaveAsDialog ( getSite ().getShell () );
    saveAsDialog.open ();
    IPath path = saveAsDialog.getResult ();
    if ( path != null )
    {
        IFile file = ResourcesPlugin.getWorkspace ().getRoot ().getFile ( path );
        if ( file != null )
        {
            doSaveAs ( URI.createPlatformResourceURI ( file.getFullPath ().toString (), true ), new FileEditorInput ( file ) );
        }
    }
}
项目:neoscada    文件:ProfileEditor.java   
/**
 * This also changes the editor's input.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void doSaveAs ()
{
    SaveAsDialog saveAsDialog = new SaveAsDialog ( getSite ().getShell () );
    saveAsDialog.open ();
    IPath path = saveAsDialog.getResult ();
    if ( path != null )
    {
        IFile file = ResourcesPlugin.getWorkspace ().getRoot ().getFile ( path );
        if ( file != null )
        {
            doSaveAs ( URI.createPlatformResourceURI ( file.getFullPath ().toString (), true ), new FileEditorInput ( file ) );
        }
    }
}
项目:neoscada    文件:OsgiEditor.java   
/**
 * This also changes the editor's input.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void doSaveAs ()
{
    SaveAsDialog saveAsDialog = new SaveAsDialog ( getSite ().getShell () );
    saveAsDialog.open ();
    IPath path = saveAsDialog.getResult ();
    if ( path != null )
    {
        IFile file = ResourcesPlugin.getWorkspace ().getRoot ().getFile ( path );
        if ( file != null )
        {
            doSaveAs ( URI.createPlatformResourceURI ( file.getFullPath ().toString (), true ), new FileEditorInput ( file ) );
        }
    }
}
项目:neoscada    文件:WorldEditor.java   
/**
 * This also changes the editor's input.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void doSaveAs ()
{
    SaveAsDialog saveAsDialog = new SaveAsDialog ( getSite ().getShell () );
    saveAsDialog.open ();
    IPath path = saveAsDialog.getResult ();
    if ( path != null )
    {
        IFile file = ResourcesPlugin.getWorkspace ().getRoot ().getFile ( path );
        if ( file != null )
        {
            doSaveAs ( URI.createPlatformResourceURI ( file.getFullPath ().toString (), true ), new FileEditorInput ( file ) );
        }
    }
}
项目:neoscada    文件:MemoryEditor.java   
/**
 * This also changes the editor's input.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void doSaveAs ()
{
    SaveAsDialog saveAsDialog = new SaveAsDialog ( getSite ().getShell () );
    saveAsDialog.open ();
    IPath path = saveAsDialog.getResult ();
    if ( path != null )
    {
        IFile file = ResourcesPlugin.getWorkspace ().getRoot ().getFile ( path );
        if ( file != null )
        {
            doSaveAs ( URI.createPlatformResourceURI ( file.getFullPath ().toString (), true ), new FileEditorInput ( file ) );
        }
    }
}
项目:neoscada    文件:RecipeEditor.java   
/**
 * This also changes the editor's input.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void doSaveAs ()
{
    SaveAsDialog saveAsDialog = new SaveAsDialog ( getSite ().getShell () );
    saveAsDialog.open ();
    IPath path = saveAsDialog.getResult ();
    if ( path != null )
    {
        IFile file = ResourcesPlugin.getWorkspace ().getRoot ().getFile ( path );
        if ( file != null )
        {
            doSaveAs ( URI.createPlatformResourceURI ( file.getFullPath ().toString (), true ), new FileEditorInput ( file ) );
        }
    }
}
项目:neoscada    文件:InfrastructureEditor.java   
/**
 * This also changes the editor's input.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void doSaveAs ()
{
    SaveAsDialog saveAsDialog = new SaveAsDialog ( getSite ().getShell () );
    saveAsDialog.open ();
    IPath path = saveAsDialog.getResult ();
    if ( path != null )
    {
        IFile file = ResourcesPlugin.getWorkspace ().getRoot ().getFile ( path );
        if ( file != null )
        {
            doSaveAs ( URI.createPlatformResourceURI ( file.getFullPath ().toString (), true ), new FileEditorInput ( file ) );
        }
    }
}
项目:neoscada    文件:SecurityEditor.java   
/**
 * This also changes the editor's input.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void doSaveAs ()
{
    SaveAsDialog saveAsDialog = new SaveAsDialog ( getSite ().getShell () );
    saveAsDialog.open ();
    IPath path = saveAsDialog.getResult ();
    if ( path != null )
    {
        IFile file = ResourcesPlugin.getWorkspace ().getRoot ().getFile ( path );
        if ( file != null )
        {
            doSaveAs ( URI.createPlatformResourceURI ( file.getFullPath ().toString (), true ), new FileEditorInput ( file ) );
        }
    }
}
项目:neoscada    文件:GlobalizeEditor.java   
/**
 * This also changes the editor's input.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void doSaveAs ()
{
    SaveAsDialog saveAsDialog = new SaveAsDialog ( getSite ().getShell () );
    saveAsDialog.open ();
    IPath path = saveAsDialog.getResult ();
    if ( path != null )
    {
        IFile file = ResourcesPlugin.getWorkspace ().getRoot ().getFile ( path );
        if ( file != null )
        {
            doSaveAs ( URI.createPlatformResourceURI ( file.getFullPath ().toString (), true ), new FileEditorInput ( file ) );
        }
    }
}
项目:neoscada    文件:ComponentEditor.java   
/**
 * This also changes the editor's input.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void doSaveAs ()
{
    SaveAsDialog saveAsDialog = new SaveAsDialog ( getSite ().getShell () );
    saveAsDialog.open ();
    IPath path = saveAsDialog.getResult ();
    if ( path != null )
    {
        IFile file = ResourcesPlugin.getWorkspace ().getRoot ().getFile ( path );
        if ( file != null )
        {
            doSaveAs ( URI.createPlatformResourceURI ( file.getFullPath ().toString (), true ), new FileEditorInput ( file ) );
        }
    }
}
项目:neoscada    文件:ItemEditor.java   
/**
 * This also changes the editor's input.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void doSaveAs ()
{
    SaveAsDialog saveAsDialog = new SaveAsDialog ( getSite ().getShell () );
    saveAsDialog.open ();
    IPath path = saveAsDialog.getResult ();
    if ( path != null )
    {
        IFile file = ResourcesPlugin.getWorkspace ().getRoot ().getFile ( path );
        if ( file != null )
        {
            doSaveAs ( URI.createPlatformResourceURI ( file.getFullPath ().toString (), true ), new FileEditorInput ( file ) );
        }
    }
}
项目:neoscada    文件:ConfigurationEditor.java   
/**
 * This also changes the editor's input.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void doSaveAs ()
{
    SaveAsDialog saveAsDialog = new SaveAsDialog ( getSite ().getShell () );
    saveAsDialog.open ();
    IPath path = saveAsDialog.getResult ();
    if ( path != null )
    {
        IFile file = ResourcesPlugin.getWorkspace ().getRoot ().getFile ( path );
        if ( file != null )
        {
            doSaveAs ( URI.createPlatformResourceURI ( file.getFullPath ().toString (), true ), new FileEditorInput ( file ) );
        }
    }
}
项目:eclipse-bash-editor    文件:OpenWithBashEditor.java   
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IFile file = getSelectedFile();
    if (file==null){
        return null;
    }
    IWorkbenchPage page = EclipseUtil.getActivePage();
    if (page==null){
        return null;
    }
    try {
        page.openEditor(new FileEditorInput(file), BashEditor.EDITOR_ID);
    } catch (PartInitException e) {
        throw new ExecutionException("Was not able to open bash editor for file:"+file.getName(),e);
    }
    return null;
}
项目:Open_Source_ECOA_Toolset_AS5    文件:TypesEditor.java   
/**
 * Closes all project files on project close.
 */
public void resourceChanged(final IResourceChangeEvent event) {
    if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
        Display.getDefault().asyncExec(new Runnable() {
            public void run() {
                IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
                for (int i = 0; i < pages.length; i++) {
                    if (((FileEditorInput) editor.getEditorInput()).getFile().getProject().equals(event.getResource())) {
                        IEditorPart editorPart = pages[i].findEditor(editor.getEditorInput());
                        pages[i].closeEditor(editorPart, true);
                    }
                }
            }
        });
    }
}
项目:Open_Source_ECOA_Toolset_AS5    文件:CompDefEditor.java   
/**
 * Closes all project files on project close.
 */
public void resourceChanged(final IResourceChangeEvent event) {
    if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
        Display.getDefault().asyncExec(new Runnable() {
            public void run() {
                IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
                for (int i = 0; i < pages.length; i++) {
                    if (((FileEditorInput) editor.getEditorInput()).getFile().getProject().equals(event.getResource())) {
                        IEditorPart editorPart = pages[i].findEditor(editor.getEditorInput());
                        pages[i].closeEditor(editorPart, true);
                    }
                }
            }
        });
    }
}
项目:Open_Source_ECOA_Toolset_AS5    文件:ServicesEditor.java   
/**
 * Closes all project files on project close.
 */
public void resourceChanged(final IResourceChangeEvent event) {
    if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
        Display.getDefault().asyncExec(new Runnable() {
            public void run() {
                IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
                for (int i = 0; i < pages.length; i++) {
                    if (((FileEditorInput) editor.getEditorInput()).getFile().getProject().equals(event.getResource())) {
                        IEditorPart editorPart = pages[i].findEditor(editor.getEditorInput());
                        pages[i].closeEditor(editorPart, true);
                    }
                }
            }
        });
    }
}
项目:Open_Source_ECOA_Toolset_AS5    文件:IntLogicalSysEditor.java   
@Override
public void resourceChanged(IResourceChangeEvent event) {
    if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
        Display.getDefault().asyncExec(new Runnable() {
            public void run() {
                IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
                for (int i = 0; i < pages.length; i++) {
                    if (((FileEditorInput) getEditorInput()).getFile().getProject().equals(event.getResource())) {
                        IEditorPart editorPart = pages[i].findEditor(getEditorInput());
                        pages[i].closeEditor(editorPart, true);
                    }
                }
            }
        });
    }
}
项目:Open_Source_ECOA_Toolset_AS5    文件:IntLogicalSysEditor.java   
@Override
protected void initializeGraphicalViewer() {
    super.initializeGraphicalViewer();
    getGraphicalViewer().setRootEditPart(new ScalableFreeformRootEditPart());
    FileEditorInput inp = (FileEditorInput) getEditorInput();
    setPartName(inp.getFile().getName());
    try {
        String path = inp.getFile().getLocation().toOSString();
        String text = FileUtils.readFileToString(new File(path));
        LogicalSystemNode node = parse(text);
        root = new LogicalSystemEditPart(node, inp.getFile().getProject().getFullPath().toOSString());
        getGraphicalViewer().setContents(root);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
项目:Open_Source_ECOA_Toolset_AS5    文件:IntLogicalSysEditor.java   
@Override
protected void configureGraphicalViewer() {
    super.configureGraphicalViewer();
    EditPartFactory factory = new EditPartFactory();
    FileEditorInput inp = (FileEditorInput) getEditorInput();
    factory.setContainerName(inp.getFile().getProject().getFullPath().toOSString());
    getGraphicalViewer().setEditPartFactory(factory);
    ((FigureCanvas) getGraphicalControl()).setScrollBarVisibility(FigureCanvas.ALWAYS);
    getActionRegistry().registerAction(new ExportImageAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new ExportAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new GenerateAPIAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new GenerateINTAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new GenerateUIDAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new ClearTargetAction(this, inp.getFile().getProject().getFullPath()));
    getGraphicalViewer().setContextMenu(new ContextMenuProvider(getGraphicalViewer(), getActionRegistry()));
}
项目:Open_Source_ECOA_Toolset_AS5    文件:IntFinalAssemblyEditor.java   
@Override
public void resourceChanged(IResourceChangeEvent event) {
    if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
        Display.getDefault().asyncExec(new Runnable() {
            public void run() {
                IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
                for (int i = 0; i < pages.length; i++) {
                    if (((FileEditorInput) getEditorInput()).getFile().getProject().equals(event.getResource())) {
                        IEditorPart editorPart = pages[i].findEditor(getEditorInput());
                        pages[i].closeEditor(editorPart, true);
                    }
                }
            }
        });
    }
}
项目:Open_Source_ECOA_Toolset_AS5    文件:IntFinalAssemblyEditor.java   
@Override
public void initializeGraphicalViewer() {
    super.initializeGraphicalViewer();
    getGraphicalViewer().setRootEditPart(new ScalableFreeformRootEditPart());
    FileEditorInput inp = (FileEditorInput) getEditorInput();
    setPartName(inp.getFile().getName());
    try {
        String path = inp.getFile().getLocation().toOSString();
        String text = FileUtils.readFileToString(new File(path));
        CompositeNode node = parse(text);
        root = new CompositeEditPart(node, inp.getFile().getProject().getFullPath().toOSString());
        getGraphicalViewer().setContents(root);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
项目:Open_Source_ECOA_Toolset_AS5    文件:IntFinalAssemblyEditor.java   
@Override
protected void configureGraphicalViewer() {
    super.configureGraphicalViewer();
    EditPartFactory factory = new EditPartFactory();
    FileEditorInput inp = (FileEditorInput) getEditorInput();
    factory.setContainerName(inp.getFile().getProject().getFullPath().toOSString());
    getGraphicalViewer().setEditPartFactory(factory);
    ((FigureCanvas) getGraphicalControl()).setScrollBarVisibility(FigureCanvas.ALWAYS);
    getActionRegistry().registerAction(new ExportImageAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new ExportAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new GenerateAPIAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new GenerateINTAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new GenerateUIDAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new ClearTargetAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new RefreshAction(this, inp.getFile().getProject().getFullPath(), inp.getFile()));
    getGraphicalViewer().setContextMenu(new ContextMenuProvider(getGraphicalViewer(), getActionRegistry()));
}
项目:Open_Source_ECOA_Toolset_AS5    文件:IntDeploymentEditor.java   
@Override
public void initializeGraphicalViewer() {
    super.initializeGraphicalViewer();
    getGraphicalViewer().setRootEditPart(new ScalableFreeformRootEditPart());
    FileEditorInput inp = (FileEditorInput) getEditorInput();
    setPartName(inp.getFile().getName());
    try {
        String path = inp.getFile().getLocation().toOSString();
        String text = FileUtils.readFileToString(new File(path));
        DeploymentNode node = parse(text);
        root = new DeploymentEditPart(node, inp.getFile().getProject().getFullPath().toOSString());
        getGraphicalViewer().setContents(root);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
项目:Open_Source_ECOA_Toolset_AS5    文件:IntDeploymentEditor.java   
@Override
public void resourceChanged(IResourceChangeEvent event) {
    if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
        Display.getDefault().asyncExec(new Runnable() {
            public void run() {
                IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
                for (int i = 0; i < pages.length; i++) {
                    if (((FileEditorInput) getEditorInput()).getFile().getProject().equals(event.getResource())) {
                        IEditorPart editorPart = pages[i].findEditor(getEditorInput());
                        pages[i].closeEditor(editorPart, true);
                    }
                }
            }
        });
    }
}
项目:Open_Source_ECOA_Toolset_AS5    文件:IntDeploymentEditor.java   
@Override
protected void configureGraphicalViewer() {
    super.configureGraphicalViewer();
    EditPartFactory factory = new EditPartFactory();
    FileEditorInput inp = (FileEditorInput) getEditorInput();
    factory.setContainerName(inp.getFile().getProject().getFullPath().toOSString());
    getGraphicalViewer().setEditPartFactory(factory);
    ((FigureCanvas) getGraphicalControl()).setScrollBarVisibility(FigureCanvas.ALWAYS);
    getActionRegistry().registerAction(new ExportImageAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new ExportAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new GenerateAPIAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new GenerateINTAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new GenerateUIDAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new ClearTargetAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new RefreshAction(this, inp.getFile().getProject().getFullPath(), inp.getFile()));
    getGraphicalViewer().setContextMenu(new ContextMenuProvider(getGraphicalViewer(), getActionRegistry()));
}
项目:Open_Source_ECOA_Toolset_AS5    文件:CompImplEditor.java   
@Override
public void initializeGraphicalViewer() {
    super.initializeGraphicalViewer();
    getGraphicalViewer().setRootEditPart(new ScalableFreeformRootEditPart());
    FileEditorInput inp = (FileEditorInput) getEditorInput();
    setPartName(inp.getFile().getName());
    try {
        String path = inp.getFile().getLocation().toOSString();
        String text = FileUtils.readFileToString(new File(path));
        ComponentImplementationNode node = parse(text);
        root = new ComponentImplementationEditPart(node, inp.getFile().getProject().getFullPath().toOSString());
        getGraphicalViewer().setContents(root);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
项目:Open_Source_ECOA_Toolset_AS5    文件:CompImplEditor.java   
@Override
protected void configureGraphicalViewer() {
    super.configureGraphicalViewer();
    EditPartFactory factory = new EditPartFactory();
    FileEditorInput inp = (FileEditorInput) getEditorInput();
    factory.setContainerName(inp.getFile().getProject().getFullPath().toOSString());
    getGraphicalViewer().setEditPartFactory(factory);
    ((FigureCanvas) getGraphicalControl()).setScrollBarVisibility(FigureCanvas.ALWAYS);
    getActionRegistry().registerAction(new ExportImageAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new ExportAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new GenerateAPIAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new GenerateINTAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new GenerateUIDAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new ClearTargetAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new RefreshAction(this, inp.getFile().getProject().getFullPath(), inp.getFile()));
    getGraphicalViewer().setContextMenu(new ContextMenuProvider(getGraphicalViewer(), getActionRegistry()));
}
项目:Open_Source_ECOA_Toolset_AS5    文件:CompImplEditor.java   
@Override
public void resourceChanged(IResourceChangeEvent event) {
    if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
        Display.getDefault().asyncExec(new Runnable() {
            public void run() {
                IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
                for (int i = 0; i < pages.length; i++) {
                    if (((FileEditorInput) getEditorInput()).getFile().getProject().equals(event.getResource())) {
                        IEditorPart editorPart = pages[i].findEditor(getEditorInput());
                        pages[i].closeEditor(editorPart, true);
                    }
                }
            }
        });
    }
}
项目:Open_Source_ECOA_Toolset_AS5    文件:InitAssemblyEditor.java   
@Override
public void resourceChanged(IResourceChangeEvent event) {
    if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
        Display.getDefault().asyncExec(new Runnable() {
            public void run() {
                IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
                for (int i = 0; i < pages.length; i++) {
                    if (((FileEditorInput) getEditorInput()).getFile().getProject().equals(event.getResource())) {
                        IEditorPart editorPart = pages[i].findEditor(getEditorInput());
                        pages[i].closeEditor(editorPart, true);
                    }
                }
            }
        });
    }
}
项目:Open_Source_ECOA_Toolset_AS5    文件:InitAssemblyEditor.java   
@Override
protected void initializeGraphicalViewer() {
    super.initializeGraphicalViewer();
    getGraphicalViewer().setRootEditPart(new ScalableFreeformRootEditPart());
    FileEditorInput inp = (FileEditorInput) getEditorInput();
    setPartName(inp.getFile().getName());
    try {
        String path = inp.getFile().getLocation().toOSString();
        String text = FileUtils.readFileToString(new File(path));
        CompositeNode node = parse(text);
        root = new CompositeEditPart(node, inp.getFile().getProject().getFullPath().toOSString());
        getGraphicalViewer().setContents(root);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
项目:Open_Source_ECOA_Toolset_AS5    文件:InitAssemblyEditor.java   
@Override
protected void configureGraphicalViewer() {
    super.configureGraphicalViewer();
    EditPartFactory factory = new EditPartFactory();
    FileEditorInput inp = (FileEditorInput) getEditorInput();
    factory.setContainerName(inp.getFile().getProject().getFullPath().toOSString());
    getGraphicalViewer().setEditPartFactory(factory);
    ((FigureCanvas) getGraphicalControl()).setScrollBarVisibility(FigureCanvas.ALWAYS);
    getActionRegistry().registerAction(new ExportImageAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new ExportAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new GenerateAPIAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new GenerateINTAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new GenerateUIDAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new ClearTargetAction(this, inp.getFile().getProject().getFullPath()));
    getGraphicalViewer().setContextMenu(new ContextMenuProvider(getGraphicalViewer(), getActionRegistry()));
}
项目:gw4e.project    文件:GW4EEditor.java   
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
    super.init(site, input);
    setSite(site);
    setPartName(input.getName());
    setInputWithNotify(input);
    site.setSelectionProvider(this);
    if (getEditorInput() instanceof FileEditorInput) {
        FileEditorInput fei = (FileEditorInput) getEditorInput();
        IFile file = fei.getFile();
        gWGraph = ResourceManager.load(file);
        Display.getDefault().asyncExec(new Runnable() {
            @Override
            public void run() {
                gWGraph.initialize(getGraphicalViewer().getEditPartRegistry());
                if (!ResourceManager.isEditable(file)) {
                    gWGraph.setReadOnly(true);
                    getGraphicalViewer().getControl().setEnabled(false);
                    String title = MessageUtil.getString("conversion");
                    String message = MessageUtil.getString("not_formatted_as_json_convert_it");
                    DialogManager.displayWarning(title, message);
                }
            }
        });
    }

}
项目:gw4e.project    文件:EditorHelper.java   
public static File getEditedFileFolder() {
    IWorkbenchPage page = null;
    IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
    for (int i = 0; i < windows.length; i++) {
        if (windows[i] != null) {
            IWorkbenchWindow window = windows[i];
            page = windows[i].getActivePage();
            if (page != null)
                break;
        }
    }
    IEditorPart part = page.getActiveEditor();
    FileEditorInput editor = (FileEditorInput) part.getEditorInput();
    IFile file = editor.getFile();
    IFolder folder = (IFolder) file.getParent();
    File f = null;
    try {
        f = ResourceManager.toFile(folder.getFullPath());
    } catch (FileNotFoundException e) {
        ResourceManager.logException(e);
    }
    return f;
}
项目:gw4e.project    文件:EditorHelper.java   
public static File getEditedFile() {
    IWorkbenchPage page = null;
    IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
    for (int i = 0; i < windows.length; i++) {
        if (windows[i] != null) {
            IWorkbenchWindow window = windows[i];
            page = windows[i].getActivePage();
            if (page != null)
                break;
        }
    }
    IEditorPart part = page.getActiveEditor();
    FileEditorInput editor = (FileEditorInput) part.getEditorInput();
    IFile file = editor.getFile();
    File f = null;
    try {
        f = ResourceManager.toFile(file.getFullPath());
    } catch (FileNotFoundException e) {
        ResourceManager.logException(e);
    }
    return f;
}