use of org.eclipse.core.resources.IWorkspace in project translationstudio8 by heartsome.
the class RenameResourceAndCloseEditorAction method queryNewResourceName.
/**
* Return the new name to be given to the target resource.
*
* @return java.lang.String
* @param resource
* the resource to query status on
*/
protected String queryNewResourceName(final IResource resource) {
final IWorkspace workspace = IDEWorkbenchPlugin.getPluginWorkspace();
final IPath prefix = resource.getFullPath().removeLastSegments(1);
IInputValidator validator = new IInputValidator() {
public String isValid(String string) {
if (resource.getName().equals(string)) {
return IDEWorkbenchMessages.RenameResourceAction_nameMustBeDifferent;
}
IStatus status = workspace.validateName(string, resource.getType());
if (!status.isOK()) {
return status.getMessage();
}
if (workspace.getRoot().exists(prefix.append(string))) {
return IDEWorkbenchMessages.RenameResourceAction_nameExists;
}
return null;
}
};
InputDialog dialog = new InputDialog(shellProvider.getShell(), IDEWorkbenchMessages.RenameResourceAction_inputDialogTitle, IDEWorkbenchMessages.RenameResourceAction_inputDialogMessage, resource.getName(), validator);
dialog.setBlockOnOpen(true);
int result = dialog.open();
if (result == Window.OK)
return dialog.getValue();
return 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