summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorBenjamin Muskalla2010-07-07 21:19:23 (EDT)
committer Benjamin Muskalla2010-07-07 21:19:23 (EDT)
commit20e7626474ab96004fc029abc38a159f4ef50dcc (patch)
tree355fe70f8da8df5cd889eb8f199279108b0023b1
parent930d7bc70d40ba1d06e5f17629c86cb772f73319 (diff)
downloadegit-20e7626474ab96004fc029abc38a159f4ef50dcc.zip
egit-20e7626474ab96004fc029abc38a159f4ef50dcc.tar.gz
egit-20e7626474ab96004fc029abc38a159f4ef50dcc.tar.bz2
Simplified Content providers by using ArrayContentProviderrefs/changes/79/1079/1
In many cases, we only need a content provider to wrap a simple array. Instead of doing this over and over again, we should just use the ArrayContentProvider available in JFace. Change-Id: I19144d7b36d0b85629c0ee534a1805d15680de0e Signed-off-by: Benjamin Muskalla <bmuskalla@eclipsesource.com>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitShareProjectsPage.java19
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RefSpecPanel.java18
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java20
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitDecoratorPreferencePage.java16
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/ConfigureKeysDialog.java22
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/ConfigureUriPage.java22
6 files changed, 12 insertions, 105 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitShareProjectsPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitShareProjectsPage.java
index 2e1abb5..0db5b10 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitShareProjectsPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitShareProjectsPage.java
@@ -23,13 +23,12 @@ import org.eclipse.egit.ui.UIText;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.osgi.util.NLS;
@@ -83,21 +82,7 @@ public class GitShareProjectsPage extends WizardPage {
tv.getTable().setHeaderVisible(true);
- tv.setContentProvider(new IStructuredContentProvider() {
-
- public void inputChanged(Viewer viewer, Object oldInput,
- Object newInput) {
- // nothing
- }
-
- public void dispose() {
- // nothing
- }
-
- public Object[] getElements(Object inputElement) {
- return (Object[]) inputElement;
- }
- });
+ tv.setContentProvider(ArrayContentProvider.getInstance());
tv.setLabelProvider(new ITableLabelProvider() {
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RefSpecPanel.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RefSpecPanel.java
index 07552cd..79a01e4 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RefSpecPanel.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RefSpecPanel.java
@@ -39,6 +39,7 @@ import org.eclipse.jface.fieldassist.IContentProposalProvider;
import org.eclipse.jface.fieldassist.TextContentAdapter;
import org.eclipse.jface.layout.TableColumnLayout;
import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.CheckboxCellEditor;
import org.eclipse.jface.viewers.ColumnLabelProvider;
@@ -46,11 +47,9 @@ import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.EditingSupport;
import org.eclipse.jface.viewers.IElementComparer;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.jface.viewers.TextCellEditor;
-import org.eclipse.jface.viewers.Viewer;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
@@ -925,20 +924,7 @@ public class RefSpecPanel {
createTableColumns(tablePanel);
createCellEditors(table);
- tableViewer.setContentProvider(new IStructuredContentProvider() {
- public Object[] getElements(final Object inputElement) {
- return ((List) inputElement).toArray();
- }
-
- public void dispose() {
- // nothing to dispose
- }
-
- public void inputChanged(Viewer viewer, Object oldInput,
- Object newInput) {
- // input is hard coded
- }
- });
+ tableViewer.setContentProvider(new ArrayContentProvider());
tableViewer.setInput(specs);
tableViewer.setComparer(new IElementComparer() {
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java
index 128e58d..7162dba 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java
@@ -38,8 +38,8 @@ import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.Viewer;
@@ -90,22 +90,6 @@ import org.eclipse.ui.model.WorkbenchLabelProvider;
*/
public class CommitDialog extends Dialog {
- class CommitContentProvider implements IStructuredContentProvider {
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // Empty
- }
-
- public void dispose() {
- // Empty
- }
-
- public Object[] getElements(Object inputElement) {
- return items.toArray();
- }
-
- }
-
static class CommitLabelProvider extends WorkbenchLabelProvider implements
ITableLabelProvider {
public String getColumnText(Object obj, int columnIndex) {
@@ -397,7 +381,7 @@ public class CommitDialog extends Dialog {
resourceCol.addSelectionListener(new HeaderSelectionListener(CommitItem.Order.ByFile));
filesViewer = new CheckboxTableViewer(resourcesTable);
- filesViewer.setContentProvider(new CommitContentProvider());
+ filesViewer.setContentProvider(ArrayContentProvider.getInstance());
filesViewer.setLabelProvider(new CommitLabelProvider());
filesViewer.addFilter(new CommitItemFilter());
filesViewer.setInput(items);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitDecoratorPreferencePage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitDecoratorPreferencePage.java
index 43007c0..0dcfb44 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitDecoratorPreferencePage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitDecoratorPreferencePage.java
@@ -40,6 +40,7 @@ import org.eclipse.jface.resource.LocalResourceManager;
import org.eclipse.jface.resource.ResourceManager;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.DecorationContext;
import org.eclipse.jface.viewers.DecorationOverlayIcon;
import org.eclipse.jface.viewers.IDecoration;
@@ -447,20 +448,7 @@ public class GitDecoratorPreferencePage extends PreferencePage implements
}
};
- final IStructuredContentProvider contentsProvider = new IStructuredContentProvider() {
- public Object[] getElements(Object inputElement) {
- return ((Collection) inputElement).toArray();
- }
-
- public void dispose() {
- // No-op
- }
-
- public void inputChanged(Viewer viewer, Object oldInput,
- Object newInput) {
- // No-op
- }
- };
+ final IStructuredContentProvider contentsProvider = ArrayContentProvider.getInstance();
final ListSelectionDialog dialog = new ListSelectionDialog(text
.getShell(), bindings.entrySet(), contentsProvider,
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/ConfigureKeysDialog.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/ConfigureKeysDialog.java
index 9cd71b4..011690d 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/ConfigureKeysDialog.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/ConfigureKeysDialog.java
@@ -19,13 +19,12 @@ import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.BaseLabelProvider;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.window.Window;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
@@ -44,23 +43,6 @@ import org.eclipse.swt.widgets.ToolItem;
*/
class ConfigureKeysDialog extends Dialog {
- private static final class ContentProvider implements
- IStructuredContentProvider {
-
- public Object[] getElements(Object inputElement) {
- return ((List) inputElement).toArray();
- }
-
- public void dispose() {
- // nothing
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // nothing
- }
-
- }
-
private static final class LabelProvider extends BaseLabelProvider
implements ITableLabelProvider {
@@ -202,7 +184,7 @@ class ConfigureKeysDialog extends Dialog {
});
tv.setLabelProvider(new LabelProvider());
- tv.setContentProvider(new ContentProvider());
+ tv.setContentProvider(ArrayContentProvider.getInstance());
tv.setInput(this.activeKeys);
applyDialogFont(main);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/ConfigureUriPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/ConfigureUriPage.java
index 61ab2bf..e33c596 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/ConfigureUriPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/ConfigureUriPage.java
@@ -17,14 +17,13 @@ import java.util.List;
import org.eclipse.egit.ui.UIText;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.BaseLabelProvider;
import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jface.wizard.WizardPage;
@@ -135,7 +134,7 @@ public class ConfigureUriPage extends WizardPage {
tv.getTable());
tv.setLabelProvider(new LabelProvider());
- tv.setContentProvider(new ContentProvider());
+ tv.setContentProvider(ArrayContentProvider.getInstance());
ToolBar tb = new ToolBar(main, SWT.HORIZONTAL);
ToolItem add = new ToolItem(tb, SWT.PUSH);
@@ -227,23 +226,6 @@ public class ConfigureUriPage extends WizardPage {
}
}
- private static final class ContentProvider implements
- IStructuredContentProvider {
-
- public Object[] getElements(Object inputElement) {
- return ((List) inputElement).toArray();
- }
-
- public void dispose() {
- // nothing
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // nothing
- }
-
- }
-
private static final class LabelProvider extends BaseLabelProvider
implements ITableLabelProvider {