use of org.eclipse.egit.core.internal.rebase.RebaseInteractivePlan.ElementAction in project egit by eclipse.
the class RebaseInteractiveStepActionToolBarProvider method mapActionItemsToSelection.
void mapActionItemsToSelection(ISelection selection) {
setMoveItemsEnabled(false);
if (selection == null || selection.isEmpty()) {
if (theToolbar.isEnabled())
theToolbar.setEnabled(false);
unselectAllActionItemsExecpt(null);
return;
}
if (selection instanceof IStructuredSelection) {
IStructuredSelection structured = (IStructuredSelection) selection;
Object obj = structured.getFirstElement();
if (!(obj instanceof PlanElement))
return;
PlanElement firstSelectedEntry = (PlanElement) obj;
PlanElement lastSelectedEntry = firstSelectedEntry;
ElementAction type = firstSelectedEntry.getPlanElementAction();
boolean singleTypeSelected = true;
if (!theToolbar.isEnabled() && !view.getCurrentPlan().hasRebaseBeenStartedYet())
theToolbar.setEnabled(true);
if (structured.size() > 1) {
// multi selection
for (Object selectedObj : structured.toList()) {
if (!(selectedObj instanceof PlanElement))
continue;
PlanElement entry = (PlanElement) selectedObj;
lastSelectedEntry = entry;
if (type != entry.getPlanElementAction()) {
singleTypeSelected = false;
}
}
}
if (singleTypeSelected)
unselectAllActionItemsExecpt(type);
else
unselectAllActionItemsExecpt(null);
enableMoveButtons(firstSelectedEntry, lastSelectedEntry);
}
}
use of org.eclipse.egit.core.internal.rebase.RebaseInteractivePlan.ElementAction in project egit by eclipse.
the class RebaseInteractiveView method createColumns.
private void createColumns(TreeColumnLayout layout) {
String[] headings = { UIText.RebaseInteractiveView_HeadingStatus, UIText.RebaseInteractiveView_HeadingStep, UIText.RebaseInteractiveView_HeadingAction, UIText.RebaseInteractiveView_HeadingCommitId, UIText.RebaseInteractiveView_HeadingMessage, UIText.RebaseInteractiveView_HeadingAuthor, UIText.RebaseInteractiveView_HeadingAuthorDate, UIText.RebaseInteractiveView_HeadingCommitter, UIText.RebaseInteractiveView_HeadingCommitDate };
ColumnViewerToolTipSupport.enableFor(planTreeViewer, ToolTip.NO_RECREATE);
TreeViewerColumn infoColumn = createColumn(headings[0]);
layout.setColumnData(infoColumn.getColumn(), new ColumnPixelData(70));
infoColumn.setLabelProvider(new HighlightingColumnLabelProvider() {
@Override
public Image getImage(Object element) {
ElementType t = getType(element);
if (t != null) {
switch(t) {
case DONE_CURRENT:
return UIIcons.getImage(resources, UIIcons.CURRENT_STEP);
case DONE:
return UIIcons.getImage(resources, UIIcons.DONE_STEP);
default:
}
}
return null;
}
@Override
public String getToolTipText(Object element) {
ElementType t = getType(element);
if (t != null) {
switch(t) {
case DONE:
return UIText.RebaseInteractiveView_StatusDone;
case DONE_CURRENT:
return UIText.RebaseInteractiveView_StatusCurrent;
case TODO:
return UIText.RebaseInteractiveView_StatusTodo;
default:
}
}
// $NON-NLS-1$
return "";
}
@Override
public String getText(Object element) {
// $NON-NLS-1$
return "";
}
});
TreeViewerColumn stepColumn = createColumn(headings[1]);
layout.setColumnData(stepColumn.getColumn(), new ColumnPixelData(55));
stepColumn.setLabelProvider(new HighlightingColumnLabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof PlanElement) {
PlanElement planLine = (PlanElement) element;
// $NON-NLS-1$
return (planIndexer.indexOf(planLine) + 1) + ".";
}
return super.getText(element);
}
});
stepColumn.getColumn().addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Tree tree = planTreeViewer.getTree();
boolean orderReversed = tree.getSortDirection() == SWT.DOWN;
RebaseInteractivePreferences.setOrderReversed(!orderReversed);
int newDirection = (orderReversed ? SWT.UP : SWT.DOWN);
tree.setSortDirection(newDirection);
TreeItem topmostVisibleItem = tree.getTopItem();
refreshUI();
if (topmostVisibleItem != null)
tree.showItem(topmostVisibleItem);
}
});
int direction = (RebaseInteractivePreferences.isOrderReversed() ? SWT.DOWN : SWT.UP);
Tree planTree = planTreeViewer.getTree();
planTree.setSortColumn(stepColumn.getColumn());
planTree.setSortDirection(direction);
TreeViewerColumn actionColumn = createColumn(headings[2]);
layout.setColumnData(actionColumn.getColumn(), new ColumnPixelData(90));
actionColumn.setLabelProvider(new HighlightingColumnLabelProvider() {
@Override
public Image getImage(Object element) {
ElementAction a = getAction(element);
if (a != null) {
switch(a) {
case EDIT:
return UIIcons.getImage(resources, UIIcons.EDITCONFIG);
case FIXUP:
if (RebaseInteractivePreferences.isOrderReversed())
return UIIcons.getImage(resources, UIIcons.FIXUP_DOWN);
else
return UIIcons.getImage(resources, UIIcons.FIXUP_UP);
case PICK:
return UIIcons.getImage(resources, UIIcons.CHERRY_PICK);
case REWORD:
return UIIcons.getImage(resources, UIIcons.REWORD);
case SKIP:
return UIIcons.getImage(resources, UIIcons.REBASE_SKIP);
case SQUASH:
if (RebaseInteractivePreferences.isOrderReversed())
return UIIcons.getImage(resources, UIIcons.SQUASH_DOWN);
else
return UIIcons.getImage(resources, UIIcons.SQUASH_UP);
default:
}
}
return super.getImage(element);
}
@Override
public String getText(Object element) {
ElementAction a = getAction(element);
return (a != null) ? a.name() : super.getText(element);
}
private ElementAction getAction(Object element) {
if (element instanceof PlanElement) {
PlanElement planLine = (PlanElement) element;
return planLine.getPlanElementAction();
} else
return null;
}
});
TreeViewerColumn commitIDColumn = createColumn(headings[3]);
int minWidth;
GC gc = new GC(planTreeViewer.getControl().getDisplay());
try {
gc.setFont(planTreeViewer.getControl().getFont());
minWidth = // $NON-NLS-1$
Math.max(// $NON-NLS-1$
gc.stringExtent("0000000").x, gc.stringExtent(headings[3]).x) + 10;
} finally {
gc.dispose();
}
layout.setColumnData(commitIDColumn.getColumn(), new ColumnPixelData(minWidth));
commitIDColumn.setLabelProvider(new HighlightingColumnLabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof PlanElement) {
PlanElement planLine = (PlanElement) element;
return planLine.getCommit().name();
}
return super.getText(element);
}
});
TreeViewerColumn commitMessageColumn = createColumn(headings[4]);
layout.setColumnData(commitMessageColumn.getColumn(), new ColumnWeightData(200, 200));
commitMessageColumn.setLabelProvider(new HighlightingColumnLabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof PlanElement) {
PlanElement planLine = (PlanElement) element;
return planLine.getShortMessage();
}
return super.getText(element);
}
});
TreeViewerColumn authorColumn = createColumn(headings[5]);
layout.setColumnData(authorColumn.getColumn(), new ColumnWeightData(120, 120));
authorColumn.setLabelProvider(new HighlightingColumnLabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof PlanElement) {
PlanElement planLine = (PlanElement) element;
return planLine.getAuthor();
}
return super.getText(element);
}
});
TreeViewerColumn authoredDateColumn = createColumn(headings[6]);
layout.setColumnData(authoredDateColumn.getColumn(), new ColumnWeightData(80, 80));
authoredDateColumn.setLabelProvider(new HighlightingColumnLabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof PlanElement) {
PlanElement planLine = (PlanElement) element;
return planLine.getAuthoredDate(dateFormatter);
}
return super.getText(element);
}
});
TreeViewerColumn committerColumn = createColumn(headings[7]);
layout.setColumnData(committerColumn.getColumn(), new ColumnWeightData(120, 120));
committerColumn.setLabelProvider(new HighlightingColumnLabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof PlanElement) {
PlanElement planLine = (PlanElement) element;
return planLine.getCommitter();
}
return super.getText(element);
}
});
TreeViewerColumn commitDateColumn = createColumn(headings[8]);
layout.setColumnData(commitDateColumn.getColumn(), new ColumnWeightData(80, 80));
commitDateColumn.setLabelProvider(new HighlightingColumnLabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof PlanElement) {
PlanElement planLine = (PlanElement) element;
return planLine.getCommittedDate(dateFormatter);
}
return super.getText(element);
}
});
dynamicColumns = new TreeViewerColumn[] { commitMessageColumn, authorColumn, authoredDateColumn, committerColumn, commitDateColumn };
}
Aggregations