`

自定义RCP外观

阅读更多
如果说只需要改变RCP的皮肤可以参照IBM上的Eclipse程序界面美化技术
http://www.ibm.com/developerworks/cn/opensource/os-cn-ecl-rcprich/
如果想自定义RCP的外观就得用到presentationFactories,presentationFactories是eclipse为editor以及view提供的一个外观工厂,在eclipse官网上推荐的书中就提到过这么个工厂,今天再看MP3MANAGER源代码的时候发现实现起来也挺简单的,不过我还是习惯eclipse风格,所以没将应用的外观改变,之前也一直在寻找改变RCP外观的方法,昨天网友告诉我IBM上有我就去看了下,就是简单的变换了图片和背景颜色,也就是个SWT的皮肤而已,下面我就直接贴代码演示presentationFactories的实现方法
首先就是Presentation 类:
/*******************************************************************************
 * Copyright (c) 2009 Siemens AG
 * 
 * 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:
 *    Kai T枚dter - initial API and implementation
 *******************************************************************************/

package com.siemens.ct.mp3m.ui.presentation;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IPropertyListener;
import org.eclipse.ui.presentations.IPresentablePart;
import org.eclipse.ui.presentations.IStackPresentationSite;
import org.eclipse.ui.presentations.StackDropResult;
import org.eclipse.ui.presentations.StackPresentation;

public class Presentation extends StackPresentation {

    private Color borderColor;

    private IPresentablePart current;

    private final PaintListener paintListener = new PaintListener() {

        public void paintControl(final PaintEvent e) {
            final Rectangle clientArea = presentationControl.getClientArea();
            // Image img = new Image(e.display, clientArea.width,
            // clientArea.height);
            // GC gc = new GC(img);
            final GC gc = e.gc;

            final int border = 1;
            gc.setLineWidth(border);
            gc.setForeground(borderColor);
            gc.drawRectangle(clientArea.x, clientArea.y, clientArea.width - border,
                    clientArea.height - border);

            // e.gc.drawImage(img, 0, 0);
            // gc.dispose();
            // img.dispose();

        }
    };

    /**
     * Listener attached to all child parts. It responds to changes in part
     * properties
     */
    private final IPropertyListener partPropertyChangeListener = new IPropertyListener() {

        public void propertyChanged(final Object source, final int property) {

            if (source instanceof IPresentablePart) {
                redraw();
            }
        }
    };

    private Composite presentationControl;

    private TabContainer tabContainer;

    private Title titleBar;

    private Color toolBarColor;

    public Presentation(final Composite parent, final IStackPresentationSite site) {
        super(site);
        // Create a top-level control for the presentation.
        presentationControl = new Composite(parent, SWT.NONE);
        borderColor = new Color(presentationControl.getDisplay(), 50, 50, 50);
        toolBarColor = new Color(presentationControl.getDisplay(), 203, 220, 235);

        presentationControl.addPaintListener(paintListener);

        titleBar = new Title(presentationControl, SWT.NONE, getSite());
        tabContainer = new TabContainer(presentationControl, SWT.NONE);

        /*
         * Add a dispose listener. Important because dispose() may // not always
         * be called.
         */
        presentationControl.addDisposeListener(new DisposeListener() {

            public void widgetDisposed(final DisposeEvent e) {
                presentationDisposed();
            }
        });

    }

    protected Presentation(final IStackPresentationSite stackSite) {
        super(stackSite);
        // TODO Auto-generated constructor stub
    }

    @Override
    public void addPart(final IPresentablePart newPart, final Object cookie) {
        newPart.addPropertyListener(partPropertyChangeListener);
        tabContainer.addPart(newPart, this, getSite());
    }

    @Override
    public int computePreferredSize(final boolean width, final int availableParallel,
            final int availablePerpendicular, final int preferredResult) {
        if (width) {
            return Math.max(preferredResult, 100);
        } else {
            return tabContainer.getHeight() + titleBar.getHeight();
        }
    }

    @Override
    public void dispose() {
        presentationDisposed();
    }

    @Override
    public StackDropResult dragOver(final Control currentControl, final Point location) {
        // TODO Auto-generated method stub
        return null;
    }

    /**
     * Gets the colorBorder.
     * 
     * @return Returns the colorBorder.
     */
    public Color getColorBorder() {
        return borderColor;
    }

    @Override
    public Control getControl() {
        return presentationControl;
    }

    @Override
    public Control[] getTabList(final IPresentablePart part) {
        return new Control[] { part.getControl() };
    }

    @Override
    public void removePart(final IPresentablePart oldPart) {
        oldPart.removePropertyListener(partPropertyChangeListener);
        tabContainer.removePart(oldPart);
        titleBar.removePart(oldPart);
        if (current == oldPart) {
            current = null;
        }
        redraw();
    }

    @Override
    public void selectPart(final IPresentablePart toSelect) {
        // Ignore redundant selections
        if (toSelect == current) {
            return;
        }

        // If there was an existing part selected, make it invisible
        if (current != null) {
            current.setVisible(false);
        }
        // Select the new part
        current = toSelect;

        // Make the part visible before setBounds, or the call to setBounds
        // may be ignored.
        if (current != null) {
            current.setVisible(true);
            setBounds(presentationControl.getBounds());
            titleBar.setPresentablePart(current);
            tabContainer.setPresentablePart(current);
        }
    }

    @Override
    public void setActive(final int newState) {
        // TODO Auto-generated method stub

    }

    @Override
    public void setBounds(final Rectangle bounds) {
        // Set the bounds of the presentation widget
        presentationControl.setBounds(bounds);

        final int titlebarHeight = titleBar.getHeight();
        final Rectangle clientArea = presentationControl.getClientArea();
        titleBar
                .setBounds(clientArea.x + 1, clientArea.y + 1, clientArea.width - 2, titlebarHeight);
        final int tabPaneHeight = tabContainer.getHeight();
        tabContainer.setBounds(clientArea.x, clientArea.y + clientArea.height - tabPaneHeight,
                clientArea.width, tabPaneHeight);
        if (current != null) {
            final Rectangle contentArea = presentationControl.getBounds();
            int toolBarHeight = 0;
            final Control toolBar = current.getToolBar();
            if (toolBar != null) {
                toolBar.setBackground(toolBarColor);
                toolBarHeight = toolBar.getBounds().height;
                toolBar.setBounds(clientArea.x + 1, clientArea.y + 1 + titlebarHeight,
                        clientArea.width - 2, toolBarHeight);
            }
            contentArea.x += 1;
            contentArea.y += titlebarHeight + toolBarHeight;
            contentArea.width -= 2;
            contentArea.height -= titlebarHeight + tabPaneHeight + toolBarHeight;
            if (tabPaneHeight == 0) {
                contentArea.height -= 1;
            }
            current.setBounds(contentArea);
        }
    }

    @Override
    public void setState(final int state) {
        // TODO Auto-generated method stub

    }

    @Override
    public void setVisible(final boolean isVisible) {
        // Make the presentation widget visible
        presentationControl.setVisible(isVisible);
        titleBar.setVisible(isVisible);

        // Make the currently visible part visible
        if (current != null) {
            current.setVisible(isVisible);

            if (isVisible) {
                // Restore the bounds of the currently visible part.
                // IPartPresentations can be used by multiple
                // StackPresentations,
                // although only one such presentation is ever visible at a
                // time.
                // It is possible that some other presentation has changed the
                // bounds of the part since it was last visible, so we need to
                // update the part's bounds when the presentation becomes
                // visible.

                setBounds(presentationControl.getBounds());
            }
        }
    }

    @Override
    public void showPaneMenu() {
        // TODO Auto-generated method stub
    }

    @Override
    public void showSystemMenu() {
        // TODO Auto-generated method stub
    }

    protected void presentationDisposed() {
        // Remove any listeners that were attached to any
        // global Eclipse resources. This is necessary in order to prevent
        // memory leaks.
        borderColor.dispose();
        toolBarColor.dispose();
        presentationControl.removePaintListener(paintListener);
        presentationControl.dispose();
        presentationControl = null;
    }

    protected void redraw() {
        if (presentationControl != null) {
            presentationControl.redraw();
            titleBar.redraw();
            tabContainer.redraw();
        }
    }
}

然后就是生产Presentation 的工厂:
/*******************************************************************************
 * Copyright (c) 2009 Siemens AG
 * 
 * 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:
 *    Kai T枚dter - initial API and implementation
 *******************************************************************************/

package com.siemens.ct.mp3m.ui.presentation;

import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.presentations.AbstractPresentationFactory;
import org.eclipse.ui.presentations.IStackPresentationSite;
import org.eclipse.ui.presentations.StackPresentation;

public class PresentationFactory extends AbstractPresentationFactory {
    public StackPresentation createEditorPresentation(Composite parent, IStackPresentationSite site) {
        return new Presentation(parent, site);
    }

    public StackPresentation createViewPresentation(Composite parent, IStackPresentationSite site) {
        return new Presentation(parent, site);
    }

    public StackPresentation createStandaloneViewPresentation(Composite parent,
            IStackPresentationSite site, boolean showTitle) {
        return new Presentation(parent, site);
    }
}

重要类:
package com.netunit.workbench.presentation;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseMoveListener;
import org.eclipse.swt.events.MouseTrackAdapter;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.presentations.IPresentablePart;

import com.netunit.workbench.Activator;
import com.netunit.workbench.intro.Application;

/**
 * 抽象皮肤属性
 * @author Ming.He
 *
 */
public abstract class AbstractClosable extends Canvas implements PaintListener {

	protected static Image closeUnselectedImage; //未选中close时的图片
	protected static Image closeSelectedImage;	//选中close时的图片
	protected boolean isCloseSelected;			//close是否被选中
	protected boolean isMouseOver;				//鼠标是否点中
	
	protected IPresentablePart part;			//控制view和editor的皮肤
	
	private final MouseMoveListener mouseMoveListener = new MouseMoveListener(){

		@Override
		public void mouseMove(MouseEvent e) {
			boolean oldState = isCloseSelected;
			Rectangle clientArea = getBounds();
			clientArea.x = clientArea.width - 20;
			clientArea.width = closeSelectedImage.getBounds().width;
			clientArea.y = 2;
			clientArea.height = closeSelectedImage.getBounds().height;
			if(clientArea.contains(e.x, e.y)){
				isCloseSelected = true;
			}else{
				isCloseSelected = false;
			}
			
			if(oldState != isCloseSelected){
				redraw();
			}
		}
		
	};
	
	protected MouseTrackAdapter mouseTrackAdapter = new MouseTrackAdapter(){

		@Override
		public void mouseEnter(MouseEvent e) {
			isMouseOver = true;
			redraw();
		}

		@Override
		public void mouseExit(MouseEvent e) {
			isMouseOver = false;
			isCloseSelected = false;
			redraw();
		}
		
	};
	
	static{
		ImageDescriptor imageDescriptor = Activator.imageDescriptorFromPlugin(Application.ID, "icons/close.gif");
		if(null != imageDescriptor){
			closeUnselectedImage = imageDescriptor.createImage();
		}
		imageDescriptor = Activator.imageDescriptorFromPlugin(Application.ID, "icons/closeSelected.gif");
		if(null != imageDescriptor){
			closeSelectedImage = imageDescriptor.createImage();
		}
	}
	
	public AbstractClosable(Composite parent, int style) {
		super(parent, style);
		addMouseMoveListener(mouseMoveListener);
		addMouseTrackListener(mouseTrackAdapter);
	}

	public void setPresentablePart(IPresentablePart part){
		this.part = part;
		setToolTipText(part.getTitleToolTip());
		layout();
		redraw();
	}
	
	public int getHeight(){
		return 21;
	}
	
	public void removePart(IPresentablePart oldPart){
		if(oldPart == part){
			part = null;
		}
	}
	
	protected String shortenText(GC gc, String text, int width){
		if(null == text){
			return null;
		}
		if(gc.textExtent(text, 0).x <= width){
			return text;
		}
		String eclipse = "...";
		int eclipseWidth = gc.textExtent(eclipse, 0).x;
		int textLength = text.length();
		
		while(textLength >= 0){
			String s1 = text.substring(0, textLength);
			int textWidth = gc.textExtent(s1, 0).x;
			
			if(textWidth + eclipseWidth < width){
				text = s1 + eclipse;
				break;
			}
			textLength --;
		}
		return text;
	}

}

辅助类:
/*******************************************************************************
 * Copyright (c) 2009 Siemens AG
 * 
 * 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:
 *    Kai T枚dter - initial API and implementation
 *******************************************************************************/

package com.siemens.ct.mp3m.ui.presentation;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.presentations.IPresentablePart;
import org.eclipse.ui.presentations.IStackPresentationSite;

public class TabContainer extends Composite {

    protected List<Tab> tabItems = new ArrayList<Tab>();

    protected IPresentablePart part;

    protected int style;

    public TabContainer(Composite parent, int style) {
        super(parent, style);
        this.style = style;
    }

    public void addPart(IPresentablePart part, Presentation presentation,
            IStackPresentationSite site) {
        Tab tab = new Tab(this, style, presentation, site);
        tab.setPresentablePart(part);
        tabItems.add(tab);
        redraw();
    }

    public void setPresentablePart(IPresentablePart part) {
        this.part = part;
        for (Tab b : tabItems) {
            b.setSected(b.checkPart(part));
        }
        redraw();
    }

    public int getHeight() {
        if (tabItems.size() < 2) {
            return 0;
        }
        return tabItems.size() * tabItems.get(0).getHeight() - tabItems.size() + 1;
    }

    @Override
    public void setBounds(int x, int y, int width, int height) {
        int y2 = 0;
        int h = 21;
        for (Tab b : tabItems) {
            b.setBounds(x, y2, width, h);
            y2 += 20;
        }
        super.setBounds(x, y, width, height);
    }

    public void redraw() {
        if (tabItems.size() < 2) {
            return;
        }
        for (Tab b : tabItems) {
            b.redraw();
        }
    }

    public void removePart(IPresentablePart oldPart) {
        Tab foundTab = null;
        for (Tab b : tabItems) {
            if (b.getPart() == oldPart) {
                foundTab = b;
                break;
            }
        }
        if (foundTab != null) {
            tabItems.remove(foundTab);
            foundTab.dispose();
        }
    }
}

/*******************************************************************************
 * Copyright (c) 2009 Siemens AG
 * 
 * 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:
 *    Kai T枚dter - initial API and implementation
 *******************************************************************************/

package com.siemens.ct.mp3m.ui.presentation;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.presentations.IPresentablePart;
import org.eclipse.ui.presentations.IStackPresentationSite;

public class Tab extends AbstractClosable implements PaintListener {

    private final Presentation presentation;

    private final IStackPresentationSite site;

    protected final Color unselectedTop = new Color(getDisplay(), 250, 250, 250);

    protected final Color unselectedBottom = new Color(getDisplay(), 200, 225, 255);

    protected final Color selectedTop = new Color(getDisplay(), 250, 230, 150);

    protected final Color selectedBottom = new Color(getDisplay(), 240, 155, 30);

    protected final Color mouseOverTop = new Color(getDisplay(), 255, 248, 223);

    protected final Color mouseOverBottom = new Color(getDisplay(), 255, 225, 120);

    protected Font font = new Font(getDisplay(), "Default", 10, SWT.NORMAL);

    private boolean isSelected;

    /**
     * This listener responds to selection events in all tabs.
     */
    private final MouseListener mouseListener = new MouseAdapter() {
        @Override
        public void mouseDown(MouseEvent e) {
            if (part != null) {
                part.setFocus();
                if (isCloseSelected()) {
                    site.close(new IPresentablePart[] { part });
                } else {
                    site.selectPart(part);
                    presentation.selectPart(part);
                }
            }
        }
    };

    public Tab(Composite parent, int style, Presentation presentation, IStackPresentationSite site) {
        super(parent, style | SWT.NO_BACKGROUND);
        this.presentation = presentation;
        this.site = site;

        setSected(false);
        addPaintListener(this);
        addMouseListener(mouseListener);
    }

    @Override
    public void setPresentablePart(IPresentablePart part) {
        this.part = part;
        setToolTipText(part.getTitleToolTip());
        layout();
        redraw();
    }

    public boolean checkPart(IPresentablePart part) {
        return (this.part == part);
    }

    public void setSected(boolean selected) {
        isSelected = selected;
    }

    /**
     * Paint the title bar
     */
    public void paintControl(PaintEvent e) {
        Rectangle clientArea = getBounds();
        Image img = new Image(e.display, clientArea.width, clientArea.height);
        GC gc = new GC(img);

        gc.setForeground(presentation.getColorBorder());
        gc.drawRectangle(0, 0, clientArea.width - 1, clientArea.height - 1);

        Color colorTop;
        Color colorBottom;

        if (isMouseOver) {
            if (isSelected) {
                colorTop = selectedBottom;
                colorBottom = selectedTop;
            } else {
                colorTop = mouseOverTop;
                colorBottom = mouseOverBottom;
            }
        } else {
            if (isSelected) {
                colorTop = selectedTop;
                colorBottom = selectedBottom;
            } else {
                colorTop = unselectedTop;
                colorBottom = unselectedBottom;
            }
        }
        gc.setForeground(colorTop);
        gc.setBackground(colorBottom);
        gc.fillGradientRectangle(1, 1, clientArea.width - 2, clientArea.height - 2, true);

        if (part != null) {
            Image partImage = part.getTitleImage();
            gc.drawImage(partImage, 2, 2);

            Color colorText = new Color(getDisplay(), 0, 0, 0);
            // gc.setFont(font);
            gc.setForeground(colorText);
            String dirty = "";
            if (part.isDirty()) {
                dirty = "*";
            }
            int closeImageOffset = 0;
            if (part.isCloseable()) {
                closeImageOffset = 20;
            }
            String text = shortenText(gc, dirty + part.getTitle(), clientArea.width - 25
                    - closeImageOffset);
            gc.drawText(text, partImage.getBounds().width + 7, 3, true);
        }

        if (part.isCloseable()) {
            if (isCloseSelected) {
                gc.drawImage(closeSelectedImage, clientArea.width - 20, 3);
            } else {
                gc.drawImage(closeUnselectedImage, clientArea.width - 20, 3);
            }
        }

        e.gc.drawImage(img, 0, 0);
        gc.dispose();
        img.dispose();
    }

    public IPresentablePart getPart() {
        return part;
    }

    public boolean isCloseSelected() {
        return isCloseSelected;
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.eclipse.swt.widgets.Widget#dispose()
     */
    @Override
    public void dispose() {
        unselectedTop.dispose();
        unselectedBottom.dispose();
        selectedTop.dispose();
        selectedBottom.dispose();
        mouseOverTop.dispose();
        mouseOverBottom.dispose();
        font.dispose();
        super.dispose();
    }
}

/*******************************************************************************
 * Copyright (c) 2009 Siemens AG
 * 
 * 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:
 *    Kai T枚dter - initial API and implementation
 *******************************************************************************/

package com.siemens.ct.mp3m.ui.presentation;

import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.presentations.IPresentablePart;
import org.eclipse.ui.presentations.IStackPresentationSite;

public class Title extends AbstractClosable {
    private IStackPresentationSite site;

    Color colorTop = new Color(getDisplay(), 135, 135, 135);

    Color colorBottom = new Color(getDisplay(), 50, 50, 50);

    Color colorText = new Color(getDisplay(), 255, 255, 255);

    protected Font font = new Font(getDisplay(), "Default", 10, SWT.BOLD);

    /**
     * This listener responds to selection events in all tab buttons.
     */
    private MouseListener mouseListener = new MouseAdapter() {
        public void mouseDown(MouseEvent e) {
            if (part != null) {
                part.setFocus();
                if (isCloseSelected) {
                    site.close(new IPresentablePart[] { part });
                }
            }
        }
    };

    public Title(Composite parent, int style, IStackPresentationSite site) {
        super(parent, style | SWT.NO_BACKGROUND);
        this.site = site;
        addPaintListener(this);
        addMouseListener(mouseListener);
    }

    /**
     * Paint the title
     */
    public void paintControl(PaintEvent e) {
        Rectangle clientArea = getBounds();
        Image img = new Image(e.display, clientArea.width, clientArea.height);
        GC gc = new GC(img);

        gc.setForeground(colorTop);
        gc.setBackground(colorBottom);
        gc.fillGradientRectangle(0, 0, clientArea.width, clientArea.height, true);

        if (part != null) {
            gc.setFont(JFaceResources.getBannerFont());
            gc.setForeground(colorText);
            String dirty = "";
            if (part.isDirty()) {
                dirty = "*";
            }
            String text = shortenText(gc,dirty + part.getTitle(), clientArea.width - 30);
            gc.drawText(text, 5, 2, true);

            if (part.isCloseable()) {
                if (isCloseSelected) {
                    gc.drawImage(closeSelectedImage, clientArea.width - 20, 2);
                } else {
                    gc.drawImage(closeUnselectedImage, clientArea.width - 20, 2);
                }
            }
        }

        e.gc.drawImage(img, 0, 0);
        gc.dispose();
        img.dispose();
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.eclipse.swt.widgets.Widget#dispose()
     */
    @Override
    public void dispose() {
        colorTop.dispose();
        colorBottom.dispose();
        colorText.dispose();
        font.dispose();
        super.dispose();
    }

}


在plugin.xml中加入
 <extension
         point="org.eclipse.ui.presentationFactories">
      <factory
            class="com.siemens.ct.mp3m.ui.presentation.PresentationFactory"
            id="com.siemens.ct.mp3m.ui.presentation.PresentationFactory"
            name="Siemens CT Presentation"/>
   </extension>

然后在plugin_customization.ini和presentation.ini文件中加入
org.eclipse.ui/presentationFactoryId=com.siemens.ct.mp3m.ui.presentation.PresentationFactory

代码不难摘自MP3M,相信大家能理解,建议大家将这几个类放到自己的UI.PRESENTATION插件中,方便重复调用,最后提醒大家一点,就是如果你设置视图标题栏的弧线形外观,那么你上面的都是无用功了,不会出来效果的
4
2
分享到:
评论

相关推荐

    RCP自定义透视图切换按钮的右键菜单

    `org.eclipse.ui.presentationFactories`是一个关键的扩展点,它允许开发者自定义工作台元素的外观和行为。通过此扩展点,我们可以替换或增强默认的UI组件,如透视图切换按钮,添加自定义的右键菜单。 2. **创建...

    RCP 产品介绍图片

    9. **外观和主题**:RCP允许用户更改应用程序的外观,如图标、颜色主题等,以适应个人偏好。图片会呈现不同主题下的界面效果。 通过这些RCP产品介绍图片,我们可以直观地理解RCP的架构、工作流程和用户交互方式,...

    RCP中文入门教程.rar

    9. **外观(Look and Feel)**:RCP可以集成不同平台的外观和行为,以适应不同的操作系统,如Windows、Linux、Mac OS等。 在“RCP中文入门教程.pdf”中,你可能会学习到如何创建一个新的RCP项目,编写插件,定义...

    RCP弹出日期控件

    5. **国际化支持**: 为了适应不同的语言环境,控件可能需要支持日期格式的自定义和多语言显示。 6. **样式定制**: 为了匹配应用的整体风格,控件的外观和感觉(如颜色、字体等)可以进行定制。 7. **访问控制和...

    Eclipse RCP Common Navigator Demo

    1. **可定制性**:CNF允许开发者自定义视图的外观和行为,如节点的展开和折叠、搜索和过滤功能,以及右键菜单操作。在这个示例中,用户可以在导航视图中通过右键菜单创建新项目,这展示了CNF的扩展性。 2. **模型与...

    RCP部分课程

    最后,课程可能还会涵盖RCP的部署策略,包括如何创建可执行的RCP应用程序、发布更新以及如何使用产品配置文件(Product Configuration)来自定义应用的外观和行为。 总的来说,"RCP部分课程"将引导你深入理解RCP的...

    eclipse rcp 例子 源码

    SWT是Eclipse RCP的一部分,提供了一套与操作系统原生控件相集成的GUI组件,使得Eclipse RCP应用能够拥有与本地应用相似的外观和感觉。SWT通过JNI(Java Native Interface)与操作系统交互,实现了高性能的图形用户...

    RCP版JAVA 编辑器

    SWT使得RCP应用可以呈现出与操作系统一致的外观和交互体验,例如在Windows、Linux和macOS上都有良好的表现。 在创建RCP版JAVA编辑器时,首先需要理解RCP的工作原理。RCP应用是由一系列插件组成的,每个插件负责提供...

    RCP_Plug-in开发自学教程(CEC首发)

    通过RCP,开发者可以创建功能丰富的、具有专业外观的应用程序,同时利用Eclipse的插件体系结构实现模块化和重用性。 二、RCP开发环境搭建 要开始RCP开发,首先需要安装Eclipse IDE for RCP and RAP Developers。这...

    Eclipse4-RCP 开发教程

    4. **UI绑定与样式**:学习如何使用SWT和JFace库创建用户界面,以及应用CSS样式来定制界面外观。 5. **服务与依赖注入**:理解Eclipse 4的服务模型,以及如何使用@Inject注解进行依赖注入。 6. **国际化与本地化**...

    定制 SWT RCP 界面--如何编写一个漂亮的 SWT

    本文将详细介绍如何使用SWT和RCP来创建一个既功能强大又外观吸引人的桌面应用。 #### SWT简介 SWT是一个开源的图形工具包,它为Java程序提供了本地外观和高性能的图形用户界面组件。SWT的主要优势在于它能够直接...

    java swt自定义控件

    如果你正在开发Eclipse Rich Client Platform (RCP) 应用程序,自定义控件可以增强应用程序的用户体验。你可以将这些控件集成到工作台视图、编辑器或其他SWT部件中。 ### 8. 性能优化 尽管SWT提供了高效的本地化...

    RCP 开发自学教程

    - 根据具体需求定制视图的功能和外观。 - 例如,一个显示最近打开文件的视图。 **5.3 向VIEW里添加ACTION** - **ACTION**: - 在视图中集成常用的操作,提高用户体验。 #### 六、编辑器 **6.1 概述** - **...

    eclipsercp教程

    开发者可以通过继承和重写特定的类和方法来自定义应用程序的行为和外观。这种设计不仅提高了开发效率,也极大地增强了应用程序的灵活性和适应性。希望本文档能帮助您更好地理解和运用Eclipse RCP框架,为您的桌面...

    基于SWt,JFace的Rcp 开发实例

    在IT行业中,RCP(Rich Client Platform)是一种用于构建桌面应用程序的框架,它源自Eclipse项目,提供了强大的可扩展性和自定义能力。本实例项目"基于SWT、JFace的Rcp开发实例"旨在帮助初学者理解如何利用SWT和...

    Java RCP企业应用快速开发框架

    Java RCP(Rich Client Platform)是Oracle公司推出的用于构建桌面应用程序的一种框架,它基于Java Swing技术,提供了丰富的用户界面和强大的功能,使得开发者能够快速创建出具有专业外观和功能的桌面应用。Java RCP...

    开发你的第一个EclipseRCP应用程序汇编.pdf

    1. **品牌化**:定制应用的外观,包括图标、标题等,以体现其独特性。 2. **产品配置**:定义产品的元数据,如版本号、许可信息等。 3. **打包**:将所有必要的组件打包成一个可部署的格式,如安装程序或可执行文件...

    rcp treeview的相关资料

    RCP提供了`IFilter`接口,你可以实现该接口并调用`TreeViewer.addFilter`方法添加自定义过滤规则。 6. **排序器(Sorters)** 对于需要按特定顺序显示节点的情况,可以使用`ISorter`接口。通过`TreeViewer....

Global site tag (gtag.js) - Google Analytics