Example usage for org.eclipse.jface.viewers IStructuredSelection isEmpty

List of usage examples for org.eclipse.jface.viewers IStructuredSelection isEmpty

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers IStructuredSelection isEmpty.

Prototype

public boolean isEmpty();

Source Link

Document

Returns whether this selection is empty.

Usage

From source file:com.google.dart.tools.ui.actions.CloseLibraryAction.java

License:Open Source License

private void handleSelectionChanged(IStructuredSelection selection) {
    this.selection = selection;
    if (selection == null || selection.isEmpty()) {
        setEnabled(false);/* www.  j  a va 2s.  co  m*/
    } else {
        for (Object object : selection.toList()) {
            if (!(object instanceof DartLibrary)) {
                setEnabled(false);
                return;
            }
        }
        setEnabled(true);
    }
}

From source file:com.google.dart.tools.ui.actions.FindAction.java

License:Open Source License

private boolean canOperateOn(IStructuredSelection sel) {
    return sel != null && !sel.isEmpty() && canOperateOn(getDartElement(sel, true));
}

From source file:com.google.dart.tools.ui.actions.GenerateDartdocAction.java

License:Open Source License

private void handleSelectionChanged(IStructuredSelection selection) {
    if (selection != null && !selection.isEmpty()) {
        selectedObject = selection.getFirstElement();
    } else {/*from   w  ww.  ja  va2 s.c o  m*/
        selectedObject = null;
    }
}

From source file:com.google.dart.tools.ui.actions.NewAppFromPackageAction.java

License:Open Source License

@Override
protected void doRun(IStructuredSelection selection, Event event, UIInstrumentationBuilder instrumentation) {
    if (!selection.isEmpty() && selection.getFirstElement() instanceof DartPackageNode_OLD) {
        DartPackageNode_OLD node = (DartPackageNode_OLD) selection.getFirstElement();
        openPackage(node.getFileStore());
    }//  ww w  .  j  a  v a2  s .  c om
}

From source file:com.google.dart.tools.ui.actions.OpenAction.java

License:Open Source License

private boolean checkEnabled(IStructuredSelection selection) {
    if (selection.isEmpty()) {
        return false;
    }//w  w  w  . ja v a 2 s .  c o m
    for (Iterator<?> iter = selection.iterator(); iter.hasNext();) {
        Object element = iter.next();
        if (element instanceof SourceReference) {
            continue;
        }
        if (element instanceof IFile) {
            continue;
        }
        if (DartModelUtil.isOpenableStorage(element)) {
            continue;
        }
        if (element instanceof HTMLFile) {
            continue;
        }
        return false;
    }
    return true;
}

From source file:com.google.dart.tools.ui.actions.OpenExternalDartdocAction_OLD.java

License:Open Source License

@Override
protected void doRun(IStructuredSelection selection, Event event, UIInstrumentationBuilder instrumentation) {
    if (selection == null || selection.isEmpty()) {
        return;//  w w w .j a  v a2 s .co  m
    }
    String libraryName = null;
    boolean browseSdkLibDocs = false;
    Object object = selection.getFirstElement();
    if (object instanceof IDartNode_OLD) {
        object = ((IDartNode_OLD) object).getFileStore();
    }
    if (object instanceof IFileStore) {
        IFileStore fileStore = (IFileStore) object;
        try {
            object = fileStore.toLocalFile(0, null);
        } catch (CoreException e) {
            DartCore.logError("Failed to convert to local file", e);
        }
    }
    if (object instanceof File) {
        IPath path = new Path(((File) object).getAbsolutePath());
        File sdkLibDir = DartSdkManager.getManager().getSdk().getLibraryDirectory();
        IPath sdkLibPath = new Path(sdkLibDir.getAbsolutePath());
        if (sdkLibPath.equals(path)) {
            browseSdkLibDocs = true;
        } else if (sdkLibPath.isPrefixOf(path)) {
            libraryName = "dart:" + path.segment(sdkLibPath.segmentCount());
        }
    }
    if (libraryName != null || browseSdkLibDocs) {
        browseDartDoc(libraryName, null, instrumentation);
    }
}

From source file:com.google.dart.tools.ui.actions.RunInBrowserAction.java

License:Open Source License

private void handleSelectionChanged(IStructuredSelection selection) {
    if (selection != null && !selection.isEmpty()) {
        selectedObject = selection.getFirstElement();

        setEnabled(true);//from  w  w  w  .  ja va2s. c  o m
    } else {
        selectedObject = null;

        setEnabled(false);
    }
}

From source file:com.google.dart.tools.ui.actions.RunPubAction.java

License:Open Source License

@Override
public void run(IStructuredSelection selection) {
    if (!selection.isEmpty() && selection.getFirstElement() instanceof IResource) {
        Object object = selection.getFirstElement();
        if (object instanceof IFile) {
            object = ((IFile) object).getParent();
        }//from   w  w w .  j  a  v a 2  s  .  com
        runPubJob((IResource) object);
    } else {
        MessageDialog.openError(getShell(), ActionMessages.RunPubAction_fail,
                ActionMessages.RunPubAction_fileNotFound);
    }
}

From source file:com.google.dart.tools.ui.actions.RunScriptAction.java

License:Open Source License

@Override
protected void doRun(IStructuredSelection selection, Event event, UIInstrumentationBuilder instrumentation) {

    String scriptName = getScript(event.keyCode);
    if (scriptName != null && !scriptName.isEmpty()) {
        instrumentation.metric("Running script ", scriptName);

        if (!selection.isEmpty() && selection.getFirstElement() instanceof IResource) {
            IResource res = (IResource) selection.getFirstElement();
            new RunScriptJob(res, scriptName).schedule();
        } else {/*from ww  w . jav a 2  s. c  o m*/
            new RunScriptJob(null, scriptName).schedule();
        }
    }
}

From source file:com.google.dart.tools.ui.callhierarchy.OpenLocationAction.java

License:Open Source License

private boolean checkEnabled(IStructuredSelection selection) {
    if (selection.isEmpty()) {
        return false;
    }/*from   ww w.java 2s .co m*/

    for (Iterator<?> iter = selection.iterator(); iter.hasNext();) {
        Object element = iter.next();

        if (element instanceof MethodWrapper) {
            continue;
        } else if (element instanceof CallLocation) {
            continue;
        }

        return false;
    }

    return true;
}