Program: 91417
Project: 91417
Buggy source:
@Override public void createPartControl(final Composite parent){
  GridLayoutFactory.fillDefaults().applyTo(parent);
  toolkit=new FormToolkit(parent.getDisplay());
  parent.addDisposeListener(new DisposeListener(){
    @Override public void widgetDisposed(    DisposeEvent e){
      if (commitMessageComponent.isAmending() || userEnteredCommitMessage())       saveCommitMessageComponentState();
 else       deleteCommitMessageComponentState();
      resources.dispose();
      toolkit.dispose();
    }
  }
);
  form=toolkit.createForm(parent);
  parent.addControlListener(new ControlListener(){
    private int[] defaultWeights={1,1};
    @Override public void controlResized(    ControlEvent e){
      org.eclipse.swt.graphics.Rectangle b=parent.getBounds();
      int oldOrientation=mainSashForm.getOrientation();
      if ((oldOrientation == SWT.HORIZONTAL) && (b.height > b.width)) {
        mainSashForm.setOrientation(SWT.VERTICAL);
        mainSashForm.setWeights(defaultWeights);
      }
 else       if ((oldOrientation == SWT.VERTICAL) && (b.height <= b.width)) {
        mainSashForm.setOrientation(SWT.HORIZONTAL);
        mainSashForm.setWeights(defaultWeights);
      }
    }
    @Override public void controlMoved(    ControlEvent e){
    }
  }
);
  form.setImage(getImage(UIIcons.REPOSITORY));
  form.setText(UIText.StagingView_NoSelectionTitle);
  GridDataFactory.fillDefaults().grab(true,true).applyTo(form);
  toolkit.decorateFormHeading(form);
  GridLayoutFactory.swtDefaults().applyTo(form.getBody());
  mainSashForm=new SashForm(form.getBody(),SWT.HORIZONTAL);
  saveSashFormWeightsOnDisposal(mainSashForm,HORIZONTAL_SASH_FORM_WEIGHT);
  toolkit.adapt(mainSashForm,true,true);
  GridDataFactory.fillDefaults().grab(true,true).applyTo(mainSashForm);
  stagingSashForm=new SashForm(mainSashForm,getStagingFormOrientation());
  saveSashFormWeightsOnDisposal(stagingSashForm,STAGING_SASH_FORM_WEIGHT);
  toolkit.adapt(stagingSashForm,true,true);
  GridDataFactory.fillDefaults().grab(true,true).applyTo(stagingSashForm);
  unstagedSection=toolkit.createSection(stagingSashForm,ExpandableComposite.TITLE_BAR);
  unstagedSection.setLayoutData(GridDataFactory.fillDefaults().grab(true,true).create());
  createUnstagedToolBarComposite();
  Composite unstagedComposite=toolkit.createComposite(unstagedSection);
  toolkit.paintBordersFor(unstagedComposite);
  unstagedSection.setClient(unstagedComposite);
  GridLayoutFactory.fillDefaults().extendedMargins(2,2,2,2).applyTo(unstagedComposite);
  unstagedViewer=createTree(unstagedComposite);
  GridDataFactory.fillDefaults().grab(true,true).applyTo(unstagedViewer.getControl());
  unstagedViewer.getTree().setData(FormToolkit.KEY_DRAW_BORDER,FormToolkit.TREE_BORDER);
  unstagedViewer.setLabelProvider(createLabelProvider(unstagedViewer));
  unstagedViewer.setContentProvider(createStagingContentProvider(true));
  unstagedViewer.addDragSupport(DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK,new Transfer[]{LocalSelectionTransfer.getTransfer(),FileTransfer.getInstance()},new StagingDragListener(unstagedViewer));
  unstagedViewer.addDropSupport(DND.DROP_MOVE,new Transfer[]{LocalSelectionTransfer.getTransfer()},new DropTargetAdapter(){
    @Override public void drop(    DropTargetEvent event){
      event.detail=DND.DROP_COPY;
      if (event.data instanceof IStructuredSelection) {
        final IStructuredSelection selection=(IStructuredSelection)event.data;
        unstage(selection);
      }
    }
    @Override public void dragOver(    DropTargetEvent event){
      event.detail=DND.DROP_MOVE;
    }
  }
);
  unstagedViewer.addOpenListener(new IOpenListener(){
    @Override public void open(    OpenEvent event){
      compareWith(event);
    }
  }
);
  unstagedViewer.setComparator(new StagingEntryComparator(getSortCheckState(),getPreferenceStore().getBoolean(UIPreferences.STAGING_VIEW_FILENAME_MODE)));
  enableAutoExpand(unstagedViewer);
  addListenerToDisableAutoExpandOnCollapse(unstagedViewer);
  Composite rebaseAndCommitComposite=toolkit.createComposite(mainSashForm);
  rebaseAndCommitComposite.setLayout(GridLayoutFactory.fillDefaults().create());
  rebaseSection=toolkit.createSection(rebaseAndCommitComposite,ExpandableComposite.TITLE_BAR);
  rebaseSection.setText(UIText.StagingView_RebaseLabel);
  Composite rebaseComposite=toolkit.createComposite(rebaseSection);
  toolkit.paintBordersFor(rebaseComposite);
  rebaseSection.setClient(rebaseComposite);
  rebaseSection.setLayoutData(GridDataFactory.fillDefaults().create());
  rebaseComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(3).equalWidth(true).create());
  GridDataFactory buttonGridData=GridDataFactory.fillDefaults().align(SWT.FILL,SWT.CENTER);
  this.rebaseAbortButton=toolkit.createButton(rebaseComposite,UIText.StagingView_RebaseAbort,SWT.PUSH);
  rebaseAbortButton.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      rebaseAbort();
    }
  }
);
  rebaseAbortButton.setImage(getImage(UIIcons.REBASE_ABORT));
  buttonGridData.applyTo(rebaseAbortButton);
  this.rebaseSkipButton=toolkit.createButton(rebaseComposite,UIText.StagingView_RebaseSkip,SWT.PUSH);
  rebaseSkipButton.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      rebaseSkip();
    }
  }
);
  rebaseSkipButton.setImage(getImage(UIIcons.REBASE_SKIP));
  buttonGridData.applyTo(rebaseSkipButton);
  this.rebaseContinueButton=toolkit.createButton(rebaseComposite,UIText.StagingView_RebaseContinue,SWT.PUSH);
  rebaseContinueButton.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      rebaseContinue();
    }
  }
);
  rebaseContinueButton.setImage(getImage(UIIcons.REBASE_CONTINUE));
  buttonGridData.applyTo(rebaseContinueButton);
  showControl(rebaseSection,false);
  commitMessageSection=toolkit.createSection(rebaseAndCommitComposite,ExpandableComposite.TITLE_BAR);
  commitMessageSection.setText(UIText.StagingView_CommitMessage);
  commitMessageSection.setLayoutData(GridDataFactory.fillDefaults().grab(true,true).create());
  Composite commitMessageToolbarComposite=toolkit.createComposite(commitMessageSection);
  commitMessageToolbarComposite.setBackground(null);
  commitMessageToolbarComposite.setLayout(createRowLayoutWithoutMargin());
  commitMessageSection.setTextClient(commitMessageToolbarComposite);
  ToolBarManager commitMessageToolBarManager=new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL);
  amendPreviousCommitAction=new Action(UIText.StagingView_Ammend_Previous_Commit,IAction.AS_CHECK_BOX){
    @Override public void run(){
      commitMessageComponent.setAmendingButtonSelection(isChecked());
      updateMessage();
    }
  }
;
  amendPreviousCommitAction.setImageDescriptor(UIIcons.AMEND_COMMIT);
  commitMessageToolBarManager.add(amendPreviousCommitAction);
  signedOffByAction=new Action(UIText.StagingView_Add_Signed_Off_By,IAction.AS_CHECK_BOX){
    @Override public void run(){
      commitMessageComponent.setSignedOffButtonSelection(isChecked());
    }
  }
;
  signedOffByAction.setImageDescriptor(UIIcons.SIGNED_OFF);
  commitMessageToolBarManager.add(signedOffByAction);
  addChangeIdAction=new Action(UIText.StagingView_Add_Change_ID,IAction.AS_CHECK_BOX){
    @Override public void run(){
      commitMessageComponent.setChangeIdButtonSelection(isChecked());
    }
  }
;
  addChangeIdAction.setImageDescriptor(UIIcons.GERRIT);
  commitMessageToolBarManager.add(addChangeIdAction);
  commitMessageToolBarManager.createControl(commitMessageToolbarComposite);
  Composite commitMessageComposite=toolkit.createComposite(commitMessageSection);
  commitMessageSection.setClient(commitMessageComposite);
  GridLayoutFactory.fillDefaults().numColumns(1).applyTo(commitMessageComposite);
  warningLabel=new ToggleableWarningLabel(commitMessageComposite,SWT.NONE);
  GridDataFactory.fillDefaults().grab(true,false).exclude(true).applyTo(warningLabel);
  Composite commitMessageTextComposite=toolkit.createComposite(commitMessageComposite);
  toolkit.paintBordersFor(commitMessageTextComposite);
  GridDataFactory.fillDefaults().grab(true,true).applyTo(commitMessageTextComposite);
  GridLayoutFactory.fillDefaults().numColumns(1).extendedMargins(2,2,2,2).applyTo(commitMessageTextComposite);
  final CommitProposalProcessor commitProposalProcessor=new CommitProposalProcessor(){
    @Override protected Collection<String> computeFileNameProposals(){
      return getStagedFileNames();
    }
    @Override protected Collection<String> computeMessageProposals(){
      return CommitMessageHistory.getCommitHistory();
    }
  }
;
  commitMessageText=new CommitMessageArea(commitMessageTextComposite,EMPTY_STRING,toolkit.getBorderStyle()){
    @Override protected CommitProposalProcessor getCommitProposalProcessor(){
      return commitProposalProcessor;
    }
    @Override protected IHandlerService getHandlerService(){
      return CommonUtils.getService(getSite(),IHandlerService.class);
    }
  }
;
  commitMessageText.setData(FormToolkit.KEY_DRAW_BORDER,FormToolkit.TEXT_BORDER);
  GridDataFactory.fillDefaults().grab(true,true).applyTo(commitMessageText);
  UIUtils.addBulbDecorator(commitMessageText.getTextWidget(),UIText.CommitDialog_ContentAssist);
  Composite composite=toolkit.createComposite(commitMessageComposite);
  toolkit.paintBordersFor(composite);
  GridDataFactory.fillDefaults().grab(true,false).applyTo(composite);
  GridLayoutFactory.swtDefaults().numColumns(2).applyTo(composite);
  toolkit.createLabel(composite,UIText.StagingView_Author).setForeground(toolkit.getColors().getColor(IFormColors.TB_TOGGLE));
  authorText=toolkit.createText(composite,null);
  authorText.setData(FormToolkit.KEY_DRAW_BORDER,FormToolkit.TEXT_BORDER);
  authorText.setLayoutData(GridDataFactory.fillDefaults().grab(true,false).create());
  toolkit.createLabel(composite,UIText.StagingView_Committer).setForeground(toolkit.getColors().getColor(IFormColors.TB_TOGGLE));
  committerText=toolkit.createText(composite,null);
  committerText.setData(FormToolkit.KEY_DRAW_BORDER,FormToolkit.TEXT_BORDER);
  committerText.setLayoutData(GridDataFactory.fillDefaults().grab(true,false).create());
  Composite buttonsContainer=toolkit.createComposite(composite);
  GridDataFactory.fillDefaults().grab(true,false).span(2,1).indent(0,8).applyTo(buttonsContainer);
  GridLayoutFactory.fillDefaults().numColumns(2).applyTo(buttonsContainer);
  ignoreErrors=toolkit.createButton(buttonsContainer,UIText.StagingView_IgnoreErrors,SWT.CHECK);
  ignoreErrors.setSelection(false);
  ignoreErrors.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      updateMessage();
      updateCommitButtons();
    }
  }
);
  getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener(){
    @Override public void propertyChange(    PropertyChangeEvent event){
      if (isDisposed()) {
        getPreferenceStore().removePropertyChangeListener(this);
        return;
      }
      asyncExec(new Runnable(){
        @Override public void run(){
          updateIgnoreErrorsButtonVisibility();
          updateMessage();
          updateCommitButtons();
        }
      }
);
    }
  }
);
  GridDataFactory.fillDefaults().align(SWT.BEGINNING,SWT.BEGINNING).grab(true,true).applyTo(ignoreErrors);
  updateIgnoreErrorsButtonVisibility();
  Label filler=toolkit.createLabel(buttonsContainer,"String_Node_Str");
  GridDataFactory.fillDefaults().align(SWT.FILL,SWT.FILL).grab(true,true).applyTo(filler);
  Composite commitButtonsContainer=toolkit.createComposite(buttonsContainer);
  GridDataFactory.fillDefaults().align(SWT.FILL,SWT.CENTER).applyTo(commitButtonsContainer);
  GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(true).applyTo(commitButtonsContainer);
  this.commitAndPushButton=toolkit.createButton(commitButtonsContainer,UIText.StagingView_CommitAndPush,SWT.PUSH);
  commitAndPushButton.setImage(getImage(UIIcons.PUSH));
  commitAndPushButton.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      commit(true);
    }
  }
);
  GridDataFactory.fillDefaults().align(SWT.FILL,SWT.CENTER).applyTo(commitAndPushButton);
  this.commitButton=toolkit.createButton(commitButtonsContainer,UIText.StagingView_Commit,SWT.PUSH);
  commitButton.setImage(getImage(UIIcons.COMMIT));
  commitButton.setText(UIText.StagingView_Commit);
  commitButton.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      commit(false);
    }
  }
);
  GridDataFactory.fillDefaults().align(SWT.FILL,SWT.CENTER).applyTo(commitButton);
  stagedSection=toolkit.createSection(stagingSashForm,ExpandableComposite.TITLE_BAR);
  createStagedToolBarComposite();
  Composite stagedComposite=toolkit.createComposite(stagedSection);
  toolkit.paintBordersFor(stagedComposite);
  stagedSection.setClient(stagedComposite);
  GridLayoutFactory.fillDefaults().extendedMargins(2,2,2,2).applyTo(stagedComposite);
  stagedViewer=createTree(stagedComposite);
  GridDataFactory.fillDefaults().grab(true,true).applyTo(stagedViewer.getControl());
  stagedViewer.getTree().setData(FormToolkit.KEY_DRAW_BORDER,FormToolkit.TREE_BORDER);
  stagedViewer.setLabelProvider(createLabelProvider(stagedViewer));
  stagedViewer.setContentProvider(createStagingContentProvider(false));
  stagedViewer.addDragSupport(DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK,new Transfer[]{LocalSelectionTransfer.getTransfer(),FileTransfer.getInstance()},new StagingDragListener(stagedViewer));
  stagedViewer.addDropSupport(DND.DROP_MOVE,new Transfer[]{LocalSelectionTransfer.getTransfer()},new DropTargetAdapter(){
    @Override public void drop(    DropTargetEvent event){
      event.detail=DND.DROP_COPY;
      if (event.data instanceof IStructuredSelection) {
        final IStructuredSelection selection=(IStructuredSelection)event.data;
        stage(selection);
      }
    }
    @Override public void dragOver(    DropTargetEvent event){
      event.detail=DND.DROP_MOVE;
    }
  }
);
  stagedViewer.addOpenListener(new IOpenListener(){
    @Override public void open(    OpenEvent event){
      compareWith(event);
    }
  }
);
  stagedViewer.setComparator(new StagingEntryComparator(getSortCheckState(),getPreferenceStore().getBoolean(UIPreferences.STAGING_VIEW_FILENAME_MODE)));
  enableAutoExpand(stagedViewer);
  addListenerToDisableAutoExpandOnCollapse(stagedViewer);
  selectionChangedListener=new ISelectionListener(){
    @Override public void selectionChanged(    IWorkbenchPart part,    ISelection selection){
      if (part == getSite().getPart()) {
        return;
      }
      if (selection instanceof StructuredSelection) {
        reactOnSelection((StructuredSelection)selection);
      }
    }
  }
;
  partListener=new PartListener();
  IPreferenceStore preferenceStore=getPreferenceStore();
  if (preferenceStore.contains(UIPreferences.STAGING_VIEW_SYNC_SELECTION))   reactOnSelection=preferenceStore.getBoolean(UIPreferences.STAGING_VIEW_SYNC_SELECTION);
 else   preferenceStore.setDefault(UIPreferences.STAGING_VIEW_SYNC_SELECTION,true);
  preferenceStore.addPropertyChangeListener(uiPrefsListener);
  InstanceScope.INSTANCE.getNode(org.eclipse.egit.core.Activator.getPluginId()).addPreferenceChangeListener(prefListener);
  updateSectionText();
  updateToolbar();
  enableCommitWidgets(false);
  refreshAction.setEnabled(false);
  createPopupMenu(unstagedViewer);
  createPopupMenu(stagedViewer);
  final ICommitMessageComponentNotifications listener=new ICommitMessageComponentNotifications(){
    @Override public void updateSignedOffToggleSelection(    boolean selection){
      signedOffByAction.setChecked(selection);
    }
    @Override public void updateChangeIdToggleSelection(    boolean selection){
      addChangeIdAction.setChecked(selection);
      commitAndPushButton.setImage(getImage(selection ? UIIcons.GERRIT : UIIcons.PUSH));
    }
    @Override public void statusUpdated(){
      updateMessage();
    }
  }
;
  commitMessageComponent=new CommitMessageComponent(listener);
  commitMessageComponent.attachControls(commitMessageText,authorText,committerText);
  commitMessageText.getTextWidget().addVerifyKeyListener(new VerifyKeyListener(){
    @Override public void verifyKey(    VerifyEvent event){
      if (UIUtils.isSubmitKeyEvent(event)) {
        event.doit=false;
        commit(false);
      }
    }
  }
);
  commitMessageText.getTextWidget().addFocusListener(new FocusListener(){
    @Override public void focusGained(    FocusEvent e){
      String commitButtonTooltip=MessageFormat.format(UIText.StagingView_CommitToolTip,UIUtils.SUBMIT_KEY_STROKE.format());
      commitButton.setToolTipText(commitButtonTooltip);
    }
    @Override public void focusLost(    FocusEvent e){
      commitButton.setToolTipText(null);
    }
  }
);
  IWorkbenchPartSite site=getSite();
  ISelectionService srv=CommonUtils.getService(site,ISelectionService.class);
  srv.addPostSelectionListener(selectionChangedListener);
  CommonUtils.getService(site,IPartService.class).addPartListener(partListener);
  UIUtils.notifySelectionChangedWithCurrentSelection(selectionChangedListener,site);
  site.setSelectionProvider(unstagedViewer);
  ViewerFilter filter=new ViewerFilter(){
    @Override public boolean select(    Viewer viewer,    Object parentElement,    Object element){
      StagingViewContentProvider contentProvider=getContentProvider((TreeViewer)viewer);
      if (element instanceof StagingEntry)       return contentProvider.isInFilter((StagingEntry)element);
 else       if (element instanceof StagingFolderEntry)       return contentProvider.hasVisibleChildren((StagingFolderEntry)element);
      return true;
    }
  }
;
  unstagedViewer.addFilter(filter);
  stagedViewer.addFilter(filter);
  restoreSashFormWeights();
  reactOnInitialSelection();
  IWorkbenchSiteProgressService service=CommonUtils.getService(getSite(),IWorkbenchSiteProgressService.class);
  if (service != null && reactOnSelection)   service.showBusyForFamily(org.eclipse.egit.core.JobFamilies.INDEX_DIFF_CACHE_UPDATE);
}

Fixed version (ground truth):
@Override public void createPartControl(final Composite parent){
  GridLayoutFactory.fillDefaults().applyTo(parent);
  toolkit=new FormToolkit(parent.getDisplay());
  parent.addDisposeListener(new DisposeListener(){
    @Override public void widgetDisposed(    DisposeEvent e){
      if (commitMessageComponent.isAmending() || userEnteredCommitMessage())       saveCommitMessageComponentState();
 else       deleteCommitMessageComponentState();
      resources.dispose();
      toolkit.dispose();
    }
  }
);
  form=toolkit.createForm(parent);
  parent.addControlListener(new ControlListener(){
    private int[] defaultWeights={1,1};
    @Override public void controlResized(    ControlEvent e){
      org.eclipse.swt.graphics.Rectangle b=parent.getBounds();
      int oldOrientation=mainSashForm.getOrientation();
      if ((oldOrientation == SWT.HORIZONTAL) && (b.height > b.width)) {
        mainSashForm.setOrientation(SWT.VERTICAL);
        mainSashForm.setWeights(defaultWeights);
      }
 else       if ((oldOrientation == SWT.VERTICAL) && (b.height <= b.width)) {
        mainSashForm.setOrientation(SWT.HORIZONTAL);
        mainSashForm.setWeights(defaultWeights);
      }
    }
    @Override public void controlMoved(    ControlEvent e){
    }
  }
);
  form.setImage(getImage(UIIcons.REPOSITORY));
  form.setText(UIText.StagingView_NoSelectionTitle);
  GridDataFactory.fillDefaults().grab(true,true).applyTo(form);
  toolkit.decorateFormHeading(form);
  GridLayoutFactory.swtDefaults().applyTo(form.getBody());
  mainSashForm=new SashForm(form.getBody(),SWT.HORIZONTAL);
  saveSashFormWeightsOnDisposal(mainSashForm,HORIZONTAL_SASH_FORM_WEIGHT);
  toolkit.adapt(mainSashForm,true,true);
  GridDataFactory.fillDefaults().grab(true,true).applyTo(mainSashForm);
  stagingSashForm=new SashForm(mainSashForm,getStagingFormOrientation());
  saveSashFormWeightsOnDisposal(stagingSashForm,STAGING_SASH_FORM_WEIGHT);
  toolkit.adapt(stagingSashForm,true,true);
  GridDataFactory.fillDefaults().grab(true,true).applyTo(stagingSashForm);
  unstagedSection=toolkit.createSection(stagingSashForm,ExpandableComposite.TITLE_BAR);
  unstagedSection.setLayoutData(GridDataFactory.fillDefaults().grab(true,true).create());
  createUnstagedToolBarComposite();
  Composite unstagedComposite=toolkit.createComposite(unstagedSection);
  toolkit.paintBordersFor(unstagedComposite);
  unstagedSection.setClient(unstagedComposite);
  GridLayoutFactory.fillDefaults().extendedMargins(2,2,2,2).applyTo(unstagedComposite);
  unstagedViewer=createTree(unstagedComposite);
  GridDataFactory.fillDefaults().grab(true,true).applyTo(unstagedViewer.getControl());
  unstagedViewer.getTree().setData(FormToolkit.KEY_DRAW_BORDER,FormToolkit.TREE_BORDER);
  unstagedViewer.setLabelProvider(createLabelProvider(unstagedViewer));
  unstagedViewer.setContentProvider(createStagingContentProvider(true));
  unstagedViewer.addDragSupport(DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK,new Transfer[]{LocalSelectionTransfer.getTransfer(),FileTransfer.getInstance()},new StagingDragListener(unstagedViewer));
  unstagedViewer.addDropSupport(DND.DROP_MOVE,new Transfer[]{LocalSelectionTransfer.getTransfer()},new DropTargetAdapter(){
    @Override public void drop(    DropTargetEvent event){
      event.detail=DND.DROP_COPY;
      if (event.data instanceof IStructuredSelection) {
        final IStructuredSelection selection=(IStructuredSelection)event.data;
        unstage(selection);
      }
    }
    @Override public void dragOver(    DropTargetEvent event){
      event.detail=DND.DROP_MOVE;
    }
  }
);
  unstagedViewer.addOpenListener(new IOpenListener(){
    @Override public void open(    OpenEvent event){
      compareWith(event);
    }
  }
);
  unstagedViewer.setComparator(new StagingEntryComparator(getSortCheckState(),getPreferenceStore().getBoolean(UIPreferences.STAGING_VIEW_FILENAME_MODE)));
  enableAutoExpand(unstagedViewer);
  addListenerToDisableAutoExpandOnCollapse(unstagedViewer);
  Composite rebaseAndCommitComposite=toolkit.createComposite(mainSashForm);
  rebaseAndCommitComposite.setLayout(GridLayoutFactory.fillDefaults().create());
  rebaseSection=toolkit.createSection(rebaseAndCommitComposite,ExpandableComposite.TITLE_BAR);
  rebaseSection.setText(UIText.StagingView_RebaseLabel);
  Composite rebaseComposite=toolkit.createComposite(rebaseSection);
  toolkit.paintBordersFor(rebaseComposite);
  rebaseSection.setClient(rebaseComposite);
  rebaseSection.setLayoutData(GridDataFactory.fillDefaults().create());
  rebaseComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(3).equalWidth(true).create());
  GridDataFactory buttonGridData=GridDataFactory.fillDefaults().align(SWT.FILL,SWT.CENTER);
  this.rebaseAbortButton=toolkit.createButton(rebaseComposite,UIText.StagingView_RebaseAbort,SWT.PUSH);
  rebaseAbortButton.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      rebaseAbort();
    }
  }
);
  rebaseAbortButton.setImage(getImage(UIIcons.REBASE_ABORT));
  buttonGridData.applyTo(rebaseAbortButton);
  this.rebaseSkipButton=toolkit.createButton(rebaseComposite,UIText.StagingView_RebaseSkip,SWT.PUSH);
  rebaseSkipButton.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      rebaseSkip();
    }
  }
);
  rebaseSkipButton.setImage(getImage(UIIcons.REBASE_SKIP));
  buttonGridData.applyTo(rebaseSkipButton);
  this.rebaseContinueButton=toolkit.createButton(rebaseComposite,UIText.StagingView_RebaseContinue,SWT.PUSH);
  rebaseContinueButton.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      rebaseContinue();
    }
  }
);
  rebaseContinueButton.setImage(getImage(UIIcons.REBASE_CONTINUE));
  buttonGridData.applyTo(rebaseContinueButton);
  showControl(rebaseSection,false);
  commitMessageSection=toolkit.createSection(rebaseAndCommitComposite,ExpandableComposite.TITLE_BAR);
  commitMessageSection.setText(UIText.StagingView_CommitMessage);
  commitMessageSection.setLayoutData(GridDataFactory.fillDefaults().grab(true,true).create());
  Composite commitMessageToolbarComposite=toolkit.createComposite(commitMessageSection);
  commitMessageToolbarComposite.setBackground(null);
  commitMessageToolbarComposite.setLayout(createRowLayoutWithoutMargin());
  commitMessageSection.setTextClient(commitMessageToolbarComposite);
  ToolBarManager commitMessageToolBarManager=new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL);
  amendPreviousCommitAction=new Action(UIText.StagingView_Ammend_Previous_Commit,IAction.AS_CHECK_BOX){
    @Override public void run(){
      commitMessageComponent.setAmendingButtonSelection(isChecked());
      updateMessage();
    }
  }
;
  amendPreviousCommitAction.setImageDescriptor(UIIcons.AMEND_COMMIT);
  commitMessageToolBarManager.add(amendPreviousCommitAction);
  signedOffByAction=new Action(UIText.StagingView_Add_Signed_Off_By,IAction.AS_CHECK_BOX){
    @Override public void run(){
      commitMessageComponent.setSignedOffButtonSelection(isChecked());
    }
  }
;
  signedOffByAction.setImageDescriptor(UIIcons.SIGNED_OFF);
  commitMessageToolBarManager.add(signedOffByAction);
  addChangeIdAction=new Action(UIText.StagingView_Add_Change_ID,IAction.AS_CHECK_BOX){
    @Override public void run(){
      commitMessageComponent.setChangeIdButtonSelection(isChecked());
    }
  }
;
  addChangeIdAction.setImageDescriptor(UIIcons.GERRIT);
  commitMessageToolBarManager.add(addChangeIdAction);
  commitMessageToolBarManager.createControl(commitMessageToolbarComposite);
  Composite commitMessageComposite=toolkit.createComposite(commitMessageSection);
  commitMessageSection.setClient(commitMessageComposite);
  GridLayoutFactory.fillDefaults().numColumns(1).applyTo(commitMessageComposite);
  warningLabel=new ToggleableWarningLabel(commitMessageComposite,SWT.NONE);
  GridDataFactory.fillDefaults().grab(true,false).exclude(true).applyTo(warningLabel);
  Composite commitMessageTextComposite=toolkit.createComposite(commitMessageComposite);
  toolkit.paintBordersFor(commitMessageTextComposite);
  GridDataFactory.fillDefaults().grab(true,true).applyTo(commitMessageTextComposite);
  GridLayoutFactory.fillDefaults().numColumns(1).extendedMargins(2,2,2,2).applyTo(commitMessageTextComposite);
  final CommitProposalProcessor commitProposalProcessor=new CommitProposalProcessor(){
    @Override protected Collection<String> computeFileNameProposals(){
      return getStagedFileNames();
    }
    @Override protected Collection<String> computeMessageProposals(){
      return CommitMessageHistory.getCommitHistory();
    }
  }
;
  commitMessageText=new CommitMessageArea(commitMessageTextComposite,EMPTY_STRING,toolkit.getBorderStyle()){
    @Override protected CommitProposalProcessor getCommitProposalProcessor(){
      return commitProposalProcessor;
    }
    @Override protected IHandlerService getHandlerService(){
      return CommonUtils.getService(getSite(),IHandlerService.class);
    }
  }
;
  commitMessageText.setData(FormToolkit.KEY_DRAW_BORDER,FormToolkit.TEXT_BORDER);
  GridDataFactory.fillDefaults().grab(true,true).applyTo(commitMessageText);
  UIUtils.addBulbDecorator(commitMessageText.getTextWidget(),UIText.CommitDialog_ContentAssist);
  Composite composite=toolkit.createComposite(commitMessageComposite);
  toolkit.paintBordersFor(composite);
  GridDataFactory.fillDefaults().grab(true,false).applyTo(composite);
  GridLayoutFactory.swtDefaults().numColumns(2).applyTo(composite);
  toolkit.createLabel(composite,UIText.StagingView_Author).setForeground(toolkit.getColors().getColor(IFormColors.TB_TOGGLE));
  authorText=toolkit.createText(composite,null);
  authorText.setData(FormToolkit.KEY_DRAW_BORDER,FormToolkit.TEXT_BORDER);
  authorText.setLayoutData(GridDataFactory.fillDefaults().grab(true,false).create());
  toolkit.createLabel(composite,UIText.StagingView_Committer).setForeground(toolkit.getColors().getColor(IFormColors.TB_TOGGLE));
  committerText=toolkit.createText(composite,null);
  committerText.setData(FormToolkit.KEY_DRAW_BORDER,FormToolkit.TEXT_BORDER);
  committerText.setLayoutData(GridDataFactory.fillDefaults().grab(true,false).create());
  Composite buttonsContainer=toolkit.createComposite(composite);
  GridDataFactory.fillDefaults().grab(true,false).span(2,1).indent(0,8).applyTo(buttonsContainer);
  GridLayoutFactory.fillDefaults().numColumns(2).applyTo(buttonsContainer);
  ignoreErrors=toolkit.createButton(buttonsContainer,UIText.StagingView_IgnoreErrors,SWT.CHECK);
  ignoreErrors.setSelection(false);
  ignoreErrors.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      updateMessage();
      updateCommitButtons();
    }
  }
);
  getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener(){
    @Override public void propertyChange(    PropertyChangeEvent event){
      if (isDisposed()) {
        getPreferenceStore().removePropertyChangeListener(this);
        return;
      }
      asyncExec(new Runnable(){
        @Override public void run(){
          updateIgnoreErrorsButtonVisibility();
          updateMessage();
          updateCommitButtons();
        }
      }
);
    }
  }
);
  GridDataFactory.fillDefaults().align(SWT.BEGINNING,SWT.BEGINNING).grab(true,true).applyTo(ignoreErrors);
  updateIgnoreErrorsButtonVisibility();
  Label filler=toolkit.createLabel(buttonsContainer,"String_Node_Str");
  GridDataFactory.fillDefaults().align(SWT.FILL,SWT.FILL).grab(true,true).applyTo(filler);
  Composite commitButtonsContainer=toolkit.createComposite(buttonsContainer);
  GridDataFactory.fillDefaults().align(SWT.FILL,SWT.CENTER).applyTo(commitButtonsContainer);
  GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(true).applyTo(commitButtonsContainer);
  this.commitAndPushButton=toolkit.createButton(commitButtonsContainer,UIText.StagingView_CommitAndPush,SWT.PUSH);
  commitAndPushButton.setImage(getImage(UIIcons.PUSH));
  commitAndPushButton.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      commit(true);
    }
  }
);
  GridDataFactory.fillDefaults().align(SWT.FILL,SWT.CENTER).applyTo(commitAndPushButton);
  this.commitButton=toolkit.createButton(commitButtonsContainer,UIText.StagingView_Commit,SWT.PUSH);
  commitButton.setImage(getImage(UIIcons.COMMIT));
  commitButton.setText(UIText.StagingView_Commit);
  commitButton.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      commit(false);
    }
  }
);
  GridDataFactory.fillDefaults().align(SWT.FILL,SWT.CENTER).applyTo(commitButton);
  stagedSection=toolkit.createSection(stagingSashForm,ExpandableComposite.TITLE_BAR);
  createStagedToolBarComposite();
  Composite stagedComposite=toolkit.createComposite(stagedSection);
  toolkit.paintBordersFor(stagedComposite);
  stagedSection.setClient(stagedComposite);
  GridLayoutFactory.fillDefaults().extendedMargins(2,2,2,2).applyTo(stagedComposite);
  stagedViewer=createTree(stagedComposite);
  GridDataFactory.fillDefaults().grab(true,true).applyTo(stagedViewer.getControl());
  stagedViewer.getTree().setData(FormToolkit.KEY_DRAW_BORDER,FormToolkit.TREE_BORDER);
  IBaseLabelProvider labelProvider=createLabelProvider(stagedViewer);
  labelProvider.addListener(new ILabelProviderListener(){
    @Override public void labelProviderChanged(    LabelProviderChangedEvent event){
      updateCommitButtons();
    }
  }
);
  stagedViewer.setLabelProvider(labelProvider);
  stagedViewer.setContentProvider(createStagingContentProvider(false));
  stagedViewer.addDragSupport(DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK,new Transfer[]{LocalSelectionTransfer.getTransfer(),FileTransfer.getInstance()},new StagingDragListener(stagedViewer));
  stagedViewer.addDropSupport(DND.DROP_MOVE,new Transfer[]{LocalSelectionTransfer.getTransfer()},new DropTargetAdapter(){
    @Override public void drop(    DropTargetEvent event){
      event.detail=DND.DROP_COPY;
      if (event.data instanceof IStructuredSelection) {
        final IStructuredSelection selection=(IStructuredSelection)event.data;
        stage(selection);
      }
    }
    @Override public void dragOver(    DropTargetEvent event){
      event.detail=DND.DROP_MOVE;
    }
  }
);
  stagedViewer.addOpenListener(new IOpenListener(){
    @Override public void open(    OpenEvent event){
      compareWith(event);
    }
  }
);
  stagedViewer.setComparator(new StagingEntryComparator(getSortCheckState(),getPreferenceStore().getBoolean(UIPreferences.STAGING_VIEW_FILENAME_MODE)));
  enableAutoExpand(stagedViewer);
  addListenerToDisableAutoExpandOnCollapse(stagedViewer);
  selectionChangedListener=new ISelectionListener(){
    @Override public void selectionChanged(    IWorkbenchPart part,    ISelection selection){
      if (part == getSite().getPart()) {
        return;
      }
      if (selection instanceof StructuredSelection) {
        reactOnSelection((StructuredSelection)selection);
      }
    }
  }
;
  partListener=new PartListener();
  IPreferenceStore preferenceStore=getPreferenceStore();
  if (preferenceStore.contains(UIPreferences.STAGING_VIEW_SYNC_SELECTION))   reactOnSelection=preferenceStore.getBoolean(UIPreferences.STAGING_VIEW_SYNC_SELECTION);
 else   preferenceStore.setDefault(UIPreferences.STAGING_VIEW_SYNC_SELECTION,true);
  preferenceStore.addPropertyChangeListener(uiPrefsListener);
  InstanceScope.INSTANCE.getNode(org.eclipse.egit.core.Activator.getPluginId()).addPreferenceChangeListener(prefListener);
  updateSectionText();
  updateToolbar();
  enableCommitWidgets(false);
  refreshAction.setEnabled(false);
  createPopupMenu(unstagedViewer);
  createPopupMenu(stagedViewer);
  final ICommitMessageComponentNotifications listener=new ICommitMessageComponentNotifications(){
    @Override public void updateSignedOffToggleSelection(    boolean selection){
      signedOffByAction.setChecked(selection);
    }
    @Override public void updateChangeIdToggleSelection(    boolean selection){
      addChangeIdAction.setChecked(selection);
      commitAndPushButton.setImage(getImage(selection ? UIIcons.GERRIT : UIIcons.PUSH));
    }
    @Override public void statusUpdated(){
      updateMessage();
    }
  }
;
  commitMessageComponent=new CommitMessageComponent(listener);
  commitMessageComponent.attachControls(commitMessageText,authorText,committerText);
  commitMessageText.getTextWidget().addVerifyKeyListener(new VerifyKeyListener(){
    @Override public void verifyKey(    VerifyEvent event){
      if (UIUtils.isSubmitKeyEvent(event)) {
        event.doit=false;
        commit(false);
      }
    }
  }
);
  commitMessageText.getTextWidget().addFocusListener(new FocusListener(){
    @Override public void focusGained(    FocusEvent e){
      String commitButtonTooltip=MessageFormat.format(UIText.StagingView_CommitToolTip,UIUtils.SUBMIT_KEY_STROKE.format());
      commitButton.setToolTipText(commitButtonTooltip);
    }
    @Override public void focusLost(    FocusEvent e){
      commitButton.setToolTipText(null);
    }
  }
);
  IWorkbenchPartSite site=getSite();
  ISelectionService srv=CommonUtils.getService(site,ISelectionService.class);
  srv.addPostSelectionListener(selectionChangedListener);
  CommonUtils.getService(site,IPartService.class).addPartListener(partListener);
  UIUtils.notifySelectionChangedWithCurrentSelection(selectionChangedListener,site);
  site.setSelectionProvider(unstagedViewer);
  ViewerFilter filter=new ViewerFilter(){
    @Override public boolean select(    Viewer viewer,    Object parentElement,    Object element){
      StagingViewContentProvider contentProvider=getContentProvider((TreeViewer)viewer);
      if (element instanceof StagingEntry)       return contentProvider.isInFilter((StagingEntry)element);
 else       if (element instanceof StagingFolderEntry)       return contentProvider.hasVisibleChildren((StagingFolderEntry)element);
      return true;
    }
  }
;
  unstagedViewer.addFilter(filter);
  stagedViewer.addFilter(filter);
  restoreSashFormWeights();
  reactOnInitialSelection();
  IWorkbenchSiteProgressService service=CommonUtils.getService(getSite(),IWorkbenchSiteProgressService.class);
  if (service != null && reactOnSelection)   service.showBusyForFamily(org.eclipse.egit.core.JobFamilies.INDEX_DIFF_CACHE_UPDATE);
}