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);
}
}
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);
}
}
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;
}
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;
}
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();
}
});
}
}
Aggregations