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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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);

}
 
Example 41
Project: eZooKeeper   File: ZnodeModelStatFormPage.java   Source Code and License 5 votes vote down vote up
private void addStatValueTableItem(Table table, String name, String value, String description) {
    TableItem item = new TableItem(table, SWT.NONE);

    item.setText(0, name);
    item.setText(1, value);
    item.setText(2, description);
}
 
Example 42
Project: Hydrograph   File: FindViewDataDialog.java   Source Code and License 5 votes vote down vote up
private void reverseTableTraverse(TableViewer debugDataViewer, TableCursor tableCursor){
	TableItem previousSelectedTableItem = null;
	if(debugDataViewer.getData("SELECTED_ROW_INDEX")!=null){
		previousSelectedTableItem = debugDataViewer.getTable().getItem((int) debugDataViewer.getData("SELECTED_ROW_INDEX"));
		findColIndex -= 1;
	}
	if(findRowIndex < 0){
		findRowIndex = debugDataViewer.getTable().getItems().length - 1;
	}
	Table table = debugDataViewer.getTable();
	TableItem[] tableItems = table.getItems();
	for(; findRowIndex >=0; findRowIndex--){
		TableItem tableItem = tableItems[findRowIndex];
		for( ; findColIndex > 0 ;findColIndex--){
			if(StringUtils.containsIgnoreCase(tableItem.getText(findColIndex), findText.getText())){
				if(prevColSelection > 0){
					previousSelectedTableItem.setBackground(prevColSelection, Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
				}
				label.setVisible(false);
				table.showItem(tableItem);
				table.showColumn(table.getColumn(findColIndex));
				tableCursor.setSelection(findRowIndex, findColIndex);
				tableCursor.setVisible(false);
				tableItem.setBackground(findColIndex,Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY));
				if(findColIndex<=0){debugDataViewer.setData("SELECTED_ROW_INDEX", findRowIndex-1);}else{
					debugDataViewer.setData("SELECTED_ROW_INDEX", findRowIndex);
				}
				debugDataViewer.setData("SEELCTED_COLUMN_INDEX", findColIndex);
				prevColSelection = findColIndex;
				prevRowSelection = findRowIndex;
				return ;
			}
			
		}
		if(findColIndex <= 0){ findColIndex = table.getColumnCount();}
		if(findRowIndex == 0){ findRowIndex = tableItems.length; }
	}
}
 
Example 43
Project: Hydrograph   File: ELTSWTWidgets.java   Source Code and License 5 votes vote down vote up
public TableViewer createTableViewer(Composite composite, String[] prop,
		int[] bounds, int columnWidth,
		IStructuredContentProvider iStructuredContentProvider,
		ITableLabelProvider iTableLabelProvider) {
	final TableViewer tableViewer = new TableViewer(composite, SWT.BORDER
			| SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL);

	Table table = tableViewer.getTable();
	table.setBounds(bounds[0], bounds[1], bounds[2], bounds[3]);
	tableViewer.setContentProvider(iStructuredContentProvider);
	tableViewer.setLabelProvider(iTableLabelProvider);
	tableViewer.setColumnProperties(prop);
	tableViewer.getTable().addTraverseListener(new TraverseListener() {

		@Override
		public void keyTraversed(TraverseEvent e) {
			if (e.keyCode == SWT.ARROW_UP) {
				e.doit = false;
			} else if (e.keyCode == SWT.ARROW_DOWN) {
				e.doit = false;
			} else if (e.keyCode == SWT.TRAVERSE_ARROW_NEXT) {
				e.doit = false;
			} else if (e.keyCode == SWT.TRAVERSE_ARROW_PREVIOUS) {
				e.doit = false;
			}

		}
	});

	table.setVisible(true);
	table.setLinesVisible(true);
	table.setHeaderVisible(true);
	/*
	 * createTableColumns(table,prop, columnWidth); CellEditor[] editors
	 * =createCellEditorList(table,1); tableViewer.setCellEditors(editors);
	 */

	return tableViewer;
}
 
Example 44
Project: eZooKeeper   File: BaseJmxModelMainFormPage.java   Source Code and License 5 votes vote down vote up
@Override
protected final void createModelFormContent(IManagedForm managedForm, Composite client) {
    ScrolledForm form = managedForm.getForm();
    FormToolkit toolkit = managedForm.getToolkit();

    _PrimarySection = createPrimarySection(form, client, toolkit);
    _DetailSection = createDetailSection(form, client, toolkit);
    _InfoSection = createInfoSection(form, client, toolkit);
    _DescriptorSection = createDescriptorSection(form, client, toolkit);

    if (_PrimarySection != null) {
        GridData primarySectionGridData = new GridData(GridData.FILL_HORIZONTAL);
        _PrimarySection.setLayoutData(primarySectionGridData);
    }

    if (_DetailSection != null) {
        GridData detailSectionGridData = new GridData(GridData.FILL_HORIZONTAL);
        _DetailSection.setLayoutData(detailSectionGridData);
    }

    if (_InfoSection != null) {
        Table infoSectionTable = getInfoTable();
        initTableEdit(infoSectionTable, null, 1);
        GridData infoSectionGridData = new GridData(GridData.FILL_BOTH);
        _InfoSection.setLayoutData(infoSectionGridData);
    }

    if (_DescriptorSection != null) {
        Table descriptorSectionTable = getDescriptorTable();
        initTableEdit(descriptorSectionTable, null, 1);
        GridData descriptorSectionGridData = new GridData(GridData.FILL_BOTH);
        _DescriptorSection.setLayoutData(descriptorSectionGridData);
    }

}
 
Example 45
Project: eZooKeeper   File: BaseJmxModelMainFormPage.java   Source Code and License 5 votes vote down vote up
/**
 * Returns the descriptorTable.
 * 
 * @return The descriptorTable
 */
protected final Table getDescriptorTable() {
    if (_DescriptorSection == null) {
        return null;
    }

    return (Table) _DescriptorSection.getClient();
}
 
Example 46
Project: Hydrograph   File: SchemaPreviewPage.java   Source Code and License 5 votes vote down vote up
private void addControlListener(Table table, TableColumn tableColumn) {
	ControlListener controlistener= new ControlAdapter() {
		@Override
		public void controlResized(ControlEvent e) {
			for (TableColumn column : table.getColumns()) {
				column.setWidth(table.getSize().x / table.getColumnCount() - (4 - table.getColumnCount()));
			}
		}
	};
	table.addControlListener(controlistener);
}
 
Example 47
Project: eZooKeeper   File: MBeanAttributeModelMainFormPage.java   Source Code and License 5 votes vote down vote up
protected Section createPrimarySection(ScrolledForm form, Composite client, FormToolkit toolkit) {
    Section primarySection = createTableSection(form, client, toolkit, getPrimarySectionTitle(), JmxActivator
            .getManagedImage(JmxActivator.IMAGE_KEY_OBJECT_MBEAN_ATTRIBUTE_VALUE));

    Table primarySectionTable = (Table) primarySection.getClient();
    initTableEdit(primarySectionTable, null, 1);

    return primarySection;
}
 
Example 48
Project: convertigo-eclipse   File: ArrayEditorComposite.java   Source Code and License 5 votes vote down vote up
/**
 * This method initializes table	
 *
 */
private void createTable() {
	int style = SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | 
	SWT.FULL_SELECTION | SWT.HIDE_SELECTION;
	
	table = new Table(this, style);
	
	GridData gridData = new GridData(GridData.FILL_BOTH);
	gridData.grabExcessVerticalSpace = true;
	gridData.horizontalSpan = 3;
	table.setLayoutData(gridData);		
	table.setLinesVisible(true);
	table.setHeaderVisible(true);
}
 
Example 49
Project: convertigo-eclipse   File: TableEditorComposite.java   Source Code and License 5 votes vote down vote up
/**
 * This method initializes table	
 *
 */
private void createTable() {
	int style = SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | 
	SWT.FULL_SELECTION | SWT.HIDE_SELECTION;
	
	table = new Table(this, style);
	
	GridData gridData = new GridData(GridData.FILL_BOTH);
	gridData.grabExcessVerticalSpace = true;
	gridData.horizontalSpan = 3;
	table.setLayoutData(gridData);		
	table.setLinesVisible(true);
	table.setHeaderVisible(true);
}
 
Example 50
Project: convertigo-eclipse   File: EngineLogViewLabelProvider.java   Source Code and License 5 votes vote down vote up
public String getColumnText(Object element, int columnIndex) {
	LogLine line = (LogLine) element;
	
	Table table = tableViewer.getTable();		
	String columnName = table.getColumn(columnIndex).getText();
	
	Class<LogLine> logLineClass = GenericUtils.cast(line.getClass());
	
	Object result;
	try {
		Method getMethod = logLineClass.getMethod("get" + columnName);
		result = getMethod.invoke(line);

		if ("Message".equals(columnName)) {
			return (String) result;
		}
		else {
			if (line.isSubLine) {
				return "";
			}
			else {
				return (String) result;
			}
		}
	} catch (Exception e) {
		return "";
	}
}
 
Example 51
Project: convertigo-eclipse   File: EngineLogView.java   Source Code and License 5 votes vote down vote up
private void searchInLogs(int side) {
	int searchIndex = currentFoundIndex + side;
	if (searchIndex < 0 || searchIndex > foundIndexes.size())
		return;
	
	currentFoundIndex = searchIndex;
	Table table = tableViewer.getTable();
	
	table.setSelection(foundIndexes.get(currentFoundIndex));
	table.setFocus();

	// Disable "previous" if is the beginning
	if (foundIndexes.get(currentFoundIndex) == foundIndexes.get(0))
		previousSearch.setEnabled(false);
	else
		previousSearch.setEnabled(true);

	// Disable "next" if is the end
	if (foundIndexes.get(currentFoundIndex) == foundIndexes.get(foundIndexes.size() - 1))
		nextSearch.setEnabled(false);
	else
		nextSearch.setEnabled(true);
	
	infoSearch.setText((currentFoundIndex + 1) + "/" + foundIndexes.size());

	// To force components resizing if needed
	compositeSearch.layout();
}
 
Example 52
Project: Hydrograph   File: FindViewDataDialog.java   Source Code and License 5 votes vote down vote up
private void clearTableItemBgColor(TableViewer debugDataViewer){
 if(debugDataViewer == null){
  return;
 }
 Table table = debugDataViewer.getTable();
 TableItem[] tableItems = table.getItems();
 for(int i=0;i<tableItems.length;i++){
TableItem tableItem = tableItems[i];
for(int j=1;j <= table.getColumnCount()-1;j++){
	tableItem.getText(j);
	tableItem.setBackground(j, Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
}
 }
}
 
Example 53
Project: convertigo-eclipse   File: XMLTableWizardPage.java   Source Code and License 5 votes vote down vote up
private void createTable(Composite parent) {
	GridData gridData = new GridData();
	gridData.horizontalSpan = numColumns;
	gridData.horizontalAlignment = GridData.FILL;
	gridData.grabExcessHorizontalSpace = true;
	gridData.grabExcessVerticalSpace = true;
	gridData.verticalAlignment = GridData.FILL;
	table = new Table(parent, SWT.VIRTUAL | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
	table.setLayoutData(gridData);
	table.setHeaderVisible(true);
	table.setLinesVisible(true);
}
 
Example 54
Project: convertigo-eclipse   File: SqlConnectorComposite.java   Source Code and License 5 votes vote down vote up
private void createTable() {
	GridData gridData = new org.eclipse.swt.layout.GridData();
	gridData.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
	gridData.grabExcessHorizontalSpace = true;
	gridData.grabExcessVerticalSpace = true;
	gridData.verticalAlignment = org.eclipse.swt.layout.GridData.FILL;
	table = new Table(this, SWT.VIRTUAL | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
	table.setLayoutData(gridData);
	table.setHeaderVisible(true);
	table.setLinesVisible(true);
}
 
Example 55
Project: Hydrograph   File: ELTSWTWidgets.java   Source Code and License 5 votes vote down vote up
public 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 56
Project: gw4e.project   File: CustomListWithButtons.java   Source Code and License 5 votes vote down vote up
/**
 * Refresh the Table Viewer
 */
private void refresh() {
	listViewer.refresh();
	Table table = listViewer.getTable();
	for (int i = 0, n = table.getColumnCount(); i < n; i++) {
		table.getColumn(i).pack();
	}
}
 
Example 57
Project: gw4e.project   File: BuildPoliciesCheckboxTableViewer.java   Source Code and License 5 votes vote down vote up
public static BuildPoliciesCheckboxTableViewer create (IResource file, Composite parent, int style, GridData gd, Listener listener) {
	Table table = new Table(parent, SWT.CHECK | style);
	table.setData(GW4E_CONVERSION_WIDGET_ID, GW4E_CONVERSION_TABLE_GENERATORS);
	
	BuildPoliciesCheckboxTableViewer bctv =  new BuildPoliciesCheckboxTableViewer(file,table);
	bctv.init(listener,gd);
	return bctv;
}
 
Example 58
Project: gw4e.project   File: BuildPoliciesCheckboxTableViewer.java   Source Code and License 5 votes vote down vote up
public BuildPoliciesCheckboxTableViewer(IResource file, Table table) {
	super(table);
	this.file=null;
	if (file instanceof IFile) {
		this.file=(IFile)file;
	}
}
 
Example 59
Project: SWET   File: TableEditorEx.java   Source Code and License 5 votes vote down vote up
private static void appendBlankRowToTable(Table table, TableItem item,
		int index) {

	item.setText(new String[] { String.format("%d", index), "Element name",
			"Action keyword", "", "Selector value" });

	TableEditor keywordChoiceEditor = new TableEditor(table);
	CCombo keywordChoiceCombo = new CCombo(table, SWT.NONE);
	keywordChoiceCombo.setText("Choose..");
	for (String keyword : keywordTable.keySet()) {
		keywordChoiceCombo.add(keyword);
	}
	// NOTE: none of options is initially selected
	keywordChoiceEditor.grabHorizontal = true;
	int keywordChoiceColumn = 2;
	keywordChoiceCombo.setData("column", keywordChoiceColumn);
	keywordChoiceCombo.setData("item", item);
	keywordChoiceEditor.setEditor(keywordChoiceCombo, item,
			keywordChoiceColumn);
	keywordChoiceCombo.addModifyListener(new keywordChoiceListener());

	TableEditor selectorChoiceEditor = new TableEditor(table);
	CCombo selectorChoiceCombo = new CCombo(table, SWT.NONE);
	selectorChoiceCombo.setText("Choose");
	for (String locator : selectorFromSWD.values()) {
		selectorChoiceCombo.add(locator);
	}
	// NOTE: none of options is initially selected
	selectorChoiceEditor.grabHorizontal = true;
	int selectorChoiceColumn = 3;
	selectorChoiceCombo.setData("item", item);
	selectorChoiceCombo.setData("column", selectorChoiceColumn);
	selectorChoiceEditor.setEditor(selectorChoiceCombo, item,
			selectorChoiceColumn);
	selectorChoiceCombo.addModifyListener(new selectorChoiceListener());
	return;
}
 
Example 60
Project: Hydrograph   File: FindViewDataDialog.java   Source Code and License 5 votes vote down vote up
private void forwardTableTraverse(TableViewer debugDataViewer, TableCursor tableCursor){
	TableItem previousSelectedTableItem = null;
	if(debugDataViewer.getData("SELECTED_ROW_INDEX")!=null){
		previousSelectedTableItem = debugDataViewer.getTable().getItem((int) debugDataViewer.getData("SELECTED_ROW_INDEX"));
		findColIndex++;
	}
	Table table = debugDataViewer.getTable();
	TableItem[] tableItems = table.getItems();
	if(findColIndex == prevColSelection && findRowIndex == prevRowSelection){
		findColIndex++;
	}
	if(findRowIndex < 0){
		findRowIndex = 0;
	}
	for(;findRowIndex<tableItems.length;){
		TableItem tableItem = tableItems[findRowIndex];
		for(;findColIndex <= table.getColumnCount();findColIndex++){
			if(StringUtils.containsIgnoreCase(tableItem.getText(findColIndex), findText.getText())){
				if(prevColSelection > 0){
					previousSelectedTableItem.setBackground(prevColSelection, Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
				}
				label.setVisible(false);
				table.showItem(tableItem);
				table.showColumn(table.getColumn(findColIndex));
				tableCursor.setSelection(findRowIndex, findColIndex);
				tableCursor.setVisible(false);
				tableItem.setBackground(findColIndex, Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY));
				debugDataViewer.setData("SELECTED_ROW_INDEX", findRowIndex);
				debugDataViewer.setData("SEELCTED_COLUMN_INDEX", findColIndex);
				prevColSelection = findColIndex;
				return;
			}
		}
		findRowIndex++;
		findColIndex=1;
		if(findRowIndex >= tableItems.length){ findRowIndex = 0;}
	}
}