Search in sources :

Example 1 with OKHandler

use of net.heartsome.cat.ts.websearch.ui.dialog.AddSearchEntryDialog.OKHandler 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 2 with OKHandler

use of net.heartsome.cat.ts.websearch.ui.dialog.AddSearchEntryDialog.OKHandler 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)2 AddSearchEntryDialog (net.heartsome.cat.ts.websearch.ui.dialog.AddSearchEntryDialog)2 OKHandler (net.heartsome.cat.ts.websearch.ui.dialog.AddSearchEntryDialog.OKHandler)2