Search in sources :

Example 1 with BrokerConfig

use of com.cubrid.common.ui.spi.model.BrokerConfig in project cubrid-manager by CUBRID.

the class BrokerConfigEditorPart method createToolBarComp.

/**
	 * Create the toolbar composition.
	 *
	 * @param parent
	 */
public void createToolBarComp(Composite parent) {
    final Composite comp = new Composite(parent, SWT.NONE);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    comp.setLayoutData(gridData);
    final GridLayout layout = new GridLayout(1, false);
    layout.marginHeight = -1;
    comp.setLayout(layout);
    final ToolBar toolbar = new ToolBar(comp, SWT.LEFT_TO_RIGHT | SWT.FLAT);
    toolbar.setLayoutData(createGridData(HORIZONTAL_ALIGN_END, 1, 1, -1, -1));
    // Show/hide of the history pane
    saveConfItem = new ToolItem(toolbar, SWT.PUSH);
    saveConfItem.setImage(getImage("icons/queryeditor/file_save.png"));
    saveConfItem.setToolTipText(Messages.cubridBrokerConfEditorSaveItemLabel);
    saveConfItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            // check whether contains duplicate property name
            String errMsg = editorComp.validate();
            if (isNotBlank(errMsg)) {
                openErrorBox(errMsg);
                return;
            }
            if (!openConfirmBox(Messages.cubridBrokerConfEditorSaveConfirm)) {
                return;
            }
            saveData();
        }
    });
    // Show/hide of the history pane
    saveAsConfItem = new ToolItem(toolbar, SWT.PUSH);
    saveAsConfItem.setImage(getImage("icons/queryeditor/file_saveas.png"));
    saveAsConfItem.setToolTipText(Messages.cubridBrokerConfEditorSaveAsItemLabel);
    saveAsConfItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            // Check whether contains duplicate property or broker name
            String errMsg = editorComp.validate();
            if (isNotBlank(errMsg)) {
                openErrorBox(errMsg);
                return;
            }
            if (!openConfirmBox(Messages.cubridBrokerConfEditorSaveAsConfirm)) {
                return;
            }
            final FileDialog dialog = new FileDialog(getSite().getShell(), SWT.OPEN | SWT.MULTI);
            dialog.setFilterPath(PersistUtils.getPreferenceValue(PLUGIN_ID, BrokerConfOpenFileDialog.CUBRIDBROKERCONFPATH));
            dialog.setText(Messages.cubridBrokerConfEditorSaveAsDialogTitle);
            dialog.setFilterExtensions(new String[] { "*.conf" });
            dialog.setOverwrite(false);
            String path = dialog.open();
            File saveAsFile = null;
            if (path == null) {
                return;
            }
            if (!path.endsWith(".conf")) {
                path += ".conf";
            }
            saveAsFile = new File(path);
            BrokerConfig brokerConf = editorComp.getBrokerConfig();
            String contents = persistUtil.readBrokerConfig(brokerConf);
            try {
                persistUtil.writeBrokerConfig(saveAsFile, charset, contents);
                openInformationBox(Messages.titleSuccess, Messages.cubridBrokerConfEditorSaveSucessMsg);
                setDirty(false);
            } catch (Exception e) {
                LOGGER.error(e.getMessage(), e);
                openErrorBox(e.getMessage());
            }
        }
    });
    new ToolItem(toolbar, SWT.SEPARATOR);
    addPropItem = new ToolItem(toolbar, SWT.PUSH);
    addPropItem.setImage(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(getImage("icons/queryeditor/table_record_delete.png"));
    deletePropItem.setToolTipText(Messages.cubridBrokerConfEditorDeletePropItemLabel);
    deletePropItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            editorComp.deletePropData();
        }
    });
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) BrokerConfig(com.cubrid.common.ui.spi.model.BrokerConfig) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) CommonUITool.createGridData(com.cubrid.common.ui.spi.util.CommonUITool.createGridData) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) BrokerConfOpenFileDialog(com.cubrid.common.ui.common.dialog.BrokerConfOpenFileDialog) FileDialog(org.eclipse.swt.widgets.FileDialog) File(java.io.File) ToolItem(org.eclipse.swt.widgets.ToolItem) PartInitException(org.eclipse.ui.PartInitException)

Example 2 with BrokerConfig

use of com.cubrid.common.ui.spi.model.BrokerConfig in project cubrid-manager by CUBRID.

the class UnifyHostConfigEditor method createBrokerConfTableData.

/**
	 * create table data by CubridBrokerConf model
	 */
public void createBrokerConfTableData() {
    //remove column
    int oldCount = brokerConfTabTableViewer.getTable().getColumnCount();
    for (int i = 0; i < oldCount; i++) {
        brokerConfTabTableViewer.getTable().getColumn(0).dispose();
    }
    //create column
    TableViewerColumn column = new TableViewerColumn(brokerConfTabTableViewer, SWT.LEFT);
    column.getColumn().setWidth(150);
    column.getColumn().setText(Messages.unifyHostConfTableColumnPropName);
    column.setEditingSupport(new PropValueEditingSupport(brokerConfTabTableViewer, 0));
    int columnIndex = 0;
    for (Entry<String, BrokerConfig> entry : cubridBrokerConfigDataMap.entrySet()) {
        BrokerConfig cubridBrokerConfig = entry.getValue();
        for (int i = 0; i < cubridBrokerConfig.getPropertyList().size(); i++) {
            TableViewerColumn propColumn = new TableViewerColumn(brokerConfTabTableViewer, SWT.LEFT);
            propColumn.getColumn().setWidth(160);
            propColumn.getColumn().setText(Messages.unifyHostBrokerConfTableTitle + columnIndex);
            propColumn.setEditingSupport(new PropValueEditingSupport(brokerConfTabTableViewer, columnIndex + 1));
            propColumn.getColumn().addSelectionListener(new SelectionAdapter() {

                @SuppressWarnings("all")
                public void widgetSelected(SelectionEvent event) {
                }
            });
            //if broker name is [broker] can't edit and don't display
            //				CubridBrokerProperty brokerProperty = cubridBrokerConfig.getPropertyList().get(i);
            //				if (brokerProperty.getCubridBrokerPropKey().equals("[broker]")) {
            //					propColumn.getColumn().setWidth(0);
            //				}
            columnIndex++;
        }
    }
    brokerConfTabTableViewer.setLabelProvider(new UnifyHostCubridBrokerTableLabelProvider());
    brokerConfTabTableViewer.setInput(cubridBrokerConfListData);
    cubridBrokerConfListData.clear();
    cubridBrokerConfListData.addAll(unifyHostConfigUtil.parseCubridBrokerConfigToCommonTableValue(cubridBrokerConfigDataMap));
    brokerConfTabTableViewer.refresh();
}
Also used : BrokerConfig(com.cubrid.common.ui.spi.model.BrokerConfig) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Point(org.eclipse.swt.graphics.Point) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 3 with BrokerConfig

use of com.cubrid.common.ui.spi.model.BrokerConfig in project cubrid-manager by CUBRID.

the class UnifyHostConfigEditor method addBrokerConfColumn.

/**
	 * addBrokerConfColumn
	 */
public void addBrokerConfColumn() {
    editorInput.setBrokerConfPropertyCount(brokerConfTabTableViewer.getTable().getColumnCount());
    LinkedHashMap<String, BrokerConfig> brokerConfMap = unifyHostConfigUtil.parseCommonTableValueToCubridBrokerConfig(cubridBrokerConfListData, editorInput.getBrokerConfPropertyCount());
    Point pt = cubridBrokerTableClickPoint;
    int selectIndex = brokerConfTabTableViewer.getTable().getSelectionIndex();
    if (selectIndex < 0) {
        return;
    }
    final TableItem item = brokerConfTabTableViewer.getTable().getItem(selectIndex);
    if (item == null) {
        return;
    }
    for (int i = 0; i < brokerConfTabTableViewer.getTable().getColumnCount(); i++) {
        Rectangle rect = item.getBounds(i);
        if (rect.contains(pt)) {
            cubridBrokerConfListData.clear();
            cubridBrokerConfListData.addAll(unifyHostConfigUtil.parseCubridBrokerConfigToCommonTableValue(cubridBrokerConfigDataMap));
            String serverName = cubridBrokerConfListData.get(0).get(i + "");
            if (!CommonUITool.openConfirmBox(Messages.bind(Messages.unifyHostConfigEditorAddColumnConfirmMsg, "broker", serverName))) {
                return;
            }
            BrokerConfig cubridBrokerConfig = brokerConfMap.get(serverName);
            //new property then set parameter
            CubridBrokerProperty property = new CubridBrokerProperty();
            property.setCubridBrokerPropKey("[%broker" + (cubridBrokerConfig.getPropertyList().size() + 1) + "]");
            property.setCubridBroker(true);
            property.setCubridBrokerPropAnnotation(StringUtil.NEWLINE);
            cubridBrokerConfig.addCubridBrokerProperty(property);
            cubridBrokerConfigDataMap.clear();
            cubridBrokerConfigDataMap.putAll(brokerConfMap);
            createBrokerConfTableData();
            setDirty(true);
            return;
        }
    }
}
Also used : BrokerConfig(com.cubrid.common.ui.spi.model.BrokerConfig) TableItem(org.eclipse.swt.widgets.TableItem) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point) CubridBrokerProperty(com.cubrid.common.ui.spi.model.CubridBrokerProperty) Point(org.eclipse.swt.graphics.Point)

Example 4 with BrokerConfig

use of com.cubrid.common.ui.spi.model.BrokerConfig 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);
    }
}
Also used : BrokerConfig(com.cubrid.common.ui.spi.model.BrokerConfig) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) GetCubridConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) UnifyHostConfigUtil(com.cubrid.cubridmanager.ui.spi.util.UnifyHostConfigUtil) InvocationTargetException(java.lang.reflect.InvocationTargetException) CubridConfConfig(com.cubrid.cubridmanager.ui.host.model.CubridConfConfig) PartInitException(org.eclipse.ui.PartInitException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) GetCMConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask) List(java.util.List) ArrayList(java.util.ArrayList) GetBrokerConfParameterTask(com.cubrid.cubridmanager.core.broker.task.GetBrokerConfParameterTask) CubridCMConfConfig(com.cubrid.cubridmanager.ui.host.model.CubridCMConfConfig)

Example 5 with BrokerConfig

use of com.cubrid.common.ui.spi.model.BrokerConfig in project cubrid-manager by CUBRID.

the class EditCMCubridBrokerConfPart method doSave.

public void doSave(IProgressMonitor monitor) {
    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);
}
Also used : BrokerConfig(com.cubrid.common.ui.spi.model.BrokerConfig)

Aggregations

BrokerConfig (com.cubrid.common.ui.spi.model.BrokerConfig)16 PartInitException (org.eclipse.ui.PartInitException)6 CubridBrokerProperty (com.cubrid.common.ui.spi.model.CubridBrokerProperty)5 ArrayList (java.util.ArrayList)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 Point (org.eclipse.swt.graphics.Point)3 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)2 File (java.io.File)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 Map (java.util.Map)2 Rectangle (org.eclipse.swt.graphics.Rectangle)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Composite (org.eclipse.swt.widgets.Composite)2 TableItem (org.eclipse.swt.widgets.TableItem)2 ToolBar (org.eclipse.swt.widgets.ToolBar)2 ToolItem (org.eclipse.swt.widgets.ToolItem)2