diff options
author | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-02-16 21:40:49 +0100 |
---|---|---|
committer | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-02-16 21:40:49 +0100 |
commit | 18375621c262ffaa1735ae860d7c111e4e634439 (patch) | |
tree | bfa26e38c2c2f2dd793496c9724e1544d433763d | |
parent | 26fb36c13b04cf2e36759b9bc0b167a3b64c92f1 (diff) | |
download | pdf-over-18375621c262ffaa1735ae860d7c111e4e634439.tar.gz pdf-over-18375621c262ffaa1735ae860d7c111e4e634439.tar.bz2 pdf-over-18375621c262ffaa1735ae860d7c111e4e634439.zip |
split AboutComposite into its own file, and refactor it
2 files changed, 129 insertions, 126 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java index 75f91cc1..76ba709d 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java @@ -15,11 +15,7 @@ */ package at.asit.pdfover.gui.composites; -// Imports -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.custom.ScrolledComposite; @@ -31,13 +27,13 @@ import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormLayout; -import org.eclipse.swt.program.Program; import org.eclipse.swt.widgets.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import at.asit.pdfover.commons.Constants; import at.asit.pdfover.gui.controls.Dialog.BUTTONS; +import at.asit.pdfover.gui.composites.configuration.AboutComposite; import at.asit.pdfover.gui.composites.configuration.AdvancedConfigurationComposite; import at.asit.pdfover.gui.composites.configuration.ConfigurationCompositeBase; import at.asit.pdfover.gui.composites.configuration.KeystoreConfigurationComposite; @@ -291,127 +287,6 @@ public class ConfigurationComposite extends StateComposite { } } - private class AboutComposite extends StateComposite { - private Link lnkAbout; - private Link lnkDataProtection; - private Label lblDataProtection; - /** - * @param parent - * @param style - */ - public AboutComposite(Composite parent, int style) { - super(parent, style, null); - - setLayout(new FormLayout()); - - this.lnkAbout = new Link(this, SWT.NONE); - - FormData fd_lnkAbout = new FormData(); - fd_lnkAbout.right = new FormAttachment(100, -5); - fd_lnkAbout.left = new FormAttachment(0, 5); - fd_lnkAbout.top = new FormAttachment(0, 5); - fd_lnkAbout.width = 100; - this.lnkAbout.setLayoutData(fd_lnkAbout); - - FontData[] fD_lnkAbout = this.lnkAbout.getFont().getFontData(); - fD_lnkAbout[0].setHeight(Constants.TEXT_SIZE_NORMAL); - this.lnkAbout.setFont(new Font(Display.getCurrent(), - fD_lnkAbout[0])); - - 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); - FormData fd_lblDataProtection = new FormData(); - fd_lblDataProtection.top = new FormAttachment(this.lnkAbout, 15); - fd_lblDataProtection.right = new FormAttachment(100, -5); - fd_lblDataProtection.left = new FormAttachment(0, 5); - fd_lblDataProtection.width = 100; - this.lblDataProtection.setLayoutData(fd_lblDataProtection); - - FontData[] fD_lblDataProtection = this.lblDataProtection.getFont().getFontData(); - fD_lblDataProtection[0].setHeight(Constants.TEXT_SIZE_BIG); - this.lblDataProtection.setFont(new Font(Display.getCurrent(), - fD_lblDataProtection[0])); - - this.lnkDataProtection = new Link(this, SWT.NONE); - - FormData fd_lnkDataProtection = new FormData(); - fd_lnkDataProtection.right = new FormAttachment(100, -5); - fd_lnkDataProtection.left = new FormAttachment(0, 5); - fd_lnkDataProtection.top = new FormAttachment(this.lblDataProtection, 10); - fd_lnkDataProtection.bottom = new FormAttachment(100, -5); - fd_lnkDataProtection.width = 100; - fd_lnkDataProtection.height = 120; - this.lnkDataProtection.setLayoutData(fd_lnkDataProtection); - - FontData[] fD_lnkDataProtection = this.lnkDataProtection.getFont().getFontData(); - fD_lnkDataProtection[0].setHeight(Constants.TEXT_SIZE_NORMAL); - this.lnkDataProtection.setFont(new Font(Display.getCurrent(), - fD_lnkDataProtection[0])); - - - 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")); - } - } - private boolean keystoreInitialized = false; /** 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 |