public void dragOver(DropTargetEvent event) {
event.detail = DND.DROP_MOVE;
}
});
unstagedViewer.addOpenListener(new IOpenListener() {
public void open(OpenEvent event) {
compareWith(event);
}
});
enableAutoExpand(unstagedViewer);
addListenerToDisableAutoExpandOnCollapse(unstagedViewer);
Composite rebaseAndCommitComposite = toolkit.createComposite(horizontalSashForm);
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) {
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) {
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) {
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);
Label filler = toolkit.createLabel(buttonsContainer, ""); //$NON-NLS-1$
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.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() {
public void drop(DropTargetEvent event) {
// Bug 411466: It is very important that detail is set
// to DND.DROP_COPY. If it was left as DND.DROP_MOVE and
// the drag comes from the Navigator view, the code in
// NavigatorDragAdapter would delete the resources.
event.detail = DND.DROP_COPY;
if (event.data instanceof IStructuredSelection) {
final IStructuredSelection selection = (IStructuredSelection) event.data;
stage(selection);
}
}
public void dragOver(DropTargetEvent event) {
event.detail = DND.DROP_MOVE;
}
});
stagedViewer.addOpenListener(new IOpenListener() {
public void open(OpenEvent event) {
compareWith(event);
}
});
enableAutoExpand(stagedViewer);