Java Code Examples for org.eclipse.swt.widgets.TableItem#setData()

The following examples show how to use org.eclipse.swt.widgets.TableItem#setData() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PickOverrideKeysAndParmName.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
  Composite mainArea = (Composite)super.createDialogArea(parent);
  
  Composite twoCol = new2ColumnComposite(mainArea);
  
  
  keysUI = newTable(twoCol, SWT.SINGLE);
  paramsUI = newTable(twoCol, SWT.SINGLE);
  
  for (Iterator it = delegates.entrySet().iterator(); it.hasNext();) {
    Map.Entry entry = (Map.Entry)it.next();
    TableItem item = new TableItem(keysUI, SWT.NULL);
    item.setText((String)entry.getKey());
    item.setData(entry);
  }
  keysUI.addListener(SWT.Selection, this);
  if (0 < keysUI.getItemCount()) {
    keysUI.setSelection(0);
  }
  
  return mainArea;
}
 
Example 2
Source File: TypeInfoViewer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void setData(TableItem item) {
	int index= fTable.indexOf(item);
	TypeNameMatch type= getTypeInfo(index);
	if (type == DASH_LINE) {
		item.setData(fDashLine);
		fillDashLine(item);
	} else {
		item.setData(type);
		item.setImage(fImageManager.get(fLabelProvider.getImageDescriptor(type)));
		item.setText(fLabelProvider.getText(
			getTypeInfo(index - 1),
			type,
			getTypeInfo(index + 1)));
		item.setForeground(null);
	}
}
 
Example 3
Source File: CompletionProposalPopup.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private void setItem(TableItem[] items, int i)
{
	TableItem item = items[i];
	ICompletionProposal proposal = fFilteredProposals[i];
	item.setData("isAlt", "false");
		
	item.setImage(0, proposal.getImage());
	item.setText(1, proposal.getDisplayString());
	boolean isItalics = false;
	if (!(isItalics))
	{
		setDefaultStyle(item);
    }
	item.setData(proposal);

}
 
Example 4
Source File: CompletionProposalPopup.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private void handleSetData(Event event)
{
	TableItem item = (TableItem) event.item;
	int index = fProposalTable.indexOf(item);
	if(index >= 0 && index < fFilteredProposals.length) 
	{
	ICompletionProposal current = fFilteredProposals[index];
		item.setData("isAlt", "false");

		item.setImage(0, current.getImage());
		item.setText(1, current.getDisplayString());
		boolean isItalics = false;

		if (!(isItalics))
		{
			setDefaultStyle(item);
		}
		item.setData(current);
	}
}
 
Example 5
Source File: TmfEventsTable.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Set the item data of the "filter status" row.
 *
 * @param item
 *            The item to use as filter status row
 */
protected void setFilterStatusRowItemData(final TableItem item) {
    for (int i = 0; i < fTable.getColumns().length; i++) {
        if (i == MARGIN_COLUMN_INDEX) {
            if ((fTrace == null) || (fFilterCheckCount == fTrace.getNbEvents())) {
                item.setImage(FILTER_IMAGE);
            } else {
                item.setImage(STOP_IMAGE);
            }
        }

        if (i == FILTER_SUMMARY_INDEX) {
            item.setText(FILTER_SUMMARY_INDEX, fFilterMatchCount + "/" + fFilterCheckCount); //$NON-NLS-1$
        } else {
            item.setText(i, EMPTY_STRING);
        }
    }
    item.setData(null);
    item.setData(Key.TIMESTAMP, null);
    item.setData(Key.RANK, null);
    item.setData(Key.STYLE_RANGES, null);
    item.setForeground(null);
    item.setBackground(null);
    item.setFont(fFont);
}
 
Example 6
Source File: SWTTable.java    From tuxguitar with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void addItem(UITableItem<T> item) {
	TableItem tableItem = new TableItem(this.getControl(), SWT.NULL);
	tableItem.setData(item);
	if( item.getImage() != null && !item.getImage().isDisposed()) {
		tableItem.setImage(((SWTImage)item.getImage()).getHandle());
	}
	
	int columns = this.getColumns();
	for(int i = 0 ; i < columns; i ++) {
		String text = item.getText(i);
		if( text != null ) {
			tableItem.setText(i, text);
		}
	}
	
	// fix column size
	if( this.isVisible() ) {
		this.updateManager.setUpdateRequired();
	}
}
 
Example 7
Source File: ERTableComposite.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
private void column2TableItem(final Column column, final TableItem tableItem) {
    disposeCheckBox(column);

    if (column instanceof NormalColumn) {
        // tableItem.setBackground(ColorConstants.white);

        final NormalColumn normalColumn = (NormalColumn) column;

        if (normalColumn.isPrimaryKey()) {
            tableItem.setData("0", ERDiagramActivator.getImage(ImageKey.PRIMARY_KEY));
        } else {
            tableItem.setData("0", null);
        }

        if (normalColumn.isForeignKey()) {
            tableItem.setData("1", ERDiagramActivator.getImage(ImageKey.FOREIGN_KEY));
        } else {
            tableItem.setData("1", null);
        }

        tableItem.setText(2, Format.null2blank(normalColumn.getPhysicalName()));
        tableItem.setText(3, Format.null2blank(normalColumn.getLogicalName()));

        final SqlType sqlType = normalColumn.getType();

        tableItem.setText(4, Format.formatType(sqlType, normalColumn.getTypeData(), diagram.getDatabase(), true));

        setTableEditor(normalColumn, tableItem);

    } else {
        // tableItem.setBackground(ColorConstants.white);
        tableItem.setData("0", ERDiagramActivator.getImage(ImageKey.GROUP));
        tableItem.setData("1", null);
        tableItem.setText(2, column.getName());
        tableItem.setText(3, "");
        tableItem.setText(4, "");
    }

}
 
Example 8
Source File: ViewClipboard.java    From arx with Apache License 2.0 5 votes vote down vote up
/**
 * Adds an item.
 *
 * @param node
 * @param index
 * @return
 */
private TableItem addItem(ARXNode node, int index) {
    
    final TableItem item = new TableItem(table, SWT.NONE, index);
    item.setText(0, Arrays.toString(node.getTransformation()));
    if (node.getAttributes().get(NODE_COMMENT) != null) {
        item.setText(1, (String) node.getAttributes().get(NODE_COMMENT));
    } else {
        item.setText(1, ""); //$NON-NLS-1$
    }
    item.setData(node);
    return item;
}
 
Example 9
Source File: OrderElementControl.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
public void refreshInput() {
	ISelection selection = viewer.getSelection();
	EList<EObject> listInput = getListInput();
	viewer.setInput(listInput);
	if (listInput.isEmpty()) {
		viewer.getTable().clearAll();
		TableItem item = new TableItem(viewer.getTable(), SWT.NONE);
		item.setData(EcoreFactory.eINSTANCE.createEObject());
		item.setText(placeholder);
	} else {
		viewer.setSelection(selection);
	}
	viewer.setSelection(selection);
}
 
Example 10
Source File: SelectTypeDialog.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Display name spaces for selected item.
 *
 * @param entry the entry
 */
private void displayNameSpacesForSelectedItem(Map.Entry entry) {
  Set nameSpaces = (Set)entry.getValue();
  nameSpacesUI.removeAll();
  for (Iterator it = nameSpaces.iterator(); it.hasNext();) {
    String nameSpace = (String) it.next();
    TableItem item = new TableItem(nameSpacesUI, SWT.NULL);
    item.setText(nameSpace);
    item.setData(entry);
  }
  if (nameSpacesUI.getItemCount() > 0) {
    nameSpacesUI.select(0);
  }
}
 
Example 11
Source File: PickOverrideKeysAndParmName.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Adds the selected parms.
 *
 * @param parms the parms
 * @param keyName the key name
 */
/*
 * Filter overridable parameters to exclude: 
 * - already overridden (can't override same parameter twice) 
 * - those with different type or multi-valued-ness 
 */
private void addSelectedParms(ConfigurationParameter[] parms, String keyName) {
  /*boolean isMultiValued = (null != parameterDialog) ? parameterDialog.multiValueUI
          .getSelection() : cp.isMultiValued();
  String type = (null != parameterDialog) ? parameterDialog.parmTypeUI.getText() : cp.getType();*/
  boolean isMultiValued = cp.isMultiValued();
  String type = cp.getType();

  if (null != parms) {
    for (int i = 0; i < parms.length; i++) {
      // multi-valued-ness must match
      if ((isMultiValued != parms[i].isMultiValued()))
        continue;
      // types must match, but we also allow if no type is spec'd - not sure if this is useful
      if ((null != type && !"".equals(type) && //$NON-NLS-1$
      !type.equals(parms[i].getType())))
        continue;
      // parameter must not be already overridden, unless we're editing an existing one
      String override = keyName + '/' + parms[i].getName();
      if (adding && null != ParameterDelegatesSection.getOverridingParmName(override, cg))
        continue;

      TableItem tableItem = new TableItem(paramsUI, SWT.NULL);
      tableItem.setText(parms[i].getName());
      tableItem.setData(parms[i]);
    }
  }
}
 
Example 12
Source File: BonitaContentProposalAdapter.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void handleSetData(final Event event) {
    final TableItem item = (TableItem) event.item;
    final int index = proposalTable.indexOf(item);

    if (0 <= index && index < proposals.length) {
        final IContentProposal current = proposals[index];
        item.setText(getString(current));
        item.setImage(getImage(current));
        item.setData(current);
    } else {
        // this should not happen, but does on win32
    }
}
 
Example 13
Source File: KeyAssistDialog.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a dialog area with a table of the partial matches for the current
 * key binding state. The table will be either the minimum width, or
 * <code>previousWidth</code> if it is not
 * <code>NO_REMEMBERED_WIDTH</code>.
 * 
 * @param parent
 *            The parent composite for the dialog area; must not be
 *            <code>null</code>.
 * @param partialMatches
 *            The lexicographically sorted map of partial matches for the
 *            current state; must not be <code>null</code> or empty.
 */
private final void createTableDialogArea(final Composite parent) {
    // Layout the table.
    completionsTable = new Table(parent, SWT.FULL_SELECTION | SWT.SINGLE);
    final GridData gridData = new GridData(GridData.FILL_BOTH);
    completionsTable.setLayoutData(gridData);
    completionsTable.setBackground(parent.getBackground());
    completionsTable.setLinesVisible(true);

    // Initialize the columns and rows.
    bindings.clear();
    final TableColumn columnCommandName = new TableColumn(completionsTable, SWT.LEFT, 0);
    final TableColumn columnKeySequence = new TableColumn(completionsTable, SWT.LEFT, 1);
    final Iterator itemsItr = keybindingToActionInfo.entrySet().iterator();
    while (itemsItr.hasNext()) {
        final Map.Entry entry = (Entry) itemsItr.next();
        final String sequence = (String) entry.getKey();
        final ActionInfo actionInfo = (ActionInfo) entry.getValue();
        final String[] text = { sequence, actionInfo.description };
        final TableItem item = new TableItem(completionsTable, SWT.NULL);
        item.setText(text);
        item.setData("ACTION_INFO", actionInfo);
        bindings.add(actionInfo);
    }

    Dialog.applyDialogFont(parent);
    columnKeySequence.pack();
    columnCommandName.pack();

    /*
     * If you double-click on the table, it should execute the selected
     * command.
     */
    completionsTable.addListener(SWT.DefaultSelection, new Listener() {
        @Override
        public final void handleEvent(final Event event) {
            executeKeyBinding(event);
        }
    });
}
 
Example 14
Source File: AdvancedSettingsComponent.java    From aem-eclipse-developer-tools with Apache License 2.0 5 votes vote down vote up
public void updateTable() {
    Table table = propertiesViewer.getTable();
    table.setItemCount(properties.size());
    int i = 0;
    for (String key : properties.keySet()) {
    	RequiredPropertyWrapper property = properties.get(key);
    	TableItem item = table.getItem(i++);
        item.setText(0, property.getKey());
       	item.setText(1, property.getValue() != null ? property.getValue() : "");
        item.setText(2, property.getDefaultValue() != null ? property.getDefaultValue() : "");
        item.setData(item);
    }

}
 
Example 15
Source File: ColumnBrowserWidget.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Update the content of the widget
 */
void updateContent() {
	if (columns == null) {
		return;
	}

	for (int i = 0; i < columns.size(); i++) {

		final Table table = columns.get(i);
		final int index = table.getSelectionIndex();
		table.removeAll();
		if (table.getData() == null) {
			continue;
		}
		for (final ColumnItem c : ((ColumnItem) table.getData()).getItems()) {
			final TableItem item = new TableItem(table, SWT.NONE);
			item.setData(c);
			if (c.getText() != null) {
				item.setText(c.getText());
			}
			if (c.getImage() != null) {
				item.setImage(c.getImage());
			}
		}
		table.setSelection(index);
	}
}
 
Example 16
Source File: AbstractSection.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Copy table item.
 *
 * @param target the target
 * @param source the source
 */
public static void copyTableItem(TableItem target, TableItem source) {
  int columnCount = target.getParent().getColumnCount();
  for (int i = 0; i < columnCount; i++) {
    String text = source.getText(i);
    if (null != text)
      target.setText(i, text);
  }
  target.setData(source.getData());
}
 
Example 17
Source File: PTWidgetTable.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Fill Data in the widget
 */
private void fillData() {
	List<PTProperty> props;
	if (getParentPropertyTable().sorted) {
		props = new ArrayList<PTProperty>(getParentPropertyTable().getPropertiesAsList());
		Collections.sort(props, new Comparator<PTProperty>() {

			@Override
			public int compare(final PTProperty o1, final PTProperty o2) {
				if (o1 == null && o2 == null) {
					return 0;
				}

				if (o1.getName() == null && o2.getName() != null) {
					return -1;
				}

				if (o1.getName() != null && o2.getName() == null) {
					return 1;
				}

				return o1.getName().compareTo(o2.getName());
			}
		});
	} else {
		props = new ArrayList<PTProperty>(getParentPropertyTable().getPropertiesAsList());
	}

	final List<ControlEditor> editors = new ArrayList<ControlEditor>();
	for (final PTProperty p : props) {
		final TableItem item = new TableItem(table, SWT.NONE);
		item.setData(p);
		item.setText(0, StringUtil.safeToString(p.getDisplayName()));
		if (p.getEditor() == null) {
			p.setEditor(new PTStringEditor());
		}

		final ControlEditor editor = p.getEditor().render(this, item, p);
		item.addListener(SWT.Dispose, event -> {
			if (editor.getEditor() != null) {
				editor.getEditor().dispose();
			}
			editor.dispose();
		});
		if (!p.isEnabled()) {
			item.setForeground(table.getDisplay().getSystemColor(SWT.COLOR_GRAY));
		}
	}

	table.setData(editors);

}
 
Example 18
Source File: PageLoaderStrategyHelper.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * This method loads the paginated list by using the given page loader
 * {@link IPageLoader} and information about pagination from the given
 * controller {@link PageableController}. After loading paginated list
 * returned in a pagination structure {@link PageResult}, this method :
 * 
 * <ul>
 * <li>update the total elements of the given controller
 * {@link PageableController}</li>
 * <li>refresh the given {@link Viewer} by replacing data with the new
 * paginated list.</li>
 * </ul>
 * 
 * @param controller
 *            the controller to use to load paginated list and update the
 *            total elements.
 * @param viewer
 *            the viewer to refresh with new paginated list.
 * @param pageLoader
 *            the page loader used to load paginated list.
 * @pageContentProvider the page content provider to retrieves total
 *                      elements+paginated list from the page result
 *                      structure returned by the pageLoader.
 * @param handler
 *            the page loader handler to observe before/after page loading
 *            process. If null no observation is done.
 */
public static void loadPageAndAddItems(final PageableController controller,
		final TableViewer viewer, final IPageLoader<?> pageLoader,
		final IPageContentProvider pageContentProvider,
		final IPageLoaderHandler<PageableController> handler) {
	Object page = loadPageAndUpdateTotalElements(controller, pageLoader,
			pageContentProvider, handler);
	if (page != null) {
		List<?> content = pageContentProvider.getPaginatedList(page);
		if (content != null && !content.isEmpty()) {
			viewer.add(content.toArray());
			int count = viewer.getTable().getItemCount();
			if (count > 0) {
				TableItem item = viewer.getTable().getItem(count - 1);
				item.setData(LazyItemsSelectionListener.LAST_ITEM_LOADED,
						true);
			}
		}
	}
}
 
Example 19
Source File: NewCodewindProjectPage.java    From codewind-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public static void sortTable(Table table, TableColumn column) {
	TableItem[] items = table.getItems();
	int rows = items.length;
	int dir = table.getSortDirection() == SWT.DOWN ? 1 : -1;
	TableColumn currentColumn = table.getSortColumn();
	int columnNum = 0;
	for (int j = 0; j < table.getColumnCount(); j++) {
		if (table.getColumn(j).equals(column)) {
			columnNum = j;
			break;
		}
	}
	if (column.equals(currentColumn))
		dir = -dir;
	else
		dir = 1;

	// sort an index map, then move the actual rows
	int[] map = new int[rows];
	for (int i = 0; i < rows; i++)
		map[i] = i;

	for (int i = 0; i < rows - 1; i++) {
		for (int j = i + 1; j < rows; j++) {
			TableItem a = items[map[i]];
			TableItem b = items[map[j]];
			if ((a.getText(columnNum).toLowerCase().compareTo(b.getText(columnNum).toLowerCase()) * dir > 0)) {
				int t = map[i];
				map[i] = map[j];
				map[j] = t;
			}
		}
	}

	// can't move existing items or delete first, so append new items to the end and then delete existing rows
	for (int i = 0; i < rows; i++) {
		int n = map[i];
		TableItem item = new TableItem(table, SWT.NONE);
		for (int j = 0; j < table.getColumnCount(); j++) {
			item.setText(j, items[n].getText(j));
		}
		item.setData(items[n].getData());
		items[n].dispose();
	}

	table.setSortDirection(dir == 1 ? SWT.DOWN : SWT.UP);
	table.setSortColumn(column);
}
 
Example 20
Source File: FilterListDialog.java    From tracecompass with Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Constructor
 *
 * @param parent The parent table
 * @param isActive <code>true</code> if filter criteria is active else <code>false</code>
 * @param isPositive <code>true</code> for positive filter else <code>false</code>
 * @param loaderClassName The loader class name
 */
public CriteriaTableItem(Table parent, boolean isActive, boolean isPositive, String loaderClassName) {
    fTableItem = new TableItem(parent, SWT.NONE);
    fTableItem.setData(this);
    fTableItem.setChecked(isActive);
    fIsPositive = isPositive;
    fLoaderClassName = loaderClassName;
}