All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opentcs.operationsdesk.application.action.app.AboutAction Maven / Gradle / Ivy

There is a newer version: 6.2.0
Show newest version
/**
 * Copyright (c) The openTCS Authors.
 *
 * This program is free software and subject to the MIT license. (For details,
 * see the licensing information (LICENSE.txt) you should have received with
 * this copy of the software.)
 */
package org.opentcs.operationsdesk.application.action.app;

import static java.util.Objects.requireNonNull;
import static javax.swing.Action.LARGE_ICON_KEY;
import static javax.swing.Action.MNEMONIC_KEY;
import static javax.swing.Action.SMALL_ICON;
import static org.opentcs.operationsdesk.util.I18nPlantOverviewOperating.MENU_PATH;

import jakarta.inject.Inject;
import java.awt.Component;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import org.opentcs.access.SharedKernelServicePortalProvider;
import org.opentcs.customizations.plantoverview.ApplicationFrame;
import org.opentcs.guing.common.application.ApplicationState;
import org.opentcs.guing.common.util.ImageDirectory;
import org.opentcs.operationsdesk.application.OpenTCSView;
import org.opentcs.thirdparty.guing.common.jhotdraw.util.ResourceBundleUtil;
import org.opentcs.util.Environment;

/**
 * Displays a dialog showing information about the application.
 */
public class AboutAction
    extends
      AbstractAction {

  /**
   * This action's ID.
   */
  public static final String ID = "application.about";

  private static final ResourceBundleUtil BUNDLE = ResourceBundleUtil.getBundle(MENU_PATH);
  /**
   * Stores the application's current state.
   */
  private final ApplicationState appState;
  /**
   * Provides access to a portal.
   */
  private final SharedKernelServicePortalProvider portalProvider;
  /**
   * The parent component for dialogs shown by this action.
   */
  private final Component dialogParent;

  /**
   * Creates a new instance.
   *
   * @param appState Stores the application's current state.
   * @param portalProvider Provides access to a portal.
   * @param dialogParent The parent component for dialogs shown by this action.
   */
  @Inject
  @SuppressWarnings("this-escape")
  public AboutAction(
      ApplicationState appState,
      SharedKernelServicePortalProvider portalProvider,
      @ApplicationFrame
      Component dialogParent
  ) {
    this.appState = requireNonNull(appState, "appState");
    this.portalProvider = requireNonNull(portalProvider, "portalProvider");
    this.dialogParent = requireNonNull(dialogParent, "dialogParent");

    putValue(NAME, BUNDLE.getString("aboutAction.name"));
    putValue(MNEMONIC_KEY, Integer.valueOf('A'));

    ImageIcon icon = ImageDirectory.getImageIcon("/menu/help-contents.png");
    putValue(SMALL_ICON, icon);
    putValue(LARGE_ICON_KEY, icon);
  }

  @Override
  public void actionPerformed(ActionEvent evt) {
    JOptionPane.showMessageDialog(
        dialogParent,
        "

" + OpenTCSView.NAME + "
" + BUNDLE.getFormatted( "aboutAction.optionPane_applicationInformation.message.baselineVersion", Environment.getBaselineVersion() ) + "
" + BUNDLE.getFormatted( "aboutAction.optionPane_applicationInformation.message.customization", Environment.getCustomizationName(), Environment.getCustomizationVersion() ) + "
" + BUNDLE.getString("aboutAction.optionPane_applicationInformation.message.copyright") + "
" + BUNDLE.getString("aboutAction.optionPane_applicationInformation.message.runningOn") + "
" + "Java: " + System.getProperty("java.version") + ", " + System.getProperty("java.vendor") + "
" + "JVM: " + System.getProperty("java.vm.version") + ", " + System.getProperty("java.vm.vendor") + "
" + "OS: " + System.getProperty("os.name") + " " + System.getProperty("os.version") + ", " + System.getProperty("os.arch") + "
" + "Kernel
" + portalProvider.getPortalDescription() + "
" + BUNDLE.getFormatted( "aboutAction.optionPane_applicationInformation.message.mode", appState.getOperationMode() ) + "

", BUNDLE.getString("aboutAction.optionPane_applicationInformation.title"), JOptionPane.PLAIN_MESSAGE, new ImageIcon( getClass().getResource("/org/opentcs/guing/res/symbols/openTCS/openTCS.300x132.gif") ) ); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy