use of com.cubrid.common.ui.spi.model.BrokerConfig in project cubrid-manager by CUBRID.
the class BrokerConfigEditorPart method loadData.
/**
* Load cubrid broker config info
*/
public void loadData() {
try {
if (firstView) {
String contents = persistUtil.loadCubridBrokerConfigString(confFile.getAbsoluteFile(), charset);
BrokerConfig brokerConf = persistUtil.parseStringLineToBrokerConfig(contents);
firstView = false;
editorComp.setBrokerConfig(brokerConf);
editorComp.createBrokerConfTableData();
}
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
}
}
use of com.cubrid.common.ui.spi.model.BrokerConfig in project cubrid-manager by CUBRID.
the class BrokerConfigEditorPart method saveData.
/**
* Save data to the open file
*/
public void saveData() {
try {
BrokerConfig brokerConf = editorComp.getBrokerConfig();
String contents = persistUtil.readBrokerConfig(brokerConf);
persistUtil.writeBrokerConfig(confFile, charset, contents);
openInformationBox(Messages.titleSuccess, Messages.cubridBrokerConfEditorSaveSucessMsg);
setDirty(false);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
openErrorBox(e.getMessage());
}
}
use of com.cubrid.common.ui.spi.model.BrokerConfig in project cubrid-manager by CUBRID.
the class EditCMCubridBrokerConfPart method createToolBarComp.
/**
* create tool barcomp
* @param parent
*/
public void createToolBarComp(Composite parent) {
Composite comp = new Composite(parent, SWT.NONE);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
comp.setLayoutData(gd);
GridLayout layout = new GridLayout(1, false);
layout.marginHeight = -1;
comp.setLayout(layout);
ToolBar toolbar = new ToolBar(comp, SWT.LEFT_TO_RIGHT | SWT.FLAT);
toolbar.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_END, 1, 1, -1, -1));
saveCubridBrokerConfItem = new ToolItem(toolbar, SWT.PUSH);
saveCubridBrokerConfItem.setImage(CubridManagerUIPlugin.getImage("icons/queryeditor/file_save.png"));
saveCubridBrokerConfItem.setToolTipText(com.cubrid.cubridmanager.ui.host.Messages.msgTipSaveAction);
saveCubridBrokerConfItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
//check whether contains duplicate property name
String errMsg = editorComp.validate();
if (errMsg != null) {
CommonUITool.openErrorBox(errMsg);
return;
}
doSave();
}
});
// Show/hide of the history pane
saveAsCubridBrokerConfItem = new ToolItem(toolbar, SWT.PUSH);
saveAsCubridBrokerConfItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/file_saveas.png"));
saveAsCubridBrokerConfItem.setToolTipText(Messages.cubridBrokerConfEditorSaveAsItemLabel);
saveAsCubridBrokerConfItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
//check whether contains duplicate property name
String errMsg = editorComp.validate();
if (errMsg != null) {
CommonUITool.openErrorBox(errMsg);
return;
}
ExportConfigDialog dialog = new ExportConfigDialog(getSite().getShell(), ConfigType.CUBRID_BROKER, true);
if (defaultExportFilePath != null && !"".equals(defaultExportFilePath)) {
dialog.setDefaultFilePath(defaultExportFilePath);
}
if (defaultExportFileName != null && !"".equals(defaultExportFileName)) {
dialog.setDefaultFileName(defaultExportFileName);
}
if (defaultExportFileExtName != null && !"".equals(defaultExportFileExtName)) {
dialog.setDefaultFileExtName(defaultExportFileExtName);
}
if (defaultExportFileCharset != null && !"".equals(defaultExportFileCharset)) {
dialog.setOutputFileCharset(defaultExportFileCharset);
}
if (dialog.open() == Dialog.OK) {
defaultExportFilePath = dialog.getDefaultFilePath();
defaultExportFileName = dialog.getDefaultFileName();
defaultExportFileExtName = dialog.getDefaultFileExtName();
String fileFullName = dialog.getOutputFileFullName();
defaultExportFileCharset = dialog.getOutputFileCharset();
BrokerConfig cubridBrokerConfig = editorComp.getBrokerConfig();
errMsg = editorComp.validate();
if (errMsg != null) {
CommonUITool.openErrorBox(errMsg);
return;
}
String contents = brokerConfPersistUtil.readBrokerConfig(cubridBrokerConfig);
try {
brokerConfPersistUtil.writeBrokerConfig(new File(fileFullName), defaultExportFileCharset, contents);
CommonUITool.openInformationBox(Messages.titleSuccess, Messages.cubridBrokerConfEditorSaveSucessMsg);
setDirty(false);
} catch (Exception e) {
CommonUITool.openErrorBox(e.getMessage());
}
}
}
});
new ToolItem(toolbar, SWT.SEPARATOR);
ToolItem importItem = new ToolItem(toolbar, SWT.PUSH);
importItem.setImage(CubridManagerUIPlugin.getImage("icons/queryeditor/file_open.png"));
importItem.setToolTipText(com.cubrid.cubridmanager.ui.host.Messages.msgTipOpenAction);
importItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
ImportConfigDialog dialog = new ImportConfigDialog(getSite().getShell(), ConfigType.CUBRID_BROKER, true);
if (defaultImportFileName != null && !"".equals(defaultImportFileName)) {
dialog.setDefaultFileName(defaultImportFileName);
}
if (defaultImportFileCharset != null && !"".equals(defaultImportFileCharset)) {
dialog.setDefaultCharset(defaultImportFileCharset);
}
if (dialog.open() == Dialog.OK) {
defaultImportFileName = dialog.getDefaultFileName();
defaultImportFileCharset = dialog.getDefaultCharset();
List<String> contents = dialog.getImportFileContent();
StringBuilder contentBuilder = new StringBuilder();
for (String content : contents) {
contentBuilder.append(content).append(StringUtil.NEWLINE);
}
BrokerConfig cubridBrokerConfig = brokerConfPersistUtil.parseStringLineToBrokerConfig(contentBuilder.toString());
firstView = false;
editorComp.setBrokerConfig(cubridBrokerConfig);
editorComp.createBrokerConfTableData();
}
}
});
new ToolItem(toolbar, SWT.SEPARATOR);
addPropItem = new ToolItem(toolbar, SWT.PUSH);
addPropItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/table_record_insert.png"));
addPropItem.setToolTipText(Messages.cubridBrokerConfEditorAddPropItemLabel);
addPropItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
editorComp.addPropData();
}
});
deletePropItem = new ToolItem(toolbar, SWT.PUSH);
deletePropItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/table_record_delete.png"));
deletePropItem.setToolTipText(Messages.cubridBrokerConfEditorDeletePropItemLabel);
deletePropItem.addSelectionListener(new SelectionAdapter() {
@SuppressWarnings("all")
public void widgetSelected(SelectionEvent event) {
editorComp.deletePropData();
}
});
}
use of com.cubrid.common.ui.spi.model.BrokerConfig in project cubrid-manager by CUBRID.
the class EditCMCubridBrokerConfPart method loadData.
/**
* load cubrid broker config info
*/
public void loadData() {
try {
if (firstView) {
List<String> contentsList = ConfigParaHelp.performGetBrokerConf(editorInput.getServerInfo());
StringBuilder contentBuilder = new StringBuilder();
for (String content : contentsList) {
contentBuilder.append(content).append(StringUtil.NEWLINE);
}
BrokerConfig cubridBrokerConfig = brokerConfPersistUtil.parseStringLineToBrokerConfig(contentBuilder.toString());
firstView = false;
editorComp.setBrokerConfig(cubridBrokerConfig);
editorComp.createBrokerConfTableData();
}
} catch (Exception e) {
LOGGER.error("load curbid broker conf file error", e.getMessage());
}
}
use of com.cubrid.common.ui.spi.model.BrokerConfig in project cubrid-manager by CUBRID.
the class EditCMCubridBrokerConfPart method doSave.
/**
* save to server
*/
public void doSave() {
if (editorInput == null) {
return;
}
if (!isSaveAllowed()) {
return;
}
BrokerConfig cubridBrokerConfig = editorComp.getBrokerConfig();
String errMsg = editorComp.validate();
if (errMsg != null) {
CommonUITool.openErrorBox(errMsg);
return;
}
String contents = brokerConfPersistUtil.readBrokerConfig(cubridBrokerConfig);
ConfigParaHelp.performImportBrokerConf(editorInput.getServerInfo(), contents);
setDirty(false);
}
Aggregations