java swt to get specific files in workspacedialog box

24 views Asked by At
import java.util.List;

import org.eclipse.core.resources.IFile;
import org.eclipse.emf.common.ui.dialogs.WorkspaceResourceDialog;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.swt.widgets.Shell;

public class WorkspaceBrowser implements FileBrowser {
    private final String TITLE = "Select File";
    private final String MESSAGE = "Select sample file.";
    private final boolean isSource;
    private final Shell parentShell;
    private List<ViewerFilter> viewerFilter;

    public WorkspaceBrowser(Shell parentShell, boolean isSource) {
        this.parentShell = parentShell;
        this.isSource = isSource;

    }

    @Override
    public Object openBrowser() {
        IFile file = null;
        if (isSource) {
            IFile[] files = WorkspaceResourceDialog.openFileSelection(parentShell, TITLE, MESSAGE, false, null, null);
            if (files != null && files.length != 0) {
                file = files[0];
            }
        } else {
            file = WorkspaceResourceDialog.openNewFile(parentShell, TITLE, MESSAGE, null, null);
        }

        return file;
    }

}

i have this code to display a dialog box with all the projects present in the workspace

public List<IProject> computeDependentProjects(IProject project) {
        List<IProject> result = new ArrayList<IProject>();
        IJavaProject jProject = JavaCore.create(project);
        IClasspathEntry[] resolvedClasspath;
        try {
            resolvedClasspath = jProject.getResolvedClasspath(true);
        } catch (JavaModelException e) {
            throw new IllegalStateException("Could not compute classpath", e);
        }
        IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
        for (IClasspathEntry entry : resolvedClasspath) {
            if (entry.getEntryKind() != IClasspathEntry.CPE_PROJECT)
                continue;
            IPath path = entry.getPath();
            result.add((IProject) wsRoot.findMember(path));
        }
        return result;
    }

and this code to get the list of dependent projects now, in the dialog box i don't want to show all the folders, instead i only want to show which are common in both the functions

0

There are 0 answers