Skip to content

Commit

Permalink
0004943: Improved resizable dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-miller-jumpmind committed Oct 1, 2021
1 parent 8646622 commit 3e8f4e4
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 37 deletions.
Expand Up @@ -43,8 +43,6 @@ public NotifyDialog(String caption, String text, final Throwable ex, Notificatio
super(caption);
setWidth("400px");
setHeight("320px");

content.setHeight("86%");

final Scroller messageArea = new Scroller();
messageArea.setSizeFull();
Expand All @@ -60,8 +58,8 @@ public NotifyDialog(String caption, String text, final Throwable ex, Notificatio
final Label textLabel = new Label(message);
messageArea.setContent(textLabel);

content.add(messageArea);
content.expand(messageArea);
innerContent.add(messageArea);
innerContent.expand(messageArea);

final Button detailsButton = new Button("Details");
detailsButton.setVisible(ex != null);
Expand All @@ -83,7 +81,7 @@ public NotifyDialog(String caption, String text, final Throwable ex, Notificatio
}
});

content.add(buildButtonFooter(detailsButton, buildCloseButton()));
innerContent.add(buildButtonFooter(detailsButton, buildCloseButton()));

}

Expand Down
Expand Up @@ -95,12 +95,11 @@ public ReadOnlyTextAreaDialog(final String title, final String value, Table tabl
if (shortcutToggler != null) {
addOpenedChangeListener(event -> shortcutToggler.accept(event.isOpened()));
}

content.setHeight("90%");

wrapper = new VerticalLayout();
wrapper.setMargin(false);
wrapper.setSizeFull();
wrapper.setHeight("100px");
wrapper.setWidthFull();
textField = new TextArea();
textField.getStyle().set("max-height", "480px");
textField.setSizeFull();
Expand Down
Expand Up @@ -43,7 +43,7 @@ public class ResizableDialog extends Dialog {

protected final Logger log = LoggerFactory.getLogger(getClass());

protected VerticalLayout content;
protected VerticalLayout innerContent;

protected Label captionLabel;

Expand All @@ -61,17 +61,23 @@ public ResizableDialog(String caption, boolean addEscapeShortcut) {
setModal(true);
setResizable(true);

VerticalLayout content = new VerticalLayout();
content.setSizeFull();
content.setPadding(false);
super.add(content);

if (caption != null) {
captionLabel = new Label(caption + "<hr>");
super.add(captionLabel);
captionLabel.setWidthFull();
captionLabel.getStyle().set("margin", null);
content.add(captionLabel);
}

content = new VerticalLayout();
content.setWidthFull();
content.setHeight("92%");
content.setMargin(false);
content.setSpacing(false);
super.add(content);
innerContent = new VerticalLayout();
innerContent.setWidthFull();
innerContent.setMargin(false);
innerContent.setSpacing(false);
content.addAndExpand(innerContent);

UI.getCurrent().addShortcutListener(() -> {
if (!"100%".equals(getWidth())) {
Expand All @@ -89,17 +95,17 @@ public ResizableDialog(String caption, boolean addEscapeShortcut) {
}

protected void add(Component component, int expandRatio) {
content.add(component);
content.setFlexGrow(expandRatio, component);
innerContent.add(component);
innerContent.setFlexGrow(expandRatio, component);
}

protected void add(Component component) {
content.add(component);
innerContent.add(component);
}

protected void addComponents(Component... components) {
for (Component component : components) {
content.add(component);
innerContent.add(component);
}
}

Expand Down
Expand Up @@ -35,8 +35,8 @@ public SqlEntryDialog(String sql) {
editor.setMode(AceMode.sql);
editor.setValue(sql);
editor.setSizeFull();
content.add(editor, buildButtonFooter(buildCloseButton()));
content.expand(editor);
innerContent.add(editor, buildButtonFooter(buildCloseButton()));
innerContent.expand(editor);
}

public String getSQL() {
Expand Down
Expand Up @@ -137,6 +137,7 @@ public DbExportDialog(IDatabasePlatform databasePlatform, Set<Table> selectedTab
this.databasePlatform = databasePlatform;
this.queryPanel = queryPanel;

setWidth("700px");
setCloseOnOutsideClick(false);

tableSelectionLayout = new TableSelectionLayout(databasePlatform, selectedTableSet, excludeTablesRegex) {
Expand All @@ -147,6 +148,7 @@ protected void selectionChanged() {
nextButton.setEnabled(tableSelectionLayout.getSelectedTables().size() > 0);
}
};
tableSelectionLayout.setHeight("318px");

createOptionLayout();

Expand Down Expand Up @@ -331,9 +333,9 @@ protected void setExportButtonsEnabled() {
}

protected void previous() {
content.remove(optionLayout);
content.addComponentAtIndex(0, tableSelectionLayout);
content.expand(tableSelectionLayout);
innerContent.remove(optionLayout);
innerContent.addComponentAtIndex(0, tableSelectionLayout);
innerContent.expand(tableSelectionLayout);
previousButton.setVisible(false);
exportEditorButton.setVisible(false);
if (exportEditorShortcutRegistration != null) {
Expand All @@ -356,9 +358,9 @@ protected void previous() {
}

protected void next() {
content.remove(tableSelectionLayout);
content.addComponentAtIndex(0, optionLayout);
content.expand(optionLayout);
innerContent.remove(tableSelectionLayout);
innerContent.addComponentAtIndex(0, optionLayout);
innerContent.expand(optionLayout);
nextButton.setVisible(false);
if (nextShortcutRegistration != null) {
nextShortcutRegistration.remove();
Expand Down Expand Up @@ -412,7 +414,7 @@ protected void exportToEditor() {
protected void buildFileDownloader() {
if (fileDownloader != null) {
fileDownloader.remove();
content.remove(buttonFooter);
innerContent.remove(buttonFooter);
}
fileDownloader = new Anchor(createResource(), null);
fileDownloader.getElement().setAttribute("download", true);
Expand Down
Expand Up @@ -117,6 +117,7 @@ protected void selectionChanged() {
nextButton.setEnabled(tableSelectionLayout.getSelectedTables().size() > 0);
};
};
tableSelectionLayout.setHeight("318px");

createOptionLayout();

Expand Down Expand Up @@ -303,9 +304,9 @@ protected void createDbFill() {
}

protected void previous() {
content.remove(optionLayout);
content.addComponentAtIndex(0, tableSelectionLayout);
content.expand(tableSelectionLayout);
innerContent.remove(optionLayout);
innerContent.addComponentAtIndex(0, tableSelectionLayout);
innerContent.expand(tableSelectionLayout);
fillButton.setVisible(false);
if (fillShortcutRegistration != null) {
fillShortcutRegistration.remove();
Expand All @@ -319,9 +320,9 @@ protected void previous() {
}

protected void next() {
content.remove(tableSelectionLayout);
content.addComponentAtIndex(0, optionLayout);
content.expand(optionLayout);
innerContent.remove(tableSelectionLayout);
innerContent.addComponentAtIndex(0, optionLayout);
innerContent.expand(optionLayout);
nextButton.setVisible(false);
if (nextShortcutRegistration != null) {
nextShortcutRegistration.remove();
Expand Down
Expand Up @@ -79,7 +79,6 @@ public SettingsDialog(SqlExplorer explorer) {
this.settingsProvider = explorer.getSettingsProvider();
setCloseOnOutsideClick(false);
setWidth("800px");
content.setHeight("91%");
add(createSettingsLayout(), 1);
add(createButtonLayout());
}
Expand Down
Expand Up @@ -104,7 +104,8 @@ public SqlHistoryDialog(ISettingsProvider settingsProvider, QueryPanel queryPane
}
});

grid.setSizeFull();
grid.setHeight("120px");
grid.setWidthFull();

mainLayout.addAndExpand(grid);

Expand Down

0 comments on commit 3e8f4e4

Please sign in to comment.