use of org.eclipse.core.resources.IWorkspace in project azure-tools-for-java by Microsoft.
the class PluginUtil method refreshWorkspace.
/**
* Refreshes the workspace.
*/
public static void refreshWorkspace() {
try {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();
root.refreshLocal(IResource.DEPTH_INFINITE, null);
} catch (CoreException e) {
//This is just a try to refresh workspace.
//User can also refresh the workspace manually.
//So user should not get any exception prompt.
Activator.getDefault().log(Messages.resCLExWkspRfrsh, null);
}
}
use of org.eclipse.core.resources.IWorkspace in project azure-tools-for-java by Microsoft.
the class AzureDockerUIResources method getCurrentSelectedProject.
public static IProject getCurrentSelectedProject() {
IProject project = null;
ISelectionService selectionService = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
ISelection selection = selectionService.getSelection();
if (selection instanceof IStructuredSelection) {
Object element = ((IStructuredSelection) selection).getFirstElement();
if (element instanceof IResource) {
project = ((IResource) element).getProject();
} else if (element instanceof PackageFragmentRoot) {
IJavaProject jProject = ((PackageFragmentRoot) element).getJavaProject();
project = jProject.getProject();
} else if (element instanceof IJavaElement) {
IJavaProject jProject = ((IJavaElement) element).getJavaProject();
project = jProject.getProject();
}
}
if (project == null) {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
if (workspace.getRoot() != null && workspace.getRoot().getProjects().length > 0) {
IProject[] projects = workspace.getRoot().getProjects();
project = projects[projects.length - 1];
} else {
PluginUtil.displayErrorDialog(Display.getDefault().getActiveShell(), "No Active Project", "Must have a project first");
}
}
return project;
}
use of org.eclipse.core.resources.IWorkspace in project azure-tools-for-java by Microsoft.
the class SparkSubmitModel method action.
public void action(@NotNull SparkSubmissionParameter submissionParameter) {
this.submissionParameter = submissionParameter;
if (isLocalArtifact()) {
submit();
} else {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();
IProject proj = root.getProject(submissionParameter.getArtifactName());
JarExportJob job = new JarExportJob("Building jar", proj);
job.schedule();
job.addJobChangeListener(new JobChangeAdapter() {
public void done(IJobChangeEvent event) {
if (event.getResult().isOK()) {
submit();
}
}
;
});
}
}
use of org.eclipse.core.resources.IWorkspace in project azure-tools-for-java by Microsoft.
the class CreateProjectUtil method convert.
@NotNull
private static IFile convert(@NotNull File file) {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IPath location = Path.fromOSString(file.getAbsolutePath());
IFile ifile = workspace.getRoot().getFileForLocation(location);
return ifile;
}
use of org.eclipse.core.resources.IWorkspace in project azure-tools-for-java by Microsoft.
the class ApplicationInsightsResourceRegistryEclipse method getInUseInstrumentationKeys.
/**
* Method scans all open Maven or Dynamic web projects form workspace
* and prepare a list of instrumentation keys which are in use.
* @return
*/
public static List<String> getInUseInstrumentationKeys() {
List<String> keyList = new ArrayList<String>();
try {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();
for (IProject iProject : root.getProjects()) {
if (iProject.isOpen() && WebPropertyTester.isWebProj(iProject)) {
String aiXMLPath;
if (iProject.hasNature(Messages.natMaven)) {
aiXMLPath = Messages.aiXMLPathMaven;
} else {
aiXMLPath = Messages.aiXMLPath;
}
AILibraryHandler handler = new AILibraryHandler();
IFile file = iProject.getFile(aiXMLPath);
if (file.exists()) {
handler.parseAIConfXmlPath(file.getLocation().toOSString());
String key = handler.getAIInstrumentationKey();
if (key != null && !key.isEmpty()) {
keyList.add(key);
}
}
}
}
} catch (Exception ex) {
Activator.getDefault().log(ex.getMessage(), ex);
}
return keyList;
}
Aggregations