use of org.eclipse.core.resources.IProject in project translationstudio8 by heartsome.
the class MultiSelectionPropertyTester method test.
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
IProject curProject = null;
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window != null) {
IWorkbenchPage page = window.getActivePage();
if (page != null) {
if (page.getActivePartReference() == null) {
return false;
}
String partId = page.getActivePartReference().getId();
if (partId.equals("net.heartsome.cat.common.ui.navigator.view")) {
// 导航视图处于激活状态
IViewPart viewPart = page.findView("net.heartsome.cat.common.ui.navigator.view");
StructuredSelection selection = (StructuredSelection) viewPart.getSite().getSelectionProvider().getSelection();
ArrayList<IFile> selectedIFileList = new ArrayList<IFile>();
if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
List<?> lstObj = ((IStructuredSelection) selection).toList();
for (Object obj : lstObj) {
if (obj instanceof IFile) {
IFile file = (IFile) obj;
// Linux 下的文本文件无扩展名,因此要先判断扩展名是否为空
if (file.getFileExtension() == null || !CommonFunction.validXlfExtension(file.getFileExtension())) {
return false;
} else {
String xlfFolderPath = file.getProject().getFullPath().append(Constant.FOLDER_XLIFF).toOSString();
if (!file.getFullPath().toOSString().startsWith(xlfFolderPath)) {
return false;
}
if (curProject == null) {
curProject = file.getProject();
} else {
if (curProject != file.getProject()) {
return false;
}
}
selectedIFileList.add(file);
}
} else if (obj instanceof IFolder) {
IFolder folder = (IFolder) obj;
String xlfFolderPath = folder.getProject().getFullPath().append(Constant.FOLDER_XLIFF).toOSString();
if (!folder.getFullPath().toOSString().startsWith(xlfFolderPath)) {
return false;
}
try {
ResourceUtils.getXliffs(folder, selectedIFileList);
} catch (CoreException e) {
logger.error(Messages.getString("propertyTester.MultiSelectionPropertyTester.logger1"), folder.getFullPath().toOSString(), e);
}
if (curProject == null) {
curProject = folder.getProject();
} else {
if (curProject != folder.getProject()) {
return false;
}
}
}
}
CommonFunction.removeRepeateSelect(selectedIFileList);
if (selectedIFileList.size() < 2) {
return false;
}
} else {
return false;
}
}
} else {
return false;
}
} else {
return false;
}
return true;
}
use of org.eclipse.core.resources.IProject in project AutoRefactor by JnRouvignac.
the class JavaCoreHelper method createJavaProject.
public static IJavaProject createJavaProject(String projectName, String binFolderName) throws Exception {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject project = root.getProject(projectName);
if (!project.exists()) {
project.create(null);
} else {
project.refreshLocal(IResource.DEPTH_INFINITE, null);
}
if (!project.isOpen()) {
project.open(null);
}
final IFolder binFolder = project.getFolder(binFolderName);
createFolder(binFolder);
addNatureToProject(project, JavaCore.NATURE_ID);
final IJavaProject javaProject = JavaCore.create(project);
javaProject.setOutputLocation(binFolder.getFullPath(), null);
javaProject.setRawClasspath(new IClasspathEntry[0], null);
return javaProject;
}
use of org.eclipse.core.resources.IProject in project AutoRefactor by JnRouvignac.
the class JavaCoreHelper method addSourceContainer.
private static IPackageFragmentRoot addSourceContainer(IJavaProject javaProject, String containerName) throws Exception {
final IProject project = javaProject.getProject();
final IFolder folder = project.getFolder(containerName);
createFolder(folder);
IPackageFragmentRoot root = javaProject.getPackageFragmentRoot(folder);
IClasspathEntry cpe = JavaCore.newSourceEntry(root.getPath(), EMPTY_PATHS, EMPTY_PATHS, null);
addToClasspath(javaProject, Arrays.asList(cpe));
return root;
}
use of org.eclipse.core.resources.IProject in project lwjgl by LWJGL.
the class LWJGLClasspathContainerPage method getPlaceholderProject.
public static IJavaProject getPlaceholderProject() {
//$NON-NLS-1$
String name = "####internal";
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
while (true) {
IProject project = root.getProject(name);
if (!project.exists()) {
return JavaCore.create(project);
}
name += '1';
}
}
use of org.eclipse.core.resources.IProject in project azure-tools-for-java by Microsoft.
the class ViewDockerHostAction method actionPerformed.
@Override
public void actionPerformed(NodeActionEvent e) {
IProject project;
try {
project = AzureDockerUIResources.getCurrentSelectedProject();
} catch (Exception Ignored) {
project = null;
}
if (project == null) {
project = (IProject) dockerHostNode.getProject();
}
AzureViewDockerDialog viewDockerDialog = new AzureViewDockerDialog(PluginUtil.getParentShell(), project, dockerHost, dockerManager);
viewDockerDialog.open();
if (viewDockerDialog.getInternalExitCode() == AzureViewDockerDialog.UPDATE_EXIT_CODE) {
if (dockerHost != null && !dockerHost.isUpdating) {
AzureDockerUIResources.updateDockerHost(PluginUtil.getParentShell(), project, new EditableDockerHost(dockerHost), dockerManager, true);
} else {
PluginUtil.displayErrorDialog(PluginUtil.getParentShell(), "Error: Invalid Edit Selection", "The selected Docker host can not be edited at this time!");
}
}
}
Aggregations