學(xué)無(wú)止境  
          日歷
          <2005年10月>
          2526272829301
          2345678
          9101112131415
          16171819202122
          23242526272829
          303112345
          統(tǒng)計(jì)
          • 隨筆 - 9
          • 文章 - 0
          • 評(píng)論 - 2
          • 引用 - 0

          導(dǎo)航

          常用鏈接

          留言簿(2)

          隨筆分類(lèi)

          隨筆檔案

          搜索

          •  

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

           

          2005年10月17日

          You have implemented your own graphical editor as a new eclipse plugin. You are looking for a way to add zoom functions into the graphical editor. It is very easy!
          1. Add the action into the toolbar:
          ...in Class: ActionBarContributor...
              ...in Method: contributeToToolBar...
                  toolBarManager.add(getAction(GEFActionConstants.ZOOM_IN));
                  toolBarManager.add(getAction(GEFActionConstants.ZOOM_OUT));
                  toolBarManager.add(new ZoomComboContributionItem(getPage()));

          2. Connect the Zoom Manager with your edit part:
          ...in Class: YourEditor...
              ...in Method: configureGraphicalViewer...
                  ScalableFreeformRootEditPart rootEditPart= new ScalableFreeformRootEditPart();
                  getGraphicalViewer().setRootEditPart(rootEditPart);

                  ZoomManager manager = rootEditPart.getZoomManager();
                  IAction action = new ZoomInAction(manager);
                  getActionRegistry().registerAction(action);
                  action = new ZoomOutAction(manager);
                  getActionRegistry().registerAction(action);

                  //define the zoom possibilities
                  double[] zoomLevels = new double[] {0.25,0.5,0.75,1.0,1.5,2.0,2.5,3.0,4.0};
                  manager.setZoomLevels(zoomLevels);
             ...in Method: getAdapter...
                  if (type == ZoomManager.class)
                        return ((ScalableFreeformRootEditPart) getGraphicalViewer().
                                  getRootEditPart()).getZoomManager();

          That's all! Now you have two buttons to zoom in and zoom out. And you can see the zoom level in percent.  With the example here you  can change  zoom level from 25% to 400%.

          posted @ 2005-10-25 23:38 lucia 閱讀(1380) | 評(píng)論 (0)編輯 收藏
           
          There is an example of creating linked resources in code.
          IProject project = workspace.getProject("Project");//assume this exists
          IFolder link = project.getFolder("Link");
          IPath location = new Path("C:\TEMP\folder");
          if (workspace.validateLinkLocation(location).isOK()) {
          link.createLink(location, IResource.NONE, null);
          } else {
          //invalid location, throw an exception or warn user
          }

          This example will create a linked folder called "Link" that is located at "c:\temp\folder".

          link.getFullPath() => "/Project/Link"
          link.getLocation() => "c:\temp\folder"
          link.getRawLocation() => "temp/folder"
          link.isLinked() => "true"
          IFile child = link.getFile("abc.txt");
          child.create(...);
          child.getFullPath() => "/Project/Link/abc.txt"
          child.getLocation() => "c:\temp\folder\abc.txt"
          child.getRawLocation() => "c:\temp\folder\abc.txt"
          child.isLinked() => "false"

          posted @ 2005-10-17 05:25 lucia 閱讀(843) | 評(píng)論 (0)編輯 收藏
           
          Copyright © lucia Powered by: 博客園 模板提供:滬江博客
          主站蜘蛛池模板: 响水县| 丰宁| 荃湾区| 甘南县| 平潭县| 江口县| 德清县| 沐川县| 吴堡县| 专栏| 青浦区| 松江区| 海安县| 长治市| 综艺| 城步| 西城区| 佛教| 赤水市| 临桂县| 扶沟县| 灵宝市| 廊坊市| 阿坝县| 镇江市| 临桂县| 沈阳市| 潼南县| 石楼县| 重庆市| 满洲里市| 同仁县| 镶黄旗| 正阳县| 大竹县| 台东市| 盘锦市| 漳平市| 霞浦县| 六安市| 无为县|