org.aperteworkflow.help.impl.HelpProviderImpl Maven / Gradle / Ivy
The newest version!
package org.aperteworkflow.help.impl;
import com.vaadin.Application;
import com.vaadin.ui.*;
import com.vaadin.ui.Field;
import com.vaadin.ui.Label;
import com.vaadin.ui.Layout;
import org.aperteworkflow.ui.help.HelpProvider;
import org.vaadin.jonatan.contexthelp.ContextHelp;
import org.vaadin.jonatan.contexthelp.Placement;
import pl.net.bluesoft.rnd.processtool.model.config.ProcessDefinitionConfig;
import pl.net.bluesoft.rnd.pt.utils.lang.Lang2;
import pl.net.bluesoft.rnd.util.i18n.I18NSource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author [email protected]
*/
public class HelpProviderImpl implements HelpProvider {
private HelpFactory helpFactory;
private boolean canEdit;
@Override
public void prepare(Application application, List cfgs, boolean canEdit, String helpDictionaryName) {
ContextHelp contextHelp = new ContextHelp();
this.canEdit = canEdit;
application.getMainWindow().getContent().addComponent(contextHelp);
helpFactory = new HelpFactory(
application,
I18NSource.ThreadUtil.getThreadI18nSource(),
// "step_help",
helpDictionaryName,
contextHelp);
}
@Override
public Component helpIcon(String taskName, String s) {
return helpFactory.helpIcon(taskName, s);
}
@Override
public Component getHelpIcon(String key) {
if (cannotEdit()) return new Label("");
return helpFactory.helpIcon(key);
}
private boolean cannotEdit() {
return !canEdit;
}
@Override
public Component getHelpIcon(String key, String message) {
if (cannotEdit()) return new Label("");
return helpFactory.helpIcon(key, message);
}
@Override
public Field wrapFieldWithHelp(Field field, String key) {
if (cannotEdit()) return field;
return helpFactory.wrapField(field, key);
}
@Override
public Component wrapComponentWithHelp(Component component, String key) {
if (cannotEdit()) return component;
return helpFactory.wrapComponentWithHelp(component, key);
}
public Component wrapComponentWithHelp(Component component, String key, String iconPlacement, String popupPlacement) {
if (cannotEdit()) return component;
return helpFactory.wrapComponentWithHelp(component,
key,
Placement.valueOf(iconPlacement),
Placement.valueOf(popupPlacement));
}
@Override
public void attachToLayout(Layout layout) {
layout.addComponent(helpFactory.getContextHelp());
}
@Override
public void showHelpFor(Component component) {
helpFactory.getContextHelp().showHelpFor(component);
}
@Override
public Field getFieldWithHelp(final Field wrappedField, Component helpButton) {
return new FieldWithHelp(wrappedField, helpButton);
}
@Override
public void makeTableHelpEnabled(Table t) {
makeTableHelpEnabled(t, t);
}
@Override
public void makeTableHelpEnabled(final Table t, final Component helpPosition) {
t.setSortDisabled(true);
t.setData(new HashMap
© 2015 - 2025 Weber Informatics LLC | Privacy Policy