Skip to content

Commit

Permalink
Cleanup switching of default note text (#109)
Browse files Browse the repository at this point in the history
cf. #105
  • Loading branch information
iaik-jheher committed Dec 1, 2023
1 parent 8b63d2b commit bc06763
Showing 1 changed file with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ public void focusLost(FocusEvent e) {
SWTUtils.setFontHeight(cmbSignatureProfiles, Constants.TEXT_SIZE_NORMAL);
SWTUtils.scrollPassthrough(cmbSignatureProfiles);
SWTUtils.addSelectionListener(cmbSignatureProfiles, e -> {
Profile current = SimpleConfigurationComposite.this.configurationContainer.getSignatureProfile();
int index = SimpleConfigurationComposite.this.cmbSignatureProfiles.getSelectionIndex();
Profile current = this.configurationContainer.getSignatureProfile();
int index = this.cmbSignatureProfiles.getSelectionIndex();
Profile selected = Profile.values()[index];
if (!current.equals(selected)) {
performProfileSelectionChanged(selected);
Expand All @@ -180,8 +180,8 @@ public void focusLost(FocusEvent e) {
this.cmbSignatureLang.setItems(Arrays.stream(Constants.SUPPORTED_LOCALES).map(l -> l.getDisplayLanguage()).toArray(String[]::new));

SWTUtils.addSelectionListener(cmbSignatureLang, e -> {
Locale currentLocale = SimpleConfigurationComposite.this.configurationContainer.signatureLocale;
Locale selectedLocale = Constants.SUPPORTED_LOCALES[SimpleConfigurationComposite.this.cmbSignatureLang.getSelectionIndex()];
Locale currentLocale = this.configurationContainer.signatureLocale;
Locale selectedLocale = Constants.SUPPORTED_LOCALES[this.cmbSignatureLang.getSelectionIndex()];
if (!currentLocale.equals(selectedLocale)) {
performSignatureLangSelectionChanged(selectedLocale, currentLocale);
}
Expand Down Expand Up @@ -292,7 +292,7 @@ public void focusLost(FocusEvent e) {
this.cSigPreview = new Canvas(containerComposite, SWT.RESIZE);
SWTUtils.anchor(cSigPreview).left(0, 5).right(100,-5).top(btnBrowseLogo,5).bottom(100,-5);
SWTUtils.setFontHeight(cSigPreview, Constants.TEXT_SIZE_NORMAL);
this.cSigPreview.addPaintListener(e -> SimpleConfigurationComposite.this.paintSignaturePreview(e));
this.cSigPreview.addPaintListener(e -> this.paintSignaturePreview(e));

DropTarget dnd_target = new DropTarget(containerComposite, DND.DROP_DEFAULT | DND.DROP_COPY);
final FileTransfer fileTransfer = FileTransfer.getInstance();
Expand Down Expand Up @@ -357,11 +357,11 @@ public void dragEnter(DropTargetEvent event) {
});

SWTUtils.addSelectionListener(btnClearImage, e -> {
SimpleConfigurationComposite.this.processEmblemChanged(null);
this.processEmblemChanged(null);
});
SWTUtils.addSelectionListener(btnBrowseLogo, e -> {
FileDialog dialog = new FileDialog(
SimpleConfigurationComposite.this.getShell(), SWT.OPEN);
this.getShell(), SWT.OPEN);
dialog.setFilterExtensions(new String[] {
"*.jpg;*.png;*.gif", "*.jpg", "*.png", "*.gif", "*" });
dialog.setFilterNames(new String[] {
Expand Down Expand Up @@ -510,8 +510,10 @@ void performSignatureLangSelectionChanged(Locale selected, Locale previous) {
this.configurationContainer.signatureLocale = selected;
this.cmbSignatureLang.select(this.getLocaleElementIndex(selected));

if ((previous != null) && (txtSignatureNote.getText().equals(getDefaultSignatureBlockNoteTextFor(null, previous))))
if ((previous != null) && (txtSignatureNote.getText().equals(getDefaultSignatureBlockNoteTextFor(null, previous)))) {
txtSignatureNote.setText(getDefaultSignatureBlockNoteTextFor(null, selected));
processSignatureNoteChanged();
}

signatureBlockPreviewChanged();
}
Expand All @@ -524,8 +526,10 @@ void performProfileSelectionChanged(Profile newProfile) {
this.configurationContainer.setSignatureProfile(newProfile);
this.cmbSignatureProfiles.select(newProfile.ordinal());

if (txtSignatureNote.getText().equals(getDefaultSignatureBlockNoteTextFor(oldProfile, null)))
if (txtSignatureNote.getText().equals(getDefaultSignatureBlockNoteTextFor(oldProfile, null))) {
txtSignatureNote.setText(getDefaultSignatureBlockNoteTextFor(newProfile, null));
processSignatureNoteChanged();
}

this.grpSignatureLang.setVisible(newProfile.hasText());
this.grpSignatureNote.setVisible(newProfile.hasText());
Expand Down

0 comments on commit bc06763

Please sign in to comment.