sidebar 隐藏/显示
try{
//do what you want to do before sleeping
Thread.sleep(1000);//sleep for 1000 ms
//do what you want to do after sleeptig
}
catch(ItrerruptedException ie){
//If this thread was intrrupted by nother thread
}

要添加一个树型的preference pages,可以对plug.xml增加如下扩展点

 <extension
        point="org.eclipse.ui.preferencePages">
      <page        class="de.tu_darmstadt.informatik.st.pegasus.collaboration.eclipse_plugin.preferences.PegasusPerferencePage"
  id="de.tu_darmstadt.informatik.st.pegasus.collaboration.eclipse_plugin.preferences.PegasusPreferencePage"
         name="Pegasus">
      </page

         <page
              name="Collaboration Server"              category="de.tu_darmstadt.informatik.st.pegasus.collaboration.eclipse_plugin.preferences.PegasusPreferencePage"
 class="de.tu_darmstadt.informatik.st.pegasus.collaboration.eclipse_plugin.preferences.CollaborationServerPreferencePage"           id="de.tu_darmstadt.informatik.st.pegasus.collaboration.eclipse_plugin.preferences.CollaborationServerPreferencePage">
   </extension>
 

注意,collaboration server 是子节点,所以它的category需填入跟节点的id。与此同时,根节点的category要留空(千万注意,不留空情况在3.3里无法显示,我就是在这个问题上败了近半个小时。)

Goal:  create a LabelProvider for a View, then it needs the images. If images are not from the default system, but in our own directory. How can i get the url of images ?

Solution: 

Eclispe 3.0 or alter:

URL url = Activator.getDefault().find(new Path(IMG_URL);

Now in 3.2 the find method is deprecated,  

So, we should use the following method:

URL url = Activator.getPathRelToPlugIn(IMG_URL);  

Activator is the Class of plugin, IMG_URL is the local path of  image.

In Class Activator:

    public static URL getPathRelToPlugIn(String filePath) {
          return Platform.getBundle(PLUGIN_ID).getEntry(filePath);
    }

After got the url  a image will be created as the result.

ImageDescriptor id = ImageDescriptor.createFromURL(url);
Image fileImage = id.createImage();

one method

            String filename = "test/testfiles/testDAOUpload.xml";
            File testfile = new File(filename);
            System.out.println(testfile.getAbsolutePath());
            FileInputStream fileinput = new FileInputStream(testfile
                    .getAbsolutePath());
            int x = fileinput.available();
            byte b[] = new byte[x];
            fileinput.read(b);
            String xmlDocument = new String(b);
            System.out.println(xmlDocument);

想把如XML格式的String转化成InputStream来生成一个Document

本想使用new StringBufferInputStream(string); 

Java API提示StringBufferInputStream已经deprecated,但可以使用StringReader class来生成stream,问题是我也看过StringReader的API,并没有提供和InputStream有关的方法。

难道这是一个BUG?

这里好像也有人提出过同样的问题。 http://bugs.sun.com/bugdatabase/view_bug.do;:YfiG?bug_id=4094886

 

最后只好用ByteArrayInputStream方法

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = factory.newDocumentBuilder();

ByteArrayInputStream stream = new
ByteArrayInputStream(string.getBytes());
Document doc = docBuilder.parse(stream);
stream.close();
话说sun就不打算解决这种小的bug么?
当然,生成一个Document也可以使用InputSource类
Document document = docBuilder.parse(new InputSource(new StringReader(content)));
先生成一个StringReader,然后再构件一个InputSource,一样也可达成目的。