BrightSide Workbench Full Report + Source Code
PublicationMenu.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package org.turro.publication.zul.menu;
19 
20 import org.turro.annotation.ExternalMenu;
21 import org.turro.elephant.zkoss.Modal;
22 import org.turro.i18n.I_;
23 import org.turro.menu.ElephantMenu;
24 import org.turro.menu.ElephantMenuBar;
25 import org.turro.publication.entity.Publication;
26 import org.turro.publication.zul.portal.PublicationContent;
27 import org.turro.security.Permission;
28 import org.turro.zul.frame.Framework;
29 import org.zkoss.zk.ui.event.Event;
30 import org.zkoss.zk.ui.event.EventListener;
31 
37 public class PublicationMenu extends ElephantMenu {
38 
39  @Override
40  public void addToMenu(ElephantMenuBar bar) {
41  bar.addMenu("Publications", Permission.from("publication:list"))
42  .addSubmenu()
43  .addMenuitem("My subscriptions", "subscription", "/mail/notifications.zul", true)
45  .addMenuitem("My publications", "publication", "/publication/publications.zul", true, Permission.from("publication:list"))
46  .addMenuitem("Newsletters", "newsletter", "/publication/newsletters.zul", true, Permission.from("publication:list"))
47  .addMenuitem("Repository", "/publication/repository.zul", Permission.from("editor:repository"))
49  .addMenuitem("Categories", "/publication/categories.zul", Permission.from("publication-category:list"))
50  .addMenuitem("Subscriptors", "/mail/subscribers.zul", Permission.from("publication-category:list"))
51  .addMenuitem("Bloggers", "/publication/bloggers.zul", Permission.from("publication-category:list"))
52  .addMenuitem("Groups", "/publication/groups.zul", Permission.from("publication-group:list"))
53  .addMenuitem("Pending to accept", "/publication/pending.zul", Permission.from("publication:accept"))
55  .addMenuitem("New publication", (EventListener) (Event event) -> {
57  }, Permission.from("publication:new"))
58  .addMenuitem("New newsletter", (EventListener) (Event event) -> {
60  }, Permission.from("publication:new"))
61  .addToolbarSeparator(true);
62  }
63 
64  public static void showPublication(Long id) {
65  showEntity(id, "publicationId", "Publication", "/publication/publication.zul");
66  }
67 
68  public static void previewPublication(Publication publication) throws InterruptedException {
69  Framework frame = Framework.getCurrent();
70  if(publication != null) {
72  pc.setPage(frame.getPage());
73  pc.setMode("modal");
74  pc.setBorder("normal");
75  pc.setTitle(I_.get("Preview"));
76  pc.setClosable(true);
77  pc.setSizable(true);
78  pc.setMaximizable(true);
79  pc.setWidth("700px");
80  pc.setHeight("600px");
81  pc.setPublication(publication);
82  pc.setMaximized(false);
83  Modal.doModal(pc, null);
84  }
85  }
86 
87  public static void previewPublication(String publication) throws InterruptedException {
88  Framework frame = Framework.getCurrent();
89  if(publication != null) {
91  pc.setPage(frame.getPage());
92  pc.setMode("modal");
93  pc.setBorder("normal");
94  pc.setTitle(I_.get("Preview"));
95  pc.setClosable(true);
96  pc.setSizable(true);
97  pc.setMaximizable(true);
98  pc.setWidth("700px");
99  pc.setHeight("600px");
100  pc.setPublication(publication);
101  pc.setMaximized(false);
102  Modal.doModal(pc, null);
103  }
104  }
105 
106  public static void showPending() {
107  showZulFile("Pending to accept", "/publication/pending.zul");
108  }
109 
110  public static void showNewsletter(Long id) {
111  showEntity(id, "newsletterId", "Newsletter", "/publication/newsletter.zul");
112  }
113 
114 }
static int doModal(String file)
Definition: Modal.java:38
static String get(String msg)
Definition: I_.java:41
ElephantMenu addMenu(String label)
static void showEntity(Object id, String attribute, String label, String include)
ElephantSubmenu addSubmenu()
static void showZulFile(String label, String include)
ElephantSubmenu addMenuitem(String label, String include)
ElephantSubmenu addToolbarSeparator(boolean bar)
static void previewPublication(Publication publication)
static void previewPublication(String publication)
static Permission from(String... roles)
Definition: Permission.java:79
static Framework getCurrent()
Definition: Framework.java:203