posts - 6, comments - 1, trackbacks - 0, articles - 0

2008年9月18日

public class NameManager implements INameManager {
       private Set namePool = new HashSet();
      

    public String generateName(String nameType) {

        if (!namePool.contains(nameType)) {
       namePool.add(nameType);
        return nameType;
  }

  int i = 1;
  while (namePool.contains(nameType + i)) {
   i++;
  }
  namePool.add(nameType + i);
  return nameType + i;
 }


posted @ 2008-09-23 11:44 jr4e 阅读(127) | 评论 (0)编辑 收藏

 ImageDescriptor temp = ImageDescriptor.createFromURL(url);

 org.eclipse.swt.graphics.Image image = temp.createImage();

posted @ 2008-09-19 12:38 jr4e 阅读(141) | 评论 (0)编辑 收藏

1.通过获得当前激活的editor来得到NameManager
IEditorPart editor = PlatformUI.getWorkbench()
    .getActiveWorkbenchWindow().getActivePage().getActiveEditor();
  ReportEditor reportEditor = null;
  if (editor instanceof ReportEditor)
   reportEditor = (ReportEditor) editor;

  String dsDisplayName = reportEditor.getDisplaynameByQDSName(table
    .getDataSet());
  INameManager nameManager = ((ReportEditorInput) reportEditor
    .getEditorInput()).getNameManager();
2.获得editPart的祖先的方法
GefUtilities.getAncestorOfClass(Class c, EditPart editPart)
public static EditPart getAncestorOfClass(Class c, EditPart editPart)

3.获得模型祖先的方法
ModelUtilities.getAncestorOfClass(Class c, EObject model));
public static EObject getAncestorOfClass(Class c, EObject model)

posted @ 2008-09-18 18:55 jr4e 阅读(180) | 评论 (0)编辑 收藏