1 /*******************************************************************************
2 * Copyright (c) 2013 hangum.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser Public License v2.1
5 * which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
9 * hangum - initial API and implementation
10 ******************************************************************************/
11 package com
.hangum
.tadpole
.rdb
.core
.editors
.main
;
13 import java
.sql
.Connection
;
14 import java
.sql
.Statement
;
15 import java
.util
.HashMap
;
18 import org
.apache
.commons
.lang
.StringUtils
;
19 import org
.apache
.log4j
.Logger
;
20 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
21 import org
.eclipse
.core
.runtime
.IStatus
;
22 import org
.eclipse
.core
.runtime
.Status
;
23 import org
.eclipse
.jface
.dialogs
.Dialog
;
24 import org
.eclipse
.jface
.dialogs
.MessageDialog
;
25 import org
.eclipse
.jface
.util
.IPropertyChangeListener
;
26 import org
.eclipse
.jface
.util
.PropertyChangeEvent
;
27 import org
.eclipse
.jface
.window
.Window
;
28 import org
.eclipse
.swt
.SWT
;
29 import org
.eclipse
.swt
.SWTException
;
30 import org
.eclipse
.swt
.browser
.Browser
;
31 import org
.eclipse
.swt
.browser
.ProgressEvent
;
32 import org
.eclipse
.swt
.browser
.ProgressListener
;
33 import org
.eclipse
.swt
.custom
.SashForm
;
34 import org
.eclipse
.swt
.events
.SelectionAdapter
;
35 import org
.eclipse
.swt
.events
.SelectionEvent
;
36 import org
.eclipse
.swt
.layout
.GridData
;
37 import org
.eclipse
.swt
.layout
.GridLayout
;
38 import org
.eclipse
.swt
.widgets
.Combo
;
39 import org
.eclipse
.swt
.widgets
.Composite
;
40 import org
.eclipse
.swt
.widgets
.ToolBar
;
41 import org
.eclipse
.swt
.widgets
.ToolItem
;
42 import org
.eclipse
.ui
.IEditorInput
;
43 import org
.eclipse
.ui
.IEditorSite
;
44 import org
.eclipse
.ui
.PartInitException
;
45 import org
.eclipse
.ui
.PlatformUI
;
47 import com
.hangum
.tadpole
.ace
.editor
.core
.dialogs
.help
.RDBShortcutHelpDialog
;
48 import com
.hangum
.tadpole
.ace
.editor
.core
.texteditor
.EditorExtension
;
49 import com
.hangum
.tadpole
.ace
.editor
.core
.texteditor
.function
.EditorFunctionService
;
50 import com
.hangum
.tadpole
.ace
.editor
.core
.texteditor
.function
.IEditorFunction
;
51 import com
.hangum
.tadpole
.commons
.dialogs
.fileupload
.SingleFileuploadDialog
;
52 import com
.hangum
.tadpole
.commons
.exception
.dialog
.ExceptionDetailsErrorDialog
;
53 import com
.hangum
.tadpole
.commons
.google
.analytics
.AnalyticCaller
;
54 import com
.hangum
.tadpole
.commons
.libs
.core
.define
.PublicTadpoleDefine
;
55 import com
.hangum
.tadpole
.commons
.libs
.core
.define
.PublicTadpoleDefine
.OBJECT_TYPE
;
56 import com
.hangum
.tadpole
.commons
.libs
.core
.define
.PublicTadpoleDefine
.PRODUCT_TYPE
;
57 import com
.hangum
.tadpole
.commons
.libs
.core
.define
.PublicTadpoleDefine
.RESULT_COMP_TYPE
;
58 import com
.hangum
.tadpole
.commons
.libs
.core
.message
.CommonMessages
;
59 import com
.hangum
.tadpole
.commons
.util
.RequestInfoUtils
;
60 import com
.hangum
.tadpole
.commons
.util
.ShortcutPrefixUtils
;
61 import com
.hangum
.tadpole
.engine
.define
.DBGroupDefine
;
62 import com
.hangum
.tadpole
.engine
.manager
.AbstractTadpoleManager
;
63 import com
.hangum
.tadpole
.engine
.manager
.TadpoleSQLManager
;
64 import com
.hangum
.tadpole
.engine
.manager
.TadpoleSQLTransactionManager
;
65 import com
.hangum
.tadpole
.engine
.query
.dao
.system
.UserDBDAO
;
66 import com
.hangum
.tadpole
.engine
.query
.dao
.system
.UserDBResourceDAO
;
67 import com
.hangum
.tadpole
.engine
.query
.sql
.DBSystemSchema
;
68 import com
.hangum
.tadpole
.engine
.query
.sql
.TadpoleSystem_UserDBResource
;
69 import com
.hangum
.tadpole
.engine
.sql
.dialog
.save
.ResourceSaveDialog
;
70 import com
.hangum
.tadpole
.engine
.sql
.util
.SQLUtil
;
71 import com
.hangum
.tadpole
.engine
.utils
.EditorDefine
;
72 import com
.hangum
.tadpole
.engine
.utils
.RequestQuery
;
73 import com
.hangum
.tadpole
.preference
.define
.GetAdminPreference
;
74 import com
.hangum
.tadpole
.preference
.define
.PreferenceDefine
;
75 import com
.hangum
.tadpole
.preference
.get
.GetPreferenceGeneral
;
76 import com
.hangum
.tadpole
.rdb
.core
.Activator
;
77 import com
.hangum
.tadpole
.rdb
.core
.Messages
;
78 import com
.hangum
.tadpole
.rdb
.core
.dialog
.db
.DBInformationDialog
;
79 import com
.hangum
.tadpole
.rdb
.core
.dialog
.db
.UserDBGroupDialog
;
80 import com
.hangum
.tadpole
.rdb
.core
.dialog
.export
.sqltoapplication
.SQLToStringDialog
;
81 import com
.hangum
.tadpole
.rdb
.core
.dialog
.restfulapi
.MainSQLEditorAPIServiceDialog
;
82 import com
.hangum
.tadpole
.rdb
.core
.editors
.main
.composite
.ResultMainComposite
;
83 import com
.hangum
.tadpole
.rdb
.core
.editors
.main
.function
.MainEditorBrowserFunctionService
;
84 import com
.hangum
.tadpole
.rdb
.core
.editors
.main
.utils
.ExtMakeContentAssistUtil
;
85 import com
.hangum
.tadpole
.rdb
.core
.extensionpoint
.definition
.IMainEditorExtension
;
86 import com
.hangum
.tadpole
.rdb
.core
.extensionpoint
.handler
.MainEditorContributionsHandler
;
87 import com
.hangum
.tadpole
.rdb
.core
.util
.DialogUtil
;
88 import com
.hangum
.tadpole
.rdb
.core
.util
.EditorUtils
;
89 import com
.hangum
.tadpole
.rdb
.core
.util
.FindEditorAndWriteQueryUtil
;
90 import com
.hangum
.tadpole
.rdb
.core
.viewers
.connections
.DBIconsUtils
;
91 import com
.hangum
.tadpole
.rdb
.core
.viewers
.object
.ExplorerViewer
;
92 import com
.hangum
.tadpole
.rdb
.core
.viewers
.object
.sub
.utils
.TadpoleObjectQuery
;
93 import com
.hangum
.tadpole
.sql
.format
.SQLFormater
;
94 import com
.swtdesigner
.ResourceManager
;
102 public class MainEditor
extends EditorExtension
{
104 public static final String ID
= "com.hangum.tadpole.rdb.core.editor.main"; //$NON-NLS-1$
105 /** Logger for this class. */
106 private static final Logger logger
= Logger
.getLogger(MainEditor
.class);
109 * MySQL 그룹은 스키마를 콤보박스
111 protected Combo comboSchema
;
113 /** connection URL */
114 private ToolItem tltmConnectURL
;
116 /** auto save를 위해 마지막 콘텐츠 를 남겨 놓는다. */
117 private String strLastContent
= "";
119 /** toolbar auto commit */
120 private ToolItem tiAutoCommit
= null, tiAutoCommitCommit
= null, tiAutoCommitRollback
= null, tltmTextResultView
= null;
121 private PublicTadpoleDefine
.RESULT_COMP_TYPE resultViewType
= RESULT_COMP_TYPE
.Table
;
124 protected ResultMainComposite resultMainComposite
;
126 /** edior가 초기화 될때 처음 로드 되어야 하는 String. */
127 protected String initDefaultEditorStr
= ""; //$NON-NLS-1$
129 /** 현재 editor가 열린 상태. 즉 table, view, index 등의 상태. */
130 protected OBJECT_TYPE dbAction
;
133 protected UserDBResourceDAO dBResource
;
134 /** 자동 저장 auto save */
135 protected UserDBResourceDAO dBResourceAuto
;
138 protected boolean isDirty
= false;
140 /** short cut prefix */
141 protected static final String STR_SHORT_CUT_PREFIX
= ShortcutPrefixUtils
.getCtrlShortcut();
143 protected SashForm sashFormExtension
;
144 protected IMainEditorExtension
[] compMainExtions
;
146 public MainEditor() {
151 public void init(IEditorSite site
, IEditorInput input
) throws PartInitException
{
152 MainEditorInput qei
= (MainEditorInput
)input
;
154 userDB
= (UserDBDAO
)qei
.getUserDB().clone();
155 } catch(Exception e
) {
156 logger
.error("set define default userDB", e
);
159 initDefaultEditorStr
= qei
.getDefaultStr();
160 strLastContent
= qei
.getDefaultStr();
161 dbAction
= qei
.getDbAction();
163 String strPartName
= qei
.getName();
164 dBResource
= qei
.getResourceDAO();
165 if(dBResource
!= null) {
166 strPartName
= dBResource
.getName();
168 // 기본 저장된 쿼리가 있는지 가져온다.
170 dBResourceAuto
= TadpoleSystem_UserDBResource
.getDefaultDBResourceData(userDB
);
171 if(dBResourceAuto
!= null) {
172 if(!StringUtils
.isEmpty(dBResourceAuto
.getDataString())) {
173 if(DBGroupDefine
.MYSQL_GROUP
== userDB
.getDBGroup()) {
174 initDefaultEditorStr
= dBResourceAuto
.getDataString() + Messages
.get().AutoRecoverMsg_mysql
+ initDefaultEditorStr
;
176 initDefaultEditorStr
= dBResourceAuto
.getDataString() + Messages
.get().AutoRecoverMsg
+ initDefaultEditorStr
;
180 } catch(Exception e
) {
181 logger
.error("Get default resource", e
);
184 strLastContent
= initDefaultEditorStr
;
186 strRoleType
= userDB
.getRole_id();
187 super.setUserType(strRoleType
);
193 setPartName(strPartName
);
195 setTitleImage(DBIconsUtils
.getEditorImage(getUserDB()));
199 public boolean isDirty() {
204 public boolean isSaveAsAllowed() {
205 if(dBResource
== null) return false;
210 public void createPartControl(Composite parent
) {
211 GridLayout gl_parent
= new GridLayout(1, false);
212 gl_parent
.verticalSpacing
= 2;
213 gl_parent
.horizontalSpacing
= 2;
214 gl_parent
.marginHeight
= 2;
215 gl_parent
.marginWidth
= 2;
216 parent
.setLayout(gl_parent
);
218 // 에디터 확장을 위한 기본 베이스 위젲을 설정합니다.
219 sashFormExtension
= new SashForm(parent
, SWT
.NONE
);
220 sashFormExtension
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true, 1, 1));
222 SashForm sashForm
= new SashForm(sashFormExtension
, SWT
.VERTICAL
);
223 sashForm
.setSashWidth(4);
224 sashForm
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true, 1, 1));
226 final Composite compositeEditor
= new Composite(sashForm
, SWT
.NONE
);
227 GridLayout gl_compositeEditor
= new GridLayout(3, false);
228 gl_compositeEditor
.verticalSpacing
= 0;
229 gl_compositeEditor
.horizontalSpacing
= 0;
230 gl_compositeEditor
.marginHeight
= 0;
231 gl_compositeEditor
.marginWidth
= 0;
232 compositeEditor
.setLayout(gl_compositeEditor
);
234 ToolBar toolBar
= new ToolBar(compositeEditor
, SWT
.NONE
| SWT
.FLAT
| SWT
.RIGHT
);
235 tltmConnectURL
= new ToolItem(toolBar
, SWT
.NONE
);
236 tltmConnectURL
.setToolTipText(Messages
.get().DatabaseInformation
);
237 tltmConnectURL
.setImage(ResourceManager
.getPluginImage(Activator
.PLUGIN_ID
, "resources/icons/editor/connect.png")); //$NON-NLS-1$
238 initConnectionInfo();
240 tltmConnectURL
.addSelectionListener(new SelectionAdapter() {
242 public void widgetSelected(SelectionEvent e
) {
243 DBInformationDialog dialog
= new DBInformationDialog(getSite().getShell(), userDB
);
249 // 패스워드를 물어야 하면 화면에서 보이지 않도록 수정.
250 if(PublicTadpoleDefine
.YES_NO
.NO
.name().equals(GetAdminPreference
.getConnectionAskType())) {
251 final ToolItem tltmSelectDB
= new ToolItem(toolBar
, SWT
.NONE
);
252 tltmSelectDB
.setToolTipText(Messages
.get().SelectOthersDB
);
253 tltmSelectDB
.setImage(ResourceManager
.getPluginImage(Activator
.PLUGIN_ID
, "resources/icons/editor/arrow_down.png")); //$NON-NLS-1$
254 tltmSelectDB
.addSelectionListener(new SelectionAdapter() {
256 public void widgetSelected(SelectionEvent e
) {
257 if(!isAutoCommit()) {
258 MessageDialog
.openWarning(getSite().getShell(), CommonMessages
.get().Warning
, Messages
.get().PleaseEndedTransaction
);
261 UserDBGroupDialog dialog
= new UserDBGroupDialog(getSite().getShell(), userDB
);
262 if(Dialog
.OK
== dialog
.open()) {
263 UserDBDAO selectedUserDB
= dialog
.getUserDB();
264 if(selectedUserDB
!= null) {
265 userDB
= selectedUserDB
;
268 TadpoleObjectQuery
.getTableList(userDB
);
269 } catch (Exception e1
) {
270 logger
.error("get table list", e1
);
273 initConnectionInfo();
275 comboSchema
.removeAll();
276 // if mysql db listup schema list
277 if(userDB
.getDBGroup() == DBGroupDefine
.MYSQL_GROUP
){
279 for (Object object
: DBSystemSchema
.getSchemas(userDB
)) {
280 HashMap
<String
, String
> mapData
= (HashMap
)object
;
281 comboSchema
.add(mapData
.get("SCHEMA"));
284 userDB
.setSchema(userDB
.getDb());
285 comboSchema
.setText(userDB
.getDb());
286 } catch (Exception ee
) {
287 comboSchema
.setItems( new String
[]{userDB
.getSchema()} );
288 logger
.error("get system schemas " + ee
.getMessage());
291 comboSchema
.add(userDB
.getDb());
292 comboSchema
.select(0);
301 new ToolItem(toolBar
, SWT
.SEPARATOR
);
304 // mysql group 이면 스키마 목록이 보이도록 합니다.
305 if(getUserDB().getDBGroup() == DBGroupDefine
.MYSQL_GROUP
| userDB
.getDBGroup() == DBGroupDefine
.ORACLE_GROUP
| userDB
.getDBGroup() == DBGroupDefine
.POSTGRE_GROUP
) {
306 ToolItem sep
= new ToolItem(toolBar
, SWT
.SEPARATOR
);
308 comboSchema
= new Combo(toolBar
, SWT
.READ_ONLY
);
309 comboSchema
.addSelectionListener(new SelectionAdapter() {
311 public void widgetSelected(SelectionEvent e
) {
312 final String strSchema
= comboSchema
.getText();
313 userDB
.setSchema(strSchema
);
315 // 기존에 설정되어 있는 테이블 목록등을 삭제한다.
316 userDB
.setTableListSeparator(null);
317 userDB
.setViewListSeparator(null);
318 userDB
.setFunctionLisstSeparator(null);
320 Connection conn
= null;
322 conn
= TadpoleSQLManager
.getConnection(userDB
);
323 AbstractTadpoleManager
.changeSchema(userDB
, conn
);
324 } catch(Exception e3
) {
325 logger
.error("** initialize connection", e3
);
327 try { if(conn
!= null) conn
.close(); } catch(Exception ee
) {}
330 if(PublicTadpoleDefine
.ACTIVE_PRODUCT_TYPE
== PRODUCT_TYPE
.TadpoleDBHub
) {
331 //오브젝트 익스플로어가 같은 스키마 일경우 스키마가 변경되도록.
332 getSite().getShell().getDisplay().asyncExec(new Runnable() {
336 // 오브젝트 탐색기가 열려 있으면 탐색기의 스키마 이름을 변경해 줍니다.
337 ExplorerViewer ev
= (ExplorerViewer
)PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(ExplorerViewer
.ID
);
338 ev
.changeSchema(userDB
, strSchema
);
340 } catch (PartInitException e
) {
341 logger
.error("ExplorerView show", e
); //$NON-NLS-1$
346 } // end product type
351 // 스키마리스트가 없는 경우 스키마 리스트를 가지고 넣는다.
353 if(userDB
.getSchemas().isEmpty()) {
355 for (Object object
: DBSystemSchema
.getSchemas(userDB
)) {
356 HashMap
<String
, String
> mapData
= (HashMap
)object
;
357 comboSchema
.add(mapData
.get("SCHEMA"));
358 userDB
.addSchema(mapData
.get("SCHEMA"));
360 if(userDB
.getDBGroup() == DBGroupDefine
.ORACLE_GROUP
) {
361 userDB
.setSchema(userDB
.getUsers());
362 } else if(userDB
.getDBGroup() == DBGroupDefine
.MYSQL_GROUP
) {
363 userDB
.setSchema(userDB
.getDb());
365 } catch(Exception e
) {
366 logger
.error("get schema list " + e
.getMessage());
369 for (String schema
: userDB
.getSchemas()) {
370 comboSchema
.add(schema
);
373 comboSchema
.setVisibleItemCount(comboSchema
.getItemCount() > 15 ?
15 : comboSchema
.getItemCount());
375 comboSchema
.setText(userDB
.getSchema());
377 new ToolItem(toolBar
, SWT
.SEPARATOR
);
379 sep
.setWidth(comboSchema
.getSize().x
);
380 sep
.setControl(comboSchema
);
385 ToolItem tltmOpen
= new ToolItem(toolBar
, SWT
.NONE
);
386 tltmOpen
.setToolTipText(Messages
.get().MainEditor_35
);
387 tltmOpen
.setImage(ResourceManager
.getPluginImage(Activator
.PLUGIN_ID
, "resources/icons/editor/file-open.png")); //$NON-NLS-1$
388 tltmOpen
.addSelectionListener(new SelectionAdapter() {
390 public void widgetSelected(SelectionEvent e
) {
391 SingleFileuploadDialog dialog
= new SingleFileuploadDialog(PlatformUI
.getWorkbench().getDisplay().getActiveShell(), Messages
.get().MainEditor_36
);
392 if(Dialog
.OK
== dialog
.open()) {
393 // if(logger.isDebugEnabled()) logger.debug("============> " + dialog.getStrTxtFile()); //$NON-NLS-1$
394 if(SingleFileuploadDialog
.ENUM_OPEN_TYPE
.ADD_APPEND
.name().equals(dialog
.getStrComboOpenType())) {
395 appendText(dialog
.getStrFileContent());
396 } else if(SingleFileuploadDialog
.ENUM_OPEN_TYPE
.NEW_WINDOW
.name().equals(dialog
.getStrComboOpenType())) {
397 FindEditorAndWriteQueryUtil
.run(userDB
, "", dialog
.getStrFileContent(), true, PublicTadpoleDefine
.OBJECT_TYPE
.TABLES
);
398 } else if(SingleFileuploadDialog
.ENUM_OPEN_TYPE
.REMOVE_AND_ADD
.name().equals(dialog
.getStrComboOpenType())) {
400 browserEvaluate(EditorFunctionService
.RE_NEW_TEXT
, dialog
.getStrFileContent());
401 } catch(Exception ee
) {
402 logger
.error("browser re_new_text error");
408 new ToolItem(toolBar
, SWT
.SEPARATOR
);
410 // 결과를 텍스트로 출력할 것인지 여부
411 tltmTextResultView
= new ToolItem(toolBar
, SWT
.CHECK
);
412 // tltmTextResultView.setImage(ResourceManager.getPluginImage(Activator.PLUGIN_ID, "resources/icons/editor/textNote.png")); //$NON-NLS-1$
413 tltmTextResultView
.setText("Text");
414 tltmTextResultView
.addSelectionListener(new SelectionAdapter() {
416 public void widgetSelected(SelectionEvent e
) {
417 if(tltmTextResultView
.getSelection()) {
418 resultViewType
= RESULT_COMP_TYPE
.Text
;
419 tltmTextResultView
.setSelection(true);
421 resultViewType
= RESULT_COMP_TYPE
.Table
;
422 tltmTextResultView
.setSelection(false);
426 tltmTextResultView
.setToolTipText(Messages
.get().TextResultView
);
427 tltmTextResultView
.setEnabled(PublicTadpoleDefine
.YES_NO
.YES
.name().equals(getUserDB().getIs_resource_download()));
428 new ToolItem(toolBar
, SWT
.SEPARATOR
);
430 ToolItem tltmExecute
= new ToolItem(toolBar
, SWT
.NONE
);
431 tltmExecute
.setToolTipText(String
.format(Messages
.get().MainEditor_tltmExecute_toolTipText_1
, STR_SHORT_CUT_PREFIX
));
432 tltmExecute
.setImage(ResourceManager
.getPluginImage(Activator
.PLUGIN_ID
, "resources/icons/editor/play.png")); //$NON-NLS-1$
433 tltmExecute
.addSelectionListener(new SelectionAdapter() {
435 public void widgetSelected(SelectionEvent e
) {
436 String strQuery
= browserEvaluateToStr(EditorFunctionService
.GET_SELECTED_TEXT
, PublicTadpoleDefine
.SQL_DELIMITER
);
438 EditorDefine
.EXECUTE_TYPE executeType
= EditorDefine
.EXECUTE_TYPE
.NONE
;
439 if( Boolean
.parseBoolean( browserEvaluateToStr(EditorFunctionService
.IS_BLOCK_TEXT
) ) ) {
440 executeType
= EditorDefine
.EXECUTE_TYPE
.BLOCK
;
443 RequestQuery reqQuery
= new RequestQuery(getConnectionid(), userDB
, strQuery
, dbAction
, EditorDefine
.QUERY_MODE
.QUERY
, executeType
, isAutoCommit());
444 executeCommand(reqQuery
);
447 new ToolItem(toolBar
, SWT
.SEPARATOR
);
449 if(SQLUtil
.isSELECTEditor(dbAction
)) {
450 ToolItem tltmExecuteAll
= new ToolItem(toolBar
, SWT
.NONE
);
451 tltmExecuteAll
.setToolTipText(Messages
.get().MainEditor_tltmExecuteAll_text
);
452 tltmExecuteAll
.setImage(ResourceManager
.getPluginImage(Activator
.PLUGIN_ID
, "resources/icons/editor/sql-query-all.png")); //$NON-NLS-1$
453 tltmExecuteAll
.addSelectionListener(new SelectionAdapter() {
455 public void widgetSelected(SelectionEvent e
) {
456 String strQuery
= browserEvaluateToStr(EditorFunctionService
.ALL_TEXT
);
458 RequestQuery reqQuery
= new RequestQuery(getConnectionid(), userDB
, strQuery
, dbAction
, EditorDefine
.QUERY_MODE
.QUERY
, EditorDefine
.EXECUTE_TYPE
.ALL
, isAutoCommit());
459 executeCommand(reqQuery
);
462 new ToolItem(toolBar
, SWT
.SEPARATOR
);
465 ToolItem tltmExplainPlanctrl
= new ToolItem(toolBar
, SWT
.NONE
);
466 tltmExplainPlanctrl
.setImage(ResourceManager
.getPluginImage(Activator
.PLUGIN_ID
, "resources/icons/editor/execute_plan.png")); //$NON-NLS-1$
467 tltmExplainPlanctrl
.addSelectionListener(new SelectionAdapter() {
469 public void widgetSelected(SelectionEvent e
) {
470 String strQuery
= browserEvaluateToStr(EditorFunctionService
.GET_SELECTED_TEXT
, PublicTadpoleDefine
.SQL_DELIMITER
); //$NON-NLS-1$
472 RequestQuery reqQuery
= new RequestQuery(getConnectionid(), userDB
, strQuery
, dbAction
, EditorDefine
.QUERY_MODE
.EXPLAIN_PLAN
, EditorDefine
.EXECUTE_TYPE
.NONE
, isAutoCommit());
473 executeCommand(reqQuery
);
477 tltmExplainPlanctrl
.setToolTipText(String
.format(Messages
.get().MainEditor_3
, STR_SHORT_CUT_PREFIX
));
478 new ToolItem(toolBar
, SWT
.SEPARATOR
);
479 if(DBGroupDefine
.DYNAMODB_GROUP
== getUserDB().getDBGroup()) tltmExplainPlanctrl
.setEnabled(false);
481 ToolItem tltmSort
= new ToolItem(toolBar
, SWT
.NONE
);
482 tltmSort
.setImage(ResourceManager
.getPluginImage(Activator
.PLUGIN_ID
, "resources/icons/editor/query_format.png")); //$NON-NLS-1$
483 tltmSort
.addSelectionListener(new SelectionAdapter() {
485 public void widgetSelected(SelectionEvent e
) {
486 String strQuery
= browserEvaluateToStr(EditorFunctionService
.ALL_TEXT
);
489 browserEvaluate(EditorFunctionService
.RE_NEW_TEXT
, SQLFormater
.format(strQuery
));
490 } catch(Exception ee
) {
491 logger
.error("sql format", ee
); //$NON-NLS-1$
495 tltmSort
.setToolTipText(String
.format(Messages
.get().MainEditor_4
, STR_SHORT_CUT_PREFIX
));
496 new ToolItem(toolBar
, SWT
.SEPARATOR
);
498 ToolItem tltmSQLToApplication
= new ToolItem(toolBar
, SWT
.NONE
);
499 tltmSQLToApplication
.setImage(ResourceManager
.getPluginImage(Activator
.PLUGIN_ID
, "resources/icons/editor/sql_to_applications.png")); //$NON-NLS-1$
500 tltmSQLToApplication
.addSelectionListener(new SelectionAdapter() {
502 public void widgetSelected(SelectionEvent e
) {
503 String strQuery
= browserEvaluateToStr(EditorFunctionService
.ALL_TEXT
);
505 SQLToStringDialog dialog
= new SQLToStringDialog(null, getUserDB(), strQuery
);
510 tltmSQLToApplication
.setToolTipText(Messages
.get().MainEditor_40
);
511 new ToolItem(toolBar
, SWT
.SEPARATOR
);
513 // ToolItem tltmDownload = new ToolItem(toolBar, SWT.NONE);
514 // tltmDownload.setImage(ResourceManager.getPluginImage(Activator.PLUGIN_ID, "resources/icons/editor/download_query.png")); //$NON-NLS-1$
515 // tltmDownload.addSelectionListener(new SelectionAdapter() {
517 // public void widgetSelected(SelectionEvent e) {
518 // if(!MessageDialog.openConfirm(null, Messages.get().MainEditor_38, Messages.get().MainEditor_39)) return;
521 // String strQuery = browserEvaluateToStr(EditorFunctionService.ALL_TEXT);
522 // compResult.downloadExtFile(getUserDB().getDisplay_name()+".sql", strQuery); //$NON-NLS-1$
523 // } catch(Exception ee) {
524 // logger.error("Download SQL", ee); //$NON-NLS-1$
528 // tltmDownload.setToolTipText(Messages.get().MainEditor_42);
529 // new ToolItem(toolBar, SWT.SEPARATOR);
531 tiAutoCommit
= new ToolItem(toolBar
, SWT
.CHECK
);
532 tiAutoCommit
.setSelection(false);
533 tiAutoCommit
.setText(Messages
.get().MainEditor_41
);
534 tiAutoCommit
.addSelectionListener(new SelectionAdapter() {
536 public void widgetSelected(SelectionEvent e
) {
537 initAutoCommitAction(false, true);
540 if(DBGroupDefine
.DYNAMODB_GROUP
== getUserDB().getDBGroup()) tiAutoCommit
.setEnabled(false);
542 tiAutoCommitCommit
= new ToolItem(toolBar
, SWT
.NONE
);
543 tiAutoCommitCommit
.setSelection(false);
544 tiAutoCommitCommit
.setText(Messages
.get().Commit
);
545 tiAutoCommitCommit
.addSelectionListener(new SelectionAdapter() {
547 public void widgetSelected(SelectionEvent e
) {
548 if(logger
.isDebugEnabled()) logger
.debug("[set commit][user id]" + getUserEMail() + "[user id]" + userDB
); //$NON-NLS-1$ //$NON-NLS-2$
550 TadpoleSQLTransactionManager
.commit(getConnectionid(), getUserEMail(), userDB
);
551 MessageDialog
.openInformation(getSite().getShell(), CommonMessages
.get().Confirm
, Messages
.get().ConfirmCommit
);
555 tiAutoCommitRollback
= new ToolItem(toolBar
, SWT
.NONE
);
556 tiAutoCommitRollback
.setSelection(false);
557 tiAutoCommitRollback
.setText(Messages
.get().Rollback
);
558 tiAutoCommitRollback
.addSelectionListener(new SelectionAdapter() {
560 public void widgetSelected(SelectionEvent e
) {
561 if(logger
.isDebugEnabled()) logger
.debug("[set rollback][user id]" + getUserEMail() + "[user id]" + userDB
); //$NON-NLS-1$ //$NON-NLS-2$
563 TadpoleSQLTransactionManager
.rollback(getConnectionid(), getUserEMail(), userDB
);
564 MessageDialog
.openInformation(getSite().getShell(), CommonMessages
.get().Confirm
, Messages
.get().ConfirmRollback
);
567 new ToolItem(toolBar
, SWT
.SEPARATOR
);
570 ToolItem tltmAPI
= new ToolItem(toolBar
, SWT
.NONE
);
571 tltmAPI
.setImage(ResourceManager
.getPluginImage(Activator
.PLUGIN_ID
, "resources/icons/editor/restful_api.png")); //$NON-NLS-1$
572 tltmAPI
.addSelectionListener(new SelectionAdapter() {
574 public void widgetSelected(SelectionEvent e
) {
575 String strQuery
= browserEvaluateToStr(EditorFunctionService
.ALL_TEXT
);
577 MainSQLEditorAPIServiceDialog dialog
= new MainSQLEditorAPIServiceDialog(getSite().getShell(), userDB
, strQuery
);
583 tltmAPI
.setToolTipText(Messages
.get().MainEditor_51
);
584 new ToolItem(toolBar
, SWT
.SEPARATOR
);
586 ToolItem tltmHelp
= new ToolItem(toolBar
, SWT
.NONE
);
587 tltmHelp
.setImage(ResourceManager
.getPluginImage(Activator
.PLUGIN_ID
, "resources/icons/editor/about.png")); //$NON-NLS-1$
588 tltmHelp
.addSelectionListener(new SelectionAdapter() {
590 public void widgetSelected(SelectionEvent e
) {
591 RDBShortcutHelpDialog dialog
= new RDBShortcutHelpDialog(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT
.NONE
);
597 tltmHelp
.setToolTipText(String
.format(Messages
.get().MainEditor_27
, STR_SHORT_CUT_PREFIX
));
598 ////// tool bar end ///////////////////////////////////////////////////////////////////////////////////
600 ////// orion editor start /////////////////////////////////////////////////////////////////////////////
601 browserQueryEditor
= new Browser(compositeEditor
, SWT
.BORDER
);
602 browserQueryEditor
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true, 3, 1));
605 resultMainComposite
= new ResultMainComposite(sashForm
, SWT
.BORDER
);
606 GridLayout gl_compositeResult
= new GridLayout(1, false);
607 gl_compositeResult
.verticalSpacing
= 0;
608 gl_compositeResult
.horizontalSpacing
= 0;
609 gl_compositeResult
.marginHeight
= 0;
610 gl_compositeResult
.marginWidth
= 0;
611 resultMainComposite
.setLayout(gl_compositeResult
);
612 resultMainComposite
.setMainEditor(this);
614 sashForm
.setWeights(new int[] {63, 37});
617 // 올챙이 확장에 관한 코드를 넣습니다. ===================================================================
618 MainEditorContributionsHandler editorExtension
= new MainEditorContributionsHandler();
619 compMainExtions
= editorExtension
.evaluateCreateWidgetContribs(userDB
);
621 for (IMainEditorExtension aMainEditorExtension
: compMainExtions
) {
623 if(aMainEditorExtension
.isEnableExtension()) {
625 Composite compExt
= new Composite(sashFormExtension
, SWT
.BORDER
);
626 GridLayout gl_compositeExt
= new GridLayout(1, false);
627 gl_compositeExt
.verticalSpacing
= 0;
628 gl_compositeExt
.horizontalSpacing
= 0;
629 gl_compositeExt
.marginHeight
= 0;
630 gl_compositeExt
.marginWidth
= 0;
631 compExt
.setLayout(gl_compositeExt
);
633 aMainEditorExtension
.createPartControl(compExt
, this);
637 if(intSashCnt
>= 2) {
638 sashFormExtension
.setWeights(new int[] {100, 0});
640 // 올챙이 확장에 관한 코드를 넣습니다. ===================================================================
642 // autocommit true 혹은 false값이 바뀌었을때..
643 PlatformUI
.getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() {
645 public void propertyChange(PropertyChangeEvent event
) {
647 // if (event.getProperty() == PublicTadpoleDefine.AUTOCOMMIT_USE) {
648 // String strAutoCommit_seq = event.getNewValue().toString();
649 // // UserDB.seq || auto commit ture or false
650 // String[] arryVal = StringUtils.split(strAutoCommit_seq, "||"); //$NON-NLS-1$
651 // int seq = Integer.parseInt(arryVal[0]);
652 // boolean boolUseAutocommit = Boolean.parseBoolean(arryVal[1]);
654 // if(!tiAutoCommit.isDisposed()) {
655 // if(seq == userDB.getSeq()) {
656 // tiAutoCommit.setSelection(boolUseAutocommit);
657 // if(!boolUseAutocommit) {
658 // tiAutoCommitCommit.setEnabled(false);
659 // tiAutoCommitRollback.setEnabled(false);
661 // tiAutoCommitCommit.setEnabled(true);
662 // tiAutoCommitRollback.setEnabled(true);
664 // } // end tltmAutoCommit
667 if(event
.getProperty() == PreferenceDefine
.EDITOR_CHANGE_EVENT
) {
668 final String varTheme
= PublicTadpoleDefine
.getMapTheme().get(GetPreferenceGeneral
.getEditorTheme());
669 final String varFontSize
= GetPreferenceGeneral
.getEditorFontSize();
670 final String varIsWrap
= ""+GetPreferenceGeneral
.getEditorIsWarp();
671 final String varWarpLimit
= GetPreferenceGeneral
.getEditorWarpLimitValue();
672 final String varIsShowGutter
= ""+GetPreferenceGeneral
.getEditorShowGutter();
674 browserEvaluate(IEditorFunction
.CHANGE_EDITOR_STYLE
,
675 varTheme
, varFontSize
, varIsWrap
, varWarpLimit
, varIsShowGutter
679 }); // end property change
683 * refresh connection title
685 private void initConnectionInfo() {
686 tltmConnectURL
.setText(String
.format("%s", userDB
.getDisplay_name()));
688 // if selected DB is mysql, reset schema list
691 public Browser
getBrowserQueryEditor() {
692 return browserQueryEditor
;
698 protected void addBrowserService() {
699 browserQueryEditor
.setUrl(REAL_DB_URL
);
701 // final String strConstList = findDefaultKeyword();
702 // 기존 리소스를 가져왔으면 auto save mode 는 false
703 final String varAutoSave
= dBResource
!= null?
"fasle":""+GetPreferenceGeneral
.getEditorAutoSave();
705 final String varTheme
= PublicTadpoleDefine
.getMapTheme().get(GetPreferenceGeneral
.getEditorTheme());
706 final String varFontSize
= GetPreferenceGeneral
.getEditorFontSize();
707 final String varIsWrap
= ""+GetPreferenceGeneral
.getEditorIsWarp();
708 final String varWarpLimit
= GetPreferenceGeneral
.getEditorWarpLimitValue();
709 final String varIsShowGutter
= ""+GetPreferenceGeneral
.getEditorShowGutter();
710 registerBrowserFunctions();
712 browserQueryEditor
.addProgressListener(new ProgressListener() {
714 public void completed( ProgressEvent event
) {
716 browserEvaluate(IEditorFunction
.RDB_INITIALIZE
,
717 findEditorExt(), dbAction
.toString(), getInitDefaultEditorStr(),
718 varAutoSave
, varTheme
, varFontSize
, varIsWrap
, varWarpLimit
, varIsShowGutter
720 } catch(Exception ee
) {
721 logger
.error("rdb editor initialize ", ee
); //$NON-NLS-1$
724 public void changed( ProgressEvent event
) {}
735 public String
getContentAssist(String strQuery
, int intPosition
) {
736 if("".equals(StringUtils
.trimToEmpty(strQuery
))) return "";
738 if(logger
.isDebugEnabled()) {
739 logger
.debug("-[start block] -------------------------------------------------------------");
740 logger
.debug("\t[strQuery]" + strQuery
);
741 logger
.debug("\t[intPosition]" + intPosition
);
744 String newContentAssist
= "";
746 ExtMakeContentAssistUtil constAssistUtil
= new ExtMakeContentAssistUtil();
747 newContentAssist
= constAssistUtil
.makeContentAssist(getUserDB(), strQuery
, intPosition
);
748 } catch(Exception e
) {
749 logger
.error("Content assist", e
);
751 if(logger
.isDebugEnabled()) logger
.debug("-[end block] -------------------------------------------------------------");
753 return newContentAssist
==null?
"":newContentAssist
;
759 private void initEditor() {
760 if (DBGroupDefine
.HIVE_GROUP
== userDB
.getDBGroup()) {
761 tiAutoCommit
.setEnabled(false);
764 if("YES".equals(userDB
.getIs_autocommit())) { //$NON-NLS-1$
765 tiAutoCommit
.setSelection(false);
767 tiAutoCommit
.setSelection(true);
770 // 기존 에디터에서 auto commit button 이 어떻게 설정 되어 있는지 가져옵니다.
771 initAutoCommitAction(true, false);
773 // 과거에 실행했던 쿼리 정보 가져오기.
774 // resultMainComposite.initMainComposite();
776 // 초기 연결 커넥션을 초기화 합니다.
777 if (DBGroupDefine
.MYSQL_GROUP
== userDB
.getDBGroup()) {
778 Connection conn
= null;
780 conn
= TadpoleSQLManager
.getConnection(userDB
);
781 AbstractTadpoleManager
.changeSchema(userDB
, conn
);
782 } catch(Exception e3
) {
783 logger
.error("** initialize connection", e3
);
785 try { if(conn
!= null) conn
.close(); } catch(Exception ee
) {}
790 AnalyticCaller
.track(MainEditor
.ID
, userDB
.getDbms_type());
794 * start sql transaction;
796 public void beginTransaction() {
797 getSite().getShell().getDisplay().asyncExec(new Runnable() {
799 if(tiAutoCommit
.isEnabled()) {
800 tiAutoCommit
.setEnabled(true);
801 tiAutoCommit
.setSelection(true);
802 tiAutoCommitCommit
.setEnabled(true);
803 tiAutoCommitRollback
.setEnabled(true);
810 * init auto commit button
815 private void initAutoCommitAction(boolean isFirst
, boolean isRiseEvent
) {
817 tiAutoCommitCommit
.setEnabled(false);
818 tiAutoCommitRollback
.setEnabled(false);
821 if(TadpoleSQLTransactionManager
.isInstance(getConnectionid(), getUserEMail(), userDB
)) {
822 if(MessageDialog
.openConfirm(null, CommonMessages
.get().Confirm
, Messages
.get().MainEditor_47
)) {
823 TadpoleSQLTransactionManager
.commit(getConnectionid(), getUserEMail(), userDB
);
825 TadpoleSQLTransactionManager
.rollback(getConnectionid(), getUserEMail(), userDB
);
830 tiAutoCommitCommit
.setEnabled(true);
831 tiAutoCommitRollback
.setEnabled(true);
835 // // auto commit의 실행버튼을 동일한 db를 열고 있는 에디터에서 공유합니다.
836 // PlatformUI.getPreferenceStore().setValue(PublicTadpoleDefine.AUTOCOMMIT_USE, userDB.getSeq() + "||" + tiAutoCommit.getSelection() + "||" + System.currentTimeMillis()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
845 public void executeCommand(final RequestQuery reqQuery
) {
846 if(!userDB
.is_isUseEnable()) {
847 MessageDialog
.openInformation(getSite().getShell(), CommonMessages
.get().Information
, CommonMessages
.get().TermExpiredMsg
);
852 if(StringUtils
.isEmpty(reqQuery
.getSql())) return;
854 // if(logger.isDebugEnabled()) {
855 // logger.debug("===> [connection id]" + reqQuery.getConnectId());
859 // schema test code start
861 final UserDBDAO userDB
= getUserDB();
862 // if(logger.isDebugEnabled()) {
863 // logger.debug("======= schema name : " + userDB.getSchema());
866 // do not execute query
867 // if(System.currentTimeMillis() > SessionManager.getServiceEnd().getTime()) {
868 // if(ApplicationArgumentUtils.isOnlineServer()) {
869 // if(MessageDialog.openConfirm(null, CommonMessages.get().Information, Messages.get().MainEditorServiceEndGoPay)) {
870 // UserBillEditorInput mei = new UserBillEditorInput();
873 // PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(mei, DefineExternalPlguin.BILL_PLUGIN);
874 // } catch (PartInitException e) {
875 // logger.error("open editor", e); //$NON-NLS-1$
876 // Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$
877 // ExceptionDetailsErrorDialog.openError(null,CommonMessages.get().Error, "Bill page open", errStatus); //$NON-NLS-1$
881 // MessageDialog.openInformation(null, CommonMessages.get().Information, Messages.get().MainEditorServiceEnd);
886 String strCheckSQL
= SQLUtil
.removeCommentAndOthers(userDB
, reqQuery
.getSql());
887 if(StringUtils
.startsWithIgnoreCase(strCheckSQL
, "desc ")) {
888 String strObject
= StringUtils
.removeStartIgnoreCase(strCheckSQL
, "desc ");
890 Map
<String
,String
> paramMap
= new HashMap
<String
, String
>();
891 if(StringUtils
.contains(strObject
, ".")) {
892 paramMap
.put("OBJECT_OWNER", StringUtils
.substringBefore(strObject
, "."));
893 paramMap
.put("OBJECT_NAME", StringUtils
.substringAfter(strObject
, "."));
895 paramMap
.put("OBJECT_OWNER", userDB
.getSchema());
896 paramMap
.put("OBJECT_NAME", strObject
);
899 DialogUtil
.popupObjectInformationDialog(getUserDB(), paramMap
);
900 } else if(StringUtils
.startsWithIgnoreCase(strCheckSQL
, "use ") && getUserDB().getDBGroup() == DBGroupDefine
.MYSQL_GROUP
) {
902 testChangeSchema(strCheckSQL
);
903 String strSchema
= StringUtils
.remove(strCheckSQL
, "use ");
904 userDB
.setSchema(strSchema
);
906 comboSchema
.setText(strSchema
);
907 } catch(Exception e
) {
908 MessageDialog
.openError(null, CommonMessages
.get().Error
, e
.getMessage());
912 resultMainComposite
.executeCommand(reqQuery
);
916 AnalyticCaller
.track(MainEditor
.ID
, "executeCommand"); //$NON-NLS-1$
920 * schema 변경시 올바른지 검증한다.
924 private void testChangeSchema(String strCheckSQL
) throws Exception
{
925 Connection javaConn
= TadpoleSQLManager
.getConnection(userDB
);
927 Statement statement
= null;
929 if(userDB
.getDBGroup() == DBGroupDefine
.MYSQL_GROUP
) {
930 if(logger
.isDebugEnabled()) logger
.debug(String
.format("=set define schema %s ", userDB
.getSchema()));
932 statement
= javaConn
.createStatement();
933 statement
.executeUpdate(strCheckSQL
);
935 } catch(Exception e
) {
936 logger
.error("change scheman ", e
);
939 if(statement
!= null) statement
.close();
946 public boolean isAutoCommit() {
947 if(tiAutoCommit
== null) return true;
948 return !tiAutoCommit
.getSelection();
952 public void setFocus() {
954 EditorUtils
.selectConnectionManager(getUserDB());
962 private UserDBResourceDAO
getResouceName(UserDBResourceDAO initDBResource
, String strContentData
) {
963 PublicTadpoleDefine
.RESOURCE_TYPE resourceType
= PublicTadpoleDefine
.RESOURCE_TYPE
.OBJECT
;
964 if(dbAction
== PublicTadpoleDefine
.OBJECT_TYPE
.TABLES
|
965 dbAction
== PublicTadpoleDefine
.OBJECT_TYPE
.VIEWS
) {
966 resourceType
= PublicTadpoleDefine
.RESOURCE_TYPE
.SQL
;
969 ResourceSaveDialog rsDialog
= new ResourceSaveDialog(null, initDBResource
, userDB
, resourceType
, strContentData
);
970 if(rsDialog
.open() == Window
.OK
) {
971 return rsDialog
.getRetResourceDao();
980 * @param strContentData
983 public boolean calledDoSave(String strContentData
) {
984 boolean isSaved
= false;
987 // 신규 저장일때는 리소스타입, 이름, 코멘를 입력받습니다.
988 if(dBResource
== null) {
989 UserDBResourceDAO newDBResource
= getResouceName(null, strContentData
);
990 if(newDBResource
== null) return false;
992 isSaved
= saveResourceData(newDBResource
, strContentData
);
995 isSaved
= updateResourceDate(strContentData
);
998 this.strLastContent
= strContentData
;
1000 // auto save 항목을 지운다.
1001 if(dBResourceAuto
!= null) {
1002 TadpoleSystem_UserDBResource
.updateResourceAuto(dBResourceAuto
, "");
1005 } catch(Exception e
) {
1006 logger
.error(RequestInfoUtils
.requestInfo("doSave exception", getUserEMail()), e
); //$NON-NLS-1$
1010 browserEvaluate(IEditorFunction
.SAVE_DATA
);
1013 browserEvaluate(IEditorFunction
.SET_FOCUS
);
1022 * @param strContentData
1025 public boolean calledDoAutoSave(String strContentData
) {
1026 if(logger
.isDebugEnabled()) logger
.debug("====== called auto save ==========" + strContentData
);
1027 // 내용이 공백이거나 이전 내용과 같으면 저장하지 않는다.
1028 if("".equals(StringUtils
.trimToEmpty(strContentData
))) return true;
1029 if(StringUtils
.trimToEmpty(strLastContent
).equals(StringUtils
.trimToEmpty(strContentData
))) return true;
1031 boolean isSaved
= false;
1033 isSaved
= updateAutoResourceDate(strContentData
);
1034 strLastContent
= strContentData
;
1035 } catch(SWTException e
) {
1036 logger
.error(RequestInfoUtils
.requestInfo("doAutoSave exception", getUserEMail()), e
); //$NON-NLS-1$
1038 // browserEvaluate(IEditorFunction.SET_FOCUS);
1045 public void doSave(IProgressMonitor monitor
) {
1046 String strEditorAllText
= browserEvaluateToStr(EditorFunctionService
.ALL_TEXT
);
1047 calledDoSave(strEditorAllText
);
1051 public void doSaveAs() {
1052 boolean isSaved
= false;
1056 String strEditorAllText
= browserEvaluateToStr(EditorFunctionService
.ALL_TEXT
);
1058 // 신규 저장일때는 리소스타입, 이름, 코멘를 입력받습니다.
1059 UserDBResourceDAO newDBResource
= getResouceName(dBResource
, strEditorAllText
);
1060 if(newDBResource
== null) return;
1062 isSaved
= saveResourceData(newDBResource
, strEditorAllText
);
1063 } catch(SWTException e
) {
1064 logger
.error(RequestInfoUtils
.requestInfo("doSave exception", getUserEMail()), e
); //$NON-NLS-1$
1068 browserEvaluate(IEditorFunction
.SAVE_DATA
);
1071 browserEvaluate(IEditorFunction
.SET_FOCUS
);
1078 * @param newContents
1081 private boolean updateResourceDate(String newContents
) {
1083 TadpoleSystem_UserDBResource
.updateResource(dBResource
, newContents
);
1085 } catch (Exception e
) {
1086 logger
.error("update file", e
); //$NON-NLS-1$
1087 Status errStatus
= new Status(IStatus
.ERROR
, Activator
.PLUGIN_ID
, e
.getMessage(), e
); //$NON-NLS-1$
1088 ExceptionDetailsErrorDialog
.openError(getSite().getShell(),CommonMessages
.get().Error
, Messages
.get().MainEditor_19
, errStatus
); //$NON-NLS-1$
1096 * @param newContents
1099 private boolean updateAutoResourceDate(String newContents
) {
1100 if(dBResource
!= null) return true;
1102 // table, view만 auto save 된다.
1103 if(dbAction
== PublicTadpoleDefine
.OBJECT_TYPE
.TABLES
|
1104 dbAction
== PublicTadpoleDefine
.OBJECT_TYPE
.VIEWS
) {
1106 if(logger
.isDebugEnabled()) logger
.debug("====> called updateAutoResourceDate ");
1108 dBResourceAuto
= TadpoleSystem_UserDBResource
.updateAutoResourceDate(getUserDB(), dBResourceAuto
, dBResource
, newContents
);
1109 if(dBResource
!= null) {
1113 } catch (Exception e
) {
1114 logger
.error("Autosave exception", e
);
1115 // igoner error message
1127 * @param newDBResource 저장 하려는 리소스
1128 * @param newContents
1131 private boolean saveResourceData(UserDBResourceDAO newDBResource
, String newContents
) {
1135 dBResource
= TadpoleSystem_UserDBResource
.saveResource(userDB
, newDBResource
, newContents
);
1136 dBResource
.setParent(userDB
);
1139 setPartName(dBResource
.getName());
1142 PlatformUI
.getPreferenceStore().setValue(PublicTadpoleDefine
.SAVE_FILE
, String
.format("%s:%s", dBResource
.getDb_seq(), System
.currentTimeMillis())); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1144 } catch (Exception e
) {
1145 logger
.error("save data", e
); //$NON-NLS-1$
1147 Status errStatus
= new Status(IStatus
.ERROR
, Activator
.PLUGIN_ID
, e
.getMessage(), e
); //$NON-NLS-1$
1148 ExceptionDetailsErrorDialog
.openError(getSite().getShell(),CommonMessages
.get().Error
, Messages
.get().MainEditor_19
, errStatus
); //$NON-NLS-1$
1156 /** save property dirty */
1157 public void setDirty(Boolean newValue
) {
1158 if(isDirty
!= newValue
) {
1160 firePropertyChange(PROP_DIRTY
);
1165 public void dispose() {
1174 public OBJECT_TYPE
getDbAction() {
1183 public UserDBResourceDAO
getdBResource() {
1188 protected void registerBrowserFunctions() {
1189 editorService
= new MainEditorBrowserFunctionService(userDB
, browserQueryEditor
, EditorFunctionService
.EDITOR_SERVICE_HANDLER
, this);
1193 * 에디터 로드할때 사용할 초기 쿼리 입니다.
1196 public String
getInitDefaultEditorStr() {
1197 return initDefaultEditorStr
;
1200 public IMainEditorExtension
[] getMainEditorExtions() {
1201 return compMainExtions
;
1204 public SashForm
getSashFormExtension() {
1205 return sashFormExtension
;
1212 public PublicTadpoleDefine
.RESULT_COMP_TYPE
getResultViewType() {
1213 return resultViewType
;