當前位置: 首頁>>代碼示例>>Java>>正文


Java ToolItem.getBounds方法代碼示例

本文整理匯總了Java中org.eclipse.swt.widgets.ToolItem.getBounds方法的典型用法代碼示例。如果您正苦於以下問題:Java ToolItem.getBounds方法的具體用法?Java ToolItem.getBounds怎麽用?Java ToolItem.getBounds使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.swt.widgets.ToolItem的用法示例。


在下文中一共展示了ToolItem.getBounds方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: widgetSelected

import org.eclipse.swt.widgets.ToolItem; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public void widgetSelected(final SelectionEvent event) {
    if (event.detail == SWT.ARROW) {
        /*
         * Show the menu.
         */
        final ToolItem item = (ToolItem) event.widget;
        final Rectangle itemRectangle = item.getBounds();

        final Point point = item.getParent().toDisplay(new Point(itemRectangle.x, itemRectangle.y));
        menu.setLocation(point.x, point.y + itemRectangle.height);
        menu.setVisible(true);
    } else {
        /*
         * Select the menu item
         */
        if (lastSelectedMenuItem != null) {
            final MenuItemSelectedHandler handler =
                (MenuItemSelectedHandler) lastSelectedMenuItem.getData(MENU_ITEM_SELECTED_HANDLER_WIDGET_DATA_KEY);
            handler.onMenuItemSelected(lastSelectedMenuItem);
        }
    }
}
 
開發者ID:Microsoft,項目名稱:team-explorer-everywhere,代碼行數:27,代碼來源:DropdownToolItemSelectionListener.java

示例2: runWithEvent

import org.eclipse.swt.widgets.ToolItem; //導入方法依賴的package包/類
@Override
public void runWithEvent(final Event event) {
    if (showMenuForDefaultAction) {
        final ToolItem item = (ToolItem) event.widget;
        final Rectangle itemRectangle = item.getBounds();
        final Point point = item.getParent().toDisplay(new Point(itemRectangle.x, itemRectangle.y));

        final Menu menu = getSubActionMenu(item.getParent());
        menu.setLocation(point.x, point.y + itemRectangle.height);
        menu.setVisible(true);
    } else {
        final IAction defaultSubAction = getDefaultSubAction();
        if (defaultSubAction != null && defaultSubAction.isEnabled()) {
            defaultSubAction.runWithEvent(event);
        }
    }
}
 
開發者ID:Microsoft,項目名稱:team-explorer-everywhere,代碼行數:18,代碼來源:ToolbarPulldownAction.java

示例3: createMenu

import org.eclipse.swt.widgets.ToolItem; //導入方法依賴的package包/類
public void createMenu(TGToolBar toolBar, ToolItem item) {
	Caret caret = TuxGuitar.getInstance().getTablatureEditor().getTablature().getCaret();
	int selection = ((caret.getSelectedNote() != null) ? caret.getSelectedNote().getVelocity() : caret.getVelocity());
	boolean running = TuxGuitar.getInstance().getPlayer().isRunning();
	
	Rectangle rect = item.getBounds();
	Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y));
	
	Menu menu = new Menu(item.getParent().getShell());
	
	this.createMenuItem(toolBar, menu, TGVelocities.PIANO_PIANISSIMO, selection, running);
	this.createMenuItem(toolBar, menu, TGVelocities.PIANISSIMO, selection, running);
	this.createMenuItem(toolBar, menu, TGVelocities.PIANO, selection, running);
	this.createMenuItem(toolBar, menu, TGVelocities.MEZZO_PIANO, selection, running);
	this.createMenuItem(toolBar, menu, TGVelocities.MEZZO_FORTE, selection, running);
	this.createMenuItem(toolBar, menu, TGVelocities.FORTE, selection, running);
	this.createMenuItem(toolBar, menu, TGVelocities.FORTISSIMO, selection, running);
	this.createMenuItem(toolBar, menu, TGVelocities.FORTE_FORTISSIMO, selection, running);
	
	menu.setLocation(pt.x, pt.y + rect.height);
	menu.setVisible(true);
}
 
開發者ID:theokyr,項目名稱:TuxGuitar-1.3.1-fork,代碼行數:23,代碼來源:TGToolBarSectionDynamic.java

示例4: createDurationMenu

import org.eclipse.swt.widgets.ToolItem; //導入方法依賴的package包/類
public void createDurationMenu(TGToolBar toolBar, ToolItem item) {
	TGDuration duration = TablatureEditor.getInstance(toolBar.getContext()).getTablature().getCaret().getDuration();
	boolean running = TuxGuitar.getInstance().getPlayer().isRunning();
	
	Menu menu = new Menu(item.getParent().getShell());
	this.createDurationMenuItem(toolBar, menu, TGDuration.WHOLE, duration.getValue(), running);
	this.createDurationMenuItem(toolBar, menu, TGDuration.HALF, duration.getValue(), running);
	this.createDurationMenuItem(toolBar, menu, TGDuration.QUARTER, duration.getValue(), running);
	this.createDurationMenuItem(toolBar, menu, TGDuration.EIGHTH, duration.getValue(), running);
	this.createDurationMenuItem(toolBar, menu, TGDuration.SIXTEENTH, duration.getValue(), running);
	this.createDurationMenuItem(toolBar, menu, TGDuration.THIRTY_SECOND, duration.getValue(), running);
	this.createDurationMenuItem(toolBar, menu, TGDuration.SIXTY_FOURTH, duration.getValue(), running);
	
	Rectangle rect = item.getBounds();
	Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y));
	
	menu.setLocation(pt.x, pt.y + rect.height);
	menu.setVisible(true);
}
 
開發者ID:theokyr,項目名稱:TuxGuitar-1.3.1-fork,代碼行數:20,代碼來源:TGToolBarSectionDuration.java

示例5: createDivisionTypeMenu

import org.eclipse.swt.widgets.ToolItem; //導入方法依賴的package包/類
private void createDivisionTypeMenu(TGToolBar toolBar, ToolItem item) {
	TGDuration duration = TablatureEditor.getInstance(toolBar.getContext()).getTablature().getCaret().getDuration();
	Menu menu = new Menu(item.getParent().getShell());
	
	for( int i = 0 ; i < TGDivisionType.ALTERED_DIVISION_TYPES.length ; i ++ ){
		TGDivisionType divisionType = TGDivisionType.ALTERED_DIVISION_TYPES[i];
		
		MenuItem menuItem = new MenuItem(menu, SWT.CHECK);
		menuItem.setText(toolBar.toCheckString(Integer.toString(TGDivisionType.ALTERED_DIVISION_TYPES[i].getEnters()), (divisionType.isEqual(duration.getDivision()))));
		menuItem.addSelectionListener(this.createDivisionTypeAction(toolBar, divisionType));
	}
	
	Rectangle rect = item.getBounds();
	Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y));
	
	menu.setLocation(pt.x, pt.y + rect.height);
	menu.setVisible(true);
}
 
開發者ID:theokyr,項目名稱:TuxGuitar-1.3.1-fork,代碼行數:19,代碼來源:TGToolBarSectionDuration.java

示例6: createMenu

import org.eclipse.swt.widgets.ToolItem; //導入方法依賴的package包/類
public void createMenu(TGToolBar toolBar, ToolItem item) {
	Rectangle rect = item.getBounds();
	Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y));
	
	Menu menu = new Menu(item.getParent().getShell());
	
	TGCustomChordManager customChordManager = TuxGuitar.getInstance().getCustomChordManager();
	for(int i = 0; i < customChordManager.countChords(); i++){
		TGChord chord = TuxGuitar.getInstance().getCustomChordManager().getChord(i);
		MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
		menuItem.setText(chord.getName());
		menuItem.addSelectionListener(this.createInsertChordAction(toolBar, chord));
	}
	
	menu.setLocation(pt.x, pt.y + rect.height);
	menu.setVisible(true);
}
 
開發者ID:theokyr,項目名稱:TuxGuitar-1.3.1-fork,代碼行數:18,代碼來源:TGToolBarSectionChord.java

示例7: runWithEvent

import org.eclipse.swt.widgets.ToolItem; //導入方法依賴的package包/類
@Override
public void runWithEvent(final Event event) {
	if (event.widget instanceof ToolItem) {
		final ToolItem toolItem = (ToolItem) event.widget;
		final Control control = toolItem.getParent();
		@SuppressWarnings("hiding")
		final Menu menu = getMenu(control);
		final Rectangle bounds = toolItem.getBounds();
		final Point topLeft = new Point(bounds.x, bounds.y + bounds.height);
		menu.setLocation(control.toDisplay(topLeft));
		menu.setVisible(true);
	}
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:14,代碼來源:DropDownAction.java

示例8: runWithEvent

import org.eclipse.swt.widgets.ToolItem; //導入方法依賴的package包/類
@Override
public void runWithEvent(Event event) {
	if (event.widget instanceof ToolItem) {
		final ToolItem toolItem = (ToolItem) event.widget;
		final Control control = toolItem.getParent();
		final Menu menu = getMenuCreator().getMenu(control);

		final Rectangle bounds = toolItem.getBounds();
		final Point topLeft = new Point(bounds.x, bounds.y + bounds.height);
		menu.setLocation(control.toDisplay(topLeft));
		menu.setVisible(true);
	}
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:14,代碼來源:ShowHistoryAction.java

示例9: widgetSelected

import org.eclipse.swt.widgets.ToolItem; //導入方法依賴的package包/類
/**
 * Handle selection events.
 */	
public void widgetSelected(SelectionEvent event) {
	/**
	 * A selection event will be fired when a drop down tool
	 * item is selected in the main area and in the drop
	 * down arrow.  Examine the event detail to determine
	 * where the widget was selected.
	 */		
	if (event.detail == SWT.ARROW) {
		/*
		 * The drop down arrow was selected.
		 */
		if (visible) {
			// Hide the menu to give the Arrow the appearance of being a toggle button.
			setMenuVisible(false);
		} else {	
			// Position the menu below and vertically aligned with the the drop down tool button.
			final ToolItem toolItem = (ToolItem) event.widget;
			final ToolBar  toolBar = toolItem.getParent();
			
			Rectangle toolItemBounds = toolItem.getBounds();
			Point point = toolBar.toDisplay(new Point(toolItemBounds.x, toolItemBounds.y));
			menu.setLocation(point.x, point.y + toolItemBounds.height);
			setMenuVisible(true);
		}
	} else {
		/*
		 * Main area of drop down tool item selected.
		 * An application would invoke the code to perform the action for the tool item.
		 */
	}
}
 
開發者ID:AppleCommander,項目名稱:AppleCommander,代碼行數:35,代碼來源:DropDownSelectionListener.java

示例10: execute

import org.eclipse.swt.widgets.ToolItem; //導入方法依賴的package包/類
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
  // Sanity check.
  if (null == event) {
    return null;
  }

  // Class check.
  if (!(event.getTrigger() instanceof Event)) {
    return null;
  }

  final Event eventWidget = (Event) event.getTrigger();

  // Makes sure event came from a ToolItem.
  if (!(eventWidget.widget instanceof ToolItem)) {
    return null;
  }

  final ToolItem toolItem = (ToolItem) eventWidget.widget;

  // Creates fake selection event.
  final Event newEvent = new Event();
  newEvent.button = 1;
  newEvent.widget = toolItem;
  newEvent.detail = SWT.ARROW;
  newEvent.x = toolItem.getBounds().x;
  newEvent.y = toolItem.getBounds().y + toolItem.getBounds().height;

  // Dispatches the event.
  toolItem.notifyListeners(SWT.Selection, newEvent);

  return null;
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:35,代碼來源:DropDownCommandHandler.java

示例11: createMenu

import org.eclipse.swt.widgets.ToolItem; //導入方法依賴的package包/類
public void createMenu(TGToolBar toolBar, ToolItem item) {
	TGLayout layout = toolBar.getTablature().getViewLayout();
	int style = layout.getStyle();
	
	Menu menu = new Menu(item.getParent().getShell());
	
	MenuItem pageLayout = new MenuItem(menu, SWT.PUSH);
	pageLayout.addSelectionListener(toolBar.createActionProcessor(TGSetPageLayoutAction.NAME));
	pageLayout.setText(toolBar.getText("view.layout.page", (layout instanceof TGLayoutVertical)));
	pageLayout.setImage(toolBar.getIconManager().getLayoutPage());
	
	MenuItem linearLayout = new MenuItem(menu, SWT.PUSH);
	linearLayout.addSelectionListener(toolBar.createActionProcessor(TGSetLinearLayoutAction.NAME));
	linearLayout.setText(toolBar.getText("view.layout.linear", (layout instanceof TGLayoutHorizontal)));
	linearLayout.setImage(toolBar.getIconManager().getLayoutLinear());
	
	MenuItem multitrack = new MenuItem(menu, SWT.PUSH);
	multitrack.addSelectionListener(toolBar.createActionProcessor(TGSetMultitrackViewAction.NAME));
	multitrack.setText(toolBar.getText("view.layout.multitrack", ( (style & TGLayout.DISPLAY_MULTITRACK) != 0 )));
	multitrack.setImage(toolBar.getIconManager().getLayoutMultitrack());
	
	MenuItem scoreEnabled = new MenuItem(menu, SWT.PUSH);
	scoreEnabled.addSelectionListener(toolBar.createActionProcessor(TGSetScoreEnabledAction.NAME));
	scoreEnabled.setText(toolBar.getText("view.layout.score-enabled", ( (style & TGLayout.DISPLAY_SCORE) != 0 )));
	scoreEnabled.setImage(toolBar.getIconManager().getLayoutScore());
	
	MenuItem compact = new MenuItem(menu, SWT.PUSH);
	compact.addSelectionListener(toolBar.createActionProcessor(TGSetCompactViewAction.NAME));
	compact.setText(toolBar.getText("view.layout.compact", ( (style & TGLayout.DISPLAY_COMPACT) != 0 )));
	compact.setImage(toolBar.getIconManager().getLayoutCompact());
	compact.setEnabled((style & TGLayout.DISPLAY_MULTITRACK) == 0 || toolBar.getSong().countTracks() == 1);
	
	Rectangle rect = item.getBounds();
	Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y));
	
	menu.setLocation(pt.x, pt.y + rect.height);
	menu.setVisible(true);
}
 
開發者ID:theokyr,項目名稱:TuxGuitar-1.3.1-fork,代碼行數:39,代碼來源:TGToolBarSectionLayout.java

示例12: createMenu

import org.eclipse.swt.widgets.ToolItem; //導入方法依賴的package包/類
public void createMenu(TGToolBar toolBar, ToolItem item) {
	Menu menu = new Menu(item.getParent().getShell());
	
	//--FRETBOARD--
	MenuItem showFretBoard = new MenuItem(menu, SWT.PUSH);
	showFretBoard.addSelectionListener(toolBar.createActionProcessor(TGToggleFretBoardEditorAction.NAME));
	showFretBoard.setImage(toolBar.getIconManager().getFretboard());
	showFretBoard.setText(toolBar.getText("view.show-fretboard", TGFretBoardEditor.getInstance(toolBar.getContext()).isVisible()));

	//--INSTRUMENTS--
	MenuItem showInstruments = new MenuItem(menu, SWT.PUSH);
	showInstruments.addSelectionListener(toolBar.createActionProcessor(TGToggleChannelsDialogAction.NAME));
	showInstruments.setImage(toolBar.getIconManager().getInstruments());
	showInstruments.setText(toolBar.getText("view.show-instruments", (!TGChannelManagerDialog.getInstance(toolBar.getContext()).isDisposed())));

	//--TRANSPORT--
	MenuItem showTransport = new MenuItem(menu, SWT.PUSH);
	showTransport.addSelectionListener(toolBar.createActionProcessor(TGToggleTransportDialogAction.NAME));
	showTransport.setImage(toolBar.getIconManager().getTransport());
	showTransport.setText(toolBar.getText("view.show-transport", (!TGTransportDialog.getInstance(toolBar.getContext()).isDisposed())));
	
	Rectangle rect = item.getBounds();
	Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y));
	
	menu.setLocation(pt.x, pt.y + rect.height);
	menu.setVisible(true);
}
 
開發者ID:theokyr,項目名稱:TuxGuitar-1.3.1-fork,代碼行數:28,代碼來源:TGToolBarSectionView.java

示例13: widgetSelected

import org.eclipse.swt.widgets.ToolItem; //導入方法依賴的package包/類
public void widgetSelected(SelectionEvent event) {
	if (event.detail == SWT.ARROW && this.subMenuItems != null && this.subMenuItems.length > 0) {
		ToolItem item = (ToolItem) event.widget;
		Rectangle rect = item.getBounds();
		Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y));
		this.menu.setLocation(pt.x, pt.y + rect.height);
		this.menu.setVisible(true);
	}else{
		new TGActionProcessor(TuxGuitar.getInstance().getContext(), TGOpenChordDialogAction.NAME).process();
	}
}
 
開發者ID:theokyr,項目名稱:TuxGuitar-1.3.1-fork,代碼行數:12,代碼來源:ChordMenuItem.java

示例14: widgetSelected

import org.eclipse.swt.widgets.ToolItem; //導入方法依賴的package包/類
@Override
public void widgetSelected(SelectionEvent event) {
    if (event.detail == SWT.ARROW) {
      ToolItem item = (ToolItem) event.widget;
      Rectangle rect = item.getBounds();
      Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y));
      menu.setLocation(pt.x, pt.y + rect.height);
      menu.setVisible(true);
    } else {
      System.out.println(dropdown.getText() + " Pressed");
    }
  }
 
開發者ID:Transkribus,項目名稱:TranskribusSwtGui,代碼行數:13,代碼來源:DropdownSelectionListener.java

示例15: createMenu

import org.eclipse.swt.widgets.ToolItem; //導入方法依賴的package包/類
public void createMenu(TGToolBar toolBar, ToolItem item) {
	TablatureEditor editor = TablatureEditor.getInstance(toolBar.getContext());
	EditorKit editorKit = editor.getTablature().getEditorKit();
	
	boolean running = TuxGuitar.getInstance().getPlayer().isRunning();
	
	Menu menu = new Menu(item.getParent().getShell());
	
	MenuItem voice1 = new MenuItem(menu, SWT.PUSH);
	voice1.addSelectionListener(toolBar.createActionProcessor(TGSetVoice1Action.NAME));
	voice1.setText(toolBar.getText("edit.voice-1", (editor.getTablature().getCaret().getVoice() == 0)));
	voice1.setImage(toolBar.getIconManager().getEditVoice1());
	voice1.setEnabled(!running);
	
	MenuItem voice2 = new MenuItem(menu, SWT.PUSH);
	voice2.addSelectionListener(toolBar.createActionProcessor(TGSetVoice2Action.NAME));
	voice2.setText(toolBar.getText("edit.voice-2", (editor.getTablature().getCaret().getVoice() == 1)));
	voice2.setImage(toolBar.getIconManager().getEditVoice2());
	voice2.setEnabled(!running);
	
	new MenuItem(menu, SWT.SEPARATOR);
	
	MenuItem modeSelection = new MenuItem(menu, SWT.PUSH);
	modeSelection.addSelectionListener(toolBar.createActionProcessor(TGSetMouseModeSelectionAction.NAME));
	modeSelection.setText(toolBar.getText("edit.mouse-mode-selection", (editorKit.getMouseMode() == EditorKit.MOUSE_MODE_SELECTION)));
	modeSelection.setImage(toolBar.getIconManager().getEditModeSelection());
	modeSelection.setEnabled(!running);
	
	MenuItem modeEdition = new MenuItem(menu, SWT.PUSH);
	modeEdition.addSelectionListener(toolBar.createActionProcessor(TGSetMouseModeEditionAction.NAME));
	modeEdition.setText(toolBar.getText("edit.mouse-mode-edition", (editorKit.getMouseMode() == EditorKit.MOUSE_MODE_EDITION)));
	modeEdition.setImage(toolBar.getIconManager().getEditModeEdition());
	modeEdition.setEnabled(!running);
	
	MenuItem notNaturalKey = new MenuItem(menu, SWT.PUSH);
	notNaturalKey.addSelectionListener(toolBar.createActionProcessor(TGSetNaturalKeyAction.NAME));
	notNaturalKey.setText(toolBar.getText("edit.not-natural-key", (!editorKit.isNatural())));
	notNaturalKey.setImage(toolBar.getIconManager().getEditModeEditionNotNatural());
	notNaturalKey.setEnabled(!running && editorKit.getMouseMode() == EditorKit.MOUSE_MODE_EDITION);
	
	Rectangle rect = item.getBounds();
	Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y));
	
	menu.setLocation(pt.x, pt.y + rect.height);
	menu.setVisible(true);
}
 
開發者ID:theokyr,項目名稱:TuxGuitar-1.3.1-fork,代碼行數:47,代碼來源:TGToolBarSectionEdit.java


注:本文中的org.eclipse.swt.widgets.ToolItem.getBounds方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。