com.google.gwt.user.client.ui.MenuItem Java Examples

The following examples show how to use com.google.gwt.user.client.ui.MenuItem. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FindToolBarMenu.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
/**
 * ResizeToolBarMenu
 */
public FindToolBarMenu() {
	// Establishes auto-close when click outside
	super(true, true);
	toolBarOption = new ToolBarOption();

	dirMenu = new MenuBar(true);
	dirMenu.setStyleName("okm-SubMenuBar");
	findFolder = new MenuItem(Util.menuHTML("img/icon/actions/folder_find.gif", Main.i18n("general.menu.file.find.folder")), true, findFolderOKM);
	findDocument = new MenuItem(Util.menuHTML("img/icon/actions/document_find.png", Main.i18n("general.menu.file.find.document")), true, findDocumentOKM);
	findSimilarDocument = new MenuItem(Util.menuHTML("img/icon/actions/similar_find.png", Main.i18n("general.menu.file.find.similar.document")), true, findSimilarOKM);

	dirMenu.addItem(findFolder);
	dirMenu.addItem(findDocument);
	dirMenu.addItem(findSimilarDocument);

	setWidget(dirMenu);
}
 
Example #2
Source File: Menu.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Browser menu
 */
public Menu() {
	// The item selected must be called on style.css : .okm-MenuBar .gwt-MenuItem-selected

	// First initialize language values
	searchMenu = new MenuBar(true);
	download = new MenuItem(Util.menuHTML("img/icon/actions/download.gif", Main.i18n("search.result.menu.download")), true, downloadFile);
	download.addStyleName("okm-MenuItem");
	go = new MenuItem(Util.menuHTML("img/icon/actions/goto_folder.gif", Main.i18n("search.result.menu.go.folder")), true, goDirectory);
	go.addStyleName("okm-MenuItem");
	findSimilarDocument = new MenuItem(Util.menuHTML("img/icon/actions/similar_find.png", Main.i18n("general.menu.file.find.similar.document")), true, findSimilarOKM);
	findSimilarDocument.addStyleName("okm-MenuItem");

	searchMenu.addItem(download);
	searchMenu.addItem(go);
	searchMenu.addItem(findSimilarDocument);
	searchMenu.setStyleName("okm-MenuBar");

	initWidget(searchMenu);
}
 
Example #3
Source File: MailMenu.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
public MailMenu() {
	toolBarOption = new ToolBarOption();
	// The item selected must be called on style.css : .okm-MenuBar .gwt-MenuItem-selected

	// First initialize language values
	dirMenu = new MenuBar(true);
	create = new MenuItem(Util.menuHTML("img/icon/actions/add_folder.gif", Main.i18n("tree.menu.directory.create")), true, addFolder);
	create.addStyleName("okm-MenuItem");
	dirMenu.addItem(create);
	remove = new MenuItem(Util.menuHTML("img/icon/actions/delete.gif", Main.i18n("tree.menu.directory.remove")), true, delFolder);
	remove.addStyleName("okm-MenuItem-strike");
	dirMenu.addItem(remove);
	rename = new MenuItem(Util.menuHTML("img/icon/actions/rename.gif", Main.i18n("tree.menu.directory.rename")), true, renFolder);
	rename.addStyleName("okm-MenuItem-strike");
	dirMenu.addItem(rename);
	move = new MenuItem(Util.menuHTML("img/icon/actions/move_folder.gif", Main.i18n("tree.menu.directory.move")), true, moveFolder);
	move.addStyleName("okm-MenuItem");
	dirMenu.addItem(move);
	copy = new MenuItem(Util.menuHTML("img/icon/actions/copy.gif", Main.i18n("tree.menu.directory.copy")), true, copyFolder);
	copy.addStyleName("okm-MenuItem");
	dirMenu.addItem(copy);
	dirMenu.setStyleName("okm-MenuBar");
	initWidget(dirMenu);
}
 
Example #4
Source File: BaseWidgetMenuItemFactory.java    From EasyML with Apache License 2.0 6 votes vote down vote up
/**
 * Create StdoutItem
 * @param com
 * @return StdoutItem
 */
public static MenuItem createStdoutItem(HasRightMouseUpMenu com) {
	Command command = new MenuItemCommand(com) {

		@Override
		public void execute() {
			ProgramWidget widget = (ProgramWidget) this.component;
			MonitorController controller = (MonitorController) widget
					.getController();
			String oozJobId = widget.getAction().getJobId();
			String actionid = widget.getId();
			controller.getStdOut(oozJobId, actionid);
			widget.getContextMenu().hide();
		}

	};

	MenuItem item = new MenuItem("Show Stdout", command);
	return item;
}
 
Example #5
Source File: CategoriesMenu.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
public CategoriesMenu() {
	toolBarOption = new ToolBarOption();
	// The item selected must be called on style.css : .okm-MenuBar .gwt-MenuItem-selected

	// First initialize language values
	dirMenu = new MenuBar(true);
	create = new MenuItem(Util.menuHTML("img/icon/actions/add_folder.gif", Main.i18n("tree.menu.directory.create")), true, addFolder);
	create.addStyleName("okm-MenuItem");
	dirMenu.addItem(create);
	rename = new MenuItem(Util.menuHTML("img/icon/actions/rename.gif", Main.i18n("tree.menu.directory.rename")), true, renFolder);
	rename.addStyleName("okm-MenuItem-strike");
	dirMenu.addItem(rename);
	move = new MenuItem(Util.menuHTML("img/icon/actions/move_folder.gif", Main.i18n("tree.menu.directory.move")), true, moveFolder);
	move.addStyleName("okm-MenuItem");
	dirMenu.addItem(move);
	dirMenu.setStyleName("okm-MenuBar");
	export = new MenuItem(Util.menuHTML("img/icon/actions/export.gif", Main.i18n("tree.menu.export")), true, exportToFile);
	export.addStyleName("okm-MenuItem-strike");
	dirMenu.addItem(export);
	initWidget(dirMenu);
}
 
Example #6
Source File: ProgramUpdateMenu.java    From EasyML with Apache License 2.0 6 votes vote down vote up
public static MenuItem create(final ProgramLeaf node, final ProgramTree tree) {

		Command command = new MenuItemCommand(node) {

			@Override
			public void execute() {
				UpdateProgramPanel panel = new UpdateProgramPanel(tree,node);
				panel.show(node.getModule());
				this.component.getContextMenu().hide();
			}

		};

		MenuItem item = new MenuItem("Update", command);
		return item;
	}
 
Example #7
Source File: Menu.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Browser menu
 */
public Menu() {
	// The item selected must be called on style.css : .okm-MenuBar .gwt-MenuItem-selected

	// First initialize language values
	searchSavedMenu = new MenuBar(true);
	run = new MenuItem(Util.menuHTML("img/icon/actions/run.gif", Main.i18n("search.saved.run")), true, runSearch);
	run.addStyleName("okm-MenuItem");
	searchSavedMenu.addItem(run);
	delete = new MenuItem(Util.menuHTML("img/icon/actions/delete.gif", Main.i18n("search.saved.delete")), true, deleteSearch);
	delete.addStyleName("okm-MenuItem");
	searchSavedMenu.addItem(delete);
	share = new MenuItem(Util.menuHTML("img/icon/actions/share_query.gif", GeneralComunicator.i18nExtension("messaging.share.query")), true, shareSearch);
	share.addStyleName("okm-MenuItem");
	searchSavedMenu.addStyleName("okm-MenuBar");
	initWidget(searchSavedMenu);
}
 
Example #8
Source File: DropDownButton.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
public DropDownButton(String widgetName, Image icon, List<DropDownItem> toolbarItems,
                      boolean rightAlign) {
  super(icon);  // icon for button

  this.menu = new ContextMenu();
  this.items = new ArrayList<MenuItem>();
  this.rightAlign = rightAlign;

  for (DropDownItem item : toolbarItems) {
    if (item != null) {
      addItem(item);
    } else {
      menu.addSeparator();
    }
  }

  addClickHandler(new ClickHandler() {
    @Override
    public void onClick(ClickEvent event) {
      menu.setPopupPositionAndShow(new DropDownPositionCallback(getElement()));
    }
  });
}
 
Example #9
Source File: DropDownButton.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
public DropDownButton(String widgetName, String caption, List<DropDownItem> toolbarItems,
                      boolean rightAlign) {
  super(caption + " \u25BE ");  // drop down triangle

  this.menu = new ContextMenu();
  this.items = new ArrayList<MenuItem>();
  this.rightAlign = rightAlign;

  for (DropDownItem item : toolbarItems) {
    if (item != null) {
      this.items.add(menu.addItem(item.caption, true, item.command));
    } else {
      menu.addSeparator();
    }
  }

  addClickHandler(new ClickHandler() {
    @Override
    public void onClick(ClickEvent event) {
      menu.setPopupPositionAndShow(new DropDownPositionCallback(getElement()));
    }
  });
}
 
Example #10
Source File: BaseShapeMenuItemFactory.java    From EasyML with Apache License 2.0 6 votes vote down vote up
/**
 * Create data visualization popup menuitem
 * 
 * @param com
 * @return
 */
public static MenuItem createVisuallizeItem(HasRightMouseUpMenu com) {
	Command command = new MenuItemCommand(com) {
		@Override
		public void execute() {
			NodeShape nodeShape = (NodeShape) this.component;
			// If the node shape is output node shape
			if(nodeShape instanceof OutNodeShape) {
				OutNodeShape outShape  = (OutNodeShape) nodeShape;
				String fileId = outShape.getFileId();
				String path = outShape.getAbsolutePath();
				String fPath = path +"/"+fileId;
				DBController.showDataVisualPopup(fPath,fileId);
			}
			nodeShape.getContextMenu().hide();
		}
	};
	MenuItem item = new MenuItem("Visualization", command);
	return item;
}
 
Example #11
Source File: BaseShapeMenuItemFactory.java    From EasyML with Apache License 2.0 6 votes vote down vote up
/**
 * Create result preview popup menuitem
 * 
 * @param com
 * @return
 */
public static MenuItem createShowResultItem(HasRightMouseUpMenu com) {
	Command command = new MenuItemCommand(com) {
		@Override
		public void execute() {
			NodeShape nodeShape = (NodeShape) this.component;
			//If the shape node is output node shape
			if(nodeShape instanceof OutNodeShape) {
				OutNodeShape outShape  = (OutNodeShape) nodeShape;
				String fileId = outShape.getFileId();
				String path = outShape.getAbsolutePath();
				DBController.showPreviewPopup(path,fileId);
			}
			nodeShape.getContextMenu().hide();
		}
	};

	MenuItem item = new MenuItem("Results preview", command);
	return item;
}
 
Example #12
Source File: JobAddExampleMenu.java    From EasyML with Apache License 2.0 5 votes vote down vote up
public static MenuItem create(final JobLeaf node) {
	Command command = new MenuItemCommand(node) {

		@Override
		public void execute() {
			String id = node.getModule().getJobId();
			boolean y = Window.confirm("Are you sure you want to join the example task?");
			if (y) {
				JobServiceAsync srv = GWT.create(JobService.class);
				srv.setExampleJobs(id, new AsyncCallback<Void>() {

					@Override
					public void onFailure(Throwable caught) {
						Window.alert(caught.getMessage());
					}

					@Override
					public void onSuccess(Void result) {
						node.delete();
					}
				});
			}
			this.component.getContextMenu().hide();
		}
	};
	MenuItem item = new MenuItem("Join example task", command);
	return item;
}
 
Example #13
Source File: ContextMenu.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
/**
 * Adds a menu item to the context menu.
 *
 * @param text  caption of menu item
 * @param command   command to execute when menu item is chosen
 * @return  menu item
 */
public MenuItem addItem(String text, final Command command) {
  MenuItem menuItem = new MenuItem(text, new Command() {
    @Override
    public void execute() {
      hide();
      command.execute();
    }
  });
  menuItem.setStylePrimaryName("ode-ContextMenuItem");
  menuBar.addItem(menuItem);
  return menuItem;
}
 
Example #14
Source File: UniTimeTableHeader.java    From unitime with Apache License 2.0 5 votes vote down vote up
@Override
public MenuItem addItem(MenuItem item) {
	Character ch = UniTimeHeaderPanel.guessAccessKey(item.getHTML());
	if (ch != null)
		iAccessKeys.put(Character.toLowerCase(ch), item);
	item.getElement().getStyle().setCursor(Cursor.POINTER);
	return super.addItem(item);
}
 
Example #15
Source File: ProgramDeprecateMenu.java    From EasyML with Apache License 2.0 5 votes vote down vote up
public static MenuItem create(final ProgramLeaf node) {
	Command command = new MenuItemCommand(node) {
		@Override
		public void execute() {
			String id = node.getModule().getId();
			boolean y = Window.confirm("Are you ready to deprecate " + node.getModule().getName() + "?");
			if (y) {
				ProgramServiceAsync svc = GWT.create(ProgramService.class);
				svc.deprecate(id, new AsyncCallback<Void>() {

					@Override
					public void onFailure(Throwable caught) {
						Window.alert(caught.getMessage());
					}

					@Override
					public void onSuccess(Void result) {
						node.delete();
					}

				});
			}
			this.component.getContextMenu().hide();
		}

	};

	MenuItem item = new MenuItem("deprecate", command);
	return item;
}
 
Example #16
Source File: DatasetEditMenu.java    From EasyML with Apache License 2.0 5 votes vote down vote up
public static MenuItem create(final DatasetLeaf node, final DatasetTree tree) {

		Command command = new MenuItemCommand(node) {
			@Override
			public void execute() {
				EditDatasetPanel panel = new EditDatasetPanel(AppController.email,tree,node);

				panel.show(node.getModule());

				this.component.getContextMenu().hide();
			}
		};
		MenuItem item = new MenuItem("Edit", command);
		return item;
	}
 
Example #17
Source File: IntervalSelector.java    From unitime with Apache License 2.0 5 votes vote down vote up
public void scrollToView() {
	List<MenuItem> items = getItems();
	int index = getSelectedItemIndex();
	if (index > -1 && index < items.size()) {
		iPopupScroll.ensureVisible(items.get(index));
	}
}
 
Example #18
Source File: DropDownButton.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
public void removeItem(String itemName) {
  for (MenuItem item : items) {
    if (item.getText().equals(itemName)) {
      menu.removeItem(item);
      items.remove(item);
      break;
    }
  }
}
 
Example #19
Source File: Bookmark.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Resets all widgets on menu
 */
private void resetMenu() {
	if (!bookmarks.isEmpty()) {
		MenuBar subMenuBookmark = Main.get().mainPanel.topPanel.mainMenu.subMenuBookmark;

		for (Iterator<MenuItem> it = bookmarks.iterator(); it.hasNext(); ) {
			subMenuBookmark.removeItem(it.next());
		}
	}
}
 
Example #20
Source File: SuggestionMenu.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
@Override
public MenuItem addItem(SafeHtml title, final Command callback) {
  // TODO(danilatos): Make the titles line up
  //return super.addItem((index++) + ". " + title, callback);
  return super.addItem(new MenuItem(title.asString(), true, new Command() {

    @Override
    public void execute() {
      handler.beforeItemClicked();
      callback.execute();
      handler.handleItemSelected();
    }

  }){
    /**
     * Adding a hook so we can add our own type-safe style name to the
     * highlighted item, as opposed to the one they use, which is private
     * and not using style injector.
     */
    @Override
    protected void setSelectionStyle(boolean selected) {
      super.setSelectionStyle(selected);
      // TODO(user): remove the dependency to SpellSuggestion.resources
      if (selected) {
        getElement().addClassName(RESOURCES.css().hover());
      } else {
        getElement().removeClassName(RESOURCES.css().hover());
      }
    }
  });
}
 
Example #21
Source File: ContextMenu.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
/**
 * Adds a menu item to the context menu.
 *
 * @param text  caption of menu item
 * @param asHtml whether to treat text as html
 * @param command   command to execute when menu item is chosen
 * @return  menu item
 */
public MenuItem addItem(String text, boolean asHtml, final Command command) {
  MenuItem menuItem = new MenuItem(text, asHtml, new Command() {
    @Override
    public void execute() {
      hide();
      command.execute();
    }
  });
  menuItem.setStylePrimaryName("ode-ContextMenuItem");
  menuBar.addItem(menuItem);
  return menuItem;
}
 
Example #22
Source File: AriaSuggestBox.java    From unitime with Apache License 2.0 5 votes vote down vote up
public void scrollToView() {
	List<MenuItem> items = getItems();
	int index = getSelectedItemIndex();
	if (index > -1 && index < items.size()) {
		iPopupScroll.ensureVisible(items.get(index));
	}
}
 
Example #23
Source File: MainMenu.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * initAvailableLanguage
 */
public void initAvailableLanguage(List<GWTLanguage> langs) {
	for (final GWTLanguage lang : langs) {
		MenuItem menuItem = new MenuItem(Util.flagMenuHTML(lang.getId(), lang.getName()), true, new Command() {
			@Override
			public void execute() {
				Main.get().refreshLang(lang.getId());
			}
		});

		menuItem.addStyleName("okm-MainMenuItem");
		subMenuLanguage.addItem(menuItem);
	}
}
 
Example #24
Source File: Menu.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Browser menu
 */
public Menu() {
	// The item selected must be called on style.css : .okm-MenuBar .gwt-MenuItem-selected

	// First initialize language values
	menu = new MenuBar(true);

	delete = new MenuItem(UtilComunicator.menuHTML("img/icon/actions/delete.png", GeneralComunicator.i18nExtension("messaging.message.delete")), true, deletePropose);
	delete.addStyleName("okm-MenuItem");
	menu.addItem(delete);
	menu.setStyleName("okm-MenuBar");
	initWidget(menu);
}
 
Example #25
Source File: TimeSelector.java    From unitime with Apache License 2.0 5 votes vote down vote up
public int getSlot(int index) {
	List<MenuItem> items = getItems();
	if (index > -1 && index < items.size()) {
		return ((TimeMenuItem)items.get(index)).getSlot();
	} else {
		return -1;
	}
}
 
Example #26
Source File: Menu.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Browser menu
 */
public Menu() {
	// The item selected must be called on style.css : .okm-MenuBar .gwt-MenuItem-selected

	// First initialize language values
	menu = new MenuBar(true);

	delete = new MenuItem(UtilComunicator.menuHTML("img/icon/actions/delete.png", GeneralComunicator.i18nExtension("messaging.message.delete")), true, deleteMessageSent);
	delete.addStyleName("okm-MenuItem");
	menu.addItem(delete);
	menu.setStyleName("okm-MenuBar");
	initWidget(menu);
}
 
Example #27
Source File: Menu.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Browser menu
 */
public Menu() {
	// The item selected must be called on style.css : .okm-MenuBar .gwt-MenuItem-selected

	// First initialize language values
	menu = new MenuBar(true);

	delete = new MenuItem(UtilComunicator.menuHTML("img/icon/actions/delete.png", GeneralComunicator.i18nExtension("messaging.message.delete")), true, deletePropose);
	delete.addStyleName("okm-MenuItem");
	menu.addItem(delete);
	menu.setStyleName("okm-MenuBar");
	initWidget(menu);
}
 
Example #28
Source File: Menu.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Browser menu
 */
public Menu() {
	// The item selected must be called on style.css : .okm-MenuBar .gwt-MenuItem-selected

	// First initialize language values
	menu = new MenuBar(true);

	delete = new MenuItem(UtilComunicator.menuHTML("img/icon/actions/delete.png", GeneralComunicator.i18nExtension("messaging.message.delete")), true, deletePropose);
	delete.addStyleName("okm-MenuItem");
	menu.addItem(delete);
	menu.setStyleName("okm-MenuBar");
	initWidget(menu);
}
 
Example #29
Source File: MassiveOperationsMenu.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Category menu
 */
public MassiveOperationsMenu() {
	// The item selected must be called on style.css : .okm-MenuBar .gwt-MenuItem-selected

	// First initialize language values
	dirMenu = new MenuBar(true);
	selectAll = new MenuItem(Util.menuHTML("img/icon/actions/select_all.png", Main.i18n("filebrowser.menu.select.all")), true, massiveSelectAll);
	selectAll.addStyleName("okm-MenuItem-strike");
	dirMenu.addItem(selectAll);
	selectFolders = new MenuItem(Util.menuHTML("img/menuitem_empty.gif", Main.i18n("filebrowser.menu.select.all.folders")), true, massiveSelectFolders);
	selectFolders.addStyleName("okm-MenuItem-strike");
	dirMenu.addItem(selectFolders);
	selectDocuments = new MenuItem(Util.menuHTML("img/document.png", Main.i18n("filebrowser.menu.select.all.documents")), true, massiveSelectDocuments);
	selectDocuments.addStyleName("okm-MenuItem-strike");
	dirMenu.addItem(selectDocuments);
	selectMails = new MenuItem(Util.menuHTML("img/email.gif", Main.i18n("filebrowser.menu.select.all.mails")), true, massiveSelectMails);
	selectMails.addStyleName("okm-MenuItem-strike");
	dirMenu.addItem(selectMails);
	removeSelection = new MenuItem(Util.menuHTML("img/icon/actions/remove_all.png", Main.i18n("filebrowser.menu.remove.selection")), true, massiveRemoveSelection);
	removeSelection.addStyleName("okm-MenuItem-strike");
	dirMenu.addItem(removeSelection);
	dirMenu.setStyleName("okm-MenuBar");
	initWidget(dirMenu);

	enable(selectAll);
	enable(selectFolders);
	enable(selectDocuments);
	enable(selectMails);
}
 
Example #30
Source File: TrashMenu.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
public TrashMenu() {
	toolBarOption = new ToolBarOption();
	// The item selected must be called on style.css : .okm-MenuBar .gwt-MenuItem-selected

	// First initialize language values
	dirMenu = new MenuBar(true);
	restoreItem = new MenuItem(Util.menuHTML("img/icon/actions/restore.gif", Main.i18n("general.menu.file.restore")), true, restore);
	restoreItem.addStyleName("okm-MenuItem");
	dirMenu.addItem(restoreItem);
	purgeItem = new MenuItem(Util.menuHTML("img/icon/actions/purge.gif", Main.i18n("general.menu.file.purge")), true, purge);
	purgeItem.addStyleName("okm-MenuItem");
	dirMenu.addItem(purgeItem);
	dirMenu.addStyleName("okm-MenuBar");
	initWidget(dirMenu);
}