Interface WorkspaceUtilities

All Superinterfaces:
ApplicationInformationAccess, ColorThemeUtilities
All Known Subinterfaces:
AuthorWorkspaceAccess, EclipsePluginWorkspace, PluginWorkspace, StandalonePluginWorkspace, WebappPluginWorkspace, Workspace

@API(type=NOT_EXTENDABLE, src=PUBLIC) public interface WorkspaceUtilities extends ColorThemeUtilities, ApplicationInformationAccess
Provides access to global utility methods.
Since:
15
  • Method Details

    • getParentFrame

      Object getParentFrame()
      Get the parent main frame.
      Returns:
      The parent frame ({javax.swing.JFrame or java.awt.Frame (when running as a JApplet)}) of the Oxygen application or the parent shell ({org.eclipse.swt.widgets.Shell}) if this is the Eclipse implementation.
    • chooseFile

      File chooseFile(String title, String[] allowedExtensions, String filterDescr, boolean openForSave)
      Displays a file chooser for selecting a File.
      Parameters:
      title - The file chooser title.
      allowedExtensions - Allowed file extensions. Can be null if you want all files filter. Example: new String[] {"xml", "dita"}.
      filterDescr - Description for the file filter.
      openForSave - true when the file chooser is used for saving, false if it is used for opening an existing file.
      Returns:
      The chosen file or null if the user canceled the dialog.
    • chooseFile

      File chooseFile(File currentFileContext, String title, String[] allowedExtensions, String filterDescr, boolean usedForSave)
      Displays a file chooser for selecting a File.
      Parameters:
      currentFileContext - The file which will be selected in the file chooser. If it is a directory, it will be used as a default directory. If it is a file (even non-existing) and the file chooser is shown for a save operation its name will also be selected in the chooser. Can be set null in order to use the default behavior.
      title - The file chooser title.
      allowedExtensions - Allowed file extensions. Can be null if you want all files filter. Example: new String[] {"xml", "dita"}.
      filterDescr - Description for the file filter.
      usedForSave - true when the file chooser is used for saving, false if it is used for opening an existing file.
      Returns:
      The chosen file or null if the user canceled the dialog.
      Since:
      14
    • chooseFile

      File chooseFile(String title, String[] allowedExtensions, String filterDescr)
      Displays a file chooser for selecting a File.
      Parameters:
      title - The file chooser title.
      allowedExtensions - Allowed file extensions. Can be null if you want all files filter. Example: new String[] {"xml", "dita"}.
      filterDescr - Description for the file filter.
      Returns:
      The chosen file or null if the user canceled the dialog.
    • chooseFiles

      File[] chooseFiles(File currentFileContext, String title, String[] allowedExtensions, String filterDescr)
      Displays a file chooser for selecting multiple Files.
      Parameters:
      currentFileContext - The file which will be selected in the file chooser. If it is a directory, it will be used as a default directory. If it is a file (even non-existing) and the file chooser is shown for a save operation its name will also be selected in the chooser. Can be set null in order to use the default behavior.
      title - The file chooser title.
      allowedExtensions - Allowed file extensions. Can be null if you want all files filter. Example: new String[] {"xml", "dita"}.
      filterDescr - Description for the file filter.
      Returns:
      The chosen files or null if the user canceled the dialog.
      Since:
      15.2
    • chooseDirectory

      File chooseDirectory()
      Displays a directory chooser for selecting a directory.
      Returns:
      The chosen directory or null if the user canceled the dialog.
      Since:
      15
    • chooseDirectory

      File chooseDirectory(File startingDir)
      Displays a directory chooser. Available for the stand-alone oXygen and the Eclipse plugin.
      Parameters:
      startingDir - The starting directory. May be null.
      Returns:
      The chosen directory or null if the user canceled the dialog.
      Since:
      21.1
    • chooseURL

      URL chooseURL(String title, String[] allowedExtensions, String filterDescr)
      Displays an URL chooser for selecting an URL.
      Parameters:
      title - The chooser dialog title.
      allowedExtensions - Allowed extensions.
      filterDescr - Description for the filter.
      Returns:
      The chosen URL or null if the user canceled the dialog.
    • chooseURL

      URL chooseURL(String title, String[] allowedExtensions, String filterDescr, String initialURL)
      Displays an URL chooser for selecting an URL.
      Parameters:
      title - The chooser dialog title.
      allowedExtensions - Allowed extensions.
      filterDescr - Description for the filter.
      initialURL - Default value for the URL (given as string). Can be null.
      Returns:
      The chosen URL or null if the user canceled the dialog.
      Since:
      14.2
    • chooseURL

      URL chooseURL(String title, String[] allowedExtensions, String filterDescr, String initialURL, String urlLabel, String okLabel)
      Displays an URL chooser for selecting an URL.
      Parameters:
      title - The chooser dialog title.
      allowedExtensions - Allowed extensions.
      filterDescr - Description for the filter.
      initialURL - Default value for the URL (given as string). Can be null.
      urlLabel - The label used for describing the URL field. If null, the value will be: "URL:".
      okLabel - The label of the "OK" button. If null the value will be "OK".
      Returns:
      The chosen URL or null if the user canceled the dialog.
      Since:
      25.0
    • chooseURLPath

      String chooseURLPath(String title, String[] allowedExtensions, String filterDescr)
      Displays an URL chooser for selecting an URL. If the user sets a relative path in the chooser, that path will be returned.
      Parameters:
      title - The chooser dialog title.
      allowedExtensions - Allowed extensions.
      filterDescr - Description for the filter.
      Returns:
      The chosen URL as String or null if the user canceled the dialog.
      Since:
      14
    • chooseURLPath

      String chooseURLPath(String title, String[] allowedExtensions, String filterDescr, String initialURL)
      Displays an URL chooser for selecting an URL. If the user sets a relative path in the chooser, that path will be returned.
      Parameters:
      title - The chooser dialog title.
      allowedExtensions - Allowed extensions.
      filterDescr - Description for the filter.
      initialURL - The initial URL to set in the field.
      Returns:
      The chosen URL as String or null if the user canceled the dialog.
      Since:
      16.1
    • showWarningDialog

      int showWarningDialog(String title, String message, String[] buttonNames, int[] buttonIds)
      Shows a warning message dialog.
      Parameters:
      title - The dialog title.
      message - The message to be presented to the user.
      buttonNames - The names of the buttons representing the choices in the dialog.
      buttonIds - The id for each button. Used to identify which button was pressed. All Ids must be greater or equal to 0.
      Returns:
      the id of the pressed button or -1 if the dialog was closed by other means.
      Since:
      26.0
    • showWarningDialog

      int showWarningDialog(String title, String message, String[] buttonNames, int[] buttonIds, int initialSelectedIndex)
      Shows a warning message dialog.
      Parameters:
      title - The dialog title.
      message - The message to be presented to the user.
      buttonNames - The names of the buttons representing the choices in the dialog.
      buttonIds - The id for each button. Used to identify which button was pressed.
      initialSelectedIndex - The index of the initial selected button. 0 based. All Ids must be greater or equal to 0.
      Returns:
      the id of the pressed button or -1 if the dialog was closed by other means.
      Since:
      26.0
    • showConfirmDialog

      int showConfirmDialog(String title, String message, String[] buttonNames, int[] buttonIds)
      Shows a question message dialog.
      Parameters:
      title - The dialog title.
      message - The message to be presented to the user.
      buttonNames - The names of the buttons representing the choices in the dialog.
      buttonIds - The id for each button. Used to identify which button was pressed. All Ids must be greater or equal to 0.
      Returns:
      the id of the pressed button or -1 if the dialog was closed by other means.
    • showConfirmDialog

      int showConfirmDialog(String title, String message, String[] buttonNames, int[] buttonIds, int initialSelectedIndex)
      Shows a question message dialog.
      Parameters:
      title - The dialog title.
      message - The message to be presented to the user.
      buttonNames - The names of the buttons representing the choices in the dialog.
      buttonIds - The id for each button. Used to identify which button was pressed.
      initialSelectedIndex - The index of the initial selected button. 0 based. All Ids must be greater or equal to 0.
      Returns:
      the id of the pressed button or -1 if the dialog was closed by other means.
      Since:
      13.1
    • showErrorMessage

      void showErrorMessage(String message)
      Presents an error message dialog.
      Parameters:
      message - The error message.
    • showErrorMessage

      void showErrorMessage(String message, Throwable exception)
      Presents an error message dialog.
      Parameters:
      message - The error message.
      exception - An exception for which the stack trace will be shown when the "More details" link is clicked. In more recent application versions due to security related decisions the exception stack trace is no longer shown.
      Since:
      19.1
    • showWarningMessage

      void showWarningMessage(String message)
      Presents a warning message dialog.
      Parameters:
      message - The warning message.
      Since:
      17.1
    • showInformationMessage

      void showInformationMessage(String message)
      Presents an information message dialog.
      Parameters:
      message - The information message.
    • showStatusMessage

      void showStatusMessage(String statusMessage)
      Show a status message.
      Parameters:
      statusMessage - The status message
    • showStatusMessage

      void showStatusMessage(String statusMessage, OperationStatus status)
      Show a status message and set a corresponding status color.
      Parameters:
      statusMessage - The message.
      status - The status that gives the color.
      Since:
      20
    • openInExternalApplication

      void openInExternalApplication(URL url, boolean preferAssociatedApplication)
      Open in the associated system application
      Parameters:
      url - The URL to open.
      preferAssociatedApplication - If true will prefer the system associated application and if this fails, open in the browser if false will open in the browser.
      Since:
      12
    • openInExternalApplication

      void openInExternalApplication(URL url, boolean preferAssociatedApplication, String mediaType)
      Open in the associated system application
      Parameters:
      url - The URL to open.
      preferAssociatedApplication - If true will prefer the system associated application and if this fails, open in the browser if false will open in the browser.
      mediaType - The media type of the URL to open.
      Since:
      18.1
    • openInExternalApplication

      void openInExternalApplication(String url, boolean preferAssociatedApplication, String mediaType)
      Open in the associated system application.
      Parameters:
      url - The URL to open.
      preferAssociatedApplication - If true, it will prefer the system associated application and if this fails, it will open in the browser. If false the resource will be opened in the browser.
      mediaType - The media type of the URL to open.
      Since:
      19.1
    • createJavaProcess

      ProcessController createJavaProcess(String additionalJavaArguments, String[] classpath, String mainClass, String additionalArguments, Map<String,String> environmentalVariables, File startDirectory, ProcessListener processListener)
      Prepare a Java process for execution. It also sets on the Java process the Oxygen HTTP proxy configuration.
      Parameters:
      additionalJavaArguments - Additional Java arguments like "-Xmx256m"
      classpath - The classpath.
      mainClass - The main class
      additionalArguments - The additional process arguments
      environmentalVariables - Additional environmental variables. Can be null
      startDirectory - The directory where the process should start. Can be null
      processListener - The process listener. Can be null
      Returns:
      Access to the process.


      Sample usage:
      ProcessListener processListener = new ProcessListener() {
      public void newErrorLine(String line) {
      System.err.println("Error from process " + line);
      }
      public void processCouldNotStart(String message) {
      System.err.println("Could not start process " + message);
      }
      public void processEnded(int exitCode) {
      System.err.println("Process ended " + exitCode);
      }
      public void newOutputLine(String line) {
      System.out.println("Output from process: " + line);
      }
      };
      final ProcessController processController = standalonePluginWorkspace.createJavaProcess("-Xmx256m",
      new String[] {"lib/oxygen.jar", "classes"},
      //The main Oxygen class
      "ro.sync.exml.Oxygen",
      //The URL which Oxygen will attempt to load on startup
      "file:/D:/projects/eXml/samples/dita/flowers/topics/copyright.xml",
      //Environmental variables to set to the process, none in mu case
      null, new File("."), processListener);
      //You can start a new thread here and send messages to the process using the ProcessControler
      //Start the process, will block until process has finished
      processController.start();
      Since:
      12.1
    • startProcess

      void startProcess(String name, File workingDirectory, String cmdLine, boolean showConsole)
      Start a process that executes a given command line. If the process is already running, it will not be started again. Does not wait for the process to finish.
      Parameters:
      name - The name of the process.
      workingDirectory - The directory where the process is started.
      cmdLine - The command line to be executed. Can contain editor variables.
      showConsole - True to show the console.
      Since:
      18.1
    • createProcess

      ProcessController createProcess(ProcessListener processListener, String name, File workingDirectory, String cmdLine, boolean showConsole)
      Create a process that executes a given command line.
      Parameters:
      processListener - The process handler
      name - The name of the process.
      workingDirectory - The directory where the process is started.
      cmdLine - The command line to be executed. Can contain editor variables.
      showConsole - True to show the console.
      Returns:
      The process controller of the started process if process could be started, otherwise null if for example the process is already running.
      Since:
      23.1
    • clearImageCache

      @Deprecated void clearImageCache()
      Deprecated.
      Clear the cache of images used to display images fast in the Author page. You can use the ImageUtilities API to clear the image cache.
      Since:
      13
    • getDataSourceAccess

      ro.sync.exml.workspace.api.options.DataSourceAccess getDataSourceAccess()
      Get information about the configured data source connections.
      Returns:
      The DataSourceAccess capable of providing information about the data source connections.
      Since:
      14.1
    • getImageUtilities

      ImageUtilities getImageUtilities()
      Get access to image related utilities, support to register custom image handlers or to reset the images cache.
      Returns:
      access to image related utilities.
      Since:
      18
    • getTemplateManager

      TemplateManager getTemplateManager()
      Get access to all new file templates.
      Returns:
      access to all new file templates.
      Since:
      18