Java Code Examples for org.eclipse.swt.widgets.Table

The following are top voted examples for showing how to use org.eclipse.swt.widgets.Table. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: n4js   File: TableViewerBuilder.java   View source code 6 votes vote down vote up
@Override
protected TableViewer createViewer(final Composite parent, final AbstractColumnLayout columnLayout, final int style) {
	final TableViewer viewer = new TableViewer(parent, style);
	final Table table = viewer.getTable();
	table.setLinesVisible(linesVisible);
	table.setHeaderVisible(headerVisible);

	int columnIndex = 0;
	for (final String columnLabel : columnLabels) {

		final TableViewerColumn viewerColumn = new TableViewerColumn(viewer, NONE);
		final TableColumn column = viewerColumn.getColumn();
		columnLayout.setColumnData(column, createColumnLayoutData(columnIndex));
		column.setText(columnLabel);
		column.setMoveable(moveable);

		columnIndex++;
	}

	return viewer;
}
 
Example 2
Project: eZooKeeper   File: DataModelFormPage.java   View source code 6 votes vote down vote up
protected Section createTableSection(ScrolledForm form, Composite client, FormToolkit toolkit, String title,
        Image image, int sectionStyle, int tableStyle, String[] columnTitles, int[] columnAlignments) {

    Section section = createSection(form, client, toolkit, title, image, sectionStyle);
    Table table = toolkit.createTable(section, tableStyle);

    for (int i = 0; i < columnTitles.length; i++) {
        TableColumn column = new TableColumn(table, SWT.NONE);
        column.setText(columnTitles[i]);
        column.setAlignment(columnAlignments[i]);
    }

    table.setHeaderVisible(true);
    table.setLinesVisible(true);

    section.setClient(table);

    return section;
}
 
Example 3
Project: Hydrograph   File: FindViewDataDialog.java   View source code 6 votes vote down vote up
private void selectAllInTable(TableViewer debugDataViewer, TableCursor tableCursor){
	Table table = debugDataViewer.getTable();
	TableItem[] tableItems = table.getItems();
	int recordCount = 0;
	
	for(int rowIndex = 0; rowIndex < tableItems.length; rowIndex++){
		TableItem tableItem = tableItems[rowIndex];
		for(int colIndex = 1; colIndex <= table.getColumnCount(); colIndex++){
			if(StringUtils.containsIgnoreCase(tableItem.getText(colIndex), findText.getText())){
				label.setVisible(false);
				tableItem.setBackground(colIndex, Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY));
				recordCount++;
			}
		}
		findColIndex=1;
	}
	
	findRowIndex = 0;
	findColIndex = 0;
	
	if(recordCount > 0){
		label.setVisible(true);
		label.setText("Match count - " + recordCount);
	}else{ label.setVisible(false); }
	
}
 
Example 4
Project: eZooKeeper   File: BaseElementType.java   View source code 6 votes vote down vote up
@Override
public void packTable(Table table) {
    table.pack();

    TableColumn[] columns = table.getColumns();
    int[] columnWidths = getColumnWidths();
    for (int i = 0; i < columns.length; i++) {

        int columnWidth = columnWidths[i];
        if (columnWidth == SWT.DEFAULT) {
            columns[i].pack();
        }
        else {
            columns[i].setWidth(columnWidth);
        }
    }
}
 
Example 5
Project: eZooKeeper   File: ZnodeAclComposite.java   View source code 6 votes vote down vote up
private void fixLayout() {

        Table table = getTable();

        // HACK to get the removed item to disappear.
        table.pack();
        layout(true);

        int[] columnWidths = TABLE_COLUMN_WIDTHS;
        TableColumn[] columns = table.getColumns();
        for (int i = 0; i < columns.length; i++) {

            if (columnWidths == null) {
                columns[i].pack();
            }
            else {
                int columnWidth = columnWidths[i];
                if (columnWidth == SWT.DEFAULT) {
                    columns[i].pack();
                }
                else {
                    columns[i].setWidth(columnWidth);
                }
            }
        }
    }
 
Example 6
Project: Hydrograph   File: GenerateRecordsGridWidgetBuilder.java   View source code 6 votes vote down vote up
@Override
public CellEditor[] createCellEditorList(Table table,
		Map<String, Integer> columns) {
	CellEditor[] cellEditor = createCellEditor(columns.size());
	addTextEditor(table, cellEditor, columns, (Messages.FIELDNAME));
	addComboBox(table, cellEditor, getDataTypeKey(), 1);
	addTextEditor(table, cellEditor, columns, Messages.DATEFORMAT);
	addTextEditor(table, cellEditor, columns, Messages.PRECISION);
	addTextEditor(table, cellEditor, columns, Messages.SCALE);
	addComboBox(table, cellEditor, getScaleTypeKey(), 5);
	addTextEditor(table, cellEditor, columns, Messages.FIELD_DESCRIPTION);
	addTextEditor(table, cellEditor, columns, Messages.LENGTH);
	addTextEditor(table, cellEditor, columns, Messages.RANGE_FROM);
	addTextEditor(table, cellEditor, columns, Messages.RANGE_TO);
	addTextEditor(table, cellEditor, columns, Messages.DEFAULT_VALUE);
	return cellEditor;
}
 
Example 7
Project: eZooKeeper   File: ZooKeeperConnectionModelMainFormPage.java   View source code 6 votes vote down vote up
@Override
protected void createModelFormContent(IManagedForm managedForm, Composite client) {
    final ScrolledForm form = managedForm.getForm();
    FormToolkit toolkit = managedForm.getToolkit();

    _EditSection = createEditSection(form, client, toolkit);
    GridData editSectionGridData = new GridData(GridData.FILL_HORIZONTAL);
    _EditSection.setLayoutData(editSectionGridData);

    _PropertiesSection = createPropertiesTableSection(form, client, toolkit);
    GridData propertiesSectionGridData = new GridData(GridData.FILL_HORIZONTAL);
    _PropertiesSection.setLayoutData(propertiesSectionGridData);

    _ZnodeSection = createZnodeSection(form, client, toolkit);
    GridData znodeSectionGridData = new GridData(GridData.FILL_HORIZONTAL);
    _ZnodeSection.setLayoutData(znodeSectionGridData);

    Table propertiesSectionTable = getPropertiesSectionTable();
    initTableEdit(propertiesSectionTable, null, 1);
}
 
Example 8
Project: eZooKeeper   File: BaseZnodeModelTableFormPage.java   View source code 6 votes vote down vote up
protected void createTableColumns() {
    Table table = getTable();
    if (table == null) {
        return;
    }

    String[] titles = getTableColumnTitles();
    if (titles != null && titles.length > 0) {

        int[] columnAlignments = getTableColumnAlignments();

        for (int i = 0; i < titles.length; i++) {
            TableColumn column = new TableColumn(table, SWT.NONE);
            column.setText(titles[i]);

            if (columnAlignments != null) {
                column.setAlignment(columnAlignments[i]);
            }
        }

        table.setHeaderVisible(true);
    }
}
 
Example 9
Project: eZooKeeper   File: JmxConnectionModelMainFormPage.java   View source code 6 votes vote down vote up
@Override
protected void createModelFormContent(IManagedForm managedForm, Composite client) {
    final ScrolledForm form = managedForm.getForm();
    FormToolkit toolkit = managedForm.getToolkit();

    _EditSection = createEditSection(form, client, toolkit);
    GridData editSectionGridData = new GridData(GridData.FILL_HORIZONTAL);
    _EditSection.setLayoutData(editSectionGridData);

    _PropertiesSection = createPropertiesTableSection(form, client, toolkit);
    GridData propertiesSectionGridData = new GridData(GridData.FILL_HORIZONTAL);
    _PropertiesSection.setLayoutData(propertiesSectionGridData);

    Table propertiesSectionTable = getPropertiesSectionTable();
    initTableEdit(propertiesSectionTable, null, 1);
}
 
Example 10
Project: Hydrograph   File: LookupMapDialog.java   View source code 6 votes vote down vote up
private void moveRowUp()
{
	Table table = mappingTableViewer.getTable();
	setValueForCellEditor();
	int[] indexes = table.getSelectionIndices();
	for (int index : indexes) {

		if (index > 0) {
			Collections.swap(
					(List<LookupMapProperty>) mappingTableItemList,
					index, index - 1);
			mappingTableViewer.refresh();
		}
	}
	refreshButtonStatus();

}
 
Example 11
Project: eZooKeeper   File: JmxConnectionModelMainFormPage.java   View source code 6 votes vote down vote up
/**
 * TODO: Comment.
 * 
 */
protected void initPropertiesSectionFromModel() {

    Table table = getPropertiesSectionTable();
    table.removeAll();

    Map<String, String> properties = getZooKeeperConnectionProperties();

    for (String key : properties.keySet()) {
        TableItem item = new TableItem(table, SWT.NONE);
        String value = properties.get(key);
        item.setText(0, key);
        item.setText(1, value);
    }

    packTable(table, PROPERTIES_COLUMN_WIDTHS);

}
 
Example 12
Project: eZooKeeper   File: BaseJmxModelMainFormPage.java   View source code 6 votes vote down vote up
protected void initDescriptorSectionFromModel() {

        Descriptor descriptor = getJmxDescriptor();
        if (descriptor == null) {
            return;
        }

        Table table = getDescriptorTable();
        if (table == null) {
            return;
        }

        table.removeAll();

        for (String fieldName : descriptor.getFieldNames()) {
            TableItem item = new TableItem(table, SWT.NONE);
            Object value = descriptor.getFieldValue(fieldName);
            item.setText(0, fieldName);
            item.setText(1, String.valueOf(value));
        }

        packTable(table, DEFAULT_NAME_VALUE_COLUMN_WIDTHS);
    }
 
Example 13
Project: Hydrograph   File: ELTGridAddSelectionListener.java   View source code 6 votes vote down vote up
@Override
public void selectionListenerAction(PropertyDialogButtonBar propertyDialogButtonBar, ListenerHelper helpers, Widget... widgets) {
	propertyDialogButtonBar.enableApplyButton(true);
	table=(Table)widgets[0];
	table.getParent().getShell().setFocus();
	((Button) widgets[1]).setEnabled(true);
	ELTGridDetails eltGridDetails = (ELTGridDetails)helpers.get(HelperType.SCHEMA_GRID);
	if (eltGridDetails.getGrids().size() >= 1) {
		((Button) widgets[2]).setEnabled(true);
		((Button) widgets[3]).setEnabled(true);
	}
	GridWidgetCommonBuilder gridCommonBuilder = eltGridDetails.getGridWidgetCommonBuilder();
	gridCommonBuilder.setRowSequence(rowSequence);
	gridCommonBuilder.createDefaultSchema(eltGridDetails.getGrids(), eltGridDetails.getTableViewer(), eltGridDetails.getLabel());
	rowSequence++;
	((Component)helpers.get(HelperType.COMPONENT)).setLatestChangesInSchema(true);
}
 
Example 14
Project: eZooKeeper   File: MBeanFeatureModeMainFormPage.java   View source code 6 votes vote down vote up
@Override
protected void initInfoSectionFromModel() {

    Table table = getInfoTable();
    table.removeAll();

    MBeanFeatureInfo featureInfo = getFeatureInfo();

    TableItem nameItem = new TableItem(table, SWT.NONE);
    nameItem.setText(0, FEATURE_INFO_PROPERTY_NAME_NAME);
    nameItem.setText(1, featureInfo.getName());

    TableItem descriptionItem = new TableItem(table, SWT.NONE);
    descriptionItem.setText(0, FEATURE_INFO_PROPERTY_NAME_DESCRIPTION);
    descriptionItem.setText(1, featureInfo.getDescription());
}
 
Example 15
Project: Hydrograph   File: ELTTransformDeleteSelectionListener.java   View source code 6 votes vote down vote up
@Override
	public void selectionListenerAction(
			PropertyDialogButtonBar propertyDialogButtonBar,
			ListenerHelper helpers, Widget... widgets) {

		ELTGridDetails gridDetails = (ELTGridDetails) helpers.get(HelperType.SCHEMA_GRID);
		Table table =gridDetails.getTableViewer().getTable();
		int temp = table.getSelectionIndex();
		int[] indexs=table.getSelectionIndices();
		if (temp == -1) {
			WidgetUtility.errorMessage("Please Select row to delete");
		} else {
			table.remove(indexs);
			ArrayList tempList= new ArrayList();
			for (int index :indexs) { 
//				PropertyField test =(PropertyField) gridDetails.getGrids().get(index);
//				tempList.add(test);
			}
			 gridDetails.getGrids().removeAll(tempList); 
			
		}		
	}
 
Example 16
Project: neoscada   File: EventViewTable.java   View source code 6 votes vote down vote up
@Override
public void widgetSelected ( final SelectionEvent e )
{
    final Table table = this.tableViewer.getTable ();
    final TableColumn newColumn = (TableColumn)e.widget;
    final TableColumn currentColumn = table.getSortColumn ();

    final EventTableColumn column = (EventTableColumn)newColumn.getData ( COLUMN_KEY );
    if ( column == EventTableColumn.reservedColumnSourceTimestamp || column == EventTableColumn.reservedColumnEntryTimestamp )
    {
        final int currentDir = table.getSortDirection ();
        int newDir = SWT.UP;
        if ( newColumn == currentColumn )
        {
            newDir = currentDir == SWT.UP ? SWT.DOWN : SWT.UP;
        }
        else
        {
            table.setSortColumn ( newColumn );
        }
        table.setSortDirection ( newDir );
        this.tableViewer.setSorter ( new EventTableSorter ( column, newDir ) );
    }
}
 
Example 17
Project: neoscada   File: QueryDataView.java   View source code 6 votes vote down vote up
@Override
public void createPartControl ( final Composite parent )
{
    addListener ();

    parent.setLayout ( new FillLayout () );
    this.table = new Table ( parent, SWT.FULL_SELECTION );
    this.table.setHeaderVisible ( true );

    this.indexCol = new TableColumn ( this.table, SWT.NONE );
    this.indexCol.setText ( Messages.QueryDataView_ColIndex );
    this.indexCol.setWidth ( 50 );

    this.qualityCol = new TableColumn ( this.table, SWT.NONE );
    this.qualityCol.setText ( Messages.QueryDataView_ColQuality );
    this.qualityCol.setWidth ( 75 );

    this.manualCol = new TableColumn ( this.table, SWT.NONE );
    this.manualCol.setText ( Messages.QueryDataView_ColManual );
    this.manualCol.setWidth ( 75 );

    this.invalidColor = JFaceColors.getErrorBackground ( getDisplay () );
}
 
Example 18
Project: neoscada   File: SecurityEditor.java   View source code 6 votes vote down vote up
protected void createColumns ( final Table table )
{
    final TableColumn typeFilterColumn = new TableColumn ( table, SWT.NONE );
    typeFilterColumn.setText ( getString ( "_UI_TypeFilterColumn_label" ) ); //$NON-NLS-1$
    typeFilterColumn.setResizable ( true );
    typeFilterColumn.setWidth ( 200 );

    final TableColumn idFilterColumn = new TableColumn ( table, SWT.NONE );
    idFilterColumn.setText ( getString ( "_UI_IdFilterColumn_label" ) ); //$NON-NLS-1$
    idFilterColumn.setResizable ( true );
    idFilterColumn.setWidth ( 200 );

    final TableColumn actionFilterColumn = new TableColumn ( table, SWT.NONE );
    actionFilterColumn.setText ( getString ( "_UI_ActionFilterColumn_label" ) ); //$NON-NLS-1$
    actionFilterColumn.setResizable ( true );
    actionFilterColumn.setWidth ( 200 );
}
 
Example 19
Project: Hydrograph   File: JoinMapDialog.java   View source code 6 votes vote down vote up
private void moveRowDown(){

		Table table = mappingTableViewer.getTable();
		setValueForCellEditor();
		int[] indexes = table.getSelectionIndices();
		for (int i = indexes.length - 1; i > -1; i--) {

			if (indexes[i] < mappingTableItemList.size() - 1) {
				Collections.swap(
						(List<LookupMapProperty>) mappingTableItemList,
						indexes[i], indexes[i] + 1);
				mappingTableViewer.refresh();

			}
		}
		refreshButtonStatus();
	
	}
 
Example 20
Project: Hydrograph   File: ELTSWTWidgets.java   View source code 6 votes vote down vote up
public void applyDragFromTableViewer(Control sourceControl, int index) {
	Transfer[] types = new Transfer[] { TextTransfer.getInstance() };
	final String portLabel = "in" + index + ".";
	int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
	final Table table = (Table) sourceControl;
	DragSource source = new DragSource(table, operations);
	source.setTransfer(types);
	final String[] columnData = new String[1];
	source.addDragListener(new DragSourceAdapter() {
		public void dragSetData(DragSourceEvent event) {
			// Set the data to be the first selected item's text
			event.data = addDelimeter(portLabel, table.getSelection());
		}
	});

}
 
Example 21
Project: n4js   File: InterfacesComponentProvider.java   View source code 5 votes vote down vote up
/**
 * Creates a new interfaces component inside the parent composite using the given model.
 *
 * @param interfacesContainingModel
 *            A interface containing model
 * @param container
 *            The component container
 */
public InterfacesComponent(InterfacesContainingModel interfacesContainingModel,
		WizardComponentContainer container) {
	super(container);
	this.model = interfacesContainingModel;

	Composite parent = getParentComposite();

	Label interfacesLabel = new Label(parent, SWT.NONE);

	GridData interfacesLabelGridData = fillLabelDefaults();
	interfacesLabelGridData.verticalAlignment = SWT.TOP;
	interfacesLabel.setLayoutData(interfacesLabelGridData);

	interfacesLabel.setText("Interfaces:");

	interfacesTable = new Table(parent, SWT.BORDER | SWT.FULL_SELECTION | SWT.VIRTUAL);
	interfacesTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

	Composite interfacesButtonsComposite = new Composite(parent, SWT.NONE);
	interfacesButtonsComposite.setLayoutData(GridDataFactory.fillDefaults().create());

	interfacesButtonsComposite.setLayout(GridLayoutFactory.swtDefaults().numColumns(1).margins(0, 0).create());

	interfacesAddButton = new Button(interfacesButtonsComposite, SWT.NONE);
	interfacesAddButton.setText("Add...");
	interfacesAddButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());

	interfacesRemoveButton = new Button(interfacesButtonsComposite, SWT.NONE);
	interfacesRemoveButton.setText("Remove");
	interfacesRemoveButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());

	setupBindings();
}
 
Example 22
Project: Hydrograph   File: ELTOperationClassDialog.java   View source code 5 votes vote down vote up
public static void createTableColumns(Table table, String[] fields) {
	for (String field : fields) {
		TableColumn tableColumn = new TableColumn(table, SWT.FILL);
		tableColumn.setText(field);

		tableColumn.setWidth(100);
		tableColumn.pack();
	}
	table.setHeaderVisible(true);
	table.setLinesVisible(true);
}
 
Example 23
Project: Hydrograph   File: ELTOperationClassDialog.java   View source code 5 votes vote down vote up
private void moveRowDown(TableViewer nameValueTableViewer){

		Table table = nameValueTableViewer.getTable();
		int[] indexes = table.getSelectionIndices();
		for (int i = indexes.length - 1; i > -1; i--) {

			if (indexes[i] < operationClassProperty.getNameValuePropertyList().size() - 1) {
				Collections.swap(operationClassProperty.getNameValuePropertyList(), indexes[i], indexes[i] + 1);
				nameValueTableViewer.refresh();
				applyButton.setEnabled(true);

			}
		}
	}
 
Example 24
Project: eZooKeeper   File: DataModelTableFormPage.java   View source code 5 votes vote down vote up
@Override
protected void createModelFormContent(IManagedForm managedForm, Composite client) {

    Table table = createTable(client);
    configureTable(table);
    table.setLayoutData(getTableFormData());

    _TableViewer = createTableViewer(table);
}
 
Example 25
Project: Hydrograph   File: GeneralGridWidgetBuilder.java   View source code 5 votes vote down vote up
@Override
public CellEditor[] createCellEditorList(Table table,
		Map<String, Integer> columns) {
	CellEditor[] cellEditor = createCellEditor(columns.size());
	addTextEditor(table,cellEditor, columns, (Messages.FIELDNAME));
	addComboBox(table, cellEditor, getDataTypeKey(), columns.get(Messages.DATATYPE));
	addTextEditor(table, cellEditor, columns, (Messages.SCALE));
	addComboBox(table, cellEditor, getScaleTypeKey(), columns.get(Messages.SCALE_TYPE));
	addTextEditor(table, cellEditor, columns, (Messages.DATEFORMAT));
	addTextEditor(table, cellEditor, columns, (Messages.PRECISION));
	addTextEditor(table, cellEditor, columns, (Messages.FIELD_DESCRIPTION));
	return cellEditor;
}
 
Example 26
Project: eZooKeeper   File: ViewerFactory.java   View source code 5 votes vote down vote up
/**
 * Create a new {@link TableViewer} with {@link DataModel} elements.
 * 
 * @param site The {@link IWorkbenchPartSite} used to register the table's context menu.
 * @param table The {@link Table}.
 * @param dataModelClass The {@link DataModel} element {@link Class}.
 * @param dataModelElementType The {@link DataModel} {@link IElementType}.
 * @param input The {@link TableViewer} input.
 * @param inputElementType The input {@link IElementType}.
 * @return A new {@link TableViewer}.
 */
public static TableViewer createDataModelTableViewer(IWorkbenchPartSite site, Table table, Class<?> dataModelClass,
        final IElementType dataModelElementType, Object input, IElementType inputElementType) {

    TableViewer tableViewer = createTableViewer(table, dataModelClass, dataModelElementType, input,
            inputElementType, new DataModelElementBinding());

    List<BaseAction> tableActions = dataModelElementType.getActions();
    if (tableActions != null) {
        for (BaseAction action : tableActions) {
            action.setSelectionProvider(tableViewer);
        }

        MenuManager menuManager = new MenuManager("#PopupMenu");
        menuManager.setRemoveAllWhenShown(true);
        menuManager.addMenuListener(new IMenuListener() {

            public void menuAboutToShow(IMenuManager manager) {
                dataModelElementType.fillContextMenu(manager);
            }

        });

        Menu menu = menuManager.createContextMenu(table);
        table.setMenu(menu);
        site.registerContextMenu(menuManager, tableViewer);
    }

    return tableViewer;
}
 
Example 27
Project: Hydrograph   File: JoinMapDialog.java   View source code 5 votes vote down vote up
private void setTableLayoutToMappingTable(Table table) {
	TableColumnLayout layout = new TableColumnLayout();
	mappingTableViewer.getControl().getParent().setLayout(layout);

	for (int columnIndex = 0, n = table.getColumnCount(); columnIndex < n; columnIndex++) {
		table.getColumn(columnIndex).pack();
	}

	for (int i = 0; i < mappingTableViewer.getTable().getColumnCount(); i++) {
		layout.setColumnData(mappingTableViewer.getTable().getColumn(i),
				new ColumnWeightData(1));
	}
}
 
Example 28
Project: Hydrograph   File: OperationClassDialog.java   View source code 5 votes vote down vote up
private void moveRowDown(TableViewer nameValueTableViewer)
{
	Table table = nameValueTableViewer.getTable();
	int[] indexes = table.getSelectionIndices();
	for (int i = indexes.length - 1; i > -1; i--) {

		if (indexes[i] < mappingSheetRow.getNameValueProperty().size() - 1) {
			Collections.swap(mappingSheetRow.getNameValueProperty(), indexes[i], indexes[i] + 1);
			nameValueTableViewer.refresh();
			applyButton.setEnabled(true);

		}
	}

}
 
Example 29
Project: eZooKeeper   File: ViewerFactory.java   View source code 5 votes vote down vote up
private static void createTableColumns(Table table, IElementType tableElementType) {

        String[] columnTitles = tableElementType.getColumnTitles();
        int[] columnAlignments = tableElementType.getColumnAlignments();

        for (int i = 0; i < columnTitles.length; i++) {
            TableColumn column = new TableColumn(table, SWT.NONE);
            column.setText(columnTitles[i]);
            column.setAlignment(columnAlignments[i]);
            column.setMoveable(true);
        }

        table.setHeaderVisible(true);
    }
 
Example 30
Project: eZooKeeper   File: ViewerFactory.java   View source code 5 votes vote down vote up
private static void initTableViewer(TableViewer tableViewer, ElementTypes elementTypes, Object input,
        IElementBinding elementBinding) {

    IViewerType viewerType = new TableViewerType();

    Table table = tableViewer.getTable();
    Class<?> contentProviderInterfaceType = IStructuredContentProvider.class;
    if ((table.getStyle() & SWT.VIRTUAL) != 0) {
        contentProviderInterfaceType = ILazyContentProvider.class;
    }

    registerTableListeners(table);

    initViewer(tableViewer, elementTypes, input, elementBinding, viewerType, contentProviderInterfaceType);
}
 
Example 31
Project: Hydrograph   File: SecondaryColumnKeysDialog.java   View source code 5 votes vote down vote up
private void createSourceTable(Composite composite_2) {
	sourceTable = new Table(composite_2, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
	sourceTable.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseDoubleClick(MouseEvent e) {
			if(sourceTable.getSelection().length==1){
				addNewProperty(targetTableViewer, sourceTable.getSelection()[0].getText());
				enableControlButtons();
			}
		}
	});
	GridData gd_table = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2);
	gd_table.widthHint = 221;
	gd_table.heightHint = 407;
	sourceTable.setLayoutData(gd_table);
	sourceTable.setHeaderVisible(true);
	sourceTable.setLinesVisible(true);

	TableColumn sourceTableColumnFieldName = new TableColumn(sourceTable, SWT.LEFT);
	if(OSValidator.isMac()){
		sourceTableColumnFieldName.setWidth(212);
	}else{
		sourceTableColumnFieldName.setWidth(202);
	}
	
	sourceTableColumnFieldName.setText(Messages.AVAILABLE_FIELDS_HEADER);
	getSourceFieldsFromPropagatedSchema(sourceTable);
	dragSource = new DragSource(sourceTable, DND.DROP_MOVE);
	dragSource.setTransfer(new Transfer[] { TextTransfer.getInstance() });
	dragSource.addDragListener(new DragSourceAdapter() {
		public void dragSetData(DragSourceEvent event) {
			// Set the data to be the first selected item's text
			event.data = formatDataToTransfer(sourceTable.getSelection());
		}

	});
}
 
Example 32
Project: Hydrograph   File: TransformMappingFeatureUtility.java   View source code 5 votes vote down vote up
/**
 * This method is used to set cursor position at last row when any field is 
 * deleted from table-viewer
 * 
 * @param tableViewer
 * @param indexes
 * @param gridList
 */
public  void setCursorOnDeleteRow(TableViewer tableViewer,int[] indexes,List<?> gridList){
       Table table = tableViewer.getTable();
       //highlight after deletion
       if(indexes.length == 1 && gridList.size() > 0){//only one item is deleted
             if(gridList.size() == 1){//list contains only one element
                   table.select(0);// select the first element
                   tableViewer.editElement(tableViewer.getElementAt(0), 0);
             }
             else if(gridList.size() == indexes[0]){//deleted last item 
                   table.select(gridList.size() - 1);//select the last element which now at the end of the list
                   tableViewer.editElement(tableViewer.getElementAt(gridList.size() - 1), 0);
             }
             else if(gridList.size() > indexes[0]){//deleted element from middle of the list
                   table.select( indexes[0] == 0 ? 0 : (indexes[0] - 1) );//select the element from at the previous location
                   tableViewer.editElement(tableViewer.getElementAt(indexes[0] == 0 ? 0 : (indexes[0] - 1)), 0);
             }
       }
       else if(indexes.length >= 2){//multiple items are selected for deletion
             if(indexes[0] == 0){//delete from 0 to ...
                   if(gridList.size() >= 1){//list contains only one element
                         table.select(0);//select the remaining element
                         tableViewer.editElement(tableViewer.getElementAt(0), 0);
                   }
             }
             else{//delete started from element other than 0th element
                   table.select((indexes[0])-1);//select element before the start of selection   
                   tableViewer.editElement(tableViewer.getElementAt((indexes[0])-1), 0);
             }
       }
   }
 
Example 33
Project: Hydrograph   File: TransformDialog.java   View source code 5 votes vote down vote up
public static void createTableColumns(Table table, String[] fields) {
	for (String field : fields) {
		TableColumn tableColumn = new TableColumn(table, SWT.LEFT);
		tableColumn.setText(field);

		tableColumn.setWidth(100);
		tableColumn.pack();
	}
	table.setHeaderVisible(true);
	table.setLinesVisible(true);
}
 
Example 34
Project: Hydrograph   File: KeyDownSchemaGridListener.java   View source code 5 votes vote down vote up
@Override
public void mouseAction(PropertyDialogButtonBar propertyDialogButtonBar,
		ListenerHelper helpers, Event event, Widget... widgets) {
	Table table=(Table)event.widget;
	   Shell tip=(Shell) table.getData("tip");
	   Label label=(Label) table.getData("label");
	if(tip!=null) 
	{
	 tip.dispose();
        tip = null;
        label = null;
	}
}
 
Example 35
Project: Hydrograph   File: LookupMapDialog.java   View source code 5 votes vote down vote up
private void setTableLayoutToMappingTable(Table table) {
	TableColumnLayout layout = new TableColumnLayout();
	mappingTableViewer.getControl().getParent().setLayout(layout);

	for (int columnIndex = 0, n = table.getColumnCount(); columnIndex < n; columnIndex++) {
		table.getColumn(columnIndex).pack();
	}

	for (int i = 0; i < mappingTableViewer.getTable().getColumnCount(); i++) {
		layout.setColumnData(mappingTableViewer.getTable().getColumn(i),
				new ColumnWeightData(1));
	}
}
 
Example 36
Project: eZooKeeper   File: ZooKeeperConnectionModelMainFormPage.java   View source code 5 votes vote down vote up
/**
 * TODO: Comment.
 * 
 */
protected void initPropertiesSectionFromModel() {

    Table table = getPropertiesSectionTable();
    table.removeAll();

    Map<String, String> properties = getZooKeeperConnectionProperties();

    for (String key : properties.keySet()) {
        TableItem item = new TableItem(table, SWT.NONE);
        String value = properties.get(key);
        item.setText(0, key);
        item.setText(1, value);

        Color valueTextColor = table.getForeground();
        if (key.equals(ZooKeeperConnectionModelElementType.PROPERTY_NAME_STATE)) {
            if (!States.CONNECTED.name().equals(value)) {
                valueTextColor = table.getDisplay().getSystemColor(SWT.COLOR_RED);
            }
            // else {
            // valueTextColor = table.getDisplay().getSystemColor(SWT.COLOR_GREEN);
            // }
        }
        
        item.setForeground(1, valueTextColor);
    }

    packTable(table, PROPERTIES_COLUMN_WIDTHS);

}
 
Example 37
Project: Hydrograph   File: ELTOperationClassDialog.java   View source code 5 votes vote down vote up
public static CellEditor[] createCellEditorList(Table table, int size) {
	CellEditor[] cellEditor = new CellEditor[size];
	for (int i = 0; i < size; i++)
		addTextEditor(table, cellEditor, i);

	return cellEditor;
}
 
Example 38
Project: Hydrograph   File: DisposeSchemaGridListener.java   View source code 5 votes vote down vote up
@Override
public void mouseAction(PropertyDialogButtonBar propertyDialogButtonBar,
		ListenerHelper helpers, Event event, Widget... widgets) {
	   Table table=(Table)event.widget;
	   Shell tip=(Shell) table.getData("tip");
	   Label label=(Label) table.getData("label");
	if(tip!=null) 
	{
	 tip.dispose();
        tip = null;
        label = null;
	}
}
 
Example 39
Project: eZooKeeper   File: BaseZnodeModelTableFormPage.java   View source code 5 votes vote down vote up
protected final void initFromModelInternal() {

        Table table = getTable();

        if (table == null || getModel().isDestroyed()) {
            return;
        }

        table.setRedraw(false);

        try {
            initTableItemsFromZnode();
            setDirtyInternal(false);
        }
        finally {
            table.setRedraw(true);
        }

        table.pack();
        forceLayout();

        TableColumn[] columns = getTable().getColumns();
        int[] columnWidths = getTableColumnWidths();
        for (int i = 0; i < columns.length; i++) {

            if (columnWidths == null) {
                columns[i].pack();
            }
            else {
                int columnWidth = columnWidths[i];
                if (columnWidth == SWT.DEFAULT) {
                    columns[i].pack();
                }
                else {
                    columns[i].setWidth(columnWidth);
                }
            }
        }
    }
 
Example 40
Project: eZooKeeper   File: ZnodeModelStatFormPage.java   View source code 5 votes vote down vote up
@Override
protected void initTableItemsFromZnode() {

    Table table = getTable();
    table.removeAll();

    ZnodeModel znodeModel = getModel();
    Znode znode = znodeModel.getData();
    Stat stat = znode.getStat();

    DateFormat format = DateFormat.getDateTimeInstance();
    String ctime = format.format(new Date(stat.getCtime()));
    String mtime = format.format(new Date(stat.getMtime()));

    addStatValueTableItem(table, Znode.STAT_NAME_CZXID, String.valueOf(stat.getCzxid()),
            Znode.STAT_DESCRIPTION_CZXID);
    addStatValueTableItem(table, Znode.STAT_NAME_MZXID, String.valueOf(stat.getMzxid()),
            Znode.STAT_DESCRIPTION_MZXID);
    addStatValueTableItem(table, Znode.STAT_NAME_CTIME, ctime, Znode.STAT_DESCRIPTION_CTIME);
    addStatValueTableItem(table, Znode.STAT_NAME_MTIME, mtime, Znode.STAT_DESCRIPTION_MTIME);
    addStatValueTableItem(table, Znode.STAT_NAME_VERSION, String.valueOf(stat.getVersion()),
            Znode.STAT_DESCRIPTION_VERSION);
    addStatValueTableItem(table, Znode.STAT_NAME_CVERSION, String.valueOf(stat.getCversion()),
            Znode.STAT_DESCRIPTION_CVERSION);
    addStatValueTableItem(table, Znode.STAT_NAME_AVERSION, String.valueOf(stat.getAversion()),
            Znode.STAT_DESCRIPTION_AVERSION);
    addStatValueTableItem(table, Znode.STAT_NAME_EPHEMERAL_OWNER, String.valueOf(stat.getEphemeralOwner()),
            Znode.STAT_DESCRIPTION_EPHEMERAL_OWNER);
    addStatValueTableItem(table, Znode.STAT_NAME_DATA_LENGTH, String.valueOf(stat.getDataLength()),
            Znode.STAT_DESCRIPTION_DATA_LENGTH);
    addStatValueTableItem(table, Znode.STAT_NAME_NUM_CHILDREN, String.valueOf(stat.getNumChildren()),
            Znode.STAT_DESCRIPTION_NUM_CHILDREN);

}