use of org.eclipse.ui.IWorkbenchWindow in project cubrid-manager by CUBRID.
the class CubridColumnNavigatorView method getInstance.
public static CubridColumnNavigatorView getInstance() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return null;
}
IWorkbenchPage page = window.getActivePage();
if (page == null) {
return null;
}
IViewReference viewReference = page.findViewReference(ID);
if (viewReference != null) {
IViewPart viewPart = viewReference.getView(false);
return viewPart instanceof CubridColumnNavigatorView ? (CubridColumnNavigatorView) viewPart : null;
}
return null;
}
use of org.eclipse.ui.IWorkbenchWindow in project cubrid-manager by CUBRID.
the class SearchContributionComposite method processSearch.
public void processSearch() {
if (text.getText().length() == 0) {
return;
}
String key = StringUtil.urlencode(text.getText(), "UTF-8");
if (key == null) {
LOGGER.error("Encode key word error");
return;
}
String url = getUrl(key);
BrowserEditorPart browserViewPart = null;
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IEditorReference[] editorReferences = window.getActivePage().getEditorReferences();
for (IEditorReference reference : editorReferences) {
if (reference.getId().equals(BrowserEditorPart.ID)) {
browserViewPart = (BrowserEditorPart) reference.getEditor(true);
}
}
if (browserViewPart == null) {
try {
browserViewPart = (BrowserEditorPart) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(new BrowserEditorPartInput(), BrowserEditorPart.ID);
} catch (PartInitException e) {
LOGGER.error(e.getMessage(), e);
}
}
if (browserViewPart != null) {
browserViewPart.go(url);
// For bug TOOLS-1014
window.getActivePage().activate(browserViewPart);
}
}
use of org.eclipse.ui.IWorkbenchWindow in project azure-tools-for-java by Microsoft.
the class PluginUtil method getSelectedProject.
/**
* This method returns currently selected project in workspace.
* @return IProject
*/
public static IProject getSelectedProject() {
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
ISelectionService service = window.getSelectionService();
ISelection selection = service.getSelection();
Object element = null;
IResource resource;
IProject selProject = null;
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSel = (IStructuredSelection) selection;
element = structuredSel.getFirstElement();
}
if (element instanceof IProject) {
resource = (IResource) element;
selProject = resource.getProject();
} else if (element instanceof IJavaProject) {
IJavaProject proj = ((IJavaElement) element).getJavaProject();
selProject = proj.getProject();
} else if (element instanceof IResource) {
resource = (IResource) element;
selProject = resource.getProject();
} else {
IWorkbenchPage page = window.getActivePage();
IEditorPart editorPart = page.getActiveEditor();
if (editorPart != null) {
IFile file = (IFile) editorPart.getEditorInput().getAdapter(IFile.class);
if (file != null) {
selProject = file.getProject();
}
}
}
return selProject;
}
use of org.eclipse.ui.IWorkbenchWindow in project azure-tools-for-java by Microsoft.
the class SDKJarsFilter method getSelectedProject.
private IProject getSelectedProject() {
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
ISelectionService service = window.getSelectionService();
ISelection selection = service.getSelection();
Object element = null;
IResource resource;
IProject selProject = null;
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSel = (IStructuredSelection) selection;
element = structuredSel.getFirstElement();
}
if (element instanceof IProject) {
resource = (IResource) element;
selProject = resource.getProject();
} else if (element instanceof IJavaProject) {
IJavaProject proj = ((IJavaElement) element).getJavaProject();
selProject = proj.getProject();
}
return selProject;
}
use of org.eclipse.ui.IWorkbenchWindow in project azure-tools-for-java by Microsoft.
the class ClasspathContainerPage method getSelectedProject.
/**
* This method returns currently selected project in workspace.
* @return IProject
*/
private IProject getSelectedProject() {
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
ISelectionService service = window.getSelectionService();
ISelection selection = service.getSelection();
Object element = null;
IResource resource;
IProject selProject = null;
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSel = (IStructuredSelection) selection;
element = structuredSel.getFirstElement();
}
if (element instanceof IProject) {
resource = (IResource) element;
selProject = resource.getProject();
} else if (element instanceof IJavaProject) {
IJavaProject proj = ((IJavaElement) element).getJavaProject();
selProject = proj.getProject();
}
return selProject;
}
Aggregations