Skip to content
This repository has been archived by the owner on Sep 17, 2019. It is now read-only.

Commit

Permalink
moving SelectPluginIProjectDialog to commons lib
Browse files Browse the repository at this point in the history
  • Loading branch information
dvojtise committed Sep 28, 2015
1 parent 559f0c8 commit 8fabc76
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
@@ -0,0 +1,31 @@
package org.gemoc.commons.eclipse.ui.dialogs;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.swt.widgets.Shell;

public class SelectPluginIProjectDialog extends SelectAnyIProjectDialog {

public SelectPluginIProjectDialog(Shell parentShell) {
super(parentShell);
}

@Override
protected boolean select(IResource resource) {
boolean result = super.select(resource);
if(resource instanceof IProject){
// must contain a manifest.mf file
boolean hasManifestFile = ((IProject)resource).findMember("META-INF/MANIFEST.MF") != null;
/*
FileFinderVisitor projectVisitor = new FileFinderVisitor("mf");
try {
resource.accept(projectVisitor);
hasManifestFile = projectVisitor.getFile() != null;
} catch (CoreException e) {
Activator.error(e.getMessage(), e);
}*/
result = result && hasManifestFile;
}
return result;
}
}
@@ -0,0 +1,44 @@
package org.gemoc.commons.eclipse.ui.dialogs;

import java.util.List;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.swt.widgets.Shell;
import org.gemoc.commons.eclipse.core.resources.FileFinderVisitor;
import org.gemoc.commons.eclipse.ui.Activator;

/**
* Project finder dialog that searches for a Plugin project containing at least one file with one of the given extension.
*
*/
public class SelectPluginIProjectWithFileExtensionDialog extends SelectPluginIProjectDialog {

protected FileFinderVisitor projectVisitor;
public SelectPluginIProjectWithFileExtensionDialog(Shell parentShell, List<String> searchedFileExtensions) {
super(parentShell);
projectVisitor = new FileFinderVisitor(searchedFileExtensions);
}
public SelectPluginIProjectWithFileExtensionDialog(Shell parentShell, String searchedFileExtension) {
super(parentShell);
projectVisitor = new FileFinderVisitor(searchedFileExtension);
}

@Override
protected boolean select(IResource resource) {
boolean result = super.select(resource);
if(resource instanceof IProject){
boolean hasFileWithExtension = false;

try {
resource.accept(projectVisitor);
hasFileWithExtension = projectVisitor.getFile() != null;
} catch (CoreException e) {
Activator.error(e.getMessage(), e);
}
result = result && hasFileWithExtension;
}
return result;
}
}

0 comments on commit 8fabc76

Please sign in to comment.