use of com.cubrid.cubridmanager.ui.host.model.CubridConfConfig in project cubrid-manager by CUBRID.
the class UnifyHostConfigEditor method delCubridConfColumn.
/**
* delCubridConfColumn
*/
public void delCubridConfColumn() {
editorInput.setCubridConfPropertyCount(cubridConfTabTableViewer.getTable().getColumnCount());
LinkedHashMap<String, CubridConfConfig> cubridConfMap = unifyHostConfigUtil.parseCommonTableValueToCubridConfConfig(cubridConfConfigListData, editorInput.getCubridConfPropertyCount());
Point pt = cubridConfTableClickPoint;
int selectIndex = cubridConfTabTableViewer.getTable().getSelectionIndex();
if (selectIndex < 0) {
return;
}
final TableItem item = cubridConfTabTableViewer.getTable().getItem(selectIndex);
if (item == null) {
return;
}
for (int i = 0; i < cubridConfTabTableViewer.getTable().getColumnCount(); i++) {
Rectangle rect = item.getBounds(i);
if (rect.contains(pt)) {
cubridConfConfigListData.clear();
cubridConfConfigListData.addAll(unifyHostConfigUtil.parseCubridConfConfigToCommonTableValue(cubridConfConfigDataMap));
String serverName = cubridConfConfigListData.get(0).get(i + "");
String sectionName = cubridConfConfigListData.get(1).get(i + "");
if (!CommonUITool.openConfirmBox(Messages.bind(Messages.unifyHostConfigEditorDelColumnConfirmMsg, sectionName, serverName))) {
return;
}
CubridConfConfig cubridConfConfig = cubridConfMap.get(serverName);
unifyHostConfigUtil.deleteCubridConfPropertyBySectionName(cubridConfConfig, sectionName);
cubridConfConfigDataMap.clear();
cubridConfConfigDataMap.putAll(cubridConfMap);
createCubridConfTableData();
setDirty(true);
return;
}
}
}
use of com.cubrid.cubridmanager.ui.host.model.CubridConfConfig in project cubrid-manager by CUBRID.
the class UnifyHostConfigEditor method loadData.
/**
* load edit data
*/
public void loadData() {
if (editorInput.getTaskCountValue() == 0) {
return;
}
try {
ProgressMonitorDialog progress = new ProgressMonitorDialog(getSite().getShell());
progress.setCancelable(false);
progress.run(true, true, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
monitor.beginTask(Messages.unifyHostConfigEditorLoadingDataMsg, editorInput.getTaskCountValue());
unifyHostConfigUtil = new UnifyHostConfigUtil();
for (CubridServer cubridServer : editorInput.getCubridServers()) {
if (editorInput.isEditCubridConf()) {
monitor.subTask(Messages.bind(Messages.unifyHostConfigEditorLoadingDataMsg2, "cubrid.conf", cubridServer.getName()));
GetCubridConfParameterTask getCubridConfParameterTask = new GetCubridConfParameterTask(cubridServer.getServerInfo());
getCubridConfParameterTask.execute();
if (getCubridConfParameterTask.isSuccess()) {
List<String> contentsList = getCubridConfParameterTask.getConfContents();
StringBuilder contentBuilder = new StringBuilder();
for (String content : contentsList) {
contentBuilder.append(content).append(StringUtil.NEWLINE);
}
CubridConfConfig cubridConfConfig = unifyHostConfigUtil.parseStringLineToCubridConfConfig(contentBuilder.toString());
cubridConfConfigDataMap.put(cubridServer.getName(), cubridConfConfig);
monitor.worked(1);
}
}
if (editorInput.isEditBrokerConf()) {
monitor.subTask(Messages.bind(Messages.unifyHostConfigEditorLoadingDataMsg2, "broker", cubridServer.getName()));
GetBrokerConfParameterTask getBrokerConfParameterTask = new GetBrokerConfParameterTask(cubridServer.getServerInfo());
getBrokerConfParameterTask.execute();
if (getBrokerConfParameterTask.isSuccess()) {
List<String> contentsList = getBrokerConfParameterTask.getConfContents();
StringBuilder contentBuilder = new StringBuilder();
for (String content : contentsList) {
contentBuilder.append(content).append(StringUtil.NEWLINE);
}
BrokerConfig cubridBrokerConfig = cubridBrokerConfUtil.parseStringLineToBrokerConfig(contentBuilder.toString());
cubridBrokerConfigDataMap.put(cubridServer.getName(), cubridBrokerConfig);
monitor.worked(1);
}
}
if (editorInput.isEditCMConf()) {
monitor.subTask(Messages.bind(Messages.unifyHostConfigEditorLoadingDataMsg2, "cm.conf", cubridServer.getName()));
GetCMConfParameterTask getCMConfParameterTask = new GetCMConfParameterTask(cubridServer.getServerInfo());
getCMConfParameterTask.execute();
if (getCMConfParameterTask.isSuccess()) {
List<String> contentsList = getCMConfParameterTask.getConfContents();
StringBuilder contentBuilder = new StringBuilder();
for (String content : contentsList) {
contentBuilder.append(content).append(StringUtil.NEWLINE);
}
CubridCMConfConfig cubridCMConfConfig = unifyHostConfigUtil.parseStringLineToCubridCMConfConfig(contentBuilder.toString());
cubridConfCMConfigDataMap.put(cubridServer.getName(), cubridCMConfConfig);
// System.out.println(contentBuilder.toString());
}
monitor.worked(1);
}
if (editorInput.isEditHAConf()) {
monitor.subTask(Messages.bind(Messages.unifyHostConfigEditorLoadingDataMsg2, "cubrid_ha.conf", cubridServer.getName()));
monitor.worked(1);
}
if (editorInput.isEditACLConf()) {
monitor.subTask(Messages.bind(Messages.unifyHostConfigEditorLoadingDataMsg2, "acl", cubridServer.getName()));
monitor.worked(1);
}
}
}
});
} catch (Exception e) {
LOGGER.error("", e);
}
}
use of com.cubrid.cubridmanager.ui.host.model.CubridConfConfig in project cubrid-manager by CUBRID.
the class UnifyHostConfigEditor method addCubridConfColumn.
/**
* addCubridConfColumn
*/
public void addCubridConfColumn() {
editorInput.setCubridConfPropertyCount(cubridConfTabTableViewer.getTable().getColumnCount());
LinkedHashMap<String, CubridConfConfig> cubridConfMap = unifyHostConfigUtil.parseCommonTableValueToCubridConfConfig(cubridConfConfigListData, editorInput.getCubridConfPropertyCount());
Point pt = cubridConfTableClickPoint;
int selectIndex = cubridConfTabTableViewer.getTable().getSelectionIndex();
if (selectIndex < 0) {
return;
}
final TableItem item = cubridConfTabTableViewer.getTable().getItem(selectIndex);
if (item == null) {
return;
}
for (int i = 0; i < cubridConfTabTableViewer.getTable().getColumnCount(); i++) {
Rectangle rect = item.getBounds(i);
if (rect.contains(pt)) {
cubridConfConfigListData.clear();
cubridConfConfigListData.addAll(unifyHostConfigUtil.parseCubridConfConfigToCommonTableValue(cubridConfConfigDataMap));
String serverName = cubridConfConfigListData.get(0).get(i + "");
if (!CommonUITool.openConfirmBox(Messages.bind(Messages.unifyHostConfigEditorAddColumnConfirmMsg, "section", serverName))) {
return;
}
CubridConfConfig cubridConfConfig = cubridConfMap.get(serverName);
//new property then set parameter
CubridConfProperty property = new CubridConfProperty();
property.setCubridConfPropKey("[%section" + (cubridConfConfig.getPropertyList().size() + 1) + "]");
property.setCubridConf(true);
property.setCubridConfPropAnnotation(StringUtil.NEWLINE);
cubridConfConfig.addCubridConfProperty(property);
cubridConfConfigDataMap.clear();
cubridConfConfigDataMap.putAll(cubridConfMap);
createCubridConfTableData();
setDirty(true);
return;
}
}
}
use of com.cubrid.cubridmanager.ui.host.model.CubridConfConfig in project cubrid-manager by CUBRID.
the class UnifyHostConfigEditor method createCubridConfTableData.
/**
* create table data by cubridConfConfig model
*/
public void createCubridConfTableData() {
//remove column
int oldCount = cubridConfTabTableViewer.getTable().getColumnCount();
for (int i = 0; i < oldCount; i++) {
cubridConfTabTableViewer.getTable().getColumn(0).dispose();
}
//create column
TableViewerColumn column = new TableViewerColumn(cubridConfTabTableViewer, SWT.LEFT);
column.getColumn().setWidth(150);
column.getColumn().setText(Messages.unifyHostConfTableColumnPropName);
column.setEditingSupport(new PropValueEditingSupport(cubridConfTabTableViewer, 0));
int columnIndex = 0;
for (Entry<String, CubridConfConfig> entry : cubridConfConfigDataMap.entrySet()) {
CubridConfConfig cubridConfConfig = entry.getValue();
for (int i = 0; i < cubridConfConfig.getPropertyList().size(); i++) {
TableViewerColumn propColumn = new TableViewerColumn(cubridConfTabTableViewer, SWT.LEFT);
propColumn.getColumn().setWidth(160);
propColumn.getColumn().setText(Messages.unifyHostCubridConfTableTitle + columnIndex);
propColumn.setEditingSupport(new PropValueEditingSupport(cubridConfTabTableViewer, columnIndex + 1));
propColumn.getColumn().addSelectionListener(new SelectionAdapter() {
@SuppressWarnings("all")
public void widgetSelected(SelectionEvent event) {
}
});
columnIndex++;
}
}
cubridConfTabTableViewer.setLabelProvider(new UnifyHostCubridConfTableLabelProvider());
cubridConfTabTableViewer.setInput(cubridConfConfigListData);
cubridConfConfigListData.clear();
cubridConfConfigListData.addAll(unifyHostConfigUtil.parseCubridConfConfigToCommonTableValue(cubridConfConfigDataMap));
cubridConfTabTableViewer.refresh();
}
use of com.cubrid.cubridmanager.ui.host.model.CubridConfConfig in project cubrid-manager by CUBRID.
the class UnifyHostConfigUtil method parseStringLineToCubridConfConfig.
/**
* parseStringLineToCubridConfConfig
* @param content
* @return
* @throws Exception
*/
public CubridConfConfig parseStringLineToCubridConfConfig(String content) {
CubridConfConfig config = new CubridConfConfig();
String cubridConfRegex = "\\[.*";
Pattern cubridConfPattern = Pattern.compile(cubridConfRegex);
String annotationRegex = "#(\\s*).+";
Pattern annotationPattern = Pattern.compile(annotationRegex);
String propertyRegex = ".+=.+";
Pattern propertyPattern = Pattern.compile(propertyRegex);
CubridConfProperty confProp = null;
StringBuilder annotationBuilder = new StringBuilder();
String[] contentArray = content.split(StringUtil.NEWLINE);
for (String lineString : contentArray) {
Matcher cubridConfMatcher = cubridConfPattern.matcher(lineString);
Matcher annotationMatcher = annotationPattern.matcher(lineString);
Matcher propertyMatcher = propertyPattern.matcher(lineString);
if (cubridConfMatcher.find()) {
//find broker like [service] [common] [@database]
confProp = new CubridConfProperty();
confProp.setCubridConfPropKey(lineString);
confProp.setCubridConf(true);
if (annotationBuilder != null) {
confProp.setCubridConfPropAnnotation(annotationBuilder.toString());
}
config.addCubridConfProperty(confProp);
annotationBuilder = null;
} else if (annotationMatcher.find() || lineString.equals("")) {
//find annotation
if (annotationBuilder == null) {
annotationBuilder = new StringBuilder();
}
annotationBuilder.append(lineString).append(StringUtil.NEWLINE);
} else if (propertyMatcher.find()) {
//find key and value
if (confProp == null) {
//if there is no cubrid conf,ignore the property
continue;
}
String[] keyValueString = lineString.split("=");
if (keyValueString.length == 2) {
String key = keyValueString[0].trim();
String value = keyValueString[1].trim();
//new property then set parameter
CubridConfProperty property = new CubridConfProperty();
property.setCubridConfPropKey(key);
property.setCubridConfPropValue(value);
if (annotationBuilder != null) {
property.setCubridConfPropAnnotation(annotationBuilder.toString());
}
confProp.addCubridConfProperty(property);
annotationBuilder = null;
}
} else {
//opthers see it to bottom annotation
annotationBuilder.append(lineString).append(StringUtil.NEWLINE);
}
}
if (annotationBuilder != null) {
config.setConfAnnotation(annotationBuilder.toString());
}
return config;
}
Aggregations