// Path: src/com/github/kennedyoliveira/ultimatepastebin/service/ToolWindowService.java
// public interface ToolWindowService {
// 
//   /**
//    * @return The tree with the pastes and user information
//    */
//   Tree getTree();
// 
//   /**
//    * Initiate the actions for fetching user and trending pastes and update the toolwindow with results
//    */
//   void fetchPastes();
// 
//   /**
//    * Initiate the action for fetching user pastes and update the toolwindow with results
//    */
//   void fetchUserPastes();
// 
//   /**
//    * Initiate the action for fetching trend pastes and update the toolwindow with results
//    */
//   void fetchTrendPastes();
// 
//   /**
//    * @return A selected paste in the {@link #getTree()}
//    */
//   Optional<Paste> getSelectedPaste();
// 
//   /**
//    * Checks of the {@code paste} is a Trend paste.
//    *
//    * @param paste Paste to be checked.
//    * @return {@code true} if trend, {@code false} otherwise.
//    */
//   boolean isTrendPast(Paste paste);
// }
// 
// Path: src/com/github/kennedyoliveira/ultimatepastebin/utils/UltimatePasteBinUtils.java
// public class UltimatePasteBinUtils {
// 
//   /**
//    * General Logger for UltimatePasteBin
//    */
//   public static final Logger logger = Logger.getInstance("com.github.kennedyoliveira.ultimatepastebin");
// 
//   private UltimatePasteBinUtils() {}
// 
//   /**
//    * <p>Shows a simple message info message box.</p>
//    * <p>Sometimes in OS X the default message box {@link Messages#showIdeaMessageDialog(Project, String, String, String[], int, Icon, com.intellij.openapi.ui.DialogWrapper.DoNotAskOption)} do not work,
//    * so if you are on OS X this method use {@link Messages#showInfoMessage(Component, String, String)} that works.</p>
//    *
//    * @param project The project
//    * @param title   Title of the message box.
//    * @param message Message of the message box.
//    */
//   public static void showInfoMessageBox(@Nullable Project project, String title, String message) {
//     // When on MacOsX for some reason intellij randomly shows or not the MessageBOX, so i'm showing with different messages that works everytime
//     UIUtil.invokeLaterIfNeeded(() -> {
//       if (SystemInfo.isMac) {
//         Messages.showIdeaMessageDialog(project, message, title, new String[]{"OK"}, 0, null, null);
//       } else {
//         Messages.showInfoMessage(project, message, title);
//       }
//     });
//   }
// 
//   /**
//    * This method exists for the same reason as {@link #showInfoMessageBox(Project, String, String)}
//    *
//    * @param project The project
//    * @param title   Title of the message box.
//    * @param message Message of the message box.
//    */
//   public static void showErrorMessageBox(@Nullable Project project, String message, @Nls(capitalization = Nls.Capitalization.Title) String title) {
//     UIUtil.invokeLaterIfNeeded(() -> {
//       if (SystemInfo.isMac) {
//         Messages.showIdeaMessageDialog(project, message, title, new String[]{"OK"}, 0, null, null);
//       } else {
//         Messages.showErrorDialog(message, title);
//       }
//     });
//   }
// 
//   /**
//    * Try to get a {@link PasteHighLight} from the default file extension for the {@link VirtualFile}, if not found try the current extension of the selected paste.
//    *
//    * @param file File to extract the {@link PasteHighLight}
//    * @return An {@link Optional} that can have the {@link PasteHighLight}
//    */
//   public static Optional<PasteHighLight> getHighlighFromVirtualFile(@Nullable VirtualFile file) {
//     if (file == null)
//       return Optional.empty();
// 
//     final String defaultFileExtension = file.getFileType().getDefaultExtension();
// 
//     final Optional<PasteHighLight> byDefaultExtension = getHighlighByFileExtension(defaultFileExtension);
// 
//     if (byDefaultExtension.isPresent())
//       return byDefaultExtension;
// 
//     final String extension = file.getExtension();
//     return getHighlighByFileExtension(extension);
//   }
// 
//   /**
//    * Get the content of the {@code virtualFile}, if there is any error, just return an {@link Optional#empty()}.
//    *
//    * @param virtualFile The virtual file to get the content
//    * @return An {@link Optional} that can have the content of the file, or empty if there was any error.
//    */
//   public static Optional<String> getFileContent(VirtualFile virtualFile) {
//     if (virtualFile == null)
//       return Optional.empty();
// 
//     try {
//       return Optional.of(new String(virtualFile.contentsToByteArray(), virtualFile.getCharset()));
//     } catch (IOException e) {
//       logger.error("Error while fetching the contents of a virtual file [" + virtualFile.getName() + "]", e);
//       return Optional.empty();
//     }
//   }
// }
// 
// Path: src/com/github/kennedyoliveira/ultimatepastebin/i18n/MessageBundle.java
// @Nullable
// public static String getMessage(String key, Object... params) {
//   return CommonBundle.message(getBundle(), key, params);
// }


import com.github.kennedyoliveira.ultimatepastebin.service.ToolWindowService;
import com.github.kennedyoliveira.ultimatepastebin.utils.UltimatePasteBinUtils;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.diagnostic.Logger;
import static com.github.kennedyoliveira.ultimatepastebin.i18n.MessageBundle.getMessage;
package com.github.kennedyoliveira.ultimatepastebin.action;



/**
 * Action the fetch all the pastes and updates the UI
 */
public class RefreshPastesAction extends AnAction {

  private static final Logger logger = UltimatePasteBinUtils.logger;

  @Override
  public void actionPerformed(AnActionEvent e) {
    logger.info("Refreshing pastes from RefreshPasteAction");
// Path: src/com/github/kennedyoliveira/ultimatepastebin/service/ToolWindowService.java
// public interface ToolWindowService {
// 
//   /**
//    * @return The tree with the pastes and user information
//    */
//   Tree getTree();
// 
//   /**
//    * Initiate the actions for fetching user and trending pastes and update the toolwindow with results
//    */
//   void fetchPastes();
// 
//   /**
//    * Initiate the action for fetching user pastes and update the toolwindow with results
//    */
//   void fetchUserPastes();
// 
//   /**
//    * Initiate the action for fetching trend pastes and update the toolwindow with results
//    */
//   void fetchTrendPastes();
// 
//   /**
//    * @return A selected paste in the {@link #getTree()}
//    */
//   Optional<Paste> getSelectedPaste();
// 
//   /**
//    * Checks of the {@code paste} is a Trend paste.
//    *
//    * @param paste Paste to be checked.
//    * @return {@code true} if trend, {@code false} otherwise.
//    */
//   boolean isTrendPast(Paste paste);
// }
// 
// Path: src/com/github/kennedyoliveira/ultimatepastebin/utils/UltimatePasteBinUtils.java
// public class UltimatePasteBinUtils {
// 
//   /**
//    * General Logger for UltimatePasteBin
//    */
//   public static final Logger logger = Logger.getInstance("com.github.kennedyoliveira.ultimatepastebin");
// 
//   private UltimatePasteBinUtils() {}
// 
//   /**
//    * <p>Shows a simple message info message box.</p>
//    * <p>Sometimes in OS X the default message box {@link Messages#showIdeaMessageDialog(Project, String, String, String[], int, Icon, com.intellij.openapi.ui.DialogWrapper.DoNotAskOption)} do not work,
//    * so if you are on OS X this method use {@link Messages#showInfoMessage(Component, String, String)} that works.</p>
//    *
//    * @param project The project
//    * @param title   Title of the message box.
//    * @param message Message of the message box.
//    */
//   public static void showInfoMessageBox(@Nullable Project project, String title, String message) {
//     // When on MacOsX for some reason intellij randomly shows or not the MessageBOX, so i'm showing with different messages that works everytime
//     UIUtil.invokeLaterIfNeeded(() -> {
//       if (SystemInfo.isMac) {
//         Messages.showIdeaMessageDialog(project, message, title, new String[]{"OK"}, 0, null, null);
//       } else {
//         Messages.showInfoMessage(project, message, title);
//       }
//     });
//   }
// 
//   /**
//    * This method exists for the same reason as {@link #showInfoMessageBox(Project, String, String)}
//    *
//    * @param project The project
//    * @param title   Title of the message box.
//    * @param message Message of the message box.
//    */
//   public static void showErrorMessageBox(@Nullable Project project, String message, @Nls(capitalization = Nls.Capitalization.Title) String title) {
//     UIUtil.invokeLaterIfNeeded(() -> {
//       if (SystemInfo.isMac) {
//         Messages.showIdeaMessageDialog(project, message, title, new String[]{"OK"}, 0, null, null);
//       } else {
//         Messages.showErrorDialog(message, title);
//       }
//     });
//   }
// 
//   /**
//    * Try to get a {@link PasteHighLight} from the default file extension for the {@link VirtualFile}, if not found try the current extension of the selected paste.
//    *
//    * @param file File to extract the {@link PasteHighLight}
//    * @return An {@link Optional} that can have the {@link PasteHighLight}
//    */
//   public static Optional<PasteHighLight> getHighlighFromVirtualFile(@Nullable VirtualFile file) {
//     if (file == null)
//       return Optional.empty();
// 
//     final String defaultFileExtension = file.getFileType().getDefaultExtension();
// 
//     final Optional<PasteHighLight> byDefaultExtension = getHighlighByFileExtension(defaultFileExtension);
// 
//     if (byDefaultExtension.isPresent())
//       return byDefaultExtension;
// 
//     final String extension = file.getExtension();
//     return getHighlighByFileExtension(extension);
//   }
// 
//   /**
//    * Get the content of the {@code virtualFile}, if there is any error, just return an {@link Optional#empty()}.
//    *
//    * @param virtualFile The virtual file to get the content
//    * @return An {@link Optional} that can have the content of the file, or empty if there was any error.
//    */
//   public static Optional<String> getFileContent(VirtualFile virtualFile) {
//     if (virtualFile == null)
//       return Optional.empty();
// 
//     try {
//       return Optional.of(new String(virtualFile.contentsToByteArray(), virtualFile.getCharset()));
//     } catch (IOException e) {
//       logger.error("Error while fetching the contents of a virtual file [" + virtualFile.getName() + "]", e);
//       return Optional.empty();
//     }
//   }
// }
// 
// Path: src/com/github/kennedyoliveira/ultimatepastebin/i18n/MessageBundle.java
// @Nullable
// public static String getMessage(String key, Object... params) {
//   return CommonBundle.message(getBundle(), key, params);
// }


// Path: src/com/github/kennedyoliveira/ultimatepastebin/action/RefreshPastesAction.java
import com.github.kennedyoliveira.ultimatepastebin.service.ToolWindowService;
import com.github.kennedyoliveira.ultimatepastebin.utils.UltimatePasteBinUtils;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.diagnostic.Logger;
import static com.github.kennedyoliveira.ultimatepastebin.i18n.MessageBundle.getMessage;

package com.github.kennedyoliveira.ultimatepastebin.action;



/**
 * Action the fetch all the pastes and updates the UI
 */
public class RefreshPastesAction extends AnAction {

  private static final Logger logger = UltimatePasteBinUtils.logger;

  @Override
  public void actionPerformed(AnActionEvent e) {
    logger.info("Refreshing pastes from RefreshPasteAction");
    final ToolWindowService service = ServiceManager.getService(ToolWindowService.class);