use of org.eclipse.swt.widgets.TreeColumn in project cogtool by cogtool.
the class ProjectUIModel method recolorTree.
public void recolorTree(int designColumn, TreeItem cellTask, boolean nowSelected) {
// Set or remove selection marker in name
TreeColumn col = tree.getColumn(designColumn);
if (nowSelected && (cellTask == null)) {
col.setText(L10N.get("PM.DesignMark", "• ") + col.getText());
} else {
col.setText(((Design) col.getData()).getName());
}
recolorItems(tree.getItems(), designColumn, nowSelected && (cellTask == null));
if (cellTask != null) {
cellTask.setBackground(designColumn, ProjectUIModel.SELECTED_CELL_COLOR);
}
}
use of org.eclipse.swt.widgets.TreeColumn in project cogtool by cogtool.
the class ProjectUIModel method addTreeColumn.
protected TreeColumn addTreeColumn(Design design, int atIndex) {
TreeColumn newColumn = new TreeColumn(tree, SWT.RIGHT, atIndex);
installTreeColumn(newColumn, design);
return newColumn;
}
use of org.eclipse.swt.widgets.TreeColumn in project translationstudio8 by heartsome.
the class KeysPreferencePage method createTree.
private void createTree(Composite parent) {
fPatternFilter = new CategoryPatternFilter(true, fDefaultCategory);
fPatternFilter.filterCategories(true);
GridData gridData;
fFilteredTree = new CategoryFilterTree(parent, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION, fPatternFilter);
final GridLayout layout = new GridLayout(1, false);
layout.marginWidth = 0;
fFilteredTree.setLayout(layout);
gridData = new GridData();
gridData.grabExcessHorizontalSpace = true;
gridData.grabExcessVerticalSpace = true;
gridData.horizontalAlignment = SWT.FILL;
gridData.verticalAlignment = SWT.FILL;
fFilteredTree.setLayoutData(gridData);
viewer = fFilteredTree.getViewer();
// Make sure the filtered tree has a height of ITEMS_TO_SHOW
final Tree tree = viewer.getTree();
tree.setHeaderVisible(true);
final Object layoutData = tree.getLayoutData();
if (layoutData instanceof GridData) {
gridData = (GridData) layoutData;
final int itemHeight = tree.getItemHeight();
if (itemHeight > 1) {
gridData.heightHint = ITEMS_TO_SHOW * itemHeight;
}
}
BindingModelComparator comparator = new BindingModelComparator();
comparator.setSortColumn(2);
viewer.setComparator(comparator);
final TreeColumn commandNameColumn = new TreeColumn(tree, SWT.LEFT, COMMAND_NAME_COLUMN);
commandNameColumn.setText(Messages.getString("preferencepage.KeysPreferencePage.commandNameColumn"));
tree.setSortColumn(commandNameColumn);
tree.setSortDirection(comparator.isAscending() ? SWT.UP : SWT.DOWN);
commandNameColumn.addSelectionListener(new ResortColumn(comparator, commandNameColumn, viewer, COMMAND_NAME_COLUMN));
final TreeViewerColumn triggerSequenceColumn = new TreeViewerColumn(viewer, SWT.LEFT, KEY_SEQUENCE_COLUMN);
triggerSequenceColumn.getColumn().setText(Messages.getString("preferencepage.KeysPreferencePage.triggerSequenceColumn"));
triggerSequenceColumn.getColumn().addSelectionListener(new ResortColumn(comparator, triggerSequenceColumn.getColumn(), viewer, KEY_SEQUENCE_COLUMN));
triggerSequenceColumn.setEditingSupport(new TableViewerEditingSupport(viewer, 1));
final TreeColumn categoryColumn = new TreeColumn(tree, SWT.LEFT, CATEGORY_COLUMN);
categoryColumn.setText(Messages.getString("preferencepage.KeysPreferencePage.categoryColumn"));
categoryColumn.addSelectionListener(new ResortColumn(comparator, categoryColumn, viewer, CATEGORY_COLUMN));
viewer.setContentProvider(new ModelContentProvider());
viewer.setLabelProvider(new BindingElementLabelProvider());
fFilteredTree.getPatternFilter().setIncludeLeadingWildcard(true);
final TreeColumn[] columns = viewer.getTree().getColumns();
columns[COMMAND_NAME_COLUMN].setWidth(240);
columns[KEY_SEQUENCE_COLUMN].setWidth(130);
columns[CATEGORY_COLUMN].setWidth(130);
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
// When the viewer changes selection, update the model's current
// selection
public void selectionChanged(SelectionChangedEvent event) {
changeBackground();
ModelElement binding = (ModelElement) ((IStructuredSelection) event.getSelection()).getFirstElement();
model.setSelectedElement(binding);
}
});
IPropertyChangeListener treeUpdateListener = new IPropertyChangeListener() {
// When the model changes a property, update the viewer
public void propertyChange(PropertyChangeEvent event) {
if (event.getSource() == model && CommonModel.PROP_SELECTED_ELEMENT.equals(event.getProperty())) {
Object newVal = event.getNewValue();
StructuredSelection structuredSelection = newVal == null ? null : new StructuredSelection(newVal);
viewer.setSelection(structuredSelection, true);
} else if (event.getSource() instanceof BindingElement && ModelElement.PROP_MODEL_OBJECT.equals(event.getProperty())) {
viewer.update(event.getSource(), null);
} else if (BindingElement.PROP_CONFLICT.equals(event.getProperty())) {
viewer.update(event.getSource(), null);
} else if (BindingModel.PROP_BINDINGS.equals(event.getProperty())) {
// viewer.refresh();
} else if (BindingModel.PROP_BINDING_ADD.equals(event.getProperty())) {
viewer.add(model, event.getNewValue());
} else if (BindingModel.PROP_BINDING_REMOVE.equals(event.getProperty())) {
viewer.remove(event.getNewValue());
} else if (BindingModel.PROP_BINDING_FILTER.equals(event.getProperty())) {
// viewer.refresh();
}
changeBackground();
// isValid();
}
};
keyController.addPropertyChangeListener(treeUpdateListener);
// IPropertyChangeListener conflictsListener = new IPropertyChangeListener() {
// public void propertyChange(PropertyChangeEvent event) {
// // System.out.println(event.getNewValue().getClass());
// if (keyController.getConflictModel().getConflicts() != null) {
// if (ConflictModel.PROP_CONFLICTS.equals(event.getProperty())) {
// // lstConflict.clear();
// if (event.getNewValue() != null) {
// lstConflict.addAll((Collection<? extends Object>) event.getNewValue());
// }
// // conflictViewer.setInput(event.getNewValue());
// } else if (ConflictModel.PROP_CONFLICTS_ADD.equals(event.getProperty())) {
// if (event.getNewValue() != null) {
// lstConflict.add(event.getNewValue());
// }
// // conflictViewer.add(event.getNewValue());
// } else if (ConflictModel.PROP_CONFLICTS_REMOVE.equals(event.getProperty())) {
// // conflictViewer.remove(event.getNewValue());
// if (event.getNewValue() != null) {
// lstConflict.remove(event.getNewValue());
// }
// }
// } else {
// lstConflict.clear();
// }
// // if (event.getSource() == keyController.getConflictModel()
// // && CommonModel.PROP_SELECTED_ELEMENT.equals(event.getProperty())) {
// // if (keyController.getConflictModel().getConflicts() != null) {
// // Object newVal = event.getNewValue();
// // StructuredSelection structuredSelection = newVal == null ? null : new StructuredSelection(
// // newVal);
// // // conflictViewer.setSelection(structuredSelection, true);
// // }
// // } else if (ConflictModel.PROP_CONFLICTS.equals(event.getProperty())) {
// // // lstConflict.clear();
// // if (event.getNewValue() != null) {
// // lstConflict.addAll((Collection<? extends Object>) event.getNewValue());
// // }
// // // conflictViewer.setInput(event.getNewValue());
// // } else if (ConflictModel.PROP_CONFLICTS_ADD.equals(event.getProperty())) {
// // if (event.getNewValue() != null) {
// // lstConflict.clear();
// // lstConflict.add(event.getNewValue());
// // }
// // // conflictViewer.add(event.getNewValue());
// // } else if (ConflictModel.PROP_CONFLICTS_REMOVE.equals(event.getProperty())) {
// // // conflictViewer.remove(event.getNewValue());
// // if (event.getNewValue() != null) {
// // lstConflict.clear();
// // lstConflict.remove(event.getNewValue());
// // }
// // }
// }
// };
// keyController.addPropertyChangeListener(conflictsListener);
IPropertyChangeListener dataUpdateListener = new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
BindingElement bindingElement = null;
boolean weCare = false;
if (event.getSource() == model && CommonModel.PROP_SELECTED_ELEMENT.equals(event.getProperty())) {
bindingElement = (BindingElement) event.getNewValue();
weCare = true;
} else if (event.getSource() == model.getSelectedElement() && ModelElement.PROP_MODEL_OBJECT.equals(event.getProperty())) {
bindingElement = (BindingElement) event.getSource();
weCare = true;
}
if (bindingElement == null && weCare) {
//$NON-NLS-1$
fBindingText.setText("");
} else if (bindingElement != null) {
KeySequence trigger = (KeySequence) bindingElement.getTrigger();
fKeySequenceText.setKeySequence(trigger);
}
}
};
keyController.addPropertyChangeListener(dataUpdateListener);
}
use of org.eclipse.swt.widgets.TreeColumn in project translationstudio8 by heartsome.
the class LanguageCodesPreferencePage method createFilterControls.
/**
* 创建包含过滤文本的 TreeViewer
* @param parent
* 顶层容器 ;
*/
private void createFilterControls(Composite parent) {
fFilteredTree = new FilteredTree(parent, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION, new PatternFilter(), true);
GridData gridData;
final GridLayout layout = new GridLayout(1, false);
layout.marginWidth = 0;
fFilteredTree.setLayout(layout);
gridData = new GridData();
gridData.grabExcessHorizontalSpace = true;
gridData.grabExcessVerticalSpace = true;
gridData.horizontalAlignment = SWT.FILL;
gridData.verticalAlignment = SWT.FILL;
fFilteredTree.setLayoutData(gridData);
final TreeViewer viewer = fFilteredTree.getViewer();
// 确保 filtered tree 有显示 ITEMS_TO_SHOW 的高度
final Tree tree = viewer.getTree();
tree.setHeaderVisible(true);
tree.setLinesVisible(true);
final Object layoutData = tree.getLayoutData();
if (layoutData instanceof GridData) {
gridData = (GridData) layoutData;
// 适应大小
gridData.heightHint = parent.getSize().y;
}
LanguageCodeComparator comparator = new LanguageCodeComparator();
final TreeColumn codeColumn = new TreeColumn(tree, SWT.LEFT, LANGUAGE_CODE_COLUMN);
codeColumn.setText(Messages.getString("languagecode.LanguageCodesPreferencePage.codeColumn"));
tree.setSortColumn(codeColumn);
tree.setSortColumn(codeColumn);
tree.setSortDirection(SWT.UP);
codeColumn.addSelectionListener(new ResortColumn(comparator, codeColumn, viewer, LANGUAGE_CODE_COLUMN));
final TreeColumn nameColumn = new TreeColumn(tree, SWT.LEFT, LANGUAGE_NAME_COLUMN);
nameColumn.setText(Messages.getString("languagecode.LanguageCodesPreferencePage.nameColumn"));
nameColumn.addSelectionListener(new ResortColumn(comparator, nameColumn, viewer, LANGUAGE_NAME_COLUMN));
final TreeColumn bidiColumn = new TreeColumn(tree, SWT.LEFT, LANGUAGE_BIDI_COLUMN);
bidiColumn.setText(Messages.getString("languagecode.LanguageCodesPreferencePage.bidiColumn"));
bidiColumn.addSelectionListener(new ResortColumn(comparator, bidiColumn, viewer, LANGUAGE_BIDI_COLUMN));
viewer.setContentProvider(new LanguageCodeContentProvider());
viewer.setLabelProvider(new LanguageCodeLabelProvider());
viewer.setComparator(comparator);
viewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
verifyCurrentSelected(EDIT);
}
});
fFilteredTree.getPatternFilter().setIncludeLeadingWildcard(true);
final TreeColumn[] columns = viewer.getTree().getColumns();
columns[LANGUAGE_CODE_COLUMN].setWidth(100);
columns[LANGUAGE_NAME_COLUMN].setWidth(240);
columns[LANGUAGE_BIDI_COLUMN].setWidth(100);
}
use of org.eclipse.swt.widgets.TreeColumn in project translationstudio8 by heartsome.
the class UpdateWizardPage method createControl.
public void createControl(final Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout gridLayout = new GridLayout();
gridLayout.marginWidth = 0;
gridLayout.marginHeight = 0;
composite.setLayout(gridLayout);
treeViewer = new TreeViewer(composite, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
GridData data = new GridData(GridData.FILL_BOTH);
Tree tree = treeViewer.getTree();
tree.setLayoutData(data);
tree.setHeaderVisible(true);
IUColumnConfig[] columns = getColumnConfig();
for (int i = 0; i < columns.length; i++) {
TreeColumn tc = new TreeColumn(tree, SWT.LEFT, i);
tc.setResizable(true);
tc.setText(columns[i].getColumnTitle());
tc.setWidth(columns[i].getWidthInPixels(tree));
}
contentProvider = new ProvElementContentProvider();
treeViewer.setContentProvider(contentProvider);
labelProvider = new IUDetailsLabelProvider(null, getColumnConfig(), getShell());
treeViewer.setLabelProvider(labelProvider);
setControl(composite);
final Runnable runnable = new Runnable() {
public void run() {
// updateStatus(input, operation);
setDrilldownElements(input, operation);
treeViewer.setInput(input);
}
};
if (operation != null && !operation.hasResolved()) {
try {
getContainer().run(true, false, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) {
operation.resolveModal(monitor);
parent.getDisplay().asyncExec(runnable);
}
});
} catch (Exception e) {
StatusManager.getManager().handle(new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, e.getMessage(), e));
}
} else {
runnable.run();
}
}
Aggregations