Search in sources :

Example 26 with TableItem

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;
        }
    }
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) File(java.io.File)

Example 27 with TableItem

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++;
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) Vector(java.util.Vector)

Example 28 with TableItem

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);
            }
        }
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) TableItem(org.eclipse.swt.widgets.TableItem) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) File(java.io.File)

Example 29 with TableItem

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();
}
Also used : FsListToTreeRunnable(com.wuntee.oter.view.widgets.runnable.FsListToTreeRunnable) TableItem(org.eclipse.swt.widgets.TableItem) FileToStyledTextRunnable(com.wuntee.oter.view.widgets.runnable.FileToStyledTextRunnable) FsListToTreeRunnable(com.wuntee.oter.view.widgets.runnable.FsListToTreeRunnable) List(java.util.List) AndroidManifestObject(com.wuntee.oter.aapt.androidmanifest.AndroidManifestObject) File(java.io.File) IOException(java.io.IOException) CommandFailedException(com.wuntee.oter.exception.CommandFailedException) SQLException(java.sql.SQLException)

Example 30 with TableItem

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();
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) File(java.io.File) IOException(java.io.IOException) CommandFailedException(com.wuntee.oter.exception.CommandFailedException) SQLException(java.sql.SQLException)

Aggregations

TableItem (org.eclipse.swt.widgets.TableItem)323 Point (org.eclipse.swt.graphics.Point)76 Table (org.eclipse.swt.widgets.Table)58 SelectionEvent (org.eclipse.swt.events.SelectionEvent)56 ArrayList (java.util.ArrayList)46 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)40 GridData (org.eclipse.swt.layout.GridData)40 Composite (org.eclipse.swt.widgets.Composite)34 HashMap (java.util.HashMap)33 GridLayout (org.eclipse.swt.layout.GridLayout)33 Map (java.util.Map)31 TableColumn (org.eclipse.swt.widgets.TableColumn)31 List (java.util.List)27 HashSet (java.util.HashSet)25 Rectangle (org.eclipse.swt.graphics.Rectangle)23 Button (org.eclipse.swt.widgets.Button)23 Label (org.eclipse.swt.widgets.Label)22 TreeItem (org.eclipse.swt.widgets.TreeItem)17 Constraint (com.cubrid.common.core.common.model.Constraint)16 TableEditor (org.eclipse.swt.custom.TableEditor)16