use of org.eclipse.swt.widgets.TableItem in project translationstudio8 by heartsome.
the class XmlConverterConfigurationDialog method setTableSelection.
/**
* 选中列中表中已经编辑或已经添加的文件
* @param curentConvertXMl
* ;
*/
public void setTableSelection(String curConvertXMl) {
File convertXml = new File(curConvertXMl);
String convertXmlName = convertXml.getName();
TableItem[] items = table.getItems();
for (int i = 0; i < items.length; i++) {
if (items[i].getText(1).equals(convertXmlName)) {
table.setSelection(i);
return;
}
}
}
use of org.eclipse.swt.widgets.TableItem in project translationstudio8 by heartsome.
the class CSV2TMXConverterDialog method createItems.
/**
* @param line
*/
private void createItems(String line) {
int size = line.length();
if (size == 0) {
return;
}
if (countColumns(line) != cols) {
return;
}
StringBuffer buffer = new StringBuffer();
Vector<String> vector = new Vector<String>();
String[] strings = new String[cols];
boolean inDelimiters = false;
for (int i = 0; i < size; i++) {
//$NON-NLS-1$
String c = "" + line.charAt(i);
if (c.equals(textDelimiter)) {
inDelimiters = !inDelimiters;
continue;
}
if (!inDelimiters && c.equals(colSeparator)) {
vector.add(buffer.toString());
buffer = null;
buffer = new StringBuffer();
continue;
}
buffer.append(c);
}
if (!buffer.toString().equals("")) {
//$NON-NLS-1$
vector.add(buffer.toString());
}
for (int i = 0; i < vector.size(); i++) {
strings[i] = vector.get(i);
}
for (int i = vector.size(); i < cols; i++) {
//$NON-NLS-1$
strings[i] = "";
}
TableItem item = new TableItem(table, SWT.NONE);
item.setText(strings);
rows++;
}
use of org.eclipse.swt.widgets.TableItem in project translationstudio8 by heartsome.
the class TBXMakerDialog method export.
/**
* 导出文件 ;
*/
private void export() {
if (cols < 2) {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.TBXMakerDialog.msgTitle"), Messages.getString("dialog.TBXMakerDialog.msg2"));
return;
}
String[] langs = getUserLangs();
if (langs.length < 1) {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.TBXMakerDialog.msgTitle"), Messages.getString("dialog.TBXMakerDialog.msg3"));
return;
}
ExportDialog exportDialog = new ExportDialog(getShell(), csvPath);
if (exportDialog.open() == IDialogConstants.OK_ID) {
String exportFile = exportDialog.getFilePath();
if (exportFile == null) {
return;
}
try {
File f = new File(exportFile);
if (!f.exists() || f.isDirectory()) {
f.createNewFile();
}
output = new FileOutputStream(f);
rows = table.getItemCount();
//$NON-NLS-1$
writeString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
//$NON-NLS-1$
writeString("<!DOCTYPE martif PUBLIC \"ISO 12200:1999A//DTD MARTIF core (DXFcdV04)//EN\" \"TBXcdv04.dtd\">\n");
//$NON-NLS-1$ //$NON-NLS-2$
writeString("<martif type=\"TBX\" xml:lang=\"" + lang + "\">\n");
//$NON-NLS-1$
writeString("<martifHeader><fileDesc><sourceDesc><p>CSV to TBX Converter</p></sourceDesc></fileDesc>\n");
//$NON-NLS-1$ //$NON-NLS-2$
writeString("<encodingDesc><p type=\"DCSName\">" + template.getTemplateFileName() + "</p></encodingDesc>\n");
//$NON-NLS-1$
writeString("</martifHeader>\n<text>\n<body>\n");
for (int r = 0; r < rows; r++) {
TableItem item = table.getItem(r);
if (checkConcept(langs, item)) {
//$NON-NLS-1$ //$NON-NLS-2$
writeString("<termEntry id=\"" + createId() + "\">\n");
writeConceptLevelProps(item);
for (int l = 0; l < langs.length; l++) {
if (checkTerm(langs[l], item)) {
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
writeString("<langSet id=\"" + createId() + "\" xml:lang=\"" + langs[l] + "\">\n");
//$NON-NLS-1$
writeString("<tig>\n");
writeLangLevel(langs[l], item);
//$NON-NLS-1$
writeString("</tig>\n");
//$NON-NLS-1$
writeString("</langSet>\n");
}
}
//$NON-NLS-1$
writeString("</termEntry>\n");
}
}
//$NON-NLS-1$
writeString("</body>\n");
//$NON-NLS-1$
writeString("</text>\n");
//$NON-NLS-1$
writeString("</martif>");
MessageDialog.openInformation(getShell(), Messages.getString("dialog.TBXMakerDialog.msgTitle"), Messages.getString("dialog.TBXMakerDialog.msg4"));
} catch (FileNotFoundException e) {
LOGGER.error(Messages.getString("dialog.TBXMakerDialog.logger2"), e);
} catch (IOException e) {
LOGGER.error(Messages.getString("dialog.TBXMakerDialog.logger2"), e);
} finally {
try {
if (output != null) {
output.close();
}
} catch (IOException e) {
LOGGER.error(Messages.getString("dialog.TBXMakerDialog.logger2"), e);
}
}
}
}
use of org.eclipse.swt.widgets.TableItem in project otertool by wuntee.
the class PackageManagerController method loadPackageDetails.
public void loadPackageDetails(TableItem[] selection) {
if (selection.length > 1) {
return;
}
TableItem item = selection[0];
final PackageBean bean = (PackageBean) item.getData(PackageBean.class.getName());
logger.info("Loading package details for: " + bean.getApk());
gui.setStatus("Loading package details for: " + bean.getApk());
// Load file details
Thread details = new Thread(new Runnable() {
public void run() {
// Pull file
File apk = null;
try {
apk = AdbWorkshop.pullFile(bean.getApk());
} catch (Exception e) {
logger.error("Could not pull apk from device: ", e);
GuiWorkshop.messageErrorThreaded(gui, "Could not pull apk from device: " + e.getMessage());
}
if (apk != null) {
// Manifest
try {
final AndroidManifestObject root = AndroidManifestWorkshop.getAndroidManifestObjectsForApk(apk);
gui.runRunnableAsync(new Runnable() {
public void run() {
// Load data in gui
gui.getPackageManagerAndroidManifestTab().loadAndroidManifestObjects(root);
}
});
} catch (Exception e) {
logger.error("Could not parse the AndroidManifest.xml file: ", e);
GuiWorkshop.messageErrorThreaded(gui, "Could not parse the AndroidManifest.xml file: " + e.getMessage());
}
// AAPT
List<String> details = null;
try {
details = PackageManagerWorkshop.getDetailedPackageInfo(apk);
} catch (Exception e) {
logger.error("Could not get detailed package information: ", e);
GuiWorkshop.messageErrorThreaded(gui, "Could not get detailed package information: " + e.getMessage());
}
final StringBuffer sb = new StringBuffer();
if (details != null) {
for (String det : details) {
sb.append(det).append("\n");
}
}
gui.runRunnableAsync(new Runnable() {
public void run() {
// Load data in gui
gui.getPackageManagerStyledText().setText(sb.toString());
}
});
}
// Files
List<FsNode> files = null;
try {
files = FsWorkshop.getDirectoryRecursive("/data/data/" + bean.getClazz() + "/");
} catch (Exception e) {
logger.error("Could not get file listing: ", e);
GuiWorkshop.messageErrorThreaded(gui, "Could not get file listing: " + e.getMessage());
}
if (files != null) {
gui.runRunnableAsync(new FsListToTreeRunnable(files, gui.getPackageManagerFilesTree()));
}
gui.clearStatus();
}
});
details.start();
}
use of org.eclipse.swt.widgets.TableItem in project otertool by wuntee.
the class PackageManagerController method pullPackages.
public void pullPackages(String destinationDirectory) {
String error = "";
for (TableItem tableItem : gui.getApkTable().getTable().getSelection()) {
PackageBean bean = (PackageBean) tableItem.getData(PackageBean.class.getName());
gui.setStatusBlocking("Pulling: " + bean.getClazz());
try {
File dst = new File(destinationDirectory, bean.getClazz() + ".apk");
dst = AdbWorkshop.pullFileTo(bean.getApk(), dst.getAbsolutePath());
logger.debug("Pulled: " + dst.getAbsolutePath());
} catch (Exception e) {
error = error + "\n\t" + bean.getClazz();
}
}
if (error.equals("")) {
GuiWorkshop.messageDialog(gui.getShell(), "All files have been sucessfully pulled.");
} else {
GuiWorkshop.messageError(gui.getShell(), "Could not pull the following files:" + error);
}
gui.clearStatus();
}
Aggregations