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

The following examples show how to use org.eclipse.swt.widgets.TableItem#setImage() . 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: 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 2
Source File: LinkManagementComposite.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
private void createItems() {
	// Create the items for the table.
	linkTable.removeAll();
	for (LinkEntry linkEntry : linkEntries) {
		TableItem item = new TableItem(linkTable, SWT.NONE);
		item.setData(linkEntry);
		if (linkEntry.targetApp != null) {
			item.setText(0, linkEntry.targetApp.name);
		} else {
			String text = Messages.LinkMgmtErrorTargetMissing;
			String projectName = linkEntry.info == null ? null : linkEntry.info.getProjectName();
			if (projectName != null && !projectName.isEmpty()) {
				text += " (" + projectName + ")";
			}
			item.setText(0, text);
			item.setImage(0, PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK));
		}
		item.setText(1, linkEntry.envVar);
	}
}
 
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: DualList.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Fill a table with data
 *
 * @param table table to be filled
 * @param listOfData list of data
 */
private void fillData(final Table table, final List<DLItem> listOfData) {
	final boolean itemsContainImage = itemsContainImage();
	for (final DLItem item : listOfData) {
		final TableItem tableItem = new TableItem(table, SWT.NONE);
		tableItem.setData(item);

		if (item.getBackground() != null) {
			tableItem.setBackground(item.getBackground());
		}

		if (item.getForeground() != null) {
			tableItem.setForeground(item.getForeground());
		}

		if (item.getImage() != null) {
			tableItem.setImage(0, item.getImage());
		}

		if (item.getFont() != null) {
			tableItem.setFont(item.getFont());
		}
		final int textColumn = itemsContainImage ? 1 : 0;
		tableItem.setText(textColumn, item.getText());
	}
}
 
Example 5
Source File: TableComboFieldEditor.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
protected TableCombo getComboBoxControl(Composite parent) {
    if (fCombo == null) {
        fCombo = new TableCombo(parent, SWT.READ_ONLY | SWT.BORDER);
        fCombo.setShowTableHeader(false);
        fCombo.setFont(parent.getFont());
        fCombo.defineColumns(new int[] { 100 });
        for (int i = 0; i < fEntryNamesAndValues.length; i++) {
            TableItem tableItem = new TableItem(fCombo.getTable(), SWT.NONE);
            tableItem.setText((String) fEntryNamesAndValues[i][0]);
            tableItem.setImage((Image) fEntryNamesAndValues[i][2]);
        }

        fCombo.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent evt) {
                String oldValue = fValue;
                String name = fCombo.getText();
                fValue = getValueForName(name);
                setPresentsDefaultValue(false);
                fireValueChanged(VALUE, oldValue, fValue);
            }
        });
    }
    return fCombo;
}
 
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: ConversionProblemsDialog.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
private void addProblemItem(String problem) {
	if (problemsTable == null || problemsTable.isDisposed())
		return;
	TableItem ti = new TableItem(problemsTable, SWT.NONE);
	ti.setImage(errorImage);
	ti.setText(problem);
}
 
Example 8
Source File: ERTableComposite.java    From erflute with Apache License 2.0 5 votes vote down vote up
private void column2TableItem(ERColumn column, TableItem tableItem) {
    disposeCheckBox(column);

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

        final NormalColumn normalColumn = (NormalColumn) column;

        if (normalColumn.isPrimaryKey()) {
            tableItem.setImage(0, Activator.getImage(ImageKey.PRIMARY_KEY));
        } else {
            tableItem.setImage(0, null);
        }

        if (normalColumn.isForeignKey()) {
            tableItem.setImage(1, Activator.getImage(ImageKey.FOREIGN_KEY));
        } else {
            tableItem.setImage(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()));

        setTableEditor(normalColumn, tableItem);
    } else {
        tableItem.setBackground(ColorConstants.white);
        tableItem.setImage(0, Activator.getImage(ImageKey.GROUP));
        tableItem.setImage(1, null);
        tableItem.setText(2, column.getName());
        tableItem.setText(3, "");
        tableItem.setText(4, "");
    }
}
 
Example 9
Source File: TableComboViewer.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void doResetItem(Item item) {
    TableItem tableItem = (TableItem) item;
    int columnCount = Math.max(1, tableCombo.getTable().getColumnCount());
    for (int i = 0; i < columnCount; i++) {
        tableItem.setText(i, ""); //$NON-NLS-1$
        if (tableItem.getImage(i) != null) {
            tableItem.setImage(i, null);
        }
    }
}
 
Example 10
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 11
Source File: ViewList.java    From arx with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an item in the list.
 *
 * @param item
 * @param index
 */
private void createItem(final TableItem item, final int index) {

    final ARXNode node = list.get(index);

    final String transformation = Arrays.toString(node.getTransformation());
    item.setText(0, transformation);

    final String anonymity = node.getAnonymity().toString();
    item.setText(2, anonymity);

    String min = null;
    if (node.getLowestScore() != null) {
        min = node.getLowestScore().toString() +
              " [" + SWTUtil.getPrettyString(asRelativeValue(node.getLowestScore())) + "%]"; //$NON-NLS-1$ //$NON-NLS-2$
    } else {
        min = Resources.getMessage("ListView.7"); //$NON-NLS-1$
    }
    item.setText(4, min);
    String max = null;
    if (node.getHighestScore() != null) {
        max = node.getHighestScore().toString() +
              " [" + SWTUtil.getPrettyString(asRelativeValue(node.getHighestScore())) + "%]"; //$NON-NLS-1$ //$NON-NLS-2$
    } else {
        max = Resources.getMessage("ListView.10"); //$NON-NLS-1$
    }
    item.setText(5, max);
    item.setData(node);

    item.setImage(1, getSymbol(super.getInnerColor(node)));
    item.setImage(3, getSymbol(super.getUtilityColor(node)));
    
    this.background = this.background != null ? this.background : item.getBackground();
}
 
Example 12
Source File: TmfEventsTable.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Set the item data of the header row.
 *
 * @param item
 *            The item to use as table header
 */
protected void setHeaderRowItemData(final TableItem item) {
    if (fHeaderState == HeaderState.NO_SEARCH) {
        item.setImage(SEARCH_IMAGE);
    } else if (fHeaderState == HeaderState.SEARCH) {
        item.setImage(FILTER_ADD_IMAGE);
    }
    item.setForeground(fGrayColor);
    // Ignore collapse and image column
    for (int i = EVENT_COLUMNS_START_INDEX; i < fTable.getColumns().length; i++) {
        final TableColumn column = fTable.getColumns()[i];
        final String filter = (String) column.getData(Key.SEARCH_TXT);
        if (filter == null) {
            item.setText(i, SEARCH_HINT);
            item.setForeground(i, fGrayColor);
            item.setFont(i, fFont);
        } else {
            item.setText(i, filter);
            item.setForeground(i, fGreenColor);
            item.setFont(i, fBoldFont);
        }
    }
    if (!fPackMarginDone) {
        packMarginColumn();
        fPackMarginDone = true;
    }
}
 
Example 13
Source File: AggregateSection.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * adds a tableItem to the table.
 *
 * @param o the o
 * @param keyName the key name
 */
private void addFile(Object o, String keyName) {
  Import impItem = (Import) o;
  String fileName = impItem.getLocation();
  if (null == fileName || (0 == fileName.length()))
    fileName = impItem.getName();
  // create new TableItem
  TableItem item = new TableItem(filesTable, SWT.NONE);
  item.setImage(TAEConfiguratorPlugin.getImage(TAEConfiguratorPlugin.IMAGE_ANNOTATOR));
  item.setText(0, fileName);
  item.setText(1, keyName);
}
 
Example 14
Source File: TypeInfoViewer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void fillDashLine(TableItem item) {
	Rectangle bounds= item.getImageBounds(0);
	Rectangle area= fTable.getBounds();
	boolean willHaveScrollBar= fExpectedItemCount + 1 > fNumberOfVisibleItems;
	item.setText(fDashLine.getText(area.width - bounds.x - bounds.width - fTableWidthDelta -
		(willHaveScrollBar ? fScrollbarWidth : 0)));
	item.setImage(fSeparatorIcon);
	item.setForeground(fDashLineColor);
	item.setData(fDashLine);
}
 
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: TaskSelectType.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 
 */
protected void populateChartTypes( )
{
	ChartUIUtil.populateTypeTable( getContext( ) );
	Iterator<String> iter = ChartUIUtil.getChartTypeNameIterator( );
	while ( iter.hasNext( ) )
	{
		String sTypeTmp = iter.next( );
		TableItem tItem = new TableItem( table, SWT.NONE );
		tItem.setText( LEADING_BLANKS
				+ ( ChartUIUtil.getChartType( sTypeTmp ) ).getDisplayName( ) );
		tItem.setData( ( ChartUIUtil.getChartType( sTypeTmp ) ).getName( ) );
		tItem.setImage( ( ChartUIUtil.getChartType( sTypeTmp ) ).getImage( ) );
	}
}
 
Example 17
Source File: HopGitPerspective.java    From hop with Apache License 2.0 5 votes vote down vote up
private void refreshChangedTable() {
  changedTable.removeAll();

  changedFiles = new ArrayList<>();
  boolean allowChecking;
  if ( isOnlyWIP() ) {
    // Work in progress, not a committed revision
    //
    authorNameTextbox.setText( Const.NVL( vcs.getAuthorName( IVCS.WORKINGTREE ), "" ) );
    commitMessageTextbox.setText( Const.NVL( vcs.getCommitMessage( IVCS.WORKINGTREE ), "" ) );
    changedFiles.addAll( vcs.getUnstagedFiles() );
    changedFiles.addAll( vcs.getStagedFiles() );
    allowChecking = true;
  } else {
    String commitId = revisions.get( revisionTable.getSelectionIndex() ).getRevisionId();
    authorNameTextbox.setText( Const.NVL( vcs.getAuthorName( commitId ), "" ) );
    commitMessageTextbox.setText( Const.NVL( vcs.getCommitMessage( commitId ), "" ) );
    changedFiles.addAll( vcs.getStagedFiles( vcs.getParentCommitId( commitId ), commitId ) );
    allowChecking = false;
  }

  addChangedTable( allowChecking );
  for ( UIFile changedFile : changedFiles ) {
    TableItem item = new TableItem( changedTable, SWT.NONE );
    item.setChecked( false );
    switch ( changedFile.getChangeType() ) {
      case MODIFY:
        item.setImage( 1, imageChanged ); break;
      case ADD:
        item.setImage( 1, imageAdded ); break;
      case DELETE:
        item.setImage( 1, imageRemoved ); break;
      default:
        item.setText( 1, changedFile.getChangeType().name() );
        break;
    }
    item.setText( 2, changedFile.getIsStaged() ? "Staged" : "" );
    item.setText( 3, changedFile.getName() );
  }
}
 
Example 18
Source File: HistoryFilteredList.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
    if (fTable.isDisposed()) {
        return Status.CANCEL_STATUS;
    }
    int itemCount = fTable.getItemCount();

    // Remove excess items
    if (fCount < itemCount) {
        fTable.setRedraw(false);
        fTable.remove(fCount, itemCount - 1);
        fTable.setRedraw(true);
        itemCount = fTable.getItemCount();
    }
    // table empty -> no selection
    if (fCount == 0) {
        fTable.notifyListeners(SWT.Selection, new Event());
        return Status.OK_STATUS;
    }
    // How many we are going to do this time.
    int iterations = Math.min(250, fCount - currentIndex);
    for (int i = 0; i < iterations; i++) {
        if (monitor.isCanceled()) {
            return Status.CANCEL_STATUS;
        }
        final TableItem item = (currentIndex < itemCount) ? fTable.getItem(currentIndex) : new TableItem(
                fTable, SWT.NONE);
        final Label label = fLabels[fFilteredIndices[fFoldedIndices[currentIndex]]];
        item.setText(label.string);
        item.setImage(label.image);
        currentIndex++;
    }
    if (monitor.isCanceled()) {
        return Status.CANCEL_STATUS;
    }
    if (currentIndex < fCount) {
        schedule(0);
    } else {
        if (indicesToSelect == null) {
            // Make a default selection in the table if there is none.
            // If a selection has already been made, honor it.
            // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=112146
            if (fCount > 0) {
                if (fTable.getSelectionIndices().length == 0) {
                    defaultSelect();
                } else {
                    // There is a selection, but it likely hasn't changed since the
                    // job started.  Force a selection notification, since the
                    // items represented by the selection have changed.
                    // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=119456
                    fTable.notifyListeners(SWT.Selection, new Event());
                }
            }
        } else {
            // Set the selection as indicated.
            selectAndNotify(indicesToSelect);
        }
        // This flag signifies that the selection can now be directly
        // updated in the widget.
        readyForSelection = true;
    }
    return Status.OK_STATUS;
}
 
Example 19
Source File: FlowSection.java    From uima-uimaj with Apache License 2.0 4 votes vote down vote up
@Override
public void refresh() {
  super.refresh();

  flowList.removeAll();
  if (!isAggregate()) {
    getSection().setText(Messages.getString("FlowSection.notUsed")); //$NON-NLS-1$
    getSection().setDescription(Messages.getString("FlowSection.onlyForAggregates")); //$NON-NLS-1$
  } else {
    getSection().setText(Messages.getString("FlowSection.ComponentEngineFlowTitle")); //$NON-NLS-1$
    getSection().setDescription(Messages.getString("FlowSection.ComponentEngineFlowDescription")); //$NON-NLS-1$

    FlowControllerDeclaration fcd = getFlowControllerDeclaration();
    flowList.setEnabled(true);
    FlowConstraints flowConstraints = getModelFlow();
    FlowNodes nodesModel = new FlowNodes(flowConstraints);
    String[] nodes = nodesModel.getFlow();
    if (null == nodes)
      nodesModel.setFlow(nodes = stringArray0);
    // add them to the list
    for (int i = 0; i < nodes.length; i++) {
      TableItem item = new TableItem(flowList, SWT.NONE);
      item.setImage(TAEConfiguratorPlugin.getImage(TAEConfiguratorPlugin.IMAGE_ANNOTATOR) 
              );
      item.setText(0, nodes[i]);
    }
    packTable(flowList);

    if (null == fcd) {
      // Not a custom, user-defined flow
      FixedFlow ff;
      if (null == flowConstraints) {
        // force fixed flow if nothing is specified
        getAnalysisEngineMetaData().setFlowConstraints(
                flowConstraints = ff = new FixedFlow_impl());
        ff.setFixedFlow(stringArray0);
      }
      String modelFlowType = flowConstraints.getFlowConstraintsType();

      flowControllerChoice.setText(modelFlowType
              .equals(CapabilityLanguageFlow.FLOW_CONSTRAINTS_TYPE) ? CAPABILITY_LANGUAGE_FLOW
              : FIXED_FLOW);

      enableFlowControllerGUI(false);
    } else {
      // User-specified Flow Controller defined
      refreshFcd(fcd);
    }
  }
  enable();
}
 
Example 20
Source File: ERTableComposite.java    From ermaster-b with Apache License 2.0 4 votes vote down vote up
private void column2TableItem(Column column, TableItem tableItem) {
	this.disposeCheckBox(column);

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

		NormalColumn normalColumn = (NormalColumn) column;

		if (normalColumn.isPrimaryKey()) {
			tableItem.setImage(0, Activator.getImage(ImageKey.PRIMARY_KEY));
		} else {
			tableItem.setImage(0, null);
		}

		if (normalColumn.isForeignKey()) {
			tableItem.setImage(1, Activator.getImage(ImageKey.FOREIGN_KEY));
		} else {
			tableItem.setImage(1, null);
		}

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

		SqlType sqlType = normalColumn.getType();

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

		this.setTableEditor(normalColumn, tableItem);

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