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();
}
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();
}
Aggregations