use of org.eclipse.ui.ISelectionService in project azure-tools-for-java by Microsoft.
the class AzureDockerHostDeployHandler method onExecute.
@Override
public Object onExecute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
ISelectionService selectionService = window.getSelectionService();
ISelection selection = selectionService.getSelection();
Shell shell = window.getShell();
IProject project = null;
if (selection instanceof IStructuredSelection) {
Object element = ((IStructuredSelection) selection).getFirstElement();
if (element instanceof IResource) {
project = ((IResource) element).getProject();
}
}
if (project == null) {
project = AzureDockerUIResources.getCurrentSelectedProject();
if (project == null) {
return null;
}
}
try {
AzureDockerUIResources.publish2DockerHostContainer(PluginUtil.getParentShell(), project, null);
// AzureDockerUIResources.createArtifact(shell, project);
//
// AzureManager azureAuthManager = AuthMethodManager.getInstance().getAzureManager();
//
// // not signed in
// if (azureAuthManager == null) {
// System.out.println("ERROR! Not signed in!");
// return null;
// }
//
// AzureDockerHostsManager dockerManager = AzureDockerHostsManager
// .getAzureDockerHostsManager(azureAuthManager);
//
// if (!dockerManager.isInitialized()) {
// AzureDockerUIResources.updateAzureResourcesWithProgressDialog(shell, project);
// if (AzureDockerUIResources.CANCELED) {
// return null;
// }
// dockerManager = AzureDockerHostsManager.getAzureDockerHostsManagerEmpty(null);
// }
//
// if (dockerManager.getSubscriptionsMap().isEmpty()) {
// PluginUtil.displayErrorDialog(shell, "Create Docker Host", "Must select an Azure subscription first");
// return null;
// }
//
// DockerHost dockerHost = (dockerManager.getDockerPreferredSettings() != null) ? dockerManager.getDockerHostForURL(dockerManager.getDockerPreferredSettings().dockerApiName) : null;
// AzureDockerImageInstance dockerImageDescription = dockerManager.getDefaultDockerImageDescription(project.getName(), dockerHost);
// AzureSelectDockerWizard selectDockerWizard = new AzureSelectDockerWizard(project, dockerManager, dockerImageDescription);
// WizardDialog selectDockerHostDialog = new WizardDialog(shell, selectDockerWizard);
//
// if (dockerHost != null) {
// selectDockerWizard.selectDefaultDockerHost(dockerHost, true);
// }
//
// if (selectDockerHostDialog.open() == Window.OK) {
//
// }
} catch (Exception e) {
log.log(Level.SEVERE, "execute: " + e.getMessage(), e);
e.printStackTrace();
}
return null;
}
use of org.eclipse.ui.ISelectionService in project azure-tools-for-java by Microsoft.
the class AILibraryUtil 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();
}
return selProject;
}
use of org.eclipse.ui.ISelectionService 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;
}
use of org.eclipse.ui.ISelectionService in project knime-core by knime.
the class EditMetaInfoAction method getSelection.
private Object getSelection() {
ISelectionService service = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
IStructuredSelection selection = (IStructuredSelection) service.getSelection();
if (selection == null) {
return null;
}
return selection.getFirstElement();
}
Aggregations