示例#1
0
  @Override
  public void execute(ActionEvent e) {

    final BoardEditor editor = EditorUtils.getCurrentActiveEditor();

    if (editor.getSelectedItem() != null) {
      AppContext.getClipboard().copy(editor.getSelectedItem());
    }
    if (editor.getSelectedItems() != null && editor.getSelectedItems().size() > 0)
      AppContext.getClipboard().copyAll(editor.getSelectedItems());

    editor.updateEditCommands();
  }
public class ShowAboutDialogCommand extends AbstractCommand {

  private static final long serialVersionUID = 428365156605269679L;
  private static final ResourceService resources =
      AppContext.getContext().getBean(ResourceService.class);

  public ShowAboutDialogCommand() {
    putValue(Action.NAME, resources.getResourceByKey("ShowAboutDialogCommand.name"));
    putValue(Action.SMALL_ICON, resources.getIcon("icon.about"));
    putValue(
        Action.SHORT_DESCRIPTION, resources.getResourceByKey("ShowAboutDialogCommand.description"));
    putValue(
        Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_F1, InputEvent.CTRL_DOWN_MASK));
  }

  @Override
  public void execute(ActionEvent e) {

    final ApplicationContext ctx = AppContext.getContext();
    final ResourceService resources = ctx.getBean(ResourceService.class);
    final ApplicationWindow win = ctx.getBean(ApplicationWindow.class);

    ImageIcon icon = resources.getIcon("icon.dialog.about");

    String title = "About";
    String subTitle = "Who created this Application.";

    AboutDialog aboutDialog = new AboutDialog(title, subTitle, icon, win);
    aboutDialog.setVisible(true);
  }
}
  @Override
  public void execute(ActionEvent e) {

    ApplicationContext ctx = AppContext.getContext();
    final ApplicationWindow win = ctx.getBean(ApplicationWindow.class);
    final String title = resources.getResourceByKey("SetLayerColorCommand.dialog.subtitle");

    final LayerTableModel model =
        AppContext.getContext().getBean(ShowLayersCommand.class).getLayerPanel().getLayerModel();
    AlternatingLineTable layerTable =
        AppContext.getContext().getBean(ShowLayersCommand.class).getLayerPanel().getLayerTable();

    int index = layerTable.convertRowIndexToModel(layerTable.getSelectedRow());

    if (index >= 0) {
      layer = model.getLayer().get(index);
    }

    if (layer == null) {
      return;
    }

    final JColorChooser chooser = new JColorChooser();

    ActionListener okListener =
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            dialog.setVisible(false);
            layer.setColor(chooser.getColor());
            model.fireTableDataChanged();
            EditorUtils.getCurrentActiveEditor().setFileState(FileState.DIRTY);
          }
        };

    ActionListener cancelListener =
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            dialog.setVisible(false);
          }
        };

    dialog = JColorChooser.createDialog(win, title, true, chooser, okListener, cancelListener);
    dialog.setVisible(true);
  }
  @Override
  public void execute(ActionEvent e) {

    final ApplicationContext ctx = AppContext.getContext();
    final ResourceService resources = ctx.getBean(ResourceService.class);
    final ApplicationWindow win = ctx.getBean(ApplicationWindow.class);

    ImageIcon icon = resources.getIcon("icon.dialog.about");

    String title = "About";
    String subTitle = "Who created this Application.";

    AboutDialog aboutDialog = new AboutDialog(title, subTitle, icon, win);
    aboutDialog.setVisible(true);
  }
 @Override
 public void execute(ActionEvent e) {
   AppContext.getContext().getBean(DatasheetDialog.class).setVisible(true);
 }
  @Override
  protected void initializeComponents() {

    final Dimension size = new Dimension(800, 500);
    setSize(size);
    setBounds(new Rectangle(size));

    panels = new HashMap<String, JPanel>();
    resources = AppContext.getContext().getBean(ResourceService.class);

    preferencesPanel = new PreferencesPanel();
    model =
        new ModuleTreeModel(
            new DefaultMutableTreeNode(resources.getResourceByKey("perspectives.text")));
    preferencesPanel.getModuleTree().setModel(model);
    preferencesPanel.getModuleTree().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    UIUtils.flattenSplitPane(preferencesPanel.getSplitPane());
    preferencesPanel.getModuleTree().setCellRenderer(new ModuleTreeRenderer());
    preferencesPanel
        .getModuleTree()
        .addTreeSelectionListener(
            new TreeSelectionListener() {

              @Override
              public void valueChanged(TreeSelectionEvent e) {

                DefaultMutableTreeNode node =
                    (DefaultMutableTreeNode) e.getPath().getLastPathComponent();
                Object o = node.getUserObject();

                if (o instanceof String) {

                  String moduleClassName = (String) o;
                  preferencesPanel.getSplitPane().setDividerLocation(0.3);
                  preferencesPanel
                      .getSplitPane()
                      .setRightComponent(new JScrollPane(panels.get(moduleClassName)));
                }
              }
            });

    getContentPanel().add(preferencesPanel, BorderLayout.CENTER);

    ApplicationPerspectiveProvider perspectiveProvider =
        ctx.getBean(ApplicationPerspectiveProvider.class);
    ArrayList<ApplicationPerspective> perspectives = perspectiveProvider.getPerspectives();

    for (ApplicationPerspective a : perspectives) {
      model.addModule(
          (DefaultMutableTreeNode) preferencesPanel.getModuleTree().getModel().getRoot(),
          a.getPerspectiveClass());
      panels.put(
          a.getPerspectiveClass(), createParamPanel(a.getPerspectiveClass(), Preferences.values));
    }

    getOkButton()
        .addActionListener(
            new ActionListener() {

              @Override
              public void actionPerformed(ActionEvent e) {
                syncPreferences();
                result = OPTION_OK;
                setVisible(false);
                Preferences.store();

                for (BoardEditor ed :
                    EditorUtils.getCurrentPerspectiveOpenEditors(
                        AppContext.getContext()
                            .getBean(ApplicationWindowAdvisor.class)
                            .getCurrentPerspective())) ed.updateStatusBar();
              }
            });

    getCancelButton()
        .addActionListener(
            new ActionListener() {

              @Override
              public void actionPerformed(ActionEvent e) {
                result = OPTION_CANCEL;
                setVisible(false);
              }
            });

    setLocationRelativeTo(getRootPane());

    // preferencesPanel.getSplitPane().setRightComponent(new
    // JScrollPane(panels.get("org.pmedv.blackboard.BoardDesignerPerspective")));

  }