use of org.eclipse.core.resources.IContainer in project translationstudio8 by heartsome.
the class ResourceDropAdapterAssistant method handleDrop.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.navigator.CommonDropAdapterAssistant#handleDrop(CommonDropAdapter,
* DropTargetEvent, Object)
*/
public IStatus handleDrop(CommonDropAdapter aDropAdapter, DropTargetEvent aDropTargetEvent, Object aTarget) {
if (Policy.DEBUG_DND) {
System.out.println(//$NON-NLS-1$
"ResourceDropAdapterAssistant.handleDrop (begin)");
}
// alwaysOverwrite = false;
if (aTarget == null || aDropTargetEvent.data == null) {
return Status.CANCEL_STATUS;
}
IStatus status = null;
IResource[] resources = null;
TransferData currentTransfer = aDropAdapter.getCurrentTransfer();
if (LocalSelectionTransfer.getTransfer().isSupportedType(currentTransfer)) {
resources = getSelectedResources();
} else if (ResourceTransfer.getInstance().isSupportedType(currentTransfer)) {
resources = (IResource[]) aDropTargetEvent.data;
}
if (FileTransfer.getInstance().isSupportedType(currentTransfer)) {
status = performFileDrop(aDropAdapter, aDropTargetEvent.data);
} else if (resources != null && resources.length > 0) {
if ((aDropAdapter.getCurrentOperation() == DND.DROP_COPY) || (aDropAdapter.getCurrentOperation() == DND.DROP_LINK)) {
if (Policy.DEBUG_DND) {
System.out.println(//$NON-NLS-1$
"ResourceDropAdapterAssistant.handleDrop executing COPY.");
}
status = performResourceCopy(aDropAdapter, getShell(), resources);
} else {
if (Policy.DEBUG_DND) {
System.out.println(//$NON-NLS-1$
"ResourceDropAdapterAssistant.handleDrop executing MOVE.");
}
status = performResourceMove(aDropAdapter, resources);
}
}
openError(status);
IContainer target = getActualTarget((IResource) aTarget);
if (target != null && target.isAccessible()) {
try {
target.refreshLocal(IResource.DEPTH_ONE, null);
} catch (CoreException e) {
}
}
return status;
}
use of org.eclipse.core.resources.IContainer in project translationstudio8 by heartsome.
the class WizardExportResourcesPage2 method getResourceProvider.
/**
* Returns a content provider for <code>IResource</code>s that returns only children of the given resource type.
*/
private ITreeContentProvider getResourceProvider(final int resourceType) {
return new WorkbenchContentProvider() {
public Object[] getChildren(Object o) {
if (o instanceof IContainer) {
IResource[] members = null;
try {
members = ((IContainer) o).members();
} catch (CoreException e) {
// just return an empty set of children
return new Object[0];
}
// filter out the desired resource types
ArrayList results = new ArrayList();
for (int i = 0; i < members.length; i++) {
if (members[i].getName().equals(".config") || members[i].getName().equals(".project") || members[i].getName().equalsIgnoreCase(".temp")) {
defaultExportItems.add(members[i]);
continue;
}
// And the test bits with the resource types to see if they are what we want
if ((members[i].getType() & resourceType) > 0) {
results.add(members[i]);
}
}
return results.toArray();
}
// input element case
if (o instanceof ArrayList) {
return ((ArrayList) o).toArray();
}
return new Object[0];
}
};
}
use of org.eclipse.core.resources.IContainer in project translationstudio8 by heartsome.
the class WizardExportResourcesPage2 method setupSelectionsBasedOnSelectedTypes.
/**
* Update the tree to only select those elements that match the selected types
*/
private void setupSelectionsBasedOnSelectedTypes() {
Runnable runnable = new Runnable() {
public void run() {
Map selectionMap = new Hashtable();
// Only get the white selected ones
Iterator resourceIterator = resourceGroup.getAllWhiteCheckedItems().iterator();
while (resourceIterator.hasNext()) {
// handle the files here - white checked containers require recursion
IResource resource = (IResource) resourceIterator.next();
if (resource.getType() == IResource.FILE) {
if (hasExportableExtension(resource.getName())) {
List resourceList = new ArrayList();
IContainer parent = resource.getParent();
if (selectionMap.containsKey(parent)) {
resourceList = (List) selectionMap.get(parent);
}
resourceList.add(resource);
selectionMap.put(parent, resourceList);
}
} else {
setupSelectionsBasedOnSelectedTypes(selectionMap, (IContainer) resource);
}
}
resourceGroup.updateSelections(selectionMap);
}
};
BusyIndicator.showWhile(getShell().getDisplay(), runnable);
}
use of org.eclipse.core.resources.IContainer in project translationstudio8 by heartsome.
the class EditProgressFA method wordsSetInputData.
/**
* 向字数分析的字数展示模块填充数据
* @param curContainer
* @param wordsFAdata
*/
public void wordsSetInputData(IContainer curContainer, StringBuffer wordsFAdata, int paddLeft) {
paddLeft += 10;
// 先判断该容器中是否有直接子文件为本次分析文件
if (hasFAIFiles(curContainer)) {
// 每个文件的具体数据
for (int fIndex = 0; fIndex < model.getAnalysisIFileList().size(); fIndex++) {
IFile curIFile = model.getAnalysisIFileList().get(fIndex);
if (curIFile.getParent().equals(curContainer)) {
EditProgressFAResult faResult = editProgFAResultMap.get(curIFile.getLocation().toOSString());
wordsFAdata.append("\t\t<tr id='" + curContainer.getFullPath().toOSString() + "' name='words' " + "onmouseover= \"this.bgColor= '#F1F1FC'\" onmouseout= \"this.bgColor='#FFFFFF'\" bgcolor='#FFFFFF'>\n");
wordsFAdata.append("\t\t\t<td class='fileTd' style='padding-left: " + paddLeft + "'>" + curIFile.getName() + // 文件名
"</td>\n");
wordsFAdata.append("\t\t\t<td class='fileTd' align='right'>" + faResult.getNotApprovedWords() + // 未批准字数
"</td>\n");
wordsFAdata.append("\t\t\t<td class='fileTd' align='right'>" + faResult.getNotApprovedWordsRatio() + // 未批准字数比例
"</td>\n");
wordsFAdata.append("\t\t\t<td class='fileTd' align='right'>" + faResult.getApprovedWords() + // 已批准字数
"</td>\n");
wordsFAdata.append("\t\t\t<td class='fileTd' align='right'>" + faResult.getApprovedWordsRatio() + // 已批准字数比例
"</td>\n");
wordsFAdata.append("\t\t\t<td class='fileTd' align='right'>" + faResult.getLockedWords() + // 锁定字数
"</td>\n");
wordsFAdata.append("\t\t\t<td class='fileTd' align='right'>" + faResult.getTotalWords() + // 总字数
"</td>\n");
wordsFAdata.append("\t\t</tr>\n");
}
}
}
// 遍历所有含有分析文件的容器,找出当前容器的子容器,
for (int index = 0; index < allFolderList.size(); index++) {
IContainer childContainer = allFolderList.get(index);
if (childContainer.getParent().equals(curContainer)) {
EditProgressFAResult faResult = editProgFAResultMap.get(childContainer.getLocation().toOSString());
String folderId = childContainer.getFullPath().toOSString();
wordsFAdata.append("<tr id='" + curContainer.getFullPath().toOSString() + "' name='words' " + "onmouseover= \"this.bgColor= '#F1F1FC'\" onmouseout= \"this.bgColor='#FFFFFF'\" bgcolor='#FFFFFF'>\n" + "<td class='folderTd' ><a href='javascript:void(0)' id='" + folderId + "' name='words' class='link' style='padding-left: " + paddLeft + "'" + "title='" + Messages.getString("qa.all.fa.clickToShrink") + "' onclick='clickFolder(id, name)'>" + "<span id='" + folderId + "_span'>-</span> " + childContainer.getName() + "</a></td>\n" + "<td class='folderTd' align='right'>" + faResult.getNotApprovedWords() + "</td>\n" + "<td class='folderTd' align='right'>" + faResult.getNotApprovedWordsRatio() + "</td>\n" + "<td class='folderTd' align='right'>" + faResult.getApprovedWords() + "</td>\n" + "<td class='folderTd' align='right'>" + faResult.getApprovedWordsRatio() + "</td>\n" + "<td class='folderTd' align='right'>" + faResult.getLockedWords() + "</td>\n" + "<td class='folderTd' align='right'>" + faResult.getTotalWords() + "</td>\n" + "</tr>\n");
wordsSetInputData(childContainer, wordsFAdata, paddLeft);
}
}
}
use of org.eclipse.core.resources.IContainer in project translationstudio8 by heartsome.
the class EditProgressFA method createFAResultHtml.
public String createFAResultHtml() {
allFolderList = new LinkedList<IContainer>();
Date createDate = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String createTime = formatter.format(createDate);
formatter = new SimpleDateFormat("yyyyMMdd-HHmmss");
String htmlNameTime = formatter.format(createDate);
IProject curProject = model.getAnalysisIFileList().get(0).getProject();
String htmlName = "EDLog" + htmlNameTime + ".html";
String htmlPath = curProject.getLocation().append("Intermediate").append("Report").append(htmlName).toOSString();
File htmlFile = new File(htmlPath);
if (!htmlFile.getParentFile().exists()) {
htmlFile.getParentFile().mkdirs();
}
FileOutputStream output;
try {
output = new FileOutputStream(htmlPath);
output.write(QAConstant.FA_HtmlDoctype.getBytes("UTF-8"));
output.write("<html>\n".getBytes("UTF-8"));
String headerNode = QAConstant.FA_htmlHeader;
headerNode = headerNode.replace("###Title###", Messages.getString("qa.fileAnalysis.EditProgressFA.tip2"));
output.write(headerNode.getBytes("UTF-8"));
output.write("\t<body>\n".getBytes("UTF-8"));
output.write(("<p class=\"title\">" + Messages.getString("qa.fileAnalysis.EditProgressFA.name1") + "</p>").getBytes("UTF-8"));
// ----------------<<<<<<start-- 下面是相关信息提示部份---------------------
output.write("\t<div>\n".getBytes("UTF-8"));
output.write("\t\t<table class=\"infoTableStyle\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n".getBytes("UTF-8"));
// 分析文件总数
String title = Messages.getString("qa.fa.info.fileSum");
String content = "" + model.getSubFileNum();
String infoStr = QAConstant.FA_Report_Info.replace("###Title###", title).replace("###Content###", content);
output.write(infoStr.getBytes("UTF-8"));
// 分析失败文件
title = Messages.getString("qa.fa.info.errorFiles");
StringBuffer errorFileSB = new StringBuffer();
errorFileSB.append("\t\t\t<div style=\"margin-bottom: 2px;\">");
errorFileSB.append(model.getErrorIFileList().size());
errorFileSB.append("</div>");
for (IFile iFile : model.getErrorIFileList()) {
errorFileSB.append("\t\t\t<div style=\"margin-bottom: 2px;\">");
errorFileSB.append(iFile.getFullPath().toOSString());
errorFileSB.append("</div>");
}
infoStr = QAConstant.FA_Report_Info.replace("###Title###", title).replace("###Content###", errorFileSB.toString());
output.write(infoStr.getBytes("UTF-8"));
// 报告生成时间
title = Messages.getString("qa.fa.info.createTime");
infoStr = QAConstant.FA_Report_Info.replace("###Title###", title).replace("###Content###", createTime);
output.write(infoStr.getBytes("UTF-8"));
output.write("</table></div><br>\n".getBytes("UTF-8"));
// ---------------->>>>>>end-- 报表信息提示部分结束---------------------
// --------------字数---------------------
output.write(("\t\t<div class=\"legendStyle\"><b>" + Messages.getString("qa.fileAnalysis.EditProgressFA.words") + "</b></div>").getBytes("UTF-8"));
StringBuffer wordsFAdata = new StringBuffer();
getAllFolder(curProject, allFolderList);
setDataToFolder(curProject);
// 创建一个表
wordsFAdata.append("\t<table class='tableStyle' cellpadding='0' cellspacing='1'> \n");
// 表头
wordsFAdata.append("\t\t<tr>\n");
wordsFAdata.append("\t\t\t<td class='headerTd' rowSpan='2' width='22%'>" + Messages.getString("qa.all.fa.fileName") + "</td>\n");
wordsFAdata.append("\t\t\t<td class='headerTd' colSpan='2' width='26%'>" + Messages.getString("qa.fileAnalysis.EditProgressFA.nonApprove") + "</td>\n");
wordsFAdata.append("\t\t\t<td class='headerTd' colSpan='2' width='26%'>" + Messages.getString("qa.fileAnalysis.EditProgressFA.approved") + "</td>\n");
wordsFAdata.append("\t\t\t<td class='headerTd' rowSpan='2' width='13%'>" + Messages.getString("qa.fileAnalysis.EditProgressFA.lockWordsNum") + "</td>\n");
wordsFAdata.append("\t\t\t<td class='headerTd' rowSpan='2' width='13%'>" + Messages.getString("qa.fileAnalysis.EditProgressFA.wordsSum") + "</td>\n");
wordsFAdata.append("\t\t</tr>\n");
wordsFAdata.append("\t\t<tr>\n");
wordsFAdata.append("\t\t\t<td class='headerTd' width='13%'>" + Messages.getString("qa.fileAnalysis.EditProgressFA.approveWords") + "</td>\n");
wordsFAdata.append("\t\t\t<td class='headerTd' width='13%'>" + Messages.getString("qa.fileAnalysis.EditProgressFA.approveProp") + "</td>\n");
wordsFAdata.append("\t\t\t<td class='headerTd' width='13%'>" + Messages.getString("qa.fileAnalysis.EditProgressFA.approveWords") + "</td>\n");
wordsFAdata.append("\t\t\t<td class='headerTd' width='13%'>" + Messages.getString("qa.fileAnalysis.EditProgressFA.approveProp") + "</td>\n");
wordsFAdata.append("\t\t</tr>\n");
// 首先写下项目
EditProgressFAResult proFaResult = editProgFAResultMap.get(curProject.getLocation().toOSString());
int paddLeft = 6;
String folderId = curProject.getFullPath().toOSString();
wordsFAdata.append("<tr onmouseover= \"this.bgColor= '#F1F1FC'\" onmouseout= \"this.bgColor='#FFFFFF'\" bgcolor='#FFFFFF'>\n" + "<td class='folderTd' style='padding-left: 6'>\n" + "<a href='javascript:void(0)' id='" + folderId + "' name='words' class='link' " + "title='" + Messages.getString("qa.all.fa.clickToShrink") + "' onclick='clickFolder(id, name)' >" + "<span id='" + folderId + "_span'>-</span> " + curProject.getName() + "</a></td>\n" + "<td class='folderTd' align='right'>" + proFaResult.getNotApprovedWords() + "</td>\n" + "<td class='folderTd' align='right'>" + proFaResult.getNotApprovedWordsRatio() + "</td>\n" + "<td class='folderTd' align='right'>" + proFaResult.getApprovedWords() + "</td>\n" + "<td class='folderTd' align='right'>" + proFaResult.getApprovedWordsRatio() + "</td>\n" + "<td class='folderTd' align='right'>" + proFaResult.getLockedWords() + "</td>\n" + "<td class='folderTd' align='right'>" + proFaResult.getTotalWords() + "</td>\n" + "</tr>\n");
wordsSetInputData(curProject, wordsFAdata, paddLeft);
wordsFAdata.append("\t</table>\n");
output.write(wordsFAdata.toString().getBytes("UTF-8"));
output.write("<br/>\n".getBytes("UTF-8"));
// --------------文本段---------------------
output.write(("\t\t<div class=\"legendStyle\"><b>" + Messages.getString("qa.fileAnalysis.EditProgressFA.paragraph") + "</b></div>").getBytes("UTF-8"));
StringBuffer paraFAdata = new StringBuffer();
// 创建一个表
paraFAdata.append("\t<table class='tableStyle' cellpadding='0' cellspacing='1'> \n");
// 表头
paraFAdata.append("\t\t<tr>\n");
paraFAdata.append("\t\t\t<td class='headerTd' rowSpan='2' width='22%'>" + Messages.getString("qa.all.fa.fileName") + "</td>\n");
paraFAdata.append("\t\t\t<td class='headerTd' colSpan='2' width='26%'>" + Messages.getString("qa.fileAnalysis.EditProgressFA.nonApprove") + "</td>\n");
paraFAdata.append("\t\t\t<td class='headerTd' colSpan='2' width='26%'>" + Messages.getString("qa.fileAnalysis.EditProgressFA.approved") + "</td>\n");
paraFAdata.append("\t\t\t<td class='headerTd' rowSpan='2' width='13%'>" + Messages.getString("qa.fileAnalysis.EditProgressFA.lockParasNum") + "</td>\n");
paraFAdata.append("\t\t\t<td class='headerTd' rowSpan='2' width='13%'>" + Messages.getString("qa.fileAnalysis.EditProgressFA.paraSum") + "</td>\n");
paraFAdata.append("\t\t</tr>\n");
paraFAdata.append("\t\t<tr>\n");
paraFAdata.append("\t\t\t<td class='headerTd' width='13%'>" + Messages.getString("qa.fileAnalysis.EditProgressFA.approveParaNum") + "</td>\n");
paraFAdata.append("\t\t\t<td class='headerTd' width='13%'>" + Messages.getString("qa.fileAnalysis.EditProgressFA.approveProp") + "</td>\n");
paraFAdata.append("\t\t\t<td class='headerTd' width='13%'>" + Messages.getString("qa.fileAnalysis.EditProgressFA.approveParaNum") + "</td>\n");
paraFAdata.append("\t\t\t<td class='headerTd' width='13%'>" + Messages.getString("qa.fileAnalysis.EditProgressFA.approveProp") + "</td>\n");
paraFAdata.append("\t\t</tr>\n");
// 首先写下项目
paddLeft = 6;
paraFAdata.append("<tr onmouseover= \"this.bgColor= '#F1F1FC'\" onmouseout= \"this.bgColor='#FFFFFF'\" bgcolor='#FFFFFF'>\n" + "<td class='folderTd' style='padding-left: 6'>\n" + "<a href='javascript:void(0)' id='" + folderId + "' name='paras' class='link' title='" + Messages.getString("qa.all.fa.clickToShrink") + "' " + " onclick='clickFolder(id, name)'><span id='" + folderId + "_span'>-</span> " + curProject.getName() + "</a></td>\n" + "<td class='folderTd' align='right'>" + proFaResult.getNotApprovedParas() + "</td>\n" + "<td class='folderTd' align='right'>" + proFaResult.getNotApprovedParasRatio() + "</td>\n" + "<td class='folderTd' align='right'>" + proFaResult.getApprovedParas() + "</td>\n" + "<td class='folderTd' align='right'>" + proFaResult.getApprovedParasRatio() + "</td>\n" + "<td class='folderTd' align='right'>" + proFaResult.getLockedParas() + "</td>\n" + "<td class='folderTd' align='right'>" + proFaResult.getTotalParas() + "</td>\n" + "</tr>");
paraSetInputData(curProject, paraFAdata, paddLeft);
paraFAdata.append("\t</table>\n");
output.write(paraFAdata.toString().getBytes("UTF-8"));
/*String htmlPathDiv = "<div style='width:100%;font-size:14;color:blue;'>"+Messages.getString("qa.all.fa.fileLocation")
+ curProject.getFullPath().append("Report").append(htmlName).toOSString() + "</div>";
output.write(htmlPathDiv.getBytes("UTF-8"));*/
// -----------文本段结束--------------
output.write("\t</body>\n".getBytes("UTF-8"));
output.write("</html>".getBytes("UTF-8"));
output.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
logger.error(Messages.getString("qa.fileAnalysis.EditProgressFA.log3"), e);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
logger.error(Messages.getString("qa.fileAnalysis.EditProgressFA.log4"), e);
} catch (IOException e) {
e.printStackTrace();
logger.error(Messages.getString("qa.fileAnalysis.EditProgressFA.log5"), e);
}
return htmlPath;
}
Aggregations