From 18375621c262ffaa1735ae860d7c111e4e634439 Mon Sep 17 00:00:00 2001 From: Jakob Heher Date: Wed, 16 Feb 2022 21:40:49 +0100 Subject: split AboutComposite into its own file, and refactor it --- .../composites/configuration/AboutComposite.java | 128 +++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AboutComposite.java (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AboutComposite.java') diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AboutComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AboutComposite.java new file mode 100644 index 00000000..ba0cb2b6 --- /dev/null +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AboutComposite.java @@ -0,0 +1,128 @@ +package at.asit.pdfover.gui.composites.configuration; + +import java.awt.Desktop; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.FormLayout; +import org.eclipse.swt.program.Program; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Link; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.asit.pdfover.commons.Constants; +import at.asit.pdfover.commons.Messages; +import at.asit.pdfover.gui.workflow.config.ConfigManipulator; +import at.asit.pdfover.gui.workflow.config.PersistentConfigProvider; + +public class AboutComposite extends ConfigurationCompositeBase { + static final Logger log = LoggerFactory.getLogger(AboutComposite.class); + private Link lnkAbout; + private Link lnkDataProtection; + private Label lblDataProtection; + /** + * @param parent + * @param style + */ + public AboutComposite(Composite parent, int style) { + super(parent, style, null, null); + + setLayout(new FormLayout()); + + this.lnkAbout = new Link(this, SWT.NONE); + ConfigurationCompositeBase.anchor(lnkAbout).right(100,-5).left(0,5).top(0,5).width(100).set(); + ConfigurationCompositeBase.setFontHeight(lnkAbout, Constants.TEXT_SIZE_NORMAL); + + this.lnkAbout.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + try { + URI url = new URI(Messages.getString("config.LicenseURL")); //$NON-NLS-1$ + log.debug("Trying to open " + url.toString()); //$NON-NLS-1$ + if (Desktop.isDesktopSupported()) { + Desktop.getDesktop().browse(url); + } else { + log.info("AWT Desktop is not supported on this platform"); //$NON-NLS-1$ + Program.launch(url.toString()); + } + } catch (IOException ex) { + log.error("AboutComposite: ", ex); //$NON-NLS-1$ + } catch (URISyntaxException ex) { + log.error("AboutComposite: ", ex); //$NON-NLS-1$ + } + } + }); + + this.lblDataProtection = new Label(this, SWT.NONE); + ConfigurationCompositeBase.anchor(lblDataProtection).top(lnkAbout, 15).right(100,-5).left(0,5).width(100).set(); + ConfigurationCompositeBase.setFontHeight(lblDataProtection, Constants.TEXT_SIZE_BIG); + + this.lnkDataProtection = new Link(this, SWT.NONE); + ConfigurationCompositeBase.anchor(lnkDataProtection).right(100,-5).left(0,5).top(lblDataProtection,10).bottom(100,-5).width(100).height(120).set(); + ConfigurationCompositeBase.setFontHeight(lnkDataProtection, Constants.TEXT_SIZE_NORMAL); + + this.lnkDataProtection.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + try { + URI url = new URI(Messages.getString("config.DataProtectionURL")); //$NON-NLS-1$ + log.debug("Trying to open " + url.toString()); //$NON-NLS-1$ + if (Desktop.isDesktopSupported()) { + Desktop.getDesktop().browse(url); + } else { + log.info("AWT Desktop is not supported on this platform"); //$NON-NLS-1$ + Program.launch(url.toString()); + } + } catch (IOException ex) { + log.error("AboutComposite: ", ex); //$NON-NLS-1$ + } catch (URISyntaxException ex) { + log.error("AboutComposite: ", ex); //$NON-NLS-1$ + } + } + }); + + // Load localized strings + reloadResources(); + } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.composites.StateComposite#doLayout() + */ + @Override + public void doLayout() { + // Nothing to do here + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.composites.StateComposite#reloadResources() + */ + @Override + public void reloadResources() { + this.lnkAbout.setText(Messages.getString("config.AboutText")); //$NON-NLS-1$ + this.lnkDataProtection.setText(Messages.getString("config.DataProtectionStatement")); + this.lblDataProtection.setText(Messages.getString("config.DataProtection")); + } + + + @Override + protected void signerChanged() {} + + @Override + public void initConfiguration(PersistentConfigProvider provider) {} + + @Override + public void loadConfiguration() {} + + @Override + public void storeConfiguration(ConfigManipulator store, PersistentConfigProvider provider) {} + + @Override + public void validateSettings(int resumeFrom) throws Exception {} +} \ No newline at end of file -- cgit v1.2.3