Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMykola Nikishov2018-07-06 05:34:35 -0400
committerMykola Nikishov2018-07-06 07:29:15 -0400
commit34dcb300f6165458410a0beb3f1500fa79b5c034 (patch)
tree6077c6950cb13d1b3d58f1a9e62a7d0dd56e0d23
parent6b06d650c4ef2b4acf8bf2400d4b5493b7f1b704 (diff)
downloadeclipse.platform.team-34dcb300f6165458410a0beb3f1500fa79b5c034.tar.gz
eclipse.platform.team-34dcb300f6165458410a0beb3f1500fa79b5c034.tar.xz
eclipse.platform.team-34dcb300f6165458410a0beb3f1500fa79b5c034.zip
Use guard condition in TextMergeViewer's configureCompareFilterActions
Change-Id: I55638c8d55ef0825892effe8415b028a859dad6b Signed-off-by: Mykola Nikishov <mn@mn.com.ua>
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java135
1 files changed, 54 insertions, 81 deletions
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
index f3c1eaa1d..a9c9555a2 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
@@ -3837,97 +3837,70 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
private void configureCompareFilterActions(Object input, Object ancestor,
Object left, Object right) {
- if (getCompareConfiguration() != null) {
- CompareFilterDescriptor[] compareFilterDescriptors =
- CompareUIPlugin.getDefault().findCompareFilters(input);
-
- Object current = getCompareConfiguration().getProperty(
- ChangeCompareFilterPropertyAction.COMPARE_FILTER_ACTIONS);
- boolean currentFiltersMatch = false;
- if (current != null
- && current instanceof List
- && ((List<?>) current).size() == compareFilterDescriptors.length) {
- currentFiltersMatch = true;
- @SuppressWarnings("unchecked")
- List<ChangeCompareFilterPropertyAction> currentFilterActions =
- (List<ChangeCompareFilterPropertyAction>) current;
- for (int i = 0; i < compareFilterDescriptors.length; i++) {
- boolean match = false;
- for (int j = 0; j < currentFilterActions.size(); j++) {
- if (compareFilterDescriptors[i]
- .getFilterId()
- .equals(currentFilterActions.get(j).getFilterId())) {
- match = true;
- break;
- }
- }
- if (!match) {
- currentFiltersMatch = false;
+ if (getCompareConfiguration() == null) {
+ return;
+ }
+
+ CompareFilterDescriptor[] compareFilterDescriptors = CompareUIPlugin.getDefault().findCompareFilters(input);
+ Object current = getCompareConfiguration()
+ .getProperty(ChangeCompareFilterPropertyAction.COMPARE_FILTER_ACTIONS);
+ boolean currentFiltersMatch = false;
+ if (current != null && current instanceof List
+ && ((List<?>) current).size() == compareFilterDescriptors.length) {
+ currentFiltersMatch = true;
+ @SuppressWarnings("unchecked")
+ List<ChangeCompareFilterPropertyAction> currentFilterActions = (List<ChangeCompareFilterPropertyAction>) current;
+ for (int i = 0; i < compareFilterDescriptors.length; i++) {
+ boolean match = false;
+ for (int j = 0; j < currentFilterActions.size(); j++) {
+ if (compareFilterDescriptors[i].getFilterId().equals(currentFilterActions.get(j).getFilterId())) {
+ match = true;
break;
}
}
+ if (!match) {
+ currentFiltersMatch = false;
+ break;
+ }
}
-
- if (!currentFiltersMatch) {
- getCompareConfiguration()
- .setProperty(
- ChangeCompareFilterPropertyAction.COMPARE_FILTERS_INITIALIZING,
- Boolean.TRUE);
- disposeCompareFilterActions(true);
- fCompareFilterActions.clear();
- for (int i = 0; i < compareFilterDescriptors.length; i++) {
- ChangeCompareFilterPropertyAction compareFilterAction = new ChangeCompareFilterPropertyAction(
- compareFilterDescriptors[i],
- getCompareConfiguration());
- compareFilterAction.setInput(input, ancestor, left, right);
- fCompareFilterActions.add(compareFilterAction);
- fLeft.addTextAction(compareFilterAction);
- fRight.addTextAction(compareFilterAction);
- fAncestor.addTextAction(compareFilterAction);
-
- if (getCompareConfiguration().getContainer()
- .getActionBars() != null) {
+ }
+ if (!currentFiltersMatch) {
+ getCompareConfiguration().setProperty(ChangeCompareFilterPropertyAction.COMPARE_FILTERS_INITIALIZING,
+ Boolean.TRUE);
+ disposeCompareFilterActions(true);
+ fCompareFilterActions.clear();
+ for (int i = 0; i < compareFilterDescriptors.length; i++) {
+ ChangeCompareFilterPropertyAction compareFilterAction = new ChangeCompareFilterPropertyAction(
+ compareFilterDescriptors[i], getCompareConfiguration());
+ compareFilterAction.setInput(input, ancestor, left, right);
+ fCompareFilterActions.add(compareFilterAction);
+ fLeft.addTextAction(compareFilterAction);
+ fRight.addTextAction(compareFilterAction);
+ fAncestor.addTextAction(compareFilterAction);
+
+ if (getCompareConfiguration().getContainer().getActionBars() != null) {
+ getCompareConfiguration().getContainer().getActionBars().getToolBarManager()
+ .appendToGroup(CompareEditorContributor.FILTER_SEPARATOR, compareFilterAction);
+ if (compareFilterAction.getActionDefinitionId() != null)
getCompareConfiguration()
.getContainer()
.getActionBars()
- .getToolBarManager()
- .appendToGroup(
- CompareEditorContributor.FILTER_SEPARATOR,
+ .setGlobalActionHandler(compareFilterAction.getActionDefinitionId(),
compareFilterAction);
- if (compareFilterAction.getActionDefinitionId() != null)
- getCompareConfiguration()
- .getContainer()
- .getActionBars()
- .setGlobalActionHandler(
- compareFilterAction
- .getActionDefinitionId(),
- compareFilterAction);
- }
- }
- if (!fCompareFilterActions.isEmpty()
- && getCompareConfiguration().getContainer()
- .getActionBars() != null) {
- getCompareConfiguration().getContainer().getActionBars()
- .getToolBarManager().markDirty();
- getCompareConfiguration().getContainer().getActionBars()
- .getToolBarManager().update(true);
- getCompareConfiguration().getContainer().getActionBars()
- .updateActionBars();
- }
- getCompareConfiguration()
- .setProperty(
- ChangeCompareFilterPropertyAction.COMPARE_FILTER_ACTIONS,
- fCompareFilterActions);
- getCompareConfiguration()
- .setProperty(
- ChangeCompareFilterPropertyAction.COMPARE_FILTERS_INITIALIZING,
- null);
- } else {
- for (int i = 0; i < fCompareFilterActions.size(); i++) {
- fCompareFilterActions
- .get(i).setInput(input, ancestor, left, right);
}
}
+ if (!fCompareFilterActions.isEmpty() && getCompareConfiguration().getContainer().getActionBars() != null) {
+ getCompareConfiguration().getContainer().getActionBars().getToolBarManager().markDirty();
+ getCompareConfiguration().getContainer().getActionBars().getToolBarManager().update(true);
+ getCompareConfiguration().getContainer().getActionBars().updateActionBars();
+ }
+ getCompareConfiguration().setProperty(ChangeCompareFilterPropertyAction.COMPARE_FILTER_ACTIONS,
+ fCompareFilterActions);
+ getCompareConfiguration().setProperty(ChangeCompareFilterPropertyAction.COMPARE_FILTERS_INITIALIZING, null);
+ } else {
+ for (int i = 0; i < fCompareFilterActions.size(); i++) {
+ fCompareFilterActions.get(i).setInput(input, ancestor, left, right);
+ }
}
}

Back to the top