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

The following examples show how to use org.eclipse.swt.SWT#LEAD . 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: nebula   File: CDateTime.java    License: Eclipse Public License 2.0 6 votes vote down vote up
private static int convertStyle(int style) {
	int rstyle = SWT.NONE;
	if ((style & CDT.DROP_DOWN) != 0) {
		rstyle |= SWT.DROP_DOWN;
	}
	if ((style & CDT.SIMPLE) != 0) {
		rstyle |= SWT.SIMPLE;
	}
	if ((style & CDT.READ_ONLY) != 0) {
		rstyle |= SWT.READ_ONLY;
	}
	if ((style & CDT.BUTTON_LEFT) != 0) {
		rstyle |= SWT.LEFT;
	}
	if ((style & CDT.TEXT_LEAD) != 0) {
		rstyle |= SWT.LEAD;
	}
	if ((style & CDT.BORDER) != 0) {
		rstyle |= SWT.BORDER;
	}
	if (win32) {
		rstyle |= SWT.DOUBLE_BUFFERED;
	}
	return rstyle;
}
 
Example 2
public static int convertColumnAlignmentToSWT(int align) {
	int swt = 0;
	int hAlign = align & 3;
	if (hAlign == TableColumn.ALIGN_CENTER) {
		swt = SWT.CENTER;
	} else if (hAlign == TableColumn.ALIGN_LEAD) {
		swt = SWT.LEAD;
	} else if (hAlign == TableColumn.ALIGN_TRAIL) {
		swt = SWT.TRAIL;
	} else {
		swt = SWT.LEAD;
	}
	int vAlign = align & ~3;
	if (vAlign == TableColumn.ALIGN_TOP) {
		swt |= SWT.TOP;
	} else if (vAlign == TableColumn.ALIGN_BOTTOM) {
		swt |= SWT.BOTTOM;
	}
	return swt;
}
 
Example 3
/**
 * Helper method to create a row of a {@link Label}, a {@link Text} for a file path input, and
 * a "browse" {@link Button} to open a {@link FileDialog}.
 *
 * @param fileFieldBasePath a base path that file input fields will treat as a prefix. The path is
 * for 1) relativizing absolute paths in file input fields; and 2) setting the default path for
 * the file chooser dialog.
 */
protected Text createBrowseFileRow(String labelText, String Tooltip,
    IPath fileFieldBasePath, String[] fileDialogfilterExtensions) {
  Label label = new Label(this, SWT.LEAD);
  label.setText(labelText);
  label.setToolTipText(Tooltip);

  Composite secondColumn = new Composite(this, SWT.NONE);
  Text fileField = new Text(secondColumn, SWT.SINGLE | SWT.BORDER);
  fileField.setToolTipText(Tooltip);

  Button browse = new Button(secondColumn, SWT.PUSH);
  browse.setText(Messages.getString("deploy.preferences.dialog.browse"));
  browse.addSelectionListener(
      new RelativeFileFieldSetter(fileField, fileFieldBasePath, fileDialogfilterExtensions));

  GridDataFactory.fillDefaults().applyTo(secondColumn);
  GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(fileField);
  GridLayoutFactory.fillDefaults().numColumns(2).generateLayout(secondColumn);
  return fileField;
}
 
Example 4
private Composite createBucketSection(Composite parent) {
  Composite bucketComposite = new Composite(parent, SWT.NONE);

  Label bucketLabel = new Label(bucketComposite, SWT.LEAD);
  bucketLabel.setText(Messages.getString("custom.bucket"));
  bucketLabel.setToolTipText(Messages.getString("tooltip.staging.bucket"));

  bucket = new Text(bucketComposite, SWT.LEAD | SWT.SINGLE | SWT.BORDER);
  bucket.setMessage(Messages.getString("custom.bucket.hint"));
  GridData bucketData = new GridData(SWT.FILL, SWT.CENTER, true, false);
  bucket.setLayoutData(bucketData);

  bucket.setToolTipText(Messages.getString("tooltip.staging.bucket"));

  GridLayoutFactory.fillDefaults().numColumns(2).generateLayout(bucketComposite);
  return bucketComposite;
}
 
Example 5
public MavenCoordinatesUi(Composite container, int style) {
  super(container, style);

  groupIdLabel = new Label(this, SWT.LEAD);
  groupIdLabel.setText(Messages.getString("GROUP_ID")); //$NON-NLS-1$
  groupIdField = new Text(this, SWT.BORDER);
  groupIdField.setToolTipText(Messages.getString("GROUP_ID_TOOLTIP")); //$NON-NLS-1$

  artifactIdLabel = new Label(this, SWT.LEAD);
  artifactIdLabel.setText(Messages.getString("ARTIFACT_ID")); //$NON-NLS-1$
  artifactIdField = new Text(this, SWT.BORDER);
  artifactIdField.setToolTipText(Messages.getString("ARTIFACT_ID_TOOLTIP")); //$NON-NLS-1$

  versionLabel = new Label(this, SWT.LEAD);
  versionLabel.setText(Messages.getString("ARTIFACT_VERSION")); //$NON-NLS-1$
  versionField = new Text(this, SWT.BORDER);
  versionField.setText(DEFAULT_VERSION);

  GridLayoutFactory.swtDefaults().numColumns(2).generateLayout(this);
}
 
Example 6
@Override
protected void createRuntimeField(Composite composite) {
  Label runtimeLabel = new Label(composite, SWT.LEAD);
  runtimeLabel.setText(Messages.getString("app.engine.standard.project.runtimetype")); //$NON-NLS-1$
  runtimeField = new ComboViewer(composite, SWT.READ_ONLY);
  runtimeField.setLabelProvider(new LabelProvider() {
    @Override
    public String getText(Object element) {
      return ((AppEngineRuntime) element).getLabel();
    }
  });
  runtimeField.setContentProvider(ArrayContentProvider.getInstance());
  runtimeField.setInput(AppEngineRuntime.STANDARD_RUNTIMES);
  runtimeField.setSelection(new StructuredSelection(DEFAULT_RUNTIME), true);
  runtimeField.addPostSelectionChangedListener(event -> revalidate());
}
 
Example 7
private void createParameterNameInput(Composite group) {
	Label l= new Label(group, SWT.NONE);
	l.setText(RefactoringMessages.ExtractClassWizard_field_name);

	final Text text= new Text(group, SWT.BORDER);
	fParameterNameDecoration= new ControlDecoration(text, SWT.TOP | SWT.LEAD);
	text.setText(fDescriptor.getFieldName());
	text.addModifyListener(new ModifyListener() {

		public void modifyText(ModifyEvent e) {
			fDescriptor.setFieldName(text.getText());
			validateRefactoring();
		}

	});
	GridData gridData= new GridData(GridData.FILL_HORIZONTAL);
	gridData.horizontalIndent= FieldDecorationRegistry.getDefault().getMaximumDecorationWidth();
	text.setLayoutData(gridData);
}
 
Example 8
private void createClassNameInput(Composite result) {
	Label label= new Label(result, SWT.LEAD);
	label.setText(RefactoringMessages.IntroduceParameterObjectWizard_classnamefield_label);
	final Text text= new Text(result, SWT.SINGLE | SWT.BORDER);
	text.setText(fProcessor.getClassName());
	text.selectAll();
	text.setFocus();
	text.addModifyListener(new ModifyListener() {

		public void modifyText(ModifyEvent e) {
			fProcessor.setClassName(text.getText());
			updateSignaturePreview();
			validateRefactoring();
		}

	});
	text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
}
 
Example 9
private Rectangle getTextBounds()
{
    Point textPoint = new Point(0, 0);

    textPoint.x = hMargin;
    textPoint.y = (titleHeight - fontHeight) / 2;

    if (getGroup().getImage() != null)
    {
        if ((getGroup().getImagePosition() & SWT.LEAD) != 0)
        {
            textPoint.x += getGroup().getImage().getBounds().width + betweenSpacing;
        }
    }
    if (getGroup().getToggleRenderer() != null)
    {
        if ((getGroup().getTogglePosition() & SWT.LEAD) != 0)
        {
            textPoint.x += getGroup().getToggleRenderer().getSize().x + betweenSpacing;
        }
    }

    int textWidth = getGroup().getSize().x - (hMargin * 2);

    if (getGroup().getImage() != null)
    {
        textWidth -= (getGroup().getImage().getBounds().width + betweenSpacing);
    }

    if (getGroup().getToggleRenderer() != null)
    {
        textWidth -= getGroup().getToggleRenderer().getSize().x + betweenSpacing;
    }

    return new Rectangle(textPoint.x, textPoint.y, textWidth, fontHeight);
}
 
Example 10
Source Project: nebula   File: BaseCombo.java    License: Eclipse Public License 2.0 5 votes vote down vote up
private void createText(int style) {
	textListener = new Listener() {
		public void handleEvent(Event event) {
			switch (event.type) {
			case SWT.KeyDown:
				if (event.stateMask == SWT.CTRL && event.keyCode == ' ') {
					event.doit = false;
					setOpen(true);
				}
				break;
			case SWT.Modify:
				Event e = new Event();
				e.time = event.time;
				setModifyEventProperties(e);
				notifyListeners(SWT.Modify, e);
				break;
			}
		}
	};

	int mask = SWT.TRAIL | SWT.LEAD;
	int textStyle = SWT.SINGLE | (style & mask);
	if (!win32 && (style & SWT.BORDER) != 0) {
		textStyle |= SWT.BORDER;
	}

	text = VNative.create(Text.class, panel, textStyle);
	addTextListener();
}
 
Example 11
@Override
protected CellEditor createCellEditorOn(Composite composite) {
    if (!Platform.getOS().equals(Platform.OS_MACOSX)) {
        ILabelDelegate label = (ILabelDelegate) getEditPart().getAdapter(
                ILabelDelegate.class);
        int style = SWT.WRAP | SWT.MULTI;
        if (label != null /* && label.isTextWrapOn() */) {

            switch (label.getTextJustification()) {
                case PositionConstants.LEFT:
                    style = style | SWT.LEAD;
                    break;
                case PositionConstants.RIGHT:
                    style = style | SWT.TRAIL;
                    break;
                case PositionConstants.CENTER:
                    style = style | SWT.CENTER;
                    break;
                default:
                    break;
            }
        }
        return new CustomWrapTextCellEditor(composite, style);
    } else {
        //USE normal textcelleditor if running on mac
        return super.createCellEditorOn(composite);
    }
}
 
Example 12
private void createProjectVersionSection() {
  Label versionLabel = new Label(this, SWT.LEAD);
  versionLabel.setText(Messages.getString("custom.versioning"));
  versionLabel.setToolTipText(Messages.getString("tooltip.version"));

  version = new Text(this, SWT.LEAD | SWT.SINGLE | SWT.BORDER);
  version.setMessage(Messages.getString("custom.versioning.hint"));
  version.setToolTipText(Messages.getString("tooltip.version"));
  GridData versionGridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
  version.setLayoutData(versionGridData);
}
 
Example 13
private void createPackageField(Composite parent) {
  Label packageNameLabel = new Label(parent, SWT.LEAD);
  packageNameLabel.setText(Messages.getString("java.package")); //$NON-NLS-1$
  javaPackageField = new Text(parent, SWT.BORDER);
  javaPackageField.addModifyListener(event -> revalidate());
  javaPackageField.addVerifyListener(event -> {
    // if the user ever changes the package name field, then we never auto-generate again.
    if (!javaPackageProgrammaticUpdate) {
      autoGeneratePackageName = false;
    }
  });
}
 
Example 14
private void createServiceField(Composite parent) {
  Label serviceNameLabel = new Label(parent, SWT.LEAD);
  serviceNameLabel.setText(Messages.getString("app.engine.service")); //$NON-NLS-1$
  serviceNameField = new Text(parent, SWT.BORDER);
  serviceNameField.setMessage("default"); //$NON-NLS-1$
  serviceNameField.addModifyListener(event -> revalidate());
}
 
Example 15
/**
 * Adds the Smart Insert Mode note to the preference page.
 * 
 * @param parent the parent composite
 * @since 3.7
 */
private void addSmartInsertModeMessage(Composite parent) {
	Label label= new Label(parent, SWT.LEAD | SWT.WRAP);
	label.setText(PreferencesMessages.JavaEditorPreferencePage_smartInsertMode_message);

	PixelConverter pixelConverter= new PixelConverter(parent);
	Label fillerLabel= new Label(parent, SWT.LEFT);
	GridData gridData= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
	gridData.horizontalSpan= 2;
	gridData.heightHint= pixelConverter.convertHeightInCharsToPixels(1) / 2;
	fillerLabel.setLayoutData(gridData);
}
 
Example 16
@Override
public void createComposite(final Composite parent) {
	this.parent = parent;
	internalModification = true;
	if (!isSubParameter) {
		titleLabel = createLeftLabel(parent, name, isSubParameter);
	} else {
		createLeftLabel(parent, " ", isSubParameter);
	}
	currentValue = getOriginalValue();
	composite = new Composite(parent, SWT.NONE);
	composite.setBackground(parent.getBackground());
	final GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false);
	data.minimumWidth = 150;
	composite.setLayoutData(data);
	final GridLayout layout = new GridLayout(isSubParameter ? 3 : 2, false);
	layout.marginWidth = 5;
	composite.setLayout(layout);
	createEditorControl(composite);
	if (isSubParameter) {
		titleLabel = createLeftLabel(composite, name, isSubParameter);
		titleLabel.setFont(GamaFonts.getNavigFolderFont());
		final GridData d = new GridData(SWT.LEAD, SWT.CENTER, true, false);
		titleLabel.setLayoutData(d);
	}

	internalModification = false;
	if (isSubParameter) {
		titleLabel.setBackground(HOVERED_BACKGROUND);
		composite.setBackground(HOVERED_BACKGROUND);
	}
	composite.layout();
}
 
Example 17
protected Rectangle getTextBounds()
{
    Point textPoint = new Point(0, 0);
    int textWidth = 0;
    Image image = getGroup().getImage();

    int titleAreaHeight = 0;

    if (image != null && !((getGroup().getImagePosition() & SWT.TOP) == 0))
    {
        titleAreaHeight = fontHeight + (2 * titleTextMargin) + (2 * vMargin);
        if (getGroup().getToggleRenderer() != null)
        {
            titleAreaHeight = Math.max(titleAreaHeight, getGroup().getToggleRenderer()
                .getSize().y
                                                        + (2 * vMargin));
        }
    }
    textPoint.x = hMargin;
    if (image != null)
    {
        if ((getGroup().getImagePosition() & SWT.LEAD) != 0)
        {
            textPoint.x += image.getBounds().width + betweenSpacing;
        }
        if ((getGroup().getImagePosition() & SWT.TOP) == 0)
        {
            textPoint.y = (titleHeight - fontHeight) / 2;
        }
        else
        {
            textPoint.y = (titleHeight - titleAreaHeight) + (titleAreaHeight - fontHeight) / 2;
        }
    }
    else
    {
        textPoint.y = (titleHeight - fontHeight) / 2;
    }

    // Part 2, Toggle
    if (getGroup().getToggleRenderer() != null)
    {
        if ((getGroup().getTogglePosition() & SWT.LEAD) != 0)
        {
            textPoint.x += getGroup().getToggleRenderer().getSize().x + betweenSpacing;
        }
    }

    textWidth = getGroup().getSize().x - (hMargin * 2);

    if (image != null)
    {
        textWidth -= (image.getBounds().width + betweenSpacing);
    }

    if (getGroup().getToggleRenderer() != null)
    {
        textWidth -= getGroup().getToggleRenderer().getSize().x + betweenSpacing;
    }

    return new Rectangle(textPoint.x, textPoint.y, textWidth, fontHeight);
}
 
Example 18
private Rectangle getTextBounds()
{
    int textX = hMargin;

    if ((getGroup().getImagePosition() & SWT.LEAD) != 0 && (getGroup().getImage() != null))
    {
        textX += getGroup().getImage().getBounds().width + betweenSpacing;
    }
    if ((getGroup().getTogglePosition() & SWT.LEAD) != 0
        && (getGroup().getToggleRenderer() != null))
    {
        textX += getGroup().getToggleRenderer().getSize().x + betweenSpacing;
    }

    int textWidth = getGroup().getSize().x - textX - hMargin;
    if (!((getGroup().getImagePosition() & SWT.LEAD) != 0) && (getGroup().getImage() != null))
    {
        textWidth -= getGroup().getImage().getBounds().width + betweenSpacing;
    }
    if (!((getGroup().getTogglePosition() & SWT.LEAD) != 0)
        && (getGroup().getToggleRenderer() != null))
    {
        textWidth -= getGroup().getToggleRenderer().getSize().x + betweenSpacing;
    }

    int textY = 0;
    if (getGroup().getLinePosition() == SWT.CENTER)
    {
        textY = (heightWithoutLine - fontHeight) / 2;
    }
    else
    {
        textY = heightWithoutLine - (fontHeight + (titleTextMargin) + (vMargin));
    }

    if (getGroup().getToggleRenderer() != null)
    {
        int toggleHeight = getGroup().getToggleRenderer().getSize().y;
        if (toggleHeight > fontHeight)
        {
            int toggleY = ((heightWithoutLine - toggleHeight) / 2);
            int difference = (toggleHeight - fontHeight) / 2;
            textY = toggleY + difference;
        }
    }

    return new Rectangle(textX, textY, textWidth, fontHeight);
}
 
Example 19
private void createProjectIdSection() {
  Label projectIdLabel = new Label(this, SWT.LEAD);
  projectIdLabel.setText(Messages.getString("project"));
  projectIdLabel.setToolTipText(Messages.getString("tooltip.project.id"));
  GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.BEGINNING).span(1, 2)
      .applyTo(projectIdLabel);

  Composite linkComposite = new Composite(this, SWT.NONE);
  Link createNewProject = new Link(linkComposite, SWT.WRAP);
  createNewProject.setText(Messages.getString("projectselector.createproject",
                                              CREATE_GCP_PROJECT_URL));
  createNewProject.setToolTipText(Messages.getString("projectselector.createproject.tooltip"));
  FontUtil.convertFontToItalic(createNewProject);
  createNewProject.addSelectionListener(new OpenUriSelectionListener(
      () -> accountSelector.getSelectedEmail().isEmpty()
          ? Collections.emptyMap()
          : Collections.singletonMap("authuser", accountSelector.getSelectedEmail()),
      new ErrorDialogErrorHandler(getShell())));
  GridDataFactory.fillDefaults().applyTo(linkComposite);
  GridLayoutFactory.fillDefaults().generateLayout(linkComposite);

  Composite projectSelectorComposite = new Composite(this, SWT.NONE);
  GridLayoutFactory.fillDefaults().numColumns(2).spacing(0, 0).applyTo(projectSelectorComposite);
  GridDataFactory.fillDefaults().grab(true, false).applyTo(projectSelectorComposite);

  final Text filterField = new Text(projectSelectorComposite,
      SWT.BORDER | SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL);
  filterField.setMessage(Messages.getString("projectselector.filter"));
  GridDataFactory.fillDefaults().applyTo(filterField);

  new Label(projectSelectorComposite, SWT.NONE); // spacer

  projectSelector = new ProjectSelector(projectSelectorComposite);
  GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, 200)
      .applyTo(projectSelector);

  final Button refreshProjectsButton = new Button(projectSelectorComposite, SWT.NONE);
  refreshProjectsButton.setImage(refreshIcon);
  GridDataFactory.swtDefaults().align(SWT.END, SWT.BEGINNING).applyTo(refreshProjectsButton);
  refreshProjectsButton.addSelectionListener(new SelectionAdapter() {
    @Override
    public void widgetSelected(SelectionEvent event) {
      refreshProjectsForSelectedCredential();
    }
  });

  accountSelector.addSelectionListener(
      new RefreshProjectOnAccountSelection(refreshProjectsButton));

  projectSelector.addSelectionChangedListener(
      new ProjectSelectorSelectionChangedListener(accountSelector,
                                                  projectRepository,
                                                  projectSelector));
  filterField.addModifyListener(event -> {
    projectSelector.setFilter(filterField.getText());
  });
}
 
Example 20
private void addRowsToProcessControllers() {
  wlRowsToProcess = new Label( wgRowHandling, SWT.RIGHT );
  wlRowsToProcess.setText( BaseMessages.getString( PKG, "CPythonScriptExecutorDialog.NumberOfRowsToProcess.Label" ) );
  props.setLook( wlRowsToProcess );
  fd = new FormData();
  fd.left = new FormAttachment( 0, 0 );
  fd.right = new FormAttachment( FIRST_LABEL_RIGHT_PERCENTAGE, 0 );
  fd.top = new FormAttachment( lastControl, MARGIN );
  wlRowsToProcess.setLayoutData( getFirstLabelFormData() );

  wcvRowsToProcess = new ComboVar( transMeta, wgRowHandling, SWT.BORDER | SWT.READ_ONLY );
  props.setLook( wcvRowsToProcess );
  wcvRowsToProcess.setEditable( false );
  wcvRowsToProcess.addSelectionListener( new SelectionAdapter() {
    @Override public void widgetSelected( SelectionEvent e ) {
      m_inputMeta.setChanged();
      handleRowsToProcessChange();
      if ( wtvInputFrames.getItemCount() > 1 && wbReservoirSampling.getSelection() && wcvRowsToProcess.getText()
          .equals( BaseMessages.getString( PKG,
              "CPythonScriptExecutorDialog.NumberOfRowsToProcess.Dropdown.RowByRowEntry.Label" ) ) ) {
        ShowMessageDialog
            smd =
            new ShowMessageDialog( shell, SWT.OK | SWT.ICON_WARNING,
                BaseMessages.getString( PKG, "CPythonScriptExecutorDialog.RowByRowWarning.Title" ),
                BaseMessages.getString( PKG, "CPythonScriptExecutorDialog.RowByRowWarning.Message" ), false );
        smd.open();
      }
    }
  } );
  wcvRowsToProcess.setLayoutData( getFirstPromptFormData( wlRowsToProcess ) );
  wcvRowsToProcess.add(
      BaseMessages.getString( PKG, "CPythonScriptExecutorDialog.NumberOfRowsToProcess.Dropdown.AllEntry.Label" ) );
  wcvRowsToProcess.add( BaseMessages
      .getString( PKG, "CPythonScriptExecutorDialog.NumberOfRowsToProcess.Dropdown.RowByRowEntry.Label" ) );
  wcvRowsToProcess.add(
      BaseMessages.getString( PKG, "CPythonScriptExecutorDialog.NumberOfRowsToProcess.Dropdown.BatchEntry.Label" ) );
  wcvRowsToProcess.setToolTipText(
      BaseMessages.getString( PKG, "CPythonScriptExecutorDialog.NumberOfRowsToProcess.Dropdown.TipText" ) );

  wlRowsToProcessSize = new Label( wgRowHandling, SWT.RIGHT );
  wlRowsToProcessSize
      .setText( BaseMessages.getString( PKG, "CPythonScriptExecutorDialog.NumberOfRowsToProcess.Size.Label" ) );
  props.setLook( wlRowsToProcessSize );
  wlRowsToProcessSize.setLayoutData( getSecondLabelFormData( wcvRowsToProcess ) );

  wtvRowsToProcessSize = new TextVar( transMeta, wgRowHandling, SWT.SINGLE | SWT.LEAD | SWT.BORDER );
  props.setLook( wtvRowsToProcessSize );
  wtvRowsToProcessSize.addModifyListener( simpleModifyListener );
  wtvRowsToProcessSize.setLayoutData( getSecondPromptFormData( wlRowsToProcessSize ) );
  wtvRowsToProcessSize.setEnabled( false );
  lastControl = wtvRowsToProcessSize;
  wtvRowsToProcessSize.setToolTipText(
      BaseMessages.getString( PKG, "CPythonScriptExecutorDialog.NumberOfRowsToProcess.Size.TipText" ) );
}