X-Git-Url: https://git.argeo.org/?p=gpl%2Fargeo-suite.git;a=blobdiff_plain;f=org.argeo.publishing.ui%2Fsrc%2Forg%2Fargeo%2Fdocbook%2Fui%2FTextEditorHeader.java;fp=org.argeo.publishing.ui%2Fsrc%2Forg%2Fargeo%2Fdocbook%2Fui%2FTextEditorHeader.java;h=0000000000000000000000000000000000000000;hp=eac75f9a5cf03161c065bc2fe5d4b24eb0c89684;hb=6e56ffa34cb02ab04d028423aea342e3dfed4358;hpb=c285180bece610b2c2921d44fe14b6dde2123efa diff --git a/org.argeo.publishing.ui/src/org/argeo/docbook/ui/TextEditorHeader.java b/org.argeo.publishing.ui/src/org/argeo/docbook/ui/TextEditorHeader.java deleted file mode 100644 index eac75f9..0000000 --- a/org.argeo.publishing.ui/src/org/argeo/docbook/ui/TextEditorHeader.java +++ /dev/null @@ -1,91 +0,0 @@ -package org.argeo.docbook.ui; - -import java.util.Observable; -import java.util.Observer; - -import org.argeo.cms.ui.CmsEditable; -import org.argeo.cms.ui.util.CmsUiUtils; -import org.argeo.cms.ui.widgets.TextStyles; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; - -/** Adds editing capabilities to a page editing text */ -public class TextEditorHeader implements SelectionListener, Observer { - private static final long serialVersionUID = 4186756396045701253L; - - private final CmsEditable cmsEditable; - private Button publish; - - private Composite parent; - private Composite display; - private Object layoutData; - - public TextEditorHeader(CmsEditable cmsEditable, Composite parent, int style) { - this.cmsEditable = cmsEditable; - this.parent = parent; - if (this.cmsEditable instanceof Observable) - ((Observable) this.cmsEditable).addObserver(this); - refresh(); - } - - protected void refresh() { - if (display != null && !display.isDisposed()) - display.dispose(); - display = null; - publish = null; - if (cmsEditable.isEditing()) { - display = new Composite(parent, SWT.NONE); - // display.setBackgroundMode(SWT.INHERIT_NONE); - display.setLayoutData(layoutData); - display.setLayout(CmsUiUtils.noSpaceGridLayout()); - CmsUiUtils.style(display, TextStyles.TEXT_EDITOR_HEADER); - publish = new Button(display, SWT.FLAT | SWT.PUSH); - publish.setText(getPublishButtonLabel()); - CmsUiUtils.style(publish, TextStyles.TEXT_EDITOR_HEADER); - publish.addSelectionListener(this); - display.moveAbove(null); - } - parent.layout(); - } - - private String getPublishButtonLabel() { - if (cmsEditable.isEditing()) - return "Publish"; - else - return "Edit"; - } - - @Override - public void widgetSelected(SelectionEvent e) { - if (e.getSource() == publish) { - if (cmsEditable.isEditing()) { - cmsEditable.stopEditing(); - } else { - cmsEditable.startEditing(); - } - // publish.setText(getPublishButtonLabel()); - } - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - } - - @Override - public void update(Observable o, Object arg) { - if (o == cmsEditable) { - // publish.setText(getPublishButtonLabel()); - refresh(); - } - } - - public void setLayoutData(Object layoutData) { - this.layoutData = layoutData; - if (display != null && !display.isDisposed()) - display.setLayoutData(layoutData); - } - -} \ No newline at end of file