blob: b01470b23009a57d974ff549c714283f493f3baf [file] [log] [blame]
/*=============================================================================#
# Copyright (c) 2014, 2019 Stephan Wahlbrink and others.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
# which is available at https://www.apache.org/licenses/LICENSE-2.0.
#
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
#
# Contributors:
# Stephan Wahlbrink <sw@wahlbrink.eu> - initial API and implementation
#=============================================================================*/
package org.eclipse.statet.internal.redocs.wikitext.r.commonmark.ui;
import java.util.concurrent.atomic.AtomicBoolean;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.statet.ecommons.ui.util.LayoutUtils;
import org.eclipse.statet.docmlet.wikitext.commonmark.ui.AbstractCommonmarkConfigDialog;
import org.eclipse.statet.docmlet.wikitext.core.markup.IMarkupConfig;
import org.eclipse.statet.docmlet.wikitext.ui.config.IMarkupConfigUIAdapter;
import org.eclipse.statet.internal.redocs.wikitext.r.commonmark.core.RCommonmarkConfig;
public class RCommonmarkConfigUI implements IMarkupConfigUIAdapter {
static class RCommonmarkConfigDialog extends AbstractCommonmarkConfigDialog<RCommonmarkConfig> {
public RCommonmarkConfigDialog(final Shell parent, final String contextLabel,
final boolean isContextEnabeld, final RCommonmarkConfig config) {
super(parent, contextLabel, isContextEnabeld, config);
}
@Override
protected Composite createExtensionGroup(final Composite parent) {
final Composite composite= super.createExtensionGroup(parent);
addProperty(composite, RCommonmarkConfig.YAML_METADATA_ENABLED_PROP);
addProperty(composite, RCommonmarkConfig.TEX_MATH_DOLLARS_ENABLED_PROP);
addProperty(composite, RCommonmarkConfig.TEX_MATH_SBACKSLASH_ENABLED_PROP);
LayoutUtils.addSmallFiller(composite, false);
addProperty(composite, RCommonmarkConfig.HEADER_INTERRUPT_PARAGRAPH_DISABLED_PROP);
addProperty(composite, RCommonmarkConfig.BLOCKQUOTE_INTERRUPT_PARAGRAPH_DISABLED_PROP);
LayoutUtils.addSmallFiller(composite, false);
addProperty(composite, RCommonmarkConfig.STRIKEOUT_DTILDE_ENABLED_PROP);
addProperty(composite, RCommonmarkConfig.SUPERSCRIPT_SCIRCUMFLEX_ENABLED_PROP);
addProperty(composite, RCommonmarkConfig.SUBSCRIPT_STILDE_ENABLED_PROP);
return composite;
}
}
@Override
public boolean edit(final String contextLabel, final AtomicBoolean isContextEnabled, final IMarkupConfig config, final Shell parent) {
final RCommonmarkConfigDialog dialog= new RCommonmarkConfigDialog(parent, contextLabel,
(isContextEnabled != null && isContextEnabled.get()), (RCommonmarkConfig) config );
if (dialog.open() == Dialog.OK) {
if (isContextEnabled != null) {
isContextEnabled.set(dialog.isCustomEnabled());
}
return true;
}
return false;
}
}