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