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

The following examples show how to use org.eclipse.swt.SWT#RIGHT_TO_LEFT . 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: AggregateEditorComposite.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private void createDropDownComponent( )
{
	Point pLoc = UIHelper.getScreenLocation( fBtnDropDown.getParent( ) );
	int iXLoc = pLoc.x;
	int iYLoc = pLoc.y + fBtnDropDown.getParent( ).getSize( ).y;
	int iShellWidth = BLOCK_WIDTH;
	int iShellHeight = BLOCK_HEIGHT;

	if ( ( getStyle( ) & SWT.RIGHT_TO_LEFT ) != 0 )
	{
		iXLoc -= iShellWidth;
	}

	// Avoid the right boundary out of screen
	if ( iXLoc + iShellWidth > this.getDisplay( ).getClientArea( ).width )
	{
		iXLoc = this.getDisplay( ).getClientArea( ).width - iShellWidth;
	}

	Shell shell = new Shell( this.getShell( ), SWT.NONE );
	shell.setLayout( new FillLayout( ) );
	shell.setSize( iShellWidth, iShellHeight );
	shell.setLocation( iXLoc, iYLoc );

	if ( query != null )
	{
		setAggregation( query, fSeriesDefi );
	}
	else
	{
		setSeriesDefinition( fSeriesDefi );
	}
	fAggregateEditor = new AggregateDropDownEditorComposite( shell, SWT.NONE, null );
	
	shell.layout( );
	shell.open( );
}
 
Example 2
Source File: ImageLabel.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Check the style bits to ensure that no invalid styles are applied.
 */
private static int checkStyle( int style )
{
	if ( ( style & SWT.BORDER ) != 0 )
		style |= SWT.SHADOW_IN;
	int mask = SWT.SHADOW_IN
			| SWT.SHADOW_OUT
			| SWT.SHADOW_NONE
			| SWT.LEFT_TO_RIGHT
			| SWT.RIGHT_TO_LEFT;
	style = style & mask;
	style |= SWT.NO_FOCUS;
	if ( ( style & ( SWT.CENTER | SWT.RIGHT ) ) == 0 )
		style |= SWT.LEFT;
	// TEMPORARY CODE
	/*
	 * The default background on carbon and some GTK themes is not a solid
	 * color but a texture. To show the correct default background, we must
	 * allow the operating system to draw it and therefore, we can not use
	 * the NO_BACKGROUND style. The NO_BACKGROUND style is not required on
	 * platforms that use double buffering which is true in both of these
	 * cases.
	 */
	String platform = SWT.getPlatform( );
	if ( "carbon".equals( platform ) || "gtk".equals( platform ) )return style; //$NON-NLS-1$ //$NON-NLS-2$
	return style | SWT.NO_BACKGROUND;
}
 
Example 3
Source File: StyleCombo.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
static int checkStyle( int style )
{
	int mask = SWT.BORDER
			| SWT.READ_ONLY
			| SWT.FLAT
			| SWT.LEFT_TO_RIGHT
			| SWT.RIGHT_TO_LEFT;
	return style & mask;
}
 
Example 4
Source File: TextPainterWithPadding.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
private TextLayout getCellTextLayout(LayerCell cell) {
	int orientation = editor.getTable().getStyle() & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT);
	TextLayout layout = new TextLayout(editor.getTable().getDisplay());
	layout.setOrientation(orientation);
	layout.setSpacing(Constants.SEGMENT_LINE_SPACING);
	layout.setFont(font);
	layout.setAscent(ascent);
	layout.setDescent(descent); // 和 StyledTextEditor 同步
	layout.setTabs(new int[] { tabWidth });

	Rectangle rectangle = cell.getBounds();
	int width = rectangle.width - leftPadding - rightPadding;
	width -= 1;
	if (wrapText && width > 0) {
		layout.setWidth(width);
	}

	String displayText = InnerTagUtil.resolveTag(innerTagFactory.parseInnerTag((String) cell.getDataValue()));
	if (XliffEditorParameter.getInstance().isShowNonpirnttingCharacter()) {
		displayText = displayText.replaceAll("\\n", Constants.LINE_SEPARATOR_CHARACTER + "\n");
		displayText = displayText.replaceAll("\\t", Constants.TAB_CHARACTER + "\u200B");
		displayText = displayText.replaceAll(" ", Constants.SPACE_CHARACTER + "\u200B");
	}
	layout.setText(displayText);
	List<InnerTagBean> innerTagBeans = innerTagFactory.getInnerTagBeans();
	for (InnerTagBean innerTagBean : innerTagBeans) {
		String placeHolder = placeHolderBuilder.getPlaceHolder(innerTagBeans, innerTagBeans.indexOf(innerTagBean));
		int start = displayText.indexOf(placeHolder);
		if (start == -1) {
			continue;
		}
		TextStyle style = new TextStyle();
		Point rect = tagRender.calculateTagSize(innerTagBean);
		style.metrics = new GlyphMetrics(rect.y, 0, rect.x + SEGMENT_LINE_SPACING * 2);
		layout.setStyle(style, start, start + placeHolder.length() - 1);
	}

	return layout;
}
 
Example 5
Source File: CustomCombo.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
void createPopup(String[] items, int selectionIndex) {
	// create shell and list
	popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP);
	int style = getStyle();
	int listStyle = SWT.SINGLE | SWT.V_SCROLL;
	if ((style & SWT.FLAT) != 0)
		listStyle |= SWT.FLAT;
	if ((style & SWT.RIGHT_TO_LEFT) != 0)
		listStyle |= SWT.RIGHT_TO_LEFT;
	if ((style & SWT.LEFT_TO_RIGHT) != 0)
		listStyle |= SWT.LEFT_TO_RIGHT;
	list = new List(popup, listStyle);
	if (font != null)
		list.setFont(font);
	if (foreground != null)
		list.setForeground(foreground);
	if (background != null)
		list.setBackground(background);

	int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate };
	for (int i = 0; i < popupEvents.length; i++)
		popup.addListener(popupEvents[i], listener);
	int[] listEvents = { SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.Dispose };
	for (int i = 0; i < listEvents.length; i++)
		list.addListener(listEvents[i], listener);

	if (items != null)
		list.setItems(items);
	if (selectionIndex != -1)
		list.setSelection(selectionIndex);
}
 
Example 6
Source File: TreeMapper.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @param targetTreeViewer
 * @param data
 * @param widget
 */
@SuppressWarnings("unchecked")
protected void performMappingByDrop(TreeViewer sourceTreeViewer, ISelection sourceData, TreeViewer targetTreeViewer, TreeItem targetTreeItem, int direction) {
	Object resolvedTargetItem = resolveTreeViewerItem(targetTreeViewer, targetTreeItem);
	for (Object sourceItem : ((IStructuredSelection)sourceData).toList()) {
		if (direction == SWT.LEFT_TO_RIGHT) {
			createMapping((L)sourceItem, (R)resolvedTargetItem);
		} else if (direction == SWT.RIGHT_TO_LEFT) {
			createMapping((L)resolvedTargetItem, (R)sourceItem);
		}
	}
}
 
Example 7
Source File: CustomChooserComposite.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
private void createDropDownComponent( int iXLoc, int iYLoc )
{
	if ( !bEnabled )
	{
		return;
	}

	int shellWidth = this.getSize( ).x;
	Shell shell = new Shell( this.getShell( ), SWT.NONE );
	shell.setLayout( new FillLayout( SWT.FILL ) );
	if ( ( getStyle( ) & SWT.RIGHT_TO_LEFT ) != 0 )
	{
		iXLoc -= shellWidth;
	}
	shell.setLocation( iXLoc, iYLoc );

	container = new ScrolledComposite( shell, SWT.V_SCROLL );
	container.setAlwaysShowScrollBars( false );
	container.setExpandHorizontal( true );

	cmpDropDown = new Composite( container, SWT.NONE );
	GridLayout gl = new GridLayout( );
	gl.horizontalSpacing = 0;
	gl.verticalSpacing = 0;
	gl.marginHeight = 0;
	gl.marginWidth = 0;
	cmpDropDown.setLayout( gl );

	Listener listenerCmpDropDown = new Listener( ) {

		public void handleEvent( Event event )
		{
			handleEventCmpDropDown( event );
		}
	};

	cmpDropDown.addListener( SWT.KeyDown, listenerCmpDropDown );
	cmpDropDown.addListener( SWT.FocusOut, listenerCmpDropDown );

	popupCanvases = new ICustomChoice[this.items.length];

	for ( int iC = 0; iC < items.length; iC++ )
	{
		ICustomChoice cnv = createChoice( cmpDropDown, items[iC] );
		GridData gd = new GridData( GridData.FILL_HORIZONTAL );
		cnv.setLayoutData( gd );
		cnv.addListener( SWT.MouseDown, canvasListener );
		cnv.addListener( SWT.MouseEnter, canvasListener );
		cnv.addListener( SWT.KeyDown, canvasListener );

		popupCanvases[iC] = cnv;
		if ( cnvSelection.getValue( ).equals( cnv.getValue( ) ) )
		{
			cnv.notifyListeners( SWT.FocusIn, new Event( ) );
			popupSelection = cnv;
		}
	}

	int width = 0;
	int height = 0;

	int maxWidth = 0;
	Control[] children = container.getChildren( );
	for ( int i = 0; i < children.length; i++ )
	{
		Point point = children[i].computeSize( SWT.DEFAULT, SWT.DEFAULT );
		maxWidth = point.x > maxWidth ? point.x : maxWidth;
		height += point.y;
	}
	
	width = getSize( ).x > maxWidth ? getSize( ).x : maxWidth;
	height = 18 > height ? 18 : height;

	cmpDropDown.setBounds( 0, 0, width, height );

	container.setContent( cmpDropDown );

	if ( height >= 298 )
	{
		int containerWidth = maxWidth
				+ container.getVerticalBar( ).getSize( ).x;
		width = width > containerWidth ? getSize( ).x : containerWidth;
	}

	shell.setSize( width, height < 298 ? height + 2 : 300 );

	shell.layout( );
	shell.open( );
}
 
Example 8
Source File: TabBar.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
private static int checkStyle(int style)
{
    int mask = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT | SWT.RIGHT;
    return (style & mask) | SWT.DOUBLE_BUFFERED;
}
 
Example 9
Source File: UrbanSashForm.java    From http4e with Apache License 2.0 4 votes vote down vote up
static int checkStyle( int style){
    int mask = SWT.BORDER | SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;
    return style & mask;
}
 
Example 10
Source File: TableCombo.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * creates the popup shell.
 * @param selectionIndex
 */
void createPopup(int selectionIndex) {
	// create shell and table
	popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP);

	// set style
	int style = getStyle();
	int tableStyle = SWT.SINGLE | SWT.V_SCROLL;
	if ((style & SWT.FLAT) != 0)
		tableStyle |= SWT.FLAT;
	if ((style & SWT.RIGHT_TO_LEFT) != 0)
		tableStyle |= SWT.RIGHT_TO_LEFT;
	if ((style & SWT.LEFT_TO_RIGHT) != 0)
		tableStyle |= SWT.LEFT_TO_RIGHT;

	// create table
	table = new Table(popup, SWT.SINGLE | SWT.FULL_SELECTION);

	if (font != null)
		table.setFont(font);
	if (foreground != null)
		table.setForeground(foreground);
	if (background != null)
		table.setBackground(background);

	// Add popup listeners
	int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate, SWT.Help };
	for (int i = 0; i < popupEvents.length; i++) {
		popup.addListener(popupEvents[i], listener);
	}

	// add table listeners
	int[] tableEvents = { SWT.MouseMove, SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp,
			SWT.FocusIn, SWT.Dispose };
	for (int i = 0; i < tableEvents.length; i++) {
		table.addListener(tableEvents[i], listener);
	}

	// set the selection
	if (selectionIndex != -1) {
		table.setSelection(selectionIndex);
	}
}
 
Example 11
Source File: XbaseInformationControl.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Xbase - modification added detailPane
 */
@Override
public void setInput(Object input) {
	Assert.isLegal(input == null || input instanceof String || input instanceof XtextBrowserInformationControlInput, String.valueOf(input));

	if (input instanceof String) {
		setInformation((String) input);
		return;
	}
	if (input instanceof XtextBrowserInformationControlInput)
		fInput = (XtextBrowserInformationControlInput) input;

	String content = null;
	if (fInput != null)
		content = fInput.getHtml();

	fBrowserHasContent = content != null && content.length() > 0;

	if (!fBrowserHasContent)
		content = "<html><body ></html>"; //$NON-NLS-1$

	boolean RTL = (getShell().getStyle() & SWT.RIGHT_TO_LEFT) != 0;
	boolean resizable = isResizable();

	// The default "overflow:auto" would not result in a predictable width for the client area
	// and the re-wrapping would cause visual noise
	String[] styles = null;
	if (RTL && resizable)
		styles = new String[] { "direction:rtl;", "overflow:scroll;", "word-wrap:break-word;" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
	else if (RTL && !resizable)
		styles = new String[] { "direction:rtl;", "overflow:hidden;", "word-wrap:break-word;" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
	else if (!resizable)
		//XXX: In IE, "word-wrap: break-word;" causes bogus wrapping even in non-broken words :-(see e.g. Javadoc of String).
		// Re-check whether we really still need this now that the Javadoc Hover header already sets this style.
		styles = new String[] { "overflow:hidden;"/*, "word-wrap: break-word;"*/}; //$NON-NLS-1$
	else
		styles = new String[] { "overflow:scroll;" }; //$NON-NLS-1$

	StringBuffer buffer = new StringBuffer(content);
	HTMLPrinter.insertStyles(buffer, styles);
	content = buffer.toString();

	/*
	 * XXX: Should add some JavaScript here that shows something like
	 * "(continued...)" or "..." at the end of the visible area when the page overflowed
	 * with "overflow:hidden;".
	 */

	fCompleted = false;
	fBrowser.setText(content);
	String unsugaredExpression = "";
	if (fInput != null && fInput instanceof XbaseInformationControlInput) {
		XbaseInformationControlInput castedInput = (XbaseInformationControlInput) fInput;
		unsugaredExpression = castedInput.getUnsugaredExpression();
		if(unsugaredExpression != null && unsugaredExpression.length() > 0){
			EObject element = fInput.getElement();
			if(element != null && element.eResource() != null && element.eResource().getResourceSet() != null){
				// FIXME: No arguments need when https://bugs.eclipse.org/bugs/show_bug.cgi?id=368827 is solved
				// THEN move to createContent as it was before
				if(embeddedEditorAccess == null)
					embeddedEditorAccess = embeddedEditor.createPartialEditor("", "INITIAL CONTENT", "", false);
				resourceProvider.setContext(((XtextResourceSet) element.eResource().getResourceSet()).getClasspathURIContext());
			} else
				return;
			embeddedEditorAccess.updateModel(castedInput.getPrefix() , unsugaredExpression ,castedInput.getSuffix());
		}
	}

	if (unsugaredExpression != null && unsugaredExpression.length() > 0)
		fSashForm.setWeights(new int[] { 7, 3 });
	else
		fSashForm.setWeights(new int[] { 10, 0 });
	Object[] listeners = fInputChangeListeners.getListeners();
	for (int i = 0; i < listeners.length; i++)
		((IInputChangedListener) listeners[i]).inputChanged(fInput);
	
}
 
Example 12
Source File: CTreeCombo.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
static int checkStyle(int style) {
	final int mask = SWT.BORDER | SWT.READ_ONLY | SWT.FLAT | SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;
	return SWT.NO_FOCUS | style & mask;
}
 
Example 13
Source File: RenameInformationPopup.java    From typescript.java with MIT License 4 votes vote down vote up
private int[] getPolygon(boolean border) {
	Point e = getExtent();
	int b = border ? 1 : 0;
	boolean isRTL= (fPopup.getStyle() & SWT.RIGHT_TO_LEFT) != 0;
	int ha1= isRTL ? e.x - HAO :           HAO + HAW;
	int ha2= isRTL ? e.x - HAO - HAW / 2 : HAO + HAW / 2;
	int ha3= isRTL ? e.x - HAO - HAW :     HAO;
		int[] poly;
		switch (fSnapPosition) {
			case SNAP_POSITION_OVER_LEFT_FIELD:
				poly= new int[] {
						0, 0,
						e.x - b, 0,
						e.x - b, e.y - b,
						ha1, e.y - b,
						ha2, e.y + HAH - b,
						ha3, e.y - b,
						0, e.y - b,
						0, 0 };
				break;

			case SNAP_POSITION_UNDER_LEFT_FIELD:
				poly= new int[] {
						0, HAH,
						ha3 + b, HAH,
						ha2, b,
						ha1 - b, HAH,
						e.x - b, HAH,
						e.x - b, e.y + HAH - b,
						0, e.y + HAH - b,
						0, HAH };
				break;

			default:
				poly= new int[] {
						0, 0,
						e.x - b, 0,
						e.x - b, e.y - b,
						0, e.y - b,
						0, 0 };
				break;
		}
	return poly;
}
 
Example 14
Source File: CTree.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
private static int checkStyle(int style) {
	int mask = SWT.BORDER | SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT
			| SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.MULTI
			| SWT.NO_FOCUS | SWT.CHECK;
	return (style & mask);
}
 
Example 15
Source File: DataItemCombo.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
void createPopup( String[] items, int selectionIndex )
{
	// create shell and list
	popup = new Shell( getShell( ), SWT.NO_TRIM | SWT.ON_TOP );
	int style = getStyle( );
	int listStyle = SWT.SINGLE | SWT.V_SCROLL;
	if ( ( style & SWT.FLAT ) != 0 )
		listStyle |= SWT.FLAT;
	if ( ( style & SWT.RIGHT_TO_LEFT ) != 0 )
		listStyle |= SWT.RIGHT_TO_LEFT;
	if ( ( style & SWT.LEFT_TO_RIGHT ) != 0 )
		listStyle |= SWT.LEFT_TO_RIGHT;
	list = new List( popup, listStyle );
	if ( font != null )
		list.setFont( font );
	if ( foreground != null )
		list.setForeground( foreground );
	if ( background != null )
		list.setBackground( background );

	int[] popupEvents = {
			SWT.Close, SWT.Paint, SWT.Deactivate
	};
	for ( int i = 0; i < popupEvents.length; i++ )
		popup.addListener( popupEvents[i], listener );
	int[] listEvents = {
			SWT.MouseUp,
			SWT.Selection,
			SWT.Traverse,
			SWT.KeyDown,
			SWT.KeyUp,
			SWT.FocusIn,
			SWT.Dispose
	};
	for ( int i = 0; i < listEvents.length; i++ )
		list.addListener( listEvents[i], listener );

	if ( items != null )
		list.setItems( items );
	if ( selectionIndex != -1 )
		list.setSelection( selectionIndex );
}
 
Example 16
Source File: TableCombo.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * @param style
 * @return
 */
private static int checkStyle(int style) {
    int mask = SWT.BORDER | SWT.READ_ONLY | SWT.FLAT | SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;
    return SWT.NO_FOCUS | (style & mask);
}
 
Example 17
Source File: PGroup.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
private static int checkStyle(int style)
{
    int mask = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT | SWT.SMOOTH;
    return (style & mask) | SWT.DOUBLE_BUFFERED;
}
 
Example 18
Source File: BreadcrumbItemDropDown.java    From birt with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Tells whether this the breadcrumb is in LTR or RTL mode.
 * 
 * @return <code>true</code> if the breadcrumb in left-to-right mode,
 *         <code>false</code> otherwise
 */
private boolean isLTR( )
{
	return ( fParentComposite.getStyle( ) & SWT.RIGHT_TO_LEFT ) == 0;
}
 
Example 19
Source File: BreadcrumbItemDropDown.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Tells whether this the breadcrumb is in LTR or RTL mode.
 * 
 * @return <code>true</code> if the breadcrumb in left-to-right mode,
 *         <code>false</code> otherwise
 */
private boolean isLTR() {
  return (fParentComposite.getStyle() & SWT.RIGHT_TO_LEFT) == 0;
}
 
Example 20
Source File: BreadcrumbItemDropDown.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Tells whether this the breadcrumb is in LTR or RTL mode.
 *
 * @return <code>true</code> if the breadcrumb in left-to-right mode, <code>false</code>
 *         otherwise
 */
private boolean isLTR() {
	return (fParentComposite.getStyle() & SWT.RIGHT_TO_LEFT) == 0;
}