wolfgangimig / joa

Java Library for Developing Microsoft Outlook Add-ins
MIT License
12 stars 12 forks source link

great project - having tutorial problem #13

Open scottccote opened 4 years ago

scottccote commented 4 years ago

Very great documentation - up to the last step.

Am at the point where I'm in your tutorial "Develop a Custom Task Pane"

Clicking on the "Smile" button works ... a note pops up with your comment :D very nice.

But

Clicking on the "Show/Hide" button is causing my outlook to freeze up. It does not unfreeze until I "kill" the java (press the red button in the eclipse run/debug).

I am using outlook 360

FYI - In outlook, if I click on Outlook Options, choose "Customize Ribbon", then view "Customize the Classic ribbon", I can see "JOA Tutorial with group called "Happy Group" and buttons "Smile" and "Show/Hide"

Is there some permission that I need to make in Outlook for the panel to be able to show? What kind of diagnostic material can I give you to help me help you help me :D

I'll continue to debug while I wait for your response. If I find a solution on my own - I'll post here too.

wolfgangimig commented 4 years ago

If something hangs in the UI it is most likely caused by an event from Outlook that in turn calls Outlook API functions. To solve such situations, it mostly helps to call Outlook API in a background thread. For the particular sample code this recursive call happens in the callback handler of createTaskPaneWindowAsync. This function calls taskPane.setVisible which invokes an Outlook API synchronously. Fix:

public void onJoaTaskPaneClicked(Dispatch control, Boolean pressed) {
    BackgTask.run(() -> {
        if (taskPane.hasWindow()) {
            taskPane.setVisible(pressed);
        } else {
            Object parentWindow = getApplication().ActiveExplorer();
            createTaskPaneWindowAsync(taskPane, "JOA TaskPane", parentWindow, (succ, ex) -> {
                if (ex == null) {
                      // call setVisible in background to avoid hanging
                    BackgTask.run(() -> taskPane.setVisible(true));
                }
                if (ex != null) {
                    ex.printStackTrace();
                }
            });
        }
    });
}
scottccote commented 4 years ago

I'll try it out ... am going now in parallel with the node js approach to adding plugins - my manager is nervous about asking customers to install java to run the plugin. just did the tutorial that gets the gists .... Separate Question: is it possible to add commands to the context menu of outlook email messages? Use your mouse to select an message from the "in box", right click, and have a outlook add-in command/extension point "fire" Looks like that capability doesn't exist anymore .

wolfgangimig commented 4 years ago

asking customers to install java

Your add-in would install your private java version which is included in the setup. The steps to create a MSI setup can be found here: https://github.com/wolfgangimig/joa/wiki/How-To:-Create-a-Windows-Installer-MSI-File However, newer Oracle JDK 8 versions lost that feature and led to errors in the build process. So I create my Setups with Visual Studio and Visual Studio Setup Addin and include the entire JDK. If your add-in is quite small, it might be more efficient to use the web add-in technology instead of JOA.

context menu

You have to extend the ribbon.xml definition as described here: https://docs.microsoft.com/de-de/visualstudio/vsto/how-to-add-commands-to-shortcut-menus?view=vs-2019 Add a button onAction as shown here: https://github.com/wolfgangimig/joa/wiki/Tutorial#define-a-ribbon-tab