This repository has been archived by the owner on Mar 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add main screen with side menu template based on Drawer #14
- Loading branch information
Timur Musin
committed
Jul 21, 2021
1 parent
a40cfc4
commit c8cc861
Showing
4 changed files
with
151 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,54 @@ | ||
package ${packageName}; | ||
|
||
import com.haulmont.cuba.gui.screen.UiController; | ||
import com.haulmont.cuba.gui.screen.UiDescriptor; | ||
import com.haulmont.cuba.web.app.main.MainScreen; | ||
<%if (classComment) {%> | ||
${classComment}<%}%> | ||
import io.jmix.ui.ScreenTools; | ||
import io.jmix.ui.component.AppWorkArea; | ||
import io.jmix.ui.component.Button; | ||
import io.jmix.ui.component.Window; | ||
import io.jmix.ui.component.mainwindow.Drawer; | ||
import io.jmix.ui.icon.JmixIcon; | ||
import io.jmix.ui.navigation.Route; | ||
import io.jmix.ui.screen.Screen; | ||
import io.jmix.ui.screen.Subscribe; | ||
import io.jmix.ui.screen.UiController; | ||
import io.jmix.ui.screen.UiControllerUtils; | ||
import io.jmix.ui.screen.UiDescriptor; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
@UiController("${id}") | ||
@UiDescriptor("${descriptorName}.xml") | ||
public class ${controllerName} extends MainScreen { | ||
@Route(path = "main", root = true) | ||
public class ${controllerName} extends Screen implements Window.HasWorkArea { | ||
|
||
@Autowired | ||
private ScreenTools screenTools; | ||
|
||
@Autowired | ||
private AppWorkArea workArea; | ||
@Autowired | ||
private Drawer drawer; | ||
@Autowired | ||
private Button collapseDrawerButton; | ||
|
||
@Override | ||
public AppWorkArea getWorkArea() { | ||
return workArea; | ||
} | ||
|
||
@Subscribe("collapseDrawerButton") | ||
private void onCollapseDrawerButtonClick(Button.ClickEvent event) { | ||
drawer.toggle(); | ||
if (drawer.isCollapsed()) { | ||
collapseDrawerButton.setIconFromSet(JmixIcon.CHEVRON_RIGHT); | ||
} else { | ||
collapseDrawerButton.setIconFromSet(JmixIcon.CHEVRON_LEFT); | ||
} | ||
} | ||
|
||
@Subscribe | ||
public void onAfterShow(AfterShowEvent event) { | ||
screenTools.openDefaultScreen( | ||
UiControllerUtils.getScreenContext(this).getScreens()); | ||
|
||
screenTools.handleRedirect(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,53 @@ | ||
package ${packageName} | ||
|
||
import com.haulmont.cuba.gui.screen.UiController | ||
import com.haulmont.cuba.gui.screen.UiDescriptor | ||
import com.haulmont.cuba.web.app.main.MainScreen | ||
<%if (classComment) {%> | ||
${classComment}<%}%> | ||
import io.jmix.ui.ScreenTools | ||
import io.jmix.ui.component.AppWorkArea | ||
import io.jmix.ui.component.Button | ||
import io.jmix.ui.component.Window.HasWorkArea | ||
import io.jmix.ui.component.mainwindow.Drawer | ||
import io.jmix.ui.icon.JmixIcon | ||
import io.jmix.ui.navigation.Route | ||
import io.jmix.ui.screen.* | ||
import org.springframework.beans.factory.annotation.Autowired | ||
|
||
@UiController("${api.escapeKotlinDollar(id)}") | ||
@UiController("${id}") | ||
@UiDescriptor("${descriptorName}.xml") | ||
class ${controllerName} : MainScreen() | ||
@Route(path = "main", root = true) | ||
open class ${controllerName} : Screen(), HasWorkArea { | ||
|
||
@Autowired | ||
private lateinit var screenTools: ScreenTools | ||
|
||
@Autowired | ||
private lateinit var workArea: AppWorkArea | ||
|
||
@Autowired | ||
private lateinit var drawer: Drawer | ||
|
||
@Autowired | ||
private lateinit var collapseDrawerButton: Button | ||
|
||
override fun getWorkArea(): AppWorkArea = workArea | ||
|
||
@Subscribe("collapseDrawerButton") | ||
private fun onCollapseDrawerButtonClick(event: Button.ClickEvent) { | ||
drawer.run { | ||
toggle() | ||
if (isCollapsed) { | ||
collapseDrawerButton.setIconFromSet(JmixIcon.CHEVRON_RIGHT) | ||
} else { | ||
collapseDrawerButton.setIconFromSet(JmixIcon.CHEVRON_LEFT) | ||
} | ||
} | ||
} | ||
|
||
@Subscribe | ||
fun onAfterShow(event: AfterShowEvent?) { | ||
screenTools.run { | ||
openDefaultScreen( | ||
UiControllerUtils.getScreenContext(this@${controllerName}).screens | ||
) | ||
handleRedirect() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters