Java Code Examples for org.eclipse.swt.widgets.Control

The following examples show how to use org.eclipse.swt.widgets.Control. These examples are extracted from open source projects. 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 Project: Pydev   Source File: DebuggerTestUtils.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @return an action that can be run to create a breakpoint in the given line
 */
public PyBreakpointRulerAction createAddBreakPointAction(final int line) {
    PyBreakpointRulerAction ret = new PyBreakpointRulerAction(debugEditor, new IVerticalRulerInfo() {
        @Override
        public int getLineOfLastMouseButtonActivity() {
            return line;
        }

        @Override
        public Control getControl() {
            throw new RuntimeException("Not Implemented");
        }

        @Override
        public int getWidth() {
            throw new RuntimeException("Not Implemented");
        }

        @Override
        public int toDocumentLineNumber(int y_coordinate) {
            throw new RuntimeException("Not Implemented");
        }
    });
    ret.update();
    return ret;
}
 
Example 2
@Override
protected Control createContents(final Composite parent) {

    final Composite mainComposite = new Composite(parent, SWT.NONE);
    mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).create());

    createFunctionCategories(mainComposite);

    final SashForm sashForm = new SashForm(mainComposite, SWT.VERTICAL);
    sashForm.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(250, 250).minSize(100, SWT.DEFAULT).create());
    final GridLayout gridLaout = GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 2).create();
    sashForm.setLayout(gridLaout);
    createFunctionsList(sashForm);
    createFunctionDocumentaion(sashForm);

    sashForm.setWeights(new int[] { 1, 1 });

    return mainComposite;
}
 
Example 3
protected Control createDialogArea(Composite parent) {
	setTitleImage(CodewindUIPlugin.getImage(CodewindUIPlugin.CODEWIND_BANNER));
	setTitle(Messages.RegMgmtDialogTitle);
	if (connection.isLocal()) {
		setMessage(Messages.RegMgmtDialogLocalMessage);
	} else {
		setMessage(Messages.RegMgmtDialogMessage);
	}
	
	Composite content = (Composite) super.createDialogArea(parent);
	content.setLayout(new GridLayout());
	content.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
	
	regComposite = new RegistryManagementComposite(content, connection, regList, pushReg);
	GridData data = new GridData(GridData.FILL, GridData.FILL, true, true);
	data.widthHint = 250;
	regComposite.setLayoutData(data);

	return parent; 
}
 
Example 4
@Override
protected Control createDialogArea(Composite parent) {
	Composite tparent = (Composite) super.createDialogArea(parent);
	GridDataFactory.fillDefaults().grab(true, true).hint(500, 450).applyTo(tparent);
	GridLayoutFactory.fillDefaults().spacing(0, 0).extendedMargins(8, 8, 0, 8).applyTo(tparent);

	createMenu(tparent);
	createToolBar(tparent);

	styledText = new StyledText(tparent, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.WRAP);
	GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).hint(100, 100).grab(true, true).applyTo(styledText);
	styledText.setText("");

	tparent.layout();
	getShell().layout();
	return tparent;
}
 
Example 5
@Override
protected Control createContents(Composite parent) {
	fPixelConverter= new PixelConverter(parent);
	setShell(parent.getShell());

	Composite mainComp= new Composite(parent, SWT.NONE);
	mainComp.setFont(parent.getFont());
	GridLayout layout= new GridLayout();
	layout.marginHeight= 0;
	layout.marginWidth= 0;
	mainComp.setLayout(layout);

	Composite othersComposite= createBuildPathTabContent(mainComp);
	GridData gridData= new GridData(GridData.FILL, GridData.FILL, true, true);
	gridData.heightHint= fPixelConverter.convertHeightInCharsToPixels(20);
	othersComposite.setLayoutData(gridData);

	validateSettings(null, null, null);

	return mainComp;
}
 
Example 6
protected Control createContents(Composite parent)
{
	Composite composite = new Composite(parent, SWT.NONE);
	GridLayout layout = new GridLayout();
	layout.marginHeight = 0;
	layout.marginWidth = 0;
	composite.setLayout(layout);
	composite.setFont(parent.getFont());

	GridData data = new GridData(GridData.FILL, GridData.FILL, true, true);

	fConfigurationBlockControl = createPreferenceContent(composite);
	fConfigurationBlockControl.setLayoutData(data);

	if (isProjectPreferencePage())
	{
		boolean useProjectSettings = hasProjectSpecificOptions(getProject());
		enableProjectSpecificSettings(useProjectSettings);
	}

	Dialog.applyDialogFont(composite);
	return composite;
}
 
Example 7
private Control createSearchFor(Composite parent) {
	Group result= new Group(parent, SWT.NONE);
	result.setText(SearchMessages.SearchPage_searchFor_label);
	result.setLayout(new GridLayout(2, true));

	fSearchFor= new Button[] {
		createButton(result, SWT.RADIO, SearchMessages.SearchPage_searchFor_type, TYPE, true),
		createButton(result, SWT.RADIO, SearchMessages.SearchPage_searchFor_method, METHOD, false),
		createButton(result, SWT.RADIO, SearchMessages.SearchPage_searchFor_package, PACKAGE, false),
		createButton(result, SWT.RADIO, SearchMessages.SearchPage_searchFor_constructor, CONSTRUCTOR, false),
		createButton(result, SWT.RADIO, SearchMessages.SearchPage_searchFor_field, FIELD, false)
	};

	// Fill with dummy radio buttons
	Label filler= new Label(result, SWT.NONE);
	filler.setVisible(false);
	filler.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));

	return result;
}
 
Example 8
/**
 * 刷新过滤器设置组件
 */
private void refresh() {
	filterNameTxt.setText("");
	andBtn.setSelection(true);
	orBtn.setSelection(false);
	btnIsTagged.setSelection(false);
	btnQT.setSelection(false);
	btnPT.setSelection(false);
	if (btnIsRemoveFromSrc != null) {
		btnIsRemoveFromSrc.setSelection(false);
	}
	for (Control ctl : conditionList) {
		if (!ctl.isDisposed()) {
			ctl.dispose();
		}
	}
	conditionList.clear();
	new DynaComposite(dynaComp, SWT.NONE);
	scroll.setMinSize(dynaComp.computeSize(SWT.DEFAULT, SWT.DEFAULT));
	dynaComp.layout();

}
 
Example 9
@Override
public Control[] doFillIntoGrid(Composite parent, int nColumns)
{
	assertEnoughColumns(nColumns);

	Button button = getSelectionButton(parent);
	GridData gd = new GridData();
	gd.horizontalSpan = nColumns;
	gd.horizontalAlignment = GridData.FILL;
	if (fButtonStyle == SWT.PUSH)
	{
		gd.widthHint = getButtonWidthHint(button);
	}

	button.setLayoutData(gd);

	return new Control[] { button };
}
 
Example 10
/**
 * 刷新过滤器设置组件
 */
private void refresh() {
	filterNameTxt.setText("");
	andBtn.setSelection(true);
	orBtn.setSelection(false);
	for (Control ctl : conditionList) {
		if (!ctl.isDisposed()) {
			ctl.dispose();
		}
	}
	conditionList.clear();
	new DynaComposite(dynaComp, SWT.NONE);
	scroll.setMinSize(dynaComp.computeSize(SWT.DEFAULT, SWT.DEFAULT));
	dynaComp.layout();

}
 
Example 11
Source Project: birt   Source File: DataDefinitionTextManager.java    License: Eclipse Public License 1.0 6 votes vote down vote up
public void addDataDefinitionText( Control text,
		IQueryExpressionManager queryManager )
{
	textCollection.put( text, queryManager );
	// update control color when switching.
	updateControlBackground( text, queryManager.getQuery( ).getDefinition( ) );
	text.addDisposeListener( new DisposeListener( ) {

		public void widgetDisposed( DisposeEvent e )
		{
			if ( e.widget instanceof Control )
			{
				removeDataDefinitionText( (Control) e.widget );
			}

		}
	} );
}
 
Example 12
Source Project: tm4e   Source File: TMinGenericEditorTest.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testTMHighlightInGenericEditorEdit() throws IOException, PartInitException {
	f = File.createTempFile("test" + System.currentTimeMillis(), ".ts");
	FileOutputStream fileOutputStream = new FileOutputStream(f);
	fileOutputStream.write("let a = '';".getBytes());
	fileOutputStream.close();
	f.deleteOnExit();
	editor = IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(),
			f.toURI(), editorDescriptor.getId(), true);
	StyledText text = (StyledText)editor.getAdapter(Control.class);
	Assert.assertTrue(new DisplayHelper() {
		@Override
		protected boolean condition() {
			return text.getStyleRanges().length > 1;
		}
	}.waitForCondition(text.getDisplay(), 3000));
	int initialNumberOfRanges = text.getStyleRanges().length;
	text.setText("let a = '';\nlet b = 10;\nlet c = true;");
	Assert.assertTrue("More styles should have been added", new DisplayHelper() {
		@Override protected boolean condition() {
			return text.getStyleRanges().length > initialNumberOfRanges + 3;
		}
	}.waitForCondition(text.getDisplay(), 300000));
}
 
Example 13
Source Project: nebula   Source File: InternalCompositeTable.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Indicate to listeners that the focus is arriving on the specified row
 */
private void fireRowArriveEvent() {
       if (rows.size() < 1 || !isRowVisible(currentRow)) {
           return;
       }
       for (Iterator<?> rowChangeListenersIter = parent.rowFocusListeners
               .iterator(); rowChangeListenersIter.hasNext();) {
           IRowFocusListener listener = 
               (IRowFocusListener) rowChangeListenersIter.next();
           // currentRow() can be null if it's scrolled off the top or bottom
           TableRow row = currentRow();
           Control control = row != null ? row.getRowControl() : null;
           listener.arrive(parent, topRow + currentRow, control);
       }

}
 
Example 14
void updateSearchScope(FindScope scope)
{
	findScope = scope;
	scopeToolItem.setImage(FindBarPlugin.getImage(scopeMap.get(findScope)));
	scopeToolItem.setToolTipText(MessageFormat.format(Messages.FindBarDecorator_TOOLTIP_Scope_menu_item,
			findScope.toString()));

	boolean isCurrentFile = findScope == FindScope.CURRENT_FILE;
	Control[] controls = new Control[] { textReplace, replace, replaceAll, replaceFind };

	for (Control control : controls)
	{
		control.setEnabled(isCurrentFile);
	}
	textReplace.setBackground(isCurrentFile ? null : UIUtils.getDisplay().getSystemColor(
			SWT.COLOR_WIDGET_BACKGROUND));
	replaceHistory.setEnabled(isCurrentFile);
	searchSelection.setEnabled(isCurrentFile);
	countMatches.setEnabled(isCurrentFile);
}
 
Example 15
Source Project: arx   Source File: ComponentTitledSeparator.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Redraw the composite
 */
private void redrawComposite() {
        // Dispose previous content
        for (final Control c : this.getChildren()) {
                c.dispose();
        }

        int numberOfColumns = 1;

        if (this.text != null) {
                numberOfColumns++;
        }

        if (this.image != null) {
                numberOfColumns++;
        }

        if (this.alignment == SWT.CENTER) {
                numberOfColumns++;
        }

        super.setLayout(new GridLayout(numberOfColumns, false));
        createContent();
}
 
Example 16
private void showPage(int page) {
boolean isEmpty= page == PAGE_EMPTY;
Control control= isEmpty ? (Control) fNoHierarchyShownLabel : fHierarchyLocationSplitter;
if (isEmpty) {
	setContentDescription(""); //$NON-NLS-1$
	setTitleToolTip(getPartName());
	getViewSite().getActionBars().getStatusLineManager().setMessage(""); //$NON-NLS-1$
	getViewer().clearViewer();
}
fPagebook.showPage(control);
if (fRefreshViewAction != null)
	fRefreshViewAction.setEnabled(!isEmpty);
if (fRefreshSingleElementAction != null)
	fRefreshSingleElementAction.setEnabled(!isEmpty);
  }
 
Example 17
/**
 * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
 */
public void handleEvent(Event event) {
	switch (event.type) {
	case SWT.KeyDown:
		textModified = true;
		if (event.character == SWT.CR)
			textChanged((Control) event.widget);
		break;
	case SWT.FocusOut:
		textChanged((Control) event.widget);
		break;
	}
}
 
Example 18
Source Project: typescript.java   Source File: TypeScriptTemplatePreferencePage.java    License: MIT License 5 votes vote down vote up
protected Control createContents(Composite ancestor) {
	ScrolledPageContent scrolled= new ScrolledPageContent(ancestor, SWT.H_SCROLL | SWT.V_SCROLL);
	scrolled.setExpandHorizontal(true);
	scrolled.setExpandVertical(true);
	
	Control control= super.createContents(scrolled);

	scrolled.setContent(control); 
	final Point size= control.computeSize(SWT.DEFAULT, SWT.DEFAULT);
	scrolled.setMinSize(size.x, size.y);
	
	return scrolled;
}
 
Example 19
Source Project: offspring   Source File: PlaceBidOrderWizard.java    License: MIT License 5 votes vote down vote up
@Override
public Control createControl(Composite parent) {
  Composite composite = new Composite(parent, SWT.NONE);
  GridLayoutFactory.fillDefaults().numColumns(2).spacing(10, 0)
      .margins(0, 0).applyTo(composite);

  textAsset = new Text(composite, SWT.BORDER);
  GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER)
      .grab(true, false).applyTo(textAsset);

  String id = presetAssetId != null ? Convert.toUnsignedLong(presetAssetId)
      : "";
  textAsset.setText(id);
  textAsset.addModifyListener(new ModifyListener() {

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

  labelAssetName = new Label(composite, SWT.NONE);

  GC gc = new GC(labelAssetName);
  GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER)
      .hint(gc.textExtent(THIRD_COLUMN).x, SWT.DEFAULT)
      .applyTo(labelAssetName);
  gc.dispose();

  labelAssetName.setText(EMPTY_NAME);
  return composite;
}
 
Example 20
Source Project: tlaplus   Source File: SpecPropertyPage.java    License: MIT License 5 votes vote down vote up
protected Control createContents(Composite parent) {
	Control control = super.createContents(parent);

	// ensure the page has no special buttons
	noDefaultAndApplyButton();

	UIHelper.setHelp(control, IHelpConstants.SPEC_PROPERTY_PAGE);
	return control;
}
 
Example 21
@Override
protected Control createDialogArea(Composite parent) {
	Composite composite= (Composite) super.createDialogArea(parent);
	Composite inner= new Composite(composite, SWT.NONE);
	inner.setFont(composite.getFont());
	GridLayout layout= new GridLayout();
	layout.marginHeight= 0;
	layout.marginWidth= 0;
	layout.numColumns= 2;
	inner.setLayout(layout);

	fMessageField.doFillIntoGrid(inner, 2);
	fPrefixField.doFillIntoGrid(inner, 2);
	fSuffixField.doFillIntoGrid(inner, 2);

	LayoutUtil.setHorizontalGrabbing(fPrefixField.getTextControl(null));
	LayoutUtil.setWidthHint(fPrefixField.getTextControl(null), convertWidthInCharsToPixels(45));
	LayoutUtil.setWidthHint(fSuffixField.getTextControl(null), convertWidthInCharsToPixels(45));

	fPrefixField.postSetFocusOnDialogField(parent.getDisplay());

	applyDialogFont(composite);

	PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IJavaHelpContextIds.CODE_STYLE_EDIT_PREFIX_SUFFIX);

	return composite;
}
 
Example 22
Source Project: gama   Source File: SliderEditor.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
protected Control createCustomParameterControl(final Composite comp) throws GamaRuntimeException {
	final List<GamaColor> colors = getParam().getColor(getScope());
	Color left = IGamaColors.OK.color();
	Color right = IGamaColors.GRAY_LABEL.lighter();
	Color thumb = left;
	if (colors != null) {
		if (colors.size() == 1) {
			left = thumb = GamaColors.get(colors.get(0)).color();
		} else if (colors.size() == 2) {
			left = GamaColors.get(colors.get(0)).color();
			right = GamaColors.get(colors.get(1)).color();
		} else if (colors.size() >= 3) {
			left = GamaColors.get(colors.get(0)).color();
			thumb = GamaColors.get(colors.get(1)).color();
			right = GamaColors.get(colors.get(2)).color();
		}
	}
	slider = new SimpleSlider(comp, left, right, thumb, false) {};

	if (stepValue != null) {
		final Double realStep = stepValue.doubleValue() / (maxValue.doubleValue() - minValue.doubleValue());
		slider.setStep(realStep);
	}

	slider.addPositionChangeListener((s, position) -> modifyAndDisplayValue(computeValue(position)));
	slider.pack(true);
	return slider;
}
 
Example 23
Source Project: tracecompass   Source File: ViewFilterDialog.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
    getShell().setText(Messages.AbstractTimeGraphView_TimeEventFilterDialogTitle);

    Composite container = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(3, false);
    layout.horizontalSpacing = 0;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    container.setLayout(layout);

    Composite labels = createCLabelsArea(container);
    createFilterTextArea(parent, container,  labels);
    createCloseButton(container);

    // support close on escape button
    getShell().addListener(SWT.Traverse, e -> {
        if (e.detail == SWT.TRAVERSE_ESCAPE) {
            clearFilter();
        }
    });

    for (String label : fFilterRegexes) {
        createCLabels(parent, labels, label);
    }

    fControl.addControlListener(fControlListener);
    fControl.getShell().addControlListener(fControlListener);

    return parent;
}
 
Example 24
Source Project: tesb-studio-se   Source File: NewOrEditDependencyDialog.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
    final String name = type;
    final boolean isNew = origin == null;
    getShell().setText(name);
    setTitle(MessageFormat.format(isNew ? Messages.NewDependencyItemDialog_addTitle
        : Messages.NewDependencyItemDialog_editTitle, name));
    setMessage(MessageFormat.format(isNew ? Messages.NewDependencyItemDialog_addMsg
        : Messages.NewDependencyItemDialog_editMsg, name));

    parent.setLayout(new GridLayout());

    Composite c = new Composite(parent, SWT.NONE);
    c.setLayout(new GridLayout(2, false));
    c.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    new Label(c, SWT.NONE).setText(Messages.NewDependencyItemDialog_name);
    fNameText = new Text(c, SWT.BORDER);
    fNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    if (type != ManifestItem.EXPORT_PACKAGE) {
        Group propertiesGroup = new Group(parent, SWT.NONE);
        propertiesGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        propertiesGroup.setText(Messages.NewOrEditDependencyDialog_properties);
        propertiesGroup.setLayout(new GridLayout());
        fOptionalBtn = new Button(propertiesGroup, SWT.CHECK);
        fOptionalBtn.setText(Messages.NewDependencyItemDialog_optional);
    }

    fVersionPart.createVersionFields(parent, true, true);

    preloadFields();
    addListeners();
    return c;
}
 
Example 25
Source Project: tmxeditor8   Source File: SegmentViewer.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 重置 ;
 */
public void reset() {
	StyledText styledText = getTextWidget();
	Control[] children = styledText.getChildren();
	for (Control child : children) {
		if (child != null && !child.isDisposed()) {
			child.dispose();
		}
	}
	innerTagCacheList.clear();
	errorTagStart = 0;
}
 
Example 26
/**
 * {@inheritDoc}
 */
public Menu getMenu(Control parent) {
	setMenu(new Menu(parent));
	fillMenu(fMenu);
	initMenu(fMenu);
	return fMenu;
}
 
Example 27
Source Project: pentaho-kettle   Source File: MqttDialogSecurityLayout.java    License: Apache License 2.0 5 votes vote down vote up
private void buildSSLTable( Composite parentWidget, Control relativePosition ) {
  ColumnInfo[] columns = getSSLColumns();

  sslTable = new TableView(
    transMeta,
    parentWidget,
    SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI,
    columns,
    0,  // num of starting rows (will be added later)
    false,
    lsMod,
    props,
    false
  );

  sslTable.setSortable( false );
  sslTable.getTable().addListener( SWT.Resize, event -> {
    Table table = (Table) event.widget;
    table.getColumn( 1 ).setWidth( 200 );
    table.getColumn( 2 ).setWidth( 200 );
  } );

  populateSSLData();

  FormData fdData = new FormData();
  fdData.left = new FormAttachment( 0, 0 );
  fdData.top = new FormAttachment( relativePosition, 5 );
  fdData.bottom = new FormAttachment( 100, 0 );
  fdData.width = INPUT_WIDTH + 80;

  // resize the columns to fit the data in them
  stream( sslTable.getTable().getColumns() ).forEach( column -> {
    if ( column.getWidth() > 0 ) {
      // don't pack anything with a 0 width, it will resize it to make it visible (like the index column)
      column.setWidth( 200 );
    }
  } );

  sslTable.setLayoutData( fdData );
}
 
Example 28
Source Project: birt   Source File: ReportPreviewFormPage.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public Control getPartControl( )
{
	if ( reportViewer instanceof SWTAbstractViewer )
	{
		return ( (SWTAbstractViewer) reportViewer ).getUI( );
		// reportViewer.setReportDesignFile( getReportDesignFilePath( ) );
	}
	return null;
}
 
Example 29
Source Project: uima-uimaj   Source File: CommonInputDialog.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
  Composite mainArea = (Composite) super.createDialogArea(parent, existing);

  text = newSingleLineStyledText(mainArea, "");
  AbstractSection.spacer(mainArea);
  newErrorMessage(mainArea);

  if (null != existing)
    text.setText(existing);
  else
    text.setText(S_);

  return mainArea;
}
 
Example 30
Source Project: birt   Source File: OptionsConfigurationBlock.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public void selectOption( Key key )
{
	Control control = findControl( key );
	if ( control != null )
	{
		control.setFocus( );
	}
}