Java Code Examples for org.eclipse.swt.custom.StyledText#setMenu()

The following examples show how to use org.eclipse.swt.custom.StyledText#setMenu() . 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: EmbeddedEditorActions.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected void initialize() {
	createFocusAndDisposeListeners();

	createActions();

	// create context menu
	MenuManager manager = new MenuManager(null, null);
	manager.setRemoveAllWhenShown(true);
	manager.addMenuListener(new IMenuListener() {
		@Override
		public void menuAboutToShow(IMenuManager mgr) {
			fillContextMenu(mgr);
		}
	});

	StyledText text = viewer.getTextWidget();
	Menu menu = manager.createContextMenu(text);
	text.setMenu(menu);
	
	List<ActionActivationCode> activationCodes = Lists.newArrayList();
	setActionActivationCode(activationCodes, ITextEditorActionConstants.SHIFT_RIGHT_TAB,'\t', -1, SWT.NONE);
	setActionActivationCode(activationCodes, ITextEditorActionConstants.SHIFT_LEFT, '\t', -1, SWT.SHIFT);
	viewer.getTextWidget().addVerifyKeyListener(new ActivationCodeTrigger(allActions, activationCodes));
}
 
Example 2
Source File: BidiLayout.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public BidiLayout(Composite parent, int style){
	super(parent, 0);
	this.setLayout(new FillLayout());
	styledText = new StyledText(this, style);

	addBidiSegmentListener();
	addListeners();
	styledText.setMenu(createContextMenu());
}
 
Example 3
Source File: StyledTextCellEditor.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
public void close() {
	if (close) {
		return;
	}

	for (Listener listener : closingListeners) {
		Event event = new Event();
		event.data = this;
		listener.handleEvent(event);
	}

	close = true; // 状态改为已经关闭
	xliffEditor.getTable().removeDisposeListener(this);

	StyledText text = viewer.getTextWidget();
	if (text != null && !text.isDisposed()) {
		actionHandler.removeTextViewer();
		text.setMenu(null); // dispose前应去掉右键menu,因为右键menu是和nattable共享的
		viewer.reset();
		text.dispose();
		text = null;
	}

	// 如果 XLIFF 编辑器仍处于激活状态,则把焦点交给编辑器
	try {
		IWorkbenchPart activepart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
				.getActivePart();
		if (xliffEditor.equals(activepart)) {
			xliffEditor.setFocus();
		}
	} catch (NullPointerException e) {
	}

	// NatTable table = xliffEditor.getTable();
	// int[] rowPositions = new int[] { hsCellEditor.getRowPosition() };
	// table.doCommand(new AutoResizeCurrentRowsCommand(table, rowPositions, table.getConfigRegistry()));
}
 
Example 4
Source File: StyledTextCellEditor.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public void close() {
	if (close) {
		return;
	}

	for (Listener listener : closingListeners) {
		Event event = new Event();
		event.data = this;
		listener.handleEvent(event);
	}

	close = true; // 状态改为已经关闭
	xliffEditor.getTable().removeDisposeListener(this);

	StyledText text = viewer.getTextWidget();
	if (text != null && !text.isDisposed()) {
		actionHandler.removeTextViewer();
		text.setMenu(null); // dispose前应去掉右键menu,因为右键menu是和nattable共享的
		viewer.reset();
		text.dispose();
		text = null;
	}

	// 如果 XLIFF 编辑器仍处于激活状态,则把焦点交给编辑器
	try {
		IWorkbenchPart activepart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
				.getActivePart();
		if (xliffEditor.equals(activepart)) {
			xliffEditor.setFocus();
		}
	} catch (NullPointerException e) {
	}

	// NatTable table = xliffEditor.getTable();
	// int[] rowPositions = new int[] { hsCellEditor.getRowPosition() };
	// table.doCommand(new AutoResizeCurrentRowsCommand(table, rowPositions, table.getConfigRegistry()));
}
 
Example 5
Source File: SQLDataSetEditorPage.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 
 * @param viewer
 */
private final void attachMenus( SourceViewer viewer )
{
	StyledText widget = viewer.getTextWidget( );
	TextMenuManager menuManager = new TextMenuManager( viewer );
	widget.setMenu( menuManager.getContextMenu( widget ) );
}
 
Example 6
Source File: EditTemplateDialog.java    From typescript.java with MIT License 4 votes vote down vote up
private void initializeActions() {
	TextViewerAction action = new TextViewerAction(fPatternEditor, ITextOperationTarget.UNDO);
	action.setText(JSDTTypeScriptUIMessages.EditTemplateDialog_undo);
	fGlobalActions.put(ITextEditorActionConstants.UNDO, action);

	action = new TextViewerAction(fPatternEditor, ITextOperationTarget.CUT);
	action.setText(JSDTTypeScriptUIMessages.EditTemplateDialog_cut);
	fGlobalActions.put(ITextEditorActionConstants.CUT, action);

	action = new TextViewerAction(fPatternEditor, ITextOperationTarget.COPY);
	action.setText(JSDTTypeScriptUIMessages.EditTemplateDialog_copy);
	fGlobalActions.put(ITextEditorActionConstants.COPY, action);

	action = new TextViewerAction(fPatternEditor, ITextOperationTarget.PASTE);
	action.setText(JSDTTypeScriptUIMessages.EditTemplateDialog_paste);
	fGlobalActions.put(ITextEditorActionConstants.PASTE, action);

	action = new TextViewerAction(fPatternEditor, ITextOperationTarget.SELECT_ALL);
	action.setText(JSDTTypeScriptUIMessages.EditTemplateDialog_select_all);
	fGlobalActions.put(ITextEditorActionConstants.SELECT_ALL, action);

	action = new TextViewerAction(fPatternEditor, ISourceViewer.CONTENTASSIST_PROPOSALS);
	action.setText(JSDTTypeScriptUIMessages.EditTemplateDialog_content_assist);
	fGlobalActions.put("ContentAssistProposal", action); //$NON-NLS-1$

	fSelectionActions.add(ITextEditorActionConstants.CUT);
	fSelectionActions.add(ITextEditorActionConstants.COPY);
	fSelectionActions.add(ITextEditorActionConstants.PASTE);

	// create context menu
	MenuManager manager = new MenuManager(null, null);
	manager.setRemoveAllWhenShown(true);
	manager.addMenuListener(new IMenuListener() {
		public void menuAboutToShow(IMenuManager mgr) {
			fillContextMenu(mgr);
		}
	});

	StyledText text = fPatternEditor.getTextWidget();
	Menu menu = manager.createContextMenu(text);
	text.setMenu(menu);
}