Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Oct 21, 2014
2 parents e0f4489 + 21e3f4d commit 6685fa2
Show file tree
Hide file tree
Showing 23 changed files with 498 additions and 41 deletions.
Expand Up @@ -43,7 +43,17 @@ protected List<WizardStepDto> load() {
return loadSteps();
}
};
WizardSteps steps = new WizardSteps(ID_STEPS, stepsModel);
WizardSteps steps = new WizardSteps(ID_STEPS, stepsModel){

@Override
public IWizardStep getActiveStep() {
if(Wizard.this.getModel() != null && Wizard.this.getModel().getObject() != null){
return Wizard.this.getModel().getObject().getActiveStep();
}

return null;
}
};
form.add(steps);

WebMarkupContainer header = new WebMarkupContainer(ID_HEADER);
Expand Down Expand Up @@ -111,6 +121,7 @@ public void onActiveStepChanged(IWizardStep newStep) {
WizardSteps steps = (WizardSteps) get(createComponentPath(ID_FORM, ID_STEPS));
IModel<List<WizardStepDto>> stepsModel = steps.getModel();
stepsModel.getObject().get(index).setActive(true);
steps.updateModal();
}

@Override
Expand All @@ -129,4 +140,6 @@ public void onFinish() {
}
}
}


}
Expand Up @@ -17,8 +17,11 @@
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<div wicket:id="helpModal" />

<div class="wizard">
<a wicket:id="link"><span wicket:id="label"/></a>
<button wicket:id="help" style="float: right" class="btn btn-sm btn-primary"><span style="font-size: 1.5em" class="glyphicon glyphicon-question-sign"></span></button>
</div>
</wicket:panel>
</html>
Expand Up @@ -18,7 +18,13 @@

import com.evolveum.midpoint.web.component.util.SimplePanel;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.web.component.wizard.resource.component.WizardHelpDialog;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.ajax.AjaxEventBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
import org.apache.wicket.extensions.wizard.IWizardStep;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
Expand All @@ -35,6 +41,8 @@ public class WizardSteps extends SimplePanel<List<WizardStepDto>> {

private static final String ID_LINK = "link";
private static final String ID_LABEL = "label";
private static final String ID_BUTTON_HELP = "help";
private static final String ID_HELP_MODAL = "helpModal";

public WizardSteps(String id, IModel<List<WizardStepDto>> model) {
super(id, model);
Expand All @@ -48,14 +56,14 @@ protected void initLayout() {
protected void populateItem(ListItem<WizardStepDto> item) {
final WizardStepDto dto = item.getModelObject();
Label label = new Label(ID_LABEL, createLabelModel(dto.getName()));
label.setRenderBodyOnly(true);
item.add(label);

item.add(new VisibleEnableBehaviour() {

@Override
public boolean isEnabled() {
return dto.isEnabled();
// return dto.isEnabled();
return true;
}

@Override
Expand All @@ -64,16 +72,50 @@ public boolean isVisible() {
}
});


item.add(AttributeModifier.replace("class", new AbstractReadOnlyModel<String>() {

@Override
public String getObject() {
return dto.isActive() ? "current" : null;
}
}));

item.add(new AjaxEventBehavior("onclick") {

@Override
protected void onEvent(AjaxRequestTarget target) {
changeStepPerformed(target, dto);
}
});
}
};
add(link);

AjaxLink help = new AjaxLink(ID_BUTTON_HELP) {

@Override
public void onClick(AjaxRequestTarget target) {
showHelpPerformed(target);
}
};
add(help);

initModals();
}

private void initModals(){
ModalWindow helpWindow = new WizardHelpDialog(ID_HELP_MODAL, getActiveStep());
add(helpWindow);
}

public void updateModal(){
WizardHelpDialog window = (WizardHelpDialog)get(ID_HELP_MODAL);

if(window != null){
AjaxRequestTarget target = getRequestCycle().find(AjaxRequestTarget.class);
window.updateModal(target ,getActiveStep());
}
}

private IModel<String> createLabelModel(final String key) {
Expand All @@ -85,4 +127,15 @@ public String getObject() {
}
};
}

public void changeStepPerformed(AjaxRequestTarget target, WizardStepDto dto){}

private void showHelpPerformed(AjaxRequestTarget target){
WizardHelpDialog window = (WizardHelpDialog)get(ID_HELP_MODAL);
window.show(target);
}

public IWizardStep getActiveStep(){
return null;
}
}
@@ -0,0 +1,30 @@
<!--
~ Copyright (c) 2010-2013 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.
-->
<wicket:panel xmlns:wicket="http://wicket.apache.org">
<div wicket:id="content" style="padding: 5px">

<label wicket:id="helpLabel" style="font-weight: normal"/>

<div class="main-button-bar" style="padding-bottom: 0px">
<p align="center">
<a wicket:id="okButton" class="btn btn-primary btn-sm">
<span><wicket:message key="WizardHelpDialog.button.ok" /></span>
</a>
</p>
</div>

</div>
</wicket:panel>
@@ -0,0 +1,127 @@
/*
* Copyright (c) 2010-2013 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.component.wizard.resource.component;

import com.evolveum.midpoint.web.component.wizard.resource.*;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
import org.apache.wicket.extensions.wizard.IWizardStep;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.StringResourceModel;

/**
* @author shood
* */
public class WizardHelpDialog extends ModalWindow{

private static final String ID_HELP = "helpLabel";
private static final String ID_BUTTON_OK = "okButton";

private boolean initialized;
private IWizardStep step;

public WizardHelpDialog(String id, final IWizardStep step){
super(id);

this.step = step;

setOutputMarkupId(true);
setTitle(createStringResource("WizardHelpDialog.label"));
showUnloadConfirmation(false);
setCssClassName(ModalWindow.CSS_CLASS_GRAY);
setCookieName(WizardHelpDialog.class.getSimpleName() + ((int) (Math.random() * 100)));
setInitialWidth(450);
setInitialHeight(500);
setWidthUnit("px");

WebMarkupContainer content = new WebMarkupContainer(getContentId());
content.setOutputMarkupId(true);
setContent(content);
}

public StringResourceModel createStringResource(String resourceKey, Object... objects) {
return new StringResourceModel(resourceKey, this, null, resourceKey, objects);
}

public void updateModal(AjaxRequestTarget target, IWizardStep step){
this.step = step;

if(target != null){
target.add(getContent());
}
}

@Override
protected void onBeforeRender(){
super.onBeforeRender();

if(initialized){
return;
}

initLayout((WebMarkupContainer) get(getContentId()));
initialized = true;
}

public void initLayout(WebMarkupContainer content){
Label helpLabel = new Label(ID_HELP, new AbstractReadOnlyModel<String>() {

@Override
public String getObject() {
return getString(determineHelpKey());
}
});
helpLabel.setEscapeModelStrings(false);
content.add(helpLabel);

AjaxLink ok = new AjaxLink(ID_BUTTON_OK) {

@Override
public void onClick(AjaxRequestTarget target) {
closePerformed(target);
}
};
content.add(ok);
}

private String determineHelpKey(){
if(step != null){
if(step instanceof NameStep){
return "ResourceWizard.help.nameStep";
} else if(step instanceof ConfigurationStep){
return "ResourceWizard.help.configurationStep";
} else if(step instanceof SchemaStep){
return "ResourceWizard.help.schemaStep";
} else if(step instanceof SchemaHandlingStep){
return "ResourceWizard.help.schemaHandlingStep";
} else if(step instanceof CapabilityStep){
return "ResourceWizard.help.capabilityStep";
} else if(step instanceof SynchronizationStep){
return "ResourceWizard.help.synchronizationStep";
}
}

return null;
}

private void closePerformed(AjaxRequestTarget target){
close(target);
}
}
@@ -0,0 +1,17 @@
#
# Copyright (c) 2010-2013 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.
#
WizardHelpDialog.label=Get Help With Resource Wizard!
WizardHelpDialog.button.ok=Ok, Got It!

0 comments on commit 6685fa2

Please sign in to comment.