java.lang.Object
com.amalgamasimulation.desktop.ui.editor.Buttons

public final class Buttons extends Object
Creates buttons for addButton(...) of the sections. Sections are of three kinds: standalone (the value comes from a Supplier, for example Sections.doubleEditor(() -> value)), container (a property of an object in a WritableValue, for example Sections.doubleEditor(writableValue)) and EMF (a feature of an EObject in a WritableValue, for example Sections.emfDoubleEditor(writableValue)). A button can be added only to a section of a fitting kind:
  • simpleButton() and the built-in buttons (refresh, clear, color, distribution, realDistribution, timeSeries, localDateTime, localTime, openFile, saveFile, openDirectory, highlight, navigate, showProperty) work in all three kinds;
  • containerButton(), selectElementFromTable() and selectElementFromGef() work in container and EMF sections;
  • emfButton(), selectEmfElementFromTable(), selectElementsFromTable() and selectEmfElementFromGef() work only in EMF sections;
  • separateButton() and checkBox() are added only to customSectionBuilder.
highlight(), navigate(), showProperty(), selectElementFromGef() and selectEmfElementFromGef() send an event to IEventBroker. On a BasePage the broker comes by itself. Outside it pass the broker with eventBroker(...), otherwise a click throws NullPointerException.
Author:
Ionov Ivan
  • Method Details

    • separateButton

      public static SeparateButtonProperties separateButton()
      Separate button in a customSectionBuilder row. handler(...) sets the action, without it a click does nothing.
      Returns:
      the properties of the button
    • simpleButton

      public static <V> ImplSimpleButtonProperties<V> simpleButton()
      The most customizable button: the action in action(...) gets the current value.
      Type Parameters:
      V - type of the value
      Returns:
      the properties of the button
    • containerButton

      public static <T, V> ImplContainerButtonProperties<T,V> containerButton()
      Customizable button of a container section: the action gets the object and the value.
      Type Parameters:
      T - type of the object in the container
      V - type of the value
      Returns:
      the properties of the button
    • emfButton

      public static <T extends org.eclipse.emf.ecore.EObject, V> ImplEmfButtonProperties<T,V> emfButton()
      Customizable button of an EMF section: the action gets the object and the feature.
      Type Parameters:
      T - type of the object in the container
      V - type of the value
      Returns:
      the properties of the button
    • color

      public static ColorButtonProperties color()
      Opens the color dialog. The default button of colorEditor.
      Returns:
      the properties of the button
    • checkBox

      public static CheckBoxButtonProperties checkBox()
      Check box in a customSectionBuilder row, checkBoxEditor of that builder adds it.
      Returns:
      the properties of the button
    • refresh

      public static <V> RefreshButtonProperties<V> refresh()
      Reads the value again and shows it in the field.
      Type Parameters:
      V - type of the value
      Returns:
      the properties of the button
    • clear

      public static <V> ClearButtonProperties<V> clear()
      Writes null. action(...) sets your own value instead of null.
      Type Parameters:
      V - type of the value
      Returns:
      the properties of the button
    • distribution

      public static DistributionButtonProperties distribution()
      Opens the Distribution dialog. The default button of distributionEditor, the right border is minus infinity by default.
      Returns:
      the properties of the button
    • realDistribution

      public static RealDistributionButtonProperties realDistribution()
      Opens the RealDistribution dialog. The default button of realDistributionEditor.
      Returns:
      the properties of the button
    • timeSeries

      public static TimeSeriesButtonProperties timeSeries()
      Opens the time series dialog. The default button of timeSeriesEditor.
      Returns:
      the properties of the button
    • openFile

      public static OpenFileButtonProperties openFile()
      Opens the file dialog and writes the path. With multipleFiles() several files can be selected.
      Returns:
      the properties of the button
    • saveFile

      public static SaveFileButtonProperties saveFile()
      Opens the save dialog and writes the path.
      Returns:
      the properties of the button
    • openDirectory

      public static OpenDirectoryButtonProperties openDirectory()
      Opens the folder dialog and writes the path.
      Returns:
      the properties of the button
    • localDateTime

      public static LocalDateTimeButtonProperties localDateTime()
      Opens the date and time dialog. The default button of localDateTimeEditor.
      Returns:
      the properties of the button
    • localTime

      public static LocalTimeButtonProperties localTime()
      Opens the time dialog. The default button of localTimeEditor.
      Returns:
      the properties of the button
    • selectEmfElementFromTable

      public static <T extends org.eclipse.emf.ecore.EObject, V> SelectEmfElementFromTableButtonProperties<T,V> selectEmfElementFromTable()
      Opens a table of the elements and writes the selected element to the feature with a command.
      Type Parameters:
      T - type of the object in the container
      V - type of the value
      Returns:
      the properties of the button
    • selectElementFromTable

      public static <T, V> SelectElementFromTableButtonProperties<T,V> selectElementFromTable()
      Opens a table of the elements, the selected element becomes the value.
      Type Parameters:
      T - type of the object in the container
      V - type of the value
      Returns:
      the properties of the button
    • selectElementsFromTable

      public static <T extends org.eclipse.emf.ecore.EObject, V> SelectElementsFromTableButtonProperties<T,V> selectElementsFromTable()
      Opens a table with check boxes for a many-valued feature and writes the change with a command.
      Type Parameters:
      T - type of the object in the container
      V - type of the value
      Returns:
      the properties of the button
    • selectEmfElementFromGef

      public static <T extends org.eclipse.emf.ecore.EObject, V> SelectEmfElementFromGefButtonProperties<T,V> selectEmfElementFromGef()
      Waits for an object selected in the GEF editor that passes filter(...) and writes it with a command. Calls eventBroker.send(PlatformTopics.WAITING_FOR_FILTERED_OBJECT_SELECTION, request). Without filter(...) a click throws NullPointerException.
      Type Parameters:
      T - type of the object in the container
      V - type of the value
      Returns:
      the properties of the button
    • selectElementFromGef

      public static <T, V> SelectElementFromGefButtonProperties<T,V> selectElementFromGef()
      The same as selectEmfElementFromGef() for a container section, but only customAction(...) writes the object.
      Type Parameters:
      T - type of the object in the container
      V - type of the value
      Returns:
      the properties of the button
    • highlight

      public static <V> HighlightButtonProperties<V> highlight()
      Calls eventBroker.send(PlatformTopics.HIGHLIGHT, value). Needs IEventBroker, see the class description.
      Type Parameters:
      V - type of the value
      Returns:
      the properties of the button
    • showProperty

      public static <V> ShowPropertyButtonProperties<V> showProperty()
      Calls eventBroker.send(PlatformTopics.PROPERTY_PERSPECTIVE_CHANGED, value). Needs IEventBroker, see the class description. The property panel shows the value if it has a page for its class.
      Type Parameters:
      V - type of the value
      Returns:
      the properties of the button