コード例 #1
0
  public GraphDesktopController(
      GraphDesktopListener listener,
      ISession session,
      GraphPlugin plugin,
      ModeManager modeManager,
      boolean showDndDesktopImageAtStartup) {
    _listener = listener;
    _session = session;
    _plugin = plugin;
    _graphPluginResources = new GraphPluginResources(_plugin);

    ImageIcon startUpImage = null;

    if (showDndDesktopImageAtStartup) {
      startUpImage = _graphPluginResources.getIcon(GraphPluginResources.IKeys.DND);
    }

    _desktopPane = new GraphDesktopPane(_session.getApplication(), startUpImage);
    _desktopPane.setBackground(Color.white);

    _modeManager = modeManager;

    DropTarget dt = new DropTarget();

    try {
      dt.addDropTargetListener(
          new DropTargetAdapter() {
            public void drop(DropTargetDropEvent dtde) {
              onTablesDroped(dtde);
            }
          });
    } catch (TooManyListenersException e) {
      throw new RuntimeException(e);
    }

    _desktopPane.setDropTarget(dt);

    _desktopPane.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            onMouseClicked(e);
          }

          public void mousePressed(MouseEvent e) {
            onMousePressed(e);
          }

          public void mouseReleased(MouseEvent e) {
            onMouseReleased(e);
          }
        });

    _desktopPane.addMouseMotionListener(
        new MouseMotionAdapter() {
          public void mouseDragged(MouseEvent e) {
            onMouseDragged(e);
          }
        });

    createPopUp();
  }
コード例 #2
0
  private void createPopUp() {
    _popUp = new JPopupMenu();

    // i18n[graph.saveGraph=Save graph]
    _mnuSaveGraph = new JMenuItem(s_stringMgr.getString("graph.saveGraph"));
    _mnuSaveGraph.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onSaveGraph();
          }
        });

    // i18n[graph.renameGraph=Rename graph]
    _mnuRenameGraph = new JMenuItem(s_stringMgr.getString("graph.renameGraph"));
    _mnuRenameGraph.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onRenameGraph();
          }
        });

    // i18n[graph.removeGraph=Remove graph]
    _mnuRemoveGraph = new JMenuItem(s_stringMgr.getString("graph.removeGraph"));
    _mnuRemoveGraph.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onRemoveGraph();
          }
        });

    // i18n[graph.refreshAllTables=Refresh all tables]
    _mnuRefreshAllTables = new JMenuItem(s_stringMgr.getString("graph.refreshAllTables"));
    _mnuRefreshAllTables.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onRefreshAllTables();
          }
        });

    // i18n[graph.scriptAllTables=Script all tables]
    _mnuScriptAllTables = new JMenuItem(s_stringMgr.getString("graph.scriptAllTables"));
    _mnuScriptAllTables.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onScriptAllTables();
          }
        });

    /////////////////////////////////////////////////////////
    // Tablegroups
    // i18n[graph.scriptAllTables=Script all tables]
    _mnuSelectAllTables = new JMenuItem(s_stringMgr.getString("graph.selectAllTables"));
    _mnuSelectAllTables.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onSelectAllTables();
          }
        });

    // i18n[graph.scriptAllTables=Script all tables]
    _mnuSelectTablesByName = new JMenuItem(s_stringMgr.getString("graph.selectTablesByName"));
    _mnuSelectTablesByName.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onSelectTablesByName();
          }
        });
    /////////////////////////////////////////////////////////

    // i18n[graph.showConstr=Show constraint names]
    _mnuShowConstraintNames = new JCheckBoxMenuItem(s_stringMgr.getString("graph.showConstr"));
    _mnuShowConstraintNames.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            _desktopPane.repaint();
          }
        });

    // i18n[graph.showQualifiedTableNames=Show qualified table names]
    _mnuShowQualifiedTableNames =
        new JCheckBoxMenuItem(s_stringMgr.getString("graph.showQualifiedTableNames"));
    _mnuShowQualifiedTableNames.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onShowQualifiedTableNames();
          }
        });

    ImageIcon toWInIcon = _graphPluginResources.getIcon(GraphPluginResources.IKeys.TO_WINDOW);
    _mnuToggleWindowTab = new JMenuItem(s_stringMgr.getString("graph.toggleWindowTab"), toWInIcon);
    _mnuToggleWindowTab.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            onToggleWindowTab();
          }
        });

    _mnuAllTablesDbOrder = new JMenuItem(s_stringMgr.getString("graph.allTablesDbOrderRequested"));
    _mnuAllTablesDbOrder.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onAllTablesDbOrder();
          }
        });

    _mnuAllTablesByNameOrder =
        new JMenuItem(s_stringMgr.getString("graph.allTablesByNameOrderRequested"));
    _mnuAllTablesByNameOrder.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onAllTablesByNameOrder();
          }
        });

    _mnuAllTablesPkConstOrder =
        new JMenuItem(s_stringMgr.getString("graph.allTablesPkConstOrderRequested"));
    _mnuAllTablesPkConstOrder.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onAllTablesPkConstOrder();
          }
        });

    _mnuAllFilteredSelectedOrder =
        new JMenuItem(s_stringMgr.getString("graph.allTablesFilteredSelectedOrderRequested"));
    _mnuAllFilteredSelectedOrder.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onAllTablesFilteredSelectedOrder();
          }
        });

    _popUp.add(_mnuSaveGraph);
    _popUp.add(_mnuRenameGraph);
    _popUp.add(_mnuRemoveGraph);
    _popUp.add(new JSeparator());
    _popUp.add(_mnuRefreshAllTables);
    _popUp.add(_mnuScriptAllTables);
    _popUp.add(new JSeparator());
    /////////////////////////////////////////////////////////
    // Tablegroups
    _popUp.add(_mnuSelectAllTables);
    _popUp.add(_mnuSelectTablesByName);
    _popUp.add(new JSeparator());
    /////////////////////////////////////////////////////////
    _popUp.add(_mnuAllTablesDbOrder);
    _popUp.add(_mnuAllTablesByNameOrder);
    _popUp.add(_mnuAllTablesPkConstOrder);
    _popUp.add(_mnuAllFilteredSelectedOrder);
    _popUp.add(new JSeparator());
    _popUp.add(_mnuShowConstraintNames);
    _popUp.add(_mnuShowQualifiedTableNames);
    _popUp.add(new JSeparator());
    _popUp.add(_mnuToggleWindowTab);
    _popUp.add(new JSeparator());
    _popUp.add(_modeManager.getModeMenuItem());

    _modeManager.addModeManagerListener(
        new ModeManagerListener() {
          @Override
          public void modeChanged(Mode newMode) {
            _popUp.setVisible(false);
          }
        });

    _popUp.addPopupMenuListener(
        new PopupMenuListener() {
          @Override
          public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
            onPopupMenuWillBecomeInvisible();
          }

          @Override
          public void popupMenuWillBecomeVisible(PopupMenuEvent e) {}

          @Override
          public void popupMenuCanceled(PopupMenuEvent e) {}
        });
  }