Search in sources :

Example 26 with PartInitException

use of org.eclipse.ui.PartInitException in project cubrid-manager by CUBRID.

the class SqlmapNavigatorView method pasteSqlToQueryEditor.

private void pasteSqlToQueryEditor(String sql) {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null || window.getActivePage() == null) {
        return;
    }
    IEditorPart editor = window.getActivePage().getActiveEditor();
    try {
        if (editor == null || !(editor instanceof QueryEditorPart)) {
            editor = window.getActivePage().openEditor(new QueryUnit(), QueryEditorPart.ID);
        }
    } catch (PartInitException e) {
        editor = null;
    }
    if (editor == null) {
        return;
    }
    QueryEditorPart queryEditor = (QueryEditorPart) editor;
    if (!StringUtil.isEmpty(queryEditor.getCurrentQuery())) {
        queryEditor.addEditorTab();
    }
    queryEditor.setQuery(sql, false, false, false);
    queryEditor.setFocus();
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) 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)

Example 27 with PartInitException

use of org.eclipse.ui.PartInitException in project cubrid-manager by CUBRID.

the class BrokerEnvStatusView method createTable.

/**
	 * This method initializes table
	 *
	 */
private void createTable() {
    tableViewer = new TableViewer(composite, SWT.FULL_SELECTION);
    tableViewer.getTable().setHeaderVisible(true);
    tableViewer.getTable().setLinesVisible(true);
    BrokerTblColumnSetHelp bcsh = BrokerTblColumnSetHelp.getInstance();
    bcsh.loadSetting(BrokerTblColumnSetHelp.StatusColumn.BrokerEnvStatusColumn, BrokerEnvStatusColumn.values());
    TableLayout tlayout = new TableLayout();
    for (BrokerEnvStatusColumn column : BrokerEnvStatusColumn.values()) {
        if (column.getValue() == -1) {
            tlayout.addColumnData(new ColumnWeightData(0, 0, false));
        } else {
            tlayout.addColumnData(new ColumnWeightData(10, 40, true));
        }
    }
    tableViewer.getTable().setLayout(tlayout);
    tableViewer.getTable().addMouseListener(new MouseAdapter() {

        public void mouseDoubleClick(MouseEvent event) {
            int index = -1;
            if ((index = tableViewer.getTable().getSelectionIndex()) >= 0) {
                TableItem tableItem = tableViewer.getTable().getItem(index);
                String brokename = tableItem.getText(0).trim();
                ICubridNode input = null;
                for (ICubridNode node : cubridNode.getChildren()) {
                    if (node.getLabel().equalsIgnoreCase(brokename)) {
                        input = node;
                        break;
                    }
                }
                LayoutManager.getInstance().setCurrentSelectedNode(input);
                IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
                if (null == window) {
                    return;
                }
                IWorkbenchPage activePage = window.getActivePage();
                IViewPart viewPart = window.getActivePage().findView(BrokerStatusView.ID);
                if (null != viewPart) {
                    activePage.hideView(viewPart);
                }
                try {
                    activePage.showView(BrokerStatusView.ID);
                } catch (PartInitException e1) {
                    LOGGER.error(e1.getMessage(), e1);
                }
            }
        }
    });
    makeTableColumn();
    tableViewer.setContentProvider(new BrokersStatusContentProvider());
    ServerInfo serverInfo = cubridNode.getServer().getServerInfo();
    BrokersStatusLabelProvider brokersStatusLabelProvider = new BrokersStatusLabelProvider();
    brokersStatusLabelProvider.setServerInfo(serverInfo);
    tableViewer.setLabelProvider(brokersStatusLabelProvider);
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewPart(org.eclipse.ui.IViewPart) MouseEvent(org.eclipse.swt.events.MouseEvent) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) TableItem(org.eclipse.swt.widgets.TableItem) MouseAdapter(org.eclipse.swt.events.MouseAdapter) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) BrokerEnvStatusColumn(com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerEnvStatusColumn) BrokerTblColumnSetHelp(com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerTblColumnSetHelp) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) TableViewer(org.eclipse.jface.viewers.TableViewer) TableLayout(org.eclipse.jface.viewers.TableLayout)

Example 28 with PartInitException

use of org.eclipse.ui.PartInitException in project cubrid-manager by CUBRID.

the class QueryNewCustomAction method run.

/**
	 * @see org.eclipse.jface.action.Action#run()
	 */
public void run() {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        return;
    }
    Object[] selected = getSelectedObj();
    LoginQueryEditDialog dialog = new LoginQueryEditDialog(getShell());
    if (selected != null && selected.length == 1 && selected[0] instanceof ISchemaNode) {
        dialog.setSelServerName(((ISchemaNode) selected[0]).getServer().getServerName());
        dialog.setSelDatabaseName(((ISchemaNode) selected[0]).getDatabase().getName());
    } else if (selected != null && selected.length == 1 && selected[0] instanceof CubridServer) {
        dialog.setSelServerName(((CubridServer) selected[0]).getName());
    } else {
        dialog.setSelServerName(DatabaseNavigatorMenu.SELF_DATABASE_SELECTED_LABEL);
    }
    if (dialog.open() == IDialogConstants.OK_ID) {
        try {
            IEditorInput input = new QueryUnit();
            IEditorPart editor = window.getActivePage().openEditor(input, QueryEditorPart.ID);
            ((QueryEditorPart) editor).connect(DatabaseNavigatorMenu.SELF_DATABASE);
        } catch (PartInitException e) {
            LOGGER.error(e.getMessage());
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) QueryEditorPart(com.cubrid.common.ui.query.editor.QueryEditorPart) QueryUnit(com.cubrid.common.ui.query.editor.QueryUnit) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) LoginQueryEditDialog(com.cubrid.cubridmanager.ui.common.dialog.LoginQueryEditDialog) IEditorPart(org.eclipse.ui.IEditorPart) PartInitException(org.eclipse.ui.PartInitException) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) IEditorInput(org.eclipse.ui.IEditorInput)

Example 29 with PartInitException

use of org.eclipse.ui.PartInitException in project cubrid-manager by CUBRID.

the class BrokerConfigEditComposite method createCubridBrokerConfPropEditor.

/**
	 * Create property editor
	 *
	 * @param cubridBrokerConfTabFolder
	 */
public void createCubridBrokerConfPropEditor(CTabFolder cubridBrokerConfTabFolder) {
    final Composite comp = new Composite(cubridBrokerConfTabFolder, SWT.NONE);
    comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    comp.setLayout(new GridLayout(1, false));
    sourceCTabItem = new CTabItem(cubridBrokerConfTabFolder, SWT.NONE);
    sourceCTabItem.setText(Messages.cubridBrokerConfEditorCTabItemSource);
    final Composite editorComp = new Composite(comp, SWT.BORDER);
    editorComp.setLayoutData(new GridData(GridData.FILL_BOTH));
    final GridLayout gridLayout = createGridLayout(1, 0, 0);
    gridLayout.horizontalSpacing = 0;
    editorComp.setLayout(gridLayout);
    propEditor = new PropEditor();
    try {
        propEditor.init(editorPart.getEditorSite(), editorPart.getEditorInput());
    } catch (PartInitException e) {
        LOGGER.error(e.getMessage(), e);
    }
    propEditor.createPartControl(editorComp);
    propEditor.getDocument().addDocumentListener(new DocumentAdpater());
    sourceCTabItem.setControl(comp);
}
Also used : CommonUITool.createGridLayout(com.cubrid.common.ui.spi.util.CommonUITool.createGridLayout) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) PropEditor(com.cubrid.tool.editor.property.PropEditor) PartInitException(org.eclipse.ui.PartInitException) CTabItem(org.eclipse.swt.custom.CTabItem)

Example 30 with PartInitException

use of org.eclipse.ui.PartInitException in project cubrid-manager by CUBRID.

the class CubridProjectSiteAction method run.

public void run() {
    String url = CommonUITool.urlEncodeForSpaces(Messages.msgCubridProjectSiteUrl);
    try {
        IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
        IWebBrowser browser = support.getExternalBrowser();
        browser.openURL(new URL(url));
    } catch (PartInitException e) {
        LOGGER.error("Can not initialize web browser on the application.", e);
    } catch (MalformedURLException e) {
        LOGGER.error("The url {} is invalid.", url, e);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) IWorkbenchBrowserSupport(org.eclipse.ui.browser.IWorkbenchBrowserSupport) IWebBrowser(org.eclipse.ui.browser.IWebBrowser) PartInitException(org.eclipse.ui.PartInitException) URL(java.net.URL)

Aggregations

PartInitException (org.eclipse.ui.PartInitException)720 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)300 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)177 IFile (org.eclipse.core.resources.IFile)146 IEditorPart (org.eclipse.ui.IEditorPart)141 CoreException (org.eclipse.core.runtime.CoreException)94 FileEditorInput (org.eclipse.ui.part.FileEditorInput)88 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)82 IEditorInput (org.eclipse.ui.IEditorInput)74 ISelection (org.eclipse.jface.viewers.ISelection)62 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)60 IResource (org.eclipse.core.resources.IResource)59 IEditorReference (org.eclipse.ui.IEditorReference)53 IViewPart (org.eclipse.ui.IViewPart)53 IOException (java.io.IOException)42 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)41 Point (org.eclipse.swt.graphics.Point)40 IWorkbench (org.eclipse.ui.IWorkbench)40 Path (org.eclipse.core.runtime.Path)39 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)39