use of org.eclipse.ui.forms.editor.IFormPage in project bndtools by bndtools.
the class BuildOperationsPart method findEditorResource.
private IResource findEditorResource() {
IFormPage formPage = (IFormPage) getManagedForm().getContainer();
IResource resource = ResourceUtil.getResource(formPage.getEditorInput());
return resource;
}
use of org.eclipse.ui.forms.editor.IFormPage in project bndtools by bndtools.
the class ExportPatternsListPart method selectPackagesToAdd.
protected List<ExportedPackage> selectPackagesToAdd() {
List<ExportedPackage> added = null;
final IPackageFilter filter = new IPackageFilter() {
@Override
public boolean select(String packageName) {
if (packageName.equals("java") || packageName.startsWith("java."))
return false;
return true;
}
};
IFormPage page = (IFormPage) getManagedForm().getContainer();
IWorkbenchWindow window = page.getEditorSite().getWorkbenchWindow();
// Prepare the package lister from the Java project
IProject project = ResourceUtil.getResource(page.getEditorInput()).getProject();
IJavaProject javaProject = JavaCore.create(project);
IJavaSearchScope searchScope = SearchEngine.createJavaSearchScope(new IJavaElement[] { javaProject });
JavaSearchScopePackageLister packageLister = new JavaSearchScopePackageLister(searchScope, window);
// Create and open the dialog
PackageSelectionDialog dialog = new PackageSelectionDialog(window.getShell(), packageLister, filter, "Select new packages to export from the bundle.");
dialog.setSourceOnly(true);
dialog.setMultipleSelection(true);
if (dialog.open() == Window.OK) {
Object[] results = dialog.getResult();
added = new LinkedList<ExportedPackage>();
// Select the results
for (Object result : results) {
String newPackageName = (String) result;
ExportedPackage newPackage = new ExportedPackage(newPackageName, new Attrs());
added.add(newPackage);
}
}
return added;
}
use of org.eclipse.ui.forms.editor.IFormPage in project bndtools by bndtools.
the class GeneralInfoPart method getJavaProject.
IJavaProject getJavaProject() {
IFormPage formPage = (IFormPage) getManagedForm().getContainer();
IFile file = ResourceUtil.getFile(formPage.getEditorInput());
return file != null ? JavaCore.create(file.getProject()) : null;
}
use of org.eclipse.ui.forms.editor.IFormPage in project bndtools by bndtools.
the class BndEditor method updateIncludedPages.
private void updateIncludedPages() {
List<String> requiredPageIds = new LinkedList<String>();
// Need to know the file and project names.
Pair<String, String> fileAndProject = getFileAndProject(getEditorInput());
String path = fileAndProject.getFirst();
String projectName = fileAndProject.getSecond();
if (isMainWorkspaceConfig(path, projectName)) {
requiredPageIds.add(WORKSPACE_PAGE);
} else if (isExtWorkspaceConfig(path, projectName)) {
requiredPageIds.add(WORKSPACE_EXT_PAGE);
setTitleImage(buildFileImg);
} else if (path.endsWith(LaunchConstants.EXT_BNDRUN)) {
requiredPageIds.addAll(getPagesBndRun());
} else {
requiredPageIds.addAll(getPagesBnd(path));
}
requiredPageIds.add(SOURCE_PAGE);
// Remove pages no longer required and remember the rest in a map
int i = 0;
Map<String, IFormPage> pageCache = new HashMap<String, IFormPage>(requiredPageIds.size());
while (i < getPageCount()) {
IFormPage current = (IFormPage) pages.get(i);
if (!requiredPageIds.contains(current.getId()))
removePage(i);
else {
pageCache.put(current.getId(), current);
i++;
}
}
// Cache new pages
for (String pageId : requiredPageIds) {
if (!pageCache.containsKey(pageId)) {
IFormPage page = SOURCE_PAGE.equals(pageId) ? sourcePage : pageFactories.get(pageId).createPage(this, model, pageId);
pageCache.put(pageId, page);
}
}
// Add pages back in
int requiredPointer = 0;
int existingPointer = 0;
while (requiredPointer < requiredPageIds.size()) {
try {
String requiredId = requiredPageIds.get(requiredPointer);
if (existingPointer >= getPageCount()) {
if (SOURCE_PAGE.equals(requiredId))
addPage(sourcePage, getEditorInput());
else
addPage(pageCache.get(requiredId));
} else {
IFormPage existingPage = (IFormPage) pages.get(existingPointer);
if (!requiredId.equals(existingPage.getId())) {
if (SOURCE_PAGE.equals(requiredId))
addPage(existingPointer, sourcePage, getEditorInput());
else
addPage(existingPointer, pageCache.get(requiredId));
}
}
existingPointer++;
} catch (PartInitException e) {
logger.logError("Error adding page(s) to the editor.", e);
}
requiredPointer++;
}
// Set the source page title
setPageText(sourcePage.getIndex(), "Source");
}
use of org.eclipse.ui.forms.editor.IFormPage in project bndtools by bndtools.
the class PrivatePackagesPart method getJavaProject.
private IJavaProject getJavaProject() {
IFormPage page = (IFormPage) getManagedForm().getContainer();
IEditorInput input = page.getEditorInput();
if (!IFileEditorInput.class.isInstance(input)) {
return null;
}
IProject project = ((IFileEditorInput) input).getFile().getProject();
return JavaCore.create(project);
}
Aggregations