Package net.alteiar.campaign.player.gui.centerViews.explorer.actions.files

Source Code of net.alteiar.campaign.player.gui.centerViews.explorer.actions.files.ViewDocumentAction

package net.alteiar.campaign.player.gui.centerViews.explorer.actions.files;

import java.awt.Dimension;
import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.JDialog;

import net.alteiar.campaign.CampaignClient;
import net.alteiar.campaign.player.gui.MainFrame;
import net.alteiar.campaign.player.gui.documents.PanelViewDocument;
import net.alteiar.campaign.player.plugin.PluginSystem;
import net.alteiar.documents.BeanDocument;

public class ViewDocumentAction extends AbstractAction {
  private static final long serialVersionUID = 1L;

  private final BeanDocument file;

  public ViewDocumentAction(BeanDocument file) {
    this.file = file;

    putValue(NAME, "Voir document");
    // putValue(LARGE_ICON_KEY, Helpers.getIcon(ICON_SHOW_GRID));

    if (file.isAllowedToSee(CampaignClient.getInstance().getCurrentPlayer())) {
      setEnabled(true);
    } else {
      setEnabled(false);
    }
  }

  @Override
  public void actionPerformed(ActionEvent e) {
    PanelViewDocument panelView = PluginSystem.getInstance().getViewPanel(
        file);

    if (panelView != null) {
      JDialog dlg = new JDialog(MainFrame.FRAME, file.getDocumentName(),
          false);
      dlg.add(panelView);
      dlg.setPreferredSize(new Dimension(800, 600));
      dlg.pack();
      dlg.setLocationRelativeTo(null);
      dlg.setVisible(true);
    }
  }

}
TOP

Related Classes of net.alteiar.campaign.player.gui.centerViews.explorer.actions.files.ViewDocumentAction

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.