use of com.cubrid.common.ui.common.sqlrunner.part.RunSQLFileEditorInput in project cubrid-manager by CUBRID.
the class RunSQLFileDialog method buttonPressed.
/**
* When press button,call it
*
* @param buttonId the button id
*/
protected void buttonPressed(int buttonId) {
if (buttonId == IDialogConstants.OK_ID) {
if (!validate()) {
return;
}
for (CubridDatabase database : cubridDatabases) {
RunSQLFileEditorInput input = new RunSQLFileEditorInput(database, filesList, fileCharsetCombo.getText(), threadCountSpinner.getSelection(), commitCountSpinner.getSelection(), saveErrExcelPath.getText());
try {
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
workbenchWindow.getActivePage().openEditor(input, RunSQLFileViewPart.ID);
} catch (Exception e) {
LOGGER.error("", e);
}
}
}
setReturnCode(buttonId);
close();
}
use of com.cubrid.common.ui.common.sqlrunner.part.RunSQLFileEditorInput in project cubrid-manager by CUBRID.
the class BatchRunDialog method buttonPressed.
/**
* Call this method when the button in button bar is pressed
*
* @param buttonId the button id
*/
protected void buttonPressed(int buttonId) {
if (buttonId == RUN_ID) {
if (!MessageDialog.openConfirm(PlatformUI.getWorkbench().getDisplay().getActiveShell(), Messages.titleBatchRunConfirm, Messages.msgBatchRunConfirm)) {
return;
}
List<String> fileList = container.getFileList();
RunSQLFileEditorInput input = new RunSQLFileEditorInput(cubridDatabase, fileList);
try {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input, RunSQLFileViewPart.ID);
} catch (Exception e) {
LOGGER.error(e.getLocalizedMessage());
}
super.buttonPressed(IDialogConstants.OK_ID);
} else if (buttonId == PASTE_ID) {
// if (!MessageDialog.openConfirm(
// PlatformUI.getWorkbench().getDisplay().getActiveShell(),
// Messages.titleBatchRunConfirm, Messages.msgBatchRunPasteConfirm)) {
// return;
// }
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null || window.getActivePage() == null) {
return;
}
IEditorPart editor = window.getActivePage().getActiveEditor();
try {
if (editor == null) {
IEditorInput input = new QueryUnit();
editor = window.getActivePage().openEditor(input, QueryEditorPart.ID);
}
} catch (PartInitException e) {
CommonUITool.openErrorBox(e.getMessage());
}
if (editor == null) {
return;
}
QueryEditorPart oldEditor = (QueryEditorPart) editor;
try {
QueryEditorPart queryEditor = (QueryEditorPart) editor;
String encoding = queryEditor.getCombinedQueryComposite().getSqlEditorComp().getDocument().getEncoding();
StringBuilder sb = new StringBuilder();
List<String> fileList = container.getFileList();
for (int i = 0; i < fileList.size(); i++) {
sb.delete(0, sb.length());
sb.append("/* SQL Filename: ").append(fileList.get(i)).append(" */").append(StringUtil.NEWLINE);
BufferedReader in = null;
try {
in = new BufferedReader(new InputStreamReader(new FileInputStream(new File(fileList.get(i))), encoding));
String line = in.readLine();
while (line != null) {
sb.append(line + StringUtil.NEWLINE);
line = in.readLine();
}
} finally {
try {
if (in != null) {
in.close();
}
} catch (IOException e) {
}
}
try {
QueryUnit input = new QueryUnit();
QueryEditorPart newEditor = (QueryEditorPart) window.getActivePage().openEditor(input, QueryEditorPart.ID);
newEditor.setQuery(sb.toString(), false, false, false);
newEditor.connect(oldEditor.getSelectedDatabase());
} catch (Exception e) {
CommonUITool.openErrorBox(e.getMessage());
}
}
} catch (IOException e) {
CommonUITool.openErrorBox(e.getMessage());
}
super.buttonPressed(IDialogConstants.OK_ID);
} else {
super.buttonPressed(buttonId);
}
}
Aggregations