GEF中同時使用兩個Router

                 gef中經常會有很多連線,這些連線如何和每個node連接,允不允許交叉等等都是用router來控制的.網上有篇文章對這個做了一些介紹:
          http://www-128.ibm.com/developerworks/cn/opensource/os-ecl-gef/part2/
                 我現在做的這個項目需要在兩個node之間同時存在多根線,如果不使用router的話就只能看見一根,在diagram的 figure里面set一個FanRouter作為缺省的router就可以解決這個問題.兩個node之間如果存在多根連線的話,FanRouter會把它們分布成扇形,每根連線都可以看見.但是FanRouter好像只能在diagram的figure里面設置,如果每根connection你都設置成FanRouter,反而不會啟效果,這可能跟它的handlecollision方法的算法有關.
                  但是設置成FanRouter之后有一個問題:我的項目中還有那種自連接的connection(該connection的source和target是同一個node),原先我是把這種connection的router設置為bendconnectionrouter,但是后來設置了FanRouter之后BendConnectionRouter好像就失效了,不管你的connection上面有多少個bendpoint都看不出來效果.
                  后來終于找到了讓這兩張router和平共處的辦法,只要加一行:fanRouter.setNextRouter(new BendPointConnectionRouter());setNextRouter這個方法有點怪,按照字面的理解,應該是fanrouter的下一個router,按理說應該是先用fanrouter來layout 連線,然后再使用BendPointConnectionRouter來layout 連線,但是它實際上是先用BendPointConnectionRouter來layout 連線,然后再使用fanRouter.

          posted @ 2008-08-12 18:06 小牛小蝦 閱讀(1792) | 評論 (2)編輯 收藏

          在GEF中實現帶content assist的Directedit

          GEF中自帶有Directeditrequest,所以實現Directedit還是比較容易的,八進制的gef例子里面就有實現.但我在給directedit加上content assist的時候卻發現由一個小bug不太好弄,費了兩天才搞定,現在先記下來,以供參考
            directedit是通過一個text celleditor來實現編輯功能的,所以可以在directeditmanager類里面的initCellEditor方法里面加上ContentAssistHandler來實現auto complete.但是加上去之后卻發現有一個問題:不支持用鼠標來選擇proposal.只能用鍵盤上的上下箭頭來選擇.雖然也可以用,但是終究不是那么的人性化.
            為了修復這個bug,走了不少的彎路,一開始以為是contentassist的問題,因為它是deprecated,所以換了3.3里面的assist api,發現還是不行.后來才知道是因為celleditor有一個focus listener,當用戶點擊proposals 來選擇一行的時候,celleditor的focus就lost了,就會調用focusLost方法,導致directedit編輯失敗.所以我重寫了celleditor的focusLost方法,把它設成當focus在contentassist的popup dialog就什么都不干,否則調用父類的focusLost方法.理論上是一個好的解決方法,但是contentassist的hasPopupFocus居然一直都返回false,這個方法也失敗了.
             最后,在bug.eclipse.org上面有人提到GMF里面的TextDirectEditManager是可以做到用鼠標選擇proposal的,于是又去看gmf的這個類,它也是繼承自DirectEditManager,不過它消除這個bug不是在listener上作文章,而是在commit方法里面,在這個方法里面判斷popup dialog是否是active的,如果是的話則給celleditor加上deactive lock,不允許它deactive,這樣來實現用鼠標選擇proposal.
          下面是TextDirectEditManager的方法commit里面的部分代碼:

          Shell activeShell = Display.getCurrent().getActiveShell();
                  if (activeShell != null
                      && getCellEditor().getControl().getShell().equals(
                          activeShell.getParent())) {
                      Control[] children = activeShell.getChildren();
                      if (children.length == 1 && children[0] instanceof Table) {
                          /*
                           * CONTENT ASSIST: focus is lost to the content assist pop up -
                           * stay in focus
                           */
                          getCellEditor().getControl().setVisible(true);
                          ((MyTextCellEditor) getCellEditor()).setDeactivationLock(true);
                          return;
                      }
                  }

            下面是MyTextCellEditor里面對于deactive lock的應用,MyTextCellEditor的deactive之前會判斷一下deactive lock是否為true:
          public boolean isDeactivationLocked() {
            return deactivationLock;
           }
           public void deactivate() {
            if (! isDeactivationLocked())
             super.deactivate();
            setDeactivationLock(false);
           }
           

           public void setDeactivationLock(boolean deactivationLock) {
            this.deactivationLock = deactivationLock;
           }

          posted @ 2008-08-05 17:09 小牛小蝦 閱讀(1121) | 評論 (1)編輯 收藏

          java生成xml文件的時候如何控制xml的縮進格式

          使用java自帶的xml api生成的xml文件,其格式都是沒有縮進的,每個element都是頂到最前面,今天終于找到了比較好的處理方法,趕緊記下來.

          使用Java標準的JAXP來輸出可以使用:
          Transformer transformer = TransformerFactory.newInstance().newTransformer();
          transformer.setOutputProperty(OutputKeys.INDENT, "yes");
          transformer.transform(new DOMSource(document), new StreamResult(outputFile));
          中間的紅色代碼是用于設置縮進的,比較遺憾的是JAXP只抽象出是否設置縮進(indent: yes|no),但并沒有抽象出設置縮進量長度的常量(indent-number),所以默認的縮進量長度為0。如果有下面這樣一個xml文檔:<root><a><b>c</b></a></root>會被格式化為:
          <root>
          <a>
          <b>c</b>
          </a>
          </root>
          由于JAXP只是一個Java一個處理XML的框架,根據實現的不一樣,可以傳入實現特定的某個Key來設置縮進量。比如在Java 1.4下面,可以通過下面語句將縮進量設為2:
          ransformer.setOutputProperty(
          "{http://xml.apache.org/xslt}indent-amount", "2");

          transformer.setOutputProperty(
           "{http://xml.apache.org/xalan}indent-amount", "2");
          上面兩句不同之處僅在于命名空間。

          而在Java 1.5下面,情況就有些復雜了。Java 1.5集成了JXAP 1.3(Java 1.4集成的是JXAP 1.1,不同之處參見http://java.sun.com/j2se/1.5.0/docs/guide/xml/jaxp/JAXP-Compatibility_150.html),實現基于Xerces類庫。由于內部實現上的Bug,導致了設置縮進的不同:
          TransformerFactory tf = TransformerFactory.newInstance();
          tf.setAttribute("indent-number", new Integer(2));
          Transformer transformer = tf.newTransformer();
          transformer.setOutputProperty(OutputKeys.INDENT, "yes");
          transformer.transform(new DOMSource(document), new StreamResult(new?BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile)))));
          注意紅色代碼的不同之處。第一句設置TransformerFactory的indent-number屬性,在Java 1.4下面運行會拋出異常,因為其不支持該屬性,而在Java 1.5中卻只能通過該屬性來設置縮進。后面標為紅色的代碼則是由于Sun實現上的Bug,只有通過StreamResult(Writer)構造函數生成才能正確設置縮進(通過OutputStream或者File生成的StreamResult是無法設置縮進的,其實現上會忽略任何非正式的屬性,而僅僅采用rt.jar下面com\sun\org\apache\xml\internal\serializer\output_xml.properties中的配置。詳細可以在com.sun.org.apache.xml.internal.serializer.ToStream類的setOutputStream方法中加斷點進行分析)
          ?
          如果忽略掉可移植性,確認綁定在Sun的JRE實現上面,則可以通過如下代碼來更好的實現:
          OutputFormat format = new OutputFormat(document);
          format.setIndenting(true);
          format.setIndent(2);
          Writer output = new BufferedWriter( new FileWriter(outputFile) );
          XMLSerializer serializer = new XMLSerializer(output, format);
          serializer.serialize(document);
          但是OutputFormat類和XMLSerializer類都是位于com.sun.org.apache.xml.internal.serialize包下。

          如果應用對增加一個300K左右的jar包不敏感的話,我還是強烈推薦用dom4j來處理xml,其API設計的非常易用,寫出來的代碼比用JXAP寫出來的代碼漂亮多了,也容易維護,也不會出現上面那種兩個Java版本不兼容的問題。

          posted @ 2008-05-27 16:31 小牛小蝦 閱讀(3998) | 評論 (5)編輯 收藏

          java中常見的文件讀寫方法

          Java 對文件進行讀寫操作的例子很多,讓初學者感到十分困惑,我覺得有必要將各種方法進行
          一次分析,歸類,理清不同方法之間的異同點。

          一.在 JDK 1.0 中,通常是用 InputStream & OutputStream 這兩個基類來進行讀寫操作的。
          InputStream 中的 FileInputStream 類似一個文件句柄,通過它來對文件進行操作,類似的,在
          OutputStream 中我們有 FileOutputStream 這個對象。

          用FileInputStream 來讀取數據的常用方法是:
          FileInputStream fstream = new FileInputStream(args[0]);
          DataInputStream in = new DataInputStream(fstream);
          用 in.readLine() 來得到數據,然后用 in.close() 關閉輸入流。
          完整代碼見 Example 1。

          用FileOutputStream 來寫入數據的常用方法是:
          FileOutputStream out out = new FileOutputStream("myfile.txt");   
          PrintStream p = new PrintStream( out );
          用 p.println() 來寫入數據,然后用 p.close() 關閉輸入。
          完整代碼見 Example 2。


          二.在 JDK 1.1中,支持兩個新的對象 Reader & Writer, 它們只能用來對文本文件進行操作,而
          JDK1.1中的 InputStream & OutputStream 可以對文本文件或二進制文件進行操作。

          用FileReader 來讀取文件的常用方法是:
          FileReader fr = new FileReader("mydata.txt");
          BufferedReader br = new BufferedReader(fr);
          用 br.readLing() 來讀出數據,然后用br.close() 關閉緩存,用fr.close() 關閉文件。
          完整代碼見 Example 3。

          用 FileWriter 來寫入文件的常用方法是:
          FileWriter fw = new FileWriter("mydata.txt");
          PrintWriter out = new PrintWriter(fw); 
          在用out.print 或 out.println 來往文件中寫入數據,out.print 和 out.println的唯一區別是后者寫
          入數據或會自動開一新行。寫完后要記得 用out.close() 關閉輸出,用fw.close() 關閉文件。  
          完整代碼見 Example 4。

          -------------------------------------------------------------- following is the source code of examples------------------------------------------------------

          Example 1:
          // FileInputDemo
          // Demonstrates FileInputStream and DataInputStream
          import java.io.*;

          class FileInputDemo {
            public static void main(String args[]) {
              // args.length is equivalent to argc in C
              if (args.length == 1) {
                try {
                  // Open the file that is the first command line parameter
                  FileInputStream fstream = new FileInputStream(args[0]);
                  // Convert our input stream to a DataInputStream
                  DataInputStream in = new DataInputStream(fstream);
                  // Continue to read lines while there are still some left to read
                  while (in.available() !=0) {
                    // Print file line to screen
                    System.out.println (in.readLine());
                  }
                  in.close();
                } catch (Exception e) {
                  System.err.println("File input error");
                }
              }
              else
                System.out.println("Invalid parameters");
            }
          }

          Example 2:
          // FileOutputDemo
          // Demonstration of FileOutputStream and PrintStream classes
          import java.io.*;

          class FileOutputDemo
          {   
            public static void main(String args[])  {             
            FileOutputStream out; // declare a file output object
              PrintStream p; // declare a print stream object

          try {
            // connected to "myfile.txt"
                out = new FileOutputStream("myfile.txt");
                // Connect print stream to the output stream
                p = new PrintStream( out );
                p.println ("This is written to a file");
                p.close();
              } catch (Exception e) {
                System.err.println ("Error writing to file");
              }
            }
          }

          Example 3:
          // FileReadTest.java
          // User FileReader in JDK1.1 to read a file
          import java.io.*;

          class FileReadTest {     
            public static void main (String[] args) {
              FileReadTest t = new FileReadTest();
              t.readMyFile();
          }
             
            void readMyFile() {
              String record = null;
              int recCount = 0;
              try {
          FileReader fr = new FileReader("mydata.txt");
                 BufferedReader br = new BufferedReader(fr);
                 record = new String();
                 while ((record = br.readLine()) != null) {
                   recCount++;
                   System.out.println(recCount + ": " + record);
          }
          br.close();
          fr.close();
               } catch (IOException e) {
                   System.out.println("Uh oh, got an IOException error!");
                   e.printStackTrace();
               }
          }
           
          }   

          Example 4:
          // FileWriteTest.java
          // User FileWriter in JDK1.1 to writer a file
          import java.io.*;

          class FileWriteTest {     
            public static void main (String[] args) {
              FileWriteTest t = new FileWriteTest();
              t.WriteMyFile();
          }
             
            void WriteMyFile() {
              try {
          FileWriter fw = new FileWriter("mydata.txt");
          PrintWriter out = new PrintWriter(fw);   
          out.print(“hi,this will be wirte into the file!”);  
          out.close();
          fw.close();
               } catch (IOException e) {
                   System.out.println("Uh oh, got an IOException error!");
                   e.printStackTrace();
               }
          }
           
          }   

          posted @ 2008-05-06 16:36 小牛小蝦 閱讀(450) | 評論 (0)編輯 收藏

          InstallShield InstallAnywhere 培訓要點記錄(二)

                      10)使用ISMP 11.5的project file
                          ISMP 11.5的project file是uip格式的,IA不能直接打開它。我們可以在ISMP 11.5中導出一種DIM file,然后在
                          IA的organization-->DIM Reference-->add DIM Reference中使用它。ISMP 11 sp1之前的版本IA不再兼容
                      11)installer運行時參數
                          你可以在installer運行的時候添加一些參數,比如
                          installer.exe -i console //在console模式下運行
                          //在silent模式下運行,由于silent模式不會有任何界面,所以你可以
                          //設置一些安裝的屬性,格式如下:
                          installer.exe -i silent <propertyname>=<value>
                          //具體實例:
                          installer.exe -i silent USER_INSTALL_DIR=C:\Mydirectory
                          //如果你屬性很多,你可以都寫在一個文件中,然后引用就可以了
                          installer.exe -i silent -f <path to the properties file>
                      12)用代碼啟動IA的build
                          稍微復雜一點的java項目在編譯打包的時候都少不了要用到ant。如果我們要在ant中啟動IA來制作安裝程序該怎么做呢
                          IA的安裝目錄下有一個build.exe,用它就可以了。
                          build.exe <path to IA project file>
                      13)source path
                          在Edit菜單里面可以設置source path。感覺它跟ISMP的alias是一樣的。無非就是讓你設置IA_HOME,PROJECT_HOME等等。
                          和alias不同的是,source path都是global,沒有project類型的。source path存放在C:\Documents and Settings\Administrator\InstallAnywhere\80\Enterprise\preferences中
                      14)merge modules
                          當我們需要有一個project包含其他project的時候,就要用到merge modules。最典型的例子就是office包含word,powerpoint
                          ,excel等。merge modules最少要有兩個project,一個parent project,若干個child project。merge modules主要有以下幾種:
                          i. design time merge module
                           這種merge module直接把child project拷貝到了parent project中,child project中的panel和action都會在parent project
                           的安裝過程中出現,并且你可以在parent project中修改它們。如果原來的child project做了某些變化,parent project中的child project不會有任何變化。
                           這種merge module只生成一個uninstaller,它會卸載掉整個軟件產品。如果要只卸載child project,好像可以通過把child project
                           設成feature來實現,但我目前還沒有實驗過。
                          ii. dynamic time merge module
                            這種merge module不拷貝child project到parent project中,它只鏈接到child project。所以child project的任何變化都會反映到
                            parent project中。但是你不能在parent project中修改child project的panel和action,因為你只是鏈接到child project。
                            這種merge module會生成多個uninstaller,分別用來卸載parent project 和child projects。
                          iii. build time merge module
                             和dynamic time merge module類似,不同的是build time merge module不會出現child project的panel。換句話說,child project是以silent模式安裝的。
                      怎么在具體的項目中用merge module呢?首先,你需要把child project build成merge module,會生成一個文件。然后在parent project的
                      orgnization-->Modules 導入就可以了
                      15)Custom Code
                          IA的advanced designer已經可以滿足大部分用戶的需要了,如果你所要的功能advanced designer還無法實現,你可以自己編寫Custom Code來實現。可以說
                          Custom Code是IA的more advanced designer。
                          Custom Code分成以下幾種:
                          i.custom code actions
                          ii.custom code panels
                          iii.custom code consoles
                          iv.custom code rules
                          在IA的安裝目錄下有一個javadoc目錄,里面有IA提供的api的文檔,跟java的api的文檔的使用方法是一樣的。IA為以上四種Custom Code提供了四個
                          缺省的類來實現,分別是CustomCodeAction,CustomCodePanel,CustomCodeConsoleAction,CustomCodeRule,你可以去繼承它們并添加你需要的
                          功能。
                          代碼寫好了之后不能直接用于IA中,還需要編譯,打包。打包有兩種方法
                          一)打包成類的JAR包
                             先寫好代碼,然后用javac命令編譯(當然你也可以用eclipse,netbean來得到class文件),最后把class file壓成jar包。
                             點擊Add Action-->Execute Custom Code,指定你的jar包的位置,如果用到了第三方的jar包,記得把它們添加到“Dependencies”中
                             ps:點擊Add Action,你會看到有四個tab:General,Panels,Consoles,Plug-ins。如果你是Custom Code Action,要選擇General里面的
                             Execute Custom Code,如果你是custom code panels,你要選擇Panels里面的Execute Custom Code,如果是custom code consoles,
                             要選擇Consoles里面的Execute Custom Code,如果是custom code rules,不能通過Add Action添加,你需要點擊Add Rule-->evaluate custom code
                             來執行
                          二)打包成plugin
                          先寫好代碼,然后用javac命令編譯(當然你也可以用eclipse,netbean來得到class文件)。
                          創建一個properties文件,然后把這個properties文件打包成一個jar包。可見與第一種方法的區別就是多了一個屬性文件
                          舉一個屬性文件的例子:
                           plguin.name=my custom action
                           plugin.main.class=MySampleAction
                           plugin.type=action
                           //如果你寫了preinstall,那在preinstall view中Add Action-->Plugin里面可以看見這個plugin,否則是看不見的。
                           plugin.available=preinstall,install,postinstall
                           //property.myproperty=this value
                           property.database=localhost
                           打包完成后,把jar包拷貝到IA安裝目錄下的plugins文件夾,然后重啟IA(eclipse的用戶肯定很熟悉這個操作吧,呵呵) 
                           然后你就可以在Add Action-->Plug-Ins里面發現你自己寫的plugin了。
                           最后列一下IA提供的api中比較重要的方法(IA提供了一個zip包IAClasses.zip在IA安裝目錄下)
                           public class MySampleAction extends CustomCodeAction
                           {
                            public  void install(InstallerProxy ip)
                          {
                           }
                           }
                           subsititue(String var)-recursively gets the variable value
                          getVariable(String var)- jaut gets the variable value
                      for example:
                           database_name=$user_install_dir$/mydir
                          subsititue(String var) C:\pf\macrovision\mydir
                          getVariable(String var)
                           $user_install_dir$/mydir
                          
                            public class MyCustom Panel extend CustomCodePanel{
              public boolean setupUI(CustomCodePanelProxy ccpp){
                  //execute some condition or logic
                  return true or false;//if true ,display,or don't display
                  public voidpanelIsDisplayed()
                  {//you will put controls and logic for displaying the panel
                 
                  //this is where you will use java's swing classes to display controls on your dialogs
                  //just for text area,if you wanna add a button to the bottom,then you need
                  //to create a new dialog by swing ,
                  }
                  public boolean okToContinue()
                  {
                  }
              }
              }
           
             public class MyCustomConsole extend CustomCodeConsoleAction{
              public boolean setup(CustomCodePanelProxy ccpp){
              //any validation you want to execute before displaying this console panel
              you will put here
                  }
              
              }
              }
              public class MyCustomRule extends CustomCodeRule{
           
                  public void evaluateRule()
                  {
                  //in this method,you can put the logic to evaulate this custom rule
                  //return true or false
                  }
              }
              }
              在IA安裝目錄下的Custom Code文件夾,你可以找到一些sample code,更多的sample code可以到
              它的網站上查詢。

                  最后,引用training teacher的一句話作為本文的結尾“不管你的產品有多好,用戶第一印象是看你的安裝程序,如果你的安裝程序不夠人性化,甚至安裝失敗了,那用戶對它的評價就不會高”

          posted @ 2007-07-30 17:09 小牛小蝦 閱讀(3354) | 評論 (1)編輯 收藏

          InstallShield InstallAnywhere 培訓要點記錄(一)

                  不知道你是否注意過,當你安裝java jdk的時候,當你安裝微軟office的時候,當你裝db2的時候,你都會看到一個熟悉的標記---installshield。installshield可以說是當今安裝程序解決方案的巨無霸了,功能十分強大,你可以用它制作出你想要的安裝程序。但是功能的強大也帶來一個壞處,就是要上手非常難。所以公司特意請macrovision(就是制作installshield的公司)的人給我們進行了一個training,感覺收獲還是很大的,所以把我認為重要的地方紀錄下來,一方面萬一自己忘了可以查一查,另一方面說不定對別人也有幫助。
                  先從版本說起。installshield有專門用于制作java安裝程序的產品,由于java是跨平臺的語言,所以installshield對應的產品就叫installshield multiple platform,簡稱ismp。我接觸的最早版本是ismp 5.0,后來又出了ismp 11.5,再后來ismp改名字叫Install Anywhere(以下簡稱IA)。目前我們training用的版本是IA 8.0,相信應該是最新的版本了。IA是共享軟件,不注冊的話有21天的試用期。
                  安裝程序是一個可定制性非常強的東西,每個軟件作者的需求都不一樣。有的推崇簡單就是美,一般只需要用戶選擇安裝的目錄,然后就一路next就裝完了;但有的軟件非常復雜,比如需要設置參數,需要選擇安裝哪些部分,甚至需要啟動windows的系統服務。這時候就需要比較復雜的配置了。installshield針對兩種用戶設計了不同的開發環境:一種是common designer,另一種是Advanced Designer。當你第一次打開IA的時候,缺省的是common designer,你只需要做一些簡單的配置,比如產品的名稱,需要安裝的文件,要不要綁定虛擬機等等,然后就可以build出一個安裝程序了。Advanced Designer是為高級用戶設置的,提供了更多,更豐富的功能,你可以用它來打造你所需要的安裝程序。本文主要是針對Advanced Designer進行一些說明。
                      1)安裝模式(install modes)
                      gui:這是最常用的一種模式,在安裝過程中會彈出若干個panel,比如welcome panel,license panel,destination panel等等。
                      console:用這種模式安裝程序時,不會出現panel。它的所有信息都在控制臺中出現。說的再通俗一點,就是整個安裝過程只有一個dos窗口,這個窗口先會顯示一行信息歡迎你安裝本軟件,然后是讓你選擇destination,再安裝,最后會顯示一行安裝成功的信息
                      silent:顧名思義,這種模式在安裝的時候不會彈出任何窗口,它會安靜地裝上軟件,所以用戶也不能自己設定安裝目錄,一般都市由安裝程序安裝到固定的目錄上
                      2)install sets
                         很多安裝程序都有完全安裝,最小安裝,自定義安裝等選項,這一般是用features來實現的。你可以把你的產品分成幾個features,然后由用戶來選擇一部分進行安裝。
                      3)actions
                         IA中很多操作被稱為actions,常見的有copy files,delete files,modifying registry,  creating service,  modifying configurations files等
                      4)variable
                         IA中很重要的一個概念,你可以用variable來存放屬性信息,比如安裝目錄,用戶名等等。比如
                         安裝目錄可能會在很多地方都用到,如果你安裝目錄是硬編碼的,萬一將來要修改就要改
                         很多地方,容易出錯;如果用variable來保存的話,只要修改變量值就可以了。注意一點:variable
                         的值基本上都是string類型的
                      5)magic folders
                         IA里面獨有的概念,但感覺沒什么新意,就是variables的一種,專門用于定義folder的
                         variable而已
                      6)InstallAnywhere registry
                         不同于windows的registry,這是InstallAnywhere自己的registry。每個用IA制作的安裝程序,在安裝的過程中
                         都會把自己注冊到這個InstallAnywhere registry(注意:你只能在InstallAnywhere registry找到安裝的
                         component,找不到product)。它的一個典型應用就是當你需要檢查這個機器上是否安裝過某個軟件的時候,就可以
                         用search這個IA registry。不過如果你是用其他工具制作的安裝程序,IA registry就不會有記錄了。
                      7)execute command&execute script
                         execute command是用來執行command,常用的dos命令(copy,cd等)你都可以寫在這里。execute script其實就是
                         execute command的加強版:如果你有多個命令,不需要建多個execute command,把它們寫在execute script就好了
                      8)計算所需空間
                         在IA中,默認的空間大小是用byte來計算的,所以如果你的軟件比較大的話,那一長串的阿拉伯數字會把用戶嚇倒的
                         解決方法是,在pre-install summary panel的配置項中,有一個是Edit Custom Field。在那里新建一個field。Variable
                         name是顯示給用戶看的內容,比如你可以寫disk space。variable value是你的軟件所需的硬盤大小。你可以先算出來
                         ,存在一個變量中,然后讓variable value等于這個變量就可以了。
                      9)results variable
                         用來存放用戶的選擇。比如在show message dialog中,有一個results variable是$CHOSEN_DIALOG_BUTTON$
                         它用來存放用戶按的是OK 還是Cancel

          posted @ 2007-07-30 17:04 小牛小蝦 閱讀(2457) | 評論 (2)編輯 收藏

          Brand your Eclipse RCP applications

               摘要: How to understand and use Eclipse Production Configuration ...  閱讀全文

          posted @ 2007-06-26 12:32 小牛小蝦 閱讀(861) | 評論 (0)編輯 收藏

          eclipse,GEF 小技巧

               摘要: 1.在tabbedProperties(eclipse3.2以上支持)中,如果要建立一個treeview,且想要click任何一列都可以實現celledit,需要在創建treeview的時候加上style: SWT.FULL_SELECTION
          2.tabbedProperties中section的大小現在無法做到根據widget的大小自動調整,目前只能用getMinimumHeight()返回一個固定值  閱讀全文

          posted @ 2007-04-11 17:31 小牛小蝦 閱讀(528) | 評論 (0)編輯 收藏

          [轉載]Eclipse插件及RCP開發中的第三方庫的設置

          很多人在開發RCP時,發現開發時都沒問題,但導出成包時卻報找不到第三方庫中類的錯誤。主要原因就是沒有將第三方庫配置好。現在我給出一個實現項目的配置為示例,以供參考。 原文出處:http://www.eclipseworld.org/bbs/read.php?tid=1133   環境:Eclipse3.2M3 一個RCP的實際項目 

          一、最關鍵的就是plugin.xml和MANIFEST.MF   
          所有界面上的最后操作,結果都是保存在這兩個文件中。注意:“.classpath”文件只是開發時對引用第三庫有用,打包發行之后它的作用就沒有了,還得靠plugin.xml和MANIFEST.MF。
          1、plugin.xml文件
          <?xml version="1.0" encoding="GB2312"?>
          <?eclipse version="3.0"?>
          <plugin>
          ?? <extension
          ???????? id="AdminConsole"
          ???????? point="org.eclipse.core.runtime.applications">
          ??????? <application>
          ??????????? <run class="com.wxxr.management.admin.console.AdminConsole"/>
          ??????? </application>
          ?? </extension>
          ?
          ?? <extension id="AdminConsole" point="org.eclipse.core.runtime.products">
          ? <product name="%productName" application="com.wxxr.management.admin.console.AdminConsole">
          ?? <property name="appName" value="%swtAppName"/>
          ?? <property name="windowImages" value="icons/eclipse.gif,icons/eclipse32.gif"/>
          ?? <property name="aboutText" value="%aboutText"/>
          ?? <property name="aboutImage" value="icons/eclipse_lg.gif"/>
          ?? <property name="windowImages" value="icons/alt16.gif,icons/eclipse.gif"/>
          ? </product>
          ?? </extension>
          ??
          ?? <extension
          ????? point="org.eclipse.ui.perspectives">
          ????? <perspective
          ??????????? class="com.wxxr.management.admin.console.monitor.MonitorPerspective"
          ??????????? name="%perspectiveName"
          ??????????? id="com.wxxr.management.admin.console.monitor.MonitorPerspective"/>
          ????? <perspective
          ??????????? class="com.wxxr.management.admin.console.configure.ConfigurePerspective"
          ??????????? name="%configurePerspectiveName"
          ??????????? id="com.wxxr.management.admin.console.configure.ConfigurePerspective"/>
          ????? <perspective
          ??????????? class="com.wxxr.management.admin.console.jmx.JMXPerspective"
          ??????????? name="%jmxPerspectiveName"
          ??????????? id="com.wxxr.management.admin.console.jmx.JMXPerspective"/>
          ?? </extension>
          ?<extension
          ?? point="org.eclipse.ui.editors">
          ?? <editor
          ?? name="事件列表"
          ?? icon="icons/alt16.gif"
          ?? class="com.wxxr.management.admin.console.log.ui.LogEditor"
          ?? id="com.wxxr.management.admin.console.log.ui.LogEditor">
          ?? </editor>
          ?? <editor
          ?? name="地圖"
          ?? icon="icons/map_view.gif"
          ?? class="com.wxxr.management.admin.console.map.MapEditor"
          ?? id="com.wxxr.management.admin.console.map.MapEditor">
          ?? </editor>
          ?</extension>
          ?? <extension
          ???????? point="org.eclipse.ui.views">
          ????? <category
          ??????????? id="com.wxxr.management.admin.console.monitor.view"
          ??????????? name="%views.category.name"/>
          ????? <view
          ??????????? id="com.wxxr.management.admin.console.navigator.ui.StationExploreView"
          ??????????? name="工作站"
          ??????????? icon="icons/eclipse.gif"
          ??????????? class="com.wxxr.management.admin.console.navigator.ui.StationExploreView"
          ??????????? category="com.wxxr.management.admin.console.monitor.view"/>
          ????? <view
          ??????????? name="事件細節"
          ??????????? icon="icons/eclipse.gif"
          ??????????? category="com.wxxr.management.admin.console.monitor.view"
          ??????????? class="com.wxxr.management.admin.console.monitor.eventview.EventDetailView"
          ??????????? id="com.wxxr.management.admin.console.monitor.eventview.EventDetailView" />
          ????? <view
          ??????????? name="事件統計"
          ??????????? icon="icons/eclipse.gif"
          ??????????? category="com.wxxr.management.admin.console.monitor.view"
          ??????????? class="com.wxxr.management.admin.console.monitor.view.SystemEventStatisticsView"
          ??????????? id="com.wxxr.management.admin.console.monitor.view.SystemEventStatisticsView" />
          ????? <view
          ??????????? name="緊急事件處理"
          ??????????? icon="icons/eclipse.gif"
          ??????????? category="com.wxxr.management.admin.console.monitor.view"
          ??????????? class="com.wxxr.management.admin.console.emergency.ui.EmergencyEventReceiverView"
          ??????????? id="com.wxxr.management.admin.console.emergency.ui.EmergencyEventReceiverView" />
          ????? <category
          ??????????? id="com.wxxr.management.admin.console.jmx.view"
          ??????????? name="%views.category.name"/>
          ????? <view
          ??????????? name="JMX Connections"
          ??????????? icon="icons/eclipse.gif"
          ??????????? category="com.wxxr.management.admin.console.jmx.view"
          ??????????? class="com.wxxr.management.admin.console.jmx.ui.JMXExploreView"
          ??????????? id="com.wxxr.management.admin.console.jmx.ui.JMXExploreView" />
          ????? <view
          ??????????? name="JMX Attributes View"
          ??????????? icon="icons/eclipse.gif"
          ??????????? category="com.wxxr.management.admin.console.jmx.view"
          ??????????? class="com.wxxr.management.admin.console.jmx.ui.AttributesView"
          ??????????? id="com.wxxr.management.admin.console.jmx.ui.AttributesView" />
          ????? <view
          ??????????? name="JMX Operations View"
          ??????????? icon="icons/eclipse.gif"
          ??????????? category="com.wxxr.management.admin.console.jmx.view"
          ??????????? class="com.wxxr.management.admin.console.jmx.ui.OperationsView"
          ??????????? id="com.wxxr.management.admin.console.jmx.ui.OperationsView" />
          ????? <view
          ??????????? name="JMX MBean View"
          ??????????? icon="icons/eclipse.gif"
          ??????????? category="com.wxxr.management.admin.console.jmx.view"
          ??????????? class="com.wxxr.management.admin.console.jmx.ui.MBeanView"
          ??????????? id="com.wxxr.management.admin.console.jmx.ui.MBeanView" />
          ?? </extension>
          ?? <extension
          ???????? id="AdminConsole"
          ???????? point="org.eclipse.core.runtime.products">
          ????? <product
          ??????????? application="com.wxxr.management.admin.console.AdminConsole"
          ??????????? name="AdminConsole"/>
          ?? </extension>
          ??
          </plugin>
          ? 2、META-INF\MANIFEST.MF文件
          ??? 注意:(1)這里require-bundle定義了項目依賴的插件。
          (2)Bundle-ClassPath定義了引用的第三方庫,別忘了把AdminConolse項目自己console.jar加進去,否則連自己項目里的類都會找不到。
          Manifest-Version: 1.0
          Bundle-ManifestVersion: 2
          Bundle-Name: %pluginName
          Bundle-SymbolicName: com.wxxr.management.admin.console; singleton:=true
          Bundle-Version: 1.0.0
          Bundle-Activator: com.wxxr.management.admin.console.AdminConsolePlugin
          Bundle-Localization: plugin
          Require-Bundle: org.eclipse.ui,
          ?org.eclipse.core.runtime,
          ?org.eclipse.core.resources,
          ?org.eclipse.gef,
          ?org.eclipse.ui.forms,
          ?org.eclipse.ui.console
          Eclipse-AutoStart: true
          Bundle-Vendor: %providerName
          Bundle-ClassPath: console.jar,
          ?lib/commons-codec-1.3.jar,
          ?lib/jboss.jar,
          ?lib/jbossall-client.jar,
          ?lib/jboss-jmx.jar,
          ?lib/jboss-system.jar,
          ?lib/log4j-1.2.8.jar,
          ?lib/wxxr-common-1.0-b1.jar,
          ?lib/wxxr-common-jboss-1.0-b1.jar,
          ?lib/wxxr-db-persistence-1.0-b1.jar,
          ?lib/wxxr-jboss-controller-1.0-b1.jar,
          ?lib/wxxr-jboss-workstation-1.0-b1.jar,
          ?lib/wxxr-remoting-1.0-b1.jar,
          ?lib/wxxr-security-1.0-b1.jar,
          ?lib/xerces-2.6.2.jar,
          ?lib/xmlParserAPIs-2.2.1.jar,
          ?lib/xmlrpc-2.0.jar
          ?3、build.properties文件
          這個文件主要是用Eclipse導出包的時候用。
          source.console.jar = src/
          output.console.jar = bin/
          bin.includes = plugin.xml,\
          ?????????????? *.jar,\
          ?????????????? console.jar, \
          ?????????????? plugin.properties
          ??????????????
          pluginName = Admin Console Plug-in
          providerName = WXXR.com.cn
          perspectiveName = Admin Console
          configurePerspectiveName= Configure
          jmxPerspectiveName= JMX Console
          ??????????????
          jars.extra.classpath = lib/commons-codec-1.3.jar,\
          ?????????????????????? lib/jboss.jar,\
          ?????????????????????? lib/jbossall-client.jar,\
          ?????????????????????? lib/jboss-jmx.jar,\
          ?????????????????????? lib/jboss-system.jar,\
          ?????????????????????? lib/log4j-1.2.8.jar,\
          ?????????????????????? lib/wxxr-common-1.0-b1.jar,\
          ?????????????????????? lib/wxxr-common-jboss-1.0-b1.jar,\
          ?????????????????????? lib/wxxr-db-persistence-1.0-b1.jar,\
          ?????????????????????? lib/wxxr-jboss-controller-1.0-b1.jar,\
          ?????????????????????? lib/wxxr-jboss-workstation-1.0-b1.jar,\
          ?????????????????????? lib/wxxr-security-1.0-b1.jar,\
          ?????????????????????? lib/wxxr-remoting-1.0-b1.jar,\
          ?????????????????????? lib/xerces-2.6.2.jar,\
          ?????????????????????? lib/xmlParserAPIs-2.2.1.jar,\
          ?????????????????????? lib/xmlrpc-2.0.jar
          4、plugin.properties,這個放一些上面幾個文件用到的變量。
          pluginName= WXXR Admin Console
          providerName= wxxr.com.cn
          ?
          productName= WXXR SMS Operation Platform
          appName= WXXR Admin Console
          perspectives.browser.name= WXXR Admin Console
          views.category.name= WXXR Admin Console
          views.browser.name= Browser
          views.history.name= History
          views.stationexplore.name= Stations
          views.tasklist.name= Task List
          views.loglist.name= Workstation Monitor
          monitor.message.detail=Monitor Message Detail
          monitor.message.statistics=????
          ?
          swtAppName= AdminConsole
          aboutText= WXXR Admin Console \n\n\
          (c) Copyright WXXR Ltd. and others 2003, 2004.? All rights reserved.\n\
          Visit http://www.wxxr.com.cn
          ?二、圖形方式 有時直接編輯plugin.xml等文件容易出錯(全角空格什么的),那么可以用圖形編輯方式來,不過最后結果還是反映到plugin.xml等文件中的。我把plugin.xml打開,然后一個項一個項的把圖截下來,以供大家參考。

          posted @ 2007-01-04 14:10 小牛小蝦 閱讀(707) | 評論 (1)編輯 收藏

          從插件/RCP中取得文件路徑的方法

          作者:hopeshared 引用地址:http://www.aygfsteel.com/hopeshared/archive/2005/12/20/24798.html 最近社區里問這個問題的人特別多,所以在這里將自己用到的幾個方法寫出來。假如以后還有其他的方法,會進行更新。 從插件中獲得絕對路徑: AaaaPlugin.getDefault().getStateLocation().makeAbsolute().toFile().getAbsolutePath()); 通過文件得到Project: IProject project = ((IFile)o).getProject(); 通過文件得到全路徑: String path = ((IFile)o).getLocation().makeAbsolute().toFile().getAbsolutePath(); 得到整個Workspace的根: IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); 從根來查找資源: IResource resource = root.findMember(new Path(containerName)); 從Bundle來查找資源: Bundle bundle = Platform.getBundle(pluginId); URL fullPathString = BundleUtility.find(bundle, filePath); 得到Appliaction workspace: Platform.asLocalURL(PRODUCT_BUNDLE.getEntry("")).getPath()).getAbsolutePath(); 得到runtimeworkspace: Platform.getInstanceLocation().getURL().getPath(); 從編輯器來獲得編輯文件: IEditorPart editor = ((DefaultEditDomain)(parent.getViewer().getEditDomain())).getEditorPart(); IEditorInput input = editor.getEditorInput(); if(input instanceof IFileEditorInput){ IFile file = ((IFileEditorInput)input).getFile(); }

          posted @ 2006-12-28 13:37 小牛小蝦 閱讀(275) | 評論 (0)編輯 收藏

          僅列出標題
          共3頁: 上一頁 1 2 3 下一頁 
          <2025年7月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          導航

          統計

          常用鏈接

          留言簿(6)

          隨筆檔案

          文章檔案

          eclipse

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 辽中县| 绿春县| 和田县| 剑川县| 潮州市| 介休市| 右玉县| 醴陵市| 苏尼特右旗| 富平县| 福安市| 日土县| 合川市| 修水县| 平陆县| 罗定市| 南城县| 绥中县| 古田县| 太和县| 灵石县| 镇安县| 罗平县| 昭平县| 罗源县| 嘉定区| 安泽县| 仲巴县| 当涂县| 彝良县| 平邑县| 尖扎县| 京山县| 昔阳县| 鄄城县| 孟津县| 咸阳市| 冀州市| 桐柏县| 名山县| 鲁甸县|