-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
* dbeaver/dbeaver-vscode#45 server feature extension * dbeaver/dbeaver-vscode#45 review fix --------- Co-authored-by: Alexey <[email protected]>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version='1.0' encoding='UTF-8'?> | ||
<schema targetNamespace="org.jkiss.dbeaver.core" xmlns="http://www.w3.org/2001/XMLSchema"> | ||
<annotation> | ||
<appInfo> | ||
<meta.schema plugin="io.cloudbeaver.model" id="io.cloudbeaver.server.feature" name="Web features"/> | ||
</appInfo> | ||
<documentation> | ||
Web feature | ||
</documentation> | ||
</annotation> | ||
|
||
<element name="extension"> | ||
<annotation> | ||
<appInfo> | ||
<meta.element /> | ||
</appInfo> | ||
</annotation> | ||
<complexType> | ||
<sequence> | ||
<element ref="feature"/> | ||
</sequence> | ||
</complexType> | ||
</element> | ||
|
||
<element name="feature"> | ||
<annotation> | ||
<documentation> | ||
Web service description | ||
</documentation> | ||
</annotation> | ||
</element> | ||
|
||
|
||
</schema> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* DBeaver - Universal Database Manager | ||
* Copyright (C) 2010-2024 DBeaver Corp and others | ||
* | ||
* 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 io.cloudbeaver.registry; | ||
|
||
import io.cloudbeaver.DBWFeatureSet; | ||
import io.cloudbeaver.utils.WebAppUtils; | ||
import org.eclipse.core.runtime.IConfigurationElement; | ||
import org.jkiss.code.NotNull; | ||
import org.jkiss.dbeaver.model.DBPImage; | ||
import org.jkiss.dbeaver.model.impl.AbstractContextDescriptor; | ||
|
||
/** | ||
* WebFeatureDescriptor | ||
*/ | ||
public class WebServerFeatureDescriptor extends AbstractContextDescriptor implements DBWFeatureSet { | ||
|
||
public static final String EXTENSION_ID = "io.cloudbeaver.server.feature"; //$NON-NLS-1$ | ||
|
||
private final String id; | ||
private final String label; | ||
private final String description; | ||
private final DBPImage icon; | ||
|
||
public WebServerFeatureDescriptor(IConfigurationElement config) | ||
{ | ||
Check warning on line 40 in server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/registry/WebServerFeatureDescriptor.java Jenkins-CI-integration / CheckStyle Java Reportserver/bundles/io.cloudbeaver.model/src/io/cloudbeaver/registry/WebServerFeatureDescriptor.java#L40
|
||
super(config); | ||
this.id = config.getAttribute("id"); | ||
this.label = config.getAttribute("label"); | ||
this.description = config.getAttribute("description"); | ||
this.icon = iconToImage(config.getAttribute("icon")); | ||
} | ||
|
||
@NotNull | ||
public String getId() { | ||
return id; | ||
} | ||
|
||
@NotNull | ||
public String getLabel() { | ||
return label; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
@Override | ||
public DBPImage getIcon() { | ||
return icon; | ||
} | ||
|
||
@Override | ||
public boolean isEnabled() { | ||
return true; | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* DBeaver - Universal Database Manager | ||
* Copyright (C) 2010-2024 DBeaver Corp and others | ||
* | ||
* 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 io.cloudbeaver.registry; | ||
|
||
import io.cloudbeaver.DBWFeatureSet; | ||
import org.eclipse.core.runtime.IConfigurationElement; | ||
import org.eclipse.core.runtime.IExtensionRegistry; | ||
import org.eclipse.core.runtime.Platform; | ||
import org.jkiss.dbeaver.Log; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class WebServerFeatureRegistry { | ||
|
||
private static final Log log = Log.getLog(WebServerFeatureRegistry.class); | ||
|
||
private static final String TAG_FEATURE = "feature"; //$NON-NLS-1$ | ||
|
||
private static WebServerFeatureRegistry instance = null; | ||
|
||
public synchronized static WebServerFeatureRegistry getInstance() { | ||
Check warning on line 36 in server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/registry/WebServerFeatureRegistry.java Jenkins-CI-integration / CheckStyle Java Reportserver/bundles/io.cloudbeaver.model/src/io/cloudbeaver/registry/WebServerFeatureRegistry.java#L36
Check warning on line 36 in server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/registry/WebServerFeatureRegistry.java Jenkins-CI-integration / CheckStyle Java Reportserver/bundles/io.cloudbeaver.model/src/io/cloudbeaver/registry/WebServerFeatureRegistry.java#L36
|
||
if (instance == null) { | ||
instance = new WebServerFeatureRegistry(); | ||
instance.loadExtensions(Platform.getExtensionRegistry()); | ||
} | ||
return instance; | ||
} | ||
|
||
private String[] serverFeatures = new String[0]; | ||
|
||
private WebServerFeatureRegistry() { | ||
} | ||
|
||
private synchronized void loadExtensions(IExtensionRegistry registry) { | ||
IConfigurationElement[] extConfigs = registry.getConfigurationElementsFor(WebServerFeatureDescriptor.EXTENSION_ID); | ||
List<DBWFeatureSet> features = new ArrayList<>(); | ||
for (IConfigurationElement ext : extConfigs) { | ||
if (TAG_FEATURE.equals(ext.getName())) { | ||
features.add( | ||
new WebServerFeatureDescriptor(ext)); | ||
} | ||
} | ||
this.serverFeatures = features | ||
.stream() | ||
.map(DBWFeatureSet::getId) | ||
.toArray(String[]::new); | ||
} | ||
|
||
public String[] getServerFeatures() { | ||
return serverFeatures; | ||
} | ||
|
||
} |