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