Search in sources :

Example 6 with QueryEditorPart

use of com.cubrid.common.ui.query.editor.QueryEditorPart in project cubrid-manager by CUBRID.

the class QueryOpenAction method run.

/**
	 * @see org.eclipse.jface.action.Action#run()
	 */
public void run() {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null || window.getActivePage() == null) {
        return;
    }
    IEditorPart editor = window.getActivePage().getActiveEditor();
    if (editor != null && editor.isDirty()) {
        int confirm = CommonUITool.openMsgBox(editor.getSite().getShell(), MessageDialog.WARNING, Messages.saveResource, Messages.bind(Messages.saveConfirm, editor.getTitle()), new String[] { Messages.btnYes, Messages.btnNo, Messages.cancel });
        switch(confirm) {
            case 0:
                editor.doSave(null);
                break;
            case 1:
                break;
            default:
                return;
        }
    }
    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;
    }
    try {
        QueryEditorPart queryEditor = (QueryEditorPart) editor;
        SQLEditorComposite editorComp = queryEditor.getCombinedQueryComposite().getSqlEditorComp();
        String encoding = editorComp.getDocument().getEncoding();
        SetFileEncodingDialog dialog = new SetFileEncodingDialog(getShell(), encoding, true);
        if (IDialogConstants.OK_ID == dialog.open()) {
            editorComp.open(dialog.getFilePath(), dialog.getEncoding());
        }
    } catch (IOException e) {
        CommonUITool.openErrorBox(e.getMessage());
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) SQLEditorComposite(com.cubrid.common.ui.query.control.SQLEditorComposite) QueryEditorPart(com.cubrid.common.ui.query.editor.QueryEditorPart) QueryUnit(com.cubrid.common.ui.query.editor.QueryUnit) IEditorPart(org.eclipse.ui.IEditorPart) PartInitException(org.eclipse.ui.PartInitException) IOException(java.io.IOException) SetFileEncodingDialog(com.cubrid.common.ui.query.dialog.SetFileEncodingDialog) IEditorInput(org.eclipse.ui.IEditorInput)

Example 7 with QueryEditorPart

use of com.cubrid.common.ui.query.editor.QueryEditorPart in project cubrid-manager by CUBRID.

the class RunQueryAction method run.

/**
	 * @see org.eclipse.jface.action.Action#run()
	 */
public void run() {
    Control control = getFocusProvider();
    if (!(control instanceof StyledText)) {
        showNoSelectionQueryError();
        return;
    }
    StyledText stext = (StyledText) control;
    String data = stext.getSelectionText();
    if (StringUtil.isEmpty(data)) {
        showNoSelectionQueryError();
        return;
    }
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        showNoSelectionQueryError();
        return;
    }
    IEditorPart editor = window.getActivePage().getActiveEditor();
    if (editor == null || !(editor instanceof QueryEditorPart)) {
        showNoSelectionQueryError();
        return;
    }
    ((QueryEditorPart) editor).runQuery(false);
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) Control(org.eclipse.swt.widgets.Control) QueryEditorPart(com.cubrid.common.ui.query.editor.QueryEditorPart) StyledText(org.eclipse.swt.custom.StyledText) IEditorPart(org.eclipse.ui.IEditorPart)

Example 8 with QueryEditorPart

use of com.cubrid.common.ui.query.editor.QueryEditorPart in project cubrid-manager by CUBRID.

the class RunQueryPlanAction method run.

/**
	 * @see org.eclipse.jface.action.Action#run()
	 */
public void run() {
    Control control = getFocusProvider();
    if (!(control instanceof StyledText)) {
        showNoSelectionQueryError();
        return;
    }
    StyledText stext = (StyledText) control;
    String data = stext.getSelectionText();
    if (StringUtil.isEmpty(data)) {
        showNoSelectionQueryError();
        return;
    }
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        showNoSelectionQueryError();
        return;
    }
    IEditorPart editor = window.getActivePage().getActiveEditor();
    if (editor == null || !(editor instanceof QueryEditorPart)) {
        showNoSelectionQueryError();
        return;
    }
    ((QueryEditorPart) editor).runQuery(true);
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) Control(org.eclipse.swt.widgets.Control) QueryEditorPart(com.cubrid.common.ui.query.editor.QueryEditorPart) StyledText(org.eclipse.swt.custom.StyledText) IEditorPart(org.eclipse.ui.IEditorPart)

Example 9 with QueryEditorPart

use of com.cubrid.common.ui.query.editor.QueryEditorPart in project cubrid-manager by CUBRID.

the class ShowSchemaAction method run.

/**
	 * @see org.eclipse.jface.action.Action#run() Override the run method in
	 *      order to complete showing brokers status server to a broker
	 */
public void run() {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        showError();
        return;
    }
    IEditorPart editor = window.getActivePage().getActiveEditor();
    if (editor == null) {
        showError();
        return;
    }
    if (!(editor instanceof QueryEditorPart)) {
        showError();
        return;
    }
    QueryEditorPart queryEditorPart = (QueryEditorPart) editor;
    CubridDatabase db = queryEditorPart.getSelectedDatabase();
    if (db == null || !db.isLogined()) {
        showError();
        return;
    }
    String tableName = queryEditorPart.getSelectedText();
    if (tableName == null) {
        showError();
        return;
    }
    DatabaseInfo databaseInfo = db.getDatabaseInfo();
    if (databaseInfo == null) {
        showError();
        return;
    }
    CubridNavigatorView mainNav = CubridNavigatorView.findNavigationView();
    if (mainNav != null) {
        mainNav.showQuickView(databaseInfo, tableName, true);
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) QueryEditorPart(com.cubrid.common.ui.query.editor.QueryEditorPart) CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) IEditorPart(org.eclipse.ui.IEditorPart) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 10 with QueryEditorPart

use of com.cubrid.common.ui.query.editor.QueryEditorPart in project cubrid-manager by CUBRID.

the class QueryTunerAction method getQuery.

public String getQuery() {
    // FIXME extract to utility
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (null == window) {
        return null;
    }
    IEditorPart editor = window.getActivePage().getActiveEditor();
    if (editor == null) {
        return null;
    }
    if (!(editor instanceof QueryEditorPart)) {
        return null;
    }
    QueryEditorPart queryEditorPart = (QueryEditorPart) editor;
    StyledText stext = queryEditorPart.getSqlEditorWidget();
    return stext.getSelectionText();
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) QueryEditorPart(com.cubrid.common.ui.query.editor.QueryEditorPart) StyledText(org.eclipse.swt.custom.StyledText) IEditorPart(org.eclipse.ui.IEditorPart)

Aggregations

QueryEditorPart (com.cubrid.common.ui.query.editor.QueryEditorPart)51 IEditorPart (org.eclipse.ui.IEditorPart)41 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)39 QueryUnit (com.cubrid.common.ui.query.editor.QueryUnit)21 PartInitException (org.eclipse.ui.PartInitException)19 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)13 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)8 ArrayList (java.util.ArrayList)7 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)6 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)5 List (java.util.List)5 StyledText (org.eclipse.swt.custom.StyledText)5 ShardIdSelectionDialog (com.cubrid.common.ui.common.dialog.ShardIdSelectionDialog)4 CombinedQueryEditorComposite (com.cubrid.common.ui.query.control.CombinedQueryEditorComposite)4 IOException (java.io.IOException)4 IEditorReference (org.eclipse.ui.IEditorReference)4 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)3 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)3 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)3 Control (org.eclipse.swt.widgets.Control)3