TableViewer füllen

tormartin

Grünschnabel
Hallo, habe folgendes Problem:
Habe mir einen TableViewer gebaut. Allerdings bekomme ich es nicht hin, ihn mit Daten zu füllen.
Gibt es jemanden der mir helfen kann?
Vielen Dank schon mal

Mein ContentProvider


package org.eclipse.promavo.ui.views;

import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableItem;

public class PromavoContentProvider implements IStructuredContentProvider {


public Object[] getElements(Object inputelement) {

return ((Results)inputelement).getResults();
}
public void dispose() {
// TODO Auto-generated method stub

}

public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
// TODO Auto-generated method stub

}

}


Mein LabelProvider


package org.eclipse.promavo.ui.views;

import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.swt.graphics.Image;

public class PromavoLabelProvider implements ITableLabelProvider {

public Image getColumnImage(Object element, int columnIndex) {
// TODO Auto-generated method stub
return null;
}

public String getColumnText(Object element, int index) {
// TODO Auto-generated method stub
ResultView result = (ResultView) element;

switch (index) {
case 0:
System.out.println("LabelProvider");
return result.toString();
case 1:
System.out.println("LabelProvider");
return result.toString();
case 2:
System.out.println("LabelProvider");
return result.toString();
}
return "";
}

public void addListener(ILabelProviderListener listener) {
// TODO Auto-generated method stub

}

public void dispose() {
// TODO Auto-generated method stub

}

public boolean isLabelProperty(Object element, String property) {
// TODO Auto-generated method stub
return false;
}

public void removeListener(ILabelProviderListener listener) {
// TODO Auto-generated method stub

}

}


package org.eclipse.promavo.ui.views;

import org.eclipse.jface.dialogs.MessageDialog;

import org.eclipse.jface.viewers.TableViewer;

import org.eclipse.promavo.ui.handlers.AutomatedChangeListener;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;

import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;

import org.eclipse.swt.widgets.TableItem;

import org.eclipse.ui.part.ViewPart;


public class SoftInventView extends ViewPart
{

private TableViewer viewer;

private AutomatedChangeListener listener;

private PromavoLabelProvider labelprovider;

private PromavoContentProvider contentprovider;

private Table table;

private ResultView result;


public SoftInventView()
{

result = new ResultView("Srt","Srtin","ser");

}


public void createPartControl(Composite parent)
{
table = new Table(parent, SWT.SINGLE | SWT.H_SCROLL

| SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);

table.setHeaderVisible(true);

table.setLinesVisible(true);

TableColumn c = new TableColumn(table, SWT.NONE, 0);

c.setText("File");

c.setWidth(100);

c = new TableColumn(table, SWT.NONE, 1);

c.setText("Project");

c.setWidth(100);

c = new TableColumn(table, SWT.None, 2);

c.setText("Pfad");

c.setWidth(100);

viewer = new TableViewer(table);

labelprovider = new PromavoLabelProvider();

contentprovider = new PromavoContentProvider();

viewer.setContentProvider(contentprovider);

viewer.setInput(result);

viewer.setLabelProvider(labelprovider);

}


private void showMessage(String message)
{

MessageDialog.openInformation(viewer.getControl().getShell(),

"SoftInvent View", message);
}



public void setFocus() {

viewer.getControl().setFocus();

}

public void setInput(String results) {



}

}


package org.eclipse.promavo.ui.views;

public class ResultView {

public String fFile;
public String fProject;
public String fPath;

public ResultView (String File, String Project, String Path)
{
fFile = File;
fProject = Project;
fPath = Path;
}

public String getFile()
{
return fFile;
}

public String getProject()
{
return fPath;
}

public String getPath()
{
return fPath;
}
}


package org.eclipse.promavo.ui.views;

import java.util.ArrayList;
import java.util.List;

public class Results {


public Object[] getResults()
{
System.out.println("Results erreicht");
return list.toArray();
}
private final ArrayList<ResultView> list = new ArrayList<ResultView>();

}
 
Zurück