Bug 371140 - Add option to configure limit on indexer error reporting
diff --git a/rdt/org.eclipse.ptp.rdt.ui/plugin.properties b/rdt/org.eclipse.ptp.rdt.ui/plugin.properties
index 63cbb12..ab39dee 100755
--- a/rdt/org.eclipse.ptp.rdt.ui/plugin.properties
+++ b/rdt/org.eclipse.ptp.rdt.ui/plugin.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2008, 2010 IBM Corporation and others.
+# Copyright (c) 2008, 2012 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
@@ -48,6 +48,8 @@
perspective.name.0 = Remote C/C++
+RemoteDevPrefPage.name = Remote Development
+
RemoteIncludeTab.name=Remote Includes
Includes.tooltip=Includes list
SymbolTab.name=Symbols
diff --git a/rdt/org.eclipse.ptp.rdt.ui/plugin.xml b/rdt/org.eclipse.ptp.rdt.ui/plugin.xml
index 130def0..966ecf0 100755
--- a/rdt/org.eclipse.ptp.rdt.ui/plugin.xml
+++ b/rdt/org.eclipse.ptp.rdt.ui/plugin.xml
@@ -888,4 +888,16 @@
</objectContribution>
</extension>
+ <extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ class="org.eclipse.ptp.rdt.ui.preferences.RemoteDevelopmentPreferencePage"
+ id="org.eclipse.ptp.rdt.ui.RemoteDevPreferencePage"
+ name="%RemoteDevPrefPage.name">
+ </page>
+ </extension>
+ <extension
+ point="org.eclipse.core.runtime.preferences">
+ <initializer class="org.eclipse.ptp.rdt.ui.preferences.PreferenceInitializer"/>
+ </extension>
</plugin>
diff --git a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/UIPlugin.java b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/UIPlugin.java
index 4e91ad8..3b09039 100755
--- a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/UIPlugin.java
+++ b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/UIPlugin.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 IBM Corporation and others.
+ * Copyright (c) 2008, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -19,6 +19,7 @@
import org.eclipse.ptp.rdt.ui.serviceproviders.IndexLocationChangeListener;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.internal.editors.text.EditorsPlugin;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
@@ -29,7 +30,7 @@
*
*
*/
-public class UIPlugin extends Plugin {
+public class UIPlugin extends AbstractUIPlugin {
private static UIPlugin fInstance = null;
diff --git a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/preferences/Messages.java b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/preferences/Messages.java
new file mode 100644
index 0000000..8f59800
--- /dev/null
+++ b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/preferences/Messages.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2012 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ptp.rdt.ui.preferences;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @since 4.0
+ */
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.ptp.rdt.ui.preferences.messages"; //$NON-NLS-1$
+ public static String RemoteDevPreferencePage_ErrorReportingGroupLabel;
+ public static String RemoteDevPreferencePage_IndexErrorLimitLabel;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/preferences/PreferenceConstants.java b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/preferences/PreferenceConstants.java
new file mode 100644
index 0000000..03f0602
--- /dev/null
+++ b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/preferences/PreferenceConstants.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2012 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ *******************************************************************************/
+
+
+package org.eclipse.ptp.rdt.ui.preferences;
+
+/**
+ * @since 4.0
+ */
+public final class PreferenceConstants {
+
+ private PreferenceConstants() {}
+
+ public static final String INDEXER_ERRORS_DISPLAY_LIMIT = "org.eclipse.ptp.rdt.ui.INDEXER_ERRORS_DISPLAY_LIMIT"; //$NON-NLS-1$
+
+}
diff --git a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/preferences/PreferenceInitializer.java b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/preferences/PreferenceInitializer.java
new file mode 100644
index 0000000..ac0930c
--- /dev/null
+++ b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/preferences/PreferenceInitializer.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2012 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.ptp.rdt.ui.preferences;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.ptp.rdt.ui.UIPlugin;
+
+/**
+ * Class used to initialize default preference values.
+ * @since 4.0
+ */
+public class PreferenceInitializer extends AbstractPreferenceInitializer {
+
+ public void initializeDefaultPreferences() {
+ IPreferenceStore store = UIPlugin.getDefault().getPreferenceStore();
+
+ store.setDefault(PreferenceConstants.INDEXER_ERRORS_DISPLAY_LIMIT, 100);
+ }
+}
diff --git a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/preferences/RemoteDevelopmentPreferencePage.java b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/preferences/RemoteDevelopmentPreferencePage.java
new file mode 100644
index 0000000..7294642
--- /dev/null
+++ b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/preferences/RemoteDevelopmentPreferencePage.java
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * Copyright (c) 2012 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.ptp.rdt.ui.preferences;
+
+import org.eclipse.jface.preference.FieldEditor;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.IntegerFieldEditor;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.ptp.rdt.ui.UIPlugin;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+/**
+ * @since 4.0
+ *
+ */
+public class RemoteDevelopmentPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
+
+ private IntegerFieldEditor indexerErrorLimit;
+
+ private IPropertyChangeListener validityChangeListener = new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getProperty().equals(FieldEditor.IS_VALID)) {
+ updateValidState();
+ }
+ }
+ };
+
+ public void init(IWorkbench workbench){
+ setPreferenceStore(UIPlugin.getDefault().getPreferenceStore());
+ }
+
+ private Composite createComposite(Composite parent, int span, int numColumns) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = numColumns;
+ composite.setLayout(layout);
+ GridData data = new GridData();
+ data.verticalAlignment = GridData.FILL;
+ data.horizontalAlignment = GridData.FILL;
+ data.horizontalSpan = span;
+ composite.setLayoutData(data);
+ return composite;
+ }
+
+ /**
+ * Creates bottomGroup control and sets the default layout data.
+ * @param parent the parent of the new composite
+ * @param numColumns the number of columns for the new composite
+ * @return the newly-created composite
+ */
+ private Group createGroup(Composite parent, int span, int numColumns, String text) {
+
+ Group group = new Group(parent, SWT.NONE);
+ group.setFont(parent.getFont());
+ group.setText(text);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = numColumns;
+ group.setLayout(layout);
+ group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ return group;
+ }
+
+ protected Control createContents(Composite parent) {
+ Composite composite_tab = createComposite(parent, 1, 1);
+
+ Group ErrorReportingDialogsGroup = createGroup(composite_tab, 1, 1, Messages.RemoteDevPreferencePage_ErrorReportingGroupLabel);
+ Composite comp= new Composite(ErrorReportingDialogsGroup, SWT.NONE);
+ indexerErrorLimit = createIndexErrorLimit(comp);
+
+ GridData data = (GridData)indexerErrorLimit.getTextControl( comp ).getLayoutData();
+ data.horizontalAlignment = GridData.BEGINNING;
+ data.widthHint = convertWidthInCharsToPixels( 6 );
+
+ initializeValues();
+
+ return composite_tab;
+ }
+
+ private IntegerFieldEditor createIndexErrorLimit(Composite group) {
+ IntegerFieldEditor result= new IntegerFieldEditor(PreferenceConstants.INDEXER_ERRORS_DISPLAY_LIMIT, Messages.RemoteDevPreferencePage_IndexErrorLimitLabel, group, 4);
+ result.setValidRange(1, 1000);
+ result.setPropertyChangeListener(validityChangeListener);
+ return result;
+ }
+
+ private void initializeValues() {
+ IPreferenceStore store = getPreferenceStore();
+ indexerErrorLimit.setStringValue(String.valueOf(store.getInt(PreferenceConstants.INDEXER_ERRORS_DISPLAY_LIMIT)));
+ }
+
+
+ protected void performDefaults() {
+ super.performDefaults();
+ initalizeDefaults();
+ }
+
+ private void initalizeDefaults() {
+ IPreferenceStore store = getPreferenceStore();
+ indexerErrorLimit.setStringValue(String.valueOf(store.getInt(PreferenceConstants.INDEXER_ERRORS_DISPLAY_LIMIT)));
+ }
+
+ public boolean performOk() {
+ storeValues();
+ return true;
+ }
+
+ private void storeValues() {
+ IPreferenceStore store = getPreferenceStore();
+ store.setValue(PreferenceConstants.INDEXER_ERRORS_DISPLAY_LIMIT, indexerErrorLimit.getIntValue());
+ }
+
+ private void updateValidState() {
+ if (!indexerErrorLimit.isValid()) {
+ setErrorMessage(indexerErrorLimit.getErrorMessage());
+ setValid(false);
+ } else {
+ setErrorMessage(null);
+ setValid(true);
+ }
+ }
+
+}
diff --git a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/preferences/messages.properties b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/preferences/messages.properties
new file mode 100644
index 0000000..1091a84
--- /dev/null
+++ b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/preferences/messages.properties
@@ -0,0 +1,12 @@
+###############################################################################
+# Copyright (c) 2012 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
+RemoteDevPreferencePage_ErrorReportingGroupLabel=Error Reporting
+RemoteDevPreferencePage_IndexErrorLimitLabel=Maximum number of indexing errors to display in Problems view:
diff --git a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/subsystems/RSECIndexSubsystem.java b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/subsystems/RSECIndexSubsystem.java
index 4b22987..5329492 100755
--- a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/subsystems/RSECIndexSubsystem.java
+++ b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/subsystems/RSECIndexSubsystem.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2008, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -74,6 +74,7 @@
import org.eclipse.ptp.rdt.core.serviceproviders.IIndexServiceProvider;
import org.eclipse.ptp.rdt.ui.UIPlugin;
import org.eclipse.ptp.rdt.ui.messages.Messages;
+import org.eclipse.ptp.rdt.ui.preferences.PreferenceConstants;
import org.eclipse.ptp.rdt.ui.serviceproviders.RSECIndexServiceProvider;
import org.eclipse.ptp.services.core.IService;
import org.eclipse.ptp.services.core.IServiceConfiguration;
@@ -280,13 +281,18 @@
}
if (status.getName().equals("done") || status.getName().equals("cancelled") || monitor.isCanceled() || smonitor.isNetworkDown()) { //$NON-NLS-1$//$NON-NLS-2$
+ int maxErrors = UIPlugin.getDefault().getPreferenceStore().getInt(PreferenceConstants.INDEXER_ERRORS_DISPLAY_LIMIT);
+ int errorsReported = 0;
for (int i = 0; i < status.getNestedSize(); i ++ ){
+ if (errorsReported >= maxErrors)
+ break;
DataElement element = status.get(i);
if (element != null && CDTMiner.T_INDEXING_ERROR.equals(element.getType())) { // Error occurred on the server
String message = element.getAttribute(DE.A_NAME)+ ". " ; //$NON-NLS-1$
for (int j = 0; j < fErrorMessages.size(); j++) {
if (message.indexOf(fErrorMessages.get(j)) > 0) {
String msg = reportProblem(scope, message);
+ errorsReported++;
RDTLog.logWarning(msg);
}
}
@@ -505,13 +511,18 @@
}
if (status.getName().equals("done") || status.getName().equals("cancelled") || monitor.isCanceled() || smonitor.isNetworkDown()) { //$NON-NLS-1$//$NON-NLS-2$
+ int maxErrors = UIPlugin.getDefault().getPreferenceStore().getInt(PreferenceConstants.INDEXER_ERRORS_DISPLAY_LIMIT);
+ int errorsReported = 0;
for (int i = 0; i < status.getNestedSize(); i ++ ){
+ if (errorsReported >= maxErrors)
+ break;
DataElement element = status.get(i);
if (element != null && CDTMiner.T_INDEXING_ERROR.equals(element.getType())) { // Error occurred on the server
String message = element.getAttribute(DE.A_NAME)+ ". " ; //$NON-NLS-1$
for (int j = 0; j < fErrorMessages.size(); j++) {
if (message.indexOf(fErrorMessages.get(j)) > 0) {
String msg = reportProblem(scope, message);
+ errorsReported++;
RDTLog.logWarning(msg);
}
}