Search in sources :

Example 61 with IWorkbenchWindow

use of org.eclipse.ui.IWorkbenchWindow 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 62 with IWorkbenchWindow

use of org.eclipse.ui.IWorkbenchWindow 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 63 with IWorkbenchWindow

use of org.eclipse.ui.IWorkbenchWindow 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 64 with IWorkbenchWindow

use of org.eclipse.ui.IWorkbenchWindow 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 65 with IWorkbenchWindow

use of org.eclipse.ui.IWorkbenchWindow 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

IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)363 IEditorPart (org.eclipse.ui.IEditorPart)136 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)102 PartInitException (org.eclipse.ui.PartInitException)81 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)41 QueryEditorPart (com.cubrid.common.ui.query.editor.QueryEditorPart)39 IViewPart (org.eclipse.ui.IViewPart)39 ArrayList (java.util.ArrayList)37 IEditorReference (org.eclipse.ui.IEditorReference)35 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)32 IWorkbench (org.eclipse.ui.IWorkbench)32 IFile (org.eclipse.core.resources.IFile)30 ISelection (org.eclipse.jface.viewers.ISelection)29 XLIFFEditorImplWithNatTable (net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable)27 Shell (org.eclipse.swt.widgets.Shell)26 XLFHandler (net.heartsome.cat.ts.core.file.XLFHandler)24 CoreException (org.eclipse.core.runtime.CoreException)23 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)21 IProject (org.eclipse.core.resources.IProject)20 QueryUnit (com.cubrid.common.ui.query.editor.QueryUnit)19