use of org.eclipse.core.runtime.NullProgressMonitor in project translationstudio8 by heartsome.
the class ImportAbstract method doImport.
/**
* 导入文件内容
* @param fileContent
* @param srcLang
* @param monitor
* @return ;
* @throws ImportException
*/
public int doImport(String fileContent, String srcLang, IProgressMonitor monitor) throws ImportException {
if (monitor == null) {
this.monitor = new NullProgressMonitor();
} else {
this.monitor = monitor;
}
// 解析文件
String message = "";
VTDGen vg = new VTDGen();
vg.setDoc(fileContent.getBytes());
try {
vg.parse(true);
} catch (EncodingException e) {
logger.error(Messages.getString("document.ImportAbstract.logger1"), e);
message = Messages.getString("document.ImportAbstract.msg1");
throw new ImportException(message + e.getMessage());
} catch (EOFException e) {
logger.error("", e);
message = Messages.getString("document.ImportAbstract.tbx.msg1");
throw new ImportException(message + e.getMessage());
} catch (EntityException e) {
logger.error("", e);
message = Messages.getString("document.ImportAbstract.tbx.msg1");
throw new ImportException(message + e.getMessage());
} catch (ParseException e) {
logger.error(Messages.getString("document.ImportAbstract.logger3"), e);
String errMsg = e.getMessage();
if (errMsg.indexOf("invalid encoding") != -1) {
// 编码异常
message = Messages.getString("document.ImportAbstract.msg1");
} else {
message = Messages.getString("document.ImportAbstract.tbx.msg1");
}
throw new ImportException(message + e.getMessage());
}
try {
// 构建VTD解析工具
vu = new VTDUtils(vg.getNav());
dbOperator.beginTransaction();
// 执行导入
executeImport(srcLang);
dbOperator.commit();
} catch (VTDException e) {
logger.error("", e);
try {
dbOperator.rollBack();
} catch (SQLException e1) {
logger.error("", e);
}
return FAILURE_4;
} catch (SQLException e) {
logger.error("", e);
try {
dbOperator.rollBack();
} catch (SQLException e1) {
logger.error("", e1);
}
throw new ImportException(Messages.getString("document.ImportAbstract.tbx.importDbError") + e.getMessage());
} catch (OperationCanceledException e) {
logger.error("", e);
try {
dbOperator.rollBack();
} catch (SQLException e1) {
logger.error("", e1);
return CANCEL;
}
} catch (Exception e) {
logger.error("", e);
try {
dbOperator.rollBack();
} catch (SQLException e1) {
logger.error("", e1);
}
throw new ImportException(Messages.getString("document.ImportAbstract.tbx.importDbError") + e.getMessage());
}
return SUCCESS;
}
use of org.eclipse.core.runtime.NullProgressMonitor in project cubrid-manager by CUBRID.
the class UnifyHostConfigEditor method createToolBar.
/**
*
* Create the tool bar
*
* @param parent the Composite
*
*/
private void createToolBar(Composite parent) {
final Composite toolBarComp = new Composite(parent, SWT.NONE);
{
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
toolBarComp.setLayoutData(gd);
GridLayout gridLayout = new GridLayout();
gridLayout.marginHeight = 0;
gridLayout.horizontalSpacing = 0;
gridLayout.marginWidth = 0;
toolBarComp.setLayout(gridLayout);
}
ToolBar toolBar = new ToolBar(toolBarComp, SWT.FLAT);
ToolItem saveItem = new ToolItem(toolBar, SWT.PUSH);
saveItem.setImage(CubridManagerUIPlugin.getImage("icons/queryeditor/file_save.png"));
saveItem.setToolTipText(Messages.msgTipSaveAction);
saveItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (isDirty) {
String errMsg = validate();
if (errMsg != null) {
CommonUITool.openErrorBox(errMsg);
return;
}
doSave(new NullProgressMonitor());
setDirty(false);
}
}
});
new ToolItem(toolBar, SWT.SEPARATOR);
ToolItem addPropItem = new ToolItem(toolBar, SWT.PUSH);
addPropItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/table_record_insert.png"));
addPropItem.setToolTipText(com.cubrid.common.ui.common.Messages.cubridBrokerConfEditorAddPropItemLabel);
addPropItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
HashMap<String, String> dataMap = new HashMap<String, String>();
dataMap.put("0", "new property");
TableViewer addDataTableViewer = null;
if (confTabFolder.getSelection() == brokerConfTableCTabItem) {
cubridBrokerConfListData.add(dataMap);
addDataTableViewer = brokerConfTabTableViewer;
} else if (confTabFolder.getSelection() == cubridConfTableCTabItem) {
cubridConfConfigListData.add(dataMap);
addDataTableViewer = cubridConfTabTableViewer;
} else if (confTabFolder.getSelection() == cubridCMConfTableCTabItem) {
cubridConfCMConfigListData.add(dataMap);
addDataTableViewer = cubridCMConfTabTableViewer;
}
for (int i = 1; i < addDataTableViewer.getTable().getColumnCount(); i++) {
dataMap.put(i + "", "");
}
addDataTableViewer.refresh();
setDirty(true);
addDataTableViewer.getTable().showItem(addDataTableViewer.getTable().getItem(addDataTableViewer.getTable().getItemCount() - 1));
}
});
ToolItem deletePropItem = new ToolItem(toolBar, SWT.PUSH);
deletePropItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/table_record_delete.png"));
deletePropItem.setToolTipText(com.cubrid.common.ui.common.Messages.cubridBrokerConfEditorDeletePropItemLabel);
deletePropItem.addSelectionListener(new SelectionAdapter() {
@SuppressWarnings("all")
public void widgetSelected(SelectionEvent event) {
TableViewer delDataTableViewer = null;
List<Map<String, String>> delConfListData = null;
if (confTabFolder.getSelection() == brokerConfTableCTabItem) {
delDataTableViewer = brokerConfTabTableViewer;
delConfListData = cubridBrokerConfListData;
} else if (confTabFolder.getSelection() == cubridConfTableCTabItem) {
delDataTableViewer = cubridConfTabTableViewer;
delConfListData = cubridConfConfigListData;
} else if (confTabFolder.getSelection() == cubridCMConfTableCTabItem) {
delDataTableViewer = cubridCMConfTabTableViewer;
delConfListData = cubridConfCMConfigListData;
}
int selectionIndex = delDataTableViewer.getTable().getSelectionIndex();
if (selectionIndex < 0) {
CommonUITool.openErrorBox(com.cubrid.common.ui.common.Messages.cubridBrokerConfEditorDeletePropertyMsg);
return;
}
IStructuredSelection selection = (IStructuredSelection) delDataTableViewer.getSelection();
HashMap<String, String> valueMap = (HashMap<String, String>) selection.getFirstElement();
if (!CommonUITool.openConfirmBox(Messages.bind(com.cubrid.common.ui.common.Messages.cubridBrokerConfEditorDeleteBrokerPropConfirm, valueMap.get("0")))) {
return;
}
delConfListData.remove(valueMap);
delDataTableViewer.refresh();
setDirty(true);
}
});
}
use of org.eclipse.core.runtime.NullProgressMonitor in project cubrid-manager by CUBRID.
the class EditConfigEditor method createToolBar.
/**
*
* Create the tool bar
*
* @param parent the Composite
*
*/
private void createToolBar(Composite parent) {
final Composite toolBarComp = new Composite(parent, SWT.NONE);
{
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
toolBarComp.setLayoutData(gd);
GridLayout gridLayout = new GridLayout();
gridLayout.marginHeight = 0;
gridLayout.horizontalSpacing = 0;
gridLayout.marginWidth = 0;
toolBarComp.setLayout(gridLayout);
}
ToolBar toolBar = new ToolBar(toolBarComp, SWT.FLAT);
ToolItem saveItem = new ToolItem(toolBar, SWT.PUSH);
saveItem.setImage(CubridManagerUIPlugin.getImage("icons/queryeditor/file_save.png"));
saveItem.setToolTipText(Messages.msgTipSaveAction);
saveItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (isDirty) {
doSave(new NullProgressMonitor());
}
}
});
new ToolItem(toolBar, SWT.SEPARATOR);
ToolItem importItem = new ToolItem(toolBar, SWT.PUSH);
importItem.setImage(CubridManagerUIPlugin.getImage("icons/queryeditor/file_open.png"));
importItem.setToolTipText(Messages.msgTipOpenAction);
importItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
doImport();
}
});
ToolItem exportItem = new ToolItem(toolBar, SWT.PUSH);
exportItem.setImage(CubridManagerUIPlugin.getImage("icons/queryeditor/file_saveas.png"));
exportItem.setToolTipText(Messages.msgTipSaveasAction);
exportItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
doExport();
}
});
}
use of org.eclipse.core.runtime.NullProgressMonitor in project cubrid-manager by CUBRID.
the class EditQueryPlanDialog method initPara.
/**
* Sets the queryPlanInfo and selection which is a folder
*
* @param selection the selection to set
*/
public void initPara(DefaultSchemaNode selection) {
childrenLabel = new ArrayList<String>();
ICubridNode[] childrenNode = null;
QueryPlanInfo qpi = null;
if (operation == AddEditType.EDIT) {
qpi = (QueryPlanInfo) selection.getAdapter(QueryPlanInfo.class);
childrenNode = selection.getParent().getChildren(new NullProgressMonitor());
} else {
qpi = new QueryPlanInfo();
childrenNode = selection.getChildren(new NullProgressMonitor());
}
queryPlanInfo = new QueryPlanInfoHelp();
queryPlanInfo.setQueryPlanInfo(qpi);
database = selection.getDatabase();
for (ICubridNode childNode : childrenNode) {
childrenLabel.add(childNode.getLabel());
}
withUser = CompatibleUtil.isSupportQueryPlanWithUser(database.getDatabaseInfo());
}
use of org.eclipse.core.runtime.NullProgressMonitor in project cubrid-manager by CUBRID.
the class EditBackupPlanDialog method initPara.
/**
* Initials the backupPlanInfo,database and childrenLabel
*
* @param selection the selection to set
*/
public void initPara(DefaultSchemaNode selection) {
childrenLabel = new ArrayList<String>();
ICubridNode[] childrenNode = null;
database = selection.getDatabase();
if (operation == AddEditType.EDIT) {
backupPlanInfo = (BackupPlanInfo) selection.getAdapter(BackupPlanInfo.class);
childrenNode = selection.getParent().getChildren(new NullProgressMonitor());
} else {
backupPlanInfo = new BackupPlanInfo();
String dbPath = database.getDatabaseInfo().getDbDir();
dbPath = FileUtil.changeSeparatorByOS(dbPath, database.getServer().getServerInfo().getServerOsInfo());
defaultPath = dbPath + selection.getServer().getServerInfo().getPathSeparator() + "backup";
childrenNode = selection.getChildren(new NullProgressMonitor());
}
for (ICubridNode childNode : childrenNode) {
childrenLabel.add(childNode.getLabel());
}
}
Aggregations