org.eclipse.swt.widgets.Table#getItemCount ( )源码实例Demo

下面列出了org.eclipse.swt.widgets.Table#getItemCount ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: xds-ide   文件: ModulaContentAssistant.java
private void selectProposal(ICompletionProposal proposal) {
	try{
		Object fProposalPopup = ReflectionUtils.getField(this.getClass(), "fProposalPopup", this, true);
		Object fProposalTable = ReflectionUtils.getField(fProposalPopup.getClass(), "fProposalTable", fProposalPopup, true);
		if (fProposalTable instanceof Table) {
			Table table = (Table) fProposalTable;
			int i = 0; 
			for (;i < table.getItemCount(); i++) {
				TableItem item = table.getItem(i);
				if (Objects.equals(item.getData(), proposal)) {
					break;
				}
			}
			if (i < table.getItemCount()) {
				Method selectMethod = ReflectionUtils.findMethod(fProposalPopup.getClass(), "selectProposal", int.class, boolean.class);
				ReflectionUtils.invokeMethod(selectMethod, fProposalPopup, i, false);
			}
		}
	}
	catch(AssertionError e) {
	}
}
 
源代码2 项目: jenerate   文件: OrderableFieldDialogImpl.java
/**
 * Move the current selection in the field list down.
 */
private void moveSelectionDown() {
    Table builderTable = fieldViewer.getTable();
    int indices[] = builderTable.getSelectionIndices();
    if (indices.length < 1) {
        return;
    }
    int newSelection[] = new int[indices.length];
    int max = builderTable.getItemCount() - 1;
    for (int i = indices.length - 1; i >= 0; i--) {
        int index = indices[i];
        if (index < max) {
            move(builderTable.getItem(index), index + 1);
            newSelection[i] = index + 1;
        }
    }
    builderTable.setSelection(newSelection);
}
 
源代码3 项目: tracecompass   文件: ExportToTsvUtils.java
/**
 * Export content of a table to TSV file
 * @param table
 *              the table to export
 * @param stream
 *              the output stream
 */
public static void exportTableToTsv(Table table, @Nullable OutputStream stream) {
    if (table == null || stream == null) {
        return;
    }
    try (PrintWriter pw = new PrintWriter(stream)) {
        int size = table.getItemCount();
        List<String> columns = new ArrayList<>();
        for (int i = 0; i < table.getColumnCount(); i++) {
            TableColumn column = table.getColumn(i);
            if (column == null) {
                return;
            }
            String columnName = String.valueOf(column.getText());
            if (columnName.isEmpty() && i == table.getColumnCount() - 1) {
                // Linux GTK2 undocumented feature
                break;
            }
            columns.add(columnName);
        }
        pw.println(Joiner.on('\t').join(columns));
        for (int i = 0; i < size; i++) {
            TableItem item = table.getItem(i);
            if (item == null) {
                continue;
            }
            List<String> data = new ArrayList<>();
            for (int col = 0; col < columns.size(); col++) {
                data.add(String.valueOf(item.getText(col)));
            }
            pw.println(Joiner.on('\t').join(data));
        }
    }
}
 
源代码4 项目: jenerate   文件: OrderableFieldDialogImpl.java
private void handleTableSelectionChanged() {
    Table fieldTable = fieldViewer.getTable();
    TableItem[] items = fieldTable.getSelection();
    boolean validSelection = items != null && items.length > 0;
    boolean enableUp = validSelection;
    boolean enableDown = validSelection;
    if (validSelection) {
        int indices[] = fieldTable.getSelectionIndices();
        int max = fieldTable.getItemCount();
        enableUp = indices[0] != 0;
        enableDown = indices[indices.length - 1] < max - 1;
    }
    upButton.setEnabled(enableUp);
    downButton.setEnabled(enableDown);
}
 
private int getAddLimit() {
	int limit= getPage().getElementLimit().intValue();
	if (limit != -1) {
		Table table= (Table) getPage().getViewer().getControl();
		int itemCount= table.getItemCount();
		if (itemCount >= limit) {
			return 0;
		}
		return limit - itemCount;
	}
	return Integer.MAX_VALUE;
}
 
源代码6 项目: JDeodorant   文件: FeatureEnvy.java
private void saveResults() {
	FileDialog fd = new FileDialog(getSite().getWorkbenchWindow().getShell(), SWT.SAVE);
	fd.setText("Save Results");
	String[] filterExt = { "*.txt" };
	fd.setFilterExtensions(filterExt);
	String selected = fd.open();
	if(selected != null) {
		try {
			BufferedWriter out = new BufferedWriter(new FileWriter(selected));
			Table table = tableViewer.getTable();
			TableColumn[] columns = table.getColumns();
			for(int i=0; i<columns.length; i++) {
				if(i == columns.length-1)
					out.write(columns[i].getText());
				else
					out.write(columns[i].getText() + "\t");
			}
			out.newLine();
			for(int i=0; i<table.getItemCount(); i++) {
				TableItem tableItem = table.getItem(i);
				for(int j=0; j<table.getColumnCount(); j++) {
					if(j == table.getColumnCount()-1)
						out.write(tableItem.getText(j));
					else
						out.write(tableItem.getText(j) + "\t");
				}
				out.newLine();
			}
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
 
源代码7 项目: JDeodorant   文件: FeatureEnvy.java
public void setSelectedLine(final CandidateRefactoring candidateRefactoring) {
	Table table = tableViewer.getTable();
	for(int i=0; i<table.getItemCount(); i++) {
		Object tableElement = tableViewer.getElementAt(i);
		CandidateRefactoring candidate = (CandidateRefactoring)tableElement;
		if(candidate.equals(candidateRefactoring)) {
			table.setSelection(i);
			break;
		}
	}
}
 
源代码8 项目: arx   文件: ViewAttributeList.java
/**
 * Update
 * @param attribute
 */
private void updateSelectedAttribute(String attribute) {
    if (model != null && model.getInputConfig() != null && model.getInputConfig().getInput() != null) {
        Table table = this.table.getViewer().getTable();
        for (int i=0; i < table.getItemCount(); i++) {
            TableItem item = table.getItem(i);
            if (item.getData().equals(attribute)) {
                table.select(i);
                break;
            }
        }
    }
}
 
源代码9 项目: xds-ide   文件: UiUtils.java
public static void setEnabled(Table table, boolean isEnabled){
  for (int i = 0; i < table.getItemCount(); i++) {
    table.getItem(i).setGrayed(!isEnabled);
  }
}
 
源代码10 项目: xds-ide   文件: UiUtils.java
public static void setDataColumnBackground(Table table, int columnIdx, Color color){
  for (int i = 0; i < table.getItemCount(); i++) {
    table.getItem(i).setBackground(columnIdx, color);
  }
}
 
源代码11 项目: xds-ide   文件: SwtUtils.java
public static void setEnabled(Table table, boolean isEnabled) {
	for (int i = 0; i < table.getItemCount(); i++) {
		table.getItem(i).setGrayed(!isEnabled);
	}
}
 
源代码12 项目: xds-ide   文件: SwtUtils.java
public static void setDataColumnBackground(Table table, int columnIdx,
		Color color) {
	for (int i = 0; i < table.getItemCount(); i++) {
		table.getItem(i).setBackground(columnIdx, color);
	}
}
 
/**
 * Handle table selection. In case it's a single selection, enable/disable the 'Up' and 'Down' buttons according to
 * the selection. We only allow up and down for checked items.
 */
private void handleTableSelection()
{
	ISelection selection = tableViewer.getSelection();
	if (selection instanceof StructuredSelection)
	{
		StructuredSelection structuredSelection = (StructuredSelection) selection;
		Table table = tableViewer.getTable();
		if (structuredSelection.size() == 1 && table.getItemCount() > 1)
		{
			int selectionIndex = table.getSelectionIndex();
			TableItem item = table.getItem(selectionIndex);
			IBuildPathEntry data = (IBuildPathEntry) item.getData();
			if (item.getChecked())
			{
				upButton.setEnabled(selectionIndex != 0);
				downButton.setEnabled(selectionIndex < table.getItemCount() - 1
						&& selectionIndex < tableViewer.getCheckedElements().length - 1);
				if (!selectedEntries.contains(data))
				{
					selectedEntries.add(data);
					tableViewer.refresh();
				}
			}
			else
			{
				if (selectedEntries.contains(data))
				{
					selectedEntries.remove(data);
					tableViewer.refresh();
				}
				upButton.setEnabled(false);
				downButton.setEnabled(false);
			}
		}
		else
		{
			upButton.setEnabled(false);
			downButton.setEnabled(false);
		}
	}
}