Search in sources :

Example 16 with TreeItem

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);
}
Also used : ColumnGroupEntry(net.sourceforge.nattable.columnChooser.ColumnGroupEntry) TreeItem(org.eclipse.swt.widgets.TreeItem)

Example 17 with TreeItem

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();
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) ArrayList(java.util.ArrayList)

Example 18 with TreeItem

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;
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) ArrayList(java.util.ArrayList)

Example 19 with TreeItem

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);
}
Also used : ColumnGroupEntry(net.sourceforge.nattable.columnChooser.ColumnGroupEntry) TreeItem(org.eclipse.swt.widgets.TreeItem)

Example 20 with TreeItem

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;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) TreeItem(org.eclipse.swt.widgets.TreeItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TreeAdapter(org.eclipse.swt.events.TreeAdapter) TreeEvent(org.eclipse.swt.events.TreeEvent) SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Tree(org.eclipse.swt.widgets.Tree) Browser(org.eclipse.swt.browser.Browser)

Aggregations

TreeItem (org.eclipse.swt.widgets.TreeItem)150 Tree (org.eclipse.swt.widgets.Tree)36 SelectionEvent (org.eclipse.swt.events.SelectionEvent)23 GridData (org.eclipse.swt.layout.GridData)23 Point (org.eclipse.swt.graphics.Point)21 ArrayList (java.util.ArrayList)20 TreeColumn (org.eclipse.swt.widgets.TreeColumn)18 GridLayout (org.eclipse.swt.layout.GridLayout)17 TreeViewer (org.eclipse.jface.viewers.TreeViewer)16 Composite (org.eclipse.swt.widgets.Composite)14 TableItem (org.eclipse.swt.widgets.TableItem)14 SelectionListener (org.eclipse.swt.events.SelectionListener)13 Group (org.eclipse.swt.widgets.Group)13 Button (org.eclipse.swt.widgets.Button)12 Table (org.eclipse.swt.widgets.Table)12 Event (org.eclipse.swt.widgets.Event)11 List (java.util.List)10 Label (org.eclipse.swt.widgets.Label)10 CubridGroupNode (com.cubrid.common.ui.spi.model.CubridGroupNode)9 AUndertaking (edu.cmu.cs.hcii.cogtool.model.AUndertaking)9