use of org.eclipse.egit.core.internal.rebase.RebaseInteractivePlan.PlanElement in project egit by eclipse.
the class RebaseInteractivePlanTest method moveUpTestTwoElements.
@Test
public void moveUpTestTwoElements() throws Exception {
PlanElement element1 = createPlanElement(false);
PlanElement element2 = createPlanElement(false);
toDoElements.add(element1);
toDoElements.add(element2);
moveHelper.moveTodoEntryUp(element2);
assertEquals(element2, toDoElements.get(0));
assertEquals(element1, toDoElements.get(1));
moveHelper.moveTodoEntryUp(element2);
assertEquals(element2, toDoElements.get(0));
assertEquals(element1, toDoElements.get(1));
moveHelper.moveTodoEntryUp(element1);
assertEquals(element1, toDoElements.get(0));
assertEquals(element2, toDoElements.get(1));
}
use of org.eclipse.egit.core.internal.rebase.RebaseInteractivePlan.PlanElement in project egit by eclipse.
the class RebaseInteractivePlanTest method createPlanElement.
@SuppressWarnings("boxing")
private PlanElement createPlanElement(boolean isComment) {
PlanElement element1 = Mockito.mock(PlanElement.class);
Mockito.when(element1.isComment()).thenReturn(isComment);
return element1;
}
use of org.eclipse.egit.core.internal.rebase.RebaseInteractivePlan.PlanElement in project egit by eclipse.
the class PlanContextMenuAction method run.
@Override
public void run() {
ISelection selection = planViewer.getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
for (Object selectedRow : structuredSelection.toList()) {
if (selectedRow instanceof PlanElement) {
PlanElement planElement = (PlanElement) selectedRow;
planElement.setPlanElementAction(action);
}
}
actionToolbarProvider.mapActionItemsToSelection(selection);
}
}
use of org.eclipse.egit.core.internal.rebase.RebaseInteractivePlan.PlanElement in project egit by eclipse.
the class RebaseInteractiveStepActionToolBarProvider method enableMoveButtons.
private void enableMoveButtons(PlanElement firstSelectedEntry, PlanElement lastSelectedEntry) {
List<PlanElement> list = view.getCurrentPlan().getList();
List<PlanElement> stepList = new ArrayList<>();
for (PlanElement planElement : list) {
if (!planElement.isComment())
stepList.add(planElement);
}
int firstEntryIndex = stepList.indexOf(firstSelectedEntry);
int lastEntryIndex = stepList.indexOf(lastSelectedEntry);
if (!RebaseInteractivePreferences.isOrderReversed()) {
itemMoveUp.setEnabled(firstEntryIndex > 0);
itemMoveDown.setEnabled(lastEntryIndex < stepList.size() - 1);
} else {
itemMoveUp.setEnabled(firstEntryIndex < stepList.size() - 1);
itemMoveDown.setEnabled(lastEntryIndex > 0);
}
}
use of org.eclipse.egit.core.internal.rebase.RebaseInteractivePlan.PlanElement 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