Skip to content

Commit

Permalink
[#1191] "Import Licenses" wizard should support import from archive
Browse files Browse the repository at this point in the history
predefined layout for all the contributed control gets a way for conform
appearance
  • Loading branch information
eparovyshnaya committed Feb 19, 2024
1 parent 8400fd8 commit fbd5b60
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
Expand Up @@ -20,7 +20,6 @@
import org.eclipse.passage.lic.internal.jface.i18n.ImportLicenseDialogMessages;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.DirectoryDialog;
Expand All @@ -32,12 +31,14 @@ public final class FromLocalFileSystem implements LicenseFilesControl {
private Text path;

@Override
/**
* parent is expected to have GridLayout(3, false)
*/
public void install(Composite parent, Consumer<List<Path>> onLicenses) {
Composite composite = row(parent, 3);
new Label(composite, SWT.NONE).setText(ImportLicenseDialogMessages.ImportLicenseDialog_path_label);
path = new Text(composite, SWT.BORDER | SWT.READ_ONLY);
new Label(parent, SWT.NONE).setText(ImportLicenseDialogMessages.ImportLicenseDialog_path_label);
path = new Text(parent, SWT.BORDER | SWT.READ_ONLY);
path.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
Button browse = new Button(composite, SWT.PUSH);
Button browse = new Button(parent, SWT.PUSH);
browse.setText(ImportLicenseDialogMessages.ImportLicenseDialog_browse);
browse.addListener(SWT.Selection, e -> browseAndLoad(onLicenses));
}
Expand All @@ -46,13 +47,6 @@ private void browseAndLoad(Consumer<List<Path>> onLicenses) {
onLicenses.accept(browse());
}

private Composite row(Composite parent, int columns) {
Composite row = new Composite(parent, SWT.NONE);
row.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
row.setLayout(new GridLayout(columns, false));
return row;
}

private List<Path> browse() {
DirectoryDialog dialog = new DirectoryDialog(path.getShell(), SWT.OPEN | SWT.SHEET);
dialog.setText(ImportLicenseDialogMessages.ImportLicenseDialog_browse_dialog_title);
Expand Down
Expand Up @@ -36,6 +36,9 @@
import org.eclipse.passage.lic.internal.equinox.access.RegisteredLibraries;
import org.eclipse.passage.lic.internal.jface.i18n.ImportLicenseDialogMessages;
import org.eclipse.passage.lic.jface.resource.LicensingImages;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;

Expand Down Expand Up @@ -77,7 +80,14 @@ protected void initMessage() {
}

private void buildSelector(Composite parent) {
source.install(parent, this::loadAndUpdate);
source.install(row(parent, 3), this::loadAndUpdate);
}

private Composite row(Composite parent, int columns) {
Composite row = new Composite(parent, SWT.NONE);
row.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
row.setLayout(new GridLayout(columns, false));
return row;
}

private void buildViewer(Composite parent) {
Expand Down
Expand Up @@ -20,6 +20,6 @@ ImportLicenseDialog_import_title=&Import
ImportLicenseDialog_import_tooltip=Copy found license files to dedicated directories
ImportLicenseDialog_io_error=License import failed due to I/O error: %s
ImportLicenseDialog_lic_read_failed=Failed to read the license from the pointed folder
ImportLicenseDialog_path_label=From folder with license(s):
ImportLicenseDialog_prelude=Point a folder with license files to see what's inside them
ImportLicenseDialog_path_label=From &Folder:
ImportLicenseDialog_prelude=Find licenses
ImportLicenseDialog_title=Import Licenses

0 comments on commit fbd5b60

Please sign in to comment.