use of org.eclipse.swt.widgets.TreeItem in project translationstudio8 by heartsome.
the class ColumnChooserDialog method selectedTreeExpanded.
private void selectedTreeExpanded(TreeEvent event) {
TreeItem item = (TreeItem) event.item;
ColumnGroupEntry columnGroupEntry = (ColumnGroupEntry) item.getData();
fireGroupExpanded(columnGroupEntry);
}
use of org.eclipse.swt.widgets.TreeItem in project translationstudio8 by heartsome.
the class ColumnChooserDialog method setSelectionIncludingNested.
/**
* Mark the leaves with matching column entries as selected.
* Also checks all the children of the column group leaves
* @param columnEntryIndexes index of the ColumnEntry in the leaf
*/
private void setSelectionIncludingNested(Tree tree, List<Integer> columnEntryIndexes) {
Collection<TreeItem> allLeaves = ArrayUtil.asCollection(tree.getItems());
List<TreeItem> selectedLeaves = new ArrayList<TreeItem>();
for (TreeItem leaf : allLeaves) {
if (!isColumnGroupLeaf(leaf)) {
int index = getColumnEntryInLeaf(leaf).getIndex().intValue();
if (columnEntryIndexes.contains(Integer.valueOf(index))) {
selectedLeaves.add(leaf);
}
} else {
//Check all children in column groups
Collection<TreeItem> columnGroupLeaves = ArrayUtil.asCollection(leaf.getItems());
for (TreeItem columnGroupLeaf : columnGroupLeaves) {
int index = getColumnEntryInLeaf(columnGroupLeaf).getIndex().intValue();
if (columnEntryIndexes.contains(Integer.valueOf(index))) {
selectedLeaves.add(columnGroupLeaf);
}
}
}
}
tree.setSelection(selectedLeaves.toArray(new TreeItem[] {}));
setGroupsSelectionIfRequired(tree, columnEntryIndexes);
tree.showSelection();
}
use of org.eclipse.swt.widgets.TreeItem in project translationstudio8 by heartsome.
the class ColumnChooserDialog method getIndexesOfSelectedLeaves.
// Leaf related methods
/**
* Get Leaf index of the selected leaves in the tree
*/
protected List<Integer> getIndexesOfSelectedLeaves(Tree tree) {
List<TreeItem> allSelectedLeaves = ArrayUtil.asList(tree.getSelection());
List<Integer> allSelectedIndexes = new ArrayList<Integer>();
for (TreeItem selectedLeaf : allSelectedLeaves) {
allSelectedIndexes.add(Integer.valueOf(tree.indexOf(selectedLeaf)));
}
return allSelectedIndexes;
}
use of org.eclipse.swt.widgets.TreeItem in project translationstudio8 by heartsome.
the class ColumnChooserDialog method selectedTreeCollapsed.
private void selectedTreeCollapsed(TreeEvent event) {
TreeItem item = (TreeItem) event.item;
ColumnGroupEntry columnGroupEntry = (ColumnGroupEntry) item.getData();
fireGroupCollapsed(columnGroupEntry);
}
use of org.eclipse.swt.widgets.TreeItem in project translationstudio8 by heartsome.
the class PluginHelpDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite tparent = (Composite) super.createDialogArea(parent);
GridLayoutFactory.swtDefaults().spacing(0, 0).numColumns(1).applyTo(tparent);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(tparent);
createMenu();
createToolBar(tparent);
mainSash = new SashForm(tparent, SWT.NONE);
mainSash.setOrientation(SWT.HORIZONTAL);
GridLayout layout = new GridLayout(1, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
mainSash.setLayout(layout);
mainSash.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
Composite navigation = new Composite(mainSash, SWT.BORDER);
navigation.setLayout(new GridLayout(1, false));
navigation.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH));
tree = new Tree(navigation, SWT.NONE);
tree.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
if (tree.getSelectionCount() > 0) {
TreeItem item = tree.getSelection()[0];
String url = hashTable.get(item);
if (url != null && !url.equals("")) {
browser.setUrl(url);
browser.update();
}
}
}
});
tree.addTreeListener(new TreeAdapter() {
public void treeCollapsed(TreeEvent e) {
TreeItem item = (TreeItem) e.item;
if (item != null && item.getData() != null) {
if (item.getData().equals("toc")) {
item.setImage(Activator.getImageDescriptor(PluginConstants.HELP_TOC_CLOSED).createImage());
}
if (item.getData().equals("book")) {
item.setImage(Activator.getImageDescriptor(PluginConstants.HELP_BOOK_CLOSED).createImage());
}
}
}
public void treeExpanded(TreeEvent e) {
TreeItem item = (TreeItem) e.item;
if (item != null && item.getData() != null) {
if (item.getData().equals("toc")) {
item.setImage(Activator.getImageDescriptor(PluginConstants.HELP_TOC_OPEN).createImage());
}
if (item.getData().equals("book")) {
item.setImage(Activator.getImageDescriptor(PluginConstants.HELP_BOOK_OPEN).createImage());
}
}
}
});
tree.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH));
Composite contents = new Composite(mainSash, SWT.BORDER);
contents.setLayout(new GridLayout(1, false));
contents.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH));
browser = new Browser(contents, SWT.NONE);
browser.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH));
mainSash.setWeights(new int[] { 30, 70 });
hashTable = new Hashtable<TreeItem, String>();
if (!helpFilePath.equals("")) {
loadTree(helpFilePath);
}
return tparent;
}
Aggregations