diff options
Diffstat (limited to 'org.eclipse.scout.rt.client/src/main/java/org')
3 files changed, 0 insertions, 404 deletions
diff --git a/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/wizard/AbstractWizardStatusField.java b/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/wizard/AbstractWizardStatusField.java deleted file mode 100644 index aff0612d13..0000000000 --- a/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/wizard/AbstractWizardStatusField.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright (c) 2010-2017 BSI Business Systems Integration AG. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * BSI Business Systems Integration AG - initial API and implementation - */ -package org.eclipse.scout.rt.client.ui.wizard; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; - -import org.eclipse.scout.rt.client.context.ClientRunContexts; -import org.eclipse.scout.rt.client.job.ModelJobs; -import org.eclipse.scout.rt.client.ui.form.IForm; -import org.eclipse.scout.rt.client.ui.form.fields.htmlfield.AbstractHtmlField; -import org.eclipse.scout.rt.platform.classid.ClassId; -import org.eclipse.scout.rt.platform.exception.PlatformError; -import org.eclipse.scout.rt.platform.util.WeakEventListener; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@ClassId("6936b8b8-6612-4efa-bf29-80a26f80b9da") -public abstract class AbstractWizardStatusField extends AbstractHtmlField { - private static final Logger LOG = LoggerFactory.getLogger(AbstractWizardStatusField.class); - private IWizard m_wizard; - private IWizardStatusHtmlProvider m_htmlProvider; - private P_WizardListener m_scoutWizardListener; - private P_WizardStepListener m_scoutWizardStepListener; - private boolean m_dirty; - public static final String STEP_ANCHOR_IDENTIFIER = "STEP_"; - - public AbstractWizardStatusField() { - this(true); - } - - public AbstractWizardStatusField(boolean callInitializer) { - super(callInitializer); - } - - public IWizardStatusHtmlProvider getHtmlProvider() { - return m_htmlProvider; - } - - public void setHtmlProvider(IWizardStatusHtmlProvider htmlProvider) { - m_htmlProvider = htmlProvider; - } - - @Override - protected boolean getConfiguredScrollBarEnabled() { - return false; - } - - @Override - protected boolean getConfiguredLabelVisible() { - return false; - } - - @Override - protected boolean getConfiguredStatusVisible() { - return false; - } - - @Override - protected void execInitField() { - //automatically set wizard if the field is placed inside a wizard container form - IForm f = getForm(); - while (f != null) { - if (f instanceof IWizardContainerForm) { - setWizard(f.getWizard()); - } - f = f.getOuterForm(); - } - } - - public void setWizard(IWizard wizard) { - if (m_wizard != null) { - m_wizard.removeWizardListener(m_scoutWizardListener); - m_wizard.removePropertyChangeListener(m_scoutWizardStepListener); - m_scoutWizardListener = null; - m_scoutWizardStepListener = null; - m_wizard = null; - } - - if (wizard != null) { - m_wizard = wizard; - m_scoutWizardListener = new P_WizardListener(); - m_wizard.addWizardListener(m_scoutWizardListener); - m_wizard.addPropertyChangeListener(m_scoutWizardListener); - // add step listeners - m_scoutWizardStepListener = new P_WizardStepListener(); - for (IWizardStep step : m_wizard.getSteps()) { - step.removePropertyChangeListener(m_scoutWizardStepListener); - step.addPropertyChangeListener(m_scoutWizardStepListener); - } - } - markDirty(); - } - - public IWizard getWizard() { - return m_wizard; - } - - @Override - protected void execDisposeField() { - m_dirty = false; - } - - private void markDirty() { - m_dirty = true; - ModelJobs.schedule(() -> { - if (m_dirty) { - try { - refreshStatus(); - } - catch (RuntimeException | PlatformError e) { - LOG.warn("Could not refresh status", e); - } - } - }, ModelJobs.newInput(ClientRunContexts.copyCurrent())); - } - - public void refreshStatus() { - m_dirty = false; - if (m_htmlProvider == null) { - m_htmlProvider = new DefaultWizardStatusHtmlProvider(); - m_htmlProvider.initialize(this); - } - setValue(m_htmlProvider.createHtml(m_wizard)); - // now scroll to the active step - int index = 1; - for (IWizardStep<?> step : m_wizard.getSteps()) { - if (step == m_wizard.getActiveStep()) { - setScrollToAnchor(STEP_ANCHOR_IDENTIFIER + index); - break; - } - index++; - } - } - - private class P_WizardListener implements WizardListener, PropertyChangeListener, WeakEventListener { - @Override - public void wizardChanged(WizardEvent e) { - switch (e.getType()) { - case WizardEvent.TYPE_STATE_CHANGED: { - // re-attach step listeners - for (IWizardStep step : m_wizard.getSteps()) { - step.removePropertyChangeListener(m_scoutWizardStepListener); - step.addPropertyChangeListener(m_scoutWizardStepListener); - } - markDirty(); - break; - } - } - } - - @Override - public void propertyChange(final PropertyChangeEvent e) { - if (IWizard.PROP_TITLE.equals(e.getPropertyName()) - || IWizard.PROP_SUB_TITLE.equals(e.getPropertyName())) { - markDirty(); - } - } - }// end class P_ScoutWizardListener - - private class P_WizardStepListener implements PropertyChangeListener, WeakEventListener { - @Override - public void propertyChange(final PropertyChangeEvent e) { - if (IWizardStep.PROP_DESCRIPTION_HTML.equals(e.getPropertyName()) - || IWizardStep.PROP_TITLE.equals(e.getPropertyName()) - || IWizardStep.PROP_TITLE_HTML.equals(e.getPropertyName()) - || IWizardStep.PROP_TOOLTIP_TEXT.equals(e.getPropertyName()) - || IWizardStep.PROP_ENABLED.equals(e.getPropertyName())) { - markDirty(); - } - } - }// end class P_ScoutWizardStepListener - -} diff --git a/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/wizard/DefaultWizardStatusHtmlProvider.java b/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/wizard/DefaultWizardStatusHtmlProvider.java deleted file mode 100644 index 2a34656909..0000000000 --- a/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/wizard/DefaultWizardStatusHtmlProvider.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (c) 2010-2017 BSI Business Systems Integration AG. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * BSI Business Systems Integration AG - initial API and implementation - */ -package org.eclipse.scout.rt.client.ui.wizard; - -import static org.eclipse.scout.rt.platform.html.HTML.imgByBinaryResource; -import static org.eclipse.scout.rt.platform.html.HTML.td; - -import java.io.InputStream; -import java.util.LinkedList; -import java.util.List; - -import org.eclipse.scout.rt.client.ResourceBase; -import org.eclipse.scout.rt.client.services.common.icon.IconLocator; -import org.eclipse.scout.rt.client.services.common.icon.IconSpec; -import org.eclipse.scout.rt.platform.exception.ProcessingException; -import org.eclipse.scout.rt.platform.html.HTML; -import org.eclipse.scout.rt.platform.resource.BinaryResource; -import org.eclipse.scout.rt.platform.util.IOUtility; -import org.eclipse.scout.rt.platform.util.ObjectUtility; -import org.eclipse.scout.rt.platform.util.StringUtility; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class DefaultWizardStatusHtmlProvider implements IWizardStatusHtmlProvider { - private static final Logger LOG = LoggerFactory.getLogger(DefaultWizardStatusHtmlProvider.class); - - private String m_htmlTemplate; - - /** - * initialize, load html template and inline images - */ - @Override - public void initialize(AbstractWizardStatusField htmlField) { - m_htmlTemplate = initHtmlTemplate(); - - // collect attachments for HTML field - List<BinaryResource> attachments = collectAttachments(); - if (attachments != null && !attachments.isEmpty()) { - htmlField.setAttachments(attachments); - } - } - - @Override - public String initHtmlTemplate() { - try (InputStream in = ResourceBase.class.getResource("html/defaultWizardStatus.html").openStream()) { - return IOUtility.readString(in, "iso-8859-1"); - } - catch (Exception t) { - throw new ProcessingException("Unexpected", t); - } - } - - protected String getHtmlTemplate() { - return m_htmlTemplate; - } - - @Override - public String createHtml(IWizard w) { - String html = m_htmlTemplate; - String topPart = ""; - String bottomPart = ""; - StringBuilder listPart = new StringBuilder(); - if (w != null) { - if (w.getSubTitle() != null) { - topPart = HTML.div(w.getSubTitle()).cssClass("infoBox").toHtml(); - } - if (w.getActiveStep() != null && (w.getActiveStep().getTooltipText() != null || w.getActiveStep().getSubTitle() != null)) { - bottomPart = HTML.div(ObjectUtility.nvl(w.getActiveStep().getSubTitle(), w.getActiveStep().getTooltipText())).cssClass("infoBox").toHtml(); - } - int index = 1; - for (IWizardStep<?> step : w.getSteps()) { - String s = createHtmlForStep(step, index, (step == w.getActiveStep())); - if (StringUtility.hasText(s)) { - listPart.append(s); - index++; - } - } - } - html = html.replace("#FONT_SIZE_UNIT#", "px"); - html = html.replace("#TOP#", topPart); - html = html.replace("#LIST#", listPart.toString()); - html = html.replace("#BOTTOM#", bottomPart); - return html; - } - - /** - * Adds a step to the HTML document. Uses old school HTML 3.2 with transparent graphics to enforce heights and widths - * background colors since HTMLEditorToolkit of swing does not support CSS level 2. - */ - protected String createHtmlForStep(IWizardStep<?> step, int index, boolean selected) { - String cssClass; - if (selected) { - cssClass = "selected"; - } - else if (step.isEnabled()) { - cssClass = "default"; - } - else { - cssClass = "disabled"; - } - StringBuilder buf = new StringBuilder(); - String spacerCssClass = "selected".equals(cssClass) ? "spacerselected" : "spacer"; - appendHtmlForSpacerLine(buf, spacerCssClass, 7, AbstractWizardStatusField.STEP_ANCHOR_IDENTIFIER + index); - - buf.append(HTML - .tr( - td(imgByBinaryResource("empty.png").addAttribute("width", "1").addAttribute("height", "30")).addAttribute("width", "15"), - td(String.valueOf(index)).addAttribute("width", "24").addAttribute("valign", "top").cssClass("bullet").style("padding:0px;padding-top:5px;"), - td().addAttribute("width", "17"), - td(step.getTitle()).style("padding-top:2px;"), - td().addAttribute("width", "15")) - .cssClass(cssClass)); - - appendHtmlForSpacerLine(buf, spacerCssClass, 11, null); - appendHtmlForSpacerLine(buf, "line", 1, null); - return buf.toString(); - } - - protected void appendHtmlForSpacerLine(StringBuilder buf, String cssClass, int height, String anchor) { - buf.append(HTML - .tr( - td( - StringUtility.isNullOrEmpty(anchor) ? null : buf.append("<a name=\"").append(anchor).append("\"/>"), - imgByBinaryResource("empty.png").addAttribute("width", "1").addAttribute("height", String.valueOf(height))).addAttribute("colspan", "5")) - .cssClass(cssClass)); - } - - /** - * To be overwritten in order to provide custom attachments. <br/> - */ - protected List<BinaryResource> collectAttachments() { - List<BinaryResource> attachments = new LinkedList<>(); - return attachments; - } - - /** - * To load an icon into the given attachments live list - */ - protected void loadIcon(List<BinaryResource> attachments, String iconName) { - if (attachments == null || iconName == null) { - return; - } - String tempIconName = iconName; - try { - int index; - // determine file format - index = tempIconName.lastIndexOf('.'); - if (index > 0) { - tempIconName = tempIconName.substring(0, index); - } - // determine icon base name - String baseIconName = tempIconName; - index = tempIconName.lastIndexOf('_'); - if (index > 0) { - baseIconName = tempIconName.substring(0, index); - } - - // load icon - IconSpec iconSpec = IconLocator.instance().getIconSpec(tempIconName); - if (iconSpec == null && !tempIconName.equals(baseIconName)) { - iconSpec = IconLocator.instance().getIconSpec(baseIconName); - } - - if (iconSpec != null) { - attachments.add(new BinaryResource(iconSpec.getName(), iconSpec.getContent())); - } - } - catch (Exception t) { - LOG.warn("Failed to load icon '{}'", tempIconName, t); - } - } -} diff --git a/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/wizard/IWizardStatusHtmlProvider.java b/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/wizard/IWizardStatusHtmlProvider.java deleted file mode 100644 index f14dda54a6..0000000000 --- a/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/wizard/IWizardStatusHtmlProvider.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2010-2015 BSI Business Systems Integration AG. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * BSI Business Systems Integration AG - initial API and implementation - */ -package org.eclipse.scout.rt.client.ui.wizard; - -/** - * Used by {@link AbstractWizardStatusField} and {@link DefaultWizardContainerForm} to customize html presentation of - * wizard status content - */ -public interface IWizardStatusHtmlProvider { - - /** - * initialize, load html template and inline images - */ - void initialize(AbstractWizardStatusField htmlField); - - /** - * Initialize the HTML template. <br> - * Template should contain the following placeholders:<br> - * <ul> - * <li><b>#TOP#</b>: Wizard titleHtml ({@link IWizard#getTitleHtml()}) or tooltipText ( - * {@link IWizard#getTooltipText()}) will be placed here.</li> - * <li><b>#FONT_SIZE_UNIT#</b>: Unit for font size calculation will be placed here.</li> - * <li><b>#LIST#</b>: Step list will be placed here.</li> - * <li><b>#BOTTOM#</b>: WizardStep descriptionHtml ({@link IWizardStep#getDescriptionHtml()}) or tooltipText ( - * {@link IWizardStep#getTooltipText()}) will be placed here.</li> - * </ul> - * - * @return template HTML file - */ - String initHtmlTemplate(); - - String createHtml(IWizard w); - -} |