use of com.liferay.ide.project.ui.dialog.LiferayProjectSelectionDialog in project liferay-ide by liferay.
the class RequiredDeploymentContextsSection method _handleAdd.
private void _handleAdd() {
PluginPackageModel model = (PluginPackageModel) getPage().getModel();
String[] existingServiceDeps = model.getRequiredDeploymentContexts();
ViewerFilter filter = new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof IJavaProject) {
IProject project = ((IJavaProject) element).getProject();
for (String existingDep : existingServiceDeps) {
if (project.getName().equals(existingDep)) {
return false;
}
}
IDEFormEditor formEditor = getPage().getLiferayFormEditor();
if (project.equals(formEditor.getCommonProject())) {
return false;
}
return true;
} else {
return false;
}
}
};
LiferayProjectSelectionDialog dialog = new LiferayProjectSelectionDialog(getPage().getShell(), filter);
dialog.create();
if (dialog.open() == Window.OK) {
Object[] selectedProjects = dialog.getResult();
try {
for (int i = 0; i < selectedProjects.length; i++) {
IJavaProject project = (IJavaProject) selectedProjects[i];
if (project.exists()) {
model.addRequiredDeploymentContext(project.getProject().getName());
}
}
} catch (Exception e) {
}
}
}
Aggregations