Skip to content

Commit

Permalink
More changes related to the removal of custom fonts.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexisDrogoul committed Jul 17, 2021
1 parent 5d617d1 commit 1906c95
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 48 deletions.
3 changes: 0 additions & 3 deletions msi.gama.application/plugin_customization.ini
Expand Up @@ -11,9 +11,6 @@ org.eclipse.core.resources/description.autobuilding=true
org.eclipse.core.resources/refresh.lightweight.enabled=true
org.eclipse.ui.workbench/HeapStatus.updateInterval=1000
org.eclipse.core.resources/encoding=UTF-8
org.eclipse.ui.workbench/org.eclipse.ui.workbench.TAB_TEXT_FONT=1|Helvetica|11|1|WINDOWS|1|
org.eclipse.ui.workbench/org.eclipse.ui.workbench.TAB_TEXT_FONT=1|Helvetica|11|1|COCOA|1|
org.eclipse.ui.workbench/org.eclipse.ui.workbench.TAB_TEXT_FONT=1|Helvetica|11|1|GTK|1|
org.eclipse.ui/showIntro=false
org.eclipse.ui.internal.views.markers.CachedMarkerBuildermsi.gama.application.problems=<?xml version\="1.0" encoding\="UTF-8"?>\n<filterGroups andFilters\="false" markerLimit\="100" markerLimitEnabled\="false">\n<filterGroup IMemento.internal.id\="Problems" enabled\="true" filterLimit\="-1" scope\="0"/>\n</filterGroups>
org.eclipse.ui.ide/USE_MARKER_LIMITS=false
Expand Down
Expand Up @@ -202,7 +202,7 @@ protected IAnnotationAccess createAnnotationAccess() {

@Override
public int getLayer(final Annotation annotation) {
if (annotation.isMarkedDeleted()) { return IAnnotationAccessExtension.DEFAULT_LAYER; }
if (annotation.isMarkedDeleted()) return IAnnotationAccessExtension.DEFAULT_LAYER;
return super.getLayer(annotation);
}

Expand All @@ -219,7 +219,7 @@ public void paint(final Annotation annotation, final GC gc, final Canvas canvas,

@Override
public boolean isPaintable(final Annotation annotation) {
if (imageProvider.getManagedImage(annotation) != null) { return true; }
if (imageProvider.getManagedImage(annotation) != null) return true;
return super.isPaintable(annotation);
}

Expand Down Expand Up @@ -295,9 +295,7 @@ public final IPreferenceStore getAdvancedPreferenceStore() {
private void configureTabFolder(final Composite compo) {
var c = compo;
while (c != null) {
if (c instanceof CTabFolder) {
break;
}
if (c instanceof CTabFolder) { break; }
c = c.getParent();
}
if (c != null) {
Expand All @@ -306,7 +304,9 @@ private void configureTabFolder(final Composite compo) {
folder.setMinimizeVisible(true);
folder.setMinimumCharacters(10);
folder.setMRUVisible(true);
folder.setTabHeight(16);
folder.setUnselectedCloseVisible(true);
folder.setHighlightEnabled(true);
// folder.setTabHeight(16);
}

}
Expand Down Expand Up @@ -348,14 +348,14 @@ protected void initializeDirtyStateSupport() {
}

private void scheduleValidationJob() {
if (!isEditable()) { return; }
if (!isEditable()) return;
final IValidationIssueProcessor processor = new MarkerIssueProcessor(getResource(),
getInternalSourceViewer().getAnnotationModel(), markerCreator, markerTypeProvider);
final ValidationJob validate = new ValidationJob(validator, getDocument(), processor, CheckMode.FAST_ONLY) {
@Override
protected IStatus run(final IProgressMonitor monitor) {
final var issues = getDocument().readOnly(resource -> {
if (resource.isValidationDisabled()) { return Collections.emptyList(); }
if (resource.isValidationDisabled()) return Collections.emptyList();
return validator.validate(resource, getCheckMode(), null);
});
processor.processIssues((List<Issue>) issues, monitor);
Expand All @@ -370,7 +370,7 @@ protected IStatus run(final IProgressMonitor monitor) {
@Override
public boolean isOverviewRulerVisible() {
final var viewer = getInternalSourceViewer();
if (viewer == null) { return super.isOverviewRulerVisible(); }
if (viewer == null) return super.isOverviewRulerVisible();
return viewer.isOverviewVisible();
}

Expand All @@ -393,33 +393,29 @@ private void installGestures() {
final var text = this.getInternalSourceViewer().getTextWidget();
if (text != null) {
text.addGestureListener(ge -> {
if (ge.detail == SWT.GESTURE_END) {
updateBoxes();
}
if (ge.detail == SWT.GESTURE_END) { updateBoxes(); }
});
}
}

@Override
protected void installFoldingSupport(final ProjectionViewer projectionViewer) {
super.installFoldingSupport(projectionViewer);
if (!isRangeIndicatorEnabled()) {
projectionViewer.doOperation(ProjectionViewer.TOGGLE);
}
if (!isRangeIndicatorEnabled()) { projectionViewer.doOperation(ProjectionViewer.TOGGLE); }
}

@Override
protected void handleCursorPositionChanged() {
if (getSelectionProvider() == null) { return; }
if (getInternalSourceViewer() == null) { return; }
if (getInternalSourceViewer().getControl() == null) { return; }
if (getInternalSourceViewer().getControl().isDisposed()) { return; }
if (getSelectionProvider() == null || getInternalSourceViewer() == null
|| getInternalSourceViewer().getControl() == null
|| getInternalSourceViewer().getControl().isDisposed())
return;
super.handleCursorPositionChanged();
this.markInNavigationHistory();
}

private void enableButton(final int index, final String text, final SelectionListener listener) {
if (text == null) { return; }
if (text == null) return;
final var expType = state.types.get(index);
final var image = IKeyword.BATCH.equals(expType) ? GamaIcons.create(IGamaIcons.BUTTON_BATCH).image()
: IKeyword.MEMORIZE.equals(expType) ? GamaIcons.create(IGamaIcons.BUTTON_BACK).image()
Expand All @@ -439,11 +435,9 @@ private void enableButton(final int index, final String text, final SelectionLis
private void updateToolbar(final GamlEditorState newState, final boolean forceState) {
if (forceState || !state.equals(newState)) {
WorkbenchHelper.runInUI("Editor refresh", 50, m -> {
if (toolbar == null || toolbar.isDisposed()) { return; }
if (toolbar == null || toolbar.isDisposed()) return;
toolbar.wipe(SWT.LEFT, true);
if (PlatformHelper.isWindows()) {
toolbar.sep(4, SWT.LEFT);
}
if (PlatformHelper.isWindows()) { toolbar.sep(4, SWT.LEFT); }

final var c = state.getColor();
var msg = state.getStatus();
Expand Down Expand Up @@ -533,20 +527,18 @@ public void doSaveAs() {
}

private void beforeSave() {
if (!GamaPreferences.Modeling.EDITOR_CLEAN_UP.getValue()) { return; }
if (!GamaPreferences.Modeling.EDITOR_CLEAN_UP.getValue()) return;
final SourceViewer sv = getInternalSourceViewer();
final var p = sv.getSelectedRange();
sv.setSelectedRange(0, sv.getDocument().getLength());
if (sv.canDoOperation(SourceViewer.FORMAT)) {
sv.doOperation(ISourceViewer.FORMAT);
}
if (sv.canDoOperation(ISourceViewer.FORMAT)) { sv.doOperation(ISourceViewer.FORMAT); }
sv.setSelectedRange(p.x, p.y);
}

@Override
protected String[] collectContextMenuPreferencePages() {
final var commonPages = super.collectContextMenuPreferencePages();
final var langSpecificPages = new String[] { "pm.eclipse.editbox.pref.default" };
final String[] langSpecificPages = { "pm.eclipse.editbox.pref.default" };
return ObjectArrays.concat(langSpecificPages, commonPages, String.class);
}

Expand All @@ -555,9 +547,7 @@ protected String[] collectContextMenuPreferencePages() {
*/
@Override
public IBoxDecorator getDecorator() {
if (decorator == null) {
createDecorator();
}
if (decorator == null) { createDecorator(); }
return decorator;
}

Expand All @@ -566,7 +556,7 @@ public IBoxDecorator getDecorator() {
*/
@Override
public void createDecorator() {
if (decorator != null) { return; }
if (decorator != null) return;
final var provider = BoxProviderRegistry.getInstance().getGamlProvider();
decorator = provider.createDecorator();
decorator.setStyledText(getStyledText());
Expand Down Expand Up @@ -603,7 +593,7 @@ public void setDecorationEnabled(final boolean toggle) {
}

public void updateBoxes() {
if (!decorationEnabled) { return; }
if (!decorationEnabled) return;
getDecorator().forceUpdate();
}

Expand All @@ -614,10 +604,8 @@ public boolean isDecorationEnabled() {

private void assignBoxPartListener() {
final var partService = getSite().getWorkbenchWindow().getPartService();
if (partService == null) { return; }
if (partListeners == null) {
partListeners = new HashMap<>();
}
if (partService == null) return;
if (partListeners == null) { partListeners = new HashMap<>(); }
final var oldListener = partListeners.get(partService);
if (oldListener == null) {
final IPartListener2 listener = new BoxDecoratorPartListener();
Expand All @@ -632,10 +620,7 @@ public void insertText(final String s) {
final var length = selection.getLength();
try {
new ReplaceEdit(offset, length, s).apply(getDocument());
} catch (final MalformedTreeException e) {
e.printStackTrace();
return;
} catch (final BadLocationException e) {
} catch (final MalformedTreeException | BadLocationException e) {
e.printStackTrace();
return;
}
Expand All @@ -645,7 +630,7 @@ public void insertText(final String s) {
public String getSelectedText() {
final var sel = (ITextSelection) getSelectionProvider().getSelection();
final var length = sel.getLength();
if (length == 0) { return ""; }
if (length == 0) return "";
final IDocument doc = getDocument();
try {
return doc.get(sel.getOffset(), length);
Expand Down Expand Up @@ -739,7 +724,7 @@ public void createToolItems(final GamaToolbar2 tb) {
protected void handlePreferenceStoreChanged(final PropertyChangeEvent event) {
final LineNumberColumn c;
super.handlePreferenceStoreChanged(event);
if (event.getProperty().equals(PREFERENCE_COLOR_BACKGROUND)) {
if (PREFERENCE_COLOR_BACKGROUND.equals(event.getProperty())) {
// this.fSourceViewerDecorationSupport.updateOverviewDecorations();

this.getVerticalRuler().getControl()
Expand Down
Expand Up @@ -49,7 +49,9 @@ protected void displayParameterValue() {
final var data = currentValue != null ? currentValue
: toGamaFont(WorkbenchHelper.getDisplay().getSystemFont().getFontData()[0]);
edit.setText(currentValue == null ? "Default" : data.toString());
Font old = edit.getFont();
edit.setFont(new Font(WorkbenchHelper.getDisplay(), toFontData(data)));
if (old != null && old != WorkbenchHelper.getDisplay().getSystemFont()) { old.dispose(); }
internalModification = false;
}

Expand Down
Expand Up @@ -147,7 +147,7 @@ public static Composite createToolbarComposite(final Composite composite) {
layout.verticalSpacing = 0;
layout.horizontalSpacing = 0;
layout.marginWidth = 0;
final int margin = 0; // REDUCED_VIEW_TOOLBAR_HEIGHT.getValue() ? -1 : 0;
final int margin = 2; // REDUCED_VIEW_TOOLBAR_HEIGHT.getValue() ? -1 : 0;
layout.marginTop = margin;
layout.marginBottom = margin;
layout.marginHeight = margin;
Expand Down

0 comments on commit 1906c95

Please sign in to comment.