Search in sources :

Example 1 with TreeEvent

use of org.eclipse.swt.events.TreeEvent in project cubrid-manager by CUBRID.

the class OIDNavigatorDialog method createDialogArea.

/**
	 * Create dialog area content
	 * 
	 * @param parent the parent composite
	 * @return the control
	 */
protected Control createDialogArea(Composite parent) {
    Composite parentComp = (Composite) super.createDialogArea(parent);
    Composite composite = new Composite(parentComp, SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridLayout layout = new GridLayout();
    layout.numColumns = 5;
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    composite.setLayout(layout);
    Label oidValueLabel = new Label(composite, SWT.LEFT);
    oidValueLabel.setText(Messages.lblOIDValue);
    oidValueLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    oidValueText = new Text(composite, SWT.LEFT | SWT.BORDER);
    oidValueText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 3, 1, -1, -1));
    if (oidStr != null) {
        oidValueText.setText(oidStr);
    }
    oidValueText.addModifyListener(this);
    findButton = new Button(composite, SWT.CENTER);
    findButton.setText(Messages.btnFind);
    findButton.setLayoutData(CommonUITool.createGridData(1, 1, 60, -1));
    if (oidStr == null || oidStr.trim().length() <= 0) {
        findButton.setEnabled(false);
    }
    findButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            find();
        }
    });
    Composite findResultComp = new Composite(composite, SWT.BORDER);
    findResultComp.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 5, 1, -1, 200));
    findResultComp.setLayout(new GridLayout());
    resultTree = new Tree(findResultComp, SWT.NONE | SWT.VIRTUAL);
    GridData data = new GridData(GridData.FILL_BOTH);
    resultTree.setLayoutData(data);
    resultTree.addTreeListener(new TreeListener() {

        public void treeCollapsed(TreeEvent event) {
        //empty
        }

        public void treeExpanded(TreeEvent event) {
            TreeItem item = (TreeItem) event.item;
            if (item.getData(OID_ITEM_FLAG) == null || (item.getData(EXPANDED_ITEM_FLAG) != null)) {
                return;
            }
            if (item.getItemCount() > 0) {
                Object obj = item.getItem(0).getData(DUMY_ITEM_FLAG);
                if (obj instanceof String && OIDNavigatorDialog.DUMY_ITEM_FLAG.equals((String) obj)) {
                    item.removeAll();
                }
            }
            searchOID((String) (item.getData(OID_ITEM_FLAG)), item);
            item.setData(EXPANDED_ITEM_FLAG, "true");
        }
    });
    setTitle(Messages.titleOIDNavigatorDialog);
    setMessage(Messages.msgOIDNavigatorDialog);
    return parentComp;
}
Also used : TreeListener(org.eclipse.swt.events.TreeListener) Composite(org.eclipse.swt.widgets.Composite) TreeItem(org.eclipse.swt.widgets.TreeItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) TreeEvent(org.eclipse.swt.events.TreeEvent) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Tree(org.eclipse.swt.widgets.Tree)

Example 2 with TreeEvent

use of org.eclipse.swt.events.TreeEvent 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)

Example 3 with TreeEvent

use of org.eclipse.swt.events.TreeEvent in project eclipse.platform.swt by eclipse.

the class FileViewer method createTreeView.

/**
 * Creates the file tree view.
 *
 * @param parent the parent control
 */
private void createTreeView(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 1;
    gridLayout.marginHeight = gridLayout.marginWidth = 2;
    gridLayout.horizontalSpacing = gridLayout.verticalSpacing = 0;
    composite.setLayout(gridLayout);
    treeScopeLabel = new Label(composite, SWT.BORDER);
    treeScopeLabel.setText(FileViewer.getResourceString("details.AllFolders.text"));
    treeScopeLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));
    tree = new Tree(composite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE);
    tree.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL));
    tree.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            final TreeItem[] selection = tree.getSelection();
            if (selection != null && selection.length != 0) {
                TreeItem item = selection[0];
                File file = (File) item.getData(TREEITEMDATA_FILE);
                notifySelectedDirectory(file);
            }
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent event) {
            final TreeItem[] selection = tree.getSelection();
            if (selection != null && selection.length != 0) {
                TreeItem item = selection[0];
                item.setExpanded(true);
                treeExpandItem(item);
            }
        }
    });
    tree.addTreeListener(new TreeAdapter() {

        @Override
        public void treeExpanded(TreeEvent event) {
            final TreeItem item = (TreeItem) event.item;
            final Image image = (Image) item.getData(TREEITEMDATA_IMAGEEXPANDED);
            if (image != null)
                item.setImage(image);
            treeExpandItem(item);
        }

        @Override
        public void treeCollapsed(TreeEvent event) {
            final TreeItem item = (TreeItem) event.item;
            final Image image = (Image) item.getData(TREEITEMDATA_IMAGECOLLAPSED);
            if (image != null)
                item.setImage(image);
        }
    });
    createTreeDragSource(tree);
    createTreeDropTarget(tree);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) TreeItem(org.eclipse.swt.widgets.TreeItem) Label(org.eclipse.swt.widgets.Label) TreeAdapter(org.eclipse.swt.events.TreeAdapter) Image(org.eclipse.swt.graphics.Image) TreeEvent(org.eclipse.swt.events.TreeEvent) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Tree(org.eclipse.swt.widgets.Tree) File(java.io.File) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 4 with TreeEvent

use of org.eclipse.swt.events.TreeEvent in project nebula.widgets.nattable by eclipse.

the class ColumnChooserDialog method populateDialogArea.

@Override
public void populateDialogArea(Composite parent) {
    GridDataFactory.fillDefaults().grab(true, true).applyTo(parent);
    parent.setLayout(new GridLayout(4, false));
    createLabels(parent, this.availableLabel, this.selectedLabel);
    this.availableTree = new Tree(parent, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.Expand);
    GridData gridData = GridDataFactory.fillDefaults().grab(true, true).create();
    this.availableTree.setLayoutData(gridData);
    this.availableTree.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(MouseEvent e) {
            addSelected();
        }
    });
    this.availableTree.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            if (e.character == ' ')
                addSelected();
        }
    });
    Composite buttonComposite = new Composite(parent, SWT.NONE);
    buttonComposite.setLayout(new GridLayout(1, true));
    Button addButton = new Button(buttonComposite, SWT.PUSH);
    // $NON-NLS-1$
    addButton.setImage(GUIHelper.getImage("arrow_right"));
    gridData = GridDataFactory.fillDefaults().grab(false, true).align(SWT.CENTER, SWT.CENTER).create();
    addButton.setLayoutData(gridData);
    addButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            addSelected();
        }
    });
    final Button removeButton = new Button(buttonComposite, SWT.PUSH);
    // $NON-NLS-1$
    removeButton.setImage(GUIHelper.getImage("arrow_left"));
    gridData = GridDataFactory.copyData(gridData);
    removeButton.setLayoutData(gridData);
    removeButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            removeSelected();
        }
    });
    this.selectedTree = new Tree(parent, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.Expand);
    gridData = GridDataFactory.fillDefaults().grab(true, true).create();
    this.selectedTree.setLayoutData(gridData);
    this.selectedTree.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(MouseEvent e) {
            if (ColumnChooserDialog.this.preventHidingAllColumns) {
                if (!isSelectedTreeCompletelySelected()) {
                    removeSelected();
                }
            } else {
                removeSelected();
            }
        }
    });
    this.selectedTree.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            boolean controlMask = (e.stateMask & SWT.MOD1) == SWT.MOD1;
            if (controlMask && e.keyCode == SWT.ARROW_UP) {
                moveSelectedUp();
                e.doit = false;
            } else if (controlMask && e.keyCode == SWT.ARROW_DOWN) {
                moveSelectedDown();
                e.doit = false;
            }
        }

        @Override
        public void keyReleased(KeyEvent e) {
            if (e.character == ' ')
                removeSelected();
        }
    });
    this.selectedTree.addTreeListener(new TreeListener() {

        @Override
        public void treeCollapsed(TreeEvent event) {
            selectedTreeCollapsed(event);
        }

        @Override
        public void treeExpanded(TreeEvent event) {
            selectedTreeExpanded(event);
        }
    });
    this.selectedTree.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent event) {
            widgetSelected(event);
        }

        @Override
        public void widgetSelected(SelectionEvent event) {
            toggleColumnGroupSelection((TreeItem) event.item);
            if (ColumnChooserDialog.this.preventHidingAllColumns) {
                removeButton.setEnabled(!isSelectedTreeCompletelySelected());
            }
        }
    });
    Composite upDownbuttonComposite = new Composite(parent, SWT.NONE);
    upDownbuttonComposite.setLayout(new GridLayout(1, true));
    Button topButton = new Button(upDownbuttonComposite, SWT.PUSH);
    // $NON-NLS-1$
    topButton.setImage(GUIHelper.getImage("arrow_up_top"));
    gridData = GridDataFactory.fillDefaults().grab(false, true).align(SWT.CENTER, SWT.CENTER).create();
    topButton.setLayoutData(gridData);
    topButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            moveSelectedToTop();
        }
    });
    Button upButton = new Button(upDownbuttonComposite, SWT.PUSH);
    // $NON-NLS-1$
    upButton.setImage(GUIHelper.getImage("arrow_up"));
    gridData = GridDataFactory.fillDefaults().grab(false, true).align(SWT.CENTER, SWT.CENTER).create();
    upButton.setLayoutData(gridData);
    upButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            moveSelectedUp();
        }
    });
    Button downButton = new Button(upDownbuttonComposite, SWT.PUSH);
    // $NON-NLS-1$
    downButton.setImage(GUIHelper.getImage("arrow_down"));
    gridData = GridDataFactory.copyData(gridData);
    downButton.setLayoutData(gridData);
    downButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            moveSelectedDown();
        }
    });
    Button bottomButton = new Button(upDownbuttonComposite, SWT.PUSH);
    // $NON-NLS-1$
    bottomButton.setImage(GUIHelper.getImage("arrow_down_end"));
    gridData = GridDataFactory.copyData(gridData);
    bottomButton.setLayoutData(gridData);
    bottomButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            moveSelectedToBottom();
        }
    });
}
Also used : TreeListener(org.eclipse.swt.events.TreeListener) ISelectionTreeListener(org.eclipse.nebula.widgets.nattable.columnChooser.ISelectionTreeListener) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) TreeItem(org.eclipse.swt.widgets.TreeItem) KeyAdapter(org.eclipse.swt.events.KeyAdapter) MouseAdapter(org.eclipse.swt.events.MouseAdapter) KeyEvent(org.eclipse.swt.events.KeyEvent) TreeEvent(org.eclipse.swt.events.TreeEvent) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Tree(org.eclipse.swt.widgets.Tree) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 5 with TreeEvent

use of org.eclipse.swt.events.TreeEvent in project pentaho-kettle by pentaho.

the class TreeMemory method addTreeListener.

/**
 * This method creates, adds and returns a tree listener that will keep track of the expanded/collapsed state of the
 * TreeItems. This state will then be stored in the TreeMemory singleton.
 *
 * @param tree
 *          The tree to add the listener to
 * @return The created/added TreeListener
 */
public static final TreeListener addTreeListener(final Tree tree, final String treeName) {
    TreeListener treeListener = new TreeListener() {

        public void treeExpanded(TreeEvent e) {
            TreeItem treeItem = (TreeItem) e.item;
            String[] path = ConstUI.getTreeStrings(treeItem);
            TreeMemory treeMemory = TreeMemory.getInstance();
            treeMemory.storeExpanded(treeName, path, true);
        }

        public void treeCollapsed(TreeEvent e) {
            TreeItem treeItem = (TreeItem) e.item;
            String[] path = ConstUI.getTreeStrings(treeItem);
            TreeMemory treeMemory = TreeMemory.getInstance();
            treeMemory.storeExpanded(treeName, path, false);
        }
    };
    tree.addTreeListener(treeListener);
    return treeListener;
}
Also used : TreeListener(org.eclipse.swt.events.TreeListener) TreeEvent(org.eclipse.swt.events.TreeEvent) TreeItem(org.eclipse.swt.widgets.TreeItem)

Aggregations

TreeEvent (org.eclipse.swt.events.TreeEvent)18 SelectionEvent (org.eclipse.swt.events.SelectionEvent)12 TreeItem (org.eclipse.swt.widgets.TreeItem)11 TreeListener (org.eclipse.swt.events.TreeListener)9 Tree (org.eclipse.swt.widgets.Tree)9 MouseEvent (org.eclipse.swt.events.MouseEvent)8 GridData (org.eclipse.swt.layout.GridData)8 SelectionListener (org.eclipse.swt.events.SelectionListener)7 GridLayout (org.eclipse.swt.layout.GridLayout)7 Composite (org.eclipse.swt.widgets.Composite)7 TreeAdapter (org.eclipse.swt.events.TreeAdapter)6 KeyEvent (org.eclipse.swt.events.KeyEvent)5 MouseAdapter (org.eclipse.swt.events.MouseAdapter)5 Button (org.eclipse.swt.widgets.Button)5 Point (org.eclipse.swt.graphics.Point)4 DropTargetEvent (org.eclipse.swt.dnd.DropTargetEvent)3 FocusEvent (org.eclipse.swt.events.FocusEvent)3 KeyAdapter (org.eclipse.swt.events.KeyAdapter)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3 Event (org.eclipse.swt.widgets.Event)3