public void adjustFeedback() {
   actionCancel.setEnabled(true);
   actionChooseNone.setEnabled(true);
   if (getSwingFocus() == null) {
     actionChooseSelected.setEnabled(false);
   } else {
     actionChooseSelected.setEnabled(true);
   }
 }
  public void setChannel(int chan) {
    currentChannel = chan;
    channelLabel.setText("Now tuned to channel: " + currentChannel);
    // enable/disable the Actions as appropriate

    downAction.setEnabled(currentChannel > MIN_CHANNEL);
    upAction.setEnabled(currentChannel < MAX_CHANNEL);
    gotoFavoriteAction.setEnabled(currentChannel != favoriteChannel);
    setFavoriteAction.setEnabled(currentChannel != favoriteChannel);
  }
  // inherit doc comment
  protected JPopupMenu createPopupMenu() {
    if (TABLE.getSelectionModel().isSelectionEmpty()) {
      return null;
    }

    JPopupMenu menu = new SkinPopupMenu();

    menu.add(new SkinMenuItem(LAUNCH_ACTION));
    if (getMediaType().equals(MediaType.getAudioMediaType())) {
      menu.add(new SkinMenuItem(LAUNCH_OS_ACTION));
    }
    if (hasExploreAction()) {
      menu.add(new SkinMenuItem(OPEN_IN_FOLDER_ACTION));
    }

    if (areAllSelectedFilesMP4s()) {
      menu.add(DEMUX_MP4_AUDIO_ACTION);
      DEMUX_MP4_AUDIO_ACTION.setEnabled(
          !((DemuxMP4AudioAction) DEMUX_MP4_AUDIO_ACTION).isDemuxing());
    }

    menu.add(new SkinMenuItem(CREATE_TORRENT_ACTION));

    if (areAllSelectedFilesPlayable()) {
      menu.add(createAddToPlaylistSubMenu());
    }

    menu.add(new SkinMenuItem(SEND_TO_FRIEND_ACTION));
    menu.add(new SkinMenuItem(SEND_TO_ITUNES_ACTION));

    menu.addSeparator();
    menu.add(new SkinMenuItem(DELETE_ACTION));
    menu.addSeparator();

    int[] rows = TABLE.getSelectedRows();
    boolean dirSelected = false;
    boolean fileSelected = false;

    for (int i = 0; i < rows.length; i++) {
      File f = DATA_MODEL.get(rows[i]).getFile();
      if (f.isDirectory()) {
        dirSelected = true;
        //				if (IncompleteFileManager.isTorrentFolder(f))
        //					torrentSelected = true;
      } else fileSelected = true;

      if (dirSelected && fileSelected) break;
    }

    DELETE_ACTION.setEnabled(true);
    LibraryFilesTableDataLine line = DATA_MODEL.get(rows[0]);
    menu.add(createSearchSubMenu(line));
    return menu;
  }
Esempio n. 4
0
 @Override
 public void show(Component c, int x, int y) {
   if (c instanceof JTextComponent) {
     JTextComponent textArea = (JTextComponent) c;
     boolean flg = Objects.nonNull(textArea.getSelectedText());
     cutAction.setEnabled(flg);
     copyAction.setEnabled(flg);
     deleteAction.setEnabled(flg);
     super.show(c, x, y);
   }
 }
Esempio n. 5
0
 public void caretUpdate(CaretEvent e) {
   // when the cursor moves on _textView
   // this method will be called. Then, we
   // must determine what the line number is
   // and update the line number view
   Element root = textView.getDocument().getDefaultRootElement();
   int line = root.getElementIndex(e.getDot());
   root = root.getElement(line);
   int col = root.getElementIndex(e.getDot());
   lineNumberView.setText(line + ":" + col);
   // if text is selected then enable copy and cut
   boolean isSelection = e.getDot() != e.getMark();
   copyAction.setEnabled(isSelection);
   cutAction.setEnabled(isSelection);
 }
  /**
   * Enable/disable an AbstractAction
   *
   * @param actionName the key that maps this action in actionTable
   * @param b true to enable or false to disable the action
   */
  public static synchronized void setActionEnabled(final Integer actionKey, final boolean b) {
    Action aa = actionTable.get(actionKey);

    if (aa != null) {
      aa.setEnabled(b);
    }
  }
 /**
  * The disconnect method will stop the eventreplayer, and send null to the other peers, to stop
  * their reading from their streams. The GUI-menu is updated appropriately.
  */
 public void disconnect() {
   setTitle("Disconnected");
   active = false;
   if (connected == true) {
     er.stopStreamToQueue();
     ert.interrupt();
     setDocumentFilter(null);
     connected = false;
     setLocked(false);
   }
   deregisterOnPort();
   Disconnect.setEnabled(false);
   Connect.setEnabled(true);
   Listen.setEnabled(true);
   Save.setEnabled(true);
   SaveAs.setEnabled(true);
 }
Esempio n. 8
0
  /**
   * Mouse Listener methods.
   *
   * <p>spv
   */
  public void mouseTriggered(MouseEvent me) {
    if (me.isPopupTrigger()) {
      actionJumpToError.setEnabled(parseError != null && parseError.hasLineNumbers());
      ((GUIMultiModel) handler.getGUIPlugin()).doEnables();

      contextPopup.show(me.getComponent(), me.getX(), me.getY());
    }
  }
  /**
   * Handles the selection rows in the library window, enabling or disabling buttons and chat menu
   * items depending on the values in the selected rows.
   *
   * @param row the index of the first row that is selected
   */
  public void handleSelection(int row) {
    int[] sel = TABLE.getSelectedRows();
    if (sel.length == 0) {
      handleNoSelection();
      return;
    }

    File selectedFile = getFile(sel[0]);

    //  always turn on Launch, Delete, Magnet Lookup, Bitzi Lookup
    LAUNCH_ACTION.setEnabled(true);
    LAUNCH_OS_ACTION.setEnabled(true);
    DELETE_ACTION.setEnabled(true);

    if (selectedFile != null && !selectedFile.getName().endsWith(".torrent")) {
      CREATE_TORRENT_ACTION.setEnabled(sel.length == 1);
    }

    if (selectedFile != null) {
      SEND_TO_FRIEND_ACTION.setEnabled(sel.length == 1);

      if (getMediaType().equals(MediaType.getAnyTypeMediaType())) {
        boolean atLeastOneIsPlayable = false;

        for (int i : sel) {
          File f = getFile(i);
          if (MediaPlayer.isPlayableFile(f) || hasExtension(f.getAbsolutePath(), "mp4")) {
            atLeastOneIsPlayable = true;
            break;
          }
        }

        SEND_TO_ITUNES_ACTION.setEnabled(atLeastOneIsPlayable);
      } else {
        SEND_TO_ITUNES_ACTION.setEnabled(
            getMediaType().equals(MediaType.getAudioMediaType())
                || hasExtension(selectedFile.getAbsolutePath(), "mp4"));
      }
    }

    if (sel.length == 1 && selectedFile.isFile() && selectedFile.getParentFile() != null) {
      OPEN_IN_FOLDER_ACTION.setEnabled(true);
    } else {
      OPEN_IN_FOLDER_ACTION.setEnabled(false);
    }

    if (sel.length == 1) {
      LibraryMediator.instance().getLibraryCoverArt().setFile(selectedFile);
    }

    //        boolean anyBeingShared = isAnyBeingShared();
    //        WIFI_SHARE_ACTION.setEnabled(!anyBeingShared);
    //        WIFI_UNSHARE_ACTION.setEnabled(!anyBeingShared);
  }
Esempio n. 10
0
  /** Synchronizes the state of the actions to the current state of this host. */
  private void updateActions() {
    final DeviceController currentDeviceController = getDeviceController();

    final boolean deviceControllerSet = currentDeviceController != null;
    final boolean deviceCapturing = deviceControllerSet && currentDeviceController.isCapturing();
    final boolean deviceSetup =
        deviceControllerSet && !deviceCapturing && currentDeviceController.isSetup();

    getAction(CaptureAction.ID).setEnabled(deviceControllerSet);
    getAction(CancelCaptureAction.ID).setEnabled(deviceCapturing);
    getAction(RepeatCaptureAction.ID).setEnabled(deviceSetup);

    final boolean projectChanged = this.projectManager.getCurrentProject().isChanged();
    final boolean projectSavedBefore =
        this.projectManager.getCurrentProject().getFilename() != null;
    final boolean dataAvailable = this.dataContainer.hasCapturedData();

    getAction(SaveProjectAction.ID).setEnabled(projectChanged);
    getAction(SaveProjectAsAction.ID).setEnabled(projectSavedBefore && projectChanged);
    getAction(SaveDataFileAction.ID).setEnabled(dataAvailable);

    getAction(ZoomInAction.ID).setEnabled(dataAvailable);
    getAction(ZoomOutAction.ID).setEnabled(dataAvailable);
    getAction(ZoomDefaultAction.ID).setEnabled(dataAvailable);
    getAction(ZoomFitAction.ID).setEnabled(dataAvailable);

    final boolean triggerEnable = dataAvailable && this.dataContainer.hasTriggerData();
    getAction(GotoTriggerAction.ID).setEnabled(triggerEnable);

    // Update the cursor actions accordingly...
    final boolean enableCursors = dataAvailable && this.dataContainer.isCursorsEnabled();

    for (int c = 0; c < CapturedData.MAX_CURSORS; c++) {
      final boolean enabled = enableCursors && this.dataContainer.isCursorPositionSet(c);
      getAction(GotoNthCursorAction.getID(c)).setEnabled(enabled);
    }

    getAction(GotoFirstCursorAction.ID).setEnabled(enableCursors);
    getAction(GotoLastCursorAction.ID).setEnabled(enableCursors);

    getAction(SetCursorModeAction.ID).setEnabled(dataAvailable);
    getAction(SetCursorModeAction.ID)
        .putValue(Action.SELECTED_KEY, Boolean.valueOf(this.dataContainer.isCursorsEnabled()));

    boolean anyCursorSet = false;
    for (int c = 0; c < CapturedData.MAX_CURSORS; c++) {
      final boolean cursorPositionSet = this.dataContainer.isCursorPositionSet(c);
      anyCursorSet |= cursorPositionSet;

      final Action action = getAction(SetCursorAction.getCursorId(c));
      action.setEnabled(dataAvailable);
      action.putValue(Action.SELECTED_KEY, Boolean.valueOf(cursorPositionSet));
    }

    getAction(ClearCursors.ID).setEnabled(enableCursors && anyCursorSet);
  }
Esempio n. 11
0
 public Action getNewFolderAction() {
   if (newFolderAction == null) {
     newFolderAction = new NewFolderAction();
     // Note: Don't return null for readOnly, it might
     // break older apps.
     if (readOnly) {
       newFolderAction.setEnabled(false);
     }
   }
   return newFolderAction;
 }
Esempio n. 12
0
 private void saveFile(String fileName) {
   try {
     FileWriter w = new FileWriter(fileName);
     area1.write(w);
     w.close();
     currentFile = fileName;
     changed = false;
     Save.setEnabled(false);
   } catch (IOException e) {
   }
 }
 private void saveFile(String fileName) {
   try {
     FileWriter w = new FileWriter(fileName);
     area.write(w);
     w.close();
     currentFile = fileName;
     setTitle(currentFile + " - CoreyTextEditor");
     changed = false;
     Save.setEnabled(false);
   } catch (IOException e) {
     // No handling done here
   }
 }
 /**
  * Handles the deselection of all rows in the library table, disabling all necessary buttons and
  * menu items.
  */
 public void handleNoSelection() {
   LAUNCH_ACTION.setEnabled(false);
   LAUNCH_OS_ACTION.setEnabled(false);
   OPEN_IN_FOLDER_ACTION.setEnabled(false);
   SEND_TO_FRIEND_ACTION.setEnabled(false);
   CREATE_TORRENT_ACTION.setEnabled(false);
   DELETE_ACTION.setEnabled(false);
   SEND_TO_ITUNES_ACTION.setEnabled(false);
 }
  public void adjustFinderMenuBar() {
    JMenuItem menuItem;
    Action act;
    String itemLabel;
    ICFSecurityServiceTypeObj selectedObj = getSwingFocusAsServiceType();
    boolean enableState;
    if (selectedObj == null) {
      enableState = false;
    } else {
      enableState = true;
    }

    if (actionViewSelected != null) {
      actionViewSelected.setEnabled(enableState);
    }
    if (actionEditSelected != null) {
      actionEditSelected.setEnabled(enableState);
    }
    if (actionDeleteSelected != null) {
      actionDeleteSelected.setEnabled(enableState);
    }
    if (actionAddServiceType != null) {
      actionAddServiceType.setEnabled(true);
    }

    if (menuFile != null) {
      int itemCount = menuFile.getItemCount();
      for (int itemIdx = 0; itemIdx < itemCount; itemIdx++) {
        menuItem = menuFile.getItem(itemIdx);
        act = menuItem.getAction();
        if (act != null) {
          if (act == actionViewSelected) {
            menuItem.setEnabled(enableState);
          } else if (act == actionEditSelected) {
            menuItem.setEnabled(enableState);
          } else if (act == actionDeleteSelected) {
            menuItem.setEnabled(enableState);
          } else if (act == actionAddServiceType) {
            menuItem.setEnabled(true);
          }
        }
      }
    }
  }
Esempio n. 16
0
 public void updateState() {
   actDelEntity.setEnabled(-1 != lstEntities.getSelectedIndex());
 }
Esempio n. 17
0
  public InterpreterFrame() {
    super("Simple Lisp Interpreter");

    // Create the menu
    menubar = buildMenuBar();
    setJMenuBar(menubar);
    // Create the toolbar
    toolbar = buildToolBar();
    // disable cut and copy actions
    cutAction.setEnabled(false);
    copyAction.setEnabled(false);
    // Setup text area for editing source code
    // and setup document listener so interpreter
    // is notified when current file modified and
    // when the cursor is moved.
    textView = buildEditor();
    textView.getDocument().addDocumentListener(this);
    textView.addCaretListener(this);

    // set default key bindings
    bindKeyToCommand("ctrl C", "(buffer-copy)");
    bindKeyToCommand("ctrl X", "(buffer-cut)");
    bindKeyToCommand("ctrl V", "(buffer-paste)");
    bindKeyToCommand("ctrl E", "(buffer-eval)");
    bindKeyToCommand("ctrl O", "(file-open)");
    bindKeyToCommand("ctrl S", "(file-save)");
    bindKeyToCommand("ctrl Q", "(exit)");

    // Give text view scrolling capability
    Border border =
        BorderFactory.createCompoundBorder(
            BorderFactory.createEmptyBorder(3, 3, 3, 3),
            BorderFactory.createLineBorder(Color.gray));
    JScrollPane topSplit = addScrollers(textView);
    topSplit.setBorder(border);

    // Create tabbed pane for console/problems
    consoleView = makeConsoleArea(10, 50, true);
    problemsView = makeConsoleArea(10, 50, false);
    tabbedPane = buildProblemsConsole();

    // Plug the editor and problems/console together
    // using a split pane. This allows one to change
    // their relative size using the split-bar in
    // between them.
    splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topSplit, tabbedPane);

    // Create status bar
    statusView = new JLabel(" Status");
    lineNumberView = new JLabel("0:0");
    statusbar = buildStatusBar();

    // Now, create the outer panel which holds
    // everything together
    outerpanel = new JPanel();
    outerpanel.setLayout(new BorderLayout());
    outerpanel.add(toolbar, BorderLayout.PAGE_START);
    outerpanel.add(splitPane, BorderLayout.CENTER);
    outerpanel.add(statusbar, BorderLayout.SOUTH);
    getContentPane().add(outerpanel);

    // tell frame to fire a WindowsListener event
    // but not to close when "x" button clicked.
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    addWindowListener(this);
    // set minimised icon to use
    setIconImage(makeImageIcon("spi.png").getImage());

    // setup additional internal functions
    InternalFunctions.setup_internals(interpreter, this);

    // set default window size
    Component top = splitPane.getTopComponent();
    Component bottom = splitPane.getBottomComponent();
    top.setPreferredSize(new Dimension(100, 400));
    bottom.setPreferredSize(new Dimension(100, 200));
    pack();

    // load + run user configuration file (if there is one)
    String homedir = System.getProperty("user.home");
    try {
      interpreter.load(homedir + "/.simplelisp");
    } catch (FileNotFoundException e) {
      // do nothing if file does not exist!
      System.out.println("Didn't find \"" + homedir + "/.simplelisp\"");
    }

    textView.grabFocus();
    setVisible(true);

    // redirect all I/O to problems/console
    redirectIO();

    // start highlighter thread
    highlighter = new DisplayThread(250);
    highlighter.setDaemon(true);
    highlighter.start();
  }
 public void setPanelMode(CFJPanel.PanelMode value) {
   CFJPanel.PanelMode oldMode = getPanelMode();
   if (oldMode == value) {
     return;
   }
   super.setPanelMode(value);
   ((ICFFreeSwitchSwingFSSFExtensionJPanelCommon) swingViewEditJPanel).setPanelMode(value);
   if (value == CFJPanel.PanelMode.View) {
     if (actionEdit != null) {
       actionEdit.setEnabled(true);
     }
     if (actionSave != null) {
       actionSave.setEnabled(false);
     }
     if (actionDelete != null) {
       actionDelete.setEnabled(true);
     }
     if (actionClose != null) {
       actionClose.setEnabled(true);
     }
   } else if (value == CFJPanel.PanelMode.Edit) {
     if (actionEdit != null) {
       actionEdit.setEnabled(false);
     }
     if (actionSave != null) {
       actionSave.setEnabled(true);
     }
     if (actionDelete != null) {
       actionDelete.setEnabled(false);
     }
     if (actionClose != null) {
       actionClose.setEnabled(true);
     }
   } else if (value == CFJPanel.PanelMode.Add) {
     if (actionEdit != null) {
       actionEdit.setEnabled(false);
     }
     if (actionSave != null) {
       actionSave.setEnabled(true);
     }
     if (actionDelete != null) {
       actionDelete.setEnabled(false);
     }
     if (actionClose != null) {
       actionClose.setEnabled(true);
     }
   } else {
     if (actionEdit != null) {
       actionEdit.setEnabled(false);
     }
     if (actionSave != null) {
       actionSave.setEnabled(false);
     }
     if (actionDelete != null) {
       actionDelete.setEnabled(false);
     }
     if (actionClose != null) {
       actionClose.setEnabled(true);
     }
   }
 }
Esempio n. 19
0
        public void actionPerformed(ActionEvent e) {
          saveOld();
          area1.setText("");
          resetArea2();
          try {
            clientSocket = new Socket(ipaddress.getText(), Integer.parseInt(portNumber.getText()));
            Random r = new Random();
            serverport = 10000 + r.nextInt(8999); // random port :D

            serverSocket = new ServerSocket(serverport);
            active = true;
            editor.setTitleToListen();

            connected = true;

            ObjectOutputStream output = new ObjectOutputStream(clientSocket.getOutputStream());
            ObjectInputStream input = new ObjectInputStream(clientSocket.getInputStream());
            output.writeObject(new JoinNetworkRequest(serverport));

            ConnectionData data = getConnectionData(clientSocket, input);

            lc = new LamportClock(data.getId());
            lc.setMaxTime(data.getTs());
            dec = new DocumentEventCapturer(lc, editor);
            er = new EventReplayer(editor, dec, lc);
            ert = new Thread(er);
            ert.start();

            Peer peer =
                new Peer(
                    editor,
                    er,
                    data.getHostId(),
                    clientSocket,
                    output,
                    input,
                    lc,
                    clientSocket.getInetAddress().getHostAddress(),
                    data.getPort());
            dec.addPeer(peer);
            Thread thread = new Thread(peer);
            thread.start();

            er.setAcknowledgements(data.getAcknowledgements());
            er.setEventHistory(data.getEventHistory());
            er.setCarets(data.getCarets());

            er.addCaretPos(lc.getID(), 0);

            for (PeerWrapper p : data.getPeers()) {
              Socket socket;
              try {
                socket = connectToPeer(p.getIP(), p.getPort());
                ObjectOutputStream outputStream = new ObjectOutputStream(socket.getOutputStream());
                ObjectInputStream inputStream = new ObjectInputStream(socket.getInputStream());
                outputStream.writeObject(
                    new NewPeerDataRequest(lc.getID(), serverSocket.getLocalPort(), 0));
                Peer newPeer =
                    new Peer(
                        editor,
                        er,
                        p.getId(),
                        socket,
                        outputStream,
                        inputStream,
                        lc,
                        p.getIP(),
                        p.getPort());
                dec.addPeer(newPeer);
                Thread t = new Thread(newPeer);
                t.start();
              } catch (IOException ex) {
                continue;
              }
            }

            Thread t1 =
                new Thread(
                    new Runnable() {

                      @Override
                      public void run() {
                        waitForConnection();
                      }
                    });
            t1.start();
            area1.setText(data.getTextField());
            area1.setCaretPosition(0);
            setDocumentFilter(dec);

            dec.sendObjectToAllPeers(new UnlockRequest(lc.getTimeStamp()));

            changed = false;
            Connect.setEnabled(false);
            Disconnect.setEnabled(true);
            Listen.setEnabled(false);
            Save.setEnabled(false);
            SaveAs.setEnabled(false);
          } catch (NumberFormatException | IOException e1) {
            setTitle("Unable to connect");
          }
        }
Esempio n. 20
0
        public void actionPerformed(ActionEvent e) {
          saveOld();
          final InetAddress local;
          active = true;
          try {
            local = InetAddress.getLocalHost();
            Runnable server =
                new Runnable() {
                  public void run() {
                    serverport = Integer.parseInt(portNumber.getText());
                    int myID = getNewId();
                    registerOnPort();
                    editor.setTitleToListen();
                    clientSocket = waitForConnectionFromClient();
                    lc = new LamportClock(myID);
                    area1.setText("");
                    resetArea2();
                    if (clientSocket != null) {
                      listen = true;
                      connected = true;
                      dec = new DocumentEventCapturer(lc, editor);
                      setDocumentFilter(dec);
                      er = new EventReplayer(editor, dec, lc);
                      er.updateCaretPos(myID, 0);
                      ert = new Thread(er);
                      ert.start();

                      try {
                        ObjectOutputStream output =
                            new ObjectOutputStream(clientSocket.getOutputStream());
                        ObjectInputStream input =
                            new ObjectInputStream(clientSocket.getInputStream());
                        JoinNetworkRequest request = (JoinNetworkRequest) input.readObject();
                        int id = getNewId();
                        Peer peer =
                            new Peer(
                                editor,
                                er,
                                id,
                                clientSocket,
                                output,
                                input,
                                lc,
                                clientSocket.getInetAddress().getHostAddress(),
                                request.getPort());
                        ConnectionData cd =
                            new ConnectionData(
                                er.getEventHistory(),
                                er.getAcknowledgements(),
                                er.getCarets(),
                                id,
                                area1.getText(),
                                lc.getTimeStamp(),
                                lc.getID(),
                                dec.getPeers(),
                                serverSocket.getLocalPort());
                        dec.addPeer(peer);
                        er.addCaretPos(id, 0);
                        Thread t = new Thread(peer);
                        t.start();
                        peer.writeObjectToStream(cd);
                      } catch (IOException | ClassNotFoundException e) {
                        e.printStackTrace();
                      }
                    }
                    waitForConnection();
                  }
                };
            Thread serverThread = new Thread(server);
            serverThread.start();
          } catch (UnknownHostException e1) {
            e1.printStackTrace();
          }

          changed = false;
          Disconnect.setEnabled(true);
          Listen.setEnabled(false);
          Connect.setEnabled(false);
          Save.setEnabled(false);
          SaveAs.setEnabled(false);
        }
  private void setState(int state, boolean updateRegardless) {
    Window wnd = getWindow();

    if (wnd != null && getWindowDecorationStyle() == JRootPane.FRAME) {
      if (myState == state && !updateRegardless) {
        return;
      }
      Frame frame = getFrame();

      if (frame != null) {
        JRootPane rootPane = getRootPane();

        if (((state & Frame.MAXIMIZED_BOTH) != 0)
            && (rootPane.getBorder() == null || (rootPane.getBorder() instanceof UIResource))
            && frame.isShowing()) {
          rootPane.setBorder(null);
        } else if ((state & Frame.MAXIMIZED_BOTH) == 0) {
          // This is a croak, if state becomes bound, this can
          // be nuked.
          rootPaneUI.installBorder(rootPane);
        }
        if (frame.isResizable()) {
          if ((state & Frame.MAXIMIZED_BOTH) != 0) {
            updateToggleButton(myRestoreAction, myMinimizeIcon);
            myMaximizeAction.setEnabled(false);
            myRestoreAction.setEnabled(true);
          } else {
            updateToggleButton(myMaximizeAction, myMaximizeIcon);
            myMaximizeAction.setEnabled(true);
            myRestoreAction.setEnabled(false);
          }
          if (myToggleButton.getParent() == null || myIconifyButton.getParent() == null) {
            add(myToggleButton);
            add(myIconifyButton);
            revalidate();
            repaint();
          }
          myToggleButton.setText(null);
        } else {
          myMaximizeAction.setEnabled(false);
          myRestoreAction.setEnabled(false);
          if (myToggleButton.getParent() != null) {
            remove(myToggleButton);
            revalidate();
            repaint();
          }
        }
      } else {
        // Not contained in a Frame
        myMaximizeAction.setEnabled(false);
        myRestoreAction.setEnabled(false);
        myIconifyAction.setEnabled(false);
        remove(myToggleButton);
        remove(myIconifyButton);
        revalidate();
        repaint();
      }
      myCloseAction.setEnabled(true);
      myState = state;
    }
  }
Esempio n. 22
0
 @Override
 public void show(Component c, int x, int y) {
   int[] l = table.getSelectedRows();
   deleteAction.setEnabled(l.length > 0);
   super.show(c, x, y);
 }
Esempio n. 23
0
  public DataPanel(
      BeautiFrame parent,
      Action importDataAction,
      Action removeDataAction /*, Action importTraitsAction*/) {

    this.frame = parent;

    dataTableModel = new DataTableModel();
    dataTable = new JTable(dataTableModel);

    dataTable.getTableHeader().setReorderingAllowed(false);
    dataTable
        .getTableHeader()
        .setDefaultRenderer(new HeaderRenderer(SwingConstants.LEFT, new Insets(0, 4, 0, 4)));

    TableColumn col = dataTable.getColumnModel().getColumn(5);
    ComboBoxRenderer comboBoxRenderer = new ComboBoxRenderer();
    comboBoxRenderer.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
    col.setCellRenderer(comboBoxRenderer);

    //        col = dataTable.getColumnModel().getColumn(5);
    //        comboBoxRenderer = new ComboBoxRenderer();
    //        comboBoxRenderer.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
    //        col.setCellRenderer(comboBoxRenderer);

    col = dataTable.getColumnModel().getColumn(6);
    comboBoxRenderer = new ComboBoxRenderer();
    comboBoxRenderer.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
    col.setCellRenderer(comboBoxRenderer);

    col = dataTable.getColumnModel().getColumn(7);
    comboBoxRenderer = new ComboBoxRenderer();
    comboBoxRenderer.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
    col.setCellRenderer(comboBoxRenderer);

    TableEditorStopper.ensureEditingStopWhenTableLosesFocus(dataTable);

    dataTable
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent evt) {
                selectionChanged();
              }
            });

    dataTable.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
              showAlignment();
            }
          }
        });

    scrollPane =
        new JScrollPane(
            dataTable,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollPane.setOpaque(false);

    JToolBar toolBar1 = new JToolBar();
    toolBar1.setFloatable(false);
    toolBar1.setOpaque(false);
    toolBar1.setLayout(new BoxLayout(toolBar1, BoxLayout.X_AXIS));

    JButton button = new JButton(unlinkModelsAction);
    unlinkModelsAction.setEnabled(false);
    PanelUtils.setupComponent(button);
    toolBar1.add(button);

    button = new JButton(linkModelsAction);
    linkModelsAction.setEnabled(false);
    PanelUtils.setupComponent(button);
    toolBar1.add(button);

    toolBar1.addSeparator();

    button = new JButton(unlinkClocksAction);
    unlinkClocksAction.setEnabled(false);
    PanelUtils.setupComponent(button);
    toolBar1.add(button);

    button = new JButton(linkClocksAction);
    linkClocksAction.setEnabled(false);
    PanelUtils.setupComponent(button);
    toolBar1.add(button);

    toolBar1.addSeparator();

    button = new JButton(unlinkTreesAction);
    unlinkTreesAction.setEnabled(false);
    PanelUtils.setupComponent(button);
    toolBar1.add(button);

    button = new JButton(linkTreesAction);
    linkTreesAction.setEnabled(false);
    PanelUtils.setupComponent(button);
    toolBar1.add(button);

    // too crowded on the toolbar  - just double click to show
    //            button = new JButton(showAction);
    //            showAction.setEnabled(false);
    //            PanelUtils.setupComponent(button);
    //            toolBar1.add(button);

    ActionPanel actionPanel1 = new ActionPanel(false);
    actionPanel1.setAddAction(importDataAction);
    actionPanel1.setRemoveAction(removeDataAction);
    removeDataAction.setEnabled(false);

    JPanel controlPanel1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    controlPanel1.setOpaque(false);
    controlPanel1.add(actionPanel1);

    controlPanel1.add(new JLabel("   "));
    PanelUtils.setupComponent(createImportTraitButton);
    controlPanel1.add(createImportTraitButton);

    //        controlPanel1.add(new JLabel(" or "));
    //
    //        button = new JButton(importTraitsAction);
    //        PanelUtils.setupComponent(button);
    //        controlPanel1.add(button);

    JPanel panel1 = new JPanel(new BorderLayout());
    panel1.setOpaque(false);
    panel1.add(useStarBEASTCheck, BorderLayout.NORTH);
    panel1.add(toolBar1, BorderLayout.SOUTH);

    setOpaque(false);
    setBorder(new BorderUIResource.EmptyBorderUIResource(new Insets(12, 12, 12, 12)));
    setLayout(new BorderLayout(0, 0));
    add(panel1, BorderLayout.NORTH);
    add(scrollPane, BorderLayout.CENTER);
    add(controlPanel1, BorderLayout.SOUTH);

    useStarBEASTCheck.setEnabled(false);
    useStarBEASTCheck.setToolTipText(STARBEASTOptions.CITATION);
    useStarBEASTCheck.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(
              ActionEvent e) { // wrong listener Issue 397: *BEAST in BEAUti is broken
            frame.setupStarBEAST(useStarBEASTCheck.isSelected());
            dataTableModel.fireTableDataChanged();
          }
        });
  }