Java Code Examples for org.eclipse.swt.SWT#CASCADE

The following examples show how to use org.eclipse.swt.SWT#CASCADE . 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: EditorMenu.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @param menu
 */
private void createOtherExperiments(final Menu menu) {

	final MenuItem usedIn = new MenuItem(menu, SWT.CASCADE);
	usedIn.setText(" Other experiments...");
	usedIn.setImage(GamaIcons.create("other.experiments").image());
	final Menu sub = new Menu(usedIn);
	usedIn.setMenu(sub);
	sub.addListener(SWT.Show, e -> {
		for (final MenuItem item : sub.getItems()) {
			item.dispose();
		}
		createOtherSubMenu(sub, getEditor());
	});

}
 
Example 2
Source File: EditorMenu.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
public static Menu createOtherSubMenu(final Menu parentMenu, final GamlEditor editor) {
	final Map<URI, List<String>> map = grabProjectModelsAndExperiments(editor);
	if (map.isEmpty()) {
		final MenuItem nothing = new MenuItem(parentMenu, SWT.PUSH);
		nothing.setText("No experiments defined");
		nothing.setEnabled(false);
		return parentMenu;
	}
	for (final URI uri : map.keySet()) {
		final MenuItem modelItem = new MenuItem(parentMenu, SWT.CASCADE);
		modelItem.setText(URI.decode(uri.lastSegment()));
		modelItem.setImage(GamaIcons.create(IGamaIcons.FILE_ICON).image());
		final Menu expMenu = new Menu(modelItem);
		modelItem.setMenu(expMenu);
		final List<String> expNames = map.get(uri);
		for (final String name : expNames) {
			final MenuItem expItem = new MenuItem(expMenu, SWT.PUSH);
			expItem.setText(name);
			expItem.setData("uri", uri);
			expItem.setData("exp", name);
			expItem.setImage(GamaIcons.create(IGamaIcons.BUTTON_GUI).image());
			expItem.addSelectionListener(OtherAdapter);
		}
	}
	return parentMenu;
}
 
Example 3
Source File: AgentsMenu.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
private static MenuItem cascadingPopulationMenuItem(final Menu parent, final IAgent agent,
		final IPopulation<? extends IAgent> population, final Image image, final MenuAction... actions) {
	if (population instanceof SimulationPopulation) {
		fillPopulationSubMenu(parent, population, actions);
		return null;
	}
	final MenuItem result = new MenuItem(parent, SWT.CASCADE);
	// if ( population instanceof SimulationPopulation ) {
	// result.setText("Simulations");
	// } else {
	result.setText("Population of " + population.getName());
	// }
	result.setImage(image);
	final Menu agentsMenu = new Menu(result);
	result.setMenu(agentsMenu);
	fillPopulationSubMenu(agentsMenu, population, actions);
	return result;
}
 
Example 4
Source File: JframeApp.java    From jframe with Apache License 2.0 6 votes vote down vote up
/**
 * @return
 */
protected Menu createMenuBar() {
    Menu bar = new Menu(shell, SWT.BAR);
    // file
    MenuItem fileItem = new MenuItem(bar, SWT.CASCADE);
    fileItem.setText("&File");
    Menu submenu = new Menu(shell, SWT.DROP_DOWN);
    fileItem.setMenu(submenu);
    MenuItem item = new MenuItem(submenu, SWT.PUSH);
    item.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event e) {

        }
    });
    item.setText("Select &All\tCtrl+A");
    item.setAccelerator(SWT.MOD1 + 'A');
    // edit
    MenuItem editItem = new MenuItem(bar, SWT.CASCADE);
    editItem.setText("&Edit");
    // search
    MenuItem searchItem = new MenuItem(bar, SWT.CASCADE);
    searchItem.setText("&Search");
    return bar;
}
 
Example 5
Source File: EditorMenu.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
public static Menu createImportedSubMenu(final Menu parentMenu, final GamlEditor editor) {
	final Set<URI> importers = getImporters(editor);
	if (importers.isEmpty()) {
		final MenuItem nothing = new MenuItem(parentMenu, SWT.PUSH);
		nothing.setText("No importers");
		nothing.setEnabled(false);
		return parentMenu;
	}
	for (final URI uri : importers) {
		final MenuItem modelItem = new MenuItem(parentMenu, SWT.CASCADE);
		modelItem.setText(URI.decode(uri.lastSegment()));
		modelItem.setImage(GamaIcons.create(IGamaIcons.FILE_ICON).image());
		modelItem.setData("uri", uri);
		modelItem.addSelectionListener(UsedInAdapter);
	}
	return parentMenu;
}
 
Example 6
Source File: GamlReferenceMenu.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
public void installSubMenuIn(final Menu menu) {
	final MenuItem builtInItem = new MenuItem(menu, SWT.CASCADE);
	builtInItem.setText(getTitle());
	builtInItem.setImage(getImage());
	mainMenu = new Menu(builtInItem);
	builtInItem.setMenu(mainMenu);
	mainMenu.addListener(SWT.Show, e -> {
		if (mainMenu.getItemCount() > 0) {
			for (final MenuItem item : mainMenu.getItems()) {
				item.dispose();
			}
		}
		fillMenu();
	});

}
 
Example 7
Source File: TextEditorContextMenuContribution.java    From git-appraise-eclipse with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void fill(Menu menu, int index) {
  MenuItem submenuItem = new MenuItem(menu, SWT.CASCADE, index);
  submenuItem.setText("&Appraise Review Comments");
  Menu submenu = new Menu(menu);
  submenuItem.setMenu(submenu);

  MenuItem reviewCommentMenuItem = new MenuItem(submenu, SWT.CHECK);
  reviewCommentMenuItem.setText("New &Review Comment...");
  reviewCommentMenuItem.addSelectionListener(createReviewCommentSelectionListener());

  MenuItem fileCommentMenuItem = new MenuItem(submenu, SWT.CHECK);
  fileCommentMenuItem.setText("New &File Comment...");
  fileCommentMenuItem.addSelectionListener(createFileCommentSelectionListener());

  MenuItem fileLineCommentMenuItem = new MenuItem(submenu, SWT.CHECK);
  fileLineCommentMenuItem.setText("New &Line Comment...");
  fileLineCommentMenuItem.addSelectionListener(createFileLineCommentSelectionListener());

  // Can only add Appraise comments if there is an active Appraise review task.
  ITask activeTask = TasksUi.getTaskActivityManager().getActiveTask();
  submenuItem.setEnabled(activeTask != null
      && AppraiseTaskMapper.APPRAISE_REVIEW_TASK_KIND.equals(activeTask.getTaskKind()));
}
 
Example 8
Source File: BuildSupplyChainMenuAction.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void createItem(Menu menu, IBuildAction action) {
	MenuItem item = new MenuItem(menu, SWT.CASCADE);
	item.setText(action.getText());
	Menu subMenu = new Menu(item);
	createSubItem(subMenu, action, DefaultProviders.IGNORE, ProcessType.UNIT_PROCESS);
	createSubItem(subMenu, action, DefaultProviders.IGNORE, ProcessType.LCI_RESULT);
	createSubItem(subMenu, action, DefaultProviders.PREFER, ProcessType.UNIT_PROCESS);
	createSubItem(subMenu, action, DefaultProviders.PREFER, ProcessType.LCI_RESULT);
	createSubItem(subMenu, action, DefaultProviders.ONLY, null);
	item.setMenu(subMenu);
}
 
Example 9
Source File: ReviewMarkerMenuContribution.java    From git-appraise-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void fill(Menu menu, int index) {
  MenuItem submenuItem = new MenuItem(menu, SWT.CASCADE, index);
  submenuItem.setText("&Appraise Review Comments");
  Menu submenu = new Menu(menu);
  submenuItem.setMenu(submenu);
  for (IMarker marker : markers) {
    MenuItem menuItem = new MenuItem(submenu, SWT.CHECK);
    menuItem.setText(marker.getAttribute(IMarker.MESSAGE, ""));
    menuItem.addSelectionListener(createDynamicSelectionListener(marker));
  }
}
 
Example 10
Source File: AbstractMenuContributionItem.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected Menu createCascadeMenu(Menu menu, String label, Optional<Image> image) {
    MenuItem cascadeMenuItem = new MenuItem(menu, SWT.CASCADE);
    cascadeMenuItem.setText(label);
    image.ifPresent(cascadeMenuItem::setImage);
    Menu cascadeMenu = new Menu(menu);
    cascadeMenuItem.setMenu(cascadeMenu);
    return cascadeMenu;
}
 
Example 11
Source File: TorrentMenuFancy.java    From BiglyBT with GNU General Public License v2.0 5 votes vote down vote up
protected void addMenuItemListener(Menu menu, Listener l) {
	for (MenuItem item : menu.getItems()) {
		if (item.getStyle() == SWT.CASCADE) {
			addMenuItemListener(item.getMenu(), l);
		} else {
			item.addListener(SWT.Selection, l);
		}
	}
}
 
Example 12
Source File: GroupPage.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void createMoveMenu() {
	Menu menu = new Menu(processViewer.getTable());
	processViewer.getTable().setMenu(menu);
	MenuItem item = new MenuItem(menu, SWT.CASCADE);
	item.setText(M.Move);
	groupMoveMenu = new Menu(item);
	item.setMenu(groupMoveMenu);
	groupMoveMenu.addListener(SWT.Show, new MenuGroupListener());
}
 
Example 13
Source File: GeoMapBrowser.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public void createMenu(Shell shell) {
	Menu bar = new Menu(shell, SWT.BAR);
	shell.setMenuBar(bar);
	MenuItem fileItem = new MenuItem(bar, SWT.CASCADE);
	fileItem.setText("&File");
	Menu submenu = new Menu(shell, SWT.DROP_DOWN);
	fileItem.setMenu(submenu);
	MenuItem item = new MenuItem(submenu, SWT.PUSH);
	item.addListener(SWT.Selection, e -> Runtime.getRuntime().halt(0));
	item.setText("E&xit\tCtrl+W");
	item.setAccelerator(SWT.MOD1 + 'W');
}
 
Example 14
Source File: XViewerCustomMenu.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
public void createClearAllFiltersMenuItem(Menu popupMenu) {
   final MenuItem item = new MenuItem(popupMenu, SWT.CASCADE);
   item.setText(XViewerText.get("menu.clear_filters")); //$NON-NLS-1$
   item.addListener(SWT.Selection, e->xViewer.getCustomizeMgr().clearFilters());
}
 
Example 15
Source File: XViewerCustomMenu.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
public void createCopyRowsMenuItem(Menu popupMenu) {
   final MenuItem item = new MenuItem(popupMenu, SWT.CASCADE);
   item.setText(XViewerText.get("menu.copy_row")); //$NON-NLS-1$
   item.addListener(SWT.Selection, e->performCopy());
}
 
Example 16
Source File: ToolbarComposite.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
public void mouseDown(MouseEvent event) {
	checkWidget();
	Rectangle bigArrowsBounds = new Rectangle(mArrowsBounds.x, 0, mArrowsBounds.width, CustomButton.BUTTON_HEIGHT);
	if (isInside(event.x, event.y, bigArrowsBounds)) {
		GC gc = new GC(this);
		Rectangle rect = new Rectangle(mArrowsBounds.x - mSettings.getToolBarLeftSpacer(), 0, mArrowsBounds.width + mSettings.getToolBarRightSpacer(),
				CustomButton.BUTTON_HEIGHT);
		mButtonPainter.paintBackground(gc, mColorManager, mSettings, rect, false, true);

		gc.drawImage(mArrowImage, mArrowsBounds.x, mArrowsBounds.y);

		gc.dispose();

		Menu mainMenu = new Menu(Display.getDefault().getActiveShell(), SWT.POP_UP);

		List<IMenuListener> menuListeners = mButtonComposite.getMenuListeners();
		for (int i = 0; i < menuListeners.size(); i++) {
			menuListeners.get(i).preMenuItemsCreated(mainMenu);
		}

		MenuItem menuShowMoreButtons = new MenuItem(mainMenu, SWT.PUSH);
		MenuItem menuShowFewerButtons = new MenuItem(mainMenu, SWT.PUSH);
		menuShowFewerButtons.addListener(SWT.Selection, e -> mButtonComposite.hideNextButton());
		menuShowMoreButtons.addListener(SWT.Selection, e-> mButtonComposite.showNextButton());

		menuShowMoreButtons.setText(mLanguage.getShowMoreButtonsText());
		menuShowFewerButtons.setText(mLanguage.getShowFewerButtonsText());

		new MenuItem(mainMenu, SWT.SEPARATOR);
		MenuItem more = new MenuItem(mainMenu, SWT.CASCADE);
		more.setText(mLanguage.getAddOrRemoveButtonsText());
		Menu moreMenu = new Menu(more);
		more.setMenu(moreMenu);

		List<CustomButton> cbs = mButtonComposite.getItems();
		for (int i = 0; i < cbs.size(); i++) {
			final CustomButton cb = cbs.get(i);
			final MenuItem temp = new MenuItem(moreMenu, SWT.CHECK);
			temp.setText(cb.getText());
			temp.setImage(cb.getToolBarImage());
			temp.setSelection(mButtonComposite.isVisible(cb));
			temp.addListener(SWT.Selection, e -> {
				if (mButtonComposite.isVisible(cb)) {
					mButtonComposite.permanentlyHideButton(cb);
					temp.setSelection(false);
				} else {
					mButtonComposite.permanentlyShowButton(cb);
					temp.setSelection(true);
				}
			});
		}

		for (int i = 0; i < menuListeners.size(); i++) {
			menuListeners.get(i).postMenuItemsCreated(mainMenu);
		}

		mainMenu.setVisible(true);
		return;
	}

	for (int i = 0; i < mToolBarItems.size(); i++) {
		TBItem item = mToolBarItems.get(i);
		if (item.getBounds() != null) {
			if (isInside(event.x, event.y, item.getBounds())) {
				mButtonComposite.selectItemAndLoad(item.getButton());
				break;
			}
		}
	}
}
 
Example 17
Source File: Rev.java    From Rel with Apache License 2.0 4 votes vote down vote up
private void refreshMenus() {
	if (getMenu() != null)
		getMenu().dispose();

	Menu menuBar = new Menu(getShell(), SWT.POP_UP);
	if (!isReadOnly())
		model.setMenu(menuBar);

	// Custom relvars
	IconMenuItem customRelvarsItem = new IconMenuItem(menuBar, "Variables", SWT.CASCADE);
	customRelvarsItem.setMenu(obtainRelvarsMenu(menuBar, false));

	// System relvars
	IconMenuItem systemRelvarsItem = new IconMenuItem(menuBar, "System variables", SWT.CASCADE);
	systemRelvarsItem.setMenu(obtainRelvarsMenu(menuBar, true));

	// Operators
	OpSelector[] queryOperators = getOperators();
	IconMenuItem insOperatorsItem = new IconMenuItem(menuBar, "Operators and constants", SWT.CASCADE);
	Menu insOperatorsMenu = new Menu(menuBar);
	for (int i = 0; i < queryOperators.length; i++) {
		OpSelector selector = queryOperators[i];
		if (selector.toString() == null)
			new MenuItem(insOperatorsMenu, SWT.SEPARATOR);
		else {
			new IconMenuItem(insOperatorsMenu, selector.getMenuTitle(), null, SWT.PUSH, e -> {
				Point lastMousePosition = model.getLastMousePosition();
				obtainOperatorForKind(selector.toString(), selector.toString() + getUniqueNumber(), 
						lastMousePosition.x, lastMousePosition.y);
			});
		}
	}
	insOperatorsItem.setMenu(insOperatorsMenu);

	new IconMenuItem(menuBar, "Refresh", null, SWT.PUSH, e -> refreshMenus());
	new IconMenuItem(menuBar, "Clear", null, SWT.PUSH, e -> {
		if (!MessageDialog.openConfirm(getShell(), "Rev", "Remove everything from this query?"))
			return;
		model.removeEverything();
	});
}
 
Example 18
Source File: SideBar.java    From BiglyBT with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @param menuDropDown
 *
 * @since 3.1.1.1
 */
protected void fillDropDownMenu(Menu menuDropDown, TreeItem[] items,
		int indent) {
	String s = "";
	for (int i = 0; i < indent; i++) {
		s += "   ";
	}
	for (int i = 0; i < items.length; i++) {
		TreeItem treeItem = items[i];

		SideBarEntrySWT entry = (SideBarEntrySWT) treeItem.getData("MdiEntry");
		if (entry == null) {
			continue;
		}
		org.eclipse.swt.widgets.MenuItem menuItem = new org.eclipse.swt.widgets.MenuItem(
				menuDropDown, entry.isSelectable() ? SWT.RADIO : SWT.CASCADE);

		String id = entry.getViewID();
		menuItem.setData("Plugin.viewID", id);
		ViewTitleInfo titleInfo = entry.getViewTitleInfo();
		String ind = "";
		if (titleInfo != null) {
			String o = (String) titleInfo.getTitleInfoProperty(ViewTitleInfo.TITLE_INDICATOR_TEXT);
			if (o != null) {
				ind = "  (" + o + ")";
				//ind = "\t" + o;
			}
		}
		menuItem.setText(s + entry.getTitle() + ind);
		menuItem.addSelectionListener(dropDownSelectionListener);
		MdiEntry currentEntry = getCurrentEntry();
		if (currentEntry != null && currentEntry.getViewID().equals(id)) {
			menuItem.setSelection(true);
		}

		TreeItem[] subItems = treeItem.getItems();
		if (subItems.length > 0) {
			Menu parent = menuDropDown;
			if (!entry.isSelectable()) {
				parent = new Menu(menuDropDown.getParent().getShell(), SWT.DROP_DOWN);
				menuItem.setMenu(parent);
			}


			fillDropDownMenu(parent, subItems, indent + 1);
		}
	}
}
 
Example 19
Source File: XViewerCustomMenu.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
public void createFilterByValueMenuItem(Menu popupMenu) {
   final MenuItem item = new MenuItem(popupMenu, SWT.CASCADE);
   item.setText(XViewerText.get("menu.value_filter")); //$NON-NLS-1$
   item.addListener(SWT.Selection, e->performFilterByValue());
}
 
Example 20
Source File: XViewerCustomMenu.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
public void createViewTableReportMenuItem(Menu popupMenu) {
   setupActions();
   final MenuItem item = new MenuItem(popupMenu, SWT.CASCADE);
   item.setText(XViewerText.get("menu.view_report")); //$NON-NLS-1$
   item.addListener(SWT.Selection, e->viewTableReport.run());
}