use of org.eclipse.egit.core.internal.rebase.RebaseInteractivePlan.PlanElement in project egit by eclipse.
the class RebaseInteractiveStepActionToolBarProvider method moveDown.
void moveDown() {
List<PlanElement> selectedRebaseTodoLines = getSelectedRebaseTodoLines();
Collections.reverse(selectedRebaseTodoLines);
for (PlanElement planElement : selectedRebaseTodoLines) {
if (planElement.getElementType() != ElementType.TODO)
return;
if (!RebaseInteractivePreferences.isOrderReversed())
view.getCurrentPlan().moveTodoEntryDown(planElement);
else
view.getCurrentPlan().moveTodoEntryUp(planElement);
mapActionItemsToSelection(view.planTreeViewer.getSelection());
}
}
use of org.eclipse.egit.core.internal.rebase.RebaseInteractivePlan.PlanElement 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.PlanElement in project egit by eclipse.
the class RebaseInteractiveView method createPartControl.
@Override
public void createPartControl(Composite parent) {
GridLayoutFactory.fillDefaults().applyTo(parent);
final FormToolkit toolkit = new FormToolkit(parent.getDisplay());
parent.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
toolkit.dispose();
}
});
form = createForm(parent, toolkit);
createCommandToolBar(form, toolkit);
planTreeViewer = createPlanTreeViewer(form.getBody(), toolkit);
planLayout = new PlanLayout();
planTreeViewer.getTree().getParent().setLayout(planLayout);
createColumns(planLayout);
createStepActionToolBar(toolkit);
createPopupMenu(planTreeViewer);
setupListeners();
createLocalDragandDrop();
planTreeViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
PlanElement element = (PlanElement) ((IStructuredSelection) event.getSelection()).getFirstElement();
if (element == null)
return;
RepositoryCommit commit = loadCommit(element.getCommit());
if (commit != null)
CommitEditor.openQuiet(commit);
}
private RepositoryCommit loadCommit(AbbreviatedObjectId abbreviatedObjectId) {
if (abbreviatedObjectId != null) {
try (RevWalk walk = new RevWalk(RebaseInteractiveView.this.currentRepository)) {
Collection<ObjectId> resolved = walk.getObjectReader().resolve(abbreviatedObjectId);
if (resolved.size() == 1) {
RevCommit commit = walk.parseCommit(resolved.iterator().next());
return new RepositoryCommit(RebaseInteractiveView.this.currentRepository, commit);
}
} catch (IOException e) {
return null;
}
}
return null;
}
});
prefListener = new IPreferenceChangeListener() {
@Override
public void preferenceChange(PreferenceChangeEvent event) {
if (!RepositoryUtil.PREFS_DIRECTORIES_REL.equals(event.getKey())) {
return;
}
final Repository repo = currentRepository;
if (repo == null)
return;
if (Activator.getDefault().getRepositoryUtil().contains(repo))
return;
// Unselect repository as it has been removed
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
currentRepository = null;
showRepository(null);
}
});
}
};
InstanceScope.INSTANCE.getNode(org.eclipse.egit.core.Activator.getPluginId()).addPreferenceChangeListener(prefListener);
uiPrefsListener = new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
String property = event.getProperty();
if (UIPreferences.DATE_FORMAT.equals(property) || UIPreferences.DATE_FORMAT_CHOICE.equals(property) || UIPreferences.RESOURCEHISTORY_SHOW_RELATIVE_DATE.equals(property)) {
refresh();
}
}
};
Activator.getDefault().getPreferenceStore().addPropertyChangeListener(uiPrefsListener);
IActionBars actionBars = getViewSite().getActionBars();
IToolBarManager toolbar = actionBars.getToolBarManager();
listenOnRepositoryViewSelection = RebaseInteractivePreferences.isReactOnSelection();
// link with selection
Action linkSelectionAction = new BooleanPrefAction((IPersistentPreferenceStore) Activator.getDefault().getPreferenceStore(), UIPreferences.REBASE_INTERACTIVE_SYNC_SELECTION, UIText.InteractiveRebaseView_LinkSelection) {
@Override
public void apply(boolean value) {
listenOnRepositoryViewSelection = value;
}
};
linkSelectionAction.setImageDescriptor(UIIcons.ELCL16_SYNCED);
toolbar.add(linkSelectionAction);
switchRepositoriesAction = new RepositoryToolbarAction(false, () -> currentRepository, repo -> setInput(new StructuredSelection(repo)));
toolbar.add(switchRepositoriesAction);
UIUtils.notifySelectionChangedWithCurrentSelection(selectionChangedListener, getSite());
getSite().setSelectionProvider(new RepositorySelectionProvider(planTreeViewer, () -> currentRepository));
}
use of org.eclipse.egit.core.internal.rebase.RebaseInteractivePlan.PlanElement in project egit by eclipse.
the class RebasePlanIndexer method createIndex.
private void createIndex() {
lastFoundElementPosition = 0;
filteredPlan.clear();
for (PlanElement element : plan.getList()) {
if (!element.isComment())
filteredPlan.add(element);
}
}
use of org.eclipse.egit.core.internal.rebase.RebaseInteractivePlan.PlanElement in project egit by eclipse.
the class RebaseInteractivePlanTest method moveDownTestOneElement.
@Test
public void moveDownTestOneElement() throws Exception {
PlanElement element1 = createPlanElement(false);
toDoElements.add(element1);
moveHelper.moveTodoEntryDown(element1);
assertEquals(element1, toDoElements.get(0));
}
Aggregations