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

The following examples show how to use org.eclipse.swt.SWT#BAR . 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: 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 2
Source File: MainMenu.java    From arx with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new instance.
 * 
 * @param shell
 * @param controller
 * @param items
 */
public MainMenu(final Shell shell, final Controller controller, final List<MainMenuItem> items) {
    super(controller);

    // Create Menu
    this.menu = new Menu(shell, SWT.BAR);
    
    // Create items
    this.createItems(menu, items);

    // Set menu bar
    shell.setMenuBar(this.menu);
    
    // Enhance experience on OSX
    SWTUtil.fixOSXMenu(controller);
    
    // Initialize
    this.update(new ModelEvent(this, ModelPart.MODEL, null));
}
 
Example 3
Source File: HopGui.java    From hop with Apache License 2.0 5 votes vote down vote up
private void addMainMenu() {
  mainMenu = new Menu( shell, SWT.BAR );

  mainMenuWidgets = new GuiMenuWidgets();
  mainMenuWidgets.registerGuiPluginObject( this );
  mainMenuWidgets.createMenuWidgets( ID_MAIN_MENU, shell, mainMenu );

  shell.setMenuBar( mainMenu );
  setUndoMenu( null );
  handleFileCapabilities( new EmptyFileType(), false, false );
}
 
Example 4
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 5
Source File: MenuManager.java    From pmTrans with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void createMenu() {
	menuBar = new Menu(shell, SWT.BAR);
	createFileMenu();
	createEditMenu();
	createPlaybackMenu();
	createViewMenu();
	createHelpMenu();

	shell.setMenuBar(menuBar);
}
 
Example 6
Source File: MenuManagerCopiedToAddCreateMenuWithMenuParent.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Updates the menu item for this sub menu.
 * The menu item is disabled if this sub menu is empty.
 * Does nothing if this menu is not a submenu.
 */
private void updateMenuItem() {
    /*
     * Commented out until proper solution to enablement of
     * menu item for a sub-menu is found. See bug 30833 for
     * more details.
     *  
     if (menuItem != null && !menuItem.isDisposed() && menuExist()) {
     IContributionItem items[] = getItems();
     boolean enabled = false;
     for (int i = 0; i < items.length; i++) {
     IContributionItem item = items[i];
     enabled = item.isEnabled();
     if(enabled) break;
     }
     // Workaround for 1GDDCN2: SWT:Linux - MenuItem.setEnabled() always causes a redraw
     if (menuItem.getEnabled() != enabled)
     menuItem.setEnabled(enabled);
     }
     */
    // Partial fix for bug #34969 - diable the menu item if no
    // items in sub-menu (for context menus).
    if (menuItem != null && !menuItem.isDisposed() && menuExist()) {
        boolean enabled = removeAllWhenShown || menu.getItemCount() > 0;
        // Workaround for 1GDDCN2: SWT:Linux - MenuItem.setEnabled() always causes a redraw
        if (menuItem.getEnabled() != enabled) {
            // We only do this for context menus (for bug #34969)
            Menu topMenu = menu;
            while (topMenu.getParentMenu() != null) {
                topMenu = topMenu.getParentMenu();
            }
            if ((topMenu.getStyle() & SWT.BAR) == 0) {
                menuItem.setEnabled(enabled);
            }
        }
    }
}
 
Example 7
Source File: MainMenuV2.java    From BiglyBT with GNU General Public License v2.0 4 votes vote down vote up
private void createMenus(final Shell parent) {

		//The Main Menu
		menuBar = parent.getDisplay().getMenuBar();
		if (menuBar == null) {
			menuBar = new Menu(parent, SWT.BAR);
			parent.setMenuBar(menuBar);
		}else{
			Utils.disposeSWTObjects((Object[])menuBar.getItems());
		}


		addFileMenu();

		/* ======= View, Transfers, Torrent, Tools menus =====
		 * hig compliance for OSX dictates that more granular actions are positioned farther
		 * on the right of the menu and more general actions are closer to the left
		 * NOTE: we keep the original menu order (for non-OSX) in-tact so as to not disturb existing non-OSX users
		 */
		if (Constants.isOSX) {
			addViewMenu(parent);
			addTransferMenu();
			addTorrentMenu(parent);
		} else {
			addTransferMenu();
			addTorrentMenu(parent);
			addViewMenu(parent);

			/*
			 * The Tools menu is only present on non-OSX systems
			 */
			addToolsMenu();
		}

		addPluginsMenu(parent);

		// ========== Windows menu (OSX only)================
		if (Constants.isOSX) {
			addWindowMenu(parent);
		}

		// =========== Debug menu (development only)=========
		if (Constants.isCVSVersion()) {
			DebugMenuHelper.createDebugMenuItem(menuBar);
		}

		addCommunityMenu( parent);
		
		addV2HelpMenu(parent);

		/*
		 * Enabled/disable menus based on what ui mode we're in
		 * NOTE: This is largely superfluous here since all menu items in the classic UI
		 * are available at all time; this method is left here for completeness should we
		 * add dynamic behavior to the menu in the future.
		 */
		MenuFactory.updateEnabledStates(menuBar);

	}
 
Example 8
Source File: BattleAggDialog.java    From logbook with MIT License 4 votes vote down vote up
/**
 * Create contents of the dialog.
 */
private void createContents() {
    // シェルを作成
    this.shell = new Shell(this.getParent(), this.getStyle());
    this.shell.setSize(this.getSize());
    // ウインドウ位置を復元
    LayoutLogic.applyWindowLocation(this.getClass(), this.shell);
    // 閉じた時にウインドウ位置を保存
    this.shell.addShellListener(new SaveWindowLocationAdapter(this.getClass()));

    this.shell.setText(this.getTitle());
    this.shell.setLayout(new FillLayout(SWT.HORIZONTAL));
    // メニューバー
    this.menubar = new Menu(this.shell, SWT.BAR);
    this.shell.setMenuBar(this.menubar);
    // ツリーテーブル
    this.tree = new Tree(this.shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.VIRTUAL | SWT.MULTI);
    this.tree.addKeyListener(new TreeKeyShortcutAdapter(this.header, this.tree));
    this.tree.setLinesVisible(true);
    this.tree.setHeaderVisible(true);
    // メニューバーのメニュー
    MenuItem operoot = new MenuItem(this.menubar, SWT.CASCADE);
    operoot.setText("操作");
    this.opemenu = new Menu(operoot);
    operoot.setMenu(this.opemenu);
    MenuItem reload = new MenuItem(this.opemenu, SWT.NONE);
    reload.setText("再読み込み(&R)\tF5");
    reload.setAccelerator(SWT.F5);
    reload.addSelectionListener((SelectedListener) e -> this.reloadTable());
    // テーブル右クリックメニュー
    this.tablemenu = new Menu(this.tree);
    this.tree.setMenu(this.tablemenu);
    MenuItem sendclipbord = new MenuItem(this.tablemenu, SWT.NONE);
    sendclipbord.addSelectionListener(new TreeToClipboardAdapter(this.header, this.tree));
    sendclipbord.setText("クリップボードにコピー(&C)");
    MenuItem reloadtable = new MenuItem(this.tablemenu, SWT.NONE);
    reloadtable.setText("再読み込み(&R)");
    reloadtable.addSelectionListener((SelectedListener) e -> this.reloadTable());

    this.setTableHeader();
    this.reloadTable();
}
 
Example 9
Source File: AbstractTableDialogEx.java    From logbook with MIT License 4 votes vote down vote up
/**
 * Open the dialog.
 */
public void open() {
    // シェルを作成
    this.shell = new Shell(this.getParent(), this.getStyle());
    this.shell.setSize(this.getSize());
    // ウインドウ位置を復元
    LayoutLogic.applyWindowLocation(this.getClass(), this.shell);
    // 閉じた時にウインドウ位置を保存
    this.shell.addShellListener(new SaveWindowLocationAdapter(this.getClass()));

    this.shell.setText(this.getTitle());
    this.shell.setLayout(new FillLayout());
    // メニューバー
    this.menubar = new Menu(this.shell, SWT.BAR);
    this.shell.setMenuBar(this.menubar);
    // メニューバーのメニュー
    MenuItem fileroot = new MenuItem(this.menubar, SWT.CASCADE);
    fileroot.setText("ファイル");
    this.filemenu = new Menu(fileroot);
    fileroot.setMenu(this.filemenu);

    MenuItem savecsv = new MenuItem(this.filemenu, SWT.NONE);
    savecsv.setText("CSVファイルに保存(&S)\tCtrl+S");
    savecsv.setAccelerator(SWT.CTRL + 'S');
    savecsv.addSelectionListener(new TableToCsvSaveAdapter(this.shell, this.getTitle(),
            () -> this.getSelectionTable().getTable()));

    MenuItem operoot = new MenuItem(this.menubar, SWT.CASCADE);
    operoot.setText("操作");
    this.opemenu = new Menu(operoot);
    operoot.setMenu(this.opemenu);

    MenuItem reload = new MenuItem(this.opemenu, SWT.NONE);
    reload.setText("再読み込み(&R)\tF5");
    reload.setAccelerator(SWT.F5);
    reload.addSelectionListener(new TableReloadAdapter());

    Boolean isCyclicReload = AppConfig.get().getCyclicReloadMap().get(this.getClass().getName());
    MenuItem cyclicReload = new MenuItem(this.opemenu, SWT.CHECK);
    cyclicReload.setText("定期的に再読み込み(&A)\tCtrl+F5");
    cyclicReload.setAccelerator(SWT.CTRL + SWT.F5);
    if ((isCyclicReload != null) && isCyclicReload.booleanValue()) {
        cyclicReload.setSelection(true);
    }
    CyclicReloadAdapter adapter = new CyclicReloadAdapter(cyclicReload);
    cyclicReload.addSelectionListener(adapter);
    adapter.setCyclicReload(cyclicReload);

    MenuItem selectVisible = new MenuItem(this.opemenu, SWT.NONE);
    selectVisible.setText("列の表示・非表示(&V)");
    selectVisible.addSelectionListener(new SelectVisibleColumnAdapter());

    new MenuItem(this.opemenu, SWT.SEPARATOR);

    // 閉じた時に設定を保存
    this.shell.addShellListener(new ShellAdapter() {
        @Override
        public void shellClosed(ShellEvent e) {
            AppConfig.get().getCyclicReloadMap()
                    .put(AbstractTableDialogEx.this.getClass().getName(), cyclicReload.getSelection());
        }
    });

    this.createContents();
    this.shell.open();
    this.shell.layout();
    Display display = this.getParent().getDisplay();
    while (!this.shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    // タスクがある場合キャンセル
    if (this.future != null) {
        this.future.cancel(false);
    }
}
 
Example 10
Source File: SWTMenuBar.java    From tuxguitar with GNU Lesser General Public License v2.1 4 votes vote down vote up
public SWTMenuBar(SWTWindow window) {
	super(window.getControl(), SWT.BAR);
	
	window.setMenuBar(this);
}
 
Example 11
Source File: MenuManagerCopiedToAddCreateMenuWithMenuParent.java    From Pydev with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * Creates and returns an SWT menu bar control for this menu,
 * for use in the given <code>Decorations</code>, and installs all registered
 * contributions. Does not create a new control if one already exists.
 *
 * @param parent the parent decorations
 * @return the menu control
 * @since 2.1
 */
public Menu createMenuBar(Decorations parent) {
    if (!menuExist()) {
        menu = new Menu(parent, SWT.BAR);
        update(false);
    }
    return menu;
}