Search in sources :

Example 11 with BrokerConfig

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);
    }
}
Also used : BrokerConfig(com.cubrid.common.ui.spi.model.BrokerConfig) PartInitException(org.eclipse.ui.PartInitException)

Example 12 with BrokerConfig

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());
    }
}
Also used : BrokerConfig(com.cubrid.common.ui.spi.model.BrokerConfig) PartInitException(org.eclipse.ui.PartInitException)

Example 13 with BrokerConfig

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();
        }
    });
}
Also used : ExportConfigDialog(com.cubrid.cubridmanager.ui.host.dialog.ExportConfigDialog) BrokerConfig(com.cubrid.common.ui.spi.model.BrokerConfig) Composite(org.eclipse.swt.widgets.Composite) BrokerConfigEditComposite(com.cubrid.common.ui.common.control.BrokerConfigEditComposite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) PartInitException(org.eclipse.ui.PartInitException) GridLayout(org.eclipse.swt.layout.GridLayout) ImportConfigDialog(com.cubrid.cubridmanager.ui.host.dialog.ImportConfigDialog) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) List(java.util.List) File(java.io.File) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 14 with BrokerConfig

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());
    }
}
Also used : BrokerConfig(com.cubrid.common.ui.spi.model.BrokerConfig) PartInitException(org.eclipse.ui.PartInitException)

Example 15 with BrokerConfig

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