Beispiel #1
0
  private JComponent createTabForSession(MemoryLogModel memoryLogModel) {

    ViewModel viewModel = new ViewModel(memoryLogModel);

    JComponent rawTable = createRawMessageTable(viewModel);
    JComponent crackedTable = createCrackedMessageTable(viewModel);

    JSplitPane messageView = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    messageView.setBorder(null);

    messageView.setLeftComponent(new JScrollPane(rawTable));
    messageView.setRightComponent(new JScrollPane(crackedTable));

    JSplitPane messageAndEventView = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    messageAndEventView.setResizeWeight(.66);
    messageAndEventView.setLeftComponent(messageView);
    messageAndEventView.setRightComponent(new JScrollPane(createEventMessageTable(viewModel)));
    messageAndEventView.setBorder(null);

    JPanel mainView = new JPanel(new BorderLayout());
    mainView.add(messageAndEventView, BorderLayout.CENTER);

    // @todo - wrap the filter component in a "view builder". This will eliminate
    // the cast and provide the ability to change the layout without junking up
    // builder.
    JTextField filterField = new MessageSearchField();

    FilterList<LogMessage> messages = ((GlazedListsMemoryLogModel) memoryLogModel).getMessages();

    EventList matchers = new BasicEventList();

    TextComponentMatcherEditor<LogMessage> liveSearchMatcherEditor =
        new TextComponentMatcherEditor<LogMessage>(filterField, new MessageFilterator());
    matchers.add(liveSearchMatcherEditor);
    MatcherEditor matcherEditor = new CompositeMatcherEditor(matchers);
    messages.setMatcherEditor(matcherEditor);

    JPanel sortPanel = new JPanel();
    ((FlowLayout) sortPanel.getLayout()).setAlignment(FlowLayout.LEFT);
    JCheckBox sortCheckbox = new JCheckBox("Keep New Messages At The Top");
    sortPanel.add(sortCheckbox);
    sortCheckbox.addActionListener(viewModel.getSortByMessageIndexActionListener());

    JCheckBox hideHeartbeats = new JCheckBox("Hide Heartbeats");
    sortPanel.add(hideHeartbeats);
    hideHeartbeats.addActionListener(viewModel.getHideHeartbeatsActionListener());

    JPanel filterPanel = new JPanel();
    ((FlowLayout) filterPanel.getLayout()).setAlignment(FlowLayout.RIGHT);
    filterPanel.add(new JLabel("Search:"));
    filterPanel.add(filterField);

    JPanel northPanel = new JPanel(new BorderLayout());
    northPanel.add(sortPanel, BorderLayout.WEST);
    northPanel.add(filterPanel, BorderLayout.EAST);
    mainView.add(northPanel, BorderLayout.NORTH);

    return mainView;
  }
Beispiel #2
0
    protected void changeBorderDisplay() {
      if (showBorders) {
        setBorder(BorderFactory.createTitledBorder("DrawViewPanel"));
        fromListScrollPane.setBorder(BorderFactory.createTitledBorder("ScrollPane from list"));
        splitPane.setBorder(BorderFactory.createTitledBorder("Split Pane"));

      } else {
        setBorder(null);
        fromListScrollPane.setBorder(null);
        splitPane.setBorder(null);
      }
      //			repaint();

    }
Beispiel #3
0
  /**
   * Descripción de Método
   *
   * @throws Exception
   */
  private void jbInit() throws Exception {
    this.setLayout(mainLayout);
    this.add(splitPane, BorderLayout.CENTER);
    splitPane.setOpaque(false);
    graphPanel.setLayout(graphLayout);

    //

    splitPane.add(graphPanel, JSplitPane.LEFT);
    splitPane.add(cardPanel, JSplitPane.RIGHT);
    splitPane.setBorder(null);
    splitPane.setName("gc_splitPane");

    //

    cardPanel.setLayout(cardLayout);
    cardPanel.add(srPane, "srPane"); // Sequence Important!
    cardPanel.add(mrPane, "mrPane");
    cardPanel.setBorder(null);
    cardPanel.setName("gc_cardPanel");

    // single row (w/o xPane it would be centered)

    srPane.setBorder(null);
    srPane.setName("gc_srPane");
    srPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    srPane.add(vPane, JSplitPane.TOP);
    srPane.setTopComponent(vPane);
    vPane.getViewport().add(xPanel, null);
    xPanel.add(vPanel);
    vPane.setBorder(null);
    xPanel.setLayout(xLayout);
    xPanel.setName("gc_xPanel");
    xLayout.setAlignment(FlowLayout.LEFT);
    xLayout.setHgap(0);
    xLayout.setVgap(0);

    // multi-row

    mrPane.setBorder(null);
    mrPane.getViewport().add(vTable, null);
    mrPane.setName("gc_mrPane");

    //

    graphPanel.setBorder(null);
    graphPanel.setName("gc_graphPanel");
    srPane.setDividerLocation(200);
  } // jbInit
Beispiel #4
0
 private JSplitPane createMessageLedgerSplitter(JScrollPane ledger, RvDetailsPanel details) {
   final JSplitPane splitter = new JSplitPane(JSplitPane.VERTICAL_SPLIT, ledger, details);
   splitter.setOneTouchExpandable(true);
   splitter.setDividerLocation(0.5);
   splitter.setBorder(BorderFactory.createEmptyBorder());
   return splitter;
 }
  public SplitPaneDemo2() {
    super("SplitPaneDemo2");

    // Create an instance of SplitPaneDemo
    SplitPaneDemo splitPaneDemo = new SplitPaneDemo();
    JSplitPane top = splitPaneDemo.getSplitPane();
    splitPaneDemo.getImageList().addListSelectionListener(this);

    // XXXX: Bug #4131528, borders on nested split panes accumulate.
    // Workaround: Set the border on any split pane within
    // another split pane to null. Components within nested split
    // panes need to have their own border for this to work well.
    top.setBorder(null);

    // Create a regular old label
    label = new JLabel("Click on an image name in the list.", JLabel.CENTER);

    // Create a split pane and put "top" (a split pane)
    // and JLabel instance in it.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, top, label);
    splitPane.setOneTouchExpandable(true);
    splitPane.setDividerLocation(180);

    // Provide minimum sizes for the two components in the split pane
    top.setMinimumSize(new Dimension(100, 50));
    label.setMinimumSize(new Dimension(100, 30));

    // Add the split pane to this frame
    getContentPane().add(splitPane);
  }
Beispiel #6
0
 private JSplitPane createConnectionListSplitter(
     JScrollPane connectionList, JSplitPane subjectExplorerSplitter) {
   final JSplitPane splitter =
       new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, connectionList, subjectExplorerSplitter);
   splitter.setOneTouchExpandable(false);
   splitter.setDividerLocation(0.20);
   splitter.setBorder(BorderFactory.createEmptyBorder());
   return splitter;
 }
Beispiel #7
0
  private void initLeftPanel() {
    leftPanel =
        Factory.createStrippedSplitPane(
            JSplitPane.VERTICAL_SPLIT, channelListPanel, metadataPanel, 0.65f);
    leftPanel.setContinuousLayout(true);
    leftPanel.setBorder(new EmptyBorder(8, 8, 8, 0));

    log.info("Created left panel");
  }
Beispiel #8
0
 private JSplitPane createSubjectExplorerSplitter(
     JScrollPane subjectExplorer, JSplitPane messageLedger) {
   final JSplitPane splitter =
       new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, subjectExplorer, messageLedger);
   splitter.setOneTouchExpandable(false);
   splitter.setDividerLocation(0.25);
   splitter.setBorder(BorderFactory.createEmptyBorder());
   return splitter;
 }
  /** Initializes the applet. */
  public void init() {
    // Set the JGoodies Plastic 3D look and feel
    initializeLookAndFeels();

    // initialize all beans to demo
    beans = new JComponent[6];
    beans[0] = new DateChooserPanel();
    beans[1] = new JCalendar();
    beans[2] = new JDayChooser();
    beans[3] = new JMonthChooser();
    beans[4] = new JYearChooser();
    beans[5] = new JSpinField();

    ((JSpinField) beans[5]).adjustWidthToMaximumValue();
    ((JYearChooser) beans[4]).setMaximum(((JSpinField) beans[5]).getMaximum());
    ((JYearChooser) beans[4]).adjustWidthToMaximumValue();

    getContentPane().setLayout(new BorderLayout());
    setJMenuBar(createMenuBar());

    toolBar = createToolBar();
    getContentPane().add(toolBar, BorderLayout.NORTH);

    splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    splitPane.setBorder(BorderFactory.createLineBorder(Color.GRAY));
    splitPane.setDividerSize(4);
    splitPane.setDividerLocation(240);

    BasicSplitPaneDivider divider = ((BasicSplitPaneUI) splitPane.getUI()).getDivider();

    if (divider != null) {
      divider.setBorder(null);
    }

    propertyPanel = new JPanel();
    componentPanel = new JPanel();

    URL iconURL = beans[0].getClass().getResource("images/" + beans[0].getName() + "Color16.gif");
    ImageIcon icon = new ImageIcon(iconURL);

    propertyTitlePanel =
        new JTitlePanel(
            "Properties", null, propertyPanel, BorderFactory.createEmptyBorder(4, 4, 4, 4));

    componentTitlePanel =
        new JTitlePanel(
            "Component", icon, componentPanel, BorderFactory.createEmptyBorder(4, 4, 0, 4));

    splitPane.setBottomComponent(propertyTitlePanel);
    splitPane.setTopComponent(componentTitlePanel);
    installBean(beans[0]);

    getContentPane().add(splitPane, BorderLayout.CENTER);
  }
 /**
  * This method initializes jSplitPane
  *
  * @return javax.swing.JSplitPane
  */
 private JSplitPane getJSplitPane() {
   if (jSplitPane == null) {
     jSplitPane = new JSplitPane();
     jSplitPane.setContinuousLayout(true);
     jSplitPane.setVisible(true);
     jSplitPane.setRightComponent(getJPanel1());
     jSplitPane.setDividerLocation(175);
     jSplitPane.setDividerSize(3);
     jSplitPane.setResizeWeight(0.3D);
     jSplitPane.setBorder(
         javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.LOWERED));
     jSplitPane.setLeftComponent(getJScrollPane());
   }
   return jSplitPane;
 }
Beispiel #11
0
 public HarvesterGUI(HarvestConfig config, Harvester.Control control) {
   super("Harvester");
   this.control = control;
   this.outputDirectory = config.outputDirectory;
   Logger.getRootLogger().addAppender(appender);
   setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   Container cp = getContentPane();
   JSplitPane split =
       new JSplitPane(
           JSplitPane.VERTICAL_SPLIT, createTopPanel(config.harvests), createLogPanel());
   split.setDividerLocation(0.5);
   split.setBorder(BorderFactory.createTitledBorder("Harvest Tasks"));
   cp.add(split, BorderLayout.CENTER);
   pack();
 }
  private static JSplitPane createSplitPane(int orientation) {
    JSplitPane split = new JSplitPane(orientation);
    // remove the border from the split pane
    split.setBorder(null);

    // set the divider size for a more reasonable, less bulky look
    split.setDividerSize(3);

    // check the UI.  If we can't work with the UI any further, then
    // exit here.
    if (!(split.getUI() instanceof BasicSplitPaneUI)) return split;

    //  grab the divider from the UI and remove the border from it
    BasicSplitPaneDivider divider = ((BasicSplitPaneUI) split.getUI()).getDivider();
    if (divider != null) divider.setBorder(null);

    return split;
  }
Beispiel #13
0
  private void initGui() {
    _listScrollPane.getViewport().add(_shoutsList);
    JScrollPane inputScrollPane = new JScrollPane();
    JPanel horizontalLimit =
        new JPanel() {
          @Override
          public Dimension getPreferredSize() {
            Dimension preferredSize = super.getPreferredSize();
            preferredSize.setSize(getWidth() - 30, preferredSize.getHeight());
            return preferredSize;
          }
        };
    horizontalLimit.setLayout(new BorderLayout());
    horizontalLimit.add(_messageInputPane.getComponent());
    inputScrollPane.getViewport().add(horizontalLimit);

    JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, _listScrollPane, inputScrollPane);
    split.setBorder(new EmptyBorder(0, 0, 0, 0));

    split.setOpaque(false);
    split.setDividerLocation((int) (getHeight() * 0.68));
    split.setDividerSize(3);
    setLayout(new BorderLayout());
    add(split, BorderLayout.CENTER);

    _shoutsList.setBorder(new EmptyBorder(0, 0, 0, 0));
    _messageInputPane.getComponent().setBorder(new EmptyBorder(0, 0, 0, 0));

    _shoutsList.addFocusListener(
        new FocusListener() {
          @Override
          public void focusGained(FocusEvent e) {
            _shoutsList.setEditable(false);
          }

          @Override
          public void focusLost(FocusEvent e) {
            _shoutsList.setEditable(true);
          }
        });
  }
Beispiel #14
0
  /** Populates the frame with UI controls. */
  private void buildUI() {
    Container cPane = getContentPane();
    cPane.setLayout(new BorderLayout());

    // Split pane for message text area and input text area
    mChatSplitter = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    mChatSplitter.setResizeWeight(1);
    mChatSplitter.setBorder(BorderFactory.createEmptyBorder());

    mLog = new ChatLogPanel(mColorMap);
    mChatSplitter.setTopComponent(mLog);

    mInputText = new JTextArea();
    mInputText.setLineWrap(true);
    mInputText.setWrapStyleWord(true);
    mInputText.setBorder(BorderFactory.createEmptyBorder(1, 4, 1, 4));
    mChatSplitter.setBottomComponent(new JScrollPane(mInputText));

    cPane.add(mChatSplitter, BorderLayout.CENTER);

    // Necessary for all windows, for Mac support
    AppMenuBar.applyPlatformMenuBar(this);
  }
  @Override
  protected void addComponents() {

    // protein quantitative data comparison histogram
    comparisonChart = new QuantProteinComparisonChart(controller);
    comparisonChart.setBorder(BorderFactory.createLineBorder(Color.gray));

    // Spectrum view pane
    spectrumViewPane = new SpectrumViewPane(controller, false);
    spectrumViewPane.setBorder(BorderFactory.createLineBorder(Color.gray));

    // put into a split pane
    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    splitPane.setBorder(BorderFactory.createEmptyBorder());
    splitPane.setOneTouchExpandable(true);
    splitPane.setDividerSize(DIVIDER_SIZE);
    splitPane.setResizeWeight(SPLIT_PANE_RESIZE_WEIGHT);

    splitPane.setTopComponent(comparisonChart);
    splitPane.setBottomComponent(spectrumViewPane);

    this.add(splitPane, BorderLayout.CENTER);
    this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
  }
Beispiel #16
0
  /**
   * Constructs a new {@code MapFrame}.
   *
   * @param contentPane The content pane used to register shortcuts in its {@link
   *     javax.swing.InputMap} and {@link javax.swing.ActionMap}
   * @param viewportData the initial viewport of the map. Can be null, then the viewport is derived
   *     from the layer data.
   */
  public MapFrame(JPanel contentPane, ViewportData viewportData) {
    setSize(400, 400);
    setLayout(new BorderLayout());

    mapView = new MapView(contentPane, viewportData);
    new FileDrop(mapView);

    splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true);

    leftPanel = new JPanel();
    leftPanel.setLayout(new GridBagLayout());
    leftPanel.add(mapView, GBC.std().fill());
    splitPane.setLeftComponent(leftPanel);

    dialogsPanel = new DialogsPanel(splitPane);
    splitPane.setRightComponent(dialogsPanel);

    /** All additional space goes to the mapView */
    splitPane.setResizeWeight(1.0);

    /** Some beautifications. */
    splitPane.setDividerSize(5);
    splitPane.setBorder(null);
    splitPane.setUI(
        new BasicSplitPaneUI() {
          @Override
          public BasicSplitPaneDivider createDefaultDivider() {
            return new BasicSplitPaneDivider(this) {
              @Override
              public void setBorder(Border b) {}
            };
          }
        });

    // JSplitPane supports F6 and F8 shortcuts by default, but we need them for Audio actions
    splitPane
        .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0), new Object());
    splitPane
        .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_F8, 0), new Object());

    add(splitPane, BorderLayout.CENTER);

    dialogsPanel.setLayout(new BoxLayout(dialogsPanel, BoxLayout.Y_AXIS));
    dialogsPanel.setPreferredSize(
        new Dimension(Main.pref.getInteger("toggleDialogs.width", DEF_TOGGLE_DLG_WIDTH), 0));
    dialogsPanel.setMinimumSize(new Dimension(24, 0));
    mapView.setMinimumSize(new Dimension(10, 0));

    // toolBarActions, map mode buttons
    addMapMode(new IconToggleButton(mapModeSelect = new SelectAction(this)));
    addMapMode(new IconToggleButton(new LassoModeAction(), true));
    addMapMode(new IconToggleButton(mapModeDraw = new DrawAction(this)));
    addMapMode(new IconToggleButton(mapModeZoom = new ZoomAction(this)));
    addMapMode(new IconToggleButton(new DeleteAction(this), true));
    addMapMode(new IconToggleButton(new ParallelWayAction(this), true));
    addMapMode(new IconToggleButton(new ExtrudeAction(this), true));
    addMapMode(new IconToggleButton(new ImproveWayAccuracyAction(Main.map), false));
    toolBarActionsGroup.setSelected(allMapModeButtons.get(0).getModel(), true);
    toolBarActions.setFloatable(false);

    // toolBarToggles, toggle dialog buttons
    LayerListDialog.createInstance(this);
    addToggleDialog(LayerListDialog.getInstance());
    addToggleDialog(propertiesDialog = new PropertiesDialog());
    addToggleDialog(selectionListDialog = new SelectionListDialog());
    addToggleDialog(relationListDialog = new RelationListDialog());
    addToggleDialog(new CommandStackDialog());
    addToggleDialog(new UserListDialog());
    addToggleDialog(new HistoryDialog(), true);
    addToggleDialog(conflictDialog = new ConflictDialog());
    addToggleDialog(validatorDialog = new ValidatorDialog());
    addToggleDialog(filterDialog = new FilterDialog());
    addToggleDialog(new ChangesetDialog(), true);
    addToggleDialog(new MapPaintDialog());
    toolBarToggle.setFloatable(false);

    // status line below the map
    statusLine = new MapStatus(this);
    MapView.addLayerChangeListener(this);

    boolean unregisterTab = Shortcut.findShortcut(KeyEvent.VK_TAB, 0) != null;
    if (unregisterTab) {
      for (JComponent c : allDialogButtons) c.setFocusTraversalKeysEnabled(false);
      for (JComponent c : allMapModeButtons) c.setFocusTraversalKeysEnabled(false);
    }
  }
  /** Main visualizer setup. */
  private void init() {
    this.setLayout(new BorderLayout());

    // MAIN PANEL
    JPanel mainPanel = new JPanel();
    Border margin = new EmptyBorder(10, 10, 5, 10);
    Border margin2 = new EmptyBorder(10, 10, 5, 10);

    mainPanel.setBorder(margin);
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    mainPanel.add(makeTitlePanel());

    myJTable = new JTable(model);
    myJTable.setPreferredScrollableViewportSize(new Dimension(500, 80));
    RendererUtils.applyRenderers(myJTable, RENDERERS);
    myScrollPane = new JScrollPane(myJTable);

    settingsPane = new VerticalPanel();
    settingsPane.setBorder(margin2);

    graphPanel = new AxisGraph();
    graphPanel.setPreferredSize(new Dimension(defaultWidth, defaultHeight));

    settingsPane.add(createGraphActionsPane());
    settingsPane.add(createGraphColumnPane());
    settingsPane.add(createGraphTitlePane());
    settingsPane.add(createGraphDimensionPane());
    JPanel axisPane = new JPanel(new BorderLayout());
    axisPane.add(createGraphXAxisPane(), BorderLayout.WEST);
    axisPane.add(createGraphYAxisPane(), BorderLayout.CENTER);
    settingsPane.add(axisPane);
    settingsPane.add(createLegendPane());

    tabbedGraph.addTab(
        JMeterUtils.getResString("aggregate_graph_tab_settings"), settingsPane); // $NON-NLS-1$
    tabbedGraph.addTab(
        JMeterUtils.getResString("aggregate_graph_tab_graph"), graphPanel); // $NON-NLS-1$

    // If clic on the Graph tab, make the graph (without apply interval or filter)
    ChangeListener changeListener =
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent changeEvent) {
            JTabbedPane srcTab = (JTabbedPane) changeEvent.getSource();
            int index = srcTab.getSelectedIndex();
            if (srcTab
                .getTitleAt(index)
                .equals(JMeterUtils.getResString("aggregate_graph_tab_graph"))) { // $NON-NLS-1$
              actionMakeGraph();
            }
          }
        };
    tabbedGraph.addChangeListener(changeListener);

    spane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    spane.setLeftComponent(myScrollPane);
    spane.setRightComponent(tabbedGraph);
    spane.setResizeWeight(.2);
    spane.setBorder(null); // see bug jdk 4131528
    spane.setContinuousLayout(true);

    this.add(mainPanel, BorderLayout.NORTH);
    this.add(spane, BorderLayout.CENTER);
  }
Beispiel #18
0
    @SuppressWarnings("unchecked") // we must be compatible with 1.6
    public VersionManagementPanel(final VisualCanvas canvas) {

      super(canvas);

      setLayout(new GridLayout());

      // TODO @Christian Poliwoda what does manual testing mean?
      // numbers tested manually
      Dimension prefScrollPaneDim = new Dimension(100, 30);
      Dimension visibleRectDim = canvas.getVisibleRect().getSize();

      final VersionController controller =
          canvas.getProjectController().getProject().getProjectFile();

      final int numVersions = controller.getNumberOfVersions() - 1;

      versionData = new Object[numVersions];

      ArrayList<RevCommit> versions = new ArrayList<RevCommit>();

      try {
        versions = controller.getVersions();
      } catch (IOException ex) {
        Logger.getLogger(VersionManagementPanel.class.getName()).log(Level.SEVERE, null, ex);
      }

      int maxTextwidth = 0;
      String longestText = null;

      // the history with timestamp and a short commit message
      for (int i = 1; i < versions.size(); i++) {
        String text =
            // + Message.generateHTMLSpace(3)
            new Date(versions.get(i).getCommitTime() * 1000L)
                + ": "
                + versions.get(i).getShortMessage();

        // truncate texts that are too long
        int maxTextLength = 100;
        String dots = "...";

        int textLength = text.length() - dots.length();

        if (textLength > maxTextLength) {
          text = text.substring(0, maxTextLength) + dots;
        }

        versionData[versions.size() - i - 1] = new Version(text, i);

        if (text.length() > maxTextwidth) {
          maxTextwidth = text.length();
          longestText = text;
        }
      }

      resultModel = new DefaultListModel();

      // first init to show all if search not started yet
      for (int i = 0; i < versionData.length; i++) {
        resultModel.addElement(versionData[i]);
      }

      versionList = new JList(resultModel);

      // set the width of version managment window
      // dependent on largest git short message length
      double maxFontWidth =
          versionList
              .getFontMetrics(versionList.getFont())
              .getStringBounds(longestText, versionList.getGraphics())
              .getWidth();

      if (maxFontWidth <= visibleRectDim.width) {

        prefScrollPaneDim.width = (int) maxFontWidth;
      } else {

        if (visibleRectDim.width < 400) {
          prefScrollPaneDim.width = visibleRectDim.width;
        } else {
          prefScrollPaneDim.width = 400;
        }
      }

      versionList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

      versionList.setOpaque(false);

      versionList.setBackground(VSwingUtil.TRANSPARENT_COLOR);
      versionList.setBorder(new EmptyBorder(3, 3, 3, 3));

      Box upperTopBox = Box.createVerticalBox();

      // press the commits to top with VerticalGlue
      // contains search area at top and
      // search results at the botton
      Box upperOuterBox = Box.createVerticalBox();

      JButton searchButton = new JButton("search");
      searchButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {
              searchAndAddToResultList();
            }
          });

      searchField = new JTextArea();

      // search area box
      Box upperBox1 = Box.createHorizontalBox();

      upperBox1.add(searchField);
      upperBox1.add(searchButton);

      Dimension fieldDim = new Dimension(Short.MAX_VALUE, searchField.getPreferredSize().height);
      searchField.setMaximumSize(fieldDim);

      searchField.addKeyListener(
          new KeyAdapter() {
            String tmp = "";

            @Override
            public void keyReleased(KeyEvent ke) {

              searchAndAddToResultList();
            }
          });

      //            upperOuterBox.add(upperBox1);
      upperTopBox.add(upperBox1);
      upperTopBox.add(upperOuterBox);

      // result area box
      Box upperBox2 = Box.createHorizontalBox();

      upperBox2.add(Box.createHorizontalGlue());
      upperBox2.add(versionList);
      upperBox2.add(Box.createHorizontalGlue());

      upperOuterBox.add(upperBox2);
      upperOuterBox.add(Box.createVerticalGlue());

      // added for optical reasons to force correct scrollbar position
      Box upperInnerBorderPane = Box.createHorizontalBox();
      upperInnerBorderPane.add(upperOuterBox);
      upperInnerBorderPane.setBorder(new EmptyBorder(5, 15, 5, 15));
      upperInnerBorderPane.setBackground(VSwingUtil.TRANSPARENT_COLOR);

      VScrollPane upperScrollPane = new VScrollPane(upperInnerBorderPane);
      upperScrollPane.setHorizontalScrollBarPolicy(VScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
      upperScrollPane.setVerticalScrollBarPolicy(VScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
      upperScrollPane.setMinimumSize(prefScrollPaneDim);

      JSplitPane splitPane = new VSplitPane(JSplitPane.VERTICAL_SPLIT);
      splitPane.setEnabled(true); // true = transparent
      splitPane.setBackground(VSwingUtil.TRANSPARENT_COLOR);
      splitPane.setBorder(new EmptyBorder(5, 5, 5, 5));
      splitPane.setDividerLocation(0.5);

      upperTopBox.add(upperScrollPane);
      splitPane.add(upperTopBox); // add in the upper part

      htmlCommit.setBackground(VSwingUtil.TRANSPARENT_COLOR);
      htmlCommit.setContentType("text/html");
      htmlCommit.setOpaque(false);
      htmlCommit.setEditable(false);
      htmlCommit.setBorder(new EmptyBorder(0, 15, 0, 15));

      Box lowerBox = Box.createVerticalBox();
      lowerBox.setAlignmentX(Component.LEFT_ALIGNMENT);
      lowerBox.add(htmlCommit);
      lowerBox.add(Box.createVerticalGlue());

      VScrollPane lowerScrollPane = new VScrollPane(lowerBox);

      lowerScrollPane.setHorizontalScrollBarPolicy(VScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
      lowerScrollPane.setVerticalScrollBarPolicy(VScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
      lowerScrollPane.setMinimumSize(new Dimension(0, 0));

      // add in the lower part
      splitPane.setBottomComponent(lowerScrollPane);

      add(splitPane);

      versionList.addMouseListener(
          new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {

              // show commit message in lower part if clicked on a row
              // in upper part
              if (e.getClickCount() == 1) {

                final VersionController controller =
                    canvas.getProjectController().getProject().getProjectFile();

                final int numVersions = controller.getNumberOfVersions() - 1;

                ArrayList<RevCommit> versions = new ArrayList<RevCommit>();

                try {
                  versions = controller.getVersions();
                } catch (IOException ex) {
                  Logger.getLogger(VersionManagementPanel.class.getName())
                      .log(Level.SEVERE, null, ex);
                }

                int versionIndex = ((Version) versionList.getSelectedValue()).getVersion();

                htmlCommit.setText(
                    "<html>"
                        + "<pre> <font color=white><br>"
                        + "<b>SHA-1:</b> "
                        + versions.get(versionIndex).getName()
                        + "<br><br>"
                        + "<b>Message:</b><br><br>"
                        + versions.get(versionIndex).getFullMessage()
                        + "</pre></p>"
                        + "</html>");
                htmlCommit.setCaretPosition(0);
              }

              if (e.getClickCount() == 2 && SwingUtilities.isLeftMouseButton(e)) {

                if (((Version) versionList.getSelectedValue()).getVersion() < 2) {
                  VDialog.showMessageDialog(
                      canvas,
                      "Cannot Load Version",
                      "The first version in a project contains no"
                          + " sessions and cannot be loaded!");
                  return;
                }

                //                        if (VDialog.showConfirmDialog(canvas,
                //                                "Checkout Version:",
                //                                "<html><div align=Center>"
                //                                + "<p>Do you want to checkout the selected"
                //                                + " version?<p>"
                //                                + "<p><b>Unsaved changes will be lost!</b></p>"
                //                                + "</div></html>",
                //                                VDialog.DialogType.YES_NO) != VDialog.YES) {
                //                            return;
                //                        }

                int answer =
                    VDialog.showConfirmDialog(
                        canvas,
                        "Checkout Version:",
                        "<html><div align=Center>"
                            + "<p>Checking out selected version.<p><br>"
                            + "<p>Do you want to save the current session?</p><br>"
                            + "<p><b>Unsaved changes will be lost!</b></p>"
                            + "</div></html>",
                        new String[] {"Save", "Discard", "Cancel"});

                if (answer == 0) {
                  try {
                    canvas.getProjectController().saveProject(false);
                  } catch (IOException ex) {
                    Logger.getLogger(VersionManagement.class.getName()).log(Level.SEVERE, null, ex);

                    VDialog.showMessageDialog(
                        canvas,
                        "Cannot save Project:",
                        "<html><div align=Center>" + "Project cannot be saved!" + "</div></html>");
                  }
                } else if (answer == 1) {
                  // nothing to do
                } else if (answer == 2) {
                  return;
                }

                try {

                  int versionIndex = ((Version) versionList.getSelectedValue()).getVersion();

                  canvas.setActive(false);

                  String currentSessionName = canvas.getProjectController().getCurrentSession();

                  canvas.getProjectController().close(currentSessionName);

                  controller.checkoutVersion(versionIndex);

                  if (dialog != null) {
                    dialog.close();
                    dialog = null;
                  }

                  if (canvas
                      .getProjectController()
                      .getProject()
                      .getSessionFileByEntryName(currentSessionName)
                      .exists()) {
                    canvas.getProjectController().open(currentSessionName, false, true);
                  } else {
                    //                                VDialog.showMessageDialog(canvas,
                    //                                        "Cannot load \""
                    //                                        + currentSessionName
                    //                                        +"\":", "<html><div align=Center>"
                    //                                        + "<p>The Session "
                    //                                        + Message.EMPHASIZE_BEGIN
                    //                                        + currentSessionName
                    //                                         +  Message.EMPHASIZE_END
                    //                                        + " does not exist in the current"
                    //                                        + " version."
                    //                                        + "<p>The <b>Main</b>-Session will"
                    //                                        + "be loaded instead</div></html>");
                    canvas.getProjectController().open("Main", false, true);
                  }

                } catch (IOException ex) {
                  Logger.getLogger(VersionManagementPanel.class.getName())
                      .log(Level.SEVERE, null, ex);
                }
              }
            }
          });

      //            setMinimumSize(visibleRectDim);
      setMaximumSize(visibleRectDim);

      int width = getPreferredSize().width;
      setPreferredSize(new Dimension(width, (int) (visibleRectDim.height * 0.5)));
    } // end constructure
Beispiel #19
0
  private void init() {
    setLayout(new GridBagLayout());
    setBackground(Color.white);

    splitPane.setBorder(BorderFactory.createEmptyBorder());
    splitPane.setOneTouchExpandable(false);

    verticalSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    add(
        verticalSplit,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));
    verticalSplit.setBorder(BorderFactory.createEmptyBorder());
    verticalSplit.setOneTouchExpandable(false);
    verticalSplit.setTopComponent(splitPane);
    textScroller.setAutoscrolls(true);
    textScroller.getVerticalScrollBar().setBlockIncrement(50);
    textScroller.getVerticalScrollBar().setUnitIncrement(20);

    chatWindowPanel = new JPanel();
    chatWindowPanel.setLayout(new GridBagLayout());
    chatWindowPanel.add(
        textScroller,
        new GridBagConstraints(
            0,
            10,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.WEST,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));
    chatWindowPanel.setOpaque(false);

    chatPanel.add(
        chatWindowPanel,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 5, 0, 5),
            0,
            0));
    splitPane.setLeftComponent(chatPanel);

    editorBar.setOpaque(false);
    chatPanel.setOpaque(false);

    bottomPanel.setOpaque(false);
    splitPane.setOpaque(false);
    bottomPanel.setLayout(new GridBagLayout());
    bottomPanel.add(
        chatAreaButton,
        new GridBagConstraints(
            0,
            1,
            5,
            1,
            1.0,
            1.0,
            GridBagConstraints.WEST,
            GridBagConstraints.BOTH,
            new Insets(0, 5, 5, 5),
            0,
            15));
    bottomPanel.add(
        editorBar,
        new GridBagConstraints(
            0,
            0,
            5,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 5, 0, 5),
            0,
            0));

    bottomPanel.setBorder(BorderFactory.createEmptyBorder());
    verticalSplit.setOpaque(false);

    verticalSplit.setBottomComponent(bottomPanel);
    verticalSplit.setResizeWeight(1.0);
    verticalSplit.setDividerSize(2);

    chatAreaButton.getButton().addActionListener(this);
    getChatInputEditor().getDocument().addDocumentListener(this);
    chatEditorKeyListener =
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            checkForEnter(e);
          }
        };
    getChatInputEditor().addKeyListener(chatEditorKeyListener);
    getChatInputEditor()
        .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
        .put(KeyStroke.getKeyStroke("ctrl F4"), "closeTheRoom");
    getChatInputEditor()
        .getActionMap()
        .put(
            "closeTheRoom",
            new AbstractAction("closeTheRoom") {
              public void actionPerformed(ActionEvent evt) {
                closeChatRoom();
              }
            });
  }
Beispiel #20
0
  /** Create the main JFrame */
  public Driver() {
    frame = (JFrame) this;

    setTitle("RIDVentory v2.1.2");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Creates connection to controller
    control = Controller.getInstance();

    setBounds(100, 100, 593, 370);
    GridBagLayout gridBagLayout = new GridBagLayout();
    gridBagLayout.columnWidths = new int[] {577, 0};
    gridBagLayout.rowHeights = new int[] {332, 0};
    gridBagLayout.columnWeights = new double[] {0.0, Double.MIN_VALUE};
    gridBagLayout.rowWeights = new double[] {0.0, Double.MIN_VALUE};
    getContentPane().setLayout(gridBagLayout);

    // Create Menu
    TopMenuBar topMenu = new TopMenuBar();
    this.setJMenuBar(topMenu.createMenuBar());

    // Popup Menus

    // Category Menu
    final JPopupMenu popupCat = new JPopupMenu();
    final JMenuItem addCat = new JMenuItem("Add Category");
    final JMenuItem editCat = new JMenuItem("Edit Category");
    final JMenuItem deleteCat = new JMenuItem("Delete Category");

    popupCat.add(addCat);
    popupCat.add(editCat);
    popupCat.add(deleteCat);

    // Brand Menu
    final JPopupMenu popupBrand = new JPopupMenu();
    final JMenuItem addBrand = new JMenuItem("Add Brand");
    final JMenuItem editBrand = new JMenuItem("Edit Brand");
    final JMenuItem deleteBrand = new JMenuItem("Delete Brand");

    popupBrand.add(addBrand);
    popupBrand.add(editBrand);
    popupBrand.add(deleteBrand);

    GridBagConstraints gbc_table = new GridBagConstraints();
    gbc_table.gridwidth = 3;
    gbc_table.fill = GridBagConstraints.BOTH;
    gbc_table.insets = new Insets(0, 0, 5, 0);
    gbc_table.gridx = 0;
    gbc_table.gridy = 0;
    gbc_table.weightx = 1;
    gbc_table.weighty = 1;

    GridBagConstraints gbc_buttonPanel = new GridBagConstraints();
    gbc_buttonPanel.insets = new Insets(0, 0, 5, 5);
    gbc_buttonPanel.fill = GridBagConstraints.BOTH;
    gbc_buttonPanel.gridx = 0;
    gbc_buttonPanel.gridy = 0;
    gbc_buttonPanel.weightx = 1;
    gbc_buttonPanel.weighty = 1;

    GridBagConstraints gbc_list = new GridBagConstraints();
    gbc_list.insets = new Insets(0, 0, 5, 0);
    gbc_list.anchor = GridBagConstraints.NORTHWEST;
    gbc_list.gridx = 1;
    gbc_list.gridy = 0;
    gbc_list.weightx = 1;
    gbc_list.weighty = 1;

    GridBagConstraints gbc_topMenu = new GridBagConstraints();
    gbc_topMenu.insets = new Insets(0, 0, 5, 0);
    gbc_topMenu.anchor = GridBagConstraints.NORTHWEST;
    gbc_topMenu.gridx = 1;
    gbc_topMenu.gridy = 0;
    gbc_topMenu.weightx = 1;
    gbc_topMenu.weighty = 1;

    JSplitPane splitPane = new JSplitPane();
    splitPane.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    GridBagConstraints gbc_splitPane = new GridBagConstraints();
    gbc_splitPane.weighty = 1.0;
    gbc_splitPane.weightx = 1.0;
    gbc_splitPane.fill = GridBagConstraints.BOTH;
    gbc_splitPane.gridx = 0;
    gbc_splitPane.gridy = 0;
    getContentPane().add(splitPane, gbc_splitPane);

    JPanel rightPanel = new JPanel();
    splitPane.setRightComponent(rightPanel);
    GridBagLayout gbl_rightPanel = new GridBagLayout();
    gbl_rightPanel.columnWidths = new int[] {499, 0};
    gbl_rightPanel.rowHeights = new int[] {281, 0};
    gbl_rightPanel.columnWeights = new double[] {0.0, Double.MIN_VALUE};
    gbl_rightPanel.rowWeights = new double[] {0.0, Double.MIN_VALUE};
    rightPanel.setLayout(gbl_rightPanel);

    table =
        new JTable() {
          /** */
          private static final long serialVersionUID = 1L;

          public boolean isCellEditable(int rowIndex, int vColIndex) {

            if (vColIndex > 0) // ID is not editable
            return true;
            else return false;
          }
        };

    table.setFillsViewportHeight(true);
    table.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    table.setAlignmentY(Component.BOTTOM_ALIGNMENT);

    // Load table data
    tableData = control.loadTableData();

    final TableRowSorter<DefaultTableModel> sorter =
        new TableRowSorter<DefaultTableModel>((DefaultTableModel) tableData);
    table.setModel(tableData);
    table.setRowSorter(sorter);

    // Change it so load is only called once (Store results of load call and use it for list)

    catCellEditor = new JComboBox<String>(control.loadCategories());
    brandCellEditor = new JComboBox<String>(control.loadBrands());

    // Make model editor a dropdown (Make dynamic in the future)
    categoryColumn = table.getColumnModel().getColumn(3);
    brandColumn = table.getColumnModel().getColumn(4);

    categoryColumn.setCellEditor(new DefaultCellEditor(catCellEditor));
    brandColumn.setCellEditor(new DefaultCellEditor(brandCellEditor));

    // Right main pane
    JSplitPane splitPaneMain = new JSplitPane();
    splitPaneMain.setBorder(null);
    splitPaneMain.setDividerSize(-1);
    splitPaneMain.setResizeWeight(1.0);
    splitPaneMain.setPreferredSize(new Dimension(187, 25));
    splitPaneMain.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    splitPaneMain.setOrientation(JSplitPane.VERTICAL_SPLIT);

    GridBagConstraints gbc_splitPaneMain = new GridBagConstraints();
    gbc_splitPaneMain.weighty = 1.0;
    gbc_splitPaneMain.weightx = 1.0;
    gbc_splitPaneMain.fill = GridBagConstraints.BOTH;
    gbc_splitPaneMain.gridx = 0;
    gbc_splitPaneMain.gridy = 0;

    // Add split pane to main Right split pane
    rightPanel.add(splitPaneMain, gbc_splitPaneMain);

    // Right main pane, buttons row
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridLayout(0, 2, 0, 0));

    final JButton btnInsert = new JButton("Insert");
    final JButton btnDelete = new JButton("Delete");

    buttonPanel.add(btnInsert);
    buttonPanel.add(btnDelete);

    // Set components
    splitPaneMain.setTopComponent(new JScrollPane(table));
    splitPaneMain.setBottomComponent(buttonPanel);

    JPanel leftPanel = new JPanel();
    splitPane.setLeftComponent(leftPanel);
    GridBagLayout gbl_leftPanel = new GridBagLayout();
    gbl_leftPanel.columnWidths = new int[] {71, 0};
    gbl_leftPanel.rowHeights = new int[] {34, 0};
    gbl_leftPanel.columnWeights = new double[] {0.0, Double.MIN_VALUE};
    gbl_leftPanel.rowWeights = new double[] {0.0, Double.MIN_VALUE};
    leftPanel.setLayout(gbl_leftPanel);

    // Left Split panel
    JSplitPane splitPaneLists = new JSplitPane();
    splitPaneLists.setResizeWeight(0.5);
    splitPaneLists.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    GridBagConstraints gbc_splitPaneLists = new GridBagConstraints();
    gbc_splitPaneLists.anchor = GridBagConstraints.NORTHWEST;
    gbc_splitPaneLists.gridx = 0;
    gbc_splitPaneLists.gridy = 0;
    gbc_splitPaneLists.weightx = 1;
    gbc_splitPaneLists.weighty = 1;
    gbc_splitPaneLists.fill = GridBagConstraints.BOTH;

    leftPanel.add(splitPaneLists, gbc_splitPaneLists);

    // Right list
    final JList<String> brandList = new JList<String>();
    brandList.setLayoutOrientation(JList.VERTICAL_WRAP);
    brandList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    brandList.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    brandList.setAlignmentX(Component.RIGHT_ALIGNMENT);
    brandList.setAlignmentY(Component.TOP_ALIGNMENT);
    brandList.setModel(control.loadListBrands());
    brandList.setSelectedIndex(0);

    final ListSelectionModel brandListSelectionModel =
        (ListSelectionModel) brandList.getSelectionModel();
    splitPaneLists.setRightComponent(brandList);

    // Left List
    final JList<String> categoryList = new JList<String>();
    categoryList.setLayoutOrientation(JList.VERTICAL_WRAP);
    categoryList.setVisible(true);
    categoryList.setAlignmentY(Component.TOP_ALIGNMENT);
    categoryList.setAlignmentX(Component.LEFT_ALIGNMENT);
    categoryList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    ListSelectionModel catListSelectionModel =
        categoryList.getSelectionModel(); // Created to add listener
    categoryList.setModel(control.loadListCategories());
    categoryList.setSelectedIndex(0);

    splitPaneLists.setLeftComponent(categoryList);

    table.addMouseListener(
        new MouseAdapter() {

          public void mouseReleased(MouseEvent e) {

            if (e.isPopupTrigger()) {

              Point p = e.getPoint();

              int rowNumber = table.rowAtPoint(p);

              if (Debug.LEVEL > 1) System.out.println("Row " + rowNumber + " selected");
            }
          }
        });

    btnDelete.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent arg0) {

            int selectedRow = table.getSelectedRow();

            String name = (String) table.getModel().getValueAt(selectedRow, 1);

            if (selectedRow != -1) {
              int answer =
                  JOptionPane.showConfirmDialog(
                      frame,
                      "Are you sure you want to erase product " + name + "?\n",
                      "Are you sure?",
                      JOptionPane.YES_NO_OPTION);

              if (answer == JOptionPane.YES_OPTION) {

                if (Debug.LEVEL > 1) System.out.println("Row " + selectedRow + " Deleted");

                DefaultTableModel model = (DefaultTableModel) table.getModel();

                // Call Delete in controller

                int id = (int) model.getValueAt(selectedRow, 0);

                if (control.deleteItem(id) == -1) {
                  JOptionPane.showMessageDialog(
                      frame, "Error: Item could not be erased", "Error", JOptionPane.ERROR_MESSAGE);
                }

                if (Debug.LEVEL > 2) System.out.println("Product ID " + id);

                // Delete it from table model

                model.removeRow(selectedRow);
              }
            }
          }
        });

    btnInsert.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent arg0) {

            InsertItem dialog = new InsertItem(table.getModel());

            dialog.setVisible(true);

            btnInsert.setEnabled(false); // Disable insert button so no multiple inserts
            btnDelete.setEnabled(false);

            // Put a listener on the window to determine when it closes
            dialog.addWindowListener(
                new WindowAdapter() {
                  @Override
                  public void windowClosed(WindowEvent e) {

                    // Notify table that data has changed to rerun filter
                    // fireTableCellUpdated
                    ((DefaultTableModel) tableData).fireTableDataChanged();

                    btnInsert.setEnabled(true); // Re-Enable insert button
                    btnDelete.setEnabled(true);

                    if (Debug.LEVEL > 3) System.out.println("Insert item window closed");
                  }
                });
          }
        });

    categoryList.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseReleased(MouseEvent e) {

            if (e.isPopupTrigger()) {

              Point p = e.getPoint();

              int itemChosen = categoryList.locationToIndex(p);

              // Make sure an item is chosen
              if (itemChosen > 0) // Greater than 0 to skip All
              {
                // Mark item as selected
                categoryList.setSelectedIndex(itemChosen);

                // Check if Delete Menu Item is on
                if (!popupDeleteOnCat) {
                  popupCat.add(editCat);
                  popupCat.add(deleteCat); // If not on, add it
                  popupDeleteOnCat = true;
                }

              } else {
                // Check if Delete is on
                if (popupDeleteOnCat) {
                  popupCat.remove(1); // Delete edit if turned on
                  popupCat.remove(1); // Delete delete if turned on
                  popupDeleteOnCat = false;
                }
              }

              popupCat.show(frame, e.getX(), e.getY());

              if (Debug.LEVEL > 0) System.out.println("Category List Item Chosen: " + itemChosen);
            }
          }
        });

    brandList.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseReleased(MouseEvent e) {

            if (e.isPopupTrigger()) {

              Point p = e.getPoint();

              int itemChosen = brandList.locationToIndex(p);

              // Make sure an item has been chosen
              if (itemChosen > 0) // Greater than 0 because 0 is All
              {
                // Mark item as selected
                brandList.setSelectedIndex(itemChosen);

                // Check if Delete Menu Item is not on the menu
                if (!popupDeleteOnBrand) {
                  popupBrand.add(editBrand);
                  popupBrand.add(deleteBrand); // If not on, add it
                  popupDeleteOnBrand = true;
                }

              } else {
                // Check if Delete is on the menu
                if (popupDeleteOnBrand) {
                  popupBrand.remove(1); // Delete edit
                  popupBrand.remove(1); // Delete delete if turned on
                  popupDeleteOnBrand = false;
                }
              }

              popupBrand.show(frame, e.getX(), e.getY());

              if (Debug.LEVEL > 0) System.out.println("Brand List Item Chosen: " + itemChosen);
            }
          }
        });

    // Selected index listeners
    catListSelectionModel.addListSelectionListener(
        new ListSelectionListener() {
          @Override
          public void valueChanged(ListSelectionEvent e) {

            if (!e.getValueIsAdjusting()) // Proceed if values aren't being changed
            {
              int index = categoryList.getSelectedIndex();

              if (index >= 0) // Make sure you're actually working on an item
              {
                String category = (String) categoryList.getModel().getElementAt(index);

                index = brandList.getSelectedIndex();

                String brand = (String) brandList.getModel().getElementAt(index);

                // Call filter update
                sorter.setRowFilter(control.createFilter(category, brand));

                // debug
                if (Debug.LEVEL > 0) System.out.println("Category List Index Chosen: " + index);
              }
            }
          }
        });

    // Selected index listeners
    brandListSelectionModel.addListSelectionListener(
        new ListSelectionListener() {
          @Override
          public void valueChanged(ListSelectionEvent e) {

            if (!e.getValueIsAdjusting()) // Proceed if values aren't being changed
            {
              int indexCat = categoryList.getSelectedIndex();
              int indexBrand = brandList.getSelectedIndex();

              if (indexCat >= 0 && indexBrand >= 0) // Make sure you're actually working on an item
              {
                String category = (String) categoryList.getModel().getElementAt(indexCat);

                String brand = (String) brandList.getModel().getElementAt(indexBrand);

                // Call filter update
                sorter.setRowFilter(control.createFilter(category, brand));
              }
            }
          }
        });

    addCat.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mouseReleased(MouseEvent e) {

            String newCat =
                (String)
                    JOptionPane.showInputDialog(
                        frame,
                        "Enter the name of the new Category:",
                        "Add New Category",
                        JOptionPane.PLAIN_MESSAGE,
                        null,
                        null,
                        null);
            if (newCat == null) {

              return; // Don't do anything
            }

            if (newCat.isEmpty() || newCat == "") {
              JOptionPane.showMessageDialog(
                  frame,
                  "No input encountered",
                  "New category was not created",
                  JOptionPane.ERROR_MESSAGE);
              return; // Don't do anything
            }

            String result = control.addCategory(newCat);

            // Input checking needs to be added before beta 2
            if (result != null) {
              JOptionPane.showMessageDialog(
                  frame, result, "SQL Error Encountered", JOptionPane.ERROR_MESSAGE);

              return;
            }

            // Add category to list
            DefaultListModel<String> model = (DefaultListModel<String>) categoryList.getModel();

            model.addElement(newCat);
            catCellEditor.addItem(newCat);
          }
        });

    deleteCat.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mouseReleased(MouseEvent e) {

            int catChosenIndex = categoryList.getSelectedIndex();
            String catName = (String) categoryList.getSelectedValue();

            // System.out.println(catChosen);

            int answer =
                JOptionPane.showConfirmDialog(
                    frame,
                    "Are you sure you want to delete category " + catName + "?\n",
                    "Are you sure?",
                    JOptionPane.YES_NO_OPTION);

            if (answer == JOptionPane.YES_OPTION) {
              if (control.deleteCategory(catName) != 0) {
                JOptionPane.showMessageDialog(
                    frame,
                    "Unable to erase category (category must not be used by any items)",
                    "SQL Error Encountered",
                    JOptionPane.ERROR_MESSAGE);

                return;
              }

              DefaultListModel<String> model = (DefaultListModel<String>) categoryList.getModel();

              categoryList.clearSelection();

              model.removeElementAt(catChosenIndex);
              catCellEditor.removeItem(catName);

              categoryList.setSelectedIndex(0);
            }
          }
        });

    addBrand.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mouseReleased(MouseEvent e) {

            String newBrand =
                (String)
                    JOptionPane.showInputDialog(
                        frame,
                        "Enter the name of the new Brand:",
                        "Add New Category",
                        JOptionPane.PLAIN_MESSAGE,
                        null,
                        null,
                        null);
            if (newBrand == null) {

              return; // Don't do anything
            }

            if (newBrand.isEmpty() || newBrand == "") {
              JOptionPane.showMessageDialog(
                  frame,
                  "No input encountered",
                  "New category was not created",
                  JOptionPane.ERROR_MESSAGE);
              return; // Don't do anything
            }

            String result = control.addBrand(newBrand);

            // Input checking needs to be added before beta 2
            if (result != null) {
              JOptionPane.showMessageDialog(
                  frame, result, "SQL Error Encountered", JOptionPane.ERROR_MESSAGE);

              return;
            }

            // Add category to list
            DefaultListModel<String> model = (DefaultListModel<String>) brandList.getModel();

            model.addElement(newBrand);
            brandCellEditor.addItem(newBrand);
          }
        });

    deleteBrand.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mouseReleased(MouseEvent e) {

            int brandChosenIndex = brandList.getSelectedIndex();
            String brandName = (String) brandList.getSelectedValue();

            System.out.println(brandChosenIndex);

            int answer =
                JOptionPane.showConfirmDialog(
                    frame,
                    "Are you sure you want to delete category " + brandName + "?\n",
                    "Are you sure?",
                    JOptionPane.YES_NO_OPTION);

            if (answer == JOptionPane.YES_OPTION) {
              if (control.deleteBrand(brandName) != 0) {
                JOptionPane.showMessageDialog(
                    frame,
                    "Unable to erase category (category must not be used by any items)",
                    "SQL Error Encountered",
                    JOptionPane.ERROR_MESSAGE);

                return;
              }

              DefaultListModel<String> model = (DefaultListModel<String>) brandList.getModel();

              // brandList.clearSelection();

              model.removeElementAt(brandChosenIndex);
              brandCellEditor.removeItem(brandName); // Use name to allow flexibility in future
              brandList.setSelectedIndex(0); // Reset to all
            }
          }
        });

    // Data change listener
    tableData.addTableModelListener(
        new TableModelListener() {

          public void tableChanged(TableModelEvent e) {

            try {
              int row = e.getFirstRow();
              int column = e.getColumn();
              String columnName = tableData.getColumnName(column);
              int itemID = (int) tableData.getValueAt(row, 0);
              Object data = tableData.getValueAt(row, column);

              if (Debug.LEVEL > 0) {
                System.out.println(
                    "Cell Edited at "
                        + row
                        + " "
                        + column
                        + ": "
                        + columnName
                        + " "
                        + data
                        + " ID: "
                        + itemID);
              }
              int rowsUpdated = control.updateItem(itemID, columnName, data);

              if (rowsUpdated == 0) {
                System.out.println("Failed to update, changes reverted");

                JOptionPane.showMessageDialog(
                    frame,
                    "Edit was invalid, please verify value is correct",
                    "SQL Error Encountered",
                    JOptionPane.ERROR_MESSAGE);

                // ((RidvTableModel)tableData).undoChange();
              }

            } catch (ArrayIndexOutOfBoundsException exception) {
              // Temp fix for data insertion bypass

            }
          }
        });
  }
Beispiel #21
0
  public void inits(String doc, String doc2) {
    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();

    JSplitPane splitPanel = new JSplitPane();
    splitPanel.setBorder(new javax.swing.border.EtchedBorder());

    editorPaneLeft = new JEditorPane();
    editorPaneLeft.setEditable(false);
    editorPaneLeft.addHyperlinkListener(
        new HyperlinkListener() {
          public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {

              if (e.getDescription().startsWith("#")) {
                // move to the link
                editorPaneRight.scrollToReference(e.getDescription().substring(1));
              }
            }
          }
        });
    // JPanel leftPanel = new JPanel(new BorderLayout());
    // leftPanel.add(editorPaneLeft,BorderLayout.CENTER);

    editorPaneRight = new JEditorPane();
    editorPaneRight.setEditable(false);
    editorPaneRight.addHyperlinkListener(
        new HyperlinkListener() {
          public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
              JEditorPane src = (JEditorPane) e.getSource();
              if (e.getDescription().startsWith("#")) {
                // move to the link
                src.scrollToReference(e.getDescription().substring(1));
              }
            }
          }
        });
    // JPanel rightPanel = new JPanel(new BorderLayout());
    // rightPanel.add(editorPaneRight,BorderLayout.CENTER);

    JScrollPane editorScrollPaneLeft = new JScrollPane(editorPaneLeft);
    editorScrollPaneLeft.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    editorScrollPaneLeft.setPreferredSize(new Dimension(200, 300));
    editorScrollPaneLeft.setMinimumSize(new Dimension(200, 300));

    JScrollPane editorScrollPaneRight = new JScrollPane(editorPaneRight);
    editorScrollPaneRight.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    editorScrollPaneRight.setPreferredSize(new Dimension(500, 300));
    editorScrollPaneRight.setMinimumSize(new Dimension(300, 100));

    // setDoc(editorPaneLeft,doc);
    setDoc(editorPaneRight, doc2);
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    WindowAdapter catchclose =
        new WindowAdapter() {
          public void windowClosing(WindowEvent we) {
            dispose();
          }

          // remove this if fixed in JDK 1.3.1
          public void windowActivated(WindowEvent ev) {
            ev.getWindow().repaint();
          }
        };
    this.addWindowListener(catchclose);
    // splitPanel.setLeftComponent(editorScrollPaneLeft);
    // splitPanel.setRightComponent(editorScrollPaneRight);

    // getContentPane().add("Center", splitPanel);
    getContentPane().add("Center", editorScrollPaneRight);
    pack();
    setLocation(100, 100);
    setSize(dim.width - 200, dim.height - 200);
    validate();

    // splitPanel.setDividerLocation(0.5);
    setVisible(true);
  }
 private void jbInit() throws Exception {
   ////////////////////////////////////////////////////////
   // Init LAF
   ////////////////////////////////////////////////////////
   ButtonGroup grpLAF = new ButtonGroup();
   ActionListener lsnLAF =
       new ActionListener() {
         public void actionPerformed(ActionEvent evt) {
           int iIndex = mvtLAFItem.indexOf(evt.getSource());
           if (iIndex >= 0) changeLAF(iIndex);
         }
       };
   ////////////////////////////////////////////////////////
   UIManager.LookAndFeelInfo laf =
       new UIManager.LookAndFeelInfo(
           "Kunststoff", "com.incors.plaf.kunststoff.KunststoffLookAndFeel");
   marrLaf = UIManager.getInstalledLookAndFeels();
   int iIndex = 0;
   while (iIndex < marrLaf.length && !marrLaf[iIndex].getName().equals(laf.getName())) iIndex++;
   if (iIndex >= marrLaf.length) {
     UIManager.installLookAndFeel(laf);
     marrLaf = UIManager.getInstalledLookAndFeels();
   }
   for (iIndex = 0; iIndex < marrLaf.length; iIndex++) {
     JMenuItem mnu = new JRadioButtonMenuItem(marrLaf[iIndex].getName());
     mnu.addActionListener(lsnLAF);
     mvtLAFItem.addElement(mnu);
     mnuUI.add(mnu);
     grpLAF.add(mnu);
   }
   mnuUI.addSeparator();
   ////////////////////////////////////////////////////////
   // Init language
   ////////////////////////////////////////////////////////
   ButtonGroup grpLanguage = new ButtonGroup();
   ActionListener lsnLanguage =
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           int iIndex = mvtLanguageItem.indexOf(e.getSource());
           if (iIndex >= 0) changeDictionary((String) mvtLanguage.elementAt(iIndex));
         }
       };
   ////////////////////////////////////////////////////////
   String[] str = MonitorDictionary.getSupportedLanguage();
   for (iIndex = 0; iIndex < str.length; iIndex++) {
     JMenuItem mnu =
         new JRadioButtonMenuItem(MonitorDictionary.getDictionary(str[iIndex]).getLanguage());
     mnu.addActionListener(lsnLanguage);
     mvtLanguage.addElement(str[iIndex]);
     mvtLanguageItem.addElement(mnu);
     mnuUI.add(mnu);
     grpLanguage.add(mnu);
   }
   ////////////////////////////////////////////////////////
   // Add to main menu
   ////////////////////////////////////////////////////////
   mnuMain.removeAll();
   mnuMain.add(mnuSystem);
   mnuSystem.add(mnuSystem_Login);
   mnuSystem.add(mnuSystem_ChangePassword);
   mnuSystem.addSeparator();
   mnuSystem.add(mnuSystem_StopServer);
   mnuSystem.add(mnuSystem_EnableThreads);
   mnuMain.add(mnuUI);
   mnuMain.add(mnuHelp);
   mnuHelp.add(mnuHelp_About);
   ////////////////////////////////////////////////////////
   mnuMain.add(chkVietnamese);
   mnuMain.add(lblStatus);
   ////////////////////////////////////////////////////////
   pnlThread.setTabPlacement(JTabbedPane.LEFT);
   pnlThread.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
   ////////////////////////////////////////////////////////
   tblUser.addColumn("", 1, false);
   tblUser.addColumn("", 2, false, Global.FORMAT_DATE_TIME);
   tblUser.addColumn("", 3, false);
   ////////////////////////////////////////////////////////
   JPanel pnlMessage = new JPanel();
   pnlMessage.setLayout(new GridBagLayout());
   pnlMessage.add(
       new JScrollPane(txtBoard),
       new GridBagConstraints(
           0,
           0,
           2,
           1,
           1.0,
           1.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.BOTH,
           new Insets(2, 2, 2, 2),
           0,
           0));
   pnlMessage.add(
       txtMessage,
       new GridBagConstraints(
           0,
           1,
           1,
           1,
           1.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.BOTH,
           new Insets(2, 2, 2, 2),
           0,
           0));
   pnlMessage.add(
       btnSend,
       new GridBagConstraints(
           1,
           1,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(2, 2, 2, 2),
           0,
           0));
   txtBoard.setEditable(false);
   txtBoard.setAutoscrolls(true);
   txtBoard.setContentType("text/html");
   clearAll(txtBoard);
   ////////////////////////////////////////////////////////
   JPanel pnlUserButton = new JPanel(new GridLayout(1, 2, 4, 4));
   pnlUserButton.add(btnKick);
   pnlUserButton.add(btnRefresh);
   ////////////////////////////////////////////////////////
   JPanel pnlManager = new JPanel(new GridBagLayout());
   pnlManager.add(
       new JScrollPane(tblUser),
       new GridBagConstraints(
           0,
           0,
           1,
           1,
           1.0,
           1.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.BOTH,
           new Insets(2, 2, 2, 2),
           0,
           0));
   pnlManager.add(
       pnlUserButton,
       new GridBagConstraints(
           0,
           1,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(4, 2, 4, 2),
           0,
           0));
   ////////////////////////////////////////////////////////
   pnlUser.setDividerLocation(320);
   pnlUser.setLeftComponent(pnlManager);
   pnlUser.setRightComponent(pnlMessage);
   pnlUser.setOneTouchExpandable(true);
   ////////////////////////////////////////////////////////
   setOrientation(JSplitPane.VERTICAL_SPLIT);
   setOneTouchExpandable(true);
   pnlThread.setVisible(false);
   pnlUser.setVisible(false);
   setTopComponent(pnlThread);
   setBottomComponent(pnlUser);
   ////////////////////////////////////////////////////////
   pmn.add(mnuSelectAll);
   pmn.addSeparator();
   pmn.add(mnuClearSelected);
   pmn.add(mnuClearAll);
   ////////////////////////////////////////////////////////
   setBorder(BorderFactory.createEmptyBorder());
   pnlUser.setBorder(BorderFactory.createEmptyBorder());
   pnlManager.setBorder(
       BorderFactory.createBevelBorder(
           javax.swing.border.BevelBorder.RAISED,
           Color.white,
           UIManager.getColor("Panel.background"),
           UIManager.getColor("Panel.background"),
           UIManager.getColor("Panel.background")));
   pnlMessage.setBorder(
       BorderFactory.createBevelBorder(
           javax.swing.border.BevelBorder.RAISED,
           Color.white,
           UIManager.getColor("Panel.background"),
           UIManager.getColor("Panel.background"),
           UIManager.getColor("Panel.background")));
   ////////////////////////////////////////////////////////
   Skin.applySkin(mnuMain);
   Skin.applySkin(tblUser);
   Skin.applySkin(pmn);
   Skin.applySkin(this);
   ////////////////////////////////////////////////////////
   // Default setting
   ////////////////////////////////////////////////////////
   Hashtable prt = null;
   try {
     prt = Global.loadHashtable(Global.FILE_CONFIG);
   } catch (Exception e) {
     prt = new Hashtable();
   }
   changeLAF(Integer.parseInt(StringUtil.nvl(prt.get("LAF"), "0")));
   changeDictionary(StringUtil.nvl(prt.get("Language"), "VN"));
   Skin.LANGUAGE_CHANGE_LISTENER = this;
   MonitorProcessor.setRootObject(this);
   updateKeyboardUI();
   ////////////////////////////////////////////////////////
   // Event handler
   ////////////////////////////////////////////////////////
   tblUser.addMouseListener(
       new MouseAdapter() {
         public void mouseClicked(MouseEvent e) {
           if (e.getClickCount() > 1) btnKick.doClick();
         }
       });
   ////////////////////////////////////////////////////////
   btnRefresh.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent evt) {
           try {
             DDTP request = new DDTP();
             request.setRequestID(String.valueOf(System.currentTimeMillis()));
             DDTP response = channel.sendRequest("ThreadProcessor", "queryUserList", request);
             if (response != null) {
               tblUser.setData((Vector) response.getReturn());
               if (mstrChannel != null) removeUser(mstrChannel);
             }
           } catch (Exception e) {
             e.printStackTrace();
             MessageBox.showMessageDialog(pnlThread, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE);
           }
         }
       });
   ////////////////////////////////////////////////////////
   btnKick.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent evt) {
           int iSelected = tblUser.getSelectedRow();
           if (iSelected < 0) return;
           int iResult =
               MessageBox.showConfirmDialog(
                   pnlThread,
                   mdic.getString("ConfirmKick"),
                   Global.APP_NAME,
                   MessageBox.YES_NO_OPTION);
           if (iResult == MessageBox.NO_OPTION) return;
           try {
             String strChannel = (String) tblUser.getRow(iSelected).elementAt(0);
             DDTP request = new DDTP();
             request.setRequestID(String.valueOf(System.currentTimeMillis()));
             request.setString("strChannel", strChannel);
             DDTP response = channel.sendRequest("ThreadProcessor", "kickUser", request);
           } catch (Exception e) {
             e.printStackTrace();
             MessageBox.showMessageDialog(pnlThread, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE);
           }
         }
       });
   ////////////////////////////////////////////////////////
   txtMessage.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent evt) {
           btnSend.doClick();
         }
       });
   ////////////////////////////////////////////////////////
   btnSend.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent evt) {
           if (txtMessage.getText().length() == 0) return;
           try {
             DDTP request = new DDTP();
             request.setString("strMessage", txtMessage.getText());
             channel.sendRequest("ThreadProcessor", "sendMessage", request);
             txtMessage.setText("");
           } catch (Exception e) {
             e.printStackTrace();
             MessageBox.showMessageDialog(pnlThread, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE);
           }
         }
       });
   ////////////////////////////////////////////////////////
   mnuClearAll.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           clearAll(txtBoard);
         }
       });
   ////////////////////////////////////////////////////////
   mnuClearSelected.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           txtBoard.setEditable(true);
           txtBoard.replaceSelection("");
           txtBoard.setEditable(false);
         }
       });
   ////////////////////////////////////////////////////////
   mnuSelectAll.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           txtBoard.requestFocus();
           txtBoard.selectAll();
         }
       });
   ////////////////////////////////////////////////////////
   txtBoard.addMouseListener(
       new MouseAdapter() {
         public void mouseClicked(MouseEvent e) {
           if (e.getButton() == e.BUTTON3) pmn.show(txtBoard, e.getX(), e.getY());
         }
       });
   ////////////////////////////////////////////////////////
   mnuSystem_Login.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           login();
         }
       });
   ////////////////////////////////////////////////////////
   mnuSystem_ChangePassword.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           changePassword();
         }
       });
   ////////////////////////////////////////////////////////
   mnuSystem_StopServer.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           stopServer();
         }
       });
   ////////////////////////////////////////////////////////
   mnuSystem_EnableThreads.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           manageThreads();
         }
       });
   ////////////////////////////////////////////////////////
   mnuHelp_About.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           WindowManager.centeredWindow(new DialogAbout(PanelThreadManager.this));
         }
       });
   ////////////////////////////////////////////////////////
   chkVietnamese.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           switchKeyboard();
         }
       });
 }
  public AncestralStatesPanel(BeautiFrame parent) {

    super();

    this.frame = parent;

    partitionTableModel = new PartitionTableModel();
    partitionTable = new JTable(partitionTableModel);

    partitionTable.getTableHeader().setReorderingAllowed(false);
    partitionTable.getTableHeader().setResizingAllowed(false);
    //        modelTable.getTableHeader().setDefaultRenderer(
    //                new HeaderRenderer(SwingConstants.LEFT, new Insets(0, 4, 0, 4)));

    final TableColumnModel model = partitionTable.getColumnModel();
    final TableColumn tableColumn0 = model.getColumn(0);

    TableEditorStopper.ensureEditingStopWhenTableLosesFocus(partitionTable);

    partitionTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    partitionTable
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent evt) {
                selectionChanged();
              }
            });

    JScrollPane scrollPane =
        new JScrollPane(
            partitionTable,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setOpaque(false);

    JPanel panel = new JPanel(new BorderLayout(0, 0));
    panel.setOpaque(false);
    panel.add(scrollPane, BorderLayout.CENTER);
    panel.setMinimumSize(new Dimension(MINIMUM_TABLE_WIDTH, 0));

    optionsPanelParent = new JPanel(new FlowLayout(FlowLayout.CENTER));
    optionsPanelParent.setOpaque(false);
    optionsBorder = new TitledBorder("Ancestral state options:");
    optionsPanelParent.setBorder(optionsBorder);

    setCurrentPartition(null);

    JScrollPane scrollPane2 =
        new JScrollPane(
            optionsPanelParent,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane2.setOpaque(false);
    scrollPane2.setBorder(null);
    scrollPane2.getViewport().setOpaque(false);

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panel, scrollPane2);
    splitPane.setDividerLocation(MINIMUM_TABLE_WIDTH);
    splitPane.setContinuousLayout(true);
    splitPane.setBorder(BorderFactory.createEmptyBorder());
    splitPane.setOpaque(false);

    setOpaque(false);
    setBorder(new BorderUIResource.EmptyBorderUIResource(new Insets(12, 12, 12, 12)));
    setLayout(new BorderLayout(0, 0));
    add(splitPane, BorderLayout.CENTER);
  }
  /**
   * Instantiates a new movie information panel.
   *
   * @param movieSelectionModel the movie selection model
   */
  public MovieInformationPanel(MovieSelectionModel movieSelectionModel) {
    this.movieSelectionModel = movieSelectionModel;

    setLayout(
        new FormLayout(
            new ColumnSpec[] {
              ColumnSpec.decode("450px:grow"),
            },
            new RowSpec[] {
              RowSpec.decode("fill:default:grow"),
            }));

    splitPaneVertical = new JSplitPane();
    splitPaneVertical.setBorder(null);
    splitPaneVertical.setResizeWeight(0.9);
    splitPaneVertical.setContinuousLayout(true);
    splitPaneVertical.setOneTouchExpandable(true);
    splitPaneVertical.setOrientation(JSplitPane.VERTICAL_SPLIT);
    add(splitPaneVertical, "1, 1, fill, fill");

    panelTop = new JPanel();
    panelTop.setBorder(null);
    splitPaneVertical.setTopComponent(panelTop);
    panelTop.setLayout(
        new FormLayout(
            new ColumnSpec[] {
              FormFactory.RELATED_GAP_COLSPEC,
              ColumnSpec.decode("200px:grow"),
              FormFactory.RELATED_GAP_COLSPEC,
              FormFactory.DEFAULT_COLSPEC,
            },
            new RowSpec[] {
              RowSpec.decode("fill:default"), RowSpec.decode("top:pref:grow"),
            }));

    JPanel panelMovieHeader = new JPanel();
    panelTop.add(panelMovieHeader, "2, 1, 3, 1, fill, top");
    panelMovieHeader.setBorder(null);
    panelMovieHeader.setLayout(new BorderLayout(0, 0));

    JPanel panelMovieTitle = new JPanel();
    panelMovieHeader.add(panelMovieTitle, BorderLayout.NORTH);
    panelMovieTitle.setLayout(new BorderLayout(0, 0));
    lblMovieName = new JLabel("");
    TmmFontHelper.changeFont(lblMovieName, 1.33, Font.BOLD);
    panelMovieTitle.add(lblMovieName);

    JPanel panelRatingTagline = new JPanel();
    panelMovieHeader.add(panelRatingTagline, BorderLayout.CENTER);
    panelRatingTagline.setLayout(
        new FormLayout(
            new ColumnSpec[] {
              FormFactory.DEFAULT_COLSPEC,
              FormFactory.DEFAULT_COLSPEC,
              FormFactory.DEFAULT_COLSPEC,
              FormFactory.UNRELATED_GAP_COLSPEC,
              ColumnSpec.decode("25px:grow"),
            },
            new RowSpec[] {
              FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("24px"), FormFactory.DEFAULT_ROWSPEC,
            }));

    lblRating = new JLabel("");
    panelRatingTagline.add(lblRating, "2, 2, left, center");

    lblVoteCount = new JLabel("");
    panelRatingTagline.add(lblVoteCount, "3, 2, left, center");

    panelRatingStars = new StarRater(10, 1);
    panelRatingTagline.add(panelRatingStars, "1, 2, left, top");
    panelRatingStars.setEnabled(false);

    lblTop250 = new JLabel("");
    panelRatingTagline.add(lblTop250, "5, 2, left, default");

    lblTagline = new JLabel();
    panelRatingTagline.add(lblTagline, "1, 3, 5, 1, default, center");

    panelMovieLogos = new JPanel();
    panelMovieHeader.add(panelMovieLogos, BorderLayout.EAST);

    lblCertificationImage = new JLabel();
    panelMovieLogos.add(lblCertificationImage);

    JLayeredPane layeredPaneImages = new JLayeredPane();
    panelTop.add(layeredPaneImages, "1, 2, 4, 1, fill, fill");
    layeredPaneImages.setLayout(
        new FormLayout(
            new ColumnSpec[] {
              ColumnSpec.decode("max(10px;default)"),
              ColumnSpec.decode("left:120px:grow"),
              ColumnSpec.decode("default:grow(10)"),
            },
            new RowSpec[] {
              RowSpec.decode("max(10px;default)"),
              RowSpec.decode("top:180px:grow"),
              RowSpec.decode("fill:80px:grow(3)"),
            }));

    lblMovieBackground = new ImageLabel(false, true);
    lblMovieBackground.setAlternativeText(BUNDLE.getString("image.notfound.fanart")); // $NON-NLS-1$
    lblMovieBackground.enableLightbox();
    layeredPaneImages.add(lblMovieBackground, "1, 1, 3, 3, fill, fill");

    lblMoviePoster = new ImageLabel();
    lblMoviePoster.setAlternativeText(BUNDLE.getString("image.notfound.poster")); // $NON-NLS-1$
    lblMoviePoster.enableLightbox();
    layeredPaneImages.setLayer(lblMoviePoster, 1);
    layeredPaneImages.add(lblMoviePoster, "2, 2, fill, fill");

    lblWatchedImage = new JLabel();
    lblWatchedImage.setOpaque(false);
    layeredPaneImages.setLayer(lblWatchedImage, 2);
    layeredPaneImages.add(lblWatchedImage, "2, 2, left, top");

    JPanel panelGenres = new MovieGenresPanel(movieSelectionModel);
    layeredPaneImages.setLayer(panelGenres, 2);
    layeredPaneImages.add(panelGenres, "2, 2, 2, 2, right, bottom");

    JPanel panelLogos = new JPanel();
    panelLogos.setOpaque(false);
    layeredPaneImages.setLayer(panelLogos, 2);
    layeredPaneImages.add(panelLogos, "2, 2, 2, 2, right, top");
    panelLogos.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));

    lblMediaLogoResolution = new JLabel("");
    panelLogos.add(lblMediaLogoResolution);

    lblMediaLogoVideoCodec = new JLabel("");
    panelLogos.add(lblMediaLogoVideoCodec);

    lblMediaLogoAudio = new JLabel("");
    panelLogos.add(lblMediaLogoAudio);

    JPanel panelBottom = new JPanel();
    panelBottom.setLayout(
        new FormLayout(
            new ColumnSpec[] {
              ColumnSpec.decode("300px:grow"),
            },
            new RowSpec[] {
              FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("fill:min:grow"),
            }));

    tabbedPaneMovieDetails = new JTabbedPane(JTabbedPane.TOP);
    panelBottom.add(tabbedPaneMovieDetails, "1, 2, fill, fill");
    splitPaneVertical.setBottomComponent(panelBottom);

    panelDetails = new MovieDetailsPanel(movieSelectionModel);
    tabbedPaneMovieDetails.addTab(
        BUNDLE.getString("metatag.details"), null, panelDetails, null); // $NON-NLS-1$

    panelOverview = new JPanel();
    tabbedPaneMovieDetails.addTab(
        BUNDLE.getString("metatag.plot"), null, panelOverview, null); // $NON-NLS-1$
    panelOverview.setLayout(
        new FormLayout(
            new ColumnSpec[] {
              ColumnSpec.decode("200px:grow"),
            },
            new RowSpec[] {
              FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("fill:default:grow"),
            }));
    // panelMovieDetails.add(tabbedPaneMovieDetails, "2, 3, fill, fill");

    JScrollPane scrollPaneOverview = new JScrollPane();
    scrollPaneOverview.setBorder(null);
    panelOverview.add(scrollPaneOverview, "1, 2, fill, fill");

    tpOverview = new JTextPane();
    tpOverview.setOpaque(false);
    tpOverview.setEditable(false);
    scrollPaneOverview.setViewportView(tpOverview);

    panelMovieCrew = new MovieCrewPanel(movieSelectionModel);
    tabbedPaneMovieDetails.addTab(
        BUNDLE.getString("metatag.crew"), null, panelMovieCrew, null); // $NON-NLS-1$

    MovieActorPanel panelMovieActors = new MovieActorPanel(movieSelectionModel);
    tabbedPaneMovieDetails.addTab(
        BUNDLE.getString("metatag.cast"), null, panelMovieActors, null); // $NON-NLS-1$

    panelMediaInformation = new MovieMediaInformationPanel(movieSelectionModel);
    tabbedPaneMovieDetails.addTab(
        BUNDLE.getString("metatag.mediainformation"),
        null,
        panelMediaInformation,
        null); //$NON-NLS-1$

    panelMediaFiles = new MovieMediaFilesPanel(movieSelectionModel);
    tabbedPaneMovieDetails.addTab(
        BUNDLE.getString("metatag.mediafiles"), null, panelMediaFiles, null); // $NON-NLS-1$

    final List<MediaFile> mediaFiles = new ArrayList<MediaFile>();
    final ImagePanel panelArtwork = new ImagePanel(mediaFiles);
    tabbedPaneMovieDetails.addTab(
        BUNDLE.getString("metatag.artwork"), null, panelArtwork, null); // $NON-NLS-1$

    panelMovieTrailer = new MovieTrailerPanel(movieSelectionModel);
    tabbedPaneMovieDetails.addTab(
        BUNDLE.getString("metatag.trailer"), null, panelMovieTrailer, null); // $NON-NLS-1$

    // beansbinding init
    initDataBindings();

    // manual coded binding
    PropertyChangeListener propertyChangeListener =
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
            String property = propertyChangeEvent.getPropertyName();
            Object source = propertyChangeEvent.getSource();
            // react on selection of a movie and change of a movie
            if (source instanceof MovieSelectionModel
                || (source instanceof Movie && MEDIA_FILES.equals(property))) {
              Movie movie = null;
              if (source instanceof MovieSelectionModel) {
                movie = ((MovieSelectionModel) source).getSelectedMovie();
              }
              if (source instanceof Movie) {
                movie = (Movie) source;
              }

              if (movie != null) {
                if (movie.getTop250() > 0) {
                  lblTop250.setText("Top 250: #" + movie.getTop250());
                } else {
                  lblTop250.setText("");
                }
                lblMovieBackground.setImagePath(movie.getArtworkFilename(MediaFileType.FANART));
                lblMoviePoster.setImagePath(movie.getArtworkFilename(MediaFileType.POSTER));

                synchronized (mediaFiles) {
                  mediaFiles.clear();
                  for (MediaFile mediafile : movie.getMediaFiles()) {
                    if (mediafile.isGraphic()) {
                      mediaFiles.add(mediafile);
                    }
                  }
                  panelArtwork.rebuildPanel();
                }
              }
            }
            if ((source.getClass() == Movie.class && FANART.equals(property))) {
              Movie movie = (Movie) source;
              lblMovieBackground.clearImage();
              lblMovieBackground.setImagePath(movie.getArtworkFilename(MediaFileType.FANART));
            }
            if ((source.getClass() == Movie.class && POSTER.equals(property))) {
              Movie movie = (Movie) source;
              lblMoviePoster.clearImage();
              lblMoviePoster.setImagePath(movie.getArtworkFilename(MediaFileType.POSTER));
            }
            if ((source.getClass() == Movie.class && TOP250.equals(property))) {
              Movie movie = (Movie) source;
              if (movie.getTop250() > 0) {
                lblTop250.setText(
                    BUNDLE.getString("metatag.top250") + ": #" + movie.getTop250()); // $NON-NLS-1$
              } else {
                lblTop250.setText("");
              }
            }
          }
        };

    movieSelectionModel.addPropertyChangeListener(propertyChangeListener);
  }
  private void jbInit() throws Exception {
    border1 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151));
    border2 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151));
    border3 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(178, 178, 178));
    titledBorder1 = new TitledBorder(border3, "Subject");
    border4 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(178, 178, 178));
    titledBorder2 = new TitledBorder(border4, "Message");
    border5 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(178, 178, 178));
    titledBorder3 = new TitledBorder(border5, "Subject");
    border6 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151));
    titledBorder4 = new TitledBorder(border6, "Message");
    border7 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151));
    titledBorder5 = new TitledBorder(border7, "Messages");
    border8 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151));
    titledBorder6 = new TitledBorder(border8, "Online Users");
    border9 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(178, 178, 178));
    titledBorder7 = new TitledBorder(border9, "Send Message");
    this.getContentPane().setLayout(borderLayout1);
    jSplitPane1.setOrientation(JSplitPane.VERTICAL_SPLIT);
    jSplitPane1.setBorder(border1);
    jSplitPane1.setLastDividerLocation(250);
    jSplitPane1.setResizeWeight(1.0);
    jLabelServer.setRequestFocusEnabled(true);
    jLabelServer.setText("Server");
    jLabelUserId.setText("User Id");
    jTextFieldServer.setPreferredSize(new Dimension(75, 20));
    jTextFieldServer.setText("");
    jTextFieldUser.setPreferredSize(new Dimension(75, 20));
    jTextFieldUser.setText("");
    this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    this.setJMenuBar(jMenuBarMain);
    this.setTitle("Message Client");
    jLabeltargetUser.setText("Target");
    jTextFieldTargetUser.setPreferredSize(new Dimension(75, 20));
    jTextFieldTargetUser.setText("");
    jPanelSendMessages.setBorder(border2);
    jPanelSendMessages.setMaximumSize(new Dimension(32767, 32767));
    jPanelSendMessages.setOpaque(false);
    jPanelSendMessages.setPreferredSize(new Dimension(96, 107));
    jPanelSendMessages.setRequestFocusEnabled(true);
    jPanelSendMessages.setToolTipText("");
    jPanelSendMessages.setLayout(verticalFlowLayout1);
    jTextFieldSendSubject.setBorder(titledBorder3);
    jTextFieldSendSubject.setText("");
    jTextFieldSendSubject.addKeyListener(new Client_jTextFieldSendSubject_keyAdapter(this));
    jSplitPane2.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
    jScrollPane1.setBorder(titledBorder5);
    jScrollPane2.setBorder(titledBorder6);
    jToggleButtonRegister.setText("Register");
    jToggleButtonRegister.addActionListener(new Client_jToggleButtonRegister_actionAdapter(this));
    jButtonMultiConnect.setText("Multi-Connect");
    jButtonMultiConnect.addActionListener(new Client_jButtonMultiConnect_actionAdapter(this));
    jListOnlineUsers.addMouseListener(new Client_jListOnlineUsers_mouseAdapter(this));
    jToggleButtonConnect.setText("Connect");
    jToggleButtonConnect.addActionListener(new Client_jToggleButtonConnect_actionAdapter(this));
    jTextPaneDisplayMessages.setEditable(false);
    jTextPaneDisplayMessages.addMouseListener(
        new Client_jTextPaneDisplayMessages_mouseAdapter(this));
    jTextFieldSendMessages.setBorder(titledBorder7);
    jTextFieldSendMessages.setToolTipText("");
    jTextFieldSendMessages.addKeyListener(new Client_jTextFieldSendMessages_keyAdapter(this));
    jButtonMessageStresser.setText("Msg Stresser");
    jButtonMessageStresser.addActionListener(
        new Client_jToggleButtonMessageStresser_actionAdapter(this));
    jMenuItemClearMessages.setText("Clear Messages");
    jMenuItemClearMessages.addActionListener(new Client_jMenuItemClearMessages_actionAdapter(this));
    jMenuServer.setText("Server");
    jMenuItemServerConnect.setText("Connect");
    jMenuItemServerConnect.addActionListener(new Client_jMenuItemServerConnect_actionAdapter(this));
    jMenuItemServerDisconnect.setText("Disconnect");
    jMenuItemServerDisconnect.addActionListener(
        new Client_jMenuItemServerDisconnect_actionAdapter(this));
    jMenuOptions.setText("Options");
    jMenuTest.setText("Test");
    jMenuItemOptionsRegister.setText("Register");
    jMenuItemOptionsRegister.addActionListener(
        new Client_jMenuItemOptionsRegister_actionAdapter(this));
    jMenuItemOptionsDeregister.setText("Deregister");
    jMenuItemOptionsDeregister.addActionListener(
        new Client_jMenuItemOptionsDeregister_actionAdapter(this));
    jMenuItemOptionsEavesdrop.setText("Eavesdrop");
    jMenuItemOptionsEavesdrop.addActionListener(
        new Client_jMenuItemOptionsEavesdrop_actionAdapter(this));
    jMenuItemOptionsUneavesdrop.setText("Uneavesdrop");
    jMenuItemOptionsUneavesdrop.addActionListener(
        new Client_jMenuItemOptionsUneavesdrop_actionAdapter(this));
    jMenuItemTestMulticonnect.setText("Multiconnect");
    jMenuItemTestMulticonnect.addActionListener(
        new Client_jMenuItemTestMulticonnect_actionAdapter(this));
    jMenuItemTestMessageStresser.setText("Message Stresser");
    jMenuItemTestMessageStresser.addActionListener(
        new Client_jMenuItemTestMessageStresser_actionAdapter(this));
    jMenuItemTestMultidisconnect.setText("Multidisconnect");
    jMenuItemTestMultidisconnect.addActionListener(
        new Client_jMenuItemTestMultidisconnect_actionAdapter(this));
    jMenuItemOptionsGlobalEavesdrop.setText("Global Eavesdrop");
    jMenuItemOptionsGlobalEavesdrop.addActionListener(
        new Client_jMenuItemOptionsGlobalEavesdrop_actionAdapter(this));
    jMenuItemOptionsGlobalUneavesdrop.setEnabled(false);
    jMenuItemOptionsGlobalUneavesdrop.setText("Global Uneavesdrop");
    jMenuItemOptionsGlobalUneavesdrop.addActionListener(
        new Client_jMenuItemOptionsGlobalUneavesdrop_actionAdapter(this));
    jLabelPwd.setText("Pwd");
    jPasswordFieldPwd.setMinimumSize(new Dimension(11, 20));
    jPasswordFieldPwd.setPreferredSize(new Dimension(75, 20));
    jPasswordFieldPwd.setText("");
    jMenuItemScheduleCommand.setText("Schedule Command");
    jMenuItemScheduleCommand.addActionListener(
        new Client_jMenuItemScheduleCommand_actionAdapter(this));
    jMenuItemEditScheduledCommands.setText("Edit Scheduled Commands");
    jMenuItemEditScheduledCommands.addActionListener(
        new Client_jMenuItemEditScheduledCommands_actionAdapter(this));
    jPanelSendMessages.add(jTextFieldSendSubject, null);
    jPanelSendMessages.add(jTextFieldSendMessages, null);
    jSplitPane1.add(jSplitPane2, JSplitPane.TOP);
    jSplitPane2.add(jScrollPane1, JSplitPane.TOP);
    jScrollPane1.getViewport().add(jTextPaneDisplayMessages, null);
    jSplitPane2.add(jScrollPane2, JSplitPane.BOTTOM);
    jScrollPane2.getViewport().add(jListOnlineUsers, null);
    this.getContentPane().add(jSplitPane1, BorderLayout.CENTER);
    jSplitPane1.add(jPanelSendMessages, JSplitPane.BOTTOM);
    this.getContentPane().add(jPanel1, BorderLayout.NORTH);
    jPanel1.add(jLabelServer, null);
    jPanel1.add(jTextFieldServer, null);
    jPanel1.add(jLabelUserId, null);
    jPanel1.add(jTextFieldUser, null);
    jPanel1.add(jLabelPwd, null);
    jPanel1.add(jPasswordFieldPwd, null);
    jPanel1.add(jLabeltargetUser, null);
    jPanel1.add(jTextFieldTargetUser, null);
    jPanel1.add(jToggleButtonConnect, null);
    jPanel1.add(jToggleButtonRegister, null);
    jPanel1.add(jButtonMultiConnect, null);
    jPanel1.add(jButtonMessageStresser, null);
    jPopupMenuMessageArea.add(jMenuItemClearMessages);
    jMenuBarMain.add(jMenuServer);
    jMenuBarMain.add(jMenuOptions);
    jMenuBarMain.add(jMenuTest);
    jMenuServer.add(jMenuItemServerConnect);
    jMenuServer.add(jMenuItemServerDisconnect);
    jMenuOptions.add(jMenuItemOptionsRegister);
    jMenuOptions.add(jMenuItemOptionsDeregister);
    jMenuOptions.add(jMenuItemOptionsEavesdrop);
    jMenuOptions.add(jMenuItemOptionsUneavesdrop);
    jMenuOptions.add(jMenuItemOptionsGlobalEavesdrop);
    jMenuOptions.add(jMenuItemOptionsGlobalUneavesdrop);
    jMenuTest.add(jMenuItemTestMulticonnect);
    jMenuTest.add(jMenuItemTestMultidisconnect);
    jMenuTest.add(jMenuItemTestMessageStresser);
    jMenuTest.add(jMenuItemScheduleCommand);
    jMenuTest.add(jMenuItemEditScheduledCommands);
    jSplitPane1.setDividerLocation(200);
    jSplitPane2.setDividerLocation(600);
    jListOnlineUsers.setCellRenderer(new OnlineListCellRenderer());
    jListOnlineUsers.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    jMenuItemTestMulticonnect.setEnabled(true);
    jMenuItemTestMultidisconnect.setEnabled(false);
    jMenuItemServerConnect.setEnabled(true);
    jMenuItemServerDisconnect.setEnabled(false);
    jMenuItemOptionsRegister.setEnabled(true);
    jMenuItemOptionsDeregister.setEnabled(false);
  }
Beispiel #26
0
  /** Constructor - creates layout. */
  public HelpFrame() {
    setTitle("Web-Harvest Help");
    setIconImage(((ImageIcon) ResourceManager.HELP32_ICON).getImage());

    this.topNode = new DefaultMutableTreeNode();
    this.treeModel = new DefaultTreeModel(this.topNode);
    try {
      String helpContent = CommonUtil.readStringFromUrl(ResourceManager.getHelpContentUrl());
      XmlNode xmlNode = XmlParser.parse(new InputSource(new StringReader(helpContent)));
      createNodes(topNode, xmlNode);
    } catch (Exception e) {
      e.printStackTrace();
      GuiUtils.showErrorMessage("Error reading help content!");
    }

    tree = new JTree(topNode);
    tree.setRootVisible(false);
    tree.setShowsRootHandles(true);
    tree.setBorder(new EmptyBorder(5, 5, 5, 5));
    tree.setCellRenderer(
        new DefaultTreeCellRenderer() {
          public Component getTreeCellRendererComponent(
              JTree tree,
              Object value,
              boolean sel,
              boolean expanded,
              boolean leaf,
              int row,
              boolean hasFocus) {
            DefaultTreeCellRenderer renderer =
                (DefaultTreeCellRenderer)
                    super.getTreeCellRendererComponent(
                        tree, value, sel, expanded, leaf, row, hasFocus);
            if (value instanceof DefaultMutableTreeNode) {
              DefaultMutableTreeNode defaultMutableTreeNode = (DefaultMutableTreeNode) value;
              Object userObject = defaultMutableTreeNode.getUserObject();
              if (userObject instanceof TopicInfo) {
                TopicInfo topicInfo = (TopicInfo) userObject;
                renderer.setIcon(
                    topicInfo.subtopicCount == 0
                        ? ResourceManager.HELPTOPIC_ICON
                        : ResourceManager.HELPDIR_ICON);
              }
            }
            return renderer;
          }
        });
    tree.addTreeSelectionListener(this);

    htmlPane = new JEditorPane();
    htmlPane.setEditable(false);
    htmlPane.setContentType("text/html");
    htmlPane.setEditorKit(new HTMLEditorKit());
    htmlPane.setBorder(new EmptyBorder(5, 5, 5, 5));

    JSplitPane splitPane = new ProportionalSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    splitPane.setResizeWeight(0.0d);
    splitPane.setBorder(null);

    JScrollPane treeScrollPane = new WHScrollPane(tree);
    treeScrollPane.getViewport().setBackground(Color.white);
    treeScrollPane.setBackground(Color.white);
    splitPane.setLeftComponent(treeScrollPane);
    splitPane.setRightComponent(new WHScrollPane(htmlPane));
    splitPane.setDividerLocation(0.3d);

    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());
    contentPane.add(splitPane, BorderLayout.CENTER);

    pack();
  }
Beispiel #27
0
  public void initializeGUI() {
    setTitle(frameTitle);
    setSize(detailsFrameXsize, detailsFrameYsize);
    setLocation(detailsFrameXlocation, detailsFrameYlocation);
    treemodel = new DefaultTreeModel(new DefaultMutableTreeNode("LSM File Information"));
    detailsTree = new JTree(treemodel);
    detailsTree.putClientProperty("JTree.lineStyle", "Angled");
    detailsTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    detailsTree.setShowsRootHandles(true);
    tablemodel = new TreeTableModel();
    table = new JTable(tablemodel);
    table.setCellSelectionEnabled(true);
    JScrollPane treepane = new JScrollPane(detailsTree);
    JScrollPane detailspane = new JScrollPane(table);
    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treepane, detailspane);
    splitPane.setBorder(null);
    splitPane.setOneTouchExpandable(true);
    splitPane.setDividerLocation(300);
    Dimension minimumSize = new Dimension(WIDTH, HEIGHT - 50);
    treepane.setMinimumSize(minimumSize);
    detailspane.setMinimumSize(minimumSize);
    exitButton = new JButton(new ImageIcon(getClass().getResource("images/exit.png")));
    exitButton.setToolTipText("Close this window");
    searchButton = new JButton(new ImageIcon(getClass().getResource("images/find.png")));
    searchButton.setToolTipText("Find tag, property or value");
    filterButton = new JToggleButton(new ImageIcon(getClass().getResource("images/filter.png")));
    filterButton.setToolTipText("Filter unused tags");
    dumpButton = new JButton(new ImageIcon(getClass().getResource("images/dump.png")));
    dumpButton.setToolTipText("Dump data to textwindow, saving to text file is possible");
    xmlButton = new JButton(new ImageIcon(getClass().getResource("images/xml.png")));
    xmlButton.setToolTipText("Dump xml data to textwindow, saving to text file is possible");

    searchTF = new JTextField("");
    detailsTreePopupMenu = new JPopupMenu();
    expandAllItem =
        new JMenuItem("Expand all", new ImageIcon(getClass().getResource("images/plus.png")));
    collapseAllItem =
        new JMenuItem("Collapse all", new ImageIcon(getClass().getResource("images/minus.png")));
    filterCBItem =
        new JCheckBoxMenuItem(
            "Filtered", new ImageIcon(getClass().getResource("images/filter.png")));
    detailsTreePopupMenu.add(expandAllItem);
    detailsTreePopupMenu.add(collapseAllItem);
    detailsTreePopupMenu.add(new JSeparator());
    detailsTreePopupMenu.add(filterCBItem);
    detailsTreePopupMenu.setOpaque(true);
    detailsTree.add(detailsTreePopupMenu);
    detailsTree.setExpandsSelectedPaths(true);
    toolBar = new JToolBar();

    toolBar.add(exitButton);
    toolBar.add(dumpButton);
    toolBar.add(xmlButton);
    toolBar.add(filterButton);
    toolBar.add(new JSeparator());
    toolBar.add(new JLabel("  Search: "));
    toolBar.add(searchTF);
    toolBar.add(searchButton);

    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(toolBar, BorderLayout.NORTH);
    getContentPane().add(splitPane, BorderLayout.CENTER);
    // filterCBItem.setSelected(true);
    // filterButton.setSelected(true);
    pack();
    centerWindow();
    setListeners();
  }