Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ui/org.eclipse.pde.spy.context/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %name
Bundle-SymbolicName: org.eclipse.pde.spy.context;singleton:=true
Bundle-Version: 1.1.400.qualifier
Bundle-Version: 1.1.500.qualifier
Bundle-Vendor: %provider-name
Automatic-Module-Name: org.eclipse.pde.spy.context
Bundle-RequiredExecutionEnvironment: JavaSE-17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ public class ContextDataFilter extends ViewerFilter {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if ((element == ContextDataProvider.LOCAL_VALUE_NODE)
|| (element == ContextDataProvider.INHERITED_INJECTED_VALUE_NODE))
|| (element == ContextDataProvider.INHERITED_INJECTED_VALUE_NODE)) {
return true;
}

// Must only select objects matching the pattern or objects under a kept
// node (to see where it is injected)
Expand Down Expand Up @@ -73,10 +74,11 @@ public boolean select(Viewer viewer, Object parentElement, Object element) {

/** Set the pattern and use it as lowercase */
public void setPattern(String newPattern) {
if ((newPattern == null) || (newPattern.length() == 0))
if ((newPattern == null) || (newPattern.length() == 0)) {
pattern = null;
else
} else {
pattern = newPattern.toLowerCase();
}
}

/**
Expand Down Expand Up @@ -129,8 +131,9 @@ private Collection<String> computeValues(IEclipseContext ctx) {

if (currentContext.getRawListenerNames() != null) {
for (String name : currentContext.getRawListenerNames()) {
if (!localKeys.contains(name) && !localContextFunctionsKeys.contains(name))
if (!localKeys.contains(name) && !localContextFunctionsKeys.contains(name)) {
result.add(name);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,9 @@ public void setColumn(int column) {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
// For root elements at first level, we keep Local before Inherited
if ((e1 == ContextDataProvider.LOCAL_VALUE_NODE) || (e2 == ContextDataProvider.LOCAL_VALUE_NODE))
if ((e1 == ContextDataProvider.LOCAL_VALUE_NODE) || (e2 == ContextDataProvider.LOCAL_VALUE_NODE)) {
return -1;
}

// Now can compare the text from label provider.
String lp1 = labelProvider.getText(e1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ public Object[] getElements(Object inputElement) {

@Override
public Object[] getChildren(Object inputElement) {
if (selectedContext == null)
if (selectedContext == null) {
return EMPTY_RESULT;
}

if (inputElement == LOCAL_VALUE_NODE) {
Collection<Object> result = new ArrayList<>();
Expand All @@ -118,12 +119,13 @@ public Object[] getChildren(Object inputElement) {
// For context function, we have to compute the value (if possible),
// and display it as a standard value
Map<String, Object> cfValues = new HashMap<>();
for (String key : selectedContext.localContextFunction().keySet())
for (String key : selectedContext.localContextFunction().keySet()) {
try {
cfValues.put(key, selectedContext.get(key));
} catch (Throwable e) {
cfValues.put(key, NO_VALUE_COULD_BE_COMPUTED + " (Exception : " + e.getClass().getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
}
}
result.addAll(cfValues.entrySet());
return result.toArray();

Expand All @@ -139,8 +141,9 @@ public Object[] getChildren(Object inputElement) {

if (selectedContext.getRawListenerNames() != null) {
for (String name : selectedContext.getRawListenerNames()) {
if (!localKeys.contains(name) && !localContextFunctionsKeys.contains(name))
if (!localKeys.contains(name) && !localContextFunctionsKeys.contains(name)) {
result.add(name);
}
}
}
return result.isEmpty() ? new String[] { NO_VALUES_FOUND } : result.toArray();
Expand All @@ -164,8 +167,9 @@ public void setDisplayKey(boolean k) {
@Override
@SuppressWarnings("unchecked")
public String getText(Object element) {
if (selectedContext == null)
if (selectedContext == null) {
return null;
}

if (element instanceof Map.Entry) {
Map.Entry<String, Object> mapEntry = (Map.Entry<String, Object>) element;
Expand All @@ -176,14 +180,16 @@ public String getText(Object element) {
// value in value
String txt = super.getText(element);
if (displayKey) {
if (txt.contains("#")) //$NON-NLS-1$
if (txt.contains("#")) { //$NON-NLS-1$
return INJECTED_IN_METHOD;
else if (txt.contains("@")) //$NON-NLS-1$
} else if (txt.contains("@")) { //$NON-NLS-1$
return UPDATED_IN_CLASS;
else
} else {
return INJECTED_IN_FIELD;
} else
}
} else {
return txt;
}
}

return displayKey ? super.getText(element) : null;
Expand All @@ -194,8 +200,9 @@ public Color getForeground(Object element) {
// Return magenta color if the value could not be yet computed (for
// context functions)
String s = getText(element);
if ((s != null) && s.startsWith(NO_VALUE_COULD_BE_COMPUTED))
if ((s != null) && s.startsWith(NO_VALUE_COULD_BE_COMPUTED)) {
return COLOR_IF_NOT_COMPUTED;
}

// Return blue color if the string matches the search
return (contextFilter.matchText(s)) ? COLOR_IF_FOUND : null;
Expand All @@ -210,8 +217,9 @@ public Font getFont(Object element) {

@Override
public Image getImage(Object element) {
if (!displayKey) // No image in value column, only in key column
if (!displayKey) { // No image in value column, only in key column
return null;
}

if (element == LOCAL_VALUE_NODE) {
return selectedContext == null ? null : imgReg.get(LOCAL_VARIABLE_IMG_KEY);
Expand All @@ -225,17 +233,18 @@ public Image getImage(Object element) {
// value in value column
String txt = super.getText(element);

if (txt.contains("#")) //$NON-NLS-1$
if (txt.contains("#")) { //$NON-NLS-1$
return imgReg.get(PUBLIC_METHOD_IMG_KEY);
else if (txt.contains("@")) //$NON-NLS-1$
} else if (txt.contains("@")) { //$NON-NLS-1$
return imgReg.get(CONTEXT_FUNCTION_IMG_KEY);
else
} else {
return imgReg.get(PUBLIC_FIELD_IMG_KEY);
}

} else if (element instanceof Map.Entry) {
if (isAContextKeyFunction(element))
if (isAContextKeyFunction(element)) {
return imgReg.get(CONTEXT_FUNCTION_IMG_KEY);
else {
} else {
// It is a value. If it is injected somewhere, display the
// inject image
return hasChildren(element) ? imgReg.get(INJECT_IMG_KEY) : imgReg.get(VALUE_IN_CONTEXT_IMG_KEY);
Expand All @@ -262,11 +271,12 @@ public String getToolTipText(Object element) {

return Messages.ContextDataProvider_26 + fname;
} else {
if (hasChildren(element))
if (hasChildren(element)) {
return Messages.ContextDataProvider_27;
else {
if (element instanceof Map.Entry)
} else {
if (element instanceof Map.Entry) {
return Messages.ContextDataProvider_28;
}
}

}
Expand Down Expand Up @@ -303,8 +313,9 @@ boolean isAContextKeyFunction(Object element) {

@Override
public Object getParent(Object element) {
if (element == LOCAL_VALUE_NODE || element == INHERITED_INJECTED_VALUE_NODE)
if (element == LOCAL_VALUE_NODE || element == INHERITED_INJECTED_VALUE_NODE) {
return null;
}

// Not computed
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ public void widgetSelected(SelectionEvent e) {
GridDataFactory.fillDefaults().hint(200, SWT.DEFAULT).applyTo(filterText);
filterText.setMessage(Messages.ContextSpyPart_7);
filterText.setToolTipText(Messages.ContextSpyPart_8);
if (lastFilterText != null)
if (lastFilterText != null) {
filterText.setText(lastFilterText);
}
contextFilter.setPattern(lastFilterText);
filterText.addKeyListener(new KeyAdapter() {
@Override
Expand Down Expand Up @@ -205,10 +206,11 @@ public void selectionChanged(SelectionChangedEvent event) {

/** Set the filter on context data part */
public void setFilter() {
if (showOnlyFilteredElements.isEnabled() && showOnlyFilteredElements.getSelection())
if (showOnlyFilteredElements.isEnabled() && showOnlyFilteredElements.getSelection()) {
contextDataPart.setFilter(contextFilter);
else
} else {
contextDataPart.setFilter(null);
}
}

@PreDestroy
Expand Down
Loading