Search in sources :

Example 11 with IEditorDescriptor

use of org.eclipse.ui.IEditorDescriptor in project azure-tools-for-java by Microsoft.

the class UIHelperImpl method refreshBlobs.

@Override
public void refreshBlobs(Object projectObject, final String accountName, final BlobContainer container) {
    IWorkbench workbench = PlatformUI.getWorkbench();
    final IEditorDescriptor editorDescriptor = workbench.getEditorRegistry().findEditor("com.microsoft.azuretools.azureexplorer.editors.BlobExplorerFileEditor");
    DefaultLoader.getIdeHelper().invokeLater(new Runnable() {

        public void run() {
        //TODO
        //                try {
        //                    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        //                    BlobExplorerFileEditor newEditor = (BlobExplorerFileEditor) page.openEditor(new StorageEditorInput(storageAccount, container), editorDescriptor.getId());
        //                    newEditor.fillGrid();
        //                } catch (PartInitException e) {
        //                    Activator.getDefault().log("Error opening container", e);
        //                }
        }
    });
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) IEditorDescriptor(org.eclipse.ui.IEditorDescriptor)

Example 12 with IEditorDescriptor

use of org.eclipse.ui.IEditorDescriptor in project translationstudio8 by heartsome.

the class ConversionCompleteAction method run.

@Override
public void run() {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    Assert.isNotNull(window);
    Shell shell = window.getShell();
    if (status.getSeverity() == IStatus.ERROR) {
        MessageDialog.openError(shell, Messages.getString("action.ConversionCompleteAction.msgTitle1"), status.getMessage());
    } else {
        // 转换完成后直接打开编辑器,不再进行弹框提示。
        // MessageDialog.openInformation(shell, "文件转换完成", status.getMessage());
        final String XLIFF_EDITOR_ID = "net.heartsome.cat.ts.ui.xliffeditor.nattable.editor";
        String xliffFile = conversionResult.get(Converter.ATTR_XLIFF_FILE);
        IWorkbenchPage page = window.getActivePage();
        Assert.isNotNull(page, Messages.getString("action.ConversionCompleteAction.msg1"));
        if (xliffFile != null) {
            IEditorDescriptor editorDescriptor = PlatformUI.getWorkbench().getEditorRegistry().findEditor(XLIFF_EDITOR_ID);
            if (editorDescriptor != null) {
                try {
                    IDE.openEditor(page, new File(xliffFile).toURI(), XLIFF_EDITOR_ID, true);
                } catch (PartInitException e) {
                    MessageDialog.openInformation(shell, Messages.getString("action.ConversionCompleteAction.msgTitle2"), Messages.getString("action.ConversionCompleteAction.msg2") + e.getMessage());
                    e.printStackTrace();
                }
            }
        } else {
            String targetFile = conversionResult.get(Converter.ATTR_TARGET_FILE);
            if (targetFile == null) {
                MessageDialog.openInformation(shell, Messages.getString("action.ConversionCompleteAction.msgTitle2"), Messages.getString("action.ConversionCompleteAction.msg3"));
            } else {
                IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
                IFile input = root.getFileForLocation(new Path(targetFile));
                try {
                    // 使用外部编辑器(系统默认编辑器)打开文件。
                    IDE.openEditor(page, input, IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID);
                } catch (PartInitException e) {
                    MessageDialog.openInformation(shell, Messages.getString("action.ConversionCompleteAction.msgTitle2"), Messages.getString("action.ConversionCompleteAction.msg4") + e.getMessage());
                    e.printStackTrace();
                }
            }
        }
    }
}
Also used : Path(org.eclipse.core.runtime.Path) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) Shell(org.eclipse.swt.widgets.Shell) IFile(org.eclipse.core.resources.IFile) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) IEditorDescriptor(org.eclipse.ui.IEditorDescriptor) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) File(java.io.File) IFile(org.eclipse.core.resources.IFile)

Aggregations

IEditorDescriptor (org.eclipse.ui.IEditorDescriptor)12 IWorkbench (org.eclipse.ui.IWorkbench)6 PartInitException (org.eclipse.ui.PartInitException)6 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)4 Image (org.eclipse.swt.graphics.Image)4 IEditorRegistry (org.eclipse.ui.IEditorRegistry)4 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)4 IEditorPart (org.eclipse.ui.IEditorPart)3 StorageEditorInput (com.microsoft.azuretools.azureexplorer.editors.StorageEditorInput)2 IFile (org.eclipse.core.resources.IFile)2 IClusterDetail (com.microsoft.azure.hdinsight.sdk.cluster.IClusterDetail)1 JobViewInput (com.microsoft.azuretools.azureexplorer.editors.JobViewInput)1 File (java.io.File)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)1 Path (org.eclipse.core.runtime.Path)1 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)1 Cursor (org.eclipse.swt.graphics.Cursor)1 Point (org.eclipse.swt.graphics.Point)1 Shell (org.eclipse.swt.widgets.Shell)1