Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'examples/org.eclipse.jface.snippets/Eclipse JFace Snippets/org/eclipse/jface/snippets/layout/Snippet016TableLayout.java')
-rwxr-xr-xexamples/org.eclipse.jface.snippets/Eclipse JFace Snippets/org/eclipse/jface/snippets/layout/Snippet016TableLayout.java53
1 files changed, 23 insertions, 30 deletions
diff --git a/examples/org.eclipse.jface.snippets/Eclipse JFace Snippets/org/eclipse/jface/snippets/layout/Snippet016TableLayout.java b/examples/org.eclipse.jface.snippets/Eclipse JFace Snippets/org/eclipse/jface/snippets/layout/Snippet016TableLayout.java
index 9be6c210bb2..d1d90e785f1 100755
--- a/examples/org.eclipse.jface.snippets/Eclipse JFace Snippets/org/eclipse/jface/snippets/layout/Snippet016TableLayout.java
+++ b/examples/org.eclipse.jface.snippets/Eclipse JFace Snippets/org/eclipse/jface/snippets/layout/Snippet016TableLayout.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2007 Tom Schindl and others.
+ * Copyright (c) 2006, 2014 Tom Schindl 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
@@ -7,11 +7,11 @@
*
* Contributors:
* Tom Schindl - initial API and implementation
+ * Jeanderson Candido <http://jeandersonbc.github.io> - Bug 414565
*******************************************************************************/
package org.eclipse.jface.snippets.layout;
-
import org.eclipse.jface.layout.TableColumnLayout;
import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.IStructuredContentProvider;
@@ -30,37 +30,24 @@ import org.eclipse.swt.widgets.TableColumn;
/**
* A simple TableViewer to demonstrate usage
- *
+ *
* @author Tom Schindl <tom.schindl@bestsolution.at>
* @since 3.3M3
*/
public class Snippet016TableLayout {
private class MyContentProvider implements IStructuredContentProvider {
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
- */
+ @Override
public Object[] getElements(Object inputElement) {
return (MyModel[]) inputElement;
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- */
+ @Override
public void dispose() {
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
- * java.lang.Object, java.lang.Object)
- */
+ @Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
@@ -70,10 +57,12 @@ public class Snippet016TableLayout {
private class MyLabelProvider extends LabelProvider implements
ITableLabelProvider {
+ @Override
public Image getColumnImage(Object element, int columnIndex) {
return null;
}
+ @Override
public String getColumnText(Object element, int columnIndex) {
return columnIndex + " - " + element;
}
@@ -87,6 +76,7 @@ public class Snippet016TableLayout {
this.counter = counter;
}
+ @Override
public String toString() {
return "Item " + this.counter;
}
@@ -100,22 +90,25 @@ public class Snippet016TableLayout {
TableColumnLayout ad = new TableColumnLayout();
comp.setLayout(ad);
-
- TableColumn column = new TableColumn(v.getTable(), SWT.NONE);
- column.setText("Column 1");
- column.setMoveable(true);
- ad.setColumnData(column, new ColumnWeightData(90, 290));
- column = new TableColumn(v.getTable(), SWT.NONE);
- column.setText("Column 2");
- column.setMoveable(true);
- ad.setColumnData(column, new ColumnWeightData(10, 200));
+ TableColumn column1 = createTableColumn(v.getTable(), "Column 1");
+ TableColumn column2 = createTableColumn(v.getTable(), "Column 2");
+
+ ad.setColumnData(column1, new ColumnWeightData(90, 290));
+ ad.setColumnData(column2, new ColumnWeightData(10, 200));
MyModel[] model = createModel();
v.setInput(model);
v.getTable().setLinesVisible(true);
}
+ private TableColumn createTableColumn(Table table, String textColumn) {
+ TableColumn column = new TableColumn(table, SWT.NONE);
+ column.setText(textColumn);
+ column.setMoveable(true);
+ return column;
+ }
+
private MyModel[] createModel() {
MyModel[] elements = new MyModel[10];
@@ -132,9 +125,9 @@ public class Snippet016TableLayout {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
- //shell.setSize(400, 150);
+ // shell.setSize(400, 150);
shell.setLayout(new FillLayout());
-
+
new Snippet016TableLayout(shell);
shell.open();

Back to the top