Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Dec 15, 2016
2 parents a74b9ae + 4bce609 commit e8f885c
Show file tree
Hide file tree
Showing 33 changed files with 1,503 additions and 1,354 deletions.
Expand Up @@ -243,23 +243,10 @@ private void testConnectionPerformed(AjaxRequestTarget target) {
saveChanges();

PageBase page = getPageBase();
ModelService model = page.getModelService();

OperationResult result = new OperationResult(TEST_CONNECTION);
List<OpResult> resultDtoList = new ArrayList<>();
try {
Task task = page.createSimpleTask(TEST_CONNECTION);
String oid = resourceModelNoFetch.getObject().getOid();
result = model.testResource(oid, task);
resultDtoList = WebComponentUtil.getTestConnectionResults(result, page);
} catch (ObjectNotFoundException ex) {
result.recordFatalError("Failed to test resource connection", ex);
}

TestConnectionResultPanel testConnectionPanel = new TestConnectionResultPanel(page.getMainPopupBodyId(), new ListModel<>(resultDtoList), getPage());
TestConnectionResultPanel testConnectionPanel = new TestConnectionResultPanel(page.getMainPopupBodyId(), resourceModelNoFetch.getObject().getOid(), getPage());
testConnectionPanel.setOutputMarkupId(true);
page.showMainPopup(testConnectionPanel, target);
page.showResult(result, "Test connection failed", false);
// page.showResult(result, "Test connection failed", false);
target.add(page.getFeedbackPanel());
target.add(getForm());
}
Expand Down
Expand Up @@ -68,7 +68,6 @@ public class PageResource extends PageAdminResources {

private static final String DOT_CLASS = PageResource.class.getName() + ".";

private static final String OPERATION_TEST_CONNECTION = DOT_CLASS + "testConnection";
private static final String OPERATION_LOAD_RESOURCE = DOT_CLASS + "loadResource";
private static final String OPERATION_REFRESH_SCHEMA = DOT_CLASS + "refreshSchema";

Expand Down Expand Up @@ -354,7 +353,7 @@ private void testConnectionPerformed(AjaxRequestTarget target) {

final TestConnectionResultPanel testConnectionPanel =
new TestConnectionResultPanel(getMainPopupBodyId(),
new ListModel<>(new ArrayList<OpResult>()), getPage(), true) {
dto.getOid(), getPage()) {

private static final long serialVersionUID = 1L;

Expand All @@ -363,38 +362,38 @@ protected void okPerformed(AjaxRequestTarget target) {
refreshStatus(target);
}

@Override
protected void initOnFocusBehavior() {
setOnFocusBehavior(new AjaxEventBehavior("focus") {

private static final long serialVersionUID = 1L;

@Override
protected void onEvent(AjaxRequestTarget target) {
removeOnFocusBehavior(getOkButton());
OperationResult result = new OperationResult(OPERATION_TEST_CONNECTION);
List<OpResult> resultsDto = new ArrayList<>();
try {
Task task = createSimpleTask(OPERATION_TEST_CONNECTION);
result = getModelService().testResource(dto.getOid(), task);
resultsDto = WebComponentUtil.getTestConnectionResults(result,(PageBase) getPage());

getModelService().getObject(ResourceType.class, dto.getOid(), null, task, result);
} catch (ObjectNotFoundException | SchemaException | SecurityViolationException
| CommunicationException | ConfigurationException e) {
result.recordFatalError("Failed to test resource connection", e);
}

if (result.isSuccess()) {
result.recomputeStatus();
}
setModelObject(resultsDto);
initResultsPanel((RepeatingView) getResultsComponent(), getPage());
setWaitForResults(false);
target.add(getContentPanel());
}
});
}
// @Override
// protected void initOnFocusBehavior() {
// setOnFocusBehavior(new AjaxEventBehavior("focus") {
//
// private static final long serialVersionUID = 1L;
//
// @Override
// protected void onEvent(AjaxRequestTarget target) {
// removeOnFocusBehavior(getOkButton());
// OperationResult result = new OperationResult(OPERATION_TEST_CONNECTION);
// List<OpResult> resultsDto = new ArrayList<>();
// try {
// Task task = createSimpleTask(OPERATION_TEST_CONNECTION);
// result = getModelService().testResource(dto.getOid(), task);
// resultsDto = WebComponentUtil.getTestConnectionResults(result,(PageBase) getPage());
//
// getModelService().getObject(ResourceType.class, dto.getOid(), null, task, result);
// } catch (ObjectNotFoundException | SchemaException | SecurityViolationException
// | CommunicationException | ConfigurationException e) {
// result.recordFatalError("Failed to test resource connection", e);
// }
//
// if (result.isSuccess()) {
// result.recomputeStatus();
// }
// setModelObject(resultsDto);
// initResultsPanel((RepeatingView) getResultsComponent(), getPage());
// setWaitForResults(false);
// target.add(getContentPanel());
// }
// });
// }
};
testConnectionPanel.setOutputMarkupId(true);

Expand All @@ -408,10 +407,10 @@ public boolean onCloseButtonClicked(AjaxRequestTarget target) {
});

showMainPopup(testConnectionPanel, target);
if (!testConnectionPanel.isFocusSet()) {
testConnectionPanel.setFocusSet(true);
testConnectionPanel.setFocusOnComponent(testConnectionPanel.getOkButton(), target);
}
// if (!testConnectionPanel.isFocusSet()) {
// testConnectionPanel.setFocusSet(true);
// testConnectionPanel.setFocusOnComponent(testConnectionPanel.getOkButton(), target);
// }

}

Expand Down
@@ -0,0 +1,28 @@
<!--
~ Copyright (c) 2010-2016 Evolveum
~
~ 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.
-->

<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<div class="box-body">
<diiv wicket:id="messagesPanel">
<div wicket:id="messages"/>

</diiv>

</div>
</wicket:panel>
</html>
@@ -0,0 +1,102 @@
/*
* Copyright (c) 2010-2016 Evolveum
*
* 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 com.evolveum.midpoint.web.page.admin.resources.component;

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.component.result.OpResult;
import com.evolveum.midpoint.gui.api.component.result.OperationResultPanel;
import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.exception.*;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType;
import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.Page;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.repeater.RepeatingView;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.util.ListModel;

import java.util.ArrayList;
import java.util.List;

/**
* Created by honchar.
*/
public class TestConnectionMessagesPanel extends BasePanel {
private static final String DOT_CLASS = TestConnectionMessagesPanel.class.getName() + ".";

private static final String OPERATION_TEST_CONNECTION = DOT_CLASS + "testConnection";

private static final String ID_MESSAGES_PANEL = "messagesPanel";
private static final String ID_MESSAGES = "messages";
private PageBase parentPage;
private ListModel<OpResult> model;

public TestConnectionMessagesPanel(String id, String resourceOid, PageBase parentPage) {
super(id);
this.parentPage = parentPage;
initResultsModel(resourceOid);
initLayout();
}

private void initResultsModel(String resourceOid) {
OperationResult result = new OperationResult(OPERATION_TEST_CONNECTION);
List<OpResult> resultsDto = new ArrayList<>();
if (StringUtils.isNotEmpty(resourceOid)) {
try {
Task task = parentPage.createSimpleTask(OPERATION_TEST_CONNECTION);
result = parentPage.getModelService().testResource(resourceOid, task);
resultsDto = WebComponentUtil.getTestConnectionResults(result, parentPage);
} catch (ObjectNotFoundException e) {
result.recordFatalError("Failed to test resource connection", e);
}

if (result.isSuccess()) {
result.recomputeStatus();
}
}
model = new ListModel<OpResult>(resultsDto);
}

private void initLayout() {
setOutputMarkupId(true);

WebMarkupContainer messagesPanel = new WebMarkupContainer(ID_MESSAGES_PANEL);
messagesPanel.setOutputMarkupId(true);
add(messagesPanel);

RepeatingView resultView = new RepeatingView(ID_MESSAGES);
if (model.getObject() != null && model.getObject().size() > 0) {
initResultsPanel(resultView, parentPage);
}
resultView.setOutputMarkupId(true);
messagesPanel.add(resultView);
}

public void initResultsPanel(RepeatingView resultView, Page parentPage) {
for (OpResult result : model.getObject()) {
OperationResultPanel resultPanel = new OperationResultPanel(resultView.newChildId(), new Model<>(result), parentPage);
resultPanel.setOutputMarkupId(true);
resultView.add(resultPanel);
}
}


}
Expand Up @@ -19,10 +19,12 @@
<wicket:panel>
<div class="box-body">
<diiv wicket:id="contentPanel">
<div wicket:id="message" />
<div wicket:id="result" />
<div wicket:id="message"/>
<div wicket:id="result"/>
<p align="center">
<a class="btn btn-sm btn-primary" wicket:id="ok"><wicket:message key="Button.ok"/></a>
<a class="btn btn-sm btn-primary" wicket:id="ok">
<wicket:message key="Button.ok"/>
</a>
</p>
</diiv>

Expand Down

0 comments on commit e8f885c

Please sign in to comment.