Skip to content

nisrael/sxda-scout-addon

Repository files navigation

Additional form fields for Eclipse Scout

The modules in this project provide wrapper modules for commonly used open source form field elements as extensions to the Eclipse Scout framework.

Versioning and Releases

The major and minor version of the modules in this repository match the major and minor version of the Eclipse Scout release they are intended to be used with. The patch version is incremented for every release of the addon modules. This means, that for example the sxda-scout-addon version 24.1.x should be compatible with all Eclipse Scout 24.1.y versions.

You should override the property org.eclipse.scout.rt.version in your root pom.xml to the version of the Eclipse Scout release you are using. For the npm modules, you should be fine because the dependency to the Eclipse Scout runtime is defined as a peer dependency.

Releases are published to central.sonatype.com and npmjs.org. The version number of the release is always the same for both repositories.

Snapshot versions are published to GitHub Packages and npmjs.org.

Contributing

Contributions are welcome:

  • If you found a bug, please open an issue or, if you are able to fix it, open a pull request.

  • If you have an idea for a new form field element or an improvement of the existing one(s), please open an issue or even better a pull request.

  • If you have a question, please open an issue.

Elements

Ace Code Editor

The Ace Code Editor is a web based code editor with syntax highlighting and code completion for many programming languages. The wrapper is implemented as AbstractAceField extends AbstractValueField<String> and can be used in a form like any other value field.

Usage

To use the field in an Eclipse Scout Classic 24.1.y application, add the following modules to your application:

your.app.client/pom.xml
<!-- ... -->
<dependency>
  <groupId>io.sxda.scout.addon</groupId>
  <artifactId>ace.client</artifactId>
  <version>24.1.1</version>
</dependency>
<!-- ... -->
your.app.ui.html/pom.xml
<!-- ... -->
<dependency>
  <groupId>io.sxda.scout.addon</groupId>
  <artifactId>ace.ui.html</artifactId>
  <version>24.1.1</version>
</dependency>
<!-- ... -->

The node module @sxda/scout-addon-ace does not redistribute the transitive dependency ace-builds. This means that if there is a new version of the ace code editor, you can use that right away (assuming compatibility) and don’t have to wait for a new release of the addon modules. The disadvantage is, that you have to add the ace code editor as a dependency yourself in addition to the @sxda/scout-addon-ace module.

Here are the dependencies you have to add to the package.json file of the ui.html module of your application :

your.app.ui.html/packages.json
{
  "dependencies": {
    "@sxda/scout-addon-ace": "24.1.1",
    "ace-code": "1.33.1",
    "webpack": "5.88.0"
  }
}

In the index.ts file of the ui.html module, the AceField need to be imported and registered. Also, the loader for the Ace mode and theme files have to be defined by importing the ace-code/esm-resolver module.

your.app.ui.html/src/main/js/index.ts
import {AceField} from "@sxda/scout-addon-ace";
ObjectFactory.get().registerNamespace('sxda', AceField);
import 'ace-code/esm-resolver';
your.app.ui.html/src/main/js/index.less
@import "@sxda/scout-addon-ace/dist/ace-theme.css";
your.app.ui.html/src/main/js/index-dark.less
@import "@sxda/scout-addon-ace/dist/ace-theme-dark.css";

Finally, the ace code editor can be used in a form:

SomeForm.java
/* */
  @Order(1000)
  public class CodeField extends AbstractAceField {
    @Override
    protected int getConfiguredGridW() {
      return 2;
    }

    @Override
    protected String getConfiguredLabel() {
      return TEXTS.get("Code");
    }

    @Override
    protected String getConfiguredTheme() {
      return AceTheme.TWILIGHT.getConfigTerm();
    }

    @Override
    protected boolean getConfiguredShowPrintMargin() {
      return true;
    }

    @Override
    protected int getConfiguredTabSize() {
      return 2;
    }

    @Override
    protected boolean getConfiguredHighlightActiveLine() {
      return true;
    }

    @Override
    protected boolean getConfiguredUseSoftTabs() {
      return true;
    }

    @Override
    protected boolean getConfiguredUseWrapMode() {
      return false;
    }
  }
/* */

Demo

A Scout JS demo application is located in the demo directory. An instance of the latest snapshot version is available at: https://nisrael.github.io/sxda-scout-addon/.

And a demo Scout Classic application can be found at: https://github.com/nisrael/sxda-scout-apps-addondemo.

License

This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which is available at https://www.eclipse.org/legal/epl-2.0/

SPDX-License-Identifier: EPL-2.0

Please also refer to the NOTICE file(s) that are distributed along with this source code.