use of com.haulmont.cuba.gui.components.mainwindow.FoldersPane in project cuba by cuba-platform.
the class WebFilterHelper method getFoldersPane.
@Override
public Object getFoldersPane() {
Window.TopLevelWindow topLevelWindow = AppUI.getCurrent().getTopLevelWindow();
FoldersPane foldersPane = null;
if (topLevelWindow instanceof Window.HasFoldersPane) {
foldersPane = ((Window.HasFoldersPane) topLevelWindow).getFoldersPane();
}
if (foldersPane == null) {
return null;
}
return foldersPane.unwrap(CubaFoldersPane.class);
}
use of com.haulmont.cuba.gui.components.mainwindow.FoldersPane in project cuba by cuba-platform.
the class WebWindowManager method createTopLevelWindow.
public void createTopLevelWindow(WindowInfo windowInfo) {
ui.beforeTopLevelWindowInit();
String template = windowInfo.getTemplate();
Window.TopLevelWindow topLevelWindow;
Map<String, Object> params = Collections.emptyMap();
if (template != null) {
// noinspection unchecked
topLevelWindow = (Window.TopLevelWindow) createWindow(windowInfo, OpenType.NEW_TAB, params, LayoutLoaderConfig.getWindowLoaders(), true);
} else {
Class screenClass = windowInfo.getScreenClass();
if (screenClass != null) {
// noinspection unchecked
topLevelWindow = (Window.TopLevelWindow) createWindowByScreenClass(windowInfo, params);
} else {
throw new DevelopmentException("Unable to load top level window");
}
}
// detect work area
Window windowImpl = ((Window.Wrapper) topLevelWindow).getWrappedWindow();
if (topLevelWindow instanceof AbstractMainWindow) {
AbstractMainWindow mainWindow = (AbstractMainWindow) topLevelWindow;
// bind system UI components to AbstractMainWindow
ComponentsHelper.walkComponents(windowImpl, component -> {
if (component instanceof AppWorkArea) {
mainWindow.setWorkArea((AppWorkArea) component);
} else if (component instanceof UserIndicator) {
mainWindow.setUserIndicator((UserIndicator) component);
} else if (component instanceof FoldersPane) {
mainWindow.setFoldersPane((FoldersPane) component);
}
return false;
});
}
ui.setTopLevelWindow(topLevelWindow);
// load menu
ComponentsHelper.walkComponents(windowImpl, component -> {
if (component instanceof TopLevelWindowAttachListener) {
((TopLevelWindowAttachListener) component).topLevelWindowAttached(topLevelWindow);
}
return false;
});
if (topLevelWindow instanceof Window.HasWorkArea) {
AppWorkArea workArea = ((Window.HasWorkArea) topLevelWindow).getWorkArea();
if (workArea != null) {
workArea.addStateChangeListener(new AppWorkArea.StateChangeListener() {
@Override
public void stateChanged(AppWorkArea.State newState) {
if (newState == AppWorkArea.State.WINDOW_CONTAINER) {
initTabShortcuts();
// listener used only once
getConfiguredWorkArea(createWorkAreaContext(topLevelWindow)).removeStateChangeListener(this);
}
}
});
}
}
afterShowWindow(topLevelWindow);
}
use of com.haulmont.cuba.gui.components.mainwindow.FoldersPane in project cuba by cuba-platform.
the class WebFilterHelper method saveFolder.
@Override
@Nullable
public AbstractSearchFolder saveFolder(AbstractSearchFolder folder) {
Window.TopLevelWindow topLevelWindow = AppUI.getCurrent().getTopLevelWindow();
FoldersPane foldersPane = null;
if (topLevelWindow instanceof Window.HasFoldersPane) {
foldersPane = ((Window.HasFoldersPane) topLevelWindow).getFoldersPane();
}
if (foldersPane == null)
return null;
CubaFoldersPane foldersPaneImpl = foldersPane.unwrap(CubaFoldersPane.class);
AbstractSearchFolder savedFolder = (AbstractSearchFolder) foldersPaneImpl.saveFolder(folder);
foldersPaneImpl.refreshFolders();
return savedFolder;
}
use of com.haulmont.cuba.gui.components.mainwindow.FoldersPane in project cuba by cuba-platform.
the class WebFilterHelper method removeFolderFromFoldersPane.
@Override
public void removeFolderFromFoldersPane(Folder folder) {
Window.TopLevelWindow topLevelWindow = AppUI.getCurrent().getTopLevelWindow();
FoldersPane foldersPane = null;
if (topLevelWindow instanceof Window.HasFoldersPane) {
foldersPane = ((Window.HasFoldersPane) topLevelWindow).getFoldersPane();
}
if (foldersPane == null) {
return;
}
CubaFoldersPane foldersPaneImpl = foldersPane.unwrap(CubaFoldersPane.class);
foldersPaneImpl.removeFolder(folder);
foldersPaneImpl.refreshFolders();
}
Aggregations