如鵬網(wǎng) 大學(xué)生計(jì)算機(jī)學(xué)習(xí)社區(qū)

          CowNew開源團(tuán)隊(duì)

          http://www.cownew.com 郵件請聯(lián)系 about521 at 163.com

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            363 隨筆 :: 2 文章 :: 808 評(píng)論 :: 0 Trackbacks

          1、從TextEditor繼承,調(diào)用setSourceViewerConfiguration,并傳進(jìn)去一個(gè)從SourceViewerConfiguration 繼承的配置類,就可以實(shí)現(xiàn)各種代碼editor。
          2、swt盡量使用GridLayout布局(不是java.awt中的GridLayout,而是swt中的)和GridData域。文章:http://coolbear.yculblog.com/post.89429.html

          3、得到文件的編輯器的方法:
          ??? public static IEditorPart findEditor(IFile file){
          ??????? IEditorReference[] editors = getActivePage().getEditorReferences();;
          ??????? for (int i = 0; i < editors.length; i++) {
          ??????????? IEditorPart part = (IEditorPart)editors[i].getPart(false);
          ??????????? if (part != null ){
          ??????????????? IEditorInput input = part.getEditorInput();
          ??????????????? if(input instanceof FileEditorInput && ((FileEditorInput)input).getFile().equals(file))
          ??????????????????? return part;
          ??????????? }???????????????
          ??????? }
          ??????? return null;
          ??? }

          4、得到工作區(qū)中所有工程的方法:
          ??????? IProject[] projects = ResourcesPlugin.getWorkspace().getRoot()
          ??????????????? .getProjects();
          這在開發(fā)自己的工程向?qū)У臅r(shí)候很有用處。
          5、工程特有文件判斷方法
          project.getFile("cownew.prj").exists();
          project.getDescription().hasNature();
          給工程增加Nature的方法:
          ?IProjectDescription desc = project.getDescription();
          String[] oldNatureIds = desc.getNatureIds();
          ??????????????? String[] newNatureIds? = new String[oldNatureIds.length +1];
          ??????????????? System.arraycopy(oldNatureIds, 0, newNatureIds, 0, oldNatureIds.length);
          ??????????????? newNatureIds[oldNatureIds.length] = "CowNewNature";
          ??????????????? desc.setNatureIds(newNatureIds);
          ??????????????? project.setDescription(desc, monitor);
          6、創(chuàng)建文件夾的方法:
          IFolder folder = project.getFolder("myfold");
          if (folder!=null && !folder.exists())
          ? folder.create(false, true, null);

          7、彈出包選擇對(duì)話框的方法:
          ElementListSelectionDialog dialog = new ElementListSelectionDialog(
          ??????????????????? getShell(), new LabelProvider());
          ??????????? dialog.setIgnoreCase(false);
          dialog.setElements(getAllPackages().toArray());
          ??????????? String path = currentPackage();
          ?dialog.setInitialSelections(new Object[] { path });
          dialog.open();
          fPKName.setText((String) dialog.getFirstResult());

          public List getAllPackages() {
          ??????? List list = new ArrayList();
          ??????? IResource res = getFirstSelection();
          ??????? IProject project = res.getProject();
          ??????? File file = project.getFolder("src").getLocation().toFile();
          ??????? File[] fs = file.listFiles();
          ??????? for (int i = 0; i < fs.length; i++) {
          ??????????? if (fs[i].isDirectory())
          ??????????????? iterator("", fs[i], list);
          ??????? }
          ??????? Collections.sort(list);
          ??????? return list;
          ??? }
          8 objectClass="org.eclipse.core.resources.IFile"代表菜單應(yīng)用到文件
          9 透視圖的的實(shí)現(xiàn)很簡單,就是在構(gòu)造函數(shù)里邊打開一些視圖,使一些action(這樣菜單和按鈕也就都可用)可以用,比如:
          String editorArea = layout.getEditorArea();
          ??????? IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT,
          ??????????????? 0.30f, editorArea);
          ??????? left.addView(PACKAGE_VIEW_ID);
          ?layout.setEditorAreaVisible(true);
          ?layout.addShowViewShortcut(IDESystem.BUSINESSVIEW_ID);

          posted on 2006-07-21 00:33 CowNew開源團(tuán)隊(duì) 閱讀(1279) 評(píng)論(1)  編輯  收藏

          評(píng)論

          # re: cownew開源-eclipse插件開發(fā)學(xué)習(xí)知識(shí)點(diǎn)筆記 2006-11-26 20:28 luckylq
          我是個(gè)新手
          請問怎么用SWT來做一個(gè)重主窗口一個(gè)Btton彈出對(duì)話框?
          謝謝
          可以發(fā)郵件給我嗎?My Email:luckylq3@163.com  回復(fù)  更多評(píng)論
            


          只有注冊用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 杂多县| 永善县| 正阳县| 尚志市| 太仓市| 芒康县| 磐石市| 从化市| 大方县| 崇左市| 西贡区| 拉孜县| 郸城县| 德保县| 封丘县| 岳阳市| 临澧县| 泗洪县| 微博| 马关县| 十堰市| 库伦旗| 康马县| 虞城县| 苏尼特左旗| 普兰店市| 南木林县| 荣成市| 新竹县| 三台县| 辽中县| 富平县| 五寨县| 旺苍县| 称多县| 万荣县| 孝感市| 秭归县| 翁源县| 孝昌县| 安乡县|