Package de.innovationgate.eclipse.editors.commands

Source Code of de.innovationgate.eclipse.editors.commands.DisplayHelp

/*******************************************************************************
* Copyright (c) 2009, 2010 Innovation Gate GmbH.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
*     Innovation Gate GmbH - initial API and implementation
******************************************************************************/
package de.innovationgate.eclipse.editors.commands;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.text.information.IInformationProvider;
import org.eclipse.jface.text.information.InformationPresenter;
import org.eclipse.ui.IEditorPart;

import de.innovationgate.eclipse.editors.Plugin;
import de.innovationgate.eclipse.editors.all.AbstractWGATextEditor;
import de.innovationgate.eclipse.editors.tml.HTMLInformationControlCreator;
import de.innovationgate.eclipse.editors.tml.TMLInformationProvider;

public class DisplayHelp extends AbstractHandler {


  public static final String ID = "de.innovationgate.eclipse.ids.editors.commands.DisplayHelp";
 
  public Object execute(ExecutionEvent event) throws ExecutionException {
    IEditorPart editorPart = Plugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();   
    if (editorPart != null && editorPart instanceof AbstractWGATextEditor) {
     
      AbstractWGATextEditor editor = (AbstractWGATextEditor) editorPart;

      InformationPresenter presenter=
        new InformationPresenter(new HTMLInformationControlCreator(500,250));
      presenter.setDocumentPartitioning(editor.getViewerConfiguration().getConfiguredDocumentPartitioning(editor.getViewer()));

      IInformationProvider provider= new TMLInformationProvider();
     
      String[] contentTypes = editor.getViewerConfiguration().getConfiguredContentTypes(editor.getViewer());
      for (int i= 0; i < contentTypes.length; i++) {
        presenter.setInformationProvider(provider, contentTypes[i]);
      }
      presenter.install(editor.getViewer());
      presenter.showInformation();
    }
    return null;
 

}
TOP

Related Classes of de.innovationgate.eclipse.editors.commands.DisplayHelp

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.