Eclipse plugin 笔记

  1. 取得当前plugin的状态保存地AutoDAOUIPlugin.getDefault().getStateLocation().toFile().getAbsolutePath()
      
  2.  打开一个对话框MessageDialog.openError(getShell(), "错误信息", "数据库连接设置错误!"),同样也可以使用静态类MessageDialog打开一个普通的消息对话框
  3. 在当前上下文中打开一个对话框NewDriverWizard wizard = new NewDriverWizard();
    		wizard.setNeedsProgressMonitor(true);
    		WizardDialog wizardDialog = new WizardDialogAutoDAOLocation(shell, wizard, 600, 650); //$NON-NLS-1$
    		wizardDialog.setMinimumPageSize(500, 550);
    		wizardDialog.open();
      构造函数WizardDialogAutoDAOLocation的第二个参数类型是org.eclipse.jface.wizard.IWizard
  4. 打开一个SWT Composit框,放置几个按钮 
    import org.eclipse.swt.SWT;
    import org.eclipse.swt.layout.RowLayout;
    import org.eclipse.swt.widgets.Button;
    import org.eclipse.swt.widgets.Display;
    import org.eclipse.swt.widgets.Shell;
    
    public class LayoutExample {
        public static void main(String[] args) {
            Display display = new Display();
            Shell shell = new Shell(display);
            // Create the layout.
            RowLayout layout = new RowLayout();
            // Optionally set layout fields.
            layout.wrap = true;
            // Set the layout into the composite.
            shell.setLayout(layout);
            // Create the children of the composite.
            new Button(shell, SWT.PUSH).setText("B1");
            new Button(shell, SWT.PUSH).setText("Wide Button 2");
            new Button(shell, SWT.PUSH).setText("Button 3");
            shell.pack();
            shell.open();
            
            while (!shell.isDisposed()) {
                if (!display.readAndDispatch()) display.sleep();
            }
        }
    }
     
  5. 代码里面是怎么实现F5的效果?
    当生成了代码,之后必须手动去目录结构上按一下F5才能将最新生成的代码显示出来。这个如何通过JDT的代码实现?
    		org.eclipse.core.resources.IResource resource = javaProject
    				.getProject().getFolder(srcFolder);
    
    		resource.refreshLocal(IResource.DEPTH_INFINITE,
    				new NullProgressMonitor());
     
  6. d

猜你喜欢

转载自mozhenghua.iteye.com/blog/1113025
今日推荐