Examples of IEditorDescriptor


Examples of org.eclipse.ui.IEditorDescriptor

   * @see org.eclipse.jface.text.hyperlink.IHyperlink#open()
   */
  public void open() {
    if (fURL != null) {
      IEditorInput input = new StorageEditorInput(new URLStorage(fURL));
      IEditorDescriptor descriptor;
      try {
        descriptor = IDE.getEditorDescriptor(input.getName(), true);
        if (descriptor != null) {
          IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
          IEditorPart openedEditor = IDE.openEditor(page, input, descriptor.getId(), true);
          IRegion definitionRegion = findDefinitionRegion(new URLStorage(fURL));
          if (definitionRegion != null) {
            openedEditor.getSite().getSelectionProvider().setSelection(new TextSelection(definitionRegion.getOffset(), definitionRegion.getLength()));
          }
        }
View Full Code Here

Examples of org.eclipse.ui.IEditorDescriptor

    IEditorRegistry editorRegistry = PlatformUI.getWorkbench().getEditorRegistry();   
   
    try
    {
   
      IEditorDescriptor defaultEditor = editorRegistry.getDefaultEditor(contents.getName());
      if (defaultEditor == null){
        defaultEditor = editorRegistry.getDefaultEditor("a.txt");
      }
      IEditorPart newEditor =null;
      try{
View Full Code Here

Examples of org.eclipse.ui.IEditorDescriptor

      else
        substring = sb.toString();
      File tmpFile = File.createTempFile(substring, fakeFileName.substring(lastIdx, fakeFileName.length()));
     
      tmpFile.deleteOnExit();
      IEditorDescriptor defaultEditor = editorRegistry.getDefaultEditor(tmpFile.getAbsolutePath());
      if (defaultEditor == null){
        defaultEditor = editorRegistry.getDefaultEditor("a.txt");
      }
      IEditorPart newEditor =null;
      try{
View Full Code Here

Examples of org.eclipse.ui.IEditorDescriptor

    }
    if(length < XML_EDITOR_FILE_SIZE_LIMIT) {
      // Open editor on new file.
      String editorId = null;
      try {
        IEditorDescriptor editor = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file.getLocation().toOSString(), file.getContentDescription().getContentType());
        if (editor != null) {
          editorId = editor.getId();
        }
      }
      catch (CoreException e1) {
        // editor id could not be retrieved, so we can not open editor
        return;
View Full Code Here

Examples of org.eclipse.ui.IEditorDescriptor

      // continue without content type
    } catch (IOException ex) {
      // continue without content type
    }

    final IEditorDescriptor descriptor = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(name, contentType);
    return descriptor != null ? descriptor.getLabel() : null;
  }
View Full Code Here

Examples of org.eclipse.ui.IEditorDescriptor

    return NLS.bind(XMLUIMessages.Open, path);
  }

  private String getEditorLabel() throws CoreException {
    final IContentDescription description = fFile.getContentDescription();
    final IEditorDescriptor defaultEditor = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(fFile.getName(), description != null ? description.getContentType() : null);
    return defaultEditor != null ? defaultEditor.getLabel() : null;
  }
View Full Code Here

Examples of org.eclipse.ui.IEditorDescriptor

      return NLS.bind(XMLUIMessages.Open_With, path, editorLabel);
    return NLS.bind(XMLUIMessages.Open, path);
  }

  protected String getEditorLabel() {
    IEditorDescriptor descriptor = getEditorDescriptor();
    return descriptor != null ? descriptor.getLabel() : null;
  }
View Full Code Here

Examples of org.eclipse.ui.IEditorDescriptor

   */
  public void open() {
    if (fURL != null) {
      IEditorInput input = new StorageEditorInput(new URLStorage(fURL));
      try {
        final IEditorDescriptor descriptor = getEditorDescriptor();
        if (descriptor != null) {
          IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
          IDE.openEditor(page, input, descriptor.getId(), true);
        }
      }
      catch (PartInitException e) {
        Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
        new URLHyperlink(fRegion, fURL.toString()).open();
View Full Code Here

Examples of org.eclipse.ui.IEditorDescriptor

        }

        // get editor for this file
        IWorkbench workbench = workbenchWindow.getWorkbench();
        IEditorRegistry editorRegistry = workbench.getEditorRegistry();
        IEditorDescriptor descriptor = editorRegistry.getDefaultEditor( file.getName() );

        if ( descriptor == null )
        {
            String msg = MessageFormat.format(
                Messages.getString( "OpenFileAction.No_appropriate_editor_found_for_x" ), new Object[] //$NON-NLS-1$
                { file.getName() } );
            MessageDialog.openWarning( workbenchWindow.getShell(), Messages
                .getString( "OpenFileAction.Warning_message" ), msg ); //$NON-NLS-1$
            return;
        }

        // create IEdiorInput
        IPath location = new Path( file.getAbsolutePath() );
        ImageDescriptor imageDescriptor = descriptor.getImageDescriptor();
        IPathEditorInput input = new PathEditorInput( location, imageDescriptor );

        // activate editor
        IWorkbenchPage page = workbenchWindow.getActivePage();
        String editorId = descriptor.getId();
        try
        {
            page.openEditor( input, editorId );
        }
        catch ( PartInitException e )
View Full Code Here

Examples of org.eclipse.ui.IEditorDescriptor

                public void run() {
                  try {
                    IContentType contentType = iFile.getContentDescription().getContentType();
                    IEditorRegistry editorRegistry = workbench.getEditorRegistry();
                    String fileName = iFile.getName();
                    IEditorDescriptor descriptor = editorRegistry.getDefaultEditor(fileName, contentType);
                    String editorId;
                    if (descriptor != null) {
                      editorId = descriptor.getId();
                    }
                    else {
                      descriptor = editorRegistry.getDefaultEditor(fileName + ".txt"); //$NON-NLS-1$
                      editorId = descriptor.getId();
                    }
                   
                    if (editorId != null)
                    {
                      FileEditorInput editorInput = new FileEditorInput(iFile);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.