@Override public void run() { if (part instanceof GraphicalEditorWithFlyoutPalette) { GraphicalEditorWithFlyoutPalette edPart = (GraphicalEditorWithFlyoutPalette) part; ImageSaveUtil.save(edPart, getViewer(edPart)); } }
private GraphicalViewer getViewer(GraphicalEditorWithFlyoutPalette edPart) { if (edPart instanceof InitAssemblyEditor) { return ((InitAssemblyEditor) edPart).getViewer(); } else if (edPart instanceof IntFinalAssemblyEditor) { return ((IntFinalAssemblyEditor) edPart).getViewer(); } else if (edPart instanceof IntLogicalSysEditor) { return ((IntLogicalSysEditor) edPart).getViewer(); } else if (edPart instanceof IntDeploymentEditor) { return ((IntDeploymentEditor) edPart).getViewer(); } else if (edPart instanceof CompImplEditor) { return ((CompImplEditor) edPart).getViewer(); } return null; }
@Override public void run() { if (part instanceof GraphicalEditorWithFlyoutPalette) { GraphicalEditorWithFlyoutPalette edPart = (GraphicalEditorWithFlyoutPalette) part; ExportCommand cmd = new ExportCommand(containerName, getFileName(edPart), getFileType(edPart), getContent(edPart)); execute(cmd); } }
private String getContent(GraphicalEditorWithFlyoutPalette edPart) { try { FileEditorInput inp = (FileEditorInput) edPart.getEditorInput(); String path = inp.getFile().getLocation().toOSString(); String text = FileUtils.readFileToString(new File(path)); return text; } catch (Exception e) { EclipseUtil.writeStactTraceToConsole(e); } return null; }
private String getFileType(GraphicalEditorWithFlyoutPalette edPart) { if (edPart instanceof InitAssemblyEditor) { return "assmbl"; } else if (edPart instanceof IntFinalAssemblyEditor) { return "fassmbl"; } else if (edPart instanceof IntLogicalSysEditor) { return "lsys"; } else if (edPart instanceof IntDeploymentEditor) { return "deploy"; } else if (edPart instanceof CompImplEditor) { return "cimpl"; } return null; }
private String getFileName(GraphicalEditorWithFlyoutPalette edPart) { FileEditorInput inp = (FileEditorInput) edPart.getEditorInput(); return inp.getFile().getLocation().toOSString(); }