use of org.eclipse.jface.text.source.ILineDiffer in project eclipse.platform.text by eclipse.
the class RevertLineAction method computeEnablement.
@Override
public boolean computeEnablement() {
if (!super.computeEnablement())
return false;
fLine = getLastLine();
if (fLine == -1)
return false;
ILineDiffer differ = getDiffer();
if (differ == null)
return false;
ILineDiffInfo info = differ.getLineInfo(fLine);
if (info == null || info.getChangeType() == ILineDiffInfo.UNCHANGED)
return false;
if (info.getChangeType() == ILineDiffInfo.ADDED)
setText(QuickDiffMessages.RevertLineAction_delete_label);
else
setText(QuickDiffMessages.RevertLineAction_label);
return true;
}
use of org.eclipse.jface.text.source.ILineDiffer in project eclipse.platform.text by eclipse.
the class RevertSelectionAction method computeEnablement.
@Override
public boolean computeEnablement() {
if (!super.computeEnablement())
return false;
ITextSelection selection = getSelection();
if (selection == null)
return false;
fStartLine = selection.getStartLine();
fEndLine = selection.getEndLine();
// only enable if mouse activity is inside line range
int activityLine = getLastLine();
if (activityLine == -1 || activityLine < fStartLine || activityLine > fEndLine + 1)
// + 1 to cover the case where the selection goes to the offset of the next line
return false;
ILineDiffer differ = getDiffer();
if (differ == null)
return false;
// only enable if selection covers at least two lines
if (fEndLine > fStartLine) {
for (int i = fStartLine; i <= fEndLine; i++) {
ILineDiffInfo info = differ.getLineInfo(i);
if (info != null && info.hasChanges()) {
return true;
}
}
}
return false;
}
use of org.eclipse.jface.text.source.ILineDiffer in project eclipse.platform.text by eclipse.
the class RestoreAction method computeEnablement.
@Override
public boolean computeEnablement() {
if (!super.computeEnablement())
return false;
fLine = getLastLine();
if (fLine == -1)
return false;
ILineDiffer differ = getDiffer();
if (differ == null)
return false;
ILineDiffInfo info = differ.getLineInfo(fLine);
if (info == null || (info.getRemovedLinesAbove() <= 0 && info.getRemovedLinesBelow() <= 0))
return false;
if (info.getRemovedLinesBelow() == 0) {
fLine--;
} else if (info.getRemovedLinesAbove() != 0) {
// take the line below
}
info = differ.getLineInfo(fLine);
if (info == null)
return false;
if (info.getRemovedLinesBelow() == 1)
// $NON-NLS-1$
setText(QuickDiffMessages.getString("RestoreAction.label"));
else
// $NON-NLS-1$
setText(NLSUtility.format(QuickDiffMessages.getString("RestoreAction.multiple.label"), String.valueOf(info.getRemovedLinesBelow())));
return true;
}
Aggregations