Package com.dci.intellij.dbn.execution.common.message.action

Source Code of com.dci.intellij.dbn.execution.common.message.action.ViewExecutedStatementAction

package com.dci.intellij.dbn.execution.common.message.action;

import com.dci.intellij.dbn.common.Icons;
import com.dci.intellij.dbn.execution.statement.result.ui.StatementViewerPopup;
import com.dci.intellij.dbn.execution.statement.result.StatementExecutionResult;
import com.dci.intellij.dbn.execution.common.message.ui.tree.StatementExecutionMessageNode;
import com.dci.intellij.dbn.execution.common.message.ui.tree.MessagesTree;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.Presentation;
import java.awt.Component;

public class ViewExecutedStatementAction extends ExecutionMessagesAction {
    public ViewExecutedStatementAction(MessagesTree messagesTree) {
        super(messagesTree, "View SQL statement", Icons.EXEC_RESULT_VIEW_STATEMENT);
    }

    public void actionPerformed(AnActionEvent e) {
        getMessagesTree().grabFocus();
        StatementExecutionMessageNode execMessageNode = (StatementExecutionMessageNode) getMessagesTree().getSelectionPath().getLastPathComponent();
        StatementExecutionResult executionResult = execMessageNode.getExecutionMessage().getExecutionResult();
        StatementViewerPopup statementViewer = new StatementViewerPopup(executionResult);
        statementViewer.show((Component) e.getInputEvent().getSource());
    }

    public void update(AnActionEvent e) {
        boolean enabled =
                getMessagesTree().getSelectionPath() != null &&
                 getMessagesTree().getSelectionPath().getLastPathComponent() instanceof StatementExecutionMessageNode;
        Presentation presentation = e.getPresentation();
        presentation.setEnabled(enabled);
    }
}
TOP

Related Classes of com.dci.intellij.dbn.execution.common.message.action.ViewExecutedStatementAction

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.