Esempio n. 1
0
 private Action getRemoveClsAction() {
   return new AbstractAction("Remove Cls", Icons.getRemoveIcon()) {
     public void actionPerformed(ActionEvent event) {
       removeInstance();
     }
   };
 }
Esempio n. 2
0
  private Bitmap loadDrawable(String fso) {
    final String filePath = (fso);

    try {
      if (Icons.isApk(filePath)) {
        return getAppDrawable(fso);
      } else if (Icons.isPicture(filePath)) {
        return loadImage(fso);
      } else if (Icons.isVideo(filePath)) return getVideoDrawable(fso);
    } catch (OutOfMemoryError outOfMemoryError) {
      cleanup();
      shutdownWorker();
    }

    return null;
  }
Esempio n. 3
0
 /** View the instance. */
 private Action getViewClsAction() {
   return new AbstractAction("View Cls", Icons.getViewIcon()) {
     public void actionPerformed(ActionEvent event) {
       viewObject();
     }
   };
 }
Esempio n. 4
0
  public static GameAbstract create(int gameCode) throws Exception {
    GameAbstract game = null;

    switch (gameCode) {
        /** Game 4x4 */
      case CUBE4_GAME:
        game = new CubeGame(4);
        break;

        /** Game 3x3 */
      case CUBE3_GAME:
        game = new CubeGame(3);
        break;

        /** Standard */
      case STANDARD_GAME:
        game = new StandardGame(3);
        break;

        /** If type of game is not found, then throws exception */
      default:
        throw new Exception("Wrong type of game");
    }

    /** Add created game to collection */
    getCollection().add(game);

    /** @TODO refactor */
    game.getFrame().setTitle(game.getFrame().getTitle() + ' ' + getCollection().getSize());

    HumanPlayer player1 =
        PlayerCollection.getPlayer(
            (Integer) Workarea.getInstance().getConfigurationHash().get("player1"));
    player1.setIcon(Icons.get("cross-lines"));
    player1.setReady(false);
    game.setPlayer(player1);

    HumanPlayer player2 =
        PlayerCollection.getPlayer(
            (Integer) Workarea.getInstance().getConfigurationHash().get("player2"));
    player2.setIcon(Icons.get("circle"));
    game.setPlayer(player2);

    game.move();

    return game;
  }
Esempio n. 5
0
  /** Get Select(+) Instance Action. */
  private Action getSelectClsAction() {
    return new AbstractAction("Select Cls", Icons.getAddIcon()) {
      public void actionPerformed(ActionEvent event) {

        if (instanceSlot == null) instanceSlot = getSlot();
        if (instanceSlot == null) return;
        Collection clses = instanceSlot.getAllowedParents();
        Instance instance = DisplayUtilities.pickCls(itsComp, getKB(), clses);

        if (instance != null) {
          setDisplayedInstance(instance);
          itsInstance = instance;
        }
        setActionsEnabled(true);
      }
    };
  }
Esempio n. 6
0
  public ThemisGui() {
    super();
    undoableEditSupport = new UndoableEditSupport(this);

    readConf(getClass().getClassLoader().getResource("conf/Themis.xml"));

    GridBagLayout gridBagLayout = new GridBagLayout();
    gridBagLayout.columnWidths = new int[] {100, 100, 0, 0, 0, 0, 0, 0};
    gridBagLayout.rowHeights = new int[] {60, 0, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    gridBagLayout.columnWeights =
        new double[] {1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
    gridBagLayout.rowWeights =
        new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE};
    setLayout(gridBagLayout);

    JPanel panel_3 = new JPanel();
    GridBagConstraints gbc_panel_3 = new GridBagConstraints();
    gbc_panel_3.anchor = GridBagConstraints.WEST;
    gbc_panel_3.fill = GridBagConstraints.VERTICAL;
    gbc_panel_3.insets = new Insets(0, 0, 5, 5);
    gbc_panel_3.gridx = 0;
    gbc_panel_3.gridy = 0;
    add(panel_3, gbc_panel_3);

    JLabel lblDataSelection = new JLabel("Data Selection:");
    panel_3.add(lblDataSelection);

    JPanel panel = new JPanel();
    GridBagConstraints gbc_panel = new GridBagConstraints();
    gbc_panel.fill = GridBagConstraints.BOTH;
    gbc_panel.insets = new Insets(0, 0, 5, 5);
    gbc_panel.gridx = 0;
    gbc_panel.gridy = 0;
    add(panel, gbc_panel);

    JScrollPane scrollPane = new JScrollPane();
    panel.add(scrollPane);

    JPanel panel_4 = new JPanel();
    GridBagConstraints gbc_panel_4 = new GridBagConstraints();
    gbc_panel_4.fill = GridBagConstraints.BOTH;
    gbc_panel_4.insets = new Insets(0, 0, 5, 5);
    gbc_panel_4.gridx = 0;
    gbc_panel_4.gridy = 0;
    add(panel_4, gbc_panel_4);

    JPanel panel_5 = new JPanel();
    GridBagConstraints gbc_panel_5 = new GridBagConstraints();
    gbc_panel_5.fill = GridBagConstraints.BOTH;
    gbc_panel_5.insets = new Insets(0, 0, 5, 5);
    gbc_panel_5.gridx = 0;
    gbc_panel_5.gridy = 0;
    add(panel_5, gbc_panel_5);

    JLabel lblDataLoaded = new JLabel("Data Loaded:");
    panel_5.add(lblDataLoaded);

    JPanel panel_1 = new JPanel();
    GridBagConstraints gbc_panel_1 = new GridBagConstraints();
    gbc_panel_1.fill = GridBagConstraints.BOTH;
    gbc_panel_1.insets = new Insets(0, 0, 5, 5);
    gbc_panel_1.gridx = 0;
    gbc_panel_1.gridy = 0;
    add(panel_1, gbc_panel_1);
    FlowLayout fl_panel_1 = new FlowLayout(FlowLayout.CENTER, 5, 5);
    fl_panel_1.setAlignOnBaseline(true);
    panel_1.setLayout(fl_panel_1);

    JLabel lblInstrumentType = new JLabel("Instrument Type:");
    GridBagConstraints gbc_lblInstrumentType = new GridBagConstraints();
    gbc_lblInstrumentType.anchor = GridBagConstraints.WEST;
    gbc_lblInstrumentType.insets = new Insets(0, 0, 5, 5);
    gbc_lblInstrumentType.gridx = 0;
    gbc_lblInstrumentType.gridy = 1;
    add(lblInstrumentType, gbc_lblInstrumentType);

    String[] hoge = getInstrumentTypes();
    JComboBox comboBox = new JComboBox(hoge);
    GridBagConstraints gbc_comboBox = new GridBagConstraints();
    gbc_comboBox.insets = new Insets(0, 0, 5, 5);
    gbc_comboBox.fill = GridBagConstraints.HORIZONTAL;
    gbc_comboBox.gridx = 1;
    gbc_comboBox.gridy = 1;
    add(comboBox, gbc_comboBox);

    JLabel lblOutputCoordinates = new JLabel("Output Coordinates:");
    GridBagConstraints gbc_lblOutputCoordinates = new GridBagConstraints();
    gbc_lblOutputCoordinates.anchor = GridBagConstraints.EAST;
    gbc_lblOutputCoordinates.insets = new Insets(0, 0, 5, 5);
    gbc_lblOutputCoordinates.gridx = 3;
    gbc_lblOutputCoordinates.gridy = 1;
    add(lblOutputCoordinates, gbc_lblOutputCoordinates);

    String[] str = getOutputCoordinates();
    JComboBox comboBox_1 = new JComboBox(str);
    GridBagConstraints gbc_comboBox_1 = new GridBagConstraints();
    gbc_comboBox_1.insets = new Insets(0, 0, 5, 5);
    gbc_comboBox_1.fill = GridBagConstraints.HORIZONTAL;
    gbc_comboBox_1.gridx = 4;
    gbc_comboBox_1.gridy = 1;
    add(comboBox_1, gbc_comboBox_1);

    JPanel panel_2 = new JPanel();
    GridBagConstraints gbc_panel_2 = new GridBagConstraints();
    gbc_panel_2.insets = new Insets(0, 0, 5, 5);
    gbc_panel_2.fill = GridBagConstraints.BOTH;
    gbc_panel_2.gridx = 0;
    gbc_panel_2.gridy = 2;
    add(panel_2, gbc_panel_2);
    panel_2.setLayout(new GridLayout(0, 1, 0, 0));

    JLabel lblStartTime = new JLabel("Start Time:");
    panel_2.add(lblStartTime);

    JLabel label = new JLabel("");
    panel_2.add(label);

    JLabel label_1 = new JLabel("");
    panel_2.add(label_1);

    JLabel label_2 = new JLabel("");
    panel_2.add(label_2);

    JLabel label_3 = new JLabel("");
    panel_2.add(label_3);

    JLabel label_4 = new JLabel("");
    panel_2.add(label_4);

    JLabel label_5 = new JLabel("");
    panel_2.add(label_5);

    JLabel label_6 = new JLabel("");
    panel_2.add(label_6);

    JLabel lblDataLoaded_2 = new JLabel("Data Loaded:");
    GridBagConstraints gbc_lblDataLoaded_2 = new GridBagConstraints();
    gbc_lblDataLoaded_2.anchor = GridBagConstraints.WEST;
    gbc_lblDataLoaded_2.insets = new Insets(0, 0, 5, 0);
    gbc_lblDataLoaded_2.gridx = 6;
    gbc_lblDataLoaded_2.gridy = 0;
    add(lblDataLoaded_2, gbc_lblDataLoaded_2);

    textField_1 = new JTextField(getStartTime());
    GridBagConstraints gbc_textField_1 = new GridBagConstraints();
    gbc_textField_1.insets = new Insets(0, 0, 5, 5);
    gbc_textField_1.gridx = 1;
    gbc_textField_1.gridy = 2;
    add(textField_1, gbc_textField_1);
    // textField.setText("2007-03-23/00:00:00");
    textField_1.setColumns(10);

    JButton btnMyCalendar_1 = new JButton("");
    btnMyCalendar_1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            System.out.println("Start Time");
            MyCalendar calendar = new MyCalendar();
            calendar.setLocationRelativeTo(null);
            calendar.setVisible(true);
          }
        });
    GridBagConstraints gbc_btnMyCalendar_1 = new GridBagConstraints();
    gbc_btnMyCalendar_1.insets = new Insets(0, 0, 5, 5);
    gbc_btnMyCalendar_1.gridx = 2;
    gbc_btnMyCalendar_1.gridy = 2;
    add(btnMyCalendar_1, gbc_btnMyCalendar_1);
    Icons icons = new Icons();
    btnMyCalendar_1.setIcon(icons.getImageIcon("icons/calendar-alt-1-20.png"));

    chckbxUseSingleDay = new JCheckBox("Use Single Day");
    chckbxUseSingleDay.setSelected(true);
    GridBagConstraints gbc_chckbxUseSingleDay = new GridBagConstraints();
    gbc_chckbxUseSingleDay.anchor = GridBagConstraints.WEST;
    gbc_chckbxUseSingleDay.insets = new Insets(0, 0, 5, 5);
    gbc_chckbxUseSingleDay.gridx = 1;
    gbc_chckbxUseSingleDay.gridy = 4;
    add(chckbxUseSingleDay, gbc_chckbxUseSingleDay);

    JLabel lblStopTime_1 = new JLabel("Stop Time:");
    GridBagConstraints gbc_lblStopTime_1 = new GridBagConstraints();
    gbc_lblStopTime_1.anchor = GridBagConstraints.EAST;
    gbc_lblStopTime_1.insets = new Insets(0, 0, 5, 5);
    gbc_lblStopTime_1.gridx = 0;
    gbc_lblStopTime_1.gridy = 3;
    add(lblStopTime_1, gbc_lblStopTime_1);
    if (chckbxUseSingleDay.isSelected()) {
      lblStopTime_1.setEnabled(false);
    }

    textField_2 = new JTextField(getStopTime());
    // textField_2.setText("2007-03-24/00:00:00");
    GridBagConstraints gbc_textField_2 = new GridBagConstraints();
    gbc_textField_2.insets = new Insets(0, 0, 5, 5);
    gbc_textField_2.fill = GridBagConstraints.HORIZONTAL;
    gbc_textField_2.gridx = 1;
    gbc_textField_2.gridy = 3;
    add(textField_2, gbc_textField_2);
    textField_2.setColumns(10);
    if (chckbxUseSingleDay.isSelected()) {
      textField_2.setEnabled(false);
    }

    JButton btnMyCalendar_2 = new JButton("");
    btnMyCalendar_2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            System.out.println("Stop Time");
            MyCalendar calendar = new MyCalendar();
            calendar.setLocationRelativeTo(null);
            calendar.setVisible(true);
          }
        });
    GridBagConstraints gbc_btnMyCalendar_2 = new GridBagConstraints();
    gbc_btnMyCalendar_2.insets = new Insets(0, 0, 5, 5);
    gbc_btnMyCalendar_2.gridx = 2;
    gbc_btnMyCalendar_2.gridy = 3;
    add(btnMyCalendar_2, gbc_btnMyCalendar_2);
    /*		btnMyCalendar_2.setIcon(new ImageIcon(ThemisGui.class
    .getResource("/calendar-alt-1-20.png")));*/
    if (chckbxUseSingleDay.isSelected()) {
      btnMyCalendar_2.setEnabled(false);
    }

    JLabel label_7 = new JLabel("");
    GridBagConstraints gbc_label_7 = new GridBagConstraints();
    gbc_label_7.insets = new Insets(0, 0, 5, 5);
    gbc_label_7.gridx = 1;
    gbc_label_7.gridy = 5;
    add(label_7, gbc_label_7);

    JLabel lblAllskyGroundStation = new JLabel("All-Sky Ground Station:");
    GridBagConstraints gbc_lblAllskyGroundStation = new GridBagConstraints();
    gbc_lblAllskyGroundStation.anchor = GridBagConstraints.WEST;
    gbc_lblAllskyGroundStation.insets = new Insets(0, 0, 5, 5);
    gbc_lblAllskyGroundStation.gridx = 0;
    gbc_lblAllskyGroundStation.gridy = 8;
    add(lblAllskyGroundStation, gbc_lblAllskyGroundStation);

    JLabel lblLevel = new JLabel("Level 1:");
    GridBagConstraints gbc_lblLevel = new GridBagConstraints();
    gbc_lblLevel.insets = new Insets(0, 0, 5, 5);
    gbc_lblLevel.gridx = 1;
    gbc_lblLevel.gridy = 8;
    add(lblLevel, gbc_lblLevel);

    JLabel lblLevel_1 = new JLabel("Level 2:");
    GridBagConstraints gbc_lblLevel_1 = new GridBagConstraints();
    gbc_lblLevel_1.insets = new Insets(0, 0, 5, 5);
    gbc_lblLevel_1.gridx = 3;
    gbc_lblLevel_1.gridy = 8;
    add(lblLevel_1, gbc_lblLevel_1);

    JList list = new JList();
    GridBagConstraints gbc_list = new GridBagConstraints();
    gbc_list.insets = new Insets(0, 0, 5, 5);
    gbc_list.fill = GridBagConstraints.BOTH;
    gbc_list.gridx = 0;
    gbc_list.gridy = 7;
    add(list, gbc_list);

    // JList list_1 = new JList();
    JList list_1 = getList0();
    GridBagConstraints gbc_list_1 = new GridBagConstraints();
    gbc_list_1.insets = new Insets(0, 0, 5, 5);
    gbc_list_1.fill = GridBagConstraints.BOTH;
    gbc_list_1.gridx = 0;
    gbc_list_1.gridy = 9;
    add(list_1, gbc_list_1);

    JList list_2 = getList1();
    GridBagConstraints gbc_list_2 = new GridBagConstraints();
    gbc_list_2.insets = new Insets(0, 0, 5, 5);
    gbc_list_2.fill = GridBagConstraints.BOTH;
    gbc_list_2.gridx = 1;
    gbc_list_2.gridy = 9;
    add(list_2, gbc_list_2);

    JList list_3 = getList2();
    GridBagConstraints gbc_list_3 = new GridBagConstraints();
    gbc_list_3.insets = new Insets(0, 0, 5, 5);
    gbc_list_3.fill = GridBagConstraints.BOTH;
    gbc_list_3.gridx = 3;
    gbc_list_3.gridy = 9;
    add(list_3, gbc_list_3);

    JButton button = new JButton("");
    /*		button.setIcon(new ImageIcon(ThemisGui.class
    .getResource("/arrow-1-right20.png")));*/
    GridBagConstraints gbc_button = new GridBagConstraints();
    gbc_button.insets = new Insets(0, 0, 5, 5);
    gbc_button.gridx = 5;
    gbc_button.gridy = 9;
    add(button, gbc_button);

    JButton btnClearProbestation = new JButton("Clear Probe/Station");
    btnClearProbestation.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {}
        });
    GridBagConstraints gbc_btnClearProbestation = new GridBagConstraints();
    gbc_btnClearProbestation.insets = new Insets(0, 0, 0, 5);
    gbc_btnClearProbestation.gridx = 0;
    gbc_btnClearProbestation.gridy = 10;
    add(btnClearProbestation, gbc_btnClearProbestation);

    JButton btnClearDataType = new JButton("Clear Data Type");
    GridBagConstraints gbc_btnClearDataType = new GridBagConstraints();
    gbc_btnClearDataType.insets = new Insets(0, 0, 0, 5);
    gbc_btnClearDataType.gridx = 3;
    gbc_btnClearDataType.gridy = 10;
    add(btnClearDataType, gbc_btnClearDataType);

    JButton btnNewButton_2 = new JButton("");
    /*		btnNewButton_2.setIcon(new ImageIcon(ThemisGui.class
    .getResource("/trash-empty20.png")));*/
    GridBagConstraints gbc_btnNewButton_2 = new GridBagConstraints();
    gbc_btnNewButton_2.insets = new Insets(0, 0, 0, 5);
    gbc_btnNewButton_2.gridx = 5;
    gbc_btnNewButton_2.gridy = 10;
    add(btnNewButton_2, gbc_btnNewButton_2);

    JButton btnDeleteAllData = new JButton("Delete All Data");
    GridBagConstraints gbc_btnDeleteAllData = new GridBagConstraints();
    gbc_btnDeleteAllData.gridx = 6;
    gbc_btnDeleteAllData.gridy = 10;
    add(btnDeleteAllData, gbc_btnDeleteAllData);
  }
Esempio n. 7
0
 public Action_AddInstance(InstanceTableWidget widget) {
   super((widget.getState()).getAddInstanceButtonTooltip(), Icons.getAddIcon());
   _widget = widget;
   _dialogTitle = (widget.getState()).getAddInstanceDialogTitle();
 }
Esempio n. 8
0
/**
 * An IssueBrowser is a program for finding and viewing issues.
 *
 * @author <a href="mailto:[email protected]">Jesse Wilson</a>
 */
public class IssuesBrowser implements Runnable {

  /** application appearance */
  public static final Color GLAZED_LISTS_DARK_BROWN = new Color(36, 23, 10);

  public static final Color GLAZED_LISTS_MEDIUM_BROWN = new Color(69, 64, 56);
  public static final Color GLAZED_LISTS_MEDIUM_LIGHT_BROWN = new Color(150, 140, 130);
  public static final Color GLAZED_LISTS_LIGHT_BROWN = new Color(246, 237, 220);
  public static final Color GLAZED_LISTS_LIGHT_BROWN_DARKER = new Color(231, 222, 205);
  public static final Icon THROBBER_ACTIVE = loadIcon("resources/throbber-active.gif");
  public static final Icon THROBBER_STATIC = loadIcon("resources/throbber-static.gif");
  public static final Icon EXPANDED_ICON =
      Icons.triangle(9, SwingConstants.EAST, GLAZED_LISTS_MEDIUM_LIGHT_BROWN);
  public static final Icon COLLAPSED_ICON =
      Icons.triangle(9, SwingConstants.SOUTH, GLAZED_LISTS_MEDIUM_LIGHT_BROWN);
  public static final Icon X_ICON = Icons.x(10, 5, GLAZED_LISTS_MEDIUM_LIGHT_BROWN);
  public static final Border EMPTY_ONE_PIXEL_BORDER = BorderFactory.createEmptyBorder(1, 1, 1, 1);
  public static final Border EMPTY_TWO_PIXEL_BORDER = BorderFactory.createEmptyBorder(2, 2, 2, 2);

  /** an event list to host the issues */
  private EventList<Issue> issuesEventList = new BasicEventList<Issue>();

  /** all the filters currently applied to the issues list */
  private FilterPanel filterPanel = new FilterPanel(issuesEventList);

  /** the currently selected issues */
  private AdvancedListSelectionModel<Issue> issuesSelectionModel;

  /** the TableModel containing the filtered and sorted issues */
  private AdvancedTableModel<Issue> issuesTableModel;

  /** the currently selected issue for which the details are displayed */
  private Issue descriptionIssue;

  /** the component that displays the details of the selected issue, if any */
  private IssueDetailsComponent issueDetails;

  /** monitor loading the issues */
  private JLabel throbber;

  /** a label to display the count of issues in the issue table */
  private IssueCounterLabel issueCounter;

  /** loads issues as requested */
  private IssueLoader issueLoader;

  /** the application window */
  private JFrame frame;

  /** things to handle when booting the issues loader */
  private String[] startupArgs;

  /** Tell the IssuesBrowser how to configure itself when starting up. */
  public void setStartupArgs(String[] startupArgs) {
    this.startupArgs = startupArgs;
  }

  /** Loads the issues browser as standalone application. */
  public void run() {
    constructStandalone();

    // we have advice for the user when we cannot connect to a host
    Exceptions.getInstance().addHandler(ExceptionHandlerFactory.unknownHostExceptionHandler(frame));
    Exceptions.getInstance().addHandler(ExceptionHandlerFactory.connectExceptionHandler(frame));
    Exceptions.getInstance()
        .addHandler(ExceptionHandlerFactory.noRouteToHostExceptionHandler(frame));
    Exceptions.getInstance()
        .addHandler(ExceptionHandlerFactory.accessControlExceptionHandler(frame));
    Exceptions.getInstance().addHandler(ExceptionHandlerFactory.ioExceptionCode500Handler(frame));

    // create the issue loader and start loading issues
    issueLoader =
        new IssueLoader(
            issuesEventList, new IndeterminateToggler(throbber, THROBBER_ACTIVE, THROBBER_STATIC));
    issueLoader.start();

    // load issues from a file if requested
    if (startupArgs.length == 1) {
      issueLoader.setFileName(startupArgs[0]);
    }
  }

  /** Load the specified icon from the pathname on the classpath. */
  private static ImageIcon loadIcon(String pathname) {
    ClassLoader jarLoader = IssuesBrowser.class.getClassLoader();
    URL url = jarLoader.getResource(pathname);
    if (url == null) return null;
    return new ImageIcon(url);
  }

  /** Constructs the browser as a standalone frame. */
  private void constructStandalone() {
    frame = new JFrame("Issues");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(1024, 600);
    frame.setLocationRelativeTo(null);
    frame.getContentPane().setLayout(new BorderLayout());
    frame.getContentPane().add(constructView(), BorderLayout.CENTER);
    frame.setVisible(true);
  }

  /** Display a frame for browsing issues. */
  private JPanel constructView() {
    // sort the original issues list
    final SortedList<Issue> issuesSortedList = new SortedList<Issue>(issuesEventList, null);

    // filter the sorted issues
    FilterList<Issue> filteredIssues =
        new FilterList<Issue>(issuesSortedList, filterPanel.getMatcherEditor());

    SeparatorList<Issue> separatedIssues =
        new SeparatorList<Issue>(
            filteredIssues,
            GlazedLists.beanPropertyComparator(Issue.class, "subcomponent"),
            0,
            Integer.MAX_VALUE);
    EventList<Issue> separatedIssuesProxyList =
        GlazedListsSwing.swingThreadProxyList(separatedIssues);
    // build the issues table
    issuesTableModel =
        GlazedListsSwing.eventTableModel(separatedIssuesProxyList, new IssueTableFormat());
    final TableColumnModel issuesTableColumnModel =
        new EventTableColumnModel<TableColumn>(new BasicEventList<TableColumn>());
    JSeparatorTable issuesJTable = new JSeparatorTable(issuesTableModel, issuesTableColumnModel);
    issuesJTable.setAutoCreateColumnsFromModel(true);

    issuesJTable.setSeparatorRenderer(new IssueSeparatorTableCell(separatedIssues));
    issuesJTable.setSeparatorEditor(new IssueSeparatorTableCell(separatedIssues));
    issuesSelectionModel = GlazedListsSwing.eventSelectionModel(separatedIssuesProxyList);
    issuesSelectionModel.setSelectionMode(
        ListSelection
            .MULTIPLE_INTERVAL_SELECTION_DEFENSIVE); // multi-selection best demos our awesome
                                                     // selection management
    issuesSelectionModel.addListSelectionListener(new IssuesSelectionListener());
    issuesJTable.setSelectionModel(issuesSelectionModel);
    issuesJTable.getColumnModel().getColumn(0).setPreferredWidth(150);
    issuesJTable.getColumnModel().getColumn(1).setPreferredWidth(400);
    issuesJTable.getColumnModel().getColumn(2).setPreferredWidth(300);
    issuesJTable.getColumnModel().getColumn(3).setPreferredWidth(300);
    issuesJTable.getColumnModel().getColumn(4).setPreferredWidth(250);
    issuesJTable.getColumnModel().getColumn(5).setPreferredWidth(300);
    issuesJTable.getColumnModel().getColumn(6).setPreferredWidth(300);
    issuesJTable.getColumnModel().getColumn(7).setPreferredWidth(1000);
    // turn off cell focus painting
    issuesJTable.setDefaultRenderer(
        String.class, new NoFocusRenderer(issuesJTable.getDefaultRenderer(String.class)));
    issuesJTable.setDefaultRenderer(
        Integer.class, new NoFocusRenderer(issuesJTable.getDefaultRenderer(Integer.class)));
    issuesJTable.setDefaultRenderer(
        Priority.class, new NoFocusRenderer(new PriorityTableCellRenderer()));
    LookAndFeelTweaks.tweakTable(issuesJTable);
    TableComparatorChooser.install(
        issuesJTable, issuesSortedList, TableComparatorChooser.MULTIPLE_COLUMN_KEYBOARD);
    JScrollPane issuesTableScrollPane =
        new JScrollPane(
            issuesJTable,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    issuesTableScrollPane.getViewport().setBackground(UIManager.getColor("EditorPane.background"));
    issuesTableScrollPane.setBorder(BorderFactory.createEmptyBorder());

    issueDetails = new IssueDetailsComponent(filteredIssues);

    // projects
    EventList<Project> projects = Project.getProjects();
    TransformedList<Project, Project> projectsProxyList =
        GlazedListsSwing.swingThreadProxyList(projects);
    // project select combobox
    DefaultEventComboBoxModel projectsComboModel =
        new DefaultEventComboBoxModel<Project>(projectsProxyList);
    JComboBox projectsCombo = new JComboBox(projectsComboModel);
    projectsCombo.setEditable(false);
    projectsCombo.setOpaque(false);
    projectsCombo.addItemListener(new ProjectChangeListener());
    projectsComboModel.setSelectedItem(new Project(null, "Select a Java.net project..."));

    // build a label to display the number of issues in the issue table
    issueCounter = new IssueCounterLabel(filteredIssues);
    issueCounter.setHorizontalAlignment(SwingConstants.CENTER);
    issueCounter.setForeground(Color.WHITE);

    // throbber
    throbber = new JLabel(THROBBER_STATIC);
    throbber.setHorizontalAlignment(SwingConstants.RIGHT);

    // header bar
    JPanel iconBar = new GradientPanel(GLAZED_LISTS_MEDIUM_BROWN, GLAZED_LISTS_DARK_BROWN, true);
    iconBar.setLayout(new GridLayout(1, 3));
    iconBar.add(projectsCombo);
    iconBar.add(issueCounter);
    iconBar.add(throbber);
    iconBar.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    // assemble all data components on a common panel
    JPanel dataPanel = new JPanel();
    JComponent issueDetailsComponent = issueDetails;
    dataPanel.setLayout(new GridLayout(2, 1));
    dataPanel.add(issuesTableScrollPane);
    dataPanel.add(issueDetailsComponent);

    // draw lines between components
    JComponent filtersPanel = filterPanel.getComponent();
    filtersPanel.setBorder(BorderFactory.createEmptyBorder());
    // filtersPanel.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1,
    // IssuesBrowser.GLAZED_LISTS_DARK_BROWN));
    issueDetailsComponent.setBorder(
        BorderFactory.createMatteBorder(1, 0, 0, 0, GLAZED_LISTS_DARK_BROWN));

    // the outermost panel to layout the icon bar with the other panels
    final JPanel mainPanel = new JPanel(new GridBagLayout());
    mainPanel.add(
        iconBar,
        new GridBagConstraints(
            0,
            0,
            2,
            1,
            1.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));
    mainPanel.add(
        filtersPanel,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            0.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));
    mainPanel.add(
        Box.createHorizontalStrut(240),
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));
    mainPanel.add(
        dataPanel,
        new GridBagConstraints(
            1,
            1,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));

    return mainPanel;
  }

  /** Listens for changes in the selection on the issues table. */
  class IssuesSelectionListener implements ListSelectionListener {
    public void valueChanged(ListSelectionEvent e) {
      // get the newly selected issue
      Issue selectedIssue = null;
      if (issuesSelectionModel.getSelected().size() > 0) {
        Object selectedObject = issuesSelectionModel.getSelected().get(0);
        if (selectedObject instanceof Issue) {
          selectedIssue = (Issue) selectedObject;
        }
      }

      // update the description issue
      if (selectedIssue == descriptionIssue) return;
      descriptionIssue = selectedIssue;
      issueDetails.setIssue(descriptionIssue);
    }
  }

  /** Listens for changes to the project combo box and updates which project is being loaded. */
  class ProjectChangeListener implements ItemListener {
    public void itemStateChanged(ItemEvent e) {
      if (e.getStateChange() != ItemEvent.SELECTED) return;

      final Project selectedProject = (Project) e.getItem();
      if (selectedProject.isValid()) issueLoader.setProject(selectedProject);
    }
  }

  /** When started via a main method, this creates a standalone issues browser. */
  public static void main(final String[] args) {
    SwingUtilities.invokeLater(new IssuesBrowserStarter(args));
  }

  /**
   * This Runnable contains the logic to start the IssuesBrowser application. It is guaranteed to be
   * executed on the EventDispatch Thread.
   */
  private static class IssuesBrowserStarter implements Runnable {
    private final String[] args;

    public IssuesBrowserStarter(String[] args) {
      this.args = args;
    }

    public void run() {
      try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
      } catch (Exception e) {
        // do nothing - fall back to default look and feel
      }

      // load the issues and display the browser
      final IssuesBrowser browser = new IssuesBrowser();
      browser.setStartupArgs(args);
      browser.run();
    }
  }

  /**
   * A custom label designed for displaying the number of issues in the issue table. Use {@link
   * #setIssueCount(int)} to update the text of the label to reflect a new issue count.
   */
  private static class IssueCounterLabel extends JLabel implements ListEventListener<Issue> {
    private static final MessageFormat issueCountFormat =
        new MessageFormat("{0} {0,choice,0#issues|1#issue|1<issues}");

    private int issueCount = -1;

    public IssueCounterLabel(EventList<Issue> source) {
      source.addListEventListener(this);
      this.setIssueCount(source.size());
    }

    public void setIssueCount(int issueCount) {
      if (this.issueCount == issueCount) return;
      this.issueCount = issueCount;
      this.setText(issueCountFormat.format(new Object[] {new Integer(issueCount)}));
    }

    public void listChanged(ListEvent<Issue> listChanges) {
      setIssueCount(listChanges.getSourceList().size());
    }
  }

  /** Render the issues separator. */
  public static class IssueSeparatorTableCell extends AbstractCellEditor
      implements TableCellRenderer, TableCellEditor, ActionListener {
    private final MessageFormat nameFormat = new MessageFormat("{0} ({1})");

    /** the separator list to lock */
    private final SeparatorList separatorList;

    private final JPanel panel = new JPanel(new BorderLayout());
    private final JButton expandButton;
    private final JLabel nameLabel = new JLabel();

    private SeparatorList.Separator<Issue> separator;

    public IssueSeparatorTableCell(SeparatorList separatorList) {
      this.separatorList = separatorList;

      this.expandButton = new JButton(EXPANDED_ICON);
      this.expandButton.setOpaque(false);
      this.expandButton.setBorder(EMPTY_TWO_PIXEL_BORDER);
      this.expandButton.setIcon(EXPANDED_ICON);
      this.expandButton.setContentAreaFilled(false);

      this.nameLabel.setFont(nameLabel.getFont().deriveFont(10.0f));
      this.nameLabel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));

      this.expandButton.addActionListener(this);

      this.panel.setBackground(GLAZED_LISTS_LIGHT_BROWN);
      this.panel.add(expandButton, BorderLayout.WEST);
      this.panel.add(nameLabel, BorderLayout.CENTER);
    }

    public Component getTableCellEditorComponent(
        JTable table, Object value, boolean isSelected, int row, int column) {
      configure(value);
      return panel;
    }

    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
      configure(value);
      return panel;
    }

    public Object getCellEditorValue() {
      return this.separator;
    }

    private void configure(Object value) {
      this.separator = (SeparatorList.Separator<Issue>) value;
      Issue issue = separator.first();
      if (issue == null) return; // handle 'late' rendering calls after this separator is invalid
      expandButton.setIcon(separator.getLimit() == 0 ? EXPANDED_ICON : COLLAPSED_ICON);
      nameLabel.setText(
          nameFormat.format(new Object[] {issue.getSubcomponent(), new Integer(separator.size())}));
    }

    public void actionPerformed(ActionEvent e) {
      final Lock writeLock = separatorList.getReadWriteLock().writeLock();
      writeLock.lock();
      boolean collapsed;
      try {
        collapsed = separator.getLimit() == 0;
        separator.setLimit(collapsed ? Integer.MAX_VALUE : 0);
      } finally {
        writeLock.unlock();
      }
      expandButton.setIcon(collapsed ? COLLAPSED_ICON : EXPANDED_ICON);
    }
  }

  /** A button that shows icons in one of three states for up, over and down. */
  public static class IconButton extends JButton implements MouseListener {
    private static final Border emptyBorder = BorderFactory.createEmptyBorder();

    private static final int UP = 0;
    private static final int OVER = 1;
    private static final int DOWN = 2;
    private int state = -1;

    private Icon[] icons;

    public IconButton(Icon[] icons) {
      this.icons = icons;
      super.setBorder(emptyBorder);
      setState(UP);
      setContentAreaFilled(false);

      addMouseListener(this);
    }

    public Icon[] getIcons() {
      return icons;
    }

    public void setIcons(Icon[] icons) {
      this.icons = icons;
      super.setIcon(this.icons[state]);
    }

    private void setState(int state) {
      this.state = state;
      super.setIcon(icons[state]);
    }

    public void mouseClicked(MouseEvent e) {
      // do nothing
    }

    public void mousePressed(MouseEvent e) {
      setState(DOWN);
    }

    public void mouseReleased(MouseEvent e) {
      setState(OVER);
    }

    public void mouseEntered(MouseEvent e) {
      setState(OVER);
    }

    public void mouseExited(MouseEvent e) {
      setState(UP);
    }
  }
}
Esempio n. 9
0
  protected void init() {
    this.pnlMain.setLayout(new GridBagLayout());
    this.pnlAvailableObjects.setLayout(new BorderLayout());
    this.labAvailableColumns.setText(
        SpringLocaleDelegate.getInstance()
            .getMessage("DefaultSelectObjectsPanel.6", "Verf\u00fcgbar"));
    this.pnlMiddleButtons.setLayout(new GridBagLayout());
    this.pnlSelectedColumns.setLayout(new BorderLayout());
    this.pnlRightButtons.setLayout(new GridBagLayout());
    this.labSelectedColumns.setText(
        SpringLocaleDelegate.getInstance()
            .getMessage("DefaultSelectObjectsPanel.1", "Ausgew\u00e4hlt"));
    this.pnlMain.setBorder(BorderFactory.createEmptyBorder(5, 5, 10, 5));
    this.scrlpnAvailableColumns.setVerticalScrollBarPolicy(
        JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    this.scrlpnAvailableColumns.setPreferredSize(new Dimension(200, 300));
    this.btnRight.setEnabled(false);
    this.btnLeft.setEnabled(false);
    this.btnUp.setEnabled(false);
    this.btnDown.setEnabled(false);
    this.scrlpnSelectedColumns.setPreferredSize(new Dimension(200, 300));
    if (header != null) {
      final JTabbedPane tabbed = new JTabbedPane();
      tabbed.add(
          SpringLocaleDelegate.getInstance().getMessage("select.panel.column", "Spalten"), pnlMain);
      final JPanel panel = new JPanel(new BorderLayout());
      panel.add(header, BorderLayout.NORTH);
      tabbed.add(
          SpringLocaleDelegate.getInstance().getMessage("select.panel.pivot", "Pivot"),
          new JScrollPane(panel));
      add(tabbed, BorderLayout.CENTER);
    } else {
      this.add(pnlMain, BorderLayout.CENTER);
    }
    this.pnlMain.add(
        pnlTitleAvailableObjects,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0));
    this.pnlMain.add(
        pnlAvailableObjects,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));
    this.pnlTitleAvailableObjects.add(labAvailableColumns, null);
    this.pnlMain.add(
        pnlMiddleButtons,
        new GridBagConstraints(
            1,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(0, 10, 0, 10),
            0,
            0));
    this.pnlMiddleButtons.add(
        btnRight,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(5, 0, 5, 0),
            0,
            0));
    this.pnlMiddleButtons.add(
        btnLeft,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(5, 0, 5, 0),
            0,
            0));
    this.pnlMain.add(
        pnlSelectedColumns,
        new GridBagConstraints(
            2,
            1,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));
    this.pnlMain.add(
        pnlRightButtons,
        new GridBagConstraints(
            3,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.VERTICAL,
            new Insets(0, 10, 0, 0),
            0,
            0));
    this.pnlRightButtons.add(
        btnUp,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 0, 5, 0),
            0,
            0));
    this.pnlRightButtons.add(
        btnDown,
        new GridBagConstraints(
            0,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 0, 5, 0),
            0,
            0));
    this.pnlMain.add(
        pnlTitleSelectedColumns,
        new GridBagConstraints(
            2,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0));
    this.pnlTitleSelectedColumns.add(labSelectedColumns, null);
    this.pnlAvailableObjects.add(scrlpnAvailableColumns, BorderLayout.CENTER);
    this.scrlpnAvailableColumns.getViewport().add(jlstAvailableColumns, null);
    this.pnlSelectedColumns.add(scrlpnSelectedColumns, BorderLayout.CENTER);
    this.scrlpnSelectedColumns.getViewport().add(jlstSelectedColumns, null);

    this.btnLeft.setIcon(Icons.getInstance().getIconLeft16());
    this.btnRight.setIcon(Icons.getInstance().getIconRight16());
    this.btnUp.setIcon(Icons.getInstance().getIconUp16());
    this.btnDown.setIcon(Icons.getInstance().getIconDown16());

    this.btnLeft.setToolTipText(
        SpringLocaleDelegate.getInstance()
            .getMessage("DefaultSelectObjectsPanel.3", "Markierte Objekte nicht ausw\u00e4hlen"));
    this.btnRight.setToolTipText(
        SpringLocaleDelegate.getInstance()
            .getMessage("DefaultSelectObjectsPanel.2", "Markierte Objekte ausw\u00e4hlen"));
    this.btnUp.setToolTipText(
        SpringLocaleDelegate.getInstance()
            .getMessage("DefaultSelectObjectsPanel.4", "Markiertes Objekt nach oben verschieben"));
    this.btnDown.setToolTipText(
        SpringLocaleDelegate.getInstance()
            .getMessage("DefaultSelectObjectsPanel.5", "Markiertes Objekt nach unten verschieben"));
    this.btnUp.setVisible(false);
    this.btnDown.setVisible(false);
  }