List of usage examples for com.google.gwt.user.client.ui MenuBar addItem
public MenuItem addItem(String text, MenuBar popup)
From source file:org.drools.guvnor.client.ruleeditor.DefaultMultiViewEditorMenuBarCreator.java
License:Apache License
public MenuBar createMenuBar(final MultiViewEditor editor) { MenuBar toolbar = new MenuBar(); toolbar.addItem(constants.SaveAllChanges(), new Command() { public void execute() { editor.checkin(false);/*w w w. j ava 2 s.c o m*/ } }); toolbar.addItem(constants.SaveAndCloseAll(), new Command() { public void execute() { editor.checkin(true); } }); return toolbar; }
From source file:org.drools.guvnor.client.ruleeditor.standalone.RealAssetsMultiViewEditorMenuBarCreator.java
License:Apache License
@Override public MenuBar createMenuBar(final MultiViewEditor editor) { MenuBar toolbar = super.createMenuBar(editor); toolbar.addItem(constants.Cancel(), this.cancelCommand); return toolbar; }
From source file:org.drools.guvnor.client.ruleeditor.standalone.TemporalAssetsMultiViewEditorMenuBarCreator.java
License:Apache License
/** * Creates a menu bar with 2 buttons: "Done" and "Cancel". Because this is * meant for temporal rules, this toolbar doesn't check-in any asset. The * buttons just call doneCommand and cancelCommand respectively. * @param editor// w w w .j a va2 s . c om * @return */ public MenuBar createMenuBar(final MultiViewEditor editor) { MenuBar toolbar = new MenuBar(); toolbar.addItem(constants.Done(), doneCommand); toolbar.addItem(constants.Cancel(), cancelCommand); return toolbar; }
From source file:org.eclipse.swt.widgets.Control.java
License:Open Source License
private void buildMenuBar(Menu swtMenu, final MenuBar gwtMenuBar) { swtMenu.setVisible(true);/*from w ww. j a v a2 s . c o m*/ org.eclipse.swt.widgets.MenuItem[] items = swtMenu.getItems(); for (final org.eclipse.swt.widgets.MenuItem menuItem : items) { final String text = menuItem.getText(); final Menu subSwtMenu = menuItem.getMenu(); if (subSwtMenu != null) { final MenuBar subGwtMenuBar = new MenuBar(true); gwtMenuBar.addItem(text, subGwtMenuBar); subGwtMenuBar.addAttachHandler(new AttachEvent.Handler() { @Override public void onAttachOrDetach(AttachEvent event) { // invoke this only when the submenu is about being // shown: if (subSwtMenu.getItemCount() == 0) { buildMenuBar(subSwtMenu, subGwtMenuBar); } } }); } else if (text.isEmpty()) { gwtMenuBar.addSeparator(); } else { com.google.gwt.user.client.ui.MenuItem gwtMenuItem = new com.google.gwt.user.client.ui.MenuItem( text, new Command() { @Override public void execute() { menuItem.setSelection(true); closeMenu(gwtMenuBar); } }); gwtMenuItem.setEnabled(menuItem.isEnabled()); gwtMenuBar.addItem(gwtMenuItem); } } }
From source file:org.eobjects.datacleaner.monitor.scheduling.widgets.CustomizeAlertClickHandler.java
License:Open Source License
@Override public void onClick(ClickEvent event) { final MenuBar menuBar = new MenuBar(true); menuBar.addItem("Edit alert", new Command() { @Override/*from w w w. j a v a 2 s . c om*/ public void execute() { final DCPopupPanel popup = new DCPopupPanel("Edit alert"); final TenantIdentifier tenant = _alertPanel.getSchedule().getTenant(); final JobIdentifier job = _alertPanel.getSchedule().getJob(); final AlertDefinition alert = _alertPanel.getAlert(); descriptorService.getJobMetrics(tenant, job, new DCAsyncCallback<JobMetrics>() { @Override public void onSuccess(JobMetrics jobMetrics) { final CustomizeAlertPanel customizeAlertPanel = new CustomizeAlertPanel(tenant, job, alert, jobMetrics); final Button button = new Button("Save alert"); button.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { customizeAlertPanel.updateAlert(); _alertPanel.updateAlert(); popup.hide(); } }); popup.setWidget(customizeAlertPanel); popup.addButton(button); popup.addButton(new CancelPopupButton(popup)); popup.center(); popup.show(); } }); } }); menuBar.addItem("Remove alert", new Command() { @Override public void execute() { _alertPanel.removeAlert(); } }); final DCPopupPanel popup = new DCPopupPanel(null); popup.setGlassEnabled(false); popup.setWidget(menuBar); popup.setAutoHideEnabled(true); popup.getButtonPanel().setVisible(false); popup.showRelativeTo((UIObject) event.getSource()); }
From source file:org.eobjects.datacleaner.monitor.scheduling.widgets.CustomizeJobClickHandler.java
License:Open Source License
@Override public void onClick(ClickEvent event) { final JobIdentifier job = _schedulePanel.getSchedule().getJob(); final MenuBar menuBar = new MenuBar(true); menuBar.addItem("Rename job", new Command() { @Override//www .ja va2 s .c o m public void execute() { final String newName = Window.prompt("Enter job name", job.getName()); if (newName == null || newName.trim().length() == 0 || newName.equals(job.getName())) { return; } final DCPopupPanel popup = new DCPopupPanel("Renaming..."); popup.setWidget(new LoadingIndicator()); popup.center(); popup.show(); final String url = Urls.createRepositoryUrl(_tenant, "jobs/" + job.getName() + ".modify"); final JSONObject payload = new JSONObject(); payload.put("name", new JSONString(newName)); final DCRequestBuilder requestBuilder = new DCRequestBuilder(RequestBuilder.POST, url); requestBuilder.setHeader("Content-Type", "application/json"); requestBuilder.send(payload.toString(), new DCRequestCallback() { @Override protected void onSuccess(Request request, Response response) { Window.Location.reload(); } @Override public void onNonSuccesfullStatusCode(Request request, Response response, int statusCode, String statusText) { popup.hide(); ErrorHandler.showErrorDialog(response.getText()); } }); } }); menuBar.addItem("Copy job", new Command() { @Override public void execute() { final String newJobName = Window.prompt("Enter new job name", job.getName() + " (Copy)"); if (newJobName == null || newJobName.trim().length() == 0 || newJobName.equals(job.getName())) { return; } final DCPopupPanel popup = new DCPopupPanel("Copying..."); popup.setWidget(new LoadingIndicator()); popup.center(); popup.show(); final String url = Urls.createRepositoryUrl(_tenant, "jobs/" + job.getName() + ".copy"); final JSONObject payload = new JSONObject(); payload.put("name", new JSONString(newJobName)); final DCRequestBuilder requestBuilder = new DCRequestBuilder(RequestBuilder.POST, url); requestBuilder.setHeader("Content-Type", "application/json"); requestBuilder.send(payload.toString(), new DCRequestCallback() { @Override protected void onSuccess(Request request, Response response) { Window.Location.reload(); } }); } }); menuBar.addItem("Delete job", new Command() { @Override public void execute() { boolean delete = Window.confirm("Are you sure you want to delete the job '" + job.getName() + "' and related schedule, results and timelines."); if (delete) { final String url = Urls.createRepositoryUrl(_tenant, "jobs/" + job.getName() + ".delete"); final DCRequestBuilder requestBuilder = new DCRequestBuilder(RequestBuilder.POST, url); requestBuilder.setHeader("Content-Type", "application/json"); requestBuilder.send("", new DCRequestCallback() { @Override protected void onSuccess(Request request, Response response) { Window.Location.reload(); } }); } } }); final boolean analysisJob = JobIdentifier.JOB_TYPE_ANALYSIS_JOB.equals(job.getType()); if (analysisJob) { menuBar.addSeparator(); menuBar.addItem("Job definition (xml)", new Command() { @Override public void execute() { String url = Urls.createRepositoryUrl(_tenant, "jobs/" + job.getName() + ".analysis.xml"); Window.open(url, "datacleaner_job_details", null); _popup.hide(); } }); menuBar.addItem("Show latest result", new Command() { @Override public void execute() { String url = Urls.createRepositoryUrl(_tenant, "results/" + job.getName() + "-latest.analysis.result.dat"); Window.open(url, "datacleaner_job_details", null); _popup.hide(); } }); } _popup.setWidget(menuBar); _popup.showRelativeTo((UIObject) event.getSource()); }
From source file:org.freemedsoftware.gwt.client.screen.PatientScreen.java
License:Open Source License
public PatientScreen() { super(moduleName); final VerticalPanel verticalPanel = new VerticalPanel(); initWidget(verticalPanel);/*from w w w. j a va 2s . com*/ verticalPanel.setSize("100%", "100%"); patientInfoBar = new PatientInfoBar(); patientInfoBar.setParentScreen(this); verticalPanel.add(patientInfoBar); { final MenuBar menuBar = new MenuBar(); verticalPanel.add(menuBar); boolean menuItemAdded = false; final MenuBar menuBar_1 = new MenuBar(true); if (CurrentState.isActionAllowed(AllergyEntryScreen.moduleName, AppConstants.WRITE)) { menuBar_1.addItem(_("Allergy"), new Command() { public void execute() { AllergyEntryScreen allergyEntryScreen = new AllergyEntryScreen(); Util.spawnTabPatient(_("Allergy"), allergyEntryScreen, getObject()); allergyEntryScreen.populate(); } }); menuItemAdded = true; } if (true) { menuBar_1.addItem(_("Drug Sample"), new Command() { public void execute() { Util.spawnTabPatient(_("Drug Sample"), new DrugSampleEntry(), getObject()); } }); menuItemAdded = true; } if (true) { menuBar_1.addItem(_("Episode of Care"), new Command() { public void execute() { EpisodeOfCareScreen eoc = new EpisodeOfCareScreen(); Util.spawnTabPatient(_("Episode of Care"), eoc, getObject()); eoc.loadData(); } }); menuItemAdded = true; } if (true) { menuBar_1.addItem(_("Encounter/Progress Notes"), new Command() { public void execute() { EncounterScreen ens = new EncounterScreen(); Util.spawnTabPatient(_("Encounter/Progress Notes"), ens, getObject()); ens.laodData(); } }); menuItemAdded = true; } if (true) { menuBar_1.addItem(_("Foreign ID"), new Command() { public void execute() { Util.spawnTabPatient(_("Foreign ID"), new PatientIdEntry(), getObject()); } }); menuItemAdded = true; } if (true) { menuBar_1.addItem(_("Form"), new Command() { public void execute() { Util.spawnTabPatient(_("Form"), new FormEntry(), getObject()); } }); menuItemAdded = true; } if (true) { menuBar_1.addItem(_("Immunization"), new Command() { public void execute() { Util.spawnTabPatient(_("Immunization"), new ImmunizationEntry(), getObject()); } }); menuItemAdded = true; } if (true) { menuBar_1.addItem(_("Letter"), new Command() { public void execute() { Util.spawnTabPatient(_("Letter"), new LetterEntry(), getObject()); } }); menuItemAdded = true; } if (true) { menuBar_1.addItem(_("Patient Correspondence"), new Command() { public void execute() { Util.spawnTabPatient(_("Patient Correspondence"), new PatientCorrespondenceEntry(), getObject()); } }); menuItemAdded = true; } if (true) { menuBar_1.addItem(_("Patient Link"), new Command() { public void execute() { Util.spawnTabPatient(_("Patient Link"), new PatientLinkEntry(), getObject()); } }); menuItemAdded = true; } if (true) { menuBar_1.addItem(_("Progress Note"), new Command() { public void execute() { Util.spawnTabPatient(_("Progress Note"), new ProgressNoteEntry(), getObject()); } }); menuItemAdded = true; } if (CurrentState.isActionAllowed(PrescriptionsScreen.moduleName, AppConstants.WRITE)) { menuBar_1.addItem(_("Prescription"), new Command() { public void execute() { Util.spawnTabPatient(_("Prescription"), new PrescriptionsScreen(), getObject()); } }); menuItemAdded = true; } if (true) { menuBar_1.addItem(_("Referral"), new Command() { public void execute() { Util.spawnTabPatient(_("Referral"), new ReferralEntry(), getObject()); } }); menuItemAdded = true; } if (true) { menuBar_1.addItem(_("Vitals"), new Command() { public void execute() { Util.spawnTabPatient(_("Vitals"), new VitalsEntry(), getObject()); } }); menuItemAdded = true; } if (true) { menuBar_1.addItem(_("Scanned Documents"), new Command() { public void execute() { ScannedDocumentsEntryScreen scannedDocumentsEntryScreen = new ScannedDocumentsEntryScreen(); Util.spawnTabPatient(_("Scanned Documents"), scannedDocumentsEntryScreen, getObject()); scannedDocumentsEntryScreen.populateAvailableData(); } }); menuItemAdded = true; } if (menuItemAdded) menuBar.addItem(_("New"), menuBar_1); menuItemAdded = false; final MenuBar menuBar_2 = new MenuBar(true); if (CurrentState.isActionAllowed(ProcedureScreen.moduleName, AppConstants.SHOW)) { menuBar_2.addItem(_("Manage Procedures"), new Command() { public void execute() { ProcedureScreen ps = new ProcedureScreen(); Util.spawnTabPatient(_("Manage Procedures"), ps, getObject()); ps.loadData(); } }); menuItemAdded = true; } if (true) { menuBar_2.addItem(_("Payment"), new Command() { public void execute() { AdvancePayment ap = new AdvancePayment(); Util.spawnTabPatient(_("Payment"), ap, getObject()); ap.loadUI(); } }); menuItemAdded = true; } if (CurrentState.isActionAllowed(PatientReportingScreen.moduleName, AppConstants.SHOW)) { menuBar_2.addItem(_("Patient Reporting"), new Command() { public void execute() { Util.spawnTabPatient(_("Patient Reporting"), new PatientReportingScreen(), getObject()); } }); menuItemAdded = true; } menuBar_2.addItem(_("Billing/Payment"), (Command) null); if (true) { menuBar_2.addItem(_("Growth Charts"), new Command() { public void execute() { GrowthChartScreen growthChartScreen = new GrowthChartScreen(); JsonUtil.debug("Calling growth charts with ptsex = " + patientInfo.get("ptsex")); growthChartScreen.setGender(patientInfo.get("ptsex")); growthChartScreen.setBirthDate(Util.sqlToDate(patientInfo.get("ptdob"))); growthChartScreen.init(); Util.spawnTabPatient(_("Growth Charts"), growthChartScreen, getObject()); } }); menuItemAdded = true; } menuBar_2.addItem(_("Trending"), (Command) null); menuBar.addItem(_("Reporting"), menuBar_2); } final VerticalPanel verticalPanel_1 = new VerticalPanel(); verticalPanel.add(verticalPanel_1); verticalPanel_1.setSize("100%", "100%"); tabPanel = new TabPanel(); verticalPanel_1.add(tabPanel); summaryScreen = new SummaryScreen(); tabPanel.add(summaryScreen, _("Summary")); summaryScreen.assignPatientScreen(getObject()); addChildWidget(summaryScreen); tabPanel.selectTab(0); tabPanel.addSelectionHandler(new SelectionHandler<Integer>() { @Override public void onSelection(SelectionEvent<Integer> arg0) { if (tabPanel.getWidget(arg0.getSelectedItem()) instanceof ScreenInterface) { ScreenInterface screenInterface = ((ScreenInterface) tabPanel .getWidget(arg0.getSelectedItem())); String className = screenInterface.getClass().getName(); className = className.substring(className.lastIndexOf('.') + 1); CurrentState.assignCurrentPageHelp(className); } } }); }
From source file:org.gwtportlets.portlet.client.edit.LayoutPanelEditor.java
License:Open Source License
public void createMenuItems(final PageEditor manager, MenuBar bar, final Widget widget) { super.createMenuItems(manager, bar, widget); bar.addItem("Edit Container...", new Command() { public void execute() { manager.displayEditWidgetDialog(widget, new LayoutPanelDialog((LayoutPanel) widget)); }//w ww. j a v a 2 s .co m }).setTitle("Edit container settings"); }
From source file:org.gwtportlets.portlet.client.edit.PageEditor.java
License:Open Source License
/** * Add menu items appropriate to editor and widget to bar. Note that * widget may be null but editor will never be null. *///from w w w . j av a2 s. c o m private void buildEditorMenuItems(final LayoutEditor editor, final Widget widget, MenuBar bar) { if (widget != null && editor.isEditConstraints(widget)) { bar.addItem("Edit Constraints...", new Command() { public void execute() { hideOtherResizers(widget); beginUndo("Edit " + getWidgetDescription(widget) + " Constraints"); editor.editConstraints(widget, new ValueChangeHandler() { public void onValueChange(ValueChangeEvent event) { onConstraintsChanged(widget); } }, editDialogClosed); } }).setTitle("Edit widget layout constraints"); } editor.createMenuItems(widget, bar); if (widget != null) { bar.addItem("Pickup", new Command() { public void execute() { pickupWidget(editor, widget); } }).setTitle("Pickup the widget (and click to drop it somewhere)"); bar.addItem("Delete...", new Command() { public void execute() { deleteWidget(editor, widget); } }).setTitle("Remove the widget"); bar.addItem("Replace With", buildReplaceWithMenu(widget)); WidgetEditor we = getWidgetEditorFor(widget); if (we != null) { we.createMenuItems(this, bar, widget); } } bar.addItem("Parent Container", buildParentMenu(editor)); }
From source file:org.gwtportlets.portlet.client.edit.PageEditor.java
License:Open Source License
/** * Build a menu of container specific menu items for the container * belonging to editor for the 'Parent >' menu. * * @see org.gwtportlets.portlet.client.edit.LayoutEditor#getContainer() *///from ww w. j av a2 s . c o m private MenuBar buildParentMenu(final LayoutEditor editor) { MenuBar bar = createMenuBar(true); final Container con = editor.getContainer(); if (editor.isEditLayout()) { bar.addItem("Edit Layout...", new Command() { public void execute() { hideOtherResizers(con); raiseOverlay(); moveIndicator(heldIndicator, (Widget) con); beginUndo("Edit " + getWidgetDescription((Widget) con) + " Layout"); editor.editLayout(editDialogClosed); } }).setTitle("Edit container layout settings"); } MenuBar changeTo = buildChangeContainerToMenu(con); if (changeTo != null) { bar.addItem("Change To", changeTo).setTitle("Convert this container into a different container"); } WidgetEditor we = getWidgetEditorFor((Widget) con); if (we != null) { we.createMenuItems(this, bar, (Widget) con); } return bar; }