Search in sources :

Example 11 with QueryRecordProject

use of com.cubrid.common.ui.query.tuner.QueryRecordProject in project cubrid-manager by CUBRID.

the class QueryRecordListComparator method saveQueryRecord.

/**
	 * Save current query record
	 *
	 */
private void saveQueryRecord() {
    QueryRecordProject queryRecordProject = null;
    if (ApplicationPersistUtil.getInstance().getQueryRecordProject(database.getDatabaseInfo()).size() == 0) {
        queryRecordProject = new QueryRecordProject();
        queryRecordProject.setCreateDate(new Date());
        queryRecordProject.setName(formater.format(queryRecordProject.getCreateDate()));
        ApplicationPersistUtil.getInstance().addQueryRecordProject(database.getDatabaseInfo(), queryRecordProject);
        ApplicationPersistUtil.getInstance().save();
        switchQueryRecordProject(queryRecordProject.getName());
    } else {
        queryRecordProject = ApplicationPersistUtil.getInstance().findQueryRecordProject(database.getDatabaseInfo(), historyCombo.getText());
    }
    if (queryRecordProject == null) {
        CommonUITool.openErrorBox(Messages.errUnselectHistory);
        return;
    }
    if (currentRecord == null) {
        CommonUITool.openErrorBox(Messages.errCurrentQueryEmpty);
        return;
    }
    AddQueryRecordDialog dialog = new AddQueryRecordDialog(getShell(), currentRecord, true, queryRecordProject);
    if (dialog.open() == IDialogConstants.OK_ID) {
        currentRecord.setName(dialog.getName());
        queryRecordProject.addQueryRecord(currentRecord);
        ApplicationPersistUtil.getInstance().removeQueryRecordProject(database.getDatabaseInfo(), historyCombo.getText());
        ApplicationPersistUtil.getInstance().addQueryRecordProject(database.getDatabaseInfo(), queryRecordProject);
        ApplicationPersistUtil.getInstance().save();
        initQueryRecord(queryRecordProject);
        displayCompareQueryRecord();
    }
}
Also used : QueryRecordProject(com.cubrid.common.ui.query.tuner.QueryRecordProject) Date(java.util.Date)

Example 12 with QueryRecordProject

use of com.cubrid.common.ui.query.tuner.QueryRecordProject in project cubrid-manager by CUBRID.

the class QueryRecordListComparator method getSelectedRightQueryRecord.

/**
	 * Get selected history query record
	 *
	 * @return
	 */
private QueryRecord getSelectedRightQueryRecord() {
    QueryRecordProject queryRecordProject = ApplicationPersistUtil.getInstance().findQueryRecordProject(database.getDatabaseInfo(), historyCombo.getText());
    if (queryRecordProject == null) {
        CommonUITool.openErrorBox(Messages.errUnselectHistory);
    }
    String historyName = queryRecordRightCombo.getText();
    return queryRecordProject.findQueryRecord(historyName);
}
Also used : QueryRecordProject(com.cubrid.common.ui.query.tuner.QueryRecordProject)

Example 13 with QueryRecordProject

use of com.cubrid.common.ui.query.tuner.QueryRecordProject in project cubrid-manager by CUBRID.

the class QueryRecordListComparator method addQueryRecordProject.

/**
	 * Add new query record list
	 *
	 */
private void addQueryRecordProject() {
    QueryRecordProject queryRecordProject = new QueryRecordProject();
    queryRecordProject.setCreateDate(new Date());
    queryRecordProject.setName(formater.format(queryRecordProject.getCreateDate()));
    AddQueryRecordProjectDialog dialog = new AddQueryRecordProjectDialog(getShell(), queryRecordProject, true, database.getDatabaseInfo());
    if (dialog.open() == IDialogConstants.OK_ID) {
        queryRecordProject.setName(dialog.getName());
        ApplicationPersistUtil.getInstance().addQueryRecordProject(database.getDatabaseInfo(), queryRecordProject);
        ApplicationPersistUtil.getInstance().save();
        switchQueryRecordProject(queryRecordProject.getName());
    }
}
Also used : QueryRecordProject(com.cubrid.common.ui.query.tuner.QueryRecordProject) Date(java.util.Date)

Example 14 with QueryRecordProject

use of com.cubrid.common.ui.query.tuner.QueryRecordProject in project cubrid-manager by CUBRID.

the class QueryRecordListComparator method createDialogArea.

/**
	 * Create dialog area content
	 *
	 * @param parent the parent composite
	 * @return the control
	 */
protected Control createDialogArea(Composite parent) {
    Composite container = new Composite(parent, SWT.None);
    container.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    container.setLayout(new FormLayout());
    topComposite = new Composite(container, SWT.None);
    FormData topData = new FormData();
    topData.top = new FormAttachment(0, 0);
    topData.bottom = new FormAttachment(0, 30);
    topData.left = new FormAttachment(0, 0);
    topData.right = new FormAttachment(100, 0);
    topComposite.setLayoutData(topData);
    topComposite.setLayout(new GridLayout(6, false));
    Label historyLable = new Label(topComposite, SWT.None);
    historyLable.setText(Messages.lblProject);
    historyLable.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    historyCombo = new Combo(topComposite, SWT.READ_ONLY);
    historyCombo.setLayoutData(CommonUITool.createGridData(1, 1, 200, -1));
    historyCombo.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            String name = historyCombo.getText();
            switchQueryRecordProject(name);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    ToolBar toolBar = new ToolBar(topComposite, SWT.None);
    toolBar.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
    addItem = new ToolItem(toolBar, SWT.PUSH);
    addItem.setImage(CommonUIPlugin.getImage("icons/queryplan/add_query.gif"));
    addItem.setToolTipText(Messages.itemTooltipAdd);
    addItem.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            addQueryRecordProject();
        }
    });
    deleteItem = new ToolItem(toolBar, SWT.PUSH);
    deleteItem.setImage(CommonUIPlugin.getImage("icons/queryplan/delete_query.gif"));
    deleteItem.setToolTipText(Messages.itemTooltipRemove);
    deleteItem.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
            if (queryRecordLeftCombo.getItemCount() == 0) {
                CommonUITool.openErrorBox(Messages.msgQueryTunerNotSavedProject);
                tabFolder.setSelection(0);
            }
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            if (CommonUITool.openConfirmBox(Messages.confirmDeleteTuningProject)) {
                ApplicationPersistUtil.getInstance().removeQueryRecordProject(database.getDatabaseInfo(), historyCombo.getText());
                ApplicationPersistUtil.getInstance().save();
                switchQueryRecordProject("");
            }
        }
    });
    renameItem = new ToolItem(toolBar, SWT.PUSH);
    renameItem.setImage(CommonUIPlugin.getImage("icons/queryplan/rename_query.gif"));
    renameItem.setToolTipText(Messages.itemTooltipRename);
    renameItem.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            renameQueryRecordProject();
        }
    });
    Label placeHolderLabel = new Label(topComposite, SWT.None);
    placeHolderLabel.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    buttomComposite = new Composite(container, SWT.None);
    buttomComposite.setLayout(new FillLayout());
    FormData buttomData = new FormData();
    buttomData.top = new FormAttachment(0, 30);
    buttomData.bottom = new FormAttachment(100, 0);
    buttomData.left = new FormAttachment(0, 0);
    buttomData.right = new FormAttachment(100, 0);
    buttomComposite.setLayoutData(buttomData);
    buttomComposite.setLayout(new FillLayout());
    tabFolder = new CTabFolder(buttomComposite, SWT.BORDER);
    tabFolder.setTabHeight(20);
    tabFolder.marginHeight = 5;
    tabFolder.marginWidth = 5;
    tabFolder.setMaximizeVisible(false);
    tabFolder.setMinimizeVisible(false);
    tabFolder.setSimple(false);
    tabFolder.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            if (tabFolder.getSelectionIndex() == 1) {
                List<QueryRecordProject> projectList = loadProjectList();
                if (projectList.size() == 0) {
                    CommonUITool.openErrorBox(Messages.msgQueryTunerNotSavedProject);
                    tabFolder.setSelection(0);
                } else {
                    QueryRecordProject usingProject = null;
                    String projectName = historyCombo.getText();
                    for (int i = 0; i < projectList.size(); i++) {
                        QueryRecordProject temp = projectList.get(i);
                        if (StringUtil.isEqual(projectName, temp.getName())) {
                            usingProject = temp;
                            break;
                        }
                    }
                    if (usingProject != null) {
                        if (usingProject.getQueryRecordList().size() == 0) {
                            CommonUITool.openErrorBox(Messages.errNoQueryInProject);
                            return;
                        }
                        switchQueryRecordProject(historyCombo.getText());
                    }
                }
            }
        }
    });
    createQueryTunerTab(tabFolder);
    createQueryCompareTab(tabFolder);
    init();
    return parent;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) CTabFolder(org.eclipse.swt.custom.CTabFolder) Composite(org.eclipse.swt.widgets.Composite) QueryPlanComposite(com.cubrid.common.ui.query.control.queryplan.QueryPlanComposite) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) FillLayout(org.eclipse.swt.layout.FillLayout) QueryRecordProject(com.cubrid.common.ui.query.tuner.QueryRecordProject) GridLayout(org.eclipse.swt.layout.GridLayout) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ToolBar(org.eclipse.swt.widgets.ToolBar) ArrayList(java.util.ArrayList) List(java.util.List) FormAttachment(org.eclipse.swt.layout.FormAttachment) ToolItem(org.eclipse.swt.widgets.ToolItem) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

QueryRecordProject (com.cubrid.common.ui.query.tuner.QueryRecordProject)14 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 QueryRecord (com.cubrid.common.ui.query.tuner.QueryRecord)2 IXMLMemento (com.cubrid.cubridmanager.core.common.xml.IXMLMemento)2 DateFormat (java.text.DateFormat)2 List (java.util.List)2 StructQueryPlan (com.cubrid.common.core.queryplan.StructQueryPlan)1 QueryPlanComposite (com.cubrid.common.ui.query.control.queryplan.QueryPlanComposite)1 RestorableQueryEditorInfo (com.cubrid.common.ui.spi.model.RestorableQueryEditorInfo)1 ParseException (java.text.ParseException)1 CTabFolder (org.eclipse.swt.custom.CTabFolder)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 SelectionListener (org.eclipse.swt.events.SelectionListener)1 FillLayout (org.eclipse.swt.layout.FillLayout)1 FormAttachment (org.eclipse.swt.layout.FormAttachment)1 FormData (org.eclipse.swt.layout.FormData)1 FormLayout (org.eclipse.swt.layout.FormLayout)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Combo (org.eclipse.swt.widgets.Combo)1