Search in sources :

Example 11 with IWorkbenchWindow

use of org.eclipse.ui.IWorkbenchWindow in project dbeaver by serge-rider.

the class RedoChangesHandler method updateElement.

@Override
public void updateElement(UIElement element, Map parameters) {
    IWorkbenchWindow workbenchWindow = element.getServiceLocator().getService(IWorkbenchWindow.class);
    if (workbenchWindow == null || workbenchWindow.getActivePage() == null) {
        return;
    }
    final IEditorPart activeEditor = workbenchWindow.getActivePage().getActiveEditor();
    if (activeEditor instanceof EntityEditor) {
        final DBECommandContext commandContext = ((EntityEditor) activeEditor).getCommandContext();
        String text = "Redo";
        if (commandContext != null && commandContext.getRedoCommand() != null) {
            text += " " + commandContext.getRedoCommand().getTitle();
        }
        element.setText(text);
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) DBECommandContext(org.jkiss.dbeaver.model.edit.DBECommandContext) EntityEditor(org.jkiss.dbeaver.ui.editors.entity.EntityEditor) IEditorPart(org.eclipse.ui.IEditorPart)

Example 12 with IWorkbenchWindow

use of org.eclipse.ui.IWorkbenchWindow in project dbeaver by serge-rider.

the class OpenHandler method openEditor.

private static void openEditor(ExecutionEvent event) throws ExecutionException, CoreException {
    List<DBPDataSourceContainer> containers = getDataSourceContainers(event);
    IWorkbenchWindow workbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
    IProject project = !containers.isEmpty() ? containers.get(0).getRegistry().getProject() : DBeaverCore.getInstance().getProjectRegistry().getActiveProject();
    checkProjectIsOpen(project);
    final DBPDataSourceContainer[] containerList = containers.toArray(new DBPDataSourceContainer[containers.size()]);
    final IFolder rootFolder = ResourceUtils.getScriptsFolder(project, true);
    final List<ResourceUtils.ResourceInfo> scriptTree = ResourceUtils.findScriptTree(rootFolder, containerList.length == 0 ? null : containerList);
    if (scriptTree.isEmpty() && containerList.length == 1) {
        // Create new script
        final IFile newScript = ResourceUtils.createNewScript(project, rootFolder, containers.isEmpty() ? null : containers.get(0));
        NavigatorHandlerObjectOpen.openResource(newScript, workbenchWindow);
    } else {
        // Show script chooser
        ScriptSelectorPanel selector = new ScriptSelectorPanel(workbenchWindow, containerList, rootFolder);
        selector.showTree(scriptTree);
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IFile(org.eclipse.core.resources.IFile) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer) IProject(org.eclipse.core.resources.IProject) IFolder(org.eclipse.core.resources.IFolder) ScriptSelectorPanel(org.jkiss.dbeaver.ui.controls.ScriptSelectorPanel)

Example 13 with IWorkbenchWindow

use of org.eclipse.ui.IWorkbenchWindow in project dbeaver by serge-rider.

the class OpenObjectConsoleHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow workbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
    DBPDataSourceContainer ds = null;
    List<DBSObject> selectedObjects = NavigatorUtils.getSelectedObjects(HandlerUtil.getCurrentSelection(event));
    List<DBSEntity> entities = new ArrayList<>();
    for (DBSObject object : selectedObjects) {
        if (object instanceof DBSEntity) {
            entities.add((DBSEntity) object);
            ds = object.getDataSource().getContainer();
        }
    }
    DBRRunnableWithResult<String> generator = GenerateSQLContributor.SELECT_GENERATOR(entities, true);
    DBeaverUI.runInUI(workbenchWindow, generator);
    String sql = generator.getResult();
    SQLEditor editor = OpenHandler.openSQLConsole(workbenchWindow, ds, "Query", sql);
    if (editor != null) {
        editor.processSQL(false, false);
    }
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) SQLEditor(org.jkiss.dbeaver.ui.editors.sql.SQLEditor) ArrayList(java.util.ArrayList) DBSEntity(org.jkiss.dbeaver.model.struct.DBSEntity) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer)

Example 14 with IWorkbenchWindow

use of org.eclipse.ui.IWorkbenchWindow in project dbeaver by serge-rider.

the class AboutBoxDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Color background = JFaceColors.getBannerBackground(parent.getDisplay());
    //Color foreground = JFaceColors.getBannerForeground(parent.getDisplay());
    parent.setBackground(background);
    Composite group = new Composite(parent, SWT.NONE);
    group.setBackground(background);
    GridLayout layout = new GridLayout(1, false);
    layout.marginHeight = 20;
    layout.marginWidth = 20;
    group.setLayout(layout);
    GridData gd;
    IProduct product = Platform.getProduct();
    {
        Label nameLabel = new Label(group, SWT.NONE);
        nameLabel.setBackground(background);
        nameLabel.setFont(NAME_FONT);
        nameLabel.setText(product.getName());
        gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.horizontalAlignment = GridData.CENTER;
        nameLabel.setLayoutData(gd);
    }
    Label titleLabel = new Label(group, SWT.NONE);
    titleLabel.setBackground(background);
    titleLabel.setFont(TITLE_FONT);
    titleLabel.setText(product.getProperty(PRODUCT_PROP_SUB_TITLE));
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.CENTER;
    titleLabel.setLayoutData(gd);
    titleLabel.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(MouseEvent e) {
            BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {

                @Override
                public void run() {
                    // Do not create InstallationDialog directly
                    // but execute "org.eclipse.ui.help.installationDialog" command
                    IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
                    IHandlerService service = workbenchWindow.getService(IHandlerService.class);
                    if (service != null) {
                        try {
                            //$NON-NLS-1$
                            service.executeCommand("org.eclipse.ui.help.installationDialog", null);
                        } catch (Exception e1) {
                        // just ignore error
                        }
                    }
                }
            });
        }
    });
    Label imageLabel = new Label(group, SWT.NONE);
    imageLabel.setBackground(background);
    gd = new GridData();
    gd.verticalAlignment = GridData.BEGINNING;
    gd.horizontalAlignment = GridData.CENTER;
    gd.grabExcessHorizontalSpace = true;
    imageLabel.setLayoutData(gd);
    imageLabel.setImage(ABOUT_IMAGE);
    Label versionLabel = new Label(group, SWT.NONE);
    versionLabel.setBackground(background);
    versionLabel.setText(CoreMessages.dialog_about_label_version + GeneralUtils.getProductVersion().toString());
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.CENTER;
    versionLabel.setLayoutData(gd);
    Label releaseTimeLabel = new Label(group, SWT.NONE);
    releaseTimeLabel.setBackground(background);
    releaseTimeLabel.setText(DateFormat.getDateInstance(DateFormat.LONG).format(GeneralUtils.getProductReleaseDate()));
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.CENTER;
    releaseTimeLabel.setLayoutData(gd);
    Label authorLabel = new Label(group, SWT.NONE);
    authorLabel.setBackground(background);
    authorLabel.setText(product.getProperty(PRODUCT_PROP_COPYRIGHT));
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.CENTER;
    authorLabel.setLayoutData(gd);
    Link siteLink = UIUtils.createLink(group, UIUtils.makeAnchor(product.getProperty(PRODUCT_PROP_WEBSITE)), new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            UIUtils.launchProgram(e.text);
        }
    });
    siteLink.setBackground(background);
    gd = new GridData();
    gd.horizontalAlignment = GridData.CENTER;
    siteLink.setLayoutData(gd);
    return parent;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) MouseEvent(org.eclipse.swt.events.MouseEvent) Color(org.eclipse.swt.graphics.Color) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MouseAdapter(org.eclipse.swt.events.MouseAdapter) GridLayout(org.eclipse.swt.layout.GridLayout) IHandlerService(org.eclipse.ui.handlers.IHandlerService) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IProduct(org.eclipse.core.runtime.IProduct)

Example 15 with IWorkbenchWindow

use of org.eclipse.ui.IWorkbenchWindow in project dbeaver by serge-rider.

the class ApplicationWorkbenchWindowAdvisor method postWindowOpen.

@Override
public void postWindowOpen() {
    log.debug("Finish initialization");
    super.postWindowOpen();
    if (DataSourceRegistry.getAllDataSources().isEmpty()) {
        // Open New Connection wizard
        DBeaverUI.asyncExec(new Runnable() {

            @Override
            public void run() {
                IWorkbenchWindow window = getWindowConfigurer().getWindow();
                CreateConnectionDialog dialog = new CreateConnectionDialog(window, new NewConnectionWizard());
                dialog.open();
            }
        });
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) NewConnectionWizard(org.jkiss.dbeaver.ui.dialogs.connection.NewConnectionWizard) CreateConnectionDialog(org.jkiss.dbeaver.ui.dialogs.connection.CreateConnectionDialog)

Aggregations

IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)284 IEditorPart (org.eclipse.ui.IEditorPart)114 PartInitException (org.eclipse.ui.PartInitException)70 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)68 QueryEditorPart (com.cubrid.common.ui.query.editor.QueryEditorPart)39 IViewPart (org.eclipse.ui.IViewPart)38 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)35 ArrayList (java.util.ArrayList)34 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)32 IEditorReference (org.eclipse.ui.IEditorReference)30 XLIFFEditorImplWithNatTable (net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable)27 ISelection (org.eclipse.jface.viewers.ISelection)25 XLFHandler (net.heartsome.cat.ts.core.file.XLFHandler)24 IFile (org.eclipse.core.resources.IFile)23 IWorkbench (org.eclipse.ui.IWorkbench)21 CoreException (org.eclipse.core.runtime.CoreException)20 QueryUnit (com.cubrid.common.ui.query.editor.QueryUnit)19 IProject (org.eclipse.core.resources.IProject)19 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)17 TreeViewer (org.eclipse.jface.viewers.TreeViewer)17