MySQL Workbench
 sql >> Database >  >> Database Tools >> MySQL Workbench

Rimuovere o disabilitare il pulsante di chiusura X mostrato su un Editor RAP/RCPPart

puoi fare così (quello che ho scritto è più o meno lo stesso come:http://wiki.eclipse.org /RCP_Custom_Look_and_Feel ):Nella tua classe ApplicationWorkbenchWindowAdvisor, puoi registrare la tua PresentationFacory come:

  public void preWindowOpen() {    
    WorkbenchAdapterBuilder.registerAdapters();    
    IWorkbenchWindowConfigurer configurer = getWindowConfigurer();        
    configurer.setPresentationFactory(new UnCloseableEditorPresentationFactory());    
  } 

la classe UnCloseableEditorPresentationFactory estende WorkbenchPresentationFactory, puoi semplicemente sovrascrivere il metodo

public StackPresentation creatEditorPresentation(Composite parent,IStackPresentationSite site)

as followings :
  DefaultTabFolder folder = new UnCloseableEditorFolder(parent, 
       editorTabPosition | SWT.BORDER,    
       site.supportsState(IStackPresentationSite.STATE_MINIMIZED),          
       site.supportsState(IStackPresentationSite.STATE_MAXIMIZED));
 // other code int this method is the same as the parent class

 then is the class UnCloseableFolder

 import org.eclipse.swt.SWT;  
 import org.eclipse.swt.widgets.Composite;  
 import org.eclipse.ui.internal.presentations.defaultpresentation.DefaultTabFolder;    
 import org.eclipse.ui.internal.presentations.util.AbstractTabItem;  
 public class UnCloseableEditorFolder extends DefaultTabFolder {   
     public UnCloseableEditorFolder(Composite parent, int flags,     
         boolean allowMin, boolean allowMax) {     
         super(parent, flags, allowMin, allowMax);   
     }  

  @SuppressWarnings("restriction")   
  public AbstractTabItem add(int index, int flags)   {     
      return super.add(index, flags ^ SWT.CLOSE);   
  }
 } 

quindi puoi rimuovere il pulsante "X" nell'EditorPart. Funziona nella mia macchina~~