Skip to content

Commit

Permalink
Various simplifications related to fonts in the UI
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexisDrogoul committed Jul 16, 2021
1 parent 73a7f41 commit 5d617d1
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 126 deletions.
Expand Up @@ -40,7 +40,7 @@
* </p>
* <p>
* Example usage:
*
*
* <pre>
* mainPage = new WizardNewProjectCreationPage("basicNewProjectPage");
* mainPage.setTitle("Project");
Expand Down Expand Up @@ -100,7 +100,7 @@ public void createControl(final Composite parent) {

/**
* Get an error reporter for the receiver.
*
*
* @return IErrorMessageReporter
*/
// private IErrorMessageReporter getErrorReporter() {
Expand Down Expand Up @@ -137,14 +137,14 @@ private final void createProjectNameGroup(final Composite parent) {
// new project label
final Label projectLabel = new Label(projectGroup, SWT.NONE);
projectLabel.setText(IDEWorkbenchMessages.WizardNewProjectCreationPage_nameLabel);
projectLabel.setFont(parent.getFont());
// projectLabel.setFont(parent.getFont());

// new project name entry field
projectNameField = new Text(projectGroup, SWT.BORDER);
final GridData data = new GridData(GridData.FILL_HORIZONTAL);
data.widthHint = SIZING_TEXT_FIELD_WIDTH;
projectNameField.setLayoutData(data);
projectNameField.setFont(parent.getFont());
// projectNameField.setFont(parent.getFont());
final Button test = new Button(projectGroup, SWT.CHECK);
final Button newModel = new Button(projectGroup, SWT.CHECK);
test.setText("Configure as a test project");
Expand Down Expand Up @@ -174,9 +174,7 @@ public void widgetSelected(final SelectionEvent e) {

// Set the initial value first before listener
// to avoid handling an event during the creation.
if (initialProjectFieldValue != null) {
projectNameField.setText(initialProjectFieldValue);
}
if (initialProjectFieldValue != null) { projectNameField.setText(initialProjectFieldValue); }
projectNameField.addListener(SWT.Modify, nameModifyListener);
}

Expand Down Expand Up @@ -208,8 +206,7 @@ public boolean createNewModel() {
* @since 3.2
*/
public URI getLocationURI() {
final URI u = Platform.getLocation().addTrailingSeparator().append(getProjectName()).toFile().toURI();
return u;
return Platform.getLocation().addTrailingSeparator().append(getProjectName()).toFile().toURI();
// DEBUG.LOG("PATH: " + s);
// final URI uri = URI.create(s);
// DEBUG.LOG("URI: " + uri);
Expand Down Expand Up @@ -239,7 +236,7 @@ public IProject getProjectHandle() {
* @return the project name, its anticipated initial value, or <code>null</code> if no project name is known
*/
public String getProjectName() {
if (projectNameField == null) { return initialProjectFieldValue; }
if (projectNameField == null) return initialProjectFieldValue;

return getProjectNameFieldValue();
}
Expand All @@ -250,8 +247,7 @@ public String getProjectName() {
* @return the project name in the field
*/
private String getProjectNameFieldValue() {
if (projectNameField == null) { return ""; //$NON-NLS-1$
}
if (projectNameField == null) return ""; //$NON-NLS-1$

return projectNameField.getText().trim();
}
Expand Down Expand Up @@ -295,7 +291,7 @@ protected boolean validatePage() {
final IWorkspace workspace = IDEWorkbenchPlugin.getPluginWorkspace();

final String projectFieldContents = getProjectNameFieldValue();
if (projectFieldContents.equals("")) { //$NON-NLS-1$
if ("".equals(projectFieldContents)) { //$NON-NLS-1$
setErrorMessage(null);
setMessage(IDEWorkbenchMessages.WizardNewProjectCreationPage_projectNameEmpty);
return false;
Expand Down Expand Up @@ -334,14 +330,12 @@ protected boolean validatePage() {
@Override
public void setVisible(final boolean visible) {
super.setVisible(visible);
if (visible) {
projectNameField.setFocus();
}
if (visible) { projectNameField.setFocus(); }
}

/**
* Returns the useDefaults.
*
*
* @return boolean
*/
// public boolean useDefaults() {
Expand Down

This file was deleted.

Expand Up @@ -16,6 +16,7 @@
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Device;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Path;
Expand Down Expand Up @@ -162,10 +163,30 @@ private void drawBackground(final GC gc, final Rectangle rect) {

}

private static class Clipping extends Path {

public Clipping(final Device device, final float x, final float y, final float width, final float height,
final float arcWidth, final float arcHeight) {
super(device);
if (this.isDisposed()) { SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); }
// Top left corner
this.cubicTo(x, y, x, y, x, y + arcHeight);
this.cubicTo(x, y, x, y, x + arcWidth, y);
// Top right corner
this.cubicTo(x + width, y, x + width, y, x + width - arcWidth, y);
this.cubicTo(x + width, y, x + width, y, x + width, y + arcHeight);
// Bottom right corner
this.cubicTo(x + width, y + height, x + width, y + height, x + width, y + height - arcHeight);
this.cubicTo(x + width, y + height, x + width, y + height, x + width - arcWidth, y + height);
// Bottom left corner
this.cubicTo(x, y + height, x, y + height, x + arcWidth, y + height);
this.cubicTo(x, y + height, x, y + height, x, y + height - arcHeight);
}

}

private Path createClipping(final Rectangle rect) {
final AdvancedPath path = new AdvancedPath(WorkbenchHelper.getDisplay());
path.addRoundRectangle(rect.x, rect.y, rect.width, rect.height, 8, 8);
return path;
return new Clipping(WorkbenchHelper.getDisplay(), rect.x, rect.y, rect.width, rect.height, 8, 8);
}

@Override
Expand Down Expand Up @@ -294,7 +315,7 @@ public String getText() {
}

public FlatButton setText(final String text) {
if ((text == null) || text.equals(this.text)) return this;
if (text == null || text.equals(this.text)) return this;
this.text = text;
redraw();
return this;
Expand Down
@@ -1,8 +1,8 @@
/*********************************************************************************************
*
* 'AbstractDetailsDialog.java, in plugin ummisco.gama.ui.shared, is part of the source code of the GAMA modeling and
* simulation platform. (v. 1.8.1)
*
* simulation platform. (v. 1.8.1)
*
* (c) 2007-2020 UMI 209 UMMISCO IRD/UPMC & Partners
*
* Visit https://github.com/gama-platform/gama for license information and developers contact.
Expand Down Expand Up @@ -100,9 +100,7 @@ protected AbstractDetailsDialog(final IShellProvider parentShell, final String t
@Override
protected void configureShell(final Shell shell) {
super.configureShell(shell);
if (title != null) {
shell.setText(title);
}
if (title != null) { shell.setText(title); }
}

/**
Expand Down Expand Up @@ -132,7 +130,7 @@ protected Control createDialogArea(final Composite parent) {
final GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER);
data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
label.setLayoutData(data);
label.setFont(parent.getFont());
// label.setFont(parent.getFont());
}
return composite;
}
Expand Down
25 changes: 10 additions & 15 deletions ummisco.gama.ui.shared/src/ummisco/gama/ui/views/GamaViewPart.java
Expand Up @@ -155,13 +155,11 @@ public void init(final IViewSite site) throws PartInitException {
}
}
}
} else {
if (shouldBeClosedWhenNoExperiments()) {
WorkbenchHelper.asyncRun(() -> {
if (shouldBeClosedWhenNoExperiments()) { close(GAMA.getRuntimeScope()); }
});
} else if (shouldBeClosedWhenNoExperiments()) {
WorkbenchHelper.asyncRun(() -> {
if (shouldBeClosedWhenNoExperiments()) { close(GAMA.getRuntimeScope()); }
});

}
}
addOutput(out);
}
Expand Down Expand Up @@ -228,13 +226,10 @@ public void addOutput(final IDisplayOutput out) {
if (out == null) return;
if (!outputs.contains(out)) {
outputs.add(out);
} else {
if (toolbar != null) {
toolbar.wipe(SWT.LEFT, true);
toolbar.wipe(SWT.RIGHT, true);
GamaToolbarFactory.buildToolbar(GamaViewPart.this, toolbar);
}

} else if (toolbar != null) {
toolbar.wipe(SWT.LEFT, true);
toolbar.wipe(SWT.RIGHT, true);
GamaToolbarFactory.buildToolbar(GamaViewPart.this, toolbar);
}

}
Expand All @@ -250,9 +245,9 @@ public void widgetDisposed(final DisposeEvent e) {

@Override
public void dispose() {
DEBUG.OUT("+++ Part " + this.getPartName() + " is being disposed");
// DEBUG.OUT("+++ Part " + this.getPartName() + " is being disposed");
toolbarUpdater = null;
WorkbenchHelper.run(() -> super.dispose());
WorkbenchHelper.run(super::dispose);

}

Expand Down
Expand Up @@ -82,7 +82,7 @@ protected Control createDialogArea(final Composite parent) {
layout.numColumns = 2;
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
composite.setFont(parentComposite.getFont());
// composite.setFont(parentComposite.getFont());

final Label l = new Label(composite, SWT.RIGHT);
l.setText("Type:");
Expand Down Expand Up @@ -138,15 +138,15 @@ protected void okPressed() {
* the SWT.IMAGE_ type.
*/
public void setOriginalName(final String name, final int type) {
String basename = name;
StringBuilder basename = new StringBuilder().append(name);
for (int i = 0; i < IMAGE_TYPES.length; i++) {
if (type == IMAGE_TYPES[i]) {
initialImageTypeIndex = i;
basename += "." + IMAGE_EXTS[i]; //$NON-NLS-1$
basename.append(".").append(IMAGE_EXTS[i]); //$NON-NLS-1$
break;
}
}
setOriginalName(basename);
setOriginalName(basename.toString());
}

/**
Expand Down Expand Up @@ -175,21 +175,19 @@ public void setOriginalFile(final IFile file, final int type) {
* Get the selected image type.
*/
public int getSaveAsImageType() {
if (selectedImageTypeIndex >= 0 && selectedImageTypeIndex < IMAGE_TYPES.length) {
if (selectedImageTypeIndex >= 0 && selectedImageTypeIndex < IMAGE_TYPES.length)
return IMAGE_TYPES[selectedImageTypeIndex];
} else {
else
return IMAGE_TYPES[0];
}
}

/**
* Get the selected image type.
*/
public String getSaveAsImageExt() {
if (selectedImageTypeIndex >= 0 && selectedImageTypeIndex < IMAGE_TYPES.length) {
if (selectedImageTypeIndex >= 0 && selectedImageTypeIndex < IMAGE_TYPES.length)
return IMAGE_EXTS[selectedImageTypeIndex];
} else {
else
return IMAGE_EXTS[0];
}
}
}

0 comments on commit 5d617d1

Please sign in to comment.