use of org.eclipse.core.resources.IWorkspace in project translationstudio8 by heartsome.
the class ApplicationWorkbenchWindowAdvisor method addWorkplaceListener.
public void addWorkplaceListener() {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
workspace.addResourceChangeListener(new IResourceChangeListener() {
public void resourceChanged(IResourceChangeEvent event) {
//刷新项目导航视图
Display.getDefault().syncExec(new Runnable() {
public void run() {
IViewPart findView = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView("net.heartsome.cat.common.ui.navigator.view");
if (null == findView) {
return;
}
IAction refreshActionHandler = findView.getViewSite().getActionBars().getGlobalActionHandler(ActionFactory.REFRESH.getId());
if (null == refreshActionHandler) {
return;
}
refreshActionHandler.run();
}
});
}
});
}
use of org.eclipse.core.resources.IWorkspace in project translationstudio8 by heartsome.
the class SplitXliff method getFullPath.
/**
* 根据绝对路径获取其项目路径
* @param filePath
* @return
*/
public String getFullPath(String filePath) {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IPath location = Path.fromOSString(filePath);
IFile ifile = workspace.getRoot().getFileForLocation(location);
return ifile.getFullPath().toOSString();
}
use of org.eclipse.core.resources.IWorkspace in project translationstudio8 by heartsome.
the class ImportProjectWizardPage method isProjectInWorkspacePath.
/**
* Determine if there is a directory with the project name in the workspace path.
*
* @param projectName the name of the project
* @return true if there is a directory with the same name of the imported project
*/
private boolean isProjectInWorkspacePath(String projectName) {
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
IPath wsPath = workspace.getRoot().getLocation();
IPath localProjectPath = wsPath.append(projectName);
return localProjectPath.toFile().exists();
}
use of org.eclipse.core.resources.IWorkspace in project translationstudio8 by heartsome.
the class NewFolderDialogOfHs method isValidContainer.
/**
* Returns whether the container specified in the constructor is
* a valid parent for creating linked resources.
*
* @return boolean <code>true</code> if the container specified in
* the constructor is a valid parent for creating linked resources.
* <code>false</code> if no linked resources may be created with the
* specified container as a parent.
*/
private boolean isValidContainer() {
if (container.getType() != IResource.PROJECT && container.getType() != IResource.FOLDER) {
return false;
}
try {
IWorkspace workspace = IDEWorkbenchPlugin.getPluginWorkspace();
IProject project = container.getProject();
String[] natureIds = project.getDescription().getNatureIds();
for (int i = 0; i < natureIds.length; i++) {
IProjectNatureDescriptor descriptor = workspace.getNatureDescriptor(natureIds[i]);
if (descriptor != null && descriptor.isLinkingAllowed() == false) {
return false;
}
}
} catch (CoreException exception) {
// project does not exist or is closed
return false;
}
return true;
}
use of org.eclipse.core.resources.IWorkspace in project translationstudio8 by heartsome.
the class NewFolderDialogOfHs method validateFolderName.
/**
* Checks if the folder name is valid.
*
* @return null if the new folder name is valid.
* a message that indicates the problem otherwise.
*/
@SuppressWarnings("restriction")
private boolean validateFolderName() {
String name = folderNameField.getText();
IWorkspace workspace = container.getWorkspace();
IStatus nameStatus = workspace.validateName(name, IResource.FOLDER);
if ("".equals(name)) {
//$NON-NLS-1$
updateStatus(IStatus.ERROR, IDEWorkbenchMessages.NewFolderDialog_folderNameEmpty);
return false;
}
if (nameStatus.isOK() == false) {
updateStatus(nameStatus);
return false;
}
// 修改创建文件夹时,所进行的文件名特殊字符验证 --robert 2013-07-01
String result = null;
if ((result = CommonFunction.validResourceName(name)) != null) {
updateStatus(new ResourceStatus(IResourceStatus.INVALID_VALUE, null, result));
return false;
}
IPath path = new Path(name);
if (container.getFolder(path).exists() || container.getFile(path).exists()) {
updateStatus(IStatus.ERROR, NLS.bind(IDEWorkbenchMessages.NewFolderDialog_alreadyExists, name));
return false;
}
//$NON-NLS-1$
updateStatus(IStatus.OK, "");
return true;
}
Aggregations