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

The following examples show how to use org.eclipse.swt.SWT#SINGLE . 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: EclipseGuiCallback.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public String showQuestionDialog(String message, String title, final String defaultValue) {
    final AtomicReference<Text> textBoxRef = new AtomicReference<>();
    MessageDialog dlg = new MessageDialog(FindbugsPlugin.getShell(), getDialogTitle(title), null, message, MessageDialog.QUESTION,
            new String[] { "OK", "Cancel" }, 1) {
        @Override
        protected Control createCustomArea(Composite parent) {
            Text text = new Text(parent, SWT.SINGLE);
            text.setText(defaultValue);
            textBoxRef.set(text);
            return text;
        }

    };

    dlg.open();
    return textBoxRef.get().getText();
}
 
Example 2
Source File: OptionsConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
protected Text addTextField(Composite parent, String label, Key key, int indent, int widthHint) {
	Label labelControl= new Label(parent, SWT.WRAP);
	labelControl.setText(label);
	labelControl.setFont(JFaceResources.getDialogFont());
	GridData gd= new GridData();
	gd.horizontalIndent= indent;
	labelControl.setLayoutData(gd);

	Text textBox= new Text(parent, SWT.BORDER | SWT.SINGLE);
	textBox.setData(key);

	makeScrollableCompositeAware(textBox);

	fLabels.put(textBox, labelControl);

	updateText(textBox);
	
	textBox.addModifyListener(getTextModifyListener());

	GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
	if (widthHint != 0) {
		data.widthHint= widthHint;
	}
	data.horizontalSpan= 2;
	textBox.setLayoutData(data);

	fTextBoxes.add(textBox);
	return textBox;
}
 
Example 3
Source File: SelectLanguageConfigurationWizardPage.java    From tm4e with Eclipse Public License 1.0 5 votes vote down vote up
private void createContentTypeTreeViewer(Composite composite) {
	TreeViewer contentTypesViewer = new TreeViewer(composite,
			SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
	contentTypesViewer.getControl().setFont(composite.getFont());
	contentTypesViewer.setContentProvider(new ContentTypesContentProvider());
	contentTypesViewer.setLabelProvider(new ContentTypesLabelProvider());
	contentTypesViewer.setComparator(new ViewerComparator());
	contentTypesViewer.setInput(Platform.getContentTypeManager());
	GridData data = new GridData(GridData.FILL_HORIZONTAL);
	data.horizontalSpan = 2;
	contentTypesViewer.getControl().setLayoutData(data);

	contentTypesViewer.addSelectionChangedListener(event -> contentTypeText
			.setText(((IContentType) event.getStructuredSelection().getFirstElement()).toString()));
}
 
Example 4
Source File: Grid_Test.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testSetSelectionByRange_Single() {
  grid = new Grid( shell, SWT.SINGLE );
  GridItem[] items = createGridItems( grid, 5, 0 );
  grid.select( 0 );
  grid.setSelection( 1, 1 );
  GridItem[] expected = new GridItem[] {
    items[ 1 ]
  };
  assertTrue( Arrays.equals( expected, grid.getSelection() ) );
}
 
Example 5
Source File: CompositeFactory.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
public static Table createTable(Composite composite, int height, int span) {
	GridData gridData = new GridData();
	gridData.horizontalSpan = span;
	gridData.heightHint = height;
	gridData.horizontalAlignment = GridData.FILL;
	gridData.grabExcessHorizontalSpace = true;

	Table table = new Table(composite, SWT.SINGLE | SWT.BORDER
			| SWT.FULL_SELECTION);
	table.setLayoutData(gridData);
	table.setHeaderVisible(true);
	table.setLinesVisible(true);

	return table;
}
 
Example 6
Source File: NewEdgeMatcherPage.java    From depan with Apache License 2.0 5 votes vote down vote up
@Override
public Composite createOptionsControl(Composite container) {
  Group result = new Group(container, SWT.NONE);
  result.setText("Edge Matcher Options");

  GridLayout grid = new GridLayout();
  grid.numColumns = 2;
  grid.verticalSpacing = 9;
  result.setLayout(grid);

  GridData fillHorz = new GridData(SWT.FILL, SWT.BEGINNING, true, false);

  // Row 1) Container selection
  Label label = new Label(result, SWT.NULL);
  label.setText("&Name:");

  nameText = new Text(result, SWT.BORDER | SWT.SINGLE);
  nameText.setLayoutData(fillHorz);
  nameText.addModifyListener(new ModifyListener() {

    @Override
    public void modifyText(ModifyEvent e) {
      updatePageStatus();
    }
  });

  return result;
}
 
Example 7
Source File: AuthComposite.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void layoutComposite() {
  FormLayout flAuthComp = new FormLayout();
  this.setLayout( flAuthComp );

  //authentication group
  wAuthGroup = new Group( this, SWT.SHADOW_ETCHED_IN );
  props.setLook( wAuthGroup );
  wAuthGroup.setText( authGroupLabel );

  FormLayout flAuthGroup = new FormLayout();
  flAuthGroup.marginHeight = 15;
  flAuthGroup.marginWidth = 15;
  wAuthGroup.setLayout( flAuthGroup );
  wAuthGroup.setLayoutData( new FormDataBuilder().fullSize().result() );

  //username
  wlUsername = new Label( wAuthGroup, SWT.LEFT );
  props.setLook( wlUsername );
  wlUsername.setText( usernameLabel );
  wlUsername.setLayoutData( new FormDataBuilder().left().top().result() );

  wUsername = new TextVar( transMeta, wAuthGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
  props.setLook( wUsername );
  wUsername.addModifyListener( lsMod );
  wUsername.setLayoutData( new FormDataBuilder().top( wlUsername ).left().width( INPUT_WIDTH ).result() );

  //password
  wlPassword = new Label( wAuthGroup, SWT.LEFT );
  props.setLook( wlPassword );
  wlPassword.setText( passwordLabel );
  wlPassword.setLayoutData( new FormDataBuilder().left().top( wUsername, ConstUI.MEDUIM_MARGIN ).result() );

  wPassword = new PasswordTextVar( transMeta, wAuthGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
  props.setLook( wPassword );
  wPassword.addModifyListener( lsMod );
  wPassword.setLayoutData( new FormDataBuilder().left().top( wlPassword ).width( INPUT_WIDTH ).result() );
}
 
Example 8
Source File: Grid_Test.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testSetSelectionByItems_SingleWithMultipleItems() {
  grid = new Grid( shell, SWT.SINGLE );
  GridItem[] items = createGridItems( grid, 5, 0 );
  grid.setSelection( new GridItem[] {
    items[ 1 ],
    items[ 2 ],
    items[ 3 ]
  } );
  assertTrue( Arrays.equals( new GridItem[ 0 ], grid.getSelection() ) );
}
 
Example 9
Source File: DiffMergePreferencePage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * creates a Text control
 */
private Text createText(Composite parent, int widthHint) {
    Text textControl = new Text(parent, SWT.SINGLE | SWT.BORDER);
    GridData gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.widthHint = widthHint;
    gridData.grabExcessHorizontalSpace = true;
    textControl.setLayoutData(gridData);
    return textControl;
}
 
Example 10
Source File: NumberRangeDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
private Text createLine( ModifyListener lsMod, String lableText, Control prevControl ) {
  // Value line
  Label lable = new Label( shell, SWT.RIGHT );
  lable.setText( lableText );
  props.setLook( lable );
  FormData lableFormData = new FormData();
  lableFormData.left = new FormAttachment( 0, 0 );
  lableFormData.right = new FormAttachment( props.getMiddlePct(), -props.getMargin() );
  // In case it is the first control
  if ( prevControl != null ) {
    lableFormData.top = new FormAttachment( prevControl, props.getMargin() );
  } else {
    lableFormData.top = new FormAttachment( 0, props.getMargin() );
  }
  lable.setLayoutData( lableFormData );

  Text control = new Text( shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
  props.setLook( control );
  control.addModifyListener( lsMod );
  FormData widgetFormData = new FormData();
  widgetFormData.left = new FormAttachment( props.getMiddlePct(), 0 );
  // In case it is the first control
  if ( prevControl != null ) {
    widgetFormData.top = new FormAttachment( prevControl, props.getMargin() );
  } else {
    widgetFormData.top = new FormAttachment( 0, props.getMargin() );
  }
  widgetFormData.right = new FormAttachment( 100, 0 );
  control.setLayoutData( widgetFormData );

  return control;
}
 
Example 11
Source File: SearchQuick.java    From Rel with Apache License 2.0 4 votes vote down vote up
public SearchQuick(FilterSorter filterSorter, Composite contentPanel) {
	super(contentPanel, SWT.NONE);
	
	this.filterSorter = filterSorter;
	
	GridLayout layout = new GridLayout(2, false);
	layout.horizontalSpacing = 0;
	layout.verticalSpacing = 0;
	layout.marginWidth = 0;
	layout.marginHeight = 0;
	setLayout(layout);
	
	findText = new StyledText(this, SWT.BORDER | SWT.SINGLE);
	findText.addListener(SWT.Traverse, event -> {
		if (event.detail == SWT.TRAVERSE_RETURN) {
			fireUpdate();
		}
	});
	findText.addListener(SWT.Modify, event -> {
		if (findText.getText().trim().length() > 0) {
			findText.setForeground(SWTResourceManager.getColor(SWT.COLOR_DARK_RED));
			findText.setBackground(SWTResourceManager.getColor(255, 225, 225));
		}
	});
	findText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	
	ToolBar toolBar = new ToolBar(this, SWT.NONE);
	
	ToolItem wholeWord = new ToolItem(toolBar, SWT.PUSH);
	wholeWord.addListener(SWT.Selection, e -> {
		wholeWordSearch = !wholeWordSearch;
		wholeWord.setText(wholeWordSearch ? "Whole word" : "Any match");
		layout();
		fireUpdateIfSearch();
	});
	wholeWord.setText("Any match");

	ToolItem caseSensitive = new ToolItem(toolBar, SWT.PUSH);
	caseSensitive.addListener(SWT.Selection, e -> {
		caseSensitiveSearch = !caseSensitiveSearch;
		caseSensitive.setText(caseSensitiveSearch ? "Case sensitive" : "Case insensitive");
		layout();
		fireUpdateIfSearch();
	});
	caseSensitive.setText("Case insensitive");
	
	ToolItem regex = new ToolItem(toolBar, SWT.CHECK);
	regex.addListener(SWT.Selection, e -> {
		regexSearch = regex.getSelection();
		wholeWord.setEnabled(!regexSearch);
		caseSensitive.setEnabled(!regexSearch);
		fireUpdateIfSearch();
	});
	regex.setText("Regex");
	
	ToolItem clear = new ToolItem(toolBar, SWT.PUSH);
	clear.addListener(SWT.Selection, e -> {
		if (findText.getText().trim().length() == 0)
			return;
		findText.setText("");
		fireUpdate();
	});
	clear.setText("Clear");
	
	toolBar.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
}
 
Example 12
Source File: ContentAssistPreferencePage.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
/**
 * createUserAgentTable
 * 
 * @param parent
 */
protected void createUserAgentTable(Composite parent)
{
	Label label = new Label(parent, SWT.WRAP);
	label.setText(Messages.UserAgentPreferencePage_Select_User_Agents);
	label.setLayoutData(GridDataFactory.fillDefaults().span(2, 0).grab(true, true).create());

	Composite composite = new Composite(parent, SWT.NONE);
	composite.setLayout(GridLayoutFactory.fillDefaults().create());
	composite.setLayoutData(GridDataFactory.fillDefaults().span(2, 0).hint(400, 120).grab(true, true).create());

	Table table = new Table(composite, SWT.CHECK | SWT.BORDER | SWT.SINGLE);
	table.setFont(parent.getFont());

	categoryViewer = new CheckboxTableViewer(table);
	categoryViewer.getControl().setFont(parent.getFont());
	categoryViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
	categoryViewer.setContentProvider(ArrayContentProvider.getInstance());

	CategoryLabelProvider categoryLabelProvider = new CategoryLabelProvider(true);
	categoryViewer.setLabelProvider(categoryLabelProvider);
	categoryViewer.setComparator(new ViewerComparator()
	{
		@Override
		public int compare(Viewer viewer, Object e1, Object e2)
		{
			if (e1 instanceof IUserAgent && e2 instanceof IUserAgent)
			{
				IUserAgent ua1 = (IUserAgent) e1;
				IUserAgent ua2 = (IUserAgent) e2;

				String uaName1 = StringUtil.getStringValue(ua1.getName());
				String uaName2 = StringUtil.getStringValue(ua2.getName());

				return uaName1.compareToIgnoreCase(uaName2);
			}

			return super.compare(viewer, e1, e2);
		}
	});

	categoryViewer.setInput(UserAgentManager.getInstance().getAllUserAgents());
}
 
Example 13
Source File: CTreeCombo.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * The CTreeCombo class represents a selectable user interface object
 * that combines a text field and a tree and issues notification
 * when an item is selected from the tree.
 * <p>
 * Note that although this class is a subclass of <code>Composite</code>,
 * it does not make sense to add children to it, or set a layout on it.
 * </p>
 * <dl>
 * <dt><b>Styles:</b>
 * <dd>BORDER, READ_ONLY, FLAT</dd>
 * <dt><b>Events:</b>
 * <dd>DefaultSelection, Modify, Selection, Verify</dd>
 * </dl>
 */
public CTreeCombo(Composite parent, int style) {
	super(parent, style = checkStyle(style));

	int textStyle = SWT.SINGLE;
	if ((style & SWT.READ_ONLY) != 0) {
		textStyle |= SWT.READ_ONLY;
	}
	if ((style & SWT.FLAT) != 0) {
		textStyle |= SWT.FLAT;
	}
	text = new Text(this, textStyle);
	int arrowStyle = SWT.ARROW | SWT.DOWN;
	if ((style & SWT.FLAT) != 0) {
		arrowStyle |= SWT.FLAT;
	}
	arrow = new Button(this, arrowStyle);

	listener = new Listener() {
		@Override
		public void handleEvent(Event event) {
			if (popup == event.widget) {
				popupEvent(event);
				return;
			}
			if (text == event.widget) {
				textEvent(event);
				return;
			}
			if (tree == event.widget) {
				treeEvent(event);
				return;
			}
			if (arrow == event.widget) {
				arrowEvent(event);
				return;
			}
			if (CTreeCombo.this == event.widget) {
				comboEvent(event);
				return;
			}
			if (getShell() == event.widget) {
				getDisplay().asyncExec(new Runnable() {
					@Override
					public void run() {
						if (isDisposed()) {
							return;
						}
						handleFocus(SWT.FocusOut);
					}
				});
			}
		}
	};
	filter = (event) -> {
		final Shell shell = ((Control) event.widget).getShell();
		if (shell == CTreeCombo.this.getShell()) {
			handleFocus(SWT.FocusOut);
		}
	};

	final int[] comboEvents = { SWT.Dispose, SWT.FocusIn, SWT.Move, SWT.Resize };
	for (int i = 0; i < comboEvents.length; i++) {
		addListener(comboEvents[i], listener);
	}

	final int[] textEvents = { SWT.DefaultSelection, SWT.KeyDown, SWT.KeyUp, SWT.MenuDetect, SWT.Modify, SWT.MouseDown, SWT.MouseUp, SWT.MouseDoubleClick, SWT.MouseWheel, SWT.Traverse, SWT.FocusIn, SWT.Verify };
	for (int i = 0; i < textEvents.length; i++) {
		text.addListener(textEvents[i], listener);
	}

	final int[] arrowEvents = { SWT.MouseDown, SWT.MouseUp, SWT.Selection, SWT.FocusIn };
	for (int i = 0; i < arrowEvents.length; i++) {
		arrow.addListener(arrowEvents[i], listener);
	}

	createPopup(null, null);
	initAccessible();
}
 
Example 14
Source File: TextAssistSnippet.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
public static void main(final String[] args) {
	final Display display = new Display();
	final Shell shell = new Shell(display);
	shell.setLayout(new GridLayout());

	final TextAssistContentProvider contentProvider = new TextAssistContentProvider() {

		private final String[] EUROZONE = new String[] { "Austria", "Belgium", "Cyprus", "Estonia", "Finland", "France", "Germany", "Greece", "Ireland", "Italy", "Luxembourg", "Malta", "Netherlands", "Portugal", "Slovakia", "Slovenia", "Spain" };

		@Override
		public List<String> getContent(final String entry) {
			final List<String> returnedList = new ArrayList<String>();

			for (final String country : EUROZONE) {
				if (country.toLowerCase().startsWith(entry.toLowerCase())) {
					returnedList.add(country);
				}
			}

			return returnedList;
		}
	};

	final Label lblTextAssist = new Label(shell, SWT.NONE);
	lblTextAssist.setText("Text field with text assist:");

	final TextAssist textAssist = new TextAssist(shell, SWT.SINGLE | SWT.BORDER, contentProvider);
	textAssist.setLayoutData(new GridData(150, SWT.DEFAULT));

	new Label(shell, SWT.NONE);
	final Label lblSimpleText = new Label(shell, SWT.NONE);
	lblSimpleText.setText("Simple Text field:");

	final Text text = new Text(shell, SWT.SINGLE | SWT.BORDER);
	text.setLayoutData(new GridData(150, SWT.DEFAULT));

	new Label(shell, SWT.NONE);
	final Button button = new Button(shell, SWT.PUSH);
	button.setText("Force focus on Text Assist Field");
	button.addListener(SWT.Selection, e -> textAssist.setFocus());

	new Label(shell, SWT.NONE);
	final Button singleClickButton = new Button(shell, SWT.CHECK);
	singleClickButton.setText("Use single click to select an entry");
	singleClickButton.addListener(SWT.Selection, e -> {
		useSingleClick = !useSingleClick;
		textAssist.setUseSingleClick(useSingleClick);
	});

	shell.pack();
	shell.open();

	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
	}
	display.dispose();
}
 
Example 15
Source File: AbortDialog.java    From hop with Apache License 2.0 4 votes vote down vote up
private void buildOptions( Control widgetAbove ) {
  wOptionsGroup = new Group( shell, SWT.SHADOW_ETCHED_IN );
  props.setLook( wOptionsGroup );
  wOptionsGroup.setText( BaseMessages.getString( PKG, "AbortDialog.Options.Group.Label" ) );
  FormLayout flOptionsGroup = new FormLayout();
  flOptionsGroup.marginHeight = 15;
  flOptionsGroup.marginWidth = 15;
  wOptionsGroup.setLayout( flOptionsGroup );

  FormData fdOptionsGroup = new FormData();
  fdOptionsGroup.left = new FormAttachment( 0, 0 );
  fdOptionsGroup.top = new FormAttachment( widgetAbove, 15 );
  fdOptionsGroup.right = new FormAttachment( 100, 0 );
  wOptionsGroup.setLayoutData( fdOptionsGroup );

  wAbortButton = new Button( wOptionsGroup, SWT.RADIO );
  wAbortButton.addSelectionListener( lsSelMod );
  wAbortButton.setText( BaseMessages.getString( PKG, "AbortDialog.Options.Abort.Label" ) );
  FormData fdAbort = new FormData();
  fdAbort.left = new FormAttachment( 0, 0 );
  fdAbort.top = new FormAttachment( 0, 0 );
  wAbortButton.setLayoutData( fdAbort );
  props.setLook( wAbortButton );

  wAbortWithErrorButton = new Button( wOptionsGroup, SWT.RADIO );
  wAbortWithErrorButton.addSelectionListener( lsSelMod );
  wAbortWithErrorButton.setText( BaseMessages.getString( PKG, "AbortDialog.Options.AbortWithError.Label" ) );
  FormData fdAbortWithError = new FormData();
  fdAbortWithError.left = new FormAttachment( 0, 0 );
  fdAbortWithError.top = new FormAttachment( wAbortButton, 10 );
  wAbortWithErrorButton.setLayoutData( fdAbortWithError );
  props.setLook( wAbortWithErrorButton );

  wSafeStopButton = new Button( wOptionsGroup, SWT.RADIO );
  wSafeStopButton.addSelectionListener( lsSelMod );
  wSafeStopButton.setText( BaseMessages.getString( PKG, "AbortDialog.Options.SafeStop.Label" ) );
  FormData fdSafeStop = new FormData();
  fdSafeStop.left = new FormAttachment( 0, 0 );
  fdSafeStop.top = new FormAttachment( wAbortWithErrorButton, 10 );
  wSafeStopButton.setLayoutData( fdSafeStop );
  props.setLook( wSafeStopButton );

  wlRowThreshold = new Label( wOptionsGroup, SWT.RIGHT );
  wlRowThreshold.setText( BaseMessages.getString( PKG, "AbortDialog.Options.RowThreshold.Label" ) );
  props.setLook( wlRowThreshold );
  fdlRowThreshold = new FormData();
  fdlRowThreshold.left = new FormAttachment( 0, 0 );
  fdlRowThreshold.top = new FormAttachment( wSafeStopButton, 10 );
  wlRowThreshold.setLayoutData( fdlRowThreshold );

  wRowThreshold = new TextVar( pipelineMeta, wOptionsGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
  wRowThreshold.setText( "" );
  props.setLook( wRowThreshold );
  wRowThreshold.addModifyListener( lsMod );
  wRowThreshold.setToolTipText( BaseMessages.getString( PKG, "AbortDialog.Options.RowThreshold.Tooltip" ) );
  fdRowThreshold = new FormData();
  fdRowThreshold.left = new FormAttachment( 0, 0 );
  fdRowThreshold.top = new FormAttachment( wlRowThreshold, 5 );
  fdRowThreshold.width = 174;
  wRowThreshold.setLayoutData( fdRowThreshold );
}
 
Example 16
Source File: CCombo.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Constructs a new instance of this class given its parent
 * and a style value describing its behavior and appearance.
 * <p>
 * The style value is either one of the style constants defined in
 * class <code>SWT</code> which is applicable to instances of this
 * class, or must be built by <em>bitwise OR</em>'ing together 
 * (that is, using the <code>int</code> "|" operator) two or more
 * of those <code>SWT</code> style constants. The class description
 * lists the style constants that are applicable to the class.
 * Style bits are also inherited from superclasses.
 * </p>
 *
 * @param parent a widget which will be the parent of the new instance (cannot be null)
 * @param style the style of widget to construct
 *
 * @exception IllegalArgumentException <ul>
 *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
 * </ul>
 * @exception SWTException <ul>
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
 * </ul>
 *
 * @see SWT#BORDER
 * @see SWT#READ_ONLY
 * @see SWT#FLAT
 * @see Widget#getStyle()
 */
public CCombo (Composite parent, int style) {
	super (parent, style = checkStyle (style));
	
	int textStyle = SWT.SINGLE;
	if ((style & SWT.READ_ONLY) != 0) textStyle |= SWT.READ_ONLY;
	if ((style & SWT.FLAT) != 0) textStyle |= SWT.FLAT;
	text = new Text (this, textStyle);
	int arrowStyle = SWT.ARROW | SWT.DOWN;
	if ((style & SWT.FLAT) != 0) arrowStyle |= SWT.FLAT;
	arrow = new Button (this, arrowStyle);

	listener = new Listener () {
		public void handleEvent (Event event) {
			if (popup == event.widget) {
				popupEvent (event);
				return;
			}
			if (text == event.widget) {
				textEvent (event);
				return;
			}
			if (list == event.widget) {
				listEvent (event);
				return;
			}
			if (arrow == event.widget) {
				arrowEvent (event);
				return;
			}
			if (CCombo.this == event.widget) {
				comboEvent (event);
				return;
			}

		}
	};
	
	
	int [] comboEvents = {SWT.Dispose, SWT.Move, SWT.Resize};
	for (int i=0; i<comboEvents.length; i++) this.addListener (comboEvents [i], listener);
	
	int [] textEvents = {SWT.KeyDown, SWT.KeyUp, SWT.Modify, SWT.MouseDown, SWT.MouseUp, SWT.Traverse, SWT.FocusIn, SWT.FocusOut};
	for (int i=0; i<textEvents.length; i++) text.addListener (textEvents [i], listener);
	
	int [] arrowEvents = {SWT.Selection, SWT.FocusIn, SWT.FocusOut};
	for (int i=0; i<arrowEvents.length; i++) arrow.addListener (arrowEvents [i], listener);
	
	createPopup(null, -1);
	initAccessible();
	
}
 
Example 17
Source File: WorkflowExecutorDialog.java    From hop with Apache License 2.0 4 votes vote down vote up
private void addParametersTab() {
  CTabItem wParametersTab = new CTabItem( wTabFolder, SWT.NONE );
  wParametersTab.setText( BaseMessages.getString( PKG, "JobExecutorDialog.Parameters.Title" ) );
  wParametersTab.setToolTipText( BaseMessages.getString( PKG, "JobExecutorDialog.Parameters.Tooltip" ) );

  Composite wParametersComposite = new Composite( wTabFolder, SWT.NONE );
  props.setLook( wParametersComposite );

  FormLayout parameterTabLayout = new FormLayout();
  parameterTabLayout.marginWidth = 15;
  parameterTabLayout.marginHeight = 15;
  wParametersComposite.setLayout( parameterTabLayout );

  // Add a button: get parameters
  //
  wGetParameters = new Button( wParametersComposite, SWT.PUSH );
  wGetParameters.setText( BaseMessages.getString( PKG, "JobExecutorDialog.Parameters.GetParameters" ) );
  props.setLook( wGetParameters );
  FormData fdGetParameters = new FormData();
  fdGetParameters.bottom = new FormAttachment( 100, 0 );
  fdGetParameters.right = new FormAttachment( 100, 0 );
  wGetParameters.setLayoutData( fdGetParameters );
  wGetParameters.setSelection( workflowExecutorMeta.getParameters().isInheritingAllVariables() );
  wGetParameters.addSelectionListener( new SelectionAdapter() {
    public void widgetSelected( SelectionEvent e ) {
      getParametersFromWorkflow( null ); // null : reload file
    }
  } );

  // Now add a table view with the 3 columns to specify: variable name, input field & optional static input
  //
  parameterColumns =
    new ColumnInfo[] {
      new ColumnInfo(
        BaseMessages.getString( PKG, "JobExecutorDialog.Parameters.column.Variable" ),
        ColumnInfo.COLUMN_TYPE_TEXT, false, false ),
      new ColumnInfo(
        BaseMessages.getString( PKG, "JobExecutorDialog.Parameters.column.Field" ),
        ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] {}, false ),
      new ColumnInfo(
        BaseMessages.getString( PKG, "JobExecutorDialog.Parameters.column.Input" ),
        ColumnInfo.COLUMN_TYPE_TEXT, false, false ), };
  parameterColumns[ 1 ].setUsingVariables( true );

  WorkflowExecutorParameters parameters = workflowExecutorMeta.getParameters();
  wWorkflowExecutorParameters =
    new TableView(
      pipelineMeta, wParametersComposite, SWT.FULL_SELECTION | SWT.SINGLE | SWT.BORDER, parameterColumns,
      parameters.getVariable().length, lsMod, props );
  props.setLook( wWorkflowExecutorParameters );
  FormData fdJobExecutors = new FormData();
  fdJobExecutors.left = new FormAttachment( 0, 0 );
  fdJobExecutors.right = new FormAttachment( 100, 0 );
  fdJobExecutors.top = new FormAttachment( 0, 0 );
  fdJobExecutors.bottom = new FormAttachment( wGetParameters, -10 );
  wWorkflowExecutorParameters.setLayoutData( fdJobExecutors );
  wWorkflowExecutorParameters.getTable().addListener( SWT.Resize, new ColumnsResizer( 0, 33, 33, 33 ) );

  for ( int i = 0; i < parameters.getVariable().length; i++ ) {
    TableItem tableItem = wWorkflowExecutorParameters.table.getItem( i );
    tableItem.setText( 1, Const.NVL( parameters.getVariable()[ i ], "" ) );
    tableItem.setText( 2, Const.NVL( parameters.getField()[ i ], "" ) );
    tableItem.setText( 3, Const.NVL( parameters.getInput()[ i ], "" ) );
  }
  wWorkflowExecutorParameters.setRowNums();
  wWorkflowExecutorParameters.optWidth( true );

  // Add a checkbox: inherit all variables...
  //
  wInheritAll = new Button( wParametersComposite, SWT.CHECK );
  wInheritAll.setText( BaseMessages.getString( PKG, "JobExecutorDialog.Parameters.InheritAll" ) );
  props.setLook( wInheritAll );
  FormData fdInheritAll = new FormData();
  fdInheritAll.left = new FormAttachment( 0, 0 );
  fdInheritAll.top = new FormAttachment( wWorkflowExecutorParameters, 15 );
  wInheritAll.setLayoutData( fdInheritAll );
  wInheritAll.setSelection( workflowExecutorMeta.getParameters().isInheritingAllVariables() );

  FormData fdParametersComposite = new FormData();
  fdParametersComposite.left = new FormAttachment( 0, 0 );
  fdParametersComposite.top = new FormAttachment( 0, 0 );
  fdParametersComposite.right = new FormAttachment( 100, 0 );
  fdParametersComposite.bottom = new FormAttachment( 100, 0 );
  wParametersComposite.setLayoutData( fdParametersComposite );

  wParametersComposite.layout();
  wParametersTab.setControl( wParametersComposite );
}
 
Example 18
Source File: Widgets.java    From depan with Apache License 2.0 4 votes vote down vote up
public static Text buildGridBoxedText(Composite parent) {
  Text result = new Text(parent, SWT.BORDER | SWT.SINGLE);
  result.setLayoutData(buildHorzFillData());
  return result;
}
 
Example 19
Source File: AnnotateView.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Show the annotation view.
 * @param svnFile
 * @param svnAnnotateBlocks
 * @param contents
 * @param useHistoryView
 * @throws PartInitException
 */
public void showAnnotations(ISVNRemoteFile svnFile, Collection svnAnnotateBlocks, InputStream contents, boolean useHistoryView) throws PartInitException {

	// Disconnect from old annotation editor
	disconnect();
	
	// Remove old viewer
	Control[] oldChildren = top.getChildren();
	if (oldChildren != null) {
		for (int i = 0; i < oldChildren.length; i++) {
			oldChildren[i].dispose();
		}
	}

	viewer = new ListViewer(top, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
	viewer.setContentProvider(new ArrayContentProvider());
	viewer.setLabelProvider(new LabelProvider());
	viewer.addSelectionChangedListener(this);
	viewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));

	PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), IHelpContextIds.ANNOTATIONS_VIEW);

	top.layout();
	
	this.svnFile = svnFile;
	this.contents = contents;
	this.svnAnnotateBlocks = svnAnnotateBlocks;
	page = SVNUIPlugin.getActivePage();
	viewer.setInput(svnAnnotateBlocks);
	editor = (ITextEditor) openEditor();
	IDocumentProvider provider = editor.getDocumentProvider();
	document = provider.getDocument(editor.getEditorInput());

	setPartName(Policy.bind("SVNAnnotateView.showFileAnnotation", new Object[] {svnFile.getName()})); //$NON-NLS-1$
	setTitleToolTip(svnFile.getName());
	
	if (!useHistoryView) {
		return;
	}

	// Get hook to the HistoryView
	historyView = (IHistoryView)page.showView(ISVNUIConstants.HISTORY_VIEW_ID);
	if (historyView != null) {
		historyView.showHistoryFor(svnFile);
	}
}
 
Example 20
Source File: SelectBestellungDialog.java    From elexis-3-core with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Return the style flags for the table viewer.
 * 
 * @return int
 */
protected int getTableStyle(){
	return SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION;
}