use of org.eclipse.jdt.internal.ui.preferences.ProjectSelectionDialog in project liferay-ide by liferay.
the class AddMacroLibrary method run.
public void run(IAction action) {
ISelectionProvider provider = part.getSite().getSelectionProvider();
if (null != provider) {
if (provider.getSelection() instanceof IStructuredSelection) {
try {
IStructuredSelection selection = (IStructuredSelection) provider.getSelection();
Object[] obj = selection.toArray();
List documents = new ArrayList();
for (int i = 0; i < obj.length; i++) {
if (obj[i] instanceof IFile) {
IFile file = (IFile) obj[i];
documents.add(file);
} else if (obj[i] instanceof JarEntryFile) {
JarEntryFile jef = (JarEntryFile) obj[i];
documents.add(jef);
System.out.println(jef.getFullPath().makeAbsolute());
System.out.println(jef.getFullPath().makeRelative());
IPath path = jef.getFullPath();
System.out.println(path);
System.out.println(jef.getName());
IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(jef.getFullPath());
System.out.println(resource);
} else if (obj[i] instanceof IStorage) {
}
}
IProject project = null;
if (documents.size() > 0) {
// what project?
HashSet projects = new HashSet();
IProject[] p = ResourcesPlugin.getWorkspace().getRoot().getProjects();
for (int i = 0; i < p.length; i++) {
projects.add(p[i]);
}
ProjectSelectionDialog dialog = new ProjectSelectionDialog(Display.getCurrent().getActiveShell(), projects);
dialog.setTitle(Messages.AddMacroLibrary_Title);
dialog.setMessage(Messages.AddMacroLibrary_Message);
int rtn = dialog.open();
if (rtn == IDialogConstants.OK_ID) {
if (dialog.getFirstResult() instanceof IJavaProject) {
project = ((IJavaProject) dialog.getFirstResult()).getProject();
} else {
MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.AddMacroLibrary_Error, Messages.AddMacroLibrary_ErrorDesc);
}
}
}
if (null != project) {
ConfigurationManager.getInstance(project).associateMappingLibraries(documents, Display.getCurrent().getActiveShell());
}
} catch (Exception e) {
Plugin.error(e);
}
}
}
}
Aggregations