Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Overview

Keith Chong edited this page Jun 2, 2020 · 29 revisions

A technical overview of the Codewind IntelliJ IDE Plug-ins

Gradle project

  • UI and Core in one gradle project, but two source folders
    • org.eclipse.codewind.intellij
      • dev/src/main/java/org.eclipse.codewind.intellij/core
      • dev/src/main/java/org.eclipse.codewind.intellij/ui
      • exception to the norm - dev/src/main/java/org.eclipse.codewind.intellij/core/launch has a bit of UI in it
  • Filewatcher plug-in dependency:
    • As a runtime library dependency in the lib folder: dev/src/main/java/org.eclipse.codewind.intellij/lib
    • See dev/build.gradle to see how the file watcher jars get copied over
  • Like Eclipse, there is a plugin.xml where you can add extensions and dependencies.
  • Tests:
    • No tests yet

IntelliJ versus Eclipse versus VS Code

  • IntelliJ resembles more of Eclipse
  • Similar concepts but implementation is different
    • Wizards (Each page is a Step versus a WizardPage)
      • New Project Wizard
    • Dialogs
    • Views ( ToolWindows versus Views)
    • Properties ( Implement a ToolWindow versus Eclipse Properties View
    • Debug (Launch configurations similar)
    • Preference Pages
  • Differences
    • Main fundamental difference is that only one project can be opened in one window (although some implementations do support it, but not in the community edition). Eclipse shows multiple projects.
  • Swing versus SWT

Core classes

The following classes are based on the classes from the Codewind for Eclipse plugin.

Interaction with Codewind

  • These classes interact with Codewind:
    • CodewindConnection: This class calls the REST APIs. This class is shrinking as more cwctl calls are used instead.
    • CodewindSocket: This class receives events from Codewind.
    • Various CLI utility classes, including CLIUtil, InstallUtil, ConnectionUtil, ProjectUtil, and more, invoke the cwctl commands.

Codewind objects

  • CodewindManager It keeps track of the installation status of local Codewind.
  • ConnectionManager keeps track of all of the connections to Codewind instances. It also takes care of restoring connections when IntelliJ starts up. (Note in Eclipse, the class is CodewindConnectionManager)
  • CodewindConnection represents a connection to a Codewind instance. It keeps track of the applications associated with the connection. It also makes REST API calls.
  • LocalConnection represents a local connection.
  • RemoteConnection represents a remote connection and handles authorization.
  • CodewindApplication represents a project in Codewind.
  • CodewindIntellijApplication contains IntelliJ specific function, such as launching a debug session.
  • RemoteIntellijApplication contains IntelliJ specific function that is modified as needed for remote applications. (TBD for Issue 2821 - Remote Debug Support)

Codewind Tool Window

The main component of the UI is the Codewind tool window or view

  • This view displays the connections and projects along with their current status.
  • All of the actions are available from this view for the root (create a new connection, etc.), the connections (create project, manage template sources, etc.), and the projects (open the monitors, build, etc.).
  • See the CodewindToolWindow, CodewindTreeNodeCellRenderer, and CodewindTreeModel classes.

View context actions

  • All AnAction actions are added to the view dynamically via a mouse listener on the Tree. See CodewindToolWindow.
  • Actions can be greyed out by implementing the update method in the AnAction
  • If an action is supported for a particular object, but it is not currently available, it is greyed out and disabled. For example, the Attach Debugger action is disabled if a debugger is already attached.
  • Important: Because the actions are added dynamically, the decision to add an action or not must be fast. A REST API cannot be called to add an action.
  • Our custom Abstract classes to extend
    • AbstractApplicationAction - base class for any action whose context is an application
    • AbstractProjectDependentAction - an application-based action that when run, requires the project to be opened in a new window

Other actions

These actions are supported outside of the Codewind view:

  • A new Codewind project can be created using File>New>Codewind Project. A connection page still needs to be added to the beginning of the wizard if more than one connection is available to choose from. See Issue 2904

Welcome page

  • There is no welcome page at this time.
  • However, when a project is created in Codewind, if there is a readme.md file, IntelliJ will open it automatically.

Project Overview Tool Window View

  • The Codewind view has limited space. The Project Overview page is provided so users can see all of the relevant information about your project.
  • This page is NOT opened automatically when a project is created or added, unlike for Eclipse and VS Code.
  • There is also an action on the project to open the Project Overview.
  • It was decided not to provide actions in multiple places so users can't make changes to a project from the overview page, only from the Codewind view using the menus.
  • Project Overview pages are closed automatically when a project is removed from Codewind.
  • The overview page is implemented as a Tool Window and a Form, AppOverviewFrame. See also the task OpenAppOverviewTask which launches the view.

Updating the UI

  • When changes are received through socket events from Codewind, the UI is updated by calling the UpdateHandler and passing in the changed item, such as root, connection, or project. If the changed item is known, it is best to pass it in otherwise everything will get updated. This UpdateHandler mirrors the version from Codewind for Eclipse.
  • Listeners can be added to the UpdateHandler for anything else that needs to be notified of updates (project overview pages).
  • All elements in the Codewind view have a Refresh action that users can use if anything gets out of sync.

Project Logs - Log Files Tool Window

  • The user can display all of the logs for a project. Currently you cannot select individual logs to display. It is Show All or Hide All.
  • All logs appear in the Log Files tool window/view, where the user can switch between them using the combo box menus
  • There is a button toolbar where you can wrap the text, scroll to the bottom, print the file, clear the view, select help, and close the view
  • The main class is SocketConsole. SocketConsole has an update method that is called when a log update event is received on the socket.
  • When the Log File view is opened but the log file is not selected (or in view), and if the log file contents changed, then the user will get a notification message. See LogsViewNotifier
  • Consoles for a project are removed automatically if the project is removed from Codewind.
  • IntelliJ's ToolWindowManager gives you a list of opened logs for a project so it helps in managing the views.

Debugging

Java

  • The built-in IntelliJ Java debug support is used for Java projects.
  • See package: dev/src/main/java/org.eclipse.codewind.intellij/core/launch
    • Only one class CoreUiUtil with two methods
      • debug - launch the debug session - via Attach Debugger action, or auto-attach via restarting in debug mode
      • clearRunConfig - clear the configuration (eg. when the project is deleted)
    • IntelliJ RunManager
  • See package dev/src/main/java/org.eclipse.codewind.intellij/ui/debug
    • CodewindConfigurationType - Our specific configuration type. Shows up as a separate node in the run/debug launch configuration view
    • CodewindDebugConfiguration - debug configuration. Resembles Eclipse's debug configuration. Has an associated editor so that you can modify the debug port number
    • CodewindDebugSettingsEditor - the editor panel that you see when you select Run->Edit Configurations... and select the Codewind Debug instance. Instead of creating our own customized widgets, we extend the built-in editor, but we hide the widgets that allow users to change the JVM (which doesn't apply to Codewind)
  • Do not have both Codewind for Eclipse and IntelliJ IDEs up. Eclipse attaches to the debug process. IntelliJ debug attach will fail.

Node.js

  • N/A for now

Remote

Preferences

  • Currently no dedicated preference page (single tree node) available for Codewind.
    • Therefore, there are no timeouts for installing, uninstalling, starting, and stopping local Codewind.
  • Currently no dedicated preference for enabling and disabling the support features (like in Eclipse).
  • However, there is a contribution to the Appearance & Behavior->Notifications preference page to turn off Log File change update notifications. (The popup notification over the Log Files tab can be annoying).

Other UI components

  • No Drag and drop a project from one connection to another at this time
  • Double-click actions on elements in the Explorer view to install or start local Codewind, connect a disconnected remote connection, or open an application in the browser.

Dialogs and wizards

  • Dialogs and wizards are included for managing template sources, managing image registries, and more.
    • Note any new 'simple' dialogs (not wizard dialogs) that require the basic OK and Cancel buttons, and a help button should extend AbstractCodewindDialogWrapper. See Issue 2996 for more details.
    • New Project wizard - see package dev/src/main/java/org.eclipse.codewind.intellij/ui/module
    • Other wizards (AddExistingProjectWizard, ManageImageRegistryWizard, etc. - see package dev/src/main/java/org.eclipse.codewind.intellij/ui/wizard
  • No context sensitive help (like Eclipse) at this time
  • Tooltips should be added
  • Reminder: For all IntelliJ dialogs and wizards, do not make any changes until the user finishes the dialog or wizard.

Development

  • To set up development environment, see README.md
  • Use IntelliJ logging support. See dev/src/main/java/org.eclipse.codewind.intellij/core/Logger.java
  • For location of IntelliJ logs, on Mac, go to Help->Show Log in Finder. Similar action on Windows (Explorer).

Accessibility