Search in sources :

Example 1 with IFindTarget

use of org.talend.designer.runtime.visualization.internal.ui.properties.cpu.actions.FindAction.IFindTarget in project tdi-studio-se by Talend.

the class FindDialog method getFindTarget.

/**
     * Gets the target for find action.
     * 
     * @return The target for find action
     */
private static IFindTarget getFindTarget() {
    IWorkbenchPart activePart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
    if (activePart instanceof IFindTarget) {
        return (IFindTarget) activePart;
    }
    PropertySheet part = (PropertySheet) activePart;
    if (part == null) {
        return null;
    }
    IPage page = part.getCurrentPage();
    if (!(page instanceof TabbedPropertySheetPage)) {
        return null;
    }
    TabbedPropertySheetPage propertySheetPage = (TabbedPropertySheetPage) page;
    ISection[] sections = propertySheetPage.getCurrentTab().getSections();
    if (sections.length != 1) {
        return null;
    }
    ISection section = sections[0];
    if (!(section instanceof IFindTarget)) {
        return null;
    }
    return (IFindTarget) section;
}
Also used : ISection(org.eclipse.ui.views.properties.tabbed.ISection) IFindTarget(org.talend.designer.runtime.visualization.internal.ui.properties.cpu.actions.FindAction.IFindTarget) IPage(org.eclipse.ui.part.IPage) PropertySheet(org.eclipse.ui.views.properties.PropertySheet) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) TabbedPropertySheetPage(org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage)

Example 2 with IFindTarget

use of org.talend.designer.runtime.visualization.internal.ui.properties.cpu.actions.FindAction.IFindTarget in project tdi-studio-se by Talend.

the class FindDialog method doFind.

/**
     * Finds the item with string specified in text field.
     */
void doFind() {
    IFindTarget target = getFindTarget();
    if (target == null) {
        return;
    }
    TreeViewer viewer = target.getTargetTreeViewer();
    ITreeNode[] rootNodes = target.getTargetTreeNodes();
    if (viewer == null || rootNodes.length == 0) {
        return;
    }
    String searchText = findText.getText();
    addHistory(searchText);
    ITreeNode treeNode = null;
    ITreeNode selectedNode = getSelectedNode(viewer);
    startSearch = (selectedNode == null);
    if (forwardButton.getSelection()) {
        treeNode = searchTreeNodeInForward(viewer, rootNodes, selectedNode, searchText);
    } else {
        treeNode = searchTreeNodeInBackward(viewer, rootNodes, selectedNode, searchText);
    }
    if (treeNode != null) {
        ISelection newSelection = new StructuredSelection(treeNode);
        viewer.setSelection(newSelection);
    }
    findButton.forceFocus();
}
Also used : IFindTarget(org.talend.designer.runtime.visualization.internal.ui.properties.cpu.actions.FindAction.IFindTarget) ITreeNode(org.talend.designer.runtime.visualization.internal.core.cpu.ITreeNode) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ISelection(org.eclipse.jface.viewers.ISelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection)

Aggregations

IFindTarget (org.talend.designer.runtime.visualization.internal.ui.properties.cpu.actions.FindAction.IFindTarget)2 ISelection (org.eclipse.jface.viewers.ISelection)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)1 IPage (org.eclipse.ui.part.IPage)1 PropertySheet (org.eclipse.ui.views.properties.PropertySheet)1 ISection (org.eclipse.ui.views.properties.tabbed.ISection)1 TabbedPropertySheetPage (org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage)1 ITreeNode (org.talend.designer.runtime.visualization.internal.core.cpu.ITreeNode)1