use of org.eclipse.jface.text.source.ILineDiffer in project eclipse.platform.text by eclipse.
the class RevertBlockAction 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;
boolean hasBlock = false;
if (fLine > 0) {
info = differ.getLineInfo(fLine - 1);
hasBlock = info != null && info.hasChanges();
}
if (!hasBlock) {
info = differ.getLineInfo(fLine + 1);
hasBlock = info != null && info.hasChanges();
}
if (hasBlock)
return true;
return false;
}
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)
// $NON-NLS-1$
setText(QuickDiffMessages.getString("RevertLineAction.delete.label"));
else
// $NON-NLS-1$
setText(QuickDiffMessages.getString("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 RevertBlockAction 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;
boolean hasBlock = false;
if (fLine > 0) {
info = differ.getLineInfo(fLine - 1);
hasBlock = info != null && info.hasChanges();
}
if (!hasBlock) {
info = differ.getLineInfo(fLine + 1);
hasBlock = info != null && info.hasChanges();
}
if (hasBlock)
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)
setText(QuickDiffMessages.RestoreAction_label);
else
setText(NLSUtility.format(QuickDiffMessages.RestoreAction_multiple_label, String.valueOf(info.getRemovedLinesBelow())));
return true;
}
Aggregations