org.eclipse.jface.resource.JFaceResources Java Examples

The following examples show how to use org.eclipse.jface.resource.JFaceResources. 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: TimelineComposite.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
public TimelineComposite(Composite parent, int style) {
	super(parent, style);

	fResourceManager = new LocalResourceManager(JFaceResources.getResources(), this);

	final FillLayout layout = new FillLayout();
	layout.marginHeight = 10;
	layout.marginWidth = 10;
	setLayout(layout);

	setBackground(ColorConstants.black);

	final Canvas canvas = new Canvas(this, SWT.DOUBLE_BUFFERED);
	canvas.setBackground(ColorConstants.black);
	final LightweightSystem lightWeightSystem = new LightweightSystem(canvas);

	fRootFigure = new RootFigure(fResourceManager);
	fRootFigure.setFont(parent.getFont());
	lightWeightSystem.setContents(fRootFigure);

	// draw2d does not directly support mouseWheelEvents, so register on canvas
	canvas.addMouseWheelListener(new TimelineScaler(this));
}
 
Example #2
Source File: FileText.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
public FileText(Composite parent, int style, String[] filterExtensions) {
		this.text = new Text(parent, style);

		this.filterExtensions = filterExtensions;

		this.openBrowseButton = new Button(parent, SWT.NONE);
		this.openBrowseButton.setText(JFaceResources.getString("openBrowse"));

		this.openBrowseButton.addSelectionListener(new SelectionAdapter() {

			/**
			 * {@inheritDoc}
			 */
			@Override
			public void widgetSelected(SelectionEvent e) {
//				String saveFilePath = Activator.showSaveDialog(text.getText(),
//						FileText.this.filterExtensions);
				String saveFilePath = Activator.showSaveDialogInternal(text.getText(),
						FileText.this.filterExtensions);
				text.setText(saveFilePath);
			}
		});
	}
 
Example #3
Source File: OptionsConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
protected Combo newComboControl(Composite composite, Key key, String[] values, String[] valueLabels) {
	ControlData data= new ControlData(key, values);

	Combo comboBox= new Combo(composite, SWT.READ_ONLY);
	comboBox.setItems(valueLabels);
	comboBox.setData(data);
	comboBox.addSelectionListener(getSelectionListener());
	comboBox.setFont(JFaceResources.getDialogFont());
	SWTUtil.setDefaultVisibleItemCount(comboBox);

	makeScrollableCompositeAware(comboBox);

	updateCombo(comboBox);

	fComboBoxes.add(comboBox);
	return comboBox;
}
 
Example #4
Source File: MatchViewPart.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
public void propertyChange(PropertyChangeEvent event) {
	if (gridTable == null || gridTable.isDisposed()) {
		return;
	}
	String property = event.getProperty();
	if (net.heartsome.cat.ts.ui.Constants.MATCH_VIEWER_TEXT_FONT.equals(property)) {
		Font font = JFaceResources.getFont(net.heartsome.cat.ts.ui.Constants.MATCH_VIEWER_TEXT_FONT);
		sourceColunmCellRenderer.setFont(font);
		targetColumnCellRenderer.setFont(font);
		GridData sTextGd = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
		sourceText.getTextWidget().setFont(font);
		int lineH = sourceText.getTextWidget().getLineHeight() * 2;
		sTextGd.heightHint = lineH;
		sTextGd.minimumHeight = lineH;
		sourceText.getTextWidget().setLayoutData(sTextGd);
		gridTable.redraw();
		sourceText.getTextWidget().getParent().layout();
	}
}
 
Example #5
Source File: JavaOutlineInformationControl.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Color getForeground(Object element) {
	if (fOutlineContentProvider.isShowingInheritedMembers()) {
		if (element instanceof IJavaElement) {
			IJavaElement je= (IJavaElement)element;
			if (fInput.getElementType() == IJavaElement.CLASS_FILE)
				je= je.getAncestor(IJavaElement.CLASS_FILE);
			else
				je= je.getAncestor(IJavaElement.COMPILATION_UNIT);
			if (fInput.equals(je)) {
				return null;
			}
		}
		return JFaceResources.getColorRegistry().get(ColoredViewersManager.INHERITED_COLOR_NAME);
	}
	return null;
}
 
Example #6
Source File: ManifestBluemixWizardPage.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
@Override
public void createControl(Composite parent) {
    super.createControl(parent);   
    
    Composite container = new Composite(parent, SWT.NONE);
    GridLayout layout = WizardUtils.createGridLayout(1, 5);
    container.setLayout(layout);

    _overwriteRadio = WizardUtils.createRadio(container, "Create a new Manifest", 1, this, 0); // $NLX-ManifestBluemixWizardPage.CreateanewManifest-1$
    _useExistingRadio = WizardUtils.createRadio(container, "Use the existing Manifest", 1, this, 0); // $NLX-ManifestBluemixWizardPage.UsetheexistingManifest-1$

    _fileLabel = WizardUtils.createText(container, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.READ_ONLY, 1, 20, GridData.FILL_BOTH);
    _fileLabel.setFont(JFaceResources.getTextFont());
    _fileLabel.setBackground(_wiz.getShell().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    
    setControl(container);
}
 
Example #7
Source File: SyntaxColoringPreferencePage.java    From editorconfig-eclipse with Apache License 2.0 6 votes vote down vote up
private Control createPreviewer(Composite parent) {

		IPreferenceStore store = new ChainedPreferenceStore(new IPreferenceStore[] { fOverlayStore,
				EditorConfigUIPlugin.getDefault().getCombinedPreferenceStore() });
		fPreviewViewer = new SourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
		fColorManager = new EditorConfigColorManager(false);
		EditorConfigSourceViewerConfiguration configuration = new EditorConfigSourceViewerConfiguration(fColorManager,
				store, null, IEditorConfigPartitions.EDITOR_CONFIG_PARTITIONING);
		fPreviewViewer.configure(configuration);
		Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_CONFIG_EDITOR_TEXT_FONT);
		fPreviewViewer.getTextWidget().setFont(font);
		new SourcePreviewerUpdater(fPreviewViewer, configuration, store);
		fPreviewViewer.setEditable(false);

		String content = loadPreviewContentFromFile("EditorConfigEditorColorSettingPreviewCode.txt"); //$NON-NLS-1$
		IDocument document = new Document(content);
		EditorConfigDocumentSetupParticipant.setupDocument(document);
		fPreviewViewer.setDocument(document);

		return fPreviewViewer.getControl();
	}
 
Example #8
Source File: StyledTextCellEditor.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 初始化默认颜色、字体等
 * @param textControl
 *            ;
 */
private void initStyle(final StyledText textControl, IStyle cellStyle) {
	// textControl.setBackground(cellStyle.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR));
	textControl.setBackground(GUIHelper.getColor(210, 210, 240));
	textControl.setForeground(cellStyle.getAttributeValue(CellStyleAttributes.FOREGROUND_COLOR));

	textControl.setLineSpacing(Constants.SEGMENT_LINE_SPACING);
	textControl.setLeftMargin(Constants.SEGMENT_LEFT_MARGIN);
	textControl.setRightMargin(Constants.SEGMENT_RIGHT_MARGIN);
	textControl.setTopMargin(Constants.SEGMENT_TOP_MARGIN);
	textControl.setBottomMargin(Constants.SEGMENT_TOP_MARGIN);

	// textControl.setLeftMargin(0);
	// textControl.setRightMargin(0);
	// textControl.setTopMargin(0);
	// textControl.setBottomMargin(0);

	textControl.setFont(JFaceResources.getFont(net.heartsome.cat.ts.ui.Constants.XLIFF_EDITOR_TEXT_FONT));
	textControl.setIME(new IME(textControl, SWT.NONE));

}
 
Example #9
Source File: ScopedPreferenceStore.java    From e4Preferences with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void firePropertyChangeEvent(String name, Object oldValue,
		Object newValue) {
	// important: create intermediate array to protect against listeners
	// being added/removed during the notification
	final Object[] listeners = getListeners();
	if (listeners.length == 0) {
		return;
	}
	final PropertyChangeEvent event = new PropertyChangeEvent(this, name, oldValue, newValue);
	for (Object listener : listeners) {
		final IPropertyChangeListener propertyChangeListener = (IPropertyChangeListener) listener;
		SafeRunner.run(new SafeRunnable(JFaceResources.getString("PreferenceStore.changeError")) { //$NON-NLS-1$
			@Override
			public void run() {
				propertyChangeListener.propertyChange(event);
			}
		});
	}
}
 
Example #10
Source File: ThemeUIComposite.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private void setFont(String fontId, FontData[] data) {
	String fdString = PreferenceConverter.getStoredRepresentation(data);

	Font existing = JFaceResources.getFont(fontId);
	String existingString = "";
	if (!(existing.isDisposed())) {
		existingString = PreferenceConverter
				.getStoredRepresentation(existing.getFontData());
	}
	if (existingString.equals(fdString)) {
		return;
	}
	JFaceResources.getFontRegistry().put(fontId, data);

	ITheme currentTheme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();
	String key = ThemeElementHelper.createPreferenceKey(currentTheme,fontId);
	IPreferenceStore store = WorkbenchPlugin.getDefault().getPreferenceStore();
	store.setValue(key, fdString);
}
 
Example #11
Source File: PreferenceWrapper.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void firePreferenceChangeEvent( String name, Object oldValue,
		Object newValue )
{
	final Object[] finalListeners = getListeners( );
	// Do we need to fire an event.
	if ( finalListeners.length > 0
			&& ( oldValue == null || !oldValue.equals( newValue ) ) )
	{
		final PreferenceChangeEvent pe = new PreferenceChangeEvent( this,
				name,
				oldValue,
				newValue );
		for ( int i = 0; i < finalListeners.length; ++i )
		{
			final IPreferenceChangeListener l = (IPreferenceChangeListener) finalListeners[i];
			SafeRunnable.run( new SafeRunnable( JFaceResources.getString( "PreferenceStore.changeError" ) ) { //$NON-NLS-1$

				public void run( )
				{
					l.preferenceChange( pe );
				}
			} );
		}
	}
}
 
Example #12
Source File: TextPainterWithPadding.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
public TextPainterWithPadding(boolean wrapText, int topPadding, int rightPadding, int bottomPadding,
		int leftPadding, final XLIFFEditorImplWithNatTable editor, Font font) {
	Assert.isNotNull(editor.getTable(), Messages.getString("editor.TextPainterWithPadding.msg1"));
	this.wrapText = wrapText;
	this.topPadding = topPadding;
	this.rightPadding = rightPadding;
	this.bottomPadding = bottomPadding;
	this.leftPadding = leftPadding;
	this.editor = editor;
	if (font == null) {
		font = JFaceResources.getFont(net.heartsome.cat.ts.ui.Constants.XLIFF_EDITOR_TEXT_FONT);
	}
	setFont(font);

	tagRender = new InnerTagRender();
}
 
Example #13
Source File: ImportBosArchiveControlSupplier.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Control createControl(Composite parent, IWizardContainer container, DataBindingContext ctx) {
    this.wizardContainer = container;
    final Composite mainComposite = new Composite(parent, SWT.NONE);
    mainComposite.setLayout(
            GridLayoutFactory.fillDefaults().margins(10, 10).spacing(LayoutConstants.getSpacing().x, 25).create());
    mainComposite.setLayoutData(GridDataFactory.fillDefaults().create());
    final LocalResourceManager resourceManager = new LocalResourceManager(JFaceResources.getResources(),
            mainComposite);
    this.errorColor = resourceManager.createColor(ColorConstants.ERROR_RGB);
    this.successColor = resourceManager.createColor(ColorConstants.SUCCESS_RGB);
    doFileLocationBrowser(mainComposite, ctx);
    doCreateAdditionalControl(mainComposite, ctx);
    doCreateFileTree(mainComposite, ctx);

    treeSection.setVisible(filePath != null);
    textWidget.addTextListener(SWT.Modify, e -> {
        treeSection.setVisible(textWidget.getText() != null && !textWidget.getText().isEmpty());
        treeSection.layout();
    });

    return mainComposite;
}
 
Example #14
Source File: ConcordanceSearchDialog.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 构造方法
 * @param parentShell
 * @param file
 *            当前文件
 * @param strSrcLang
 *            当前文件的源语言
 * @param strTgtLang
 *            当前文件的目标语言
 * @param strSearchText
 *            搜索文本
 */
public ConcordanceSearchDialog(Shell parentShell, IFile file, String strSrcLang, String strTgtLang,
		String strSearchText) {
	super(parentShell);

	FontData fontData = JFaceResources.getDefaultFont().getFontData()[0];
	fontData.setStyle(fontData.getStyle() | SWT.BOLD);
	font = new Font(Display.getDefault(), fontData);
	style = new TextStyle(font, null, null);

	this.strSrcLang = strSrcLang;
	this.strTgtLang = strTgtLang;
	this.strSearchText = strSearchText;
	ProjectConfiger projectConfig = ProjectConfigerFactory.getProjectConfiger(file.getProject());
	lstDatabase = projectConfig.getAllTmDbs();
	filterUnAvaliableDatabase();
	setHelpAvailable(true);
	setBlockOnOpen(false);
	lstSearchHistory = new ArrayList<String>(HISTORY_SIZE - 1);
	lstFilterHistory = new ArrayList<String>(HISTORY_SIZE - 1);
	if (!Util.isLinux()) {
		totalWidth = 910;
	}
}
 
Example #15
Source File: RenameRefactoringPopup.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected void createContent(Composite parent) {
	Display display = parent.getDisplay();
	ColorRegistry registry = JFaceResources.getColorRegistry();
	Color foreground= registry.get("org.eclipse.ui.workbench.HOVER_FOREGROUND"); //$NON-NLS-1$
	if (foreground == null) {
		foreground = display.getSystemColor(SWT.COLOR_INFO_FOREGROUND);
	}
	Color background= registry.get("org.eclipse.ui.workbench.HOVER_BACKGROUND"); //$NON-NLS-1$
	if (background == null) {
		background = display.getSystemColor(SWT.COLOR_INFO_BACKGROUND);
	}
	StyledText hint = new StyledText(popup, SWT.READ_ONLY | SWT.SINGLE);
	String enterKeyName = getEnterBinding();
	String hintTemplate = "Enter new name, press {0} to refactor";
	hint.setText(Messages.format(hintTemplate, enterKeyName));
	hint.setForeground(foreground);
	hint.setStyleRange(new StyleRange(hintTemplate.indexOf("{0}"), enterKeyName.length(), null, null, SWT.BOLD)); //$NON-NLS-1$
	hint.setEnabled(false); // text must not be selectable
	addViewMenu(parent);
	recursiveSetBackgroundColor(parent, background);
}
 
Example #16
Source File: SyntaxColorerPreviewer.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
public SyntaxColorerPreviewer(Composite parent, final IPreferenceStore preferenceStore) {
     super(parent, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY);
     this.preferenceStore = preferenceStore;
     this.setLayoutData(new GridData(GridData.FILL_BOTH));
     
     Font font= JFaceResources.getTextFont();
     this.setFont(font);
     
     defBackgroundColor = getEditorBackgroundColor(preferenceStore);
     this.setBackground(defBackgroundColor);
     
     prefListener = new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
	try { // Widget may be disposed here
	    defBackgroundColor = getEditorBackgroundColor(preferenceStore);
              setBackground(defBackgroundColor);
              updateColors();
       } catch (Exception e) {} 
}
     };
     
     preferenceStore.addPropertyChangeListener(prefListener);
     
     tokenManager = new TokenManager();
 }
 
Example #17
Source File: HoverInfoWithSpellingAnnotation.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void deferredCreateContent(Composite parent, HoverInformationControl miControl) 
{
    this.fParent = parent;
    this.fMIControl = miControl;
    
    GridLayout layout= new GridLayout(1, false);
    layout.verticalSpacing= 0;
    layout.marginWidth= 0;
    layout.marginHeight= 0;
    fParent.setLayout(layout);

    // fillToolbar();
    
    createAnnotationInformation(fParent, fSpellingAnnotation);
    setColorAndFont(fParent, fParent.getForeground(), fParent.getBackground(), JFaceResources.getDialogFont());

    ICompletionProposal[] proposals= fSpellingAnnotation.getSpellingProblem().getProposals();
    if (proposals.length > 0)
        createCompletionProposalsControl(fParent, proposals);

    fParent.layout(true);
}
 
Example #18
Source File: PatternExpressionViewer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void createTextViewer() {
	viewer = createViewer(mc);
	viewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
	configureTextViewer();
	addLineStyleListener();
	helpDecoration = new ControlDecoration(viewer.getControl(), SWT.TOP | SWT.RIGHT, this);
	helpDecoration.setImage(JFaceResources.getImage(Dialog.DLG_IMG_HELP));
	helpDecoration.setDescriptionText(Messages.patternViewerHint);
	helpDecoration.setMarginWidth(2);
	helpDecoration.hide();

	hintDecoration = new ControlDecoration(viewer.getControl(), SWT.TOP | SWT.LEFT, this);
	hintDecoration.setImage(Pics.getImage(PicsConstants.hint));
	hintDecoration.setMarginWidth(2);
	hintDecoration.setShowHover(true);
	hintDecoration.setShowOnlyOnFocus(true);
	hintDecoration.hide();

	viewer.addTextListener(new ITextListener() {

		@Override
		public void textChanged(final TextEvent event) {
			viewer.getTextWidget().notifyListeners(SWT.Modify, new Event());
		}
	});

	helpDecoration.show();
}
 
Example #19
Source File: AbstractOpenWizardAction.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void run() {
  Shell localShell = getShell();
  if (!doCreateProjectFirstOnEmptyWorkspace(localShell)) {
    return;
  }

  try {
    INewWizard wizard = createWizard();
    wizard.init(PlatformUI.getWorkbench(), getSelection());

    WizardDialog dialog = new WizardDialog(localShell, wizard);
    IPixelConverter converter =
        PixelConverterFactory.createPixelConverter(JFaceResources.getDialogFont());
    dialog.setMinimumPageSize(converter.convertWidthInCharsToPixels(70),
        converter.convertHeightInCharsToPixels(20));
    dialog.create();
    int res = dialog.open();
    if (res == Window.OK && wizard instanceof NewElementWizard) {
      createdElement = ((NewElementWizard) wizard).getCreatedElement();
    }

    notifyResult(res == Window.OK);
  } catch (CoreException e) {
    String title = NewWizardMessages.AbstractOpenWizardAction_createerror_title;
    String message = NewWizardMessages.AbstractOpenWizardAction_createerror_message;
    ExceptionHandler.handle(e, localShell, title, message);
  }
}
 
Example #20
Source File: CordovaPluginWizardResources.java    From thym with Eclipse Public License 1.0 5 votes vote down vote up
public CordovaPluginWizardResources(Display display) {
	this.resourceManager = new LocalResourceManager(JFaceResources.getResources(display));
	this.h2FontDescriptor = createFontDescriptor(SWT.BOLD, 1.15f);
	this.h2ItalicFontDescriptor = createFontDescriptor(SWT.BOLD | SWT.ITALIC, 1.15f);
	this.subFontDescriptor = createFontDescriptor(SWT.NONE, 0.75f);
	this.italicFontDescriptor = createFontDescriptor(SWT.ITALIC, 1);
}
 
Example #21
Source File: ClassFileEditor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private Label createHeadingLabel(Composite parent, String text) {
	Label label = new Label(parent, SWT.NONE);
	if (text != null)
		label.setText(text);
	label.setBackground(fBackgroundColor);
	label.setForeground(fForegroundColor);
	label.setFont(JFaceResources.getBannerFont());
	fBannerLabels.add(label);
	return label;
}
 
Example #22
Source File: AbstractDocumentationHover.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the PHP hover style sheet
 */
private String getStyleSheet()
{
	if (styleSheet == null)
	{
		styleSheet = loadStyleSheet(getCSSPath());
	}
	if (styleSheet != null)
	{
		FontData fontData = JFaceResources.getFontRegistry().getFontData("Dialog")[0]; //$NON-NLS-1$
		return HTMLPrinter.convertTopLevelFont(styleSheet, fontData);
	}

	return null;
}
 
Example #23
Source File: SVNDecoratorPreferencesPage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public Preview(Composite composite) {
          SWTUtils.createLabel(composite, Policy.bind("SVNDecoratorPreferencesPage.preview"));  //$NON-NLS-1$
	fImageCache= new LocalResourceManager(JFaceResources.getResources());
	fViewer = new TreeViewer(composite);
	GridData data = SWTUtils.createHVFillGridData();
	data.heightHint = 225;
	fViewer.getControl().setLayoutData(data);
	fViewer.setContentProvider(this);
	fViewer.setLabelProvider(this);
	fViewer.setInput(ROOT);
	fViewer.expandAll();
}
 
Example #24
Source File: AbstractAnnotationHover.java    From typescript.java with MIT License 5 votes vote down vote up
/**
 * Create content of the hover. This is called after the input has been
 * set.
 */
protected void deferredCreateContent() {
	fillToolbar();

	createAnnotationInformation(fParent, getAnnotationInfo().annotation);
	setColorAndFont(fParent, fParent.getForeground(), fParent.getBackground(), JFaceResources.getDialogFont());

	ICompletionProposal[] proposals = getAnnotationInfo().getCompletionProposals();
	if (proposals.length > 0)
		createCompletionProposalsControl(fParent, proposals);

	fParent.layout(true);
}
 
Example #25
Source File: OnEnterRuleTableWidget.java    From tm4e with Eclipse Public License 1.0 5 votes vote down vote up
public OnEnterRuleTableWidget(Table table) {
	super(table);
	setContentProvider(new OnEnterRuleContentProvider());
	setLabelProvider(new OnEnterRuleLabelProvider());

	GC gc = new GC(table.getShell());
	gc.setFont(JFaceResources.getDialogFont());
	TableColumnLayout columnLayout = new TableColumnLayout();

	TableColumn column1 = new TableColumn(table, SWT.NONE);
	column1.setText(LanguageConfigurationMessages.OnEnterRuleTableWidget_beforeText);
	int minWidth = computeMinimumColumnWidth(gc, LanguageConfigurationMessages.OnEnterRuleTableWidget_beforeText);
	columnLayout.setColumnData(column1, new ColumnWeightData(2, minWidth, true));

	TableColumn column2 = new TableColumn(table, SWT.NONE);
	column2.setText(LanguageConfigurationMessages.OnEnterRuleTableWidget_afterText);
	minWidth = computeMinimumColumnWidth(gc, LanguageConfigurationMessages.OnEnterRuleTableWidget_afterText);
	columnLayout.setColumnData(column2, new ColumnWeightData(2, minWidth, true));

	TableColumn column3 = new TableColumn(table, SWT.NONE);
	column3.setText(LanguageConfigurationMessages.OnEnterRuleTableWidget_indentAction);
	minWidth = computeMinimumColumnWidth(gc, LanguageConfigurationMessages.OnEnterRuleTableWidget_indentAction);
	columnLayout.setColumnData(column3, new ColumnWeightData(1, minWidth, true));

	TableColumn column4 = new TableColumn(table, SWT.NONE);
	column4.setText(LanguageConfigurationMessages.OnEnterRuleTableWidget_appendText);
	minWidth = computeMinimumColumnWidth(gc, LanguageConfigurationMessages.OnEnterRuleTableWidget_appendText);
	columnLayout.setColumnData(column4, new ColumnWeightData(1, minWidth, true));

	TableColumn column5 = new TableColumn(table, SWT.NONE);
	column5.setText(LanguageConfigurationMessages.OnEnterRuleTableWidget_removeText);
	minWidth = computeMinimumColumnWidth(gc, LanguageConfigurationMessages.OnEnterRuleTableWidget_removeText);
	columnLayout.setColumnData(column5, new ColumnWeightData(1, minWidth, true));
}
 
Example #26
Source File: SyntaxHighlighter.java    From textuml with Eclipse Public License 1.0 5 votes vote down vote up
protected void initialize(String[] keywords) {
    ColorRegistry registry = JFaceResources.getColorRegistry();

    IToken keyword = new Token(new TextAttribute(registry.get(KEYWORD_COLOR), null, SWT.BOLD));
    IToken string = new Token(new TextAttribute(registry.get(STRING_COLOR)));
    IToken number = new Token(new TextAttribute(registry.get(NUMBER_COLOR)));
    IToken annotation = new Token(new TextAttribute(registry.get(ANNOTATION_COLOR)));
    IToken defaultToken = new Token(new TextAttribute(registry.get(DEFAULT_COLOR)));

    List<IRule> rules = new ArrayList<IRule>();

    // strings
    rules.add(new SingleLineRule("\"", "\"", string, '\\'));

    // annotations
    rules.add(new MultiLineRule("[", "]", annotation));

    // numbers
    rules.add(new NumberRule(number));

    // keywords and normal (default) text
    WordRule wordRule = new WordRule(new WordDetector(), defaultToken);
    for (int i = 0; i < keywords.length; i++) {
        wordRule.addWord(keywords[i], keyword);
    }
    rules.add(wordRule);

    setRules(rules.toArray(new IRule[rules.size()]));
}
 
Example #27
Source File: TableEditor.java    From cppcheclipse with Apache License 2.0 5 votes vote down vote up
/**
 * Helper method to create a push button.
 * 
 * @param parent
 *            the parent control
 * @param key
 *            the resource name used to supply the button's label text
 * @return Button
 */
protected Button createPushButton(Composite parent, String key,
		SelectionListener listener) {
	Button button = new Button(parent, SWT.PUSH);
	button.setText(JFaceResources.getString(key));
	button.setFont(parent.getFont());
	GridData data = new GridData(GridData.FILL_HORIZONTAL);
	int widthHint = convertHorizontalDLUsToPixels(button,
			IDialogConstants.BUTTON_WIDTH);
	data.widthHint = Math.max(widthHint,
			button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
	button.setLayoutData(data);
	button.addSelectionListener(listener);
	return button;
}
 
Example #28
Source File: TabbedPropertyTitle.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private void updateToolBar( )
{
	if ( toolbar != null )
	{
		ResourceManager parentResourceManager = JFaceResources.getResources( );
		LocalResourceManager localManager = new LocalResourceManager( parentResourceManager );

		for ( int i = 0; i < toolbar.getItemCount( ); i++ )
		{
			ToolItem item = toolbar.getItem( i );
			IAction action = (IAction) actionMap.get( item );
			if ( action != null )
			{
				ImageDescriptor image = null;
				if ( action.getImageDescriptor( ) != null )
					image = action.getImageDescriptor( );
				if ( image != null )
					item.setImage( localManager.createImageWithDefault( image ) );

				item.setToolTipText( action.getToolTipText( ) );
				if ( IAction.AS_CHECK_BOX == action.getStyle( ) )
				{
					item.setSelection( action.isChecked( ) );
				}

				item.setEnabled( action.isEnabled( ) );
			}
		}

		disposeOldImages( );
		imageManager = localManager;

		if ( toolbar.isFocusControl( ) )
			toolbar.setFocus( );
	}
}
 
Example #29
Source File: PropertiesPage.java    From thym with Eclipse Public License 1.0 5 votes vote down vote up
private Button createButton(Composite parent, String label) {
	Button button = formToolkit.createButton( parent, label, SWT.NULL);
	button.setFont(JFaceResources.getDialogFont());
	
	PixelConverter converter = new PixelConverter(button);
	int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
	widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
	GridDataFactory.swtDefaults().align(SWT.FILL, SWT.BEGINNING).hint(widthHint, SWT.DEFAULT).applyTo(button);

	return button;
}
 
Example #30
Source File: PreviewPage.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
protected void renderResult ( final ViewerCell cell, final Entry element )
{
    if ( element.getException () != null )
    {
        cell.setText ( ExceptionHelper.getMessage ( element.getException () ) );
        cell.setImage ( JFaceResources.getImage ( Dialog.DLG_IMG_MESSAGE_ERROR ) );
    }
    else
    {
        cell.setText ( element.getNewName () );
        cell.setImage ( null );
    }
}