Search in sources :

Example 6 with SearchEntry

use of net.heartsome.cat.ts.websearch.bean.SearchEntry in project translationstudio8 by heartsome.

the class BrowserViewPart method refreshTabContent.

public void refreshTabContent() {
    if (browserTabs != null && browserTabs.length != 0) {
        for (BrowserTab tab : browserTabs) {
            tab.close();
        }
    }
    browserTabs = new BrowserTab[urls.size()];
    for (int i = 0; i < urls.size(); i++) {
        SearchEntry searchEntry = urls.get(i);
        browserTabs[i] = new BrowserTab(searchEntry);
        CTabItem item = new CTabItem(tabFolder, SWT.NONE);
        browserTabs[i].setItem(item);
        item.setText(searchEntry.getSearchName().replaceAll("&", "&&"));
        item.setControl(browserTabs[i].createTabFolderPage(tabFolder));
        item.setData(browserTabs[i]);
        Image image = getImage(searchEntry.getSearchUrl());
        if (null != image) {
            item.setImage(image);
        }
        browserTabs[i].searchKeyWord(keyWordForSearch.getText());
    }
    tabFolder.setSelection(0);
    tabFolder.layout();
}
Also used : Image(org.eclipse.swt.graphics.Image) CTabItem(org.eclipse.swt.custom.CTabItem) SearchEntry(net.heartsome.cat.ts.websearch.bean.SearchEntry) BrowserTab(net.heartsome.cat.ts.websearch.ui.browser.BrowserTab)

Example 7 with SearchEntry

use of net.heartsome.cat.ts.websearch.bean.SearchEntry in project translationstudio8 by heartsome.

the class WebSearchPreferencePage method upSelectItem.

public void upSelectItem() {
    int selectIndex = getSelectIndex();
    if (-1 == selectIndex || 0 == selectIndex) {
        return;
    }
    SearchEntry currentSelect = cache.get(selectIndex);
    SearchEntry lastData = cache.get(selectIndex - 1);
    cache.set(selectIndex - 1, currentSelect);
    cache.set(selectIndex, lastData);
    checkboxTableViewer.refresh();
    setDirty(true);
    updateState();
}
Also used : SearchEntry(net.heartsome.cat.ts.websearch.bean.SearchEntry)

Example 8 with SearchEntry

use of net.heartsome.cat.ts.websearch.bean.SearchEntry in project translationstudio8 by heartsome.

the class WebSearchPreferencePage method editItem.

public void editItem() {
    final SearchEntry selectTableItem = getSelectTableItem();
    if (null == selectTableItem) {
        return;
    }
    final String oldName = selectTableItem.getSearchName();
    final String oldUrl = selectTableItem.getSearchUrl();
    final boolean isChecked = selectTableItem.isChecked();
    AddSearchEntryDialog addDilog = new AddSearchEntryDialog(getShell(), selectTableItem, AddSearchEntryDialog.EDIT);
    addDilog.setHandler(new OKHandler() {

        @Override
        public boolean doOk() {
            if (//
            oldName.equals(selectTableItem.getSearchName()) && //
            isChecked == selectTableItem.isChecked() && oldUrl.equals(selectTableItem.getSearchUrl())) {
                return false;
            }
            if (hasDisplayNameDulicate(cache, selectTableItem)) {
                selectTableItem.setChecked(isChecked);
                selectTableItem.setSearchName(oldName);
                selectTableItem.setSearchUrl(oldUrl);
                MessageDialog.openInformation(getShell(), Messages.getString("Websearch.WebSearcPreferencePage.tipTitle"), Messages.getString("Websearch.WebSearcPreferencePage.hasDuplicateName"));
                return false;
            }
            if (hasDupliacateUrl(cache, selectTableItem)) {
                selectTableItem.setChecked(isChecked);
                selectTableItem.setSearchName(oldName);
                selectTableItem.setSearchUrl(oldUrl);
                MessageDialog.openInformation(getShell(), Messages.getString("Websearch.WebSearcPreferencePage.tipTitle"), Messages.getString("Websearch.WebSearcPreferencePage.hasDuplicateUrl"));
                return false;
            }
            setDirty(true);
            checkboxTableViewer.refresh();
            updateState();
            return true;
        }
    });
    addDilog.open();
}
Also used : OKHandler(net.heartsome.cat.ts.websearch.ui.dialog.AddSearchEntryDialog.OKHandler) AddSearchEntryDialog(net.heartsome.cat.ts.websearch.ui.dialog.AddSearchEntryDialog) SearchEntry(net.heartsome.cat.ts.websearch.bean.SearchEntry)

Example 9 with SearchEntry

use of net.heartsome.cat.ts.websearch.bean.SearchEntry in project translationstudio8 by heartsome.

the class WebSearchPreferencePage method importConfig.

public void importConfig() {
    boolean config = MessageDialog.openConfirm(getShell(), Messages.getString("Websearch.WebSearcPreferencePage.tipTitle"), Messages.getString("Websearch.WebSearcPreferencePage.importConfig"));
    if (!config) {
        return;
    }
    FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);
    dialog.setFilterExtensions(new String[] { "*.xml" });
    dialog.open();
    String filterPath = dialog.getFilterPath();
    if (null == filterPath || filterPath.isEmpty()) {
        return;
    }
    String fileName = dialog.getFileName();
    if (fileName == null) {
        return;
    }
    String filePath = filterPath + File.separator + fileName;
    List<SearchEntry> importSearchConfig = WebSearchPreferencStore.getIns().importSearchConfig(filePath);
    if (null == importSearchConfig || importSearchConfig.isEmpty()) {
        MessageDialog.openError(getShell(), Messages.getString("Websearch.WebSearcPreferencePage.errorTitle"), Messages.getString("Websearch.WebSearcPreferencePage.importError"));
        return;
    } else {
        cache = importSearchConfig;
        refreshTable(cache);
        setDirty(true);
    }
}
Also used : FileDialog(org.eclipse.swt.widgets.FileDialog) SearchEntry(net.heartsome.cat.ts.websearch.bean.SearchEntry)

Example 10 with SearchEntry

use of net.heartsome.cat.ts.websearch.bean.SearchEntry in project translationstudio8 by heartsome.

the class WebSearchPreferencePage method addItem.

public void addItem() {
    final SearchEntry entry = new SearchEntry();
    AddSearchEntryDialog addDilog = new AddSearchEntryDialog(getShell(), entry, AddSearchEntryDialog.ADD);
    addDilog.setHandler(new OKHandler() {

        @Override
        public boolean doOk() {
            if (null == entry.getSearchName()) {
                return false;
            }
            if (hasDisplayNameDulicate(cache, entry)) {
                MessageDialog.openInformation(getShell(), Messages.getString("Websearch.WebSearcPreferencePage.tipTitle"), Messages.getString("Websearch.WebSearcPreferencePage.hasDuplicateName"));
                return false;
            }
            if (hasDupliacateUrl(cache, entry)) {
                MessageDialog.openInformation(getShell(), Messages.getString("Websearch.WebSearcPreferencePage.tipTitle"), Messages.getString("Websearch.WebSearcPreferencePage.hasDuplicateUrl"));
                return false;
            }
            cache.add(entry);
            setDirty(true);
            checkboxTableViewer.refresh();
            updateState();
            return true;
        }
    });
    addDilog.open();
}
Also used : OKHandler(net.heartsome.cat.ts.websearch.ui.dialog.AddSearchEntryDialog.OKHandler) AddSearchEntryDialog(net.heartsome.cat.ts.websearch.ui.dialog.AddSearchEntryDialog) SearchEntry(net.heartsome.cat.ts.websearch.bean.SearchEntry)

Aggregations

SearchEntry (net.heartsome.cat.ts.websearch.bean.SearchEntry)10 XPathParseException (com.ximpleware.XPathParseException)2 AddSearchEntryDialog (net.heartsome.cat.ts.websearch.ui.dialog.AddSearchEntryDialog)2 OKHandler (net.heartsome.cat.ts.websearch.ui.dialog.AddSearchEntryDialog.OKHandler)2 AutoPilot (com.ximpleware.AutoPilot)1 ModifyException (com.ximpleware.ModifyException)1 NavException (com.ximpleware.NavException)1 ParseException (com.ximpleware.ParseException)1 TranscodeException (com.ximpleware.TranscodeException)1 VTDNav (com.ximpleware.VTDNav)1 XMLModifier (com.ximpleware.XMLModifier)1 XPathEvalException (com.ximpleware.XPathEvalException)1 FileNotFoundException (java.io.FileNotFoundException)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ArrayList (java.util.ArrayList)1 BrowserTab (net.heartsome.cat.ts.websearch.ui.browser.BrowserTab)1 CTabItem (org.eclipse.swt.custom.CTabItem)1 Image (org.eclipse.swt.graphics.Image)1