⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 activehelpaction.java

📁 Eclipse高级编程3源码(书本源码)
💻 JAVA
字号:
/*******************************************************************************
 * Copyright (c) 2003 Berthold Daum.
 * All rights reserved. This program and the accompanying materials 
 * are made available under the terms of the Common Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/cpl-v10.html
 * 
 * Contributors:
 *     Berthold Daum
 *******************************************************************************/
package com.bdaum.SpellChecker.actions;

import org.eclipse.help.ILiveHelpAction;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.WorkbenchPage;

import com.bdaum.SpellChecker.SpellCheckerPlugin;

/**
 * Invoking spell checking via active help
 */
public class ActiveHelpAction implements ILiveHelpAction {
  // JavaScript invocation parameter
  String data;

  /**
   * Accepts the third parameter of the script invocation
   */
  public void setInitializationString(
    String data) {
    // Remember the parameter
    this.data = data;
  }

  /**
   * Runs help action
   */
  public void run() {
    IWorkbench wb = PlatformUI.getWorkbench();
    final IWorkbenchWindow window = 
         (wb.getActiveWorkbenchWindow() == null) ? 
             wb.getWorkbenchWindows()[0] : 
             wb.getActiveWorkbenchWindow();
    if (window == null) return;
    Display display = window.getShell().getDisplay();
    if (display == null) return;
    // Active help does not run in the SWT thread.
    // Therefore we must encapsulate all GUI accesses into
    // a syncExec() method.
    display.syncExec(new Runnable() {
      public void run() {
        // Bring the workbench window into the foreground
        Shell shell = window.getShell();
        shell.setMinimized(false);
        shell.forceActive();
        if (data.equals("install")) {
          // Fetch workbench page
          WorkbenchPage page = (WorkbenchPage) window.getActivePage();
          if (page == null) return;
          // Call Perspective Configuration function
          page.editActionSets();
        } else if (data.equals("start")) {
          // Get the SpellCheckingActionDelegate
          IWorkbenchWindowActionDelegate delegate = 
              SpellCheckerPlugin.getSpellCheckingActionDelegate();
          if (delegate == null) return;
          // Execute the spell checking action
          delegate.run(null);
        }
      }
    });
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -