Java/SWT JFace Eclipse/Eclipse Plugin

Материал из Java эксперт
Версия от 18:01, 31 мая 2010; (обсуждение)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Bdaum Spell Checker Eclipse Plugin

Custom widget PlugIn

Eclipse Help PlugIn

Eclipse PlugIn Demo

Eclipse PlugIn FlowChart

/*
SWT/JFace in Action
GUI Design with Eclipse 3.0
Matthew Scarpino, Stephen Holder, Stanford Ng, and Laurent Mihalkovic
ISBN: 1932394273
Publisher: Manning
*/





Eclipse PlugIn Gadget

Eclipse PlugIn Game

Eclipse PlugIn Hello World

Eclipse PlugIn Hello World 2

Eclipse PlugIn Image Viewer

Eclipse PlugIn Menu Editor

Eclipse Plug In RCP Example Plugin

/*
SWT/JFace in Action
GUI Design with Eclipse 3.0
Matthew Scarpino, Stephen Holder, Stanford Ng, and Laurent Mihalkovic
ISBN: 1932394273
Publisher: Manning
*/





Eclipse PlugIn shapes merlin

Eclipse Plugin Spell Checker

Eclipse PlugIn Wizards Plugin

HEX Eclipse Plugin

Shapes Emf PlugIn

Shape srcp PlugIn

Table Viewer Example Plugin

The main plugin class to be used in the desktop.

/*******************************************************************************
 * Copyright (c) 2000, 2005 IBM Corporation and others.
 * 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:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.swt.examples.paint;

import org.eclipse.core.runtime.*;
import org.eclipse.ui.plugin.*;
/**
 * The main plugin class to be used in the desktop.
 */
public class PaintPlugin extends AbstractUIPlugin {
  private static PaintPlugin plugin;
  /**
   * Constructs the Paint plugin.
   */
  public PaintPlugin() {
    super();
    plugin = this;
  }
  
  /**
   * Log an error to the ILog for this plugin
   * 
   * @param message the localized error message text
   * @param exception the associated exception, or null
   */
  public static void logError(String message, Throwable exception) {
    plugin.getLog().log(
      new Status(IStatus.ERROR, plugin.getBundle().getSymbolicName(), 0, message, exception));
  }
}

/*******************************************************************************
 * Copyright (c) 2000, 2005 IBM Corporation and others.
 * 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:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.swt.examples.paint;

import org.eclipse.jface.action.*;
import org.eclipse.jface.resource.*;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.*;
import org.eclipse.ui.*;
import org.eclipse.ui.part.*;
/**
 * The view for the paint application.
 * All rendering happens inside the area created by createPartControl().
 * 
 * @see ViewPart
 */
public class PaintView extends ViewPart {
  PaintExample instance = null;
  /**
   * Constructs a Paint view.
   */
  public PaintView() {
  }
  /**
   * Creates the example.
   * 
   * @see ViewPart#createPartControl
   */
  public void createPartControl(Composite parent) {
    instance = new PaintExample(parent);
    instance.createGUI(parent);
    /*** Add toolbar contributions ***/
    final IActionBars actionBars = getViewSite().getActionBars();
    IToolBarManager toolbarManager = actionBars.getToolBarManager();
    Tool tools[] = PaintExample.tools;
    String group = tools[0].group;
    toolbarManager.add(new GroupMarker(group));
    for (int i = 0; i < tools.length; i++) {
      Tool tool = tools[i];
      if (!tool.group.equals(group)) {
        toolbarManager.add(new Separator());
        toolbarManager.add(new GroupMarker(tool.group));
      }
      group = tool.group;
      PaintAction action = new PaintAction(tool);
      toolbarManager.appendToGroup(group, action);
      if (i == PaintExample.Default_tool || i == PaintExample.Default_fill || i == PaintExample.Default_linestyle) {
        action.setChecked(true);
      }
    }
    actionBars.updateActionBars();
    instance.setDefaults();
  }
  /**
   * Called when the View is to be disposed
   */  
  public void dispose() {
    instance.dispose();
    instance = null;
    super.dispose();
  }
  
  /**
   * Returns the Display.
   * 
   * @return the display we"re using
   */
  public Display getDisplay() {
    return instance.getDisplay();
  }
  
  /**
   * Called when we must grab focus.
   * 
   * @see org.eclipse.ui.part.ViewPart#setFocus
   */
  public void setFocus() {
    instance.setFocus();
  }
  /**
   * Action set glue.
   */
  class PaintAction extends Action {
    private int style;
    private Runnable action;
    public PaintAction(Tool tool) {
      super();
      String id = tool.group + "." + tool.name;
      setId(id);
      style = tool.type == SWT.RADIO ? IAction.AS_RADIO_BUTTON : IAction.AS_PUSH_BUTTON;
      action = tool.action;
      setText(PaintExample.getResourceString(id + ".label"));
      setToolTipText(PaintExample.getResourceString(id + ".tooltip"));
      setDescription(PaintExample.getResourceString(id + ".description"));
      setImageDescriptor(ImageDescriptor.createFromFile(
          PaintExample.class,
          PaintExample.getResourceString(id + ".image")));
    }
    public int getStyle() { return style; }
    public void run() { action.run(); }
  }
}





Tree viewer PlugIn

View Article PlugIn

WizardsPlugin

XML Editor Plugin