Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » Problems with a TableView - it's not showing...(... and not refreshing.)
Problems with a TableView - it's not showing... [message #662131] Tue, 29 March 2011 13:13 Go to next message
akoeck is currently offline akoeckFriend
Messages: 62
Registered: December 2010
Member
Hi in my Plug-In i want to use a TableViewer to show the content of a selected Table. Therefore I have created a View with a TableViewer inside.

But the View ist not showing, although I have added it to my perspective.

The provided area remains empty. I could add the view via the Open View Menu, but then the view is not showing the content of my tables. I also got the problem, how can I handle this if have no selected element, so that I create an empty table. This is the code of my view.

public class TableView extends ViewPart {
	
	private TableViewer tableViewer;
	private Table table;
	private ITableData tableData;

	/**
	 * 
	 */
	public TableView() {
		super();
	}
	
	/* (non-Javadoc)
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
	 */
	@Override
	public void createPartControl(Composite parent) {
		GridLayout layout = new GridLayout(2, false);
			parent.setLayout(layout);
			createViewer(parent);
	}
	
	
	/* (non-Javadoc)
	 * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
	 */
	@Override
	public void setFocus() {
		tableViewer.getControl().setFocus();
	}
	
	/**
	 * 
	 * @param model
	 */
	public void setModel(Table model){
		table = model;
	}
	
	
	private void createViewer(Composite parent){
		tableViewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL 
				| SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
		tableViewer.getTable().setHeaderVisible(true);
		tableViewer.getTable().setLinesVisible(true);
		tableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
		
		tableViewer.setLabelProvider(new TableDataLabelProvider());
		tableViewer.setContentProvider(new TableDataContentProvider());
		
		try {
			tableData = new TableDataImpl(table);
			configureTable();
			tableViewer.setInput(tableData);
		} catch (Exception e) {
			String title = Messages.getString(
					"TableDataEditor.ErrorInitializingEditor");
			IStatus error = new Status(IStatus.ERROR, DataUIPlugin.PLUGIN_ID,
					1, e.toString(), e);
			ErrorDialog.openError(PlatformUI.getWorkbench().getDisplay()
					.getActiveShell(), title, null, error);
			e.printStackTrace();
		}
		
	}
	
	
	private void configureTable(){
		for(int i=0; i<tableData.getColumnCount(); ++i){
			final TableViewerColumn viewerColumn = 
				new TableViewerColumn(tableViewer,SWT.NONE);
			final TableColumn column = viewerColumn.getColumn();
			column.setText(tableData.getColumnHeader(i));
			column.setWidth(100);
			column.setResizable(true);
			column.pack();
		}
		
		tableViewer.getTable().pack();
	}

}


I hope you can help me.
Re: Problems with a TableView - it's not showing... [message #662141 is a reply to message #662131] Tue, 29 March 2011 13:51 Go to previous messageGo to next message
Daniel Krügler is currently offline Daniel KrüglerFriend
Messages: 853
Registered: July 2009
Senior Member
On 2011-03-29 15:13, akoeck@gmx.de wrote:
> Hi in my Plug-In i want to use a TableViewer to show the content of a
> selected Table. Therefore I have created a View with a TableViewer inside.
>
> But the View ist not showing, although I have added it to my perspective.
>
> The provided area remains empty. I could add the view via the Open View
> Menu, but then the view is not showing the content of my tables. I also
> got the problem, how can I handle this if have no selected element, so
> that I create an empty table. This is the code of my view.
>
>
> public class TableView extends ViewPart {
>
> private TableViewer tableViewer;
> private Table table;
> private ITableData tableData;
>
> /**
> * */
> public TableView() {
> super();
> }
>
> /* (non-Javadoc)
> * @see
> org.eclipse.ui.part.WorkbenchPart#createPartControl(org.ecli pse.swt.widgets.Composite)
>
> */
> @Override
> public void createPartControl(Composite parent) {
> GridLayout layout = new GridLayout(2, false);
> parent.setLayout(layout);
> createViewer(parent);
> }
>
>
> /* (non-Javadoc)
> * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
> */
> @Override
> public void setFocus() {
> tableViewer.getControl().setFocus();
> }
>
> /**
> * * @param model
> */
> public void setModel(Table model){
> table = model;
> }
>
>
> private void createViewer(Composite parent){
> tableViewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL |
> SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
> tableViewer.getTable().setHeaderVisible(true);
> tableViewer.getTable().setLinesVisible(true);
> tableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
>
> tableViewer.setLabelProvider(new TableDataLabelProvider());
> tableViewer.setContentProvider(new TableDataContentProvider());
>
> try {
> tableData = new TableDataImpl(table);
> configureTable();
> tableViewer.setInput(tableData);
> } catch (Exception e) {
> String title = Messages.getString(
> "TableDataEditor.ErrorInitializingEditor");
> IStatus error = new Status(IStatus.ERROR, DataUIPlugin.PLUGIN_ID,
> 1, e.toString(), e);
> ErrorDialog.openError(PlatformUI.getWorkbench().getDisplay()
> .getActiveShell(), title, null, error);
> e.printStackTrace();
> }
>
> }
>
>
> private void configureTable(){
> for(int i=0; i<tableData.getColumnCount(); ++i){
> final TableViewerColumn viewerColumn = new
> TableViewerColumn(tableViewer,SWT.NONE);
> final TableColumn column = viewerColumn.getColumn();
> column.setText(tableData.getColumnHeader(i));
> column.setWidth(100);
> column.setResizable(true);
> column.pack();
> }
>
> tableViewer.getTable().pack();
> }
>
> }
>
>
> I hope you can help me.

Apply a proper layout to the table widget. For reference how to do this
check SWT snippets (for tables) and jfaces snippets (for table viewers).

HTH & Greetings from Bremen,

Daniel Krügler
Re: Problems with a TableView - it's not showing... [message #662305 is a reply to message #662141] Wed, 30 March 2011 08:23 Go to previous message
akoeck is currently offline akoeckFriend
Messages: 62
Registered: December 2010
Member
Ok, I think there is somehow a Problem with my Perspective. I have created this perspective for my Plug-In but even when I use the PropertyPage or another View it's not showing in the bottom area.
public class PerspectiveFactory implements IPerspectiveFactory {

	/* (non-Javadoc)
	 * @see org.eclipse.ui.IPerspectiveFactory#createInitialLayout(org.eclipse.ui.IPageLayout)
	 */
	@Override
	public void createInitialLayout(IPageLayout layout) {
		String editorArea = layout.getEditorArea();
		
		layout.setEditorAreaVisible(true);
		
		IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT,
				0.25f, editorArea);
		IFolderLayout bottom_left = layout.createFolder("bottomright",
				IPageLayout.BOTTOM, 0.25f, "left");
		IFolderLayout bottom = layout.createFolder("bottom",
				IPageLayout.BOTTOM, 0.5f, editorArea);
		
		left.addView("org.eclipse.ui.navigator.ProjectExplorer");
		bottom_left.addView("org.eclipse.datatools.connectivity." +
				"DataSourceExplorerNavigator");
		bottom.addView(TableView.ID);
	}

}

Previous Topic:Missing baseline error
Next Topic:read a file from inside the plugin jar.
Goto Forum:
  


Current Time: Wed Apr 24 17:26:24 GMT 2024

Powered by FUDForum. Page generated in 0.03342 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top