From 7fda56b9c6e7f0838c3fb27e1b380e861133f51c Mon Sep 17 00:00:00 2001 From: Serge Rider Date: Mon, 4 Feb 2019 20:14:25 +0300 Subject: [PATCH] #5191 Dashboard view, commands stubs Former-commit-id: 9045bcda975b57aac09c3dbd9544aa79e3e9c759 --- .../OSGI-INF/l10n/bundle.properties | 2 +- .../registry/DashboardDescriptor.java | 67 ++++++++++++++++ .../dashboard/registry/DashboardRegistry.java | 69 +++++++++++++++++ .../ui/dashboard/view/DashboardView.java | 76 +++++++++++++++++++ .../dashboard/view/HandlerDashboardOpen.java | 40 ++++++++++ 5 files changed, 253 insertions(+), 1 deletion(-) create mode 100644 plugins/org.jkiss.dbeaver.ui.dashboard/src/org/jkiss/dbeaver/ui/dashboard/registry/DashboardDescriptor.java create mode 100644 plugins/org.jkiss.dbeaver.ui.dashboard/src/org/jkiss/dbeaver/ui/dashboard/registry/DashboardRegistry.java create mode 100644 plugins/org.jkiss.dbeaver.ui.dashboard/src/org/jkiss/dbeaver/ui/dashboard/view/DashboardView.java create mode 100644 plugins/org.jkiss.dbeaver.ui.dashboard/src/org/jkiss/dbeaver/ui/dashboard/view/HandlerDashboardOpen.java diff --git a/plugins/org.jkiss.dbeaver.ui.dashboard/OSGI-INF/l10n/bundle.properties b/plugins/org.jkiss.dbeaver.ui.dashboard/OSGI-INF/l10n/bundle.properties index 3c29a8a519..996424cc65 100644 --- a/plugins/org.jkiss.dbeaver.ui.dashboard/OSGI-INF/l10n/bundle.properties +++ b/plugins/org.jkiss.dbeaver.ui.dashboard/OSGI-INF/l10n/bundle.properties @@ -3,7 +3,7 @@ Bundle-Name = DBeaver Dashboard UI extension-point.org.jkiss.dbeaver.dashboard.name = Dashboard -view.dashboard.title = Dashboard +view.dashboard.title = Database Dashboard wizard.org.jkiss.dbeaver.dashboard.new.dashboard.name = Dashboard wizard.org.jkiss.dbeaver.dashboard.new.dashboard.description = Create custom dashboard diff --git a/plugins/org.jkiss.dbeaver.ui.dashboard/src/org/jkiss/dbeaver/ui/dashboard/registry/DashboardDescriptor.java b/plugins/org.jkiss.dbeaver.ui.dashboard/src/org/jkiss/dbeaver/ui/dashboard/registry/DashboardDescriptor.java new file mode 100644 index 0000000000..fc22dd43d3 --- /dev/null +++ b/plugins/org.jkiss.dbeaver.ui.dashboard/src/org/jkiss/dbeaver/ui/dashboard/registry/DashboardDescriptor.java @@ -0,0 +1,67 @@ +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2019 Serge Rider (serge@jkiss.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jkiss.dbeaver.ui.dashboard.registry; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.jkiss.code.NotNull; +import org.jkiss.dbeaver.model.app.DBPPlatformLanguage; +import org.jkiss.dbeaver.model.impl.AbstractContextDescriptor; + +/** + * DashboardDescriptor + */ +public class DashboardDescriptor extends AbstractContextDescriptor implements DBPPlatformLanguage +{ + public static final String EXTENSION_ID = "org.jkiss.dbeaver.dashboard"; //$NON-NLS-1$ + + private final String id; + private final String label; + private final String description; + + public DashboardDescriptor( + IConfigurationElement config) + { + super(config); + + this.id = config.getAttribute("id"); + this.label = config.getAttribute("label"); + this.description = config.getAttribute("description"); + } + + @NotNull + @Override + public String getId() { + return id; + } + + @NotNull + @Override + public String getLabel() + { + return label; + } + + public String getDescription() + { + return description; + } + + @Override + public String toString() { + return id; + } +} diff --git a/plugins/org.jkiss.dbeaver.ui.dashboard/src/org/jkiss/dbeaver/ui/dashboard/registry/DashboardRegistry.java b/plugins/org.jkiss.dbeaver.ui.dashboard/src/org/jkiss/dbeaver/ui/dashboard/registry/DashboardRegistry.java new file mode 100644 index 0000000000..2b2cb51242 --- /dev/null +++ b/plugins/org.jkiss.dbeaver.ui.dashboard/src/org/jkiss/dbeaver/ui/dashboard/registry/DashboardRegistry.java @@ -0,0 +1,69 @@ +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2019 Serge Rider (serge@jkiss.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jkiss.dbeaver.ui.dashboard.registry; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.Platform; +import org.jkiss.dbeaver.model.DBPDataSourceContainer; + +import java.util.ArrayList; +import java.util.List; + +public class DashboardRegistry { + private static DashboardRegistry instance = null; + + public synchronized static DashboardRegistry getInstance() { + if (instance == null) { + instance = new DashboardRegistry(Platform.getExtensionRegistry()); + } + return instance; + } + + private final List descriptors = new ArrayList<>(); + + private DashboardRegistry(IExtensionRegistry registry) { + // Load data descriptors from external plugins + { + IConfigurationElement[] extElements = registry.getConfigurationElementsFor(DashboardDescriptor.EXTENSION_ID); + for (IConfigurationElement ext : extElements) { + DashboardDescriptor formatterDescriptor = new DashboardDescriptor(ext); + descriptors.add(formatterDescriptor); + } + } + } + + public List getAllDashboards() { + return descriptors; + } + + public DashboardDescriptor getDashboard(String id) { + for (DashboardDescriptor descriptor : descriptors) { + if (descriptor.getId().equals(id)) { + return descriptor; + } + } + return null; + } + + public List getDashboard(DBPDataSourceContainer dataSourceContainer) { + List result = new ArrayList<>(); + + return result; + } + +} diff --git a/plugins/org.jkiss.dbeaver.ui.dashboard/src/org/jkiss/dbeaver/ui/dashboard/view/DashboardView.java b/plugins/org.jkiss.dbeaver.ui.dashboard/src/org/jkiss/dbeaver/ui/dashboard/view/DashboardView.java new file mode 100644 index 0000000000..f2021f45e1 --- /dev/null +++ b/plugins/org.jkiss.dbeaver.ui.dashboard/src/org/jkiss/dbeaver/ui/dashboard/view/DashboardView.java @@ -0,0 +1,76 @@ +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2019 Serge Rider (serge@jkiss.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jkiss.dbeaver.ui.dashboard.view; + +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.IMemento; +import org.eclipse.ui.IViewSite; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.part.ViewPart; +import org.jkiss.dbeaver.model.DBPDataSourceContainer; +import org.jkiss.dbeaver.model.IDataSourceContainerProvider; +import org.jkiss.utils.CommonUtils; + +public class DashboardView extends ViewPart implements IDataSourceContainerProvider { + public static final String VIEW_ID = "org.jkiss.dbeaver.ui.dashboardView"; + + public DashboardView() + { + super(); + } + + @Override + public void createPartControl(Composite parent) + { + //UIUtils.setHelp(parent, IHelpContextIds.CTX_DATABASE_NAVIGATOR); + + String secondaryId = getViewSite().getSecondaryId(); + if (!CommonUtils.isEmpty(secondaryId)) { +/* + try { + DBNNode node = getNodeFromSecondaryId(secondaryId); + setPartName(node.getNodeName()); + setTitleImage(DBeaverIcons.getImage(node.getNodeIconDefault())); + } catch (DBException e) { + // ignore + } +*/ + } + } + + @Override + public void setFocus() { + + } + + @Override + public void init(IViewSite site) throws PartInitException { + super.init(site); + + } + + @Override + public void saveState(IMemento memento) { + super.saveState(memento); + } + + @Override + public DBPDataSourceContainer getDataSourceContainer() { + return null; + } + +} diff --git a/plugins/org.jkiss.dbeaver.ui.dashboard/src/org/jkiss/dbeaver/ui/dashboard/view/HandlerDashboardOpen.java b/plugins/org.jkiss.dbeaver.ui.dashboard/src/org/jkiss/dbeaver/ui/dashboard/view/HandlerDashboardOpen.java new file mode 100644 index 0000000000..1bea3cda5d --- /dev/null +++ b/plugins/org.jkiss.dbeaver.ui.dashboard/src/org/jkiss/dbeaver/ui/dashboard/view/HandlerDashboardOpen.java @@ -0,0 +1,40 @@ +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2019 Serge Rider (serge@jkiss.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jkiss.dbeaver.ui.dashboard.view; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.ui.commands.IElementUpdater; +import org.eclipse.ui.menus.UIElement; + +import java.util.Map; + +public class HandlerDashboardOpen extends AbstractHandler implements IElementUpdater { + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + return null; + } + + @Override + public void updateElement(UIElement element, Map parameters) + { + + } + +} \ No newline at end of file -- GitLab