Skip to content

Commit

Permalink
Improved filtering logic in module management GUI.
Browse files Browse the repository at this point in the history
  • Loading branch information
gWestenberger committed Dec 13, 2024
1 parent e383884 commit daa00fa
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 13 deletions.
60 changes: 47 additions & 13 deletions src/org/opencms/ui/apps/modules/CmsModuleApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@
import com.vaadin.navigator.View;
import com.vaadin.server.Resource;
import com.vaadin.ui.Component;
import com.vaadin.ui.UI;
import com.vaadin.ui.Window;
import com.vaadin.ui.themes.ValoTheme;
import com.vaadin.v7.ui.TextField;

/**
* Main module manager app class.<p>
Expand Down Expand Up @@ -568,12 +570,37 @@ public static CmsMenuItemVisibilityMode visibilityCheckHasModule(String name) {
*/
public void editModule(String moduleName) {

StringBuilder searchFilterBuffer = new StringBuilder();
CmsVaadinUtils.visitDescendants(UI.getCurrent(), component -> {
if (component instanceof CmsModuleTable) {
TextField searchBox = ((CmsModuleTable)component).getSearchBox();
if (searchBox != null) {
searchFilterBuffer.append(searchBox.getValue());
}
return false;
} else {
return true;
}
});
String filter = searchFilterBuffer.toString();
CmsModule module = OpenCms.getModuleManager().getModule(moduleName);
editModule(
module,
false,
CmsVaadinUtils.getMessageText(Messages.GUI_MODULES_TITLE_EDIT_MODULE_1, module.getName()),
this::reload);
() -> {
reload();
// Setting the filter again is redundant for this class, but might be needed for subclasses, as the actual table instance may change
CmsVaadinUtils.visitDescendants(UI.getCurrent(), component -> {
if (component instanceof CmsModuleTable) {
((CmsModuleTable)component).getSearchBox().setValue(filter);
return false;
} else {
return true;
}
});

});
}

/**
Expand Down Expand Up @@ -741,19 +768,19 @@ protected Component getComponentForState(String state) {
} else if (state.equals(States.IMPORT_REPORT)
|| state.equals(States.DELETE_REPORT)
|| state.equals(States.EXPORT_REPORT)) {
String label = getReportLabel(state);
CmsBasicReportPage reportForm = new CmsBasicReportPage(label, m_reports.get(state), new Runnable() {
String label = getReportLabel(state);
CmsBasicReportPage reportForm = new CmsBasicReportPage(label, m_reports.get(state), new Runnable() {

public void run() {
public void run() {

openSubView("", true);
}
});
reportForm.setHeight("100%");
return reportForm;
} else {
return getModuleTable();
}
openSubView("", true);
}
});
reportForm.setHeight("100%");
return reportForm;
} else {
return getModuleTable();
}
}

/**
Expand Down Expand Up @@ -797,7 +824,14 @@ protected List<NavEntry> getSubNavEntries(String state) {
*/
protected void reload() {

A_CmsUI.get().reload();
CmsVaadinUtils.visitDescendants(UI.getCurrent(), component -> {
if (component instanceof CmsModuleTable) {
((CmsModuleTable)component).reload();
return false;
} else {
return true;
}
});

}

Expand Down
9 changes: 9 additions & 0 deletions src/org/opencms/ui/apps/modules/CmsModuleTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,15 @@ public void buttonClick(ClickEvent event) {
updateCounter();
}

/**
* Gets the search field.
*
* @return the search field
*/
public TextField getSearchBox() {
return m_searchBox;
}

/**
* Opens the import module dialog.<p>
*/
Expand Down

0 comments on commit daa00fa

Please sign in to comment.