??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲精品中文字幕有码专区,精品婷婷色一区二区三区蜜桃,99久久www免费http://www.aygfsteel.com/keweibo/category/36491.html一? Java 多能 Delphi,Powerbuilder ... zh-cnSat, 09 Jun 2012 02:16:38 GMTSat, 09 Jun 2012 02:16:38 GMT60通过RCP创徏的viewQ怎样直接昄出来http://www.aygfsteel.com/keweibo/articles/380322.htmlKeKeFri, 08 Jun 2012 03:25:00 GMThttp://www.aygfsteel.com/keweibo/articles/380322.htmlhttp://www.aygfsteel.com/keweibo/comments/380322.htmlhttp://www.aygfsteel.com/keweibo/articles/380322.html#Feedback0http://www.aygfsteel.com/keweibo/comments/commentRss/380322.htmlhttp://www.aygfsteel.com/keweibo/services/trackbacks/380322.html
解决Ҏ:

原来是设|了q个D?/p>

configurer.setSaveAndRestore(true);
代码如下:

package com.act.mac.upload.intro;

import org.eclipse.ui.application.IWorkbenchConfigurer;
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
import org.eclipse.ui.application.WorkbenchAdvisor;
import org.eclipse.ui.application.WorkbenchWindowAdvisor;

public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor {

private static final String PERSPECTIVE_ID = "com.act.mac.upload.perspective";

    public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
        return new ApplicationWorkbenchWindowAdvisor(configurer);
    }
    
    public void initialize(IWorkbenchConfigurer configurer) {
        super.initialize(configurer);
        //configurer.setSaveAndRestore(true);//注释掉就OK?/span>
    }

public String getInitialWindowPerspectiveId() {
return PERSPECTIVE_ID;
}
}



Ke 2012-06-08 11:25 发表评论
]]>
RCP开?--Log4j配置http://www.aygfsteel.com/keweibo/articles/376986.htmlKeKeSat, 28 Apr 2012 09:56:00 GMThttp://www.aygfsteel.com/keweibo/articles/376986.htmlhttp://www.aygfsteel.com/keweibo/comments/376986.htmlhttp://www.aygfsteel.com/keweibo/articles/376986.html#Feedback0http://www.aygfsteel.com/keweibo/comments/commentRss/376986.htmlhttp://www.aygfsteel.com/keweibo/services/trackbacks/376986.html
q行控制台打?(只在控制CQ不?log文g?
log4j:WARN No appenders could be found for logger (myrcp.OpenViewAction).
log4j:WARN Please initialize the log4j system properly.
q是因ؓ没有dLog4j的配|信息?/div>
在启动RCP的插件中的startҎ里:
    public void start(BundleContext context) throws Exception {
        super.start(context);
        plugin = this;       
        Properties prop = new Properties();
        try {
            prop.load(Activator.class.getResourceAsStream("log4j.properties")); //$NON-NLS-1$
        } catch (IOException e) {
            // e.printStackTrace();
        }
        PropertyConfigurator.configure(prop);
    }
在myrcp.Activator同目录下添加log4j.propertiesQ?nbsp;


Ke 2012-04-28 17:56 发表评论
]]>
SWT的SHELL样式http://www.aygfsteel.com/keweibo/articles/326316.htmlKeKeFri, 16 Jul 2010 07:26:00 GMThttp://www.aygfsteel.com/keweibo/articles/326316.htmlhttp://www.aygfsteel.com/keweibo/comments/326316.htmlhttp://www.aygfsteel.com/keweibo/articles/326316.html#Feedback0http://www.aygfsteel.com/keweibo/comments/commentRss/326316.htmlhttp://www.aygfsteel.com/keweibo/services/trackbacks/326316.html




Shell   dlgShell   =   new    Shell(parent,    SWT.DIALOG_TRIM   |    SWT.APPLICATION_MODAL);   
   所谓模态对话框Q就是指除非采取有效的关闭手D,用户的鼠标焦Ҏ者输入光标将一直停留在其上的对话框。非模态对话框则不会强制此U特性,用户可以在当? 对话框以及其他窗口间q行切换?/font>

setShellStyle(q里可以L讄样式);能够? |的样式如下Q(以下属性可以多选,但是某些属性相冲突时会D讄的其他属性失效)
SWT.BORDER //建立一个有Ҏ但没有标题栏的窗?/span>
SWT.CLOSE //建立一个只有关闭按钮的H口
SWT.MIN  //建立一个不能最大化的窗?/span>
SWT.MAX, //建立一个可以最大化最化的窗?/span>
SWT.NO_TRIM //建立一个没有Q何边界和标题栏的H口
SWT.RESIZE //建立一个可以改变大的H口
SWT.TITLE //建立一个没有标题栏图标Q没有关闭按钮的H口
SWT.ON_TOP //建立一个L在上的窗口,注意Q此属性最好与CLOSE、MIN、MAX一起用?/span>
SWT.TOOL  //建立一个类似工h的窗?/span>
SWT.APPLICATION_MODAL //建立一个APPLICATION模态窗?/span>
SWT.MODELESS //建立一个非模态窗?/span>
SWT.PRIMARY_MODAL //建立一个PRIMARY模态窗?/span>
SWT.SYSTEM_MODAL  //建立一个SYSTEM模态窗?/span>
     q有两个快捷属性来建立H口
SHELL_TRIM //建立一个标准模式的H口Q相当于属性设|ؓCLOSE | TITLE | MIN | MAX | RESIZE
DIALOG_TRIM //建立一个对话框模式的窗口,相当于属性设|ؓTITLE | CLOSE | BORDER


Ke 2010-07-16 15:26 发表评论
]]>
透视囄标签Ҏ波浪?/title><link>http://www.aygfsteel.com/keweibo/articles/288679.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Tue, 28 Jul 2009 01:39:00 GMT</pubDate><guid>http://www.aygfsteel.com/keweibo/articles/288679.html</guid><wfw:comment>http://www.aygfsteel.com/keweibo/comments/288679.html</wfw:comment><comments>http://www.aygfsteel.com/keweibo/articles/288679.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/keweibo/comments/commentRss/288679.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/keweibo/services/trackbacks/288679.html</trackback:ping><description><![CDATA[使用代的方式Q具體類代碼如下<br /> package gecs.mes.ke.reelup.apps;<br /> <br /> import gecs.mes.ke.reelup.sys.IAppConstants;<br /> <br /> import org.eclipse.ui.IWorkbenchPreferenceConstants;<br /> import org.eclipse.ui.PlatformUI;<br /> import org.eclipse.ui.application.IWorkbenchConfigurer;<br /> import org.eclipse.ui.application.IWorkbenchWindowConfigurer;<br /> import org.eclipse.ui.application.WorkbenchAdvisor;<br /> import org.eclipse.ui.application.WorkbenchWindowAdvisor;<br /> <br /> public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor {<br /> <br />     private static final String PERSPECTIVE_ID = IAppConstants.DEFAULT_PERSPECTIVE_ID;<br /> <br />     public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {<br />         return new ApplicationWorkbenchWindowAdvisor(configurer);<br />     }<br />     <br />     public void initialize(IWorkbenchConfigurer configurer) {<br />         <br />         super.initialize(configurer);<br />         configurer.setSaveAndRestore(false);<br />         PlatformUI.getPreferenceStore().setValue(IWorkbenchPreferenceConstants.SHOW_INTRO, false);<br />         //a置視圖標題Ƅ的外觀弧線外觀<br />         PlatformUI.getPreferenceStore().setValue(IWorkbenchPreferenceConstants.DOCK_PERSPECTIVE_BAR, IWorkbenchPreferenceConstants.TOP_RIGHT);<br />         PlatformUI.getPreferenceStore().setDefault(IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS, false);<br />         //<br />         PlatformUI.getPreferenceStore().setValue(IWorkbenchPreferenceConstants.SHOW_PROGRESS_ON_STARTUP, true);<br />     }<br /> <br />     public String getInitialWindowPerspectiveId() {<br />         <br />         return PERSPECTIVE_ID;<br />     }<br /> }<br /> <br /> <br /> <img src ="http://www.aygfsteel.com/keweibo/aggbug/288679.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/keweibo/" target="_blank">Ke</a> 2009-07-28 09:39 <a href="http://www.aygfsteel.com/keweibo/articles/288679.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>解決在eclipse目中用utf-8字符時导出错?/title><link>http://www.aygfsteel.com/keweibo/articles/288671.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Tue, 28 Jul 2009 01:17:00 GMT</pubDate><guid>http://www.aygfsteel.com/keweibo/articles/288671.html</guid><wfw:comment>http://www.aygfsteel.com/keweibo/comments/288671.html</wfw:comment><comments>http://www.aygfsteel.com/keweibo/articles/288671.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/keweibo/comments/commentRss/288671.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/keweibo/services/trackbacks/288671.html</trackback:ping><description><![CDATA[在eclipse目中用utf-8字符可能会造成导出时生错误,E序不能正常q行 <br /> 我以前网上找到的办法都不好,解决的办法其实十分简? <br /> 在build.properties文g中加? <br /> <br /> javacDefaultEncoding.. = UTF-8 <img src ="http://www.aygfsteel.com/keweibo/aggbug/288671.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/keweibo/" target="_blank">Ke</a> 2009-07-28 09:17 <a href="http://www.aygfsteel.com/keweibo/articles/288671.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>往Eclipse RCP视图中添加右键弹单(轉)http://www.aygfsteel.com/keweibo/articles/288565.htmlKeKeMon, 27 Jul 2009 05:50:00 GMThttp://www.aygfsteel.com/keweibo/articles/288565.htmlhttp://www.aygfsteel.com/keweibo/comments/288565.htmlhttp://www.aygfsteel.com/keweibo/articles/288565.html#Feedback0http://www.aygfsteel.com/keweibo/comments/commentRss/288565.htmlhttp://www.aygfsteel.com/keweibo/services/trackbacks/288565.html 往eclipse的默认NavigationView中,d右键菜单Ҏ非常Ҏ的,甚至不需要自己写代码Q只要在plugin.xml中添加扩展项便可以了?br /> 但是q远q达不到我们的要求。如果要我们在自qrcpE序的View中添加右键弹单就不是很容易了。现在我介绍一下如何在一个树视图中针对不同的TreeObjectd不同的右键弹单的Ҏ?br /> 如果不清楚如何构Z个树Q请参?/font>http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/CatalogSWT-JFace-Eclipse.htm, q里有很多关于eclipse Tree的实例。简单将来,Eclipse中创建树有两U,一U是使用SWT提供的树Q依照一定的格式l其提供数据Q我自己只用q种Ҏ创徏一些简单的? 静态的树。另一U方法,针对于RCPE序Q可以用JFace提供的TreeViewerc,非常灉|q且易于扩展。用TreeViewer需要实? ITreeContentProvider接口和ITreeLableProvider接口。由于我的时间有限,不能向大家提供具体的实现ҎQ请原谅? 可以参考以下文章:http://eclipse.org/articles/treeviewer-cg/TreeViewerArticle.htm
在大体了解了如何构造一个树之后Q我们下面就来介l右键弹单context menu的实现方法?br /> 一个TreeViewer 必须l承ViewPartҎQƈ且重写其中的createPartControl(Composite parent)cR?/font>

1    public void createPartControl(Composite parent) {
2
3    /* Set the imput data and image model of the tree viewer,
4    * and layout the viewer on the left part of the composite.
5    */
6     viewer = new TreeViewer(parent);
7     viewer.setContentProvider(new ViewContentProvider());
8     viewer.setLabelProvider(new ViewLabelProvider());
9     viewer.setInput(createDummyModel());
10
11   createActions();
12   createMenus();
13   createContextMenu(parent);
14
15   //handles the actions related with treeviewer.
16   makeActions(parent);
17 }
其中Q第7?行ؓ讄TreeViewer的内Ҏ供器、图像提供器、以及初始化时的输入数据。第13行ؓ创徏右键弹出菜单?br />
1     private void createContextMenu(Composite parent) {
2
3          MenuManager mgr = new MenuManager();
4          mgr.setRemoveAllWhenShown(true);
5          mgr.addMenuListener(new IMenuListener() {
6              public void menuAboutToShow(IMenuManager manager) {
7                 fillContextMenu(manager);
8              }
9          });
10     Menu menu = mgr.createContextMenu(viewer.getControl());
11      viewer.getControl().setMenu(menu);
12     getSite().registerContextMenu(mgr, viewer);
13   }
W?行代? 中,setRemoveAllWhenShown(true)的作用是清空以前昄的菜单项Q当触发了menu事gӞ重新填充 QfillContextMenuQ,所以如果不把removeAllWhenShow|ؓtrue的话Q每点一下右键你׃看到菜单多Z倍来? Menu是swt的控Ӟ而Menumanager是Jface中的控gQ不象SWT那样直接同底层打交道。用MenuManager可以创徏Z? Menu对象。第十行mgr.createContextMenu(viewer.getControl());q里的viewer即ؓ上面的viewer。第十一行,然后我们树的setMenuҎ树控g与Menu控g联系在一起就好了?br /> 最重要的是W十二行Q这是context menu能不能显C的关键。一个视图中可以有多个context menu, 而每一个context menu都必L册给workbench。这需要通过调用org.eclipse.ui.IWorkbenchPartSite.registerContextMenu(MenuManager menuManager, ISelectionProvider selectionProvider)或者(当有多个注册的context menuӞorg.eclipse.ui.IWorkbenchPartSite.registerContextMenu(String menuId, MenuManager menuManager, ISelectionProvider selectionProvider) 增加的参数menuId用于区分不同的context menu?br /> 接下来,我们有两U方法来创徏右键弹出菜单V第一U,实现fillContextMenu()Ҏ。典型的实现代码如下Q?br /> 1     protected void fillContextMenu(IMenuManager manager) {
2  
3         manager.add(openAction);
4         manager.add(removeAction);
5          manager.add(addAction);
6               }

q些Action都可p己定义创建?br /> 另外的方法,可以~辑plugin.xml文g。不需要自己写M代码便可以显C出自己惌的弹出项?br /> q次先讲到这里,下次介绍另外的一U实现方式。(主要是由于刚创徏BlogQ不知道如何插入囄Q这么写太费劲也太枯燥了Q相信大家一定不能忍了吧Q咱们下ơ再?/font>Q?br />


Ke 2009-07-27 13:50 发表评论
]]>
eclispe RCP 技巧(轉)http://www.aygfsteel.com/keweibo/articles/288564.htmlKeKeMon, 27 Jul 2009 05:46:00 GMThttp://www.aygfsteel.com/keweibo/articles/288564.htmlhttp://www.aygfsteel.com/keweibo/comments/288564.htmlhttp://www.aygfsteel.com/keweibo/articles/288564.html#Feedback0http://www.aygfsteel.com/keweibo/comments/commentRss/288564.htmlhttp://www.aygfsteel.com/keweibo/services/trackbacks/288564.html

一、同时关闭所有打开的view 
 
在view?只有一个close,每次只能关闭当前H口
在eclipse的编辑窗口的标题上点右键,里面?close All
可以使用遍历的方法,遍历所有打开的ViewQ然后将光藏:
AsyncUtil.asyncExec(new Runnable()
{
       public void run()
       {
             IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
             IViewReference[] iViewReferences = page.getViewReferences();
             for (IViewReference iViewReference: iViewReferences)
                  if (!ID.equals(iViewReference.getId()))
                       page.hideView(iViewReference);
        }
});   
  二、RCP中生目标区的Bar 
 
产生U线区域的Bar,实现Ҏ如下Q?br /> 1、这个是perspectiveQ要创徏多个perspectiveQ然后设|某个ؓactive
2、在WorkbenchWindowAdvisor中preWindowOpen内,加下面这D代?br /> public void preWindowOpen() { 
        IPreferenceStore apiStore = PrefUtil.getAPIPreferenceStore();
        apiStore.setValue(IWorkbenchPreferenceConstants.DOCK_PERSPECTIVE_BAR,
                IWorkbenchPreferenceConstants.TOP_RIGHT);
        apiStore.setValue(
                IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS,
                false);
 }
3、需要加 config.setShowPespectivebar(true); 
三、RCP目Q-H口关闭事g 
在ApplicationWorkbenchWindowAdvisor中override
public boolean preWindowShellClose() {
        // do nothing, but allow the close() to proceed
        MessageBox msgBox = new MessageBox(new Shell(), SWT.YES|SWT.NO|SWT.ICON_QUESTION);
        msgBox.setText("退出系l?);
        msgBox.setMessage("定退出系l?");
        if(msgBox.open()==SWT.YES){
            return true;
        }
        return false;
    }
以后使用IWorkbenchWindow的getShell().close();都会调用该处代码.  
四、在RCP中设计界面适合桌面大小 
 
final int screenWidth = Display.getCurrent().getBounds().width;
final int screenHeight = Display.getCurrent().getBounds().height;
 
五、Treeviewer中通过代码Q选中树上的某个node节点 
StructuredSelection sel=new StructuredSelection(node);
 tree.setSelected(sel); 
六、TreeViewer实现双击展开、关?nbsp;
private class DoubleEventPro implements MouseListener {
        public void mouseDoubleClick(MouseEvent e) {
            TreeItem item = viewer.getTree().getItem(new Point(e.x, e.y));

            if (item != null && item.getItem(0).getText().trim().length() == 0) {
                viewer.expandToLevel(item.getData(), 1);
                return;
            }

            if (item != null && item.getItemCount() > 0
                    && item.getItem(0).getText().trim().length() > 0) {
                item.setExpanded(!item.getExpanded());
            }
        }

        public void mouseDown(MouseEvent e) {
        }
        public void mouseUp(MouseEvent e) {

        }
    } 
七?如何屏蔽掉视囄口上的右键弹单?


Ҏ一Q在 postWindowOpen() 中执行下面语?
PlatformUI.getWorkbench().getDisplay().addFilter(SWT.MouseUp, new Listener() {
    public void handleEvent(final Event event) {
        if(event.widget == your editor && event.button == 3) {
            int hwndCursor = OS.GetCapture ();
            OS.PostMessage(hwndCursor, OS.WM_LBUTTONDOWN, hwndCursor, OS.HTCLIENT | (OS.WM_MOUSEMOVE << 16));
        }
    }
});

其它Qorg.eclipse.ui.internal.presentations.util包中的StandardViewSystemMenucL制着q些菜单Q还没来得急仔l研IӞ研究q后再补?/font>

八、在使用tableviewer的时候导入大量数据的问题

创徏了一个tableviewerQ然后用setInputҎ导入数据Q如果数据量很大的话Ҏ无效率可言了,以下是几U解决的ҎQ?/font>

Ҏ一Q通过Ud滚动条来辑ֈ自动加蝲的目的,在滚动条的事件中加入页的代码,可以参考《Eclipse从入门到_N》第二版的P383

Ҏ二:分页昄Q?/font>http://www.eclipseworld.org/bbs/read-cec-tid-11678-keyword-table.htmlQ?/font>

Ҏ三:使用 Virtual TablesQJFace3.2的Viewer已经支持SWT.VIRTUAL样式
http://www.eclipse.org/articles/Article-SWT-Virtual/Virtual-in-SWT.html

1 int COUNT = 10000;
2 final String [] itemStrings = new String [COUNT];
3 for (int i = 0; i < COUNT; i++) {
4   itemStrings = "item " + i;
5 }
6 final Table table = new Table(parent, SWT.BORDER | SWT.VIRTUAL);
7 table.addListener(SWT.SetData, new Listener() {
8   public void handleEvent(Event event) {
9     TableItem item = (TableItem)event.item;
10     int index = event.index;
11     item.setText(itemStrings [index]);
12   }
13 });
14 table.setItemCount(COUNT);

九、在透视囑ֿh式栏中同时显C多个透视囑ֿh?/font>

如果在程序中做了多个个透视图,默认只显C初始透视囑ֿh式,每次都要 打开透视䏀—otherQ特ȝQ所以,一下提供两U方法:

1、在切换栏中昄
public class PIMWorkbenchAdvisor extends WorkbenchAdvisor {
    @Override
    public void postStartup() {
        super.postStartup();
        IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        //2007.01.11 讄同时昄多个透视图标
        PerspectiveBarManager barManager=((WorkbenchWindow)activeWorkbenchWindow).getPerspectiveBar();
        if(barManager != null){
            IPerspectiveDescriptor mailPerspective = WorkbenchPlugin.getDefault().getPerspectiveRegistry   ().findPerspectiveWithId("MyWork_mail.perspective");
            PerspectiveBarContributionItem item=new PerspectiveBarContributionItem(mailPerspective,activeWorkbenchWindow.getActivePage());
            barManager.addItem(item);
        }
}
2、在下拉框中(shortcut)昄
public class UiPerspective implements IPerspectiveFactory
{
    public void createInitialLayout(IPageLayout layout){
....
        //增加透视?br />         layout.addPerspectiveShortcut("net.sf.pim.plugin.UiPerspective");
        layout.addPerspectiveShortcut("MyWork_mail.perspective");
       }
}
十、控?#8220;最q打开文档”的个?br />        RCP中在l承ActionBarAdvisor的类中定?
       private IContributionItem reOpenAction = ContributionItemFactory.REOPEN_EDITORS.create(window);
       然后在fillMenuBar(IMenuManager menuBar)Ҏ中添加上面的aciton
       q行?#8220;最q打开的文?#8221;只有4个,如果惌己控?#8220;最q打开的文?#8221;的数量,则设|一下Workbench中的初始化首选项时RECENT_FILES的默认参数值如Q?br /> WorkbenchPlugin.getDefault().getPreferenceStore().setDefault(IPreferenceConstants.RECENT_FILES,10);

十一、设|Eclipse RCPE序的外观和首选项
       RCP应用E序的缺省外观是一个空白窗口,一般我们要通过一个WorkbenchAdvisorcd界面q行定制? WorkbenchAdvisor有很多回调方法,可以在preWindowOpen()Ҏ里设|菜单、工h、状态栏、进度栏、透视囑ֈ换工h否可 见,在fillActionBars()Ҏ里添加菜单和工具条项Q在getInitialWindowPerspectiveId()Ҏ里指定首选的 透视图?/font>

       ~省情况下,透视囑ֈ换工具位于窗口左上角Q在Eclipse里可以通过Window->Preferences-> Workbench->Appearance改变它的位置Q那么怎样用程序控制它呢?有两个方法,W一个是使用如下代码讄 IPreferenceStore中的变量Q?/font>

IPreferenceStore apiStore = PrefUtil.getAPIPreferenceStore();
apiStore.setValue(IWorkbenchPreferenceConstants.DOCK_PERSPECTIVE_BAR, IWorkbenchPreferenceConstants.TOP_RIGHT);
另一个方法是在plugin所在目录徏一个名为plugin_customization.ini的文Ӟ里面写如下内容:

your.plugin.id/DOCK_PERSPECTIVE_BAR=topRight
其他与plugin相关的Preference值可以用同样Ҏ讄?/font>

Update:在最新的Eclipse 3.1M5a版本中,对RCP应用E序菜单和工h的定制方法有所改变Q应该用新加入的ActionBarAdvisorcL完成此项工作?/font>

十二、获得自己开发的plugin被安装的目录
  /** *//**
     * @return 本插件的安装路径
     */
    public String getInstallDir() ...{
        if (installPath == null) ...{
            URL localUrl = null;
            try ...{
                localUrl = FileLocator.toFileURL(getDefault().getBundle()
                        .getEntry("/"));
                installPath = localUrl.getFile().substring(1);
            } catch (Exception e) ...{
                log(e);
            }
        }
        return installPath;
    }

轉自http://duguanglong002.blog.163.com/blog/static/26955626200955415545/



Ke 2009-07-27 13:46 发表评论
]]>
其它R程a問UIR程http://www.aygfsteel.com/keweibo/articles/286959.htmlKeKeThu, 16 Jul 2009 03:52:00 GMThttp://www.aygfsteel.com/keweibo/articles/286959.htmlhttp://www.aygfsteel.com/keweibo/comments/286959.htmlhttp://www.aygfsteel.com/keweibo/articles/286959.html#Feedback0http://www.aygfsteel.com/keweibo/comments/commentRss/286959.htmlhttp://www.aygfsteel.com/keweibo/services/trackbacks/286959.html
                    @Override
                    public void run() {
                            // TODO Auto-generated method stub
                             ... ...
                   }
                                   
 });


Ke 2009-07-16 11:52 发表评论
]]>
Eclipse切换界面示的語ahttp://www.aygfsteel.com/keweibo/articles/283352.htmlKeKeSat, 20 Jun 2009 06:42:00 GMThttp://www.aygfsteel.com/keweibo/articles/283352.htmlhttp://www.aygfsteel.com/keweibo/comments/283352.htmlhttp://www.aygfsteel.com/keweibo/articles/283352.html#Feedback0http://www.aygfsteel.com/keweibo/comments/commentRss/283352.htmlhttp://www.aygfsteel.com/keweibo/services/trackbacks/283352.html

首先要加入Eclipse的語a包,官方有提?a >www.eclipse.org注意適用的版本?br />
要切換不同的界面語言Q只需的快捷鏈接中加入參數Q?br />
-nl "zh_CN"  體中文
-nl "zh_TW" J體中文
-nl "en_US" 英文


C:\Program Files\eclipse\eclipse.exe -nl "en_US"



Ke 2009-06-20 14:42 发表评论
]]>
rcpdjar文ghttp://www.aygfsteel.com/keweibo/articles/268293.htmlKeKeThu, 30 Apr 2009 01:52:00 GMThttp://www.aygfsteel.com/keweibo/articles/268293.htmlhttp://www.aygfsteel.com/keweibo/comments/268293.htmlhttp://www.aygfsteel.com/keweibo/articles/268293.html#Feedback0http://www.aygfsteel.com/keweibo/comments/commentRss/268293.htmlhttp://www.aygfsteel.com/keweibo/services/trackbacks/268293.html 在plugin.xml中,runtime面Qclass-path节中Q点addQ选择刚才的jar包?OK?br />

Ke 2009-04-30 09:52 发表评论
]]>
pȝ托盤http://www.aygfsteel.com/keweibo/articles/244711.htmlKeKeFri, 05 Dec 2008 15:56:00 GMThttp://www.aygfsteel.com/keweibo/articles/244711.htmlhttp://www.aygfsteel.com/keweibo/comments/244711.htmlhttp://www.aygfsteel.com/keweibo/articles/244711.html#Feedback0http://www.aygfsteel.com/keweibo/comments/commentRss/244711.htmlhttp://www.aygfsteel.com/keweibo/services/trackbacks/244711.htmlpackage hellorcp.tool;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Tray;
import org.eclipse.swt.widgets.TrayItem;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.plugin.AbstractUIPlugin;

public class HookSysTray {

 private TrayItem trayItem;
 
 public HookSysTray() {
  
 }
 
 public void createSysTray(final IWorkbenchWindow window) {
  trayItem = initTrayItem(window);
  if(trayItem != null) {
   trayPopupMenu(window);
   trayMinimize(window);
  }
 }
 //最化到颖P
 private void trayMinimize(final IWorkbenchWindow window) {
  // TODO Auto-generated method stub
  window.getShell().addShellListener(new ShellAdapter(){

   @Override
   public void shellIconified(ShellEvent e) {
    // TODO Auto-generated method stub
    window.getShell().setVisible(false);
   }
   
  });
  trayItem.addListener(SWT.Selection, new Listener(){

   public void handleEvent(Event event) {
    // TODO Auto-generated method stub
    Shell shell = window.getShell();
    if(!shell.isVisible()) {
     shell.setVisible(true);
     window.getShell().setMinimized(false);
    }
   }
   
  });
 }
 //颖P?
 private void trayPopupMenu(final IWorkbenchWindow window) {
  // TODO Auto-generated method stub
  trayItem.addListener(SWT.MenuDetect, new Listener() {

   public void handleEvent(Event event) {
    // TODO Auto-generated method stub
    MenuManager trayMenu = new MenuManager();
    Menu menu = trayMenu.createContextMenu(window.getShell());
    fillTrayItem(trayMenu, window);
    menu.setVisible(true);
   }
  });
 }

 //造颖P菜雾
 private void fillTrayItem(IMenuManager trayMenu, final IWorkbenchWindow window) {
  Action exitSystem = new Action("退出系i[&E]",
AbstractUIPlugin.imageDescriptorFromPlugin(
    IAppConstants.APPLICATION_ID, IImagekey.EXIT_STSTEN)) {

     @Override
     public void run() {
      // TODO Auto-generated method stub
      PlatformUI.getWorkbench().close();
     }
   
  };
  trayMenu.add(exitSystem);
 }
 //初始?br />  private TrayItem initTrayItem(IWorkbenchWindow window) {
  // TODO Auto-generated method stub
  final Tray tray = window.getShell().getDisplay().getSystemTray();
  if(tray == null)
   return null;
  trayItem = new TrayItem(tray, SWT.NONE);
  trayItem.setImage(CacheImage.getInstance().getImage(
    IAppConstants.APPLICATION_ID, IImagekey.WINDOW_IMAGE));
  trayItem.setToolTipText(IAppConstants.APPLICATION_TITLE);
  return trayItem;
 }
 
 //最化E式H口
 public void windowMinimized(final Shell shell) {
  shell.setMinimized(true);
  shell.setVisible(false);
 }
 
 //
 public void disponse() {
  if(trayItem != null)
   trayItem.dispose();
 }
}



Ke 2008-12-05 23:56 发表评论
]]>
圖片R存(CacheImageQ?http://www.aygfsteel.com/keweibo/articles/244710.htmlKeKeFri, 05 Dec 2008 15:54:00 GMThttp://www.aygfsteel.com/keweibo/articles/244710.htmlhttp://www.aygfsteel.com/keweibo/comments/244710.htmlhttp://www.aygfsteel.com/keweibo/articles/244710.html#Feedback0http://www.aygfsteel.com/keweibo/comments/commentRss/244710.htmlhttp://www.aygfsteel.com/keweibo/services/trackbacks/244710.htmlpackage hellorcp.tool;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.plugin.AbstractUIPlugin;

public class CacheImage {

 private final Map<String, Image> imageMap = new HashMap<String, Image>();
 private static CacheImage INSTANCE = null;
 
 private CacheImage(){
  
 }
 //單例
 public static CacheImage getInstance() {
  if(INSTANCE == null)
   INSTANCE = new CacheImage();
  return INSTANCE;
 }
 //獲得圖片
 public Image getImage(String applicationId, String imageName) {
  if(imageName == null)
   return null;
  Image image = imageMap.get(imageName);
  if(image == null) {
   image = AbstractUIPlugin.imageDescriptorFromPlugin(applicationId,
imageName).createImage();//應用E序的IDQ圖片的路徑
   imageMap.put(imageName, image);
  }
  return image;
 }
 //dispose資源
 public void dispose() {
  Iterator<Image> iterator = imageMap.values().iterator();
  while(iterator.hasNext())
   iterator.next().dispose();
  imageMap.clear();
 }
}



Ke 2008-12-05 23:54 发表评论
]]>
示視圖(ShowViewAction Q與ActionManager一起?/title><link>http://www.aygfsteel.com/keweibo/articles/244709.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Fri, 05 Dec 2008 15:46:00 GMT</pubDate><guid>http://www.aygfsteel.com/keweibo/articles/244709.html</guid><wfw:comment>http://www.aygfsteel.com/keweibo/comments/244709.html</wfw:comment><comments>http://www.aygfsteel.com/keweibo/articles/244709.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/keweibo/comments/commentRss/244709.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/keweibo/services/trackbacks/244709.html</trackback:ping><description><![CDATA[<p>package testrcp.actions;</p> <p>import org.eclipse.jface.action.Action;<br /> import org.eclipse.jface.dialogs.ErrorDialog;<br /> import org.eclipse.ui.IWorkbenchPage;<br /> import org.eclipse.ui.IWorkbenchWindow;<br /> import org.eclipse.ui.PartInitException;<br /> import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;<br /> import org.eclipse.ui.views.IViewDescriptor;</p> <p>public class ShowViewAction extends Action implements IWorkbenchAction {</p> <p> private IWorkbenchWindow workbenchWindow;<br />  private IViewDescriptor desc;<br />  <br />  public ShowViewAction(IWorkbenchWindow window, IViewDescriptor desc) {<br />   super("");<br />   /** 获得视图的名U?*/<br />   String label = desc.getLabel();<br />   /** 讄操作的名U?*/<br />   setText(label);<br />   /** 讄操作的图标ؓ视图的图?*/<br />   setImageDescriptor(desc.getImageDescriptor());<br />   /** 讄操作的提C文?*/<br />   setToolTipText(label);<br />   setId("ShowView" + desc.getId());<br />   <br />   this.workbenchWindow = window;<br />   this.desc = desc;<br />  }<br />  <br />  @Override<br />  public void run() {<br />   /** 获得当前工作区及获得工作面 */<br />   IWorkbenchPage page = workbenchWindow.getActivePage();<br />   /** 如果面不ؓnull */<br />   if (page != null) {<br />    try {<br />     /** 昄视图 */<br />     page.showView(desc.getId());<br />    } catch (PartInitException e) {<br />     ErrorDialog.openError(workbenchWindow.getShell(), "打开视图错误<br /> Q?, e.getMessage(), e.getStatus());<br />    }<br />   }<br />  }</p> <p> @Override<br />  public void dispose() {<br />   <br />   workbenchWindow = null;<br />  }</p> <p>}<br /> </p> <img src ="http://www.aygfsteel.com/keweibo/aggbug/244709.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/keweibo/" target="_blank">Ke</a> 2008-12-05 23:46 <a href="http://www.aygfsteel.com/keweibo/articles/244709.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Action 理(ActionManager Q?/title><link>http://www.aygfsteel.com/keweibo/articles/244708.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Fri, 05 Dec 2008 15:45:00 GMT</pubDate><guid>http://www.aygfsteel.com/keweibo/articles/244708.html</guid><wfw:comment>http://www.aygfsteel.com/keweibo/comments/244708.html</wfw:comment><comments>http://www.aygfsteel.com/keweibo/articles/244708.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/keweibo/comments/commentRss/244708.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/keweibo/services/trackbacks/244708.html</trackback:ping><description><![CDATA[<p>package testrcp.actions;</p> <p>import org.eclipse.ui.IWorkbenchWindow;<br /> import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;<br /> import org.eclipse.ui.views.IViewDescriptor;</p> <p>public class ActionManager {</p> <p> public static IWorkbenchAction createHelloWorldAction(IWorkbenchWindow window) {<br />   if(window == null)<br />    throw new IllegalArgumentException();<br />   IWorkbenchAction helloWorldAction = new HelloWorldAction(window);<br />   return helloWorldAction;<br />  }<br />  <br />  /**获得plugin.xml文g中配|的视图信息*/<br />  public static IWorkbenchAction createShowViewAction(IWorkbenchWindow window, String viewId) {<br />   if(window == null)<br />    throw new IllegalArgumentException();<br />   IViewDescriptor desc = window.getWorkbench().getViewRegistry().find(viewId);<br />   IWorkbenchAction action = new ShowViewAction(window, desc);<br />   return action;<br />  }<br /> }<br /> </p> <img src ="http://www.aygfsteel.com/keweibo/aggbug/244708.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/keweibo/" target="_blank">Ke</a> 2008-12-05 23:45 <a href="http://www.aygfsteel.com/keweibo/articles/244708.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ApplicationWorkbenchWindowAdvisor ?/title><link>http://www.aygfsteel.com/keweibo/articles/244707.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Fri, 05 Dec 2008 15:42:00 GMT</pubDate><guid>http://www.aygfsteel.com/keweibo/articles/244707.html</guid><wfw:comment>http://www.aygfsteel.com/keweibo/comments/244707.html</wfw:comment><comments>http://www.aygfsteel.com/keweibo/articles/244707.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/keweibo/comments/commentRss/244707.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/keweibo/services/trackbacks/244707.html</trackback:ping><description><![CDATA[<p>package testrcp.app;</p> <p>import org.eclipse.jface.action.MenuManager;<br /> import org.eclipse.swt.SWT;<br /> import org.eclipse.swt.graphics.Image;<br /> import org.eclipse.swt.graphics.Point;<br /> import org.eclipse.swt.graphics.Rectangle;<br /> import org.eclipse.swt.widgets.Display;<br /> import org.eclipse.swt.widgets.Event;<br /> import org.eclipse.swt.widgets.Listener;<br /> import org.eclipse.swt.widgets.Menu;<br /> import org.eclipse.swt.widgets.Shell;<br /> import org.eclipse.swt.widgets.Tray;<br /> import org.eclipse.swt.widgets.TrayItem;<br /> import org.eclipse.ui.IWorkbenchWindow;<br /> import org.eclipse.ui.application.ActionBarAdvisor;<br /> import org.eclipse.ui.application.IActionBarConfigurer;<br /> import org.eclipse.ui.application.IWorkbenchWindowConfigurer;<br /> import org.eclipse.ui.application.WorkbenchWindowAdvisor;</p> <p>public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {</p> <p> private TrayItem trayItem;//pȝ托盘对象<br />  private Image trayImage;//pȝ托盘图标对象<br />  /** E序的菜单条 */<br />  private ApplicationActionBarAdvisor actionBarAdvisor;<br />  <br />     public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {<br />         super(configurer);<br />     }<br />     /** 创徏菜单条对?*/<br />     public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) {<br />         actionBarAdvisor = new ApplicationActionBarAdvisor(configurer);<br />      return actionBarAdvisor;<br />     }<br />     <br />     /** 打开H口前调用该ҎQ对H口初始化设|?*/<br />     public void preWindowOpen() {<br />         IWorkbenchWindowConfigurer configurer = getWindowConfigurer();<br />         configurer.setInitialSize(new Point(600, 400));<br />         configurer.setShowCoolBar(true);//工具?br />         configurer.setShowStatusLine(false);//状态栏<br />         <br />         configurer.setShowPerspectiveBar(true);//透视?br />         configurer.setShowProgressIndicator(true);//q度?br />         <br />         final IWorkbenchWindow window = super.getWindowConfigurer().getWindow();<br />         /** 创徏pȝ托盘 */<br />         trayItem = initTrayItem(window);<br />         /** 如果支持pȝ托盘Q则创徏托盘的菜?*/<br />         if(trayItem != null) {<br />          createPopupMenu(window);<br />         }<br />     }<br />     <br />     /**<br />   * 创徏pȝ托盘菜单<br />   * <br />   * @param window<br />   *            工作台窗口对?br />   */<br />     private void createPopupMenu(final IWorkbenchWindow window) {<br />   trayItem.addListener(SWT.MenuDetect, new Listener() {</p> <p>   @Override<br />    public void handleEvent(Event event) {<br />     MenuManager trayMenu = new MenuManager();<br />     Menu menu = trayMenu.createContextMenu(window.getShell());<br />     /**<br />      * 调用fillTrayItemҎ创徏pȝ托盘对象Q可以直接利用菜单栏中的操作 而不需要,重新创徏操作<br />      */<br />     actionBarAdvisor.fillTrayItem(trayMenu);<br />     menu.setVisible(true);<br />    }<br />    <br />   });<br />   <br />  }</p> <p> /**<br />   * 初始化系l托盘对?br />   * <br />   * @param window<br />   *            工作台窗口对?br />   * @return 该程序所对应的系l托盘对?br />   */<br />  private TrayItem initTrayItem(IWorkbenchWindow window) {<br />   final Tray tray = Display.getCurrent().getSystemTray();<br />   if(tray == null)<br />    return null;<br />   TrayItem trayItem = new TrayItem(tray, SWT.NONE);<br />   trayImage = Activator.getImageDescriptor("icons/logo.gif").createImage();<br />   trayItem.setImage(trayImage);<br />   trayItem.setToolTipText("System Tray");<br />   <br />   return trayItem;<br />  }</p> <p> @Override<br />  public void postWindowOpen() {<br />   //H口居中昄<br />   Shell shell = getWindowConfigurer().getWindow().getShell();<br />   Rectangle screenSize = Display.getDefault().getClientArea();<br />   Rectangle frameSize = shell.getBounds();<br />   shell.setLocation((screenSize.width - frameSize.width)/2, (screenSize.height - frameSize.height)/2);<br />  }<br />     <br />  /** 释放H口Q释攄l托?*/<br />  public void dispose() {<br />   if (trayImage != null) {<br />    trayImage.dispose();<br />    trayItem.dispose();<br />   }<br />  }</p> <p>}<br /> </p> <img src ="http://www.aygfsteel.com/keweibo/aggbug/244707.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/keweibo/" target="_blank">Ke</a> 2008-12-05 23:42 <a href="http://www.aygfsteel.com/keweibo/articles/244707.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>H口居中示代碼http://www.aygfsteel.com/keweibo/articles/244706.htmlKeKeFri, 05 Dec 2008 15:40:00 GMThttp://www.aygfsteel.com/keweibo/articles/244706.htmlhttp://www.aygfsteel.com/keweibo/comments/244706.htmlhttp://www.aygfsteel.com/keweibo/articles/244706.html#Feedback0http://www.aygfsteel.com/keweibo/comments/commentRss/244706.htmlhttp://www.aygfsteel.com/keweibo/services/trackbacks/244706.html重寫ApplicationWorkbenchWindowAdvisor的postWindowOpenҎ
public void postWindowOpen() {
  //H口居中
  Shell shell = getWindowConfigurer().getWindow().getShell();
  Rectangle screenSize = Display.getDefault().getClientArea();
  Rectangle frameSize = shell.getBounds();
  shell.setLocation((screenSize.width - frameSize.width)/2, (screenSize.height - frameSize.height)/2);
 }



Ke 2008-12-05 23:40 发表评论
]]>
վ֩ģ壺 üɽ| | | | ¬| | ׿| | | ʯ| | ƺ| | Զ| | | | | ع| | ï| Ӽ| | | ƶ| | ֵ| ʵ| | | | | | | | | ٳ| ǰ| | | |