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


Java MenuItem.setEnabled方法代碼示例

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


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

示例1: showCompareMenu

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
private void showCompareMenu(final Point location, final ConflictDescription conflict) {
    final ConflictComparisonOption[] comparisons =
        ConflictComparisonFactory.getConflictComparison(conflict).getOptions();

    final Menu compareMenu = new Menu(getSite().getShell(), SWT.POP_UP);

    for (final ConflictComparisonOption comparison : comparisons) {
        final Object originalNode = comparison.getOriginalNode();
        final Object modifiedNode = comparison.getModifiedNode();

        final MenuItem compareItem = new MenuItem(compareMenu, SWT.NONE);

        final String messageFormat = Messages.getString("ConflictResolutionEditor.CompareActionTextFormat"); //$NON-NLS-1$
        final String message =
            MessageFormat.format(messageFormat, comparison.getModifiedTitle(), comparison.getOriginalTitle());

        compareItem.setText(message);
        compareItem.setEnabled(modifiedNode != null && originalNode != null);

        compareItem.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent e) {
                openComparison(conflict, originalNode, modifiedNode);
            }
        });
    }

    getSite().getShell().setMenu(compareMenu);

    compareMenu.setLocation(location);
    compareMenu.setVisible(true);
}
 
開發者ID:Microsoft,項目名稱:team-explorer-everywhere,代碼行數:33,代碼來源:ConflictResolutionEditor.java

示例2: createMenu

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的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

示例3: createMenuItem

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
private void createMenuItem(TGToolBar toolBar, Menu menu, int velocity, int selection, boolean running) {
	MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
	menuItem.setEnabled(!running);
	menuItem.addSelectionListener(this.createChangeVelocityAction(toolBar, velocity));
	
	String nameKey = getNameKey(velocity);
	if( nameKey != null ) {
		menuItem.setText(toolBar.getText(nameKey, (velocity == selection)));
	}
	Image icon = this.getDynamicIcon(toolBar, velocity);
	if( icon != null ) {
		menuItem.setImage(icon);
	}
}
 
開發者ID:theokyr,項目名稱:TuxGuitar-1.3.1-fork,代碼行數:15,代碼來源:TGToolBarSectionDynamic.java

示例4: createDurationMenuItem

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
private void createDurationMenuItem(TGToolBar toolBar, Menu menu, int value, int selection, boolean running) {
	Image icon = this.findDurationIcon(toolBar, value);
	String action = this.findDurationAction(value);
	String nameKey = this.findDurationNameKey(value);
	if( icon != null && action != null && nameKey != null ) {
		MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
		menuItem.setEnabled(!running);
		menuItem.addSelectionListener(toolBar.createActionProcessor(action));
		menuItem.setText(toolBar.getText(nameKey, (value == selection)));
		menuItem.setImage(icon);
	}
}
 
開發者ID:theokyr,項目名稱:TuxGuitar-1.3.1-fork,代碼行數:13,代碼來源:TGToolBarSectionDuration.java

示例5: setFindEnabled

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
public void setFindEnabled(boolean b) {
	for (MenuItem item : findDependent)
		if (!item.isDisposed())
			item.setEnabled(b);
}
 
開發者ID:juanerasmoe,項目名稱:pmTrans,代碼行數:6,代碼來源:MenuManager.java

示例6: fillMenu

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
@Override
public void
fillMenu(
	String sColumnName, Menu menu)
{
	List<Object>	ds = tv.getSelectedDataSources();

	final List<DownloadStubFile> files = new ArrayList<>();

	for ( Object o: ds ){

		files.add((DownloadStubFile)o);
	}

	boolean	hasSelection = files.size() > 0;

		// Explore (or open containing folder)

	final boolean use_open_containing_folder = COConfigurationManager.getBooleanParameter("MyTorrentsView.menu.show_parent_folder_enabled");

	final MenuItem itemExplore = new MenuItem(menu, SWT.PUSH);

	Messages.setLanguageText(itemExplore, "MyTorrentsView.menu."
			+ (use_open_containing_folder ? "open_parent_folder" : "explore"));

	itemExplore.addListener(SWT.Selection, new Listener() {
		@Override
		public void
		handleEvent(
			Event event)
		{
			for ( DownloadStubFile file: files ){

				ManagerUtils.open( new File( file.getFile().getAbsolutePath()), use_open_containing_folder);
			}
		}
	});

	itemExplore.setEnabled(hasSelection);

	new MenuItem( menu, SWT.SEPARATOR );
}
 
開發者ID:BiglySoftware,項目名稱:BiglyBT,代碼行數:43,代碼來源:ArchivedFilesView.java

示例7: update

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
@Override
public void update(MenuItem m) {
    m.setEnabled(isEnabled(m));
    if (isCheckable())
        m.setSelection(isChecked(m));
}
 
開發者ID:openaudible,項目名稱:openaudible,代碼行數:7,代碼來源:MenuCommand.java

示例8: createMenu

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的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

示例9: createMenu

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
public void createMenu(TGToolBar toolBar, ToolItem item) {
	boolean running = TuxGuitar.getInstance().getPlayer().isRunning();
	TGMeasure measure = toolBar.getTablature().getCaret().getMeasure();
	
	Menu menu = new Menu(item.getParent().getShell());
	
	MenuItem tempo = new MenuItem(menu, SWT.PUSH);
	tempo.addSelectionListener(toolBar.createActionProcessor(TGOpenTempoDialogAction.NAME));
	tempo.setEnabled(!running);
	tempo.setText(toolBar.getText("composition.tempo"));
	tempo.setImage(toolBar.getIconManager().getCompositionTempo());

	MenuItem timeSignature = new MenuItem(menu, SWT.PUSH);
	timeSignature.addSelectionListener(toolBar.createActionProcessor(TGOpenTimeSignatureDialogAction.NAME));
	timeSignature.setEnabled(!running);
	timeSignature.setText(toolBar.getText("composition.timesignature"));
	timeSignature.setImage(toolBar.getIconManager().getCompositionTimeSignature());

	new MenuItem(menu, SWT.SEPARATOR);
	
	MenuItem repeatOpen = new MenuItem(menu, SWT.PUSH);
	repeatOpen.addSelectionListener(toolBar.createActionProcessor(TGRepeatOpenAction.NAME));
	repeatOpen.setEnabled( !running );
	repeatOpen.setText(toolBar.getText("repeat.open", (measure != null && measure.isRepeatOpen())));
	repeatOpen.setImage(toolBar.getIconManager().getCompositionRepeatOpen());

	MenuItem repeatClose = new MenuItem(menu, SWT.PUSH);
	repeatClose.addSelectionListener(toolBar.createActionProcessor(TGOpenRepeatCloseDialogAction.NAME));
	repeatClose.setEnabled( !running );
	repeatClose.setText(toolBar.getText("repeat.close", (measure != null && measure.getRepeatClose() > 0)));
	repeatClose.setImage(toolBar.getIconManager().getCompositionRepeatClose());
	
	MenuItem repeatAlternative = new MenuItem(menu, SWT.PUSH);
	repeatAlternative.addSelectionListener(toolBar.createActionProcessor(TGOpenRepeatAlternativeDialogAction.NAME));
	repeatAlternative.setEnabled( !running );
	repeatAlternative.setText(toolBar.getText("repeat.alternative", (measure != null && measure.getHeader().getRepeatAlternative() > 0)));
	repeatAlternative.setImage(toolBar.getIconManager().getCompositionRepeatAlternative());
	
	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,代碼行數:45,代碼來源:TGToolBarSectionComposition.java


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