List of usage examples for org.eclipse.jface.util Util isCarbon
@Deprecated public static boolean isCarbon()
From source file:com.imperial.fiksen.codesimilarity.compare.ParseTreeMergeViewer.java
License:Open Source License
/** * Creates a text merge viewer under the given parent control. * //from w w w . j ava 2 s . c o m * @param parent * the parent control * @param style * SWT style bits for top level composite of this viewer * @param configuration * the configuration object */ public ParseTreeMergeViewer(Composite parent, int style, CompareConfiguration configuration) { super(style, ResourceBundle.getBundle(BUNDLE_NAME), configuration); operationHistoryListener = new IOperationHistoryListener() { public void historyNotification(OperationHistoryEvent event) { ParseTreeMergeViewer.this.historyNotification(event); } }; OperationHistoryFactory.getOperationHistory().addOperationHistoryListener(operationHistoryListener); fMerger = new ParseTreeDocumentMerger(new IDocumentMergerInput() { public ITokenComparator createTokenComparator(String line) { return ParseTreeMergeViewer.this.createTokenComparator(line); } public CompareConfiguration getCompareConfiguration() { return ParseTreeMergeViewer.this.getCompareConfiguration(); } public IDocument getDocument(char contributor) { switch (contributor) { case LEFT_CONTRIBUTOR: return fLeft.getSourceViewer().getDocument(); case RIGHT_CONTRIBUTOR: return fRight.getSourceViewer().getDocument(); case ANCESTOR_CONTRIBUTOR: return fAncestor.getSourceViewer().getDocument(); } return null; } public int getHunkStart() { return ParseTreeMergeViewer.this.getHunkStart(); } public Position getRegion(char contributor) { switch (contributor) { case LEFT_CONTRIBUTOR: return fLeft.getRegion(); case RIGHT_CONTRIBUTOR: return fRight.getRegion(); case ANCESTOR_CONTRIBUTOR: return fAncestor.getRegion(); } return null; } public boolean isHunkOnLeft() { ITypedElement left = ((ICompareInput) getInput()).getRight(); return left != null && Utilities.getAdapter(left, IHunk.class) != null; } public boolean isIgnoreAncestor() { return ParseTreeMergeViewer.this.isIgnoreAncestor(); } public boolean isPatchHunk() { return ParseTreeMergeViewer.this.isPatchHunk(); } public boolean isShowPseudoConflicts() { return fShowPseudoConflicts; } public boolean isThreeWay() { return ParseTreeMergeViewer.this.isThreeWay(); } public boolean isPatchHunkOk() { return ParseTreeMergeViewer.this.isPatchHunkOk(); } }); int inheritedStyle = parent.getStyle(); if ((inheritedStyle & SWT.LEFT_TO_RIGHT) != 0) fInheritedDirection = SWT.LEFT_TO_RIGHT; else if ((inheritedStyle & SWT.RIGHT_TO_LEFT) != 0) fInheritedDirection = SWT.RIGHT_TO_LEFT; else fInheritedDirection = SWT.NONE; if ((style & SWT.LEFT_TO_RIGHT) != 0) fTextDirection = SWT.LEFT_TO_RIGHT; else if ((style & SWT.RIGHT_TO_LEFT) != 0) fTextDirection = SWT.RIGHT_TO_LEFT; else fTextDirection = SWT.NONE; fSymbolicFontName = getSymbolicFontName(); fIsMotif = Util.isMotif(); fIsCarbon = Util.isCarbon(); fIsMac = Util.isMac(); if (fIsMotif) fMarginWidth = 0; fPreferenceChangeListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { ParseTreeMergeViewer.this.handlePropertyChangeEvent(event); } }; fPreferenceStore = createChainedPreferenceStore(); if (fPreferenceStore != null) { fPreferenceStore.addPropertyChangeListener(fPreferenceChangeListener); fLeftIsLocal = Utilities.getBoolean(getCompareConfiguration(), "LEFT_IS_LOCAL", false); //$NON-NLS-1$ fSynchronizedScrolling = fPreferenceStore.getBoolean(ComparePreferencePage.SYNCHRONIZE_SCROLLING); fShowPseudoConflicts = fPreferenceStore.getBoolean(ComparePreferencePage.SHOW_PSEUDO_CONFLICTS); // fUseSplines= // fPreferenceStore.getBoolean(ComparePreferencePage.USE_SPLINES); fUseSingleLine = fPreferenceStore.getBoolean(ComparePreferencePage.USE_SINGLE_LINE); fHighlightTokenChanges = fPreferenceStore.getBoolean(ComparePreferencePage.HIGHLIGHT_TOKEN_CHANGES); // fUseResolveUI= // fPreferenceStore.getBoolean(ComparePreferencePage.USE_RESOLVE_UI); } buildControl(parent); setColors(); INavigatable nav = new INavigatable() { public boolean selectChange(int flag) { if (flag == INavigatable.FIRST_CHANGE || flag == INavigatable.LAST_CHANGE) { selectFirstDiff(flag == INavigatable.FIRST_CHANGE); return false; } return navigate(flag == INavigatable.NEXT_CHANGE, false, false); } public Object getInput() { return ParseTreeMergeViewer.this.getInput(); } public boolean openSelectedChange() { return false; } public boolean hasChange(int flag) { return getNextVisibleDiff(flag == INavigatable.NEXT_CHANGE, false) != null; } }; getControl().setData(INavigatable.NAVIGATOR_PROPERTY, nav); fBirdsEyeCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND); JFaceResources.getFontRegistry().addListener(fPreferenceChangeListener); JFaceResources.getColorRegistry().addListener(fPreferenceChangeListener); updateFont(); }
From source file:gov.nasa.ensemble.common.ui.ide.navigator.EnsembleOpenResourceDialog.java
License:Open Source License
@Override protected void createButtonsForButtonBar(final Composite parent) { // increment the number of columns in the button bar GridLayout parentLayout = (GridLayout) parent.getLayout(); parentLayout.numColumns++;/* ww w . j av a 2 s . c o m*/ parentLayout.makeColumnsEqualWidth = false; final Composite openComposite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.horizontalSpacing = 0; layout.marginWidth = 0; layout.marginHeight = 0; openComposite.setLayout(layout); Button okButton = createButton(openComposite, IDialogConstants.OK_ID, IDEWorkbenchMessages.OpenResourceDialog_openButton_text, true); // Arrow down button for Open With menu ((GridLayout) openComposite.getLayout()).numColumns++; openWithButton = new Button(openComposite, SWT.PUSH); // openWithButton.setToolTipText(IDEWorkbenchMessages.OpenResourceDialog_openWithButton_toolTip); openWithButton.setImage(WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_LCL_BUTTON_MENU)); GridData data = new GridData(SWT.CENTER, SWT.FILL, false, true); openWithButton.setLayoutData(data); openWithButton.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { showOpenWithMenu(openComposite); } }); openWithButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { showOpenWithMenu(openComposite); } }); Button cancelButton = createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); GridData cancelLayoutData = (GridData) cancelButton.getLayoutData(); GridData okLayoutData = (GridData) okButton.getLayoutData(); int buttonWidth = Math.max(cancelLayoutData.widthHint, okLayoutData.widthHint); cancelLayoutData.widthHint = buttonWidth; okLayoutData.widthHint = buttonWidth; if (openComposite.getDisplay().getDismissalAlignment() == SWT.RIGHT) { // Make the default button the right-most button. // See also special code in org.eclipse.jface.dialogs.Dialog#initializeBounds() openComposite.moveBelow(null); if (Util.isCarbon()) { okLayoutData.horizontalIndent = -10; } } }
From source file:org.eclipse.compare.codereview.compareEditor.RefacTextMergeViewer.java
License:Open Source License
/** * Creates a text merge viewer under the given parent control. * * @param parent the parent control//from w w w .java 2 s. c o m * @param style SWT style bits for top level composite of this viewer * @param configuration the configuration object */ public RefacTextMergeViewer(Composite parent, int style, CompareConfiguration configuration) { super(style, ResourceBundle.getBundle(BUNDLE_NAME), configuration); operationHistoryListener = new IOperationHistoryListener() { public void historyNotification(OperationHistoryEvent event) { RefacTextMergeViewer.this.historyNotification(event); } }; OperationHistoryFactory.getOperationHistory().addOperationHistoryListener(operationHistoryListener); fMerger = new DocumentMerger(new IDocumentMergerInput() { public ITokenComparator createTokenComparator(String line) { return RefacTextMergeViewer.this.createTokenComparator(line); } public CompareConfiguration getCompareConfiguration() { return RefacTextMergeViewer.this.getCompareConfiguration(); } public IDocument getDocument(char contributor) { switch (contributor) { case LEFT_CONTRIBUTOR: return fLeft.getSourceViewer().getDocument(); case RIGHT_CONTRIBUTOR: return fRight.getSourceViewer().getDocument(); case ANCESTOR_CONTRIBUTOR: return fAncestor.getSourceViewer().getDocument(); } return null; } public int getHunkStart() { return RefacTextMergeViewer.this.getHunkStart(); } public Position getRegion(char contributor) { switch (contributor) { case LEFT_CONTRIBUTOR: return fLeft.getRegion(); case RIGHT_CONTRIBUTOR: return fRight.getRegion(); case ANCESTOR_CONTRIBUTOR: return fAncestor.getRegion(); } return null; } public boolean isHunkOnLeft() { ITypedElement left = ((ICompareInput) getInput()).getRight(); return left != null && Utilities.getAdapter(left, IHunk.class) != null; } public boolean isIgnoreAncestor() { return RefacTextMergeViewer.this.isIgnoreAncestor(); } public boolean isPatchHunk() { return RefacTextMergeViewer.this.isPatchHunk(); } public boolean isShowPseudoConflicts() { return fShowPseudoConflicts; } public boolean isThreeWay() { return RefacTextMergeViewer.this.isThreeWay(); } public boolean isPatchHunkOk() { return RefacTextMergeViewer.this.isPatchHunkOk(); } }); int inheritedStyle = parent.getStyle(); if ((inheritedStyle & SWT.LEFT_TO_RIGHT) != 0) fInheritedDirection = SWT.LEFT_TO_RIGHT; else if ((inheritedStyle & SWT.RIGHT_TO_LEFT) != 0) fInheritedDirection = SWT.RIGHT_TO_LEFT; else fInheritedDirection = SWT.NONE; if ((style & SWT.LEFT_TO_RIGHT) != 0) fTextDirection = SWT.LEFT_TO_RIGHT; else if ((style & SWT.RIGHT_TO_LEFT) != 0) fTextDirection = SWT.RIGHT_TO_LEFT; else fTextDirection = SWT.NONE; fSymbolicFontName = getSymbolicFontName(); fIsMotif = Util.isMotif(); fIsCarbon = Util.isCarbon(); fIsMac = Util.isMac(); if (fIsMotif) fMarginWidth = 0; fPreferenceChangeListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { RefacTextMergeViewer.this.handlePropertyChangeEvent(event); } }; fPreferenceStore = createChainedPreferenceStore(); if (fPreferenceStore != null) { fPreferenceStore.addPropertyChangeListener(fPreferenceChangeListener); fLeftIsLocal = Utilities.getBoolean(getCompareConfiguration(), "LEFT_IS_LOCAL", false); //$NON-NLS-1$ fSynchronizedScrolling = fPreferenceStore.getBoolean(ComparePreferencePage.SYNCHRONIZE_SCROLLING); fShowPseudoConflicts = fPreferenceStore.getBoolean(ComparePreferencePage.SHOW_PSEUDO_CONFLICTS); //fUseSplines= fPreferenceStore.getBoolean(ComparePreferencePage.USE_SPLINES); fUseSingleLine = fPreferenceStore.getBoolean(ComparePreferencePage.USE_SINGLE_LINE); fHighlightTokenChanges = fPreferenceStore.getBoolean(ComparePreferencePage.HIGHLIGHT_TOKEN_CHANGES); //fUseResolveUI= fPreferenceStore.getBoolean(ComparePreferencePage.USE_RESOLVE_UI); } buildControl(parent); setColors(); INavigatable nav = new INavigatable() { public boolean selectChange(int flag) { if (flag == INavigatable.FIRST_CHANGE || flag == INavigatable.LAST_CHANGE) { selectFirstDiff(flag == INavigatable.FIRST_CHANGE); return false; } return navigate(flag == INavigatable.NEXT_CHANGE, false, false); } public Object getInput() { return RefacTextMergeViewer.this.getInput(); } public boolean openSelectedChange() { return false; } public boolean hasChange(int flag) { return getNextVisibleDiff(flag == INavigatable.NEXT_CHANGE, false) != null; } }; fComposite.setData(INavigatable.NAVIGATOR_PROPERTY, nav); fBirdsEyeCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND); JFaceResources.getFontRegistry().addListener(fPreferenceChangeListener); JFaceResources.getColorRegistry().addListener(fPreferenceChangeListener); updateFont(); }
From source file:org.eclipse.compare.contentmergeviewer.TextMergeViewer.java
License:Open Source License
/** * Creates a text merge viewer under the given parent control. * * @param parent the parent control// ww w.j av a 2 s . c o m * @param style SWT style bits for top level composite of this viewer * @param configuration the configuration object */ public TextMergeViewer(Composite parent, int style, CompareConfiguration configuration) { super(style, ResourceBundle.getBundle(BUNDLE_NAME), configuration); operationHistoryListener = new IOperationHistoryListener() { public void historyNotification(OperationHistoryEvent event) { TextMergeViewer.this.historyNotification(event); } }; OperationHistoryFactory.getOperationHistory().addOperationHistoryListener(operationHistoryListener); fMerger = new DocumentMerger(new IDocumentMergerInput() { public ITokenComparator createTokenComparator(String line) { return TextMergeViewer.this.createTokenComparator(line); } public CompareConfiguration getCompareConfiguration() { return TextMergeViewer.this.getCompareConfiguration(); } public IDocument getDocument(char contributor) { switch (contributor) { case LEFT_CONTRIBUTOR: return fLeft.getSourceViewer().getDocument(); case RIGHT_CONTRIBUTOR: return fRight.getSourceViewer().getDocument(); case ANCESTOR_CONTRIBUTOR: return fAncestor.getSourceViewer().getDocument(); } return null; } public int getHunkStart() { return TextMergeViewer.this.getHunkStart(); } public Position getRegion(char contributor) { switch (contributor) { case LEFT_CONTRIBUTOR: return fLeft.getRegion(); case RIGHT_CONTRIBUTOR: return fRight.getRegion(); case ANCESTOR_CONTRIBUTOR: return fAncestor.getRegion(); } return null; } public boolean isHunkOnLeft() { ITypedElement left = ((ICompareInput) getInput()).getRight(); return left != null && Utilities.getAdapter(left, IHunk.class) != null; } public boolean isIgnoreAncestor() { return TextMergeViewer.this.isIgnoreAncestor(); } public boolean isPatchHunk() { return TextMergeViewer.this.isPatchHunk(); } public boolean isShowPseudoConflicts() { return fShowPseudoConflicts; } public boolean isThreeWay() { return TextMergeViewer.this.isThreeWay(); } public boolean isPatchHunkOk() { return TextMergeViewer.this.isPatchHunkOk(); } }); int inheritedStyle = parent.getStyle(); if ((inheritedStyle & SWT.LEFT_TO_RIGHT) != 0) fInheritedDirection = SWT.LEFT_TO_RIGHT; else if ((inheritedStyle & SWT.RIGHT_TO_LEFT) != 0) fInheritedDirection = SWT.RIGHT_TO_LEFT; else fInheritedDirection = SWT.NONE; if ((style & SWT.LEFT_TO_RIGHT) != 0) fTextDirection = SWT.LEFT_TO_RIGHT; else if ((style & SWT.RIGHT_TO_LEFT) != 0) fTextDirection = SWT.RIGHT_TO_LEFT; else fTextDirection = SWT.NONE; fSymbolicFontName = getSymbolicFontName(); fIsMotif = Util.isMotif(); fIsCarbon = Util.isCarbon(); fIsMac = Util.isMac(); if (fIsMotif) fMarginWidth = 0; fPreferenceChangeListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { TextMergeViewer.this.handlePropertyChangeEvent(event); } }; fPreferenceStore = createChainedPreferenceStore(); if (fPreferenceStore != null) { fPreferenceStore.addPropertyChangeListener(fPreferenceChangeListener); fLeftIsLocal = Utilities.getBoolean(getCompareConfiguration(), "LEFT_IS_LOCAL", false); //$NON-NLS-1$ fSynchronizedScrolling = fPreferenceStore.getBoolean(ComparePreferencePage.SYNCHRONIZE_SCROLLING); fShowPseudoConflicts = fPreferenceStore.getBoolean(ComparePreferencePage.SHOW_PSEUDO_CONFLICTS); //fUseSplines= fPreferenceStore.getBoolean(ComparePreferencePage.USE_SPLINES); fUseSingleLine = fPreferenceStore.getBoolean(ComparePreferencePage.USE_SINGLE_LINE); fHighlightTokenChanges = fPreferenceStore.getBoolean(ComparePreferencePage.HIGHLIGHT_TOKEN_CHANGES); //fUseResolveUI= fPreferenceStore.getBoolean(ComparePreferencePage.USE_RESOLVE_UI); } buildControl(parent); setColors(); INavigatable nav = new INavigatable() { public boolean selectChange(int flag) { if (flag == INavigatable.FIRST_CHANGE || flag == INavigatable.LAST_CHANGE) { selectFirstDiff(flag == INavigatable.FIRST_CHANGE); return false; } return navigate(flag == INavigatable.NEXT_CHANGE, false, false); } public Object getInput() { return TextMergeViewer.this.getInput(); } public boolean openSelectedChange() { return false; } public boolean hasChange(int flag) { return getNextVisibleDiff(flag == INavigatable.NEXT_CHANGE, false) != null; } }; fComposite.setData(INavigatable.NAVIGATOR_PROPERTY, nav); fBirdsEyeCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND); JFaceResources.getFontRegistry().addListener(fPreferenceChangeListener); JFaceResources.getColorRegistry().addListener(fPreferenceChangeListener); updateFont(); }
From source file:org.eclipse.ui.internal.ide.dialogs.OpenResourceDialog.java
License:Open Source License
protected void createButtonsForButtonBar(final Composite parent) { // increment the number of columns in the button bar GridLayout parentLayout = (GridLayout) parent.getLayout(); parentLayout.numColumns++;/*w ww. j a va2 s . c o m*/ parentLayout.makeColumnsEqualWidth = false; final Composite openComposite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.horizontalSpacing = 0; layout.marginWidth = 0; layout.marginHeight = 0; openComposite.setLayout(layout); Button okButton = createButton(openComposite, IDialogConstants.OK_ID, IDEWorkbenchMessages.OpenResourceDialog_openButton_text, true); // Arrow down button for Open With menu ((GridLayout) openComposite.getLayout()).numColumns++; openWithButton = new Button(openComposite, SWT.PUSH); openWithButton.setToolTipText(IDEWorkbenchMessages.OpenResourceDialog_openWithButton_toolTip); openWithButton.setImage(WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_LCL_BUTTON_MENU)); GridData data = new GridData(SWT.CENTER, SWT.FILL, false, true); openWithButton.setLayoutData(data); openWithButton.addMouseListener(new MouseAdapter() { public void mouseDown(MouseEvent e) { showOpenWithMenu(openComposite); } }); openWithButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { showOpenWithMenu(openComposite); } }); openWithButton.getAccessible().addAccessibleListener(new AccessibleAdapter() { public void getName(AccessibleEvent e) { if (e.childID == ACC.CHILDID_SELF) e.result = IDEWorkbenchMessages.OpenResourceDialog_openWithButton_toolTip; } }); Button cancelButton = createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); GridData cancelLayoutData = (GridData) cancelButton.getLayoutData(); GridData okLayoutData = (GridData) okButton.getLayoutData(); int buttonWidth = Math.max(cancelLayoutData.widthHint, okLayoutData.widthHint); cancelLayoutData.widthHint = buttonWidth; okLayoutData.widthHint = buttonWidth; if (openComposite.getDisplay().getDismissalAlignment() == SWT.RIGHT) { // Make the default button the right-most button. // See also special code in org.eclipse.jface.dialogs.Dialog#initializeBounds() openComposite.moveBelow(null); if (Util.isCarbon()) { okLayoutData.horizontalIndent = -10; } } }
From source file:org.xmind.gef.draw2d.graphics.GraphicsUtils.java
License:Open Source License
private static boolean isCarbon() { if (carbon == null) { carbon = Boolean.valueOf(Util.isCarbon()); }/* w ww . ja va2s . com*/ return carbon.booleanValue(); }