diff --git a/app/src/main/java/org/jboss/hal/client/ConsoleModule.java b/app/src/main/java/org/jboss/hal/client/ConsoleModule.java index 85513776c5..b9755ae606 100644 --- a/app/src/main/java/org/jboss/hal/client/ConsoleModule.java +++ b/app/src/main/java/org/jboss/hal/client/ConsoleModule.java @@ -316,6 +316,11 @@ protected void configure() { org.jboss.hal.client.runtime.subsystem.datasource.DataSourceView.class, org.jboss.hal.client.runtime.subsystem.datasource.DataSourcePresenter.MyProxy.class); + bindPresenter(org.jboss.hal.client.runtime.subsystem.datasource.DataSourceXAPresenter.class, + org.jboss.hal.client.runtime.subsystem.datasource.DataSourceXAPresenter.MyView.class, + org.jboss.hal.client.runtime.subsystem.datasource.DataSourceXAView.class, + org.jboss.hal.client.runtime.subsystem.datasource.DataSourceXAPresenter.MyProxy.class); + bindPresenter(org.jboss.hal.client.deployment.DeploymentPresenter.class, org.jboss.hal.client.deployment.DeploymentPresenter.MyView.class, org.jboss.hal.client.deployment.DeploymentView.class, diff --git a/app/src/main/java/org/jboss/hal/client/runtime/subsystem/datasource/DataSourceColumn.java b/app/src/main/java/org/jboss/hal/client/runtime/subsystem/datasource/DataSourceColumn.java index 99fe0ac0bf..66f6f7954f 100644 --- a/app/src/main/java/org/jboss/hal/client/runtime/subsystem/datasource/DataSourceColumn.java +++ b/app/src/main/java/org/jboss/hal/client/runtime/subsystem/datasource/DataSourceColumn.java @@ -59,7 +59,6 @@ import static java.util.stream.Collectors.toList; import static org.jboss.gwt.elemento.core.Elements.span; import static org.jboss.hal.client.runtime.subsystem.datasource.AddressTemplates.*; -import static org.jboss.hal.client.runtime.subsystem.datasource.DataSourcePresenter.XA_PARAM; import static org.jboss.hal.core.finder.FinderColumn.RefreshMode.RESTORE_SELECTION; import static org.jboss.hal.dmr.ModelDescriptionConstants.*; import static org.jboss.hal.meta.StatementContext.Expression.SELECTED_HOST; @@ -277,11 +276,17 @@ public List> actions() { List> actions = new ArrayList<>(); if (dataSource.isEnabled()) { if (!dataSource.fromDeployment() && dataSource.isStatisticsEnabled()) { - PlaceRequest placeRequest = places.selectedServer(NameTokens.DATA_SOURCE_RUNTIME) - .with(NAME, dataSource.getName()) - .with(XA_PARAM, String.valueOf(dataSource.isXa())) - .build(); - actions.add(itemActionFactory.view(placeRequest)); + if (dataSource.isXa()) { + PlaceRequest placeRequest = places.selectedServer(NameTokens.DATA_SOURCE_XA_RUNTIME) + .with(NAME, dataSource.getName()) + .build(); + actions.add(itemActionFactory.view(placeRequest)); + } else { + PlaceRequest placeRequest = places.selectedServer(NameTokens.DATA_SOURCE_RUNTIME) + .with(NAME, dataSource.getName()) + .build(); + actions.add(itemActionFactory.view(placeRequest)); + } } actions.add(new ItemAction.Builder().title(resources.constants().test()) .handler(item -> testConnection(item)) diff --git a/app/src/main/java/org/jboss/hal/client/runtime/subsystem/datasource/DataSourcePresenter.java b/app/src/main/java/org/jboss/hal/client/runtime/subsystem/datasource/DataSourcePresenter.java index f7e7ab3ded..127f6b361c 100644 --- a/app/src/main/java/org/jboss/hal/client/runtime/subsystem/datasource/DataSourcePresenter.java +++ b/app/src/main/java/org/jboss/hal/client/runtime/subsystem/datasource/DataSourcePresenter.java @@ -40,20 +40,16 @@ import static org.jboss.hal.client.runtime.subsystem.datasource.AddressTemplates.*; import static org.jboss.hal.dmr.ModelDescriptionConstants.*; -import static org.jboss.hal.meta.AddressTemplate.OPTIONAL; import static org.jboss.hal.meta.token.NameTokens.DATA_SOURCE_RUNTIME; public class DataSourcePresenter extends ApplicationFinderPresenter { - static final String XA_PARAM = "xa"; - private final FinderPathFactory finderPathFactory; private final Dispatcher dispatcher; private final StatementContext statementContext; private final Resources resources; private String name; - private boolean xa; @Inject public DataSourcePresenter(EventBus eventBus, @@ -81,7 +77,6 @@ protected void onBind() { public void prepareFromRequest(PlaceRequest request) { super.prepareFromRequest(request); name = request.getParameter(NAME, null); - xa = Boolean.valueOf(request.getParameter(XA_PARAM, String.valueOf(false))); getView().setup(); } @@ -89,37 +84,30 @@ public void prepareFromRequest(PlaceRequest request) { public FinderPath finderPath() { return finderPathFactory.runtimeServerPath() .append(Ids.RUNTIME_SUBSYSTEM, DATASOURCES, resources.constants().monitor(), Names.DATASOURCES) - .append(Ids.DATA_SOURCE_RUNTIME, Ids.dataSourceRuntime(name, xa), Names.DATASOURCE, name); + .append(Ids.DATA_SOURCE_RUNTIME, Ids.dataSourceRuntime(name, false), Names.DATASOURCE, name); } @Override protected void reload() { - ResourceAddress address = xa ? XA_DATA_SOURCE_TEMPLATE.resolve(statementContext, name) : DATA_SOURCE_TEMPLATE - .resolve(statementContext, name); + ResourceAddress address = DATA_SOURCE_TEMPLATE.resolve(statementContext, name); Operation operation = new Operation.Builder(address, READ_RESOURCE_OPERATION) .param(INCLUDE_RUNTIME, true) .param(RECURSIVE, true) .build(); - dispatcher.execute(operation, result -> getView().update(new DataSource(name, result, xa))); + dispatcher.execute(operation, result -> getView().update(new DataSource(name, result, false))); } String getDataSource() { return name; } - boolean isXa() { - return xa; - } - // @formatter:off @ProxyCodeSplit @NameToken(DATA_SOURCE_RUNTIME) @Requires({DATA_SOURCE_ADDRESS, XA_DATA_SOURCE_ADDRESS, - OPTIONAL + DATA_SOURCE_POOL_ADDRESS, - OPTIONAL + DATA_SOURCE_JDBC_ADDRESS, - OPTIONAL + XA_DATA_SOURCE_POOL_ADDRESS, - OPTIONAL + XA_DATA_SOURCE_JDBC_ADDRESS}) + DATA_SOURCE_POOL_ADDRESS, + DATA_SOURCE_JDBC_ADDRESS}) public interface MyProxy extends ProxyPlace { } diff --git a/app/src/main/java/org/jboss/hal/client/runtime/subsystem/datasource/DataSourceView.java b/app/src/main/java/org/jboss/hal/client/runtime/subsystem/datasource/DataSourceView.java index a38c131efd..ebb50713f9 100644 --- a/app/src/main/java/org/jboss/hal/client/runtime/subsystem/datasource/DataSourceView.java +++ b/app/src/main/java/org/jboss/hal/client/runtime/subsystem/datasource/DataSourceView.java @@ -18,7 +18,6 @@ import javax.inject.Inject; import elemental2.dom.HTMLElement; -import org.jboss.gwt.elemento.core.Elements; import org.jboss.hal.ballroom.Tabs; import org.jboss.hal.ballroom.form.Form; import org.jboss.hal.core.datasource.DataSource; @@ -41,8 +40,6 @@ import static org.jboss.hal.ballroom.LayoutBuilder.row; import static org.jboss.hal.client.runtime.subsystem.datasource.AddressTemplates.DATA_SOURCE_JDBC_TEMPLATE; import static org.jboss.hal.client.runtime.subsystem.datasource.AddressTemplates.DATA_SOURCE_POOL_TEMPLATE; -import static org.jboss.hal.client.runtime.subsystem.datasource.AddressTemplates.XA_DATA_SOURCE_JDBC_TEMPLATE; -import static org.jboss.hal.client.runtime.subsystem.datasource.AddressTemplates.XA_DATA_SOURCE_POOL_TEMPLATE; import static org.jboss.hal.dmr.ModelDescriptionConstants.STATISTICS_ENABLED; import static org.jboss.hal.dmr.ModelNodeHelper.failSafeGet; import static org.jboss.hal.resources.CSS.*; @@ -86,45 +83,27 @@ public class DataSourceView extends HalViewImpl implements DataSourcePresenter.M private final Resources resources; private DataSourcePresenter presenter; private HTMLElement header; - private Tabs nonXaTabs; - private Tabs xaTabs; private Form poolForm; - private Form xaPoolForm; private Form jdbcForm; - private Form xaJdbcForm; - private boolean setup; @Inject public DataSourceView(MetadataRegistry metadataRegistry, Resources resources) { this.metadataRegistry = metadataRegistry; this.resources = resources; - this.setup = false; } @Override public void setup() { - if (setup) { - return; - } - // The metadata for the "statistic" resources is only available fro existing data-sources. // That's why we cannot setup the UI in the constructor like in other views and // using wildcards in the address templates. As a workaround we defer the UI setup // until the DS name is known and replace the wildcards with the DS name. Metadata poolMeta; Metadata jdbcMeta; - if (presenter.isXa()) { - poolMeta = metadataRegistry.lookup( - XA_DATA_SOURCE_POOL_TEMPLATE.replaceWildcards(presenter.getDataSource())); - jdbcMeta = metadataRegistry.lookup( - XA_DATA_SOURCE_JDBC_TEMPLATE.replaceWildcards(presenter.getDataSource())); - } else { - poolMeta = metadataRegistry.lookup(DATA_SOURCE_POOL_TEMPLATE.replaceWildcards(presenter.getDataSource())); - jdbcMeta = metadataRegistry.lookup(DATA_SOURCE_JDBC_TEMPLATE.replaceWildcards(presenter.getDataSource())); - } + poolMeta = metadataRegistry.lookup(DATA_SOURCE_POOL_TEMPLATE.replaceWildcards(presenter.getDataSource())); + jdbcMeta = metadataRegistry.lookup(DATA_SOURCE_JDBC_TEMPLATE.replaceWildcards(presenter.getDataSource())); - nonXaTabs = new Tabs(Ids.DATA_SOURCE_RUNTIME_TAB_CONTAINER); - xaTabs = new Tabs(Ids.XA_DATA_SOURCE_RUNTIME_TAB_CONTAINER); + Tabs tabs = new Tabs(Ids.DATA_SOURCE_RUNTIME_TAB_CONTAINER); poolForm = new ModelNodeForm.Builder<>(Ids.DATA_SOURCE_RUNTIME_POOL_FORM, poolMeta) .readOnly() @@ -132,28 +111,14 @@ public void setup() { .exclude(STATISTICS_ENABLED) .exclude(XA_ATTRIBUTES) .build(); - nonXaTabs.add(Ids.DATA_SOURCE_RUNTIME_POOL_TAB, Names.POOL, poolForm.element()); - - xaPoolForm = new ModelNodeForm.Builder<>(Ids.XA_DATA_SOURCE_RUNTIME_POOL_FORM, poolMeta) - .readOnly() - .includeRuntime() - .exclude(STATISTICS_ENABLED) - .build(); - xaTabs.add(Ids.XA_DATA_SOURCE_RUNTIME_POOL_TAB, Names.POOL, xaPoolForm.element()); + tabs.add(Ids.DATA_SOURCE_RUNTIME_POOL_TAB, Names.POOL, poolForm.element()); jdbcForm = new ModelNodeForm.Builder<>(Ids.DATA_SOURCE_RUNTIME_JDBC_FORM, jdbcMeta) .readOnly() .includeRuntime() .exclude(STATISTICS_ENABLED) .build(); - nonXaTabs.add(Ids.DATA_SOURCE_RUNTIME_JDBC_TAB, Names.JDBC, jdbcForm.element()); - - xaJdbcForm = new ModelNodeForm.Builder<>(Ids.XA_DATA_SOURCE_RUNTIME_JDBC_FORM, jdbcMeta) - .readOnly() - .includeRuntime() - .exclude(STATISTICS_ENABLED) - .build(); - xaTabs.add(Ids.XA_DATA_SOURCE_RUNTIME_JDBC_TAB, Names.JDBC, xaJdbcForm.element()); + tabs.add(Ids.DATA_SOURCE_RUNTIME_JDBC_TAB, Names.JDBC, jdbcForm.element()); HTMLElement root = row() .add(column() @@ -162,12 +127,11 @@ public void setup() { .add(a().css(clickable, pullRight).on(click, event -> refresh()) .add(span().css(fontAwesome("refresh"), marginRight5)) .add(span().textContent(resources.constants().refresh())))) - .add(nonXaTabs) - .add(xaTabs)).element(); + .add(tabs)) + .element(); - registerAttachables(asList(poolForm, xaPoolForm, jdbcForm, xaJdbcForm)); + registerAttachables(asList(poolForm, jdbcForm)); initElement(root); - setup = true; } @Override @@ -177,20 +141,9 @@ public void setPresenter(DataSourcePresenter presenter) { @Override public void update(DataSource dataSource) { - showHide(dataSource.isXa()); header.textContent = dataSource.getName(); - if (dataSource.isXa()) { - xaPoolForm.view(failSafeGet(dataSource, POOL_PATH)); - xaJdbcForm.view(failSafeGet(dataSource, JDBC_PATH)); - } else { - poolForm.view(failSafeGet(dataSource, POOL_PATH)); - jdbcForm.view(failSafeGet(dataSource, JDBC_PATH)); - } - } - - private void showHide(boolean xa) { - Elements.setVisible(nonXaTabs.element(), !xa); - Elements.setVisible(xaTabs.element(), xa); + poolForm.view(failSafeGet(dataSource, POOL_PATH)); + jdbcForm.view(failSafeGet(dataSource, JDBC_PATH)); } private void refresh() { diff --git a/app/src/main/java/org/jboss/hal/client/runtime/subsystem/datasource/DataSourceXAPresenter.java b/app/src/main/java/org/jboss/hal/client/runtime/subsystem/datasource/DataSourceXAPresenter.java new file mode 100644 index 0000000000..7892fcbcbd --- /dev/null +++ b/app/src/main/java/org/jboss/hal/client/runtime/subsystem/datasource/DataSourceXAPresenter.java @@ -0,0 +1,126 @@ +/* + * Copyright 2022 Red Hat + * + * 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 + * + * https://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.jboss.hal.client.runtime.subsystem.datasource; + +import javax.inject.Inject; +import org.jboss.hal.core.datasource.DataSource; +import org.jboss.hal.core.finder.Finder; +import org.jboss.hal.core.finder.FinderPath; +import org.jboss.hal.core.finder.FinderPathFactory; +import org.jboss.hal.core.mvp.ApplicationFinderPresenter; +import org.jboss.hal.core.mvp.HalView; +import org.jboss.hal.core.mvp.HasPresenter; +import org.jboss.hal.dmr.Operation; +import org.jboss.hal.dmr.ResourceAddress; +import org.jboss.hal.dmr.dispatch.Dispatcher; +import org.jboss.hal.meta.StatementContext; +import org.jboss.hal.resources.Ids; +import org.jboss.hal.resources.Names; +import org.jboss.hal.resources.Resources; +import org.jboss.hal.spi.Requires; +import com.google.web.bindery.event.shared.EventBus; +import com.gwtplatform.mvp.client.annotations.NameToken; +import com.gwtplatform.mvp.client.annotations.ProxyCodeSplit; +import com.gwtplatform.mvp.client.proxy.ProxyPlace; +import com.gwtplatform.mvp.shared.proxy.PlaceRequest; + +import static org.jboss.hal.client.runtime.subsystem.datasource.AddressTemplates.DATA_SOURCE_ADDRESS; +import static org.jboss.hal.client.runtime.subsystem.datasource.AddressTemplates.XA_DATA_SOURCE_ADDRESS; +import static org.jboss.hal.client.runtime.subsystem.datasource.AddressTemplates.XA_DATA_SOURCE_JDBC_ADDRESS; +import static org.jboss.hal.client.runtime.subsystem.datasource.AddressTemplates.XA_DATA_SOURCE_POOL_ADDRESS; +import static org.jboss.hal.client.runtime.subsystem.datasource.AddressTemplates.XA_DATA_SOURCE_TEMPLATE; +import static org.jboss.hal.dmr.ModelDescriptionConstants.DATASOURCES; +import static org.jboss.hal.dmr.ModelDescriptionConstants.INCLUDE_RUNTIME; +import static org.jboss.hal.dmr.ModelDescriptionConstants.NAME; +import static org.jboss.hal.dmr.ModelDescriptionConstants.READ_RESOURCE_OPERATION; +import static org.jboss.hal.dmr.ModelDescriptionConstants.RECURSIVE; +import static org.jboss.hal.meta.token.NameTokens.DATA_SOURCE_XA_RUNTIME; + +public class DataSourceXAPresenter + extends ApplicationFinderPresenter { + + private final FinderPathFactory finderPathFactory; + private final Dispatcher dispatcher; + private final StatementContext statementContext; + private final Resources resources; + private String name; + + @Inject + public DataSourceXAPresenter(EventBus eventBus, + MyView view, + MyProxy myProxy, + Finder finder, + FinderPathFactory finderPathFactory, + Dispatcher dispatcher, + StatementContext statementContext, + Resources resources) { + super(eventBus, view, myProxy, finder); + this.finderPathFactory = finderPathFactory; + this.dispatcher = dispatcher; + this.statementContext = statementContext; + this.resources = resources; + } + + @Override + protected void onBind() { + super.onBind(); + getView().setPresenter(this); + } + + @Override + public void prepareFromRequest(PlaceRequest request) { + super.prepareFromRequest(request); + name = request.getParameter(NAME, null); + getView().setup(); + } + + @Override + public FinderPath finderPath() { + return finderPathFactory.runtimeServerPath() + .append(Ids.RUNTIME_SUBSYSTEM, DATASOURCES, resources.constants().monitor(), Names.DATASOURCES) + .append(Ids.DATA_SOURCE_RUNTIME, Ids.dataSourceRuntime(name, true), Names.DATASOURCE, name); + } + + @Override + protected void reload() { + ResourceAddress address = XA_DATA_SOURCE_TEMPLATE.resolve(statementContext, name); + Operation operation = new Operation.Builder(address, READ_RESOURCE_OPERATION) + .param(INCLUDE_RUNTIME, true) + .param(RECURSIVE, true) + .build(); + dispatcher.execute(operation, result -> getView().update(new DataSource(name, result, true))); + } + + String getDataSource() { + return name; + } + + // @formatter:off + @ProxyCodeSplit + @NameToken(DATA_SOURCE_XA_RUNTIME) + @Requires({ DATA_SOURCE_ADDRESS, XA_DATA_SOURCE_ADDRESS, + XA_DATA_SOURCE_POOL_ADDRESS, + XA_DATA_SOURCE_JDBC_ADDRESS }) + public interface MyProxy extends ProxyPlace { + } + + public interface MyView extends HalView, HasPresenter { + void setup(); + + void update(DataSource dataSource); + } + // @formatter:on +} diff --git a/app/src/main/java/org/jboss/hal/client/runtime/subsystem/datasource/DataSourceXAView.java b/app/src/main/java/org/jboss/hal/client/runtime/subsystem/datasource/DataSourceXAView.java new file mode 100644 index 0000000000..35c915fa2e --- /dev/null +++ b/app/src/main/java/org/jboss/hal/client/runtime/subsystem/datasource/DataSourceXAView.java @@ -0,0 +1,127 @@ +/* + * Copyright 2022 Red Hat + * + * 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 + * + * https://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.jboss.hal.client.runtime.subsystem.datasource; + +import javax.inject.Inject; +import org.jboss.hal.ballroom.Tabs; +import org.jboss.hal.ballroom.form.Form; +import org.jboss.hal.core.datasource.DataSource; +import org.jboss.hal.core.mbui.form.ModelNodeForm; +import org.jboss.hal.core.mvp.HalViewImpl; +import org.jboss.hal.dmr.ModelNode; +import org.jboss.hal.meta.Metadata; +import org.jboss.hal.meta.MetadataRegistry; +import org.jboss.hal.resources.Ids; +import org.jboss.hal.resources.Names; +import org.jboss.hal.resources.Resources; + +import elemental2.dom.HTMLElement; + +import static java.util.Arrays.asList; +import static org.jboss.gwt.elemento.core.Elements.a; +import static org.jboss.gwt.elemento.core.Elements.h; +import static org.jboss.gwt.elemento.core.Elements.p; +import static org.jboss.gwt.elemento.core.Elements.span; +import static org.jboss.gwt.elemento.core.EventType.click; +import static org.jboss.hal.ballroom.LayoutBuilder.column; +import static org.jboss.hal.ballroom.LayoutBuilder.row; +import static org.jboss.hal.client.runtime.subsystem.datasource.AddressTemplates.XA_DATA_SOURCE_JDBC_TEMPLATE; +import static org.jboss.hal.client.runtime.subsystem.datasource.AddressTemplates.XA_DATA_SOURCE_POOL_TEMPLATE; +import static org.jboss.hal.dmr.ModelDescriptionConstants.STATISTICS_ENABLED; +import static org.jboss.hal.dmr.ModelNodeHelper.failSafeGet; +import static org.jboss.hal.resources.CSS.clearfix; +import static org.jboss.hal.resources.CSS.clickable; +import static org.jboss.hal.resources.CSS.fontAwesome; +import static org.jboss.hal.resources.CSS.marginRight5; +import static org.jboss.hal.resources.CSS.pullRight; + +public class DataSourceXAView extends HalViewImpl implements DataSourceXAPresenter.MyView { + + private static final String POOL_PATH = "statistics/pool"; + private static final String JDBC_PATH = "statistics/jdbc"; + + private final MetadataRegistry metadataRegistry; + private final Resources resources; + private DataSourceXAPresenter presenter; + private HTMLElement header; + private Form poolForm; + private Form jdbcForm; + + @Inject + public DataSourceXAView(MetadataRegistry metadataRegistry, Resources resources) { + this.metadataRegistry = metadataRegistry; + this.resources = resources; + } + + @Override + public void setup() { + // The metadata for the "statistic" resources is only available for existing data-sources. + // That's why we cannot set up the UI in the constructor like in other views and + // using wildcards in the address templates. As a workaround we defer the UI setup + // until the DS name is known and replace the wildcards with the DS name. + Metadata poolMeta; + Metadata jdbcMeta; + poolMeta = metadataRegistry.lookup(XA_DATA_SOURCE_POOL_TEMPLATE.replaceWildcards(presenter.getDataSource())); + jdbcMeta = metadataRegistry.lookup(XA_DATA_SOURCE_JDBC_TEMPLATE.replaceWildcards(presenter.getDataSource())); + + Tabs tabs = new Tabs(Ids.XA_DATA_SOURCE_RUNTIME_TAB_CONTAINER); + + poolForm = new ModelNodeForm.Builder<>(Ids.XA_DATA_SOURCE_RUNTIME_POOL_FORM, poolMeta) + .readOnly() + .includeRuntime() + .exclude(STATISTICS_ENABLED) + .build(); + tabs.add(Ids.XA_DATA_SOURCE_RUNTIME_POOL_TAB, Names.POOL, poolForm.element()); + + jdbcForm = new ModelNodeForm.Builder<>(Ids.XA_DATA_SOURCE_RUNTIME_JDBC_FORM, jdbcMeta) + .readOnly() + .includeRuntime() + .exclude(STATISTICS_ENABLED) + .build(); + tabs.add(Ids.XA_DATA_SOURCE_RUNTIME_JDBC_TAB, Names.JDBC, jdbcForm.element()); + + HTMLElement root = row() + .add(column() + .add(header = h(1).textContent(Names.DATASOURCE).element()) + .add(p().css(clearfix) + .add(a().css(clickable, pullRight).on(click, event -> refresh()) + .add(span().css(fontAwesome("refresh"), marginRight5)) + .add(span().textContent(resources.constants().refresh())))) + .add(tabs)) + .element(); + + registerAttachables(asList(poolForm, jdbcForm)); + initElement(root); + } + + @Override + public void setPresenter(DataSourceXAPresenter presenter) { + this.presenter = presenter; + } + + @Override + public void update(DataSource dataSource) { + header.textContent = dataSource.getName(); + poolForm.view(failSafeGet(dataSource, POOL_PATH)); + jdbcForm.view(failSafeGet(dataSource, JDBC_PATH)); + } + + private void refresh() { + if (presenter != null) { + presenter.reload(); + } + } +} diff --git a/meta/src/main/java/org/jboss/hal/meta/token/NameTokens.java b/meta/src/main/java/org/jboss/hal/meta/token/NameTokens.java index a1e0fcd8c3..2044cec292 100644 --- a/meta/src/main/java/org/jboss/hal/meta/token/NameTokens.java +++ b/meta/src/main/java/org/jboss/hal/meta/token/NameTokens.java @@ -36,6 +36,7 @@ public interface NameTokens { String CORE_MANAGEMENT = "core-management"; String DATA_SOURCE_CONFIGURATION = ModelDescriptionConstants.DATA_SOURCE + CONFIGURATION_SUFFIX; String DATA_SOURCE_RUNTIME = ModelDescriptionConstants.DATA_SOURCE + RUNTIME_SUFFIX; + String DATA_SOURCE_XA_RUNTIME = ModelDescriptionConstants.DATA_SOURCE + "-xa" + RUNTIME_SUFFIX; String DEPLOYMENT_SCANNERS = ModelDescriptionConstants.DEPLOYMENT_SCANNER; String DEPLOYMENT = "deployment"; String DEPLOYMENTS = "deployments";