コード例 #1
0
  private void createViews() {

    optionsView =
        new ElegantPanel(i18n.getString("RemoveDialogRemoveOptionsTitle"), getRemoveOptionsPanel());
    descView =
        new ElegantPanel(i18n.getString("RemoveDialogDescriptionTitle"), getPackageDescPanel());
    packageView =
        new ElegantPanel(
            i18n.getString("RemoveDialogRemovablePackagesTitle"), getPackageListPanel());
  }
コード例 #2
0
  public RemovePackageDialog(Frame parent, String title, boolean modal, Properties properties) {
    super(parent, title, modal);

    i18n = I18nManager.getI18nManager("i18n/JacmanLabels", Locale.getDefault());
    jacmanProperties = properties;

    sortedPackages = new SortedList(packageEventList, new PackageComparitor());
    FilterList textFilteredIssues =
        new FilterList(
            sortedPackages, new TextComponentMatcherEditor(txtSearch, new PackageTextFilterator()));

    String[] propertyNames = {"name", "version", "description", "size"};
    String[] columnNames = {
      i18n.getString("PackageTableColumnName"),
      i18n.getString("PackageTableColumnInstalledVer"),
      i18n.getString("PackageTableColumnDescription"),
      i18n.getString("PackageTableColumnSize")
    };

    checkableTableFormat =
        new CheckableTableFormat(
            new BeanTableFormat(InstalledPacmanPkg.class, propertyNames, columnNames));
    packagesTableModel = new EventTableModel(textFilteredIssues, checkableTableFormat);

    if (parent != null) this.setLocation(parent.getLocation());
    setupGUI();

    final InfiniteProgressPanel pane =
        new InfiniteProgressPanel(i18n.getString("LoadingPackagesMessage"));
    setGlassPane(pane);
    validate();
    pane.start();
    SwingWorker worker =
        new SwingWorker() {
          public Object construct() {

            Jacman.findInstalledPackages(packageEventList);
            return "done";
          }

          public void finished() {
            JacmanUtils.setOptimalTableWidth(getPackageListTable());
            pane.stop();
          }
        };
    worker.start();
  }
コード例 #3
0
  private JPanel getPackageListPanel() {

    if (pnlPackageList == null) {
      pnlPackageList = new JPanel(new BorderLayout());

      GridBagConstraints gridBagConstraints = new GridBagConstraints();

      JLabel lblSearch = new JLabel(i18n.getString("SearchLabel"));
      lblSearch.setLabelFor(txtSearch);

      JPanel filterPanel = new JPanel(new GridBagLayout());
      filterPanel.setBorder(new EmptyBorder(3, 0, 3, 0));
      ImageIcon icon = new ImageIcon(URLClassLoader.getSystemResource("icons/erase.png"));
      JButton eraseSearch = new JButton(icon);
      eraseSearch.setToolTipText(i18n.getString("SearchResetButtonTooltip"));
      eraseSearch.addActionListener(
          new ActionListener() {

            public void actionPerformed(ActionEvent e) {
              txtSearch.setText("");
            }
          });
      Dimension d = eraseSearch.getPreferredSize();
      d.setSize(icon.getIconWidth() * 2, txtSearch.getPreferredSize().getHeight());
      eraseSearch.setPreferredSize(d);

      gridBagConstraints = new GridBagConstraints();
      gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 3);

      filterPanel.add(eraseSearch, gridBagConstraints);
      filterPanel.add(lblSearch, gridBagConstraints);

      gridBagConstraints = new GridBagConstraints();
      gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
      gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
      gridBagConstraints.weightx = 1.0;

      filterPanel.add(txtSearch, gridBagConstraints);

      pnlPackageList.add(filterPanel, BorderLayout.NORTH);
      pnlPackageList.add(new JScrollPane(getPackageListTable()), BorderLayout.CENTER);
    }

    return pnlPackageList;
  }
コード例 #4
0
  private void setupGUI() {

    initSplitPanes();

    getContentPane().add(horizontalSplit, BorderLayout.CENTER);
    JPanel buttonPanel =
        new JPanel(new EqualsLayout(EqualsLayout.HORIZONTAL, EqualsLayout.RIGHT, 3));
    buttonPanel.setBorder(new EmptyBorder(3, 3, 3, 3));
    JButton removeButton = new JButton(i18n.getString("RemoveDialogRemoveButton"));
    removeButton.setIcon(JacmanUtils.loadIcon("icons/button_ok_16x16.png"));
    removeButton.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {

            List<String> commandArgs = new ArrayList<String>();
            commandArgs.add("pacman");
            // commandArgs.add("--noconfirm");
            commandArgs.addAll(options.getRemoveOptionsArgs());

            List selectedPackages = checkableTableFormat.getSelection();
            for (Iterator p = selectedPackages.iterator(); p.hasNext(); ) {
              commandArgs.add(((PacmanPkg) p.next()).getName());
            }

            String[] command = new String[commandArgs.size()];

            for (int i = 0; i < commandArgs.size(); i++) {
              command[i] = (String) commandArgs.get(i);
            }

            new ConsoleDialog(
                command,
                (Dialog) SwingUtilities.getRoot(RemovePackageDialog.this),
                i18n.getString("RemoveDialogConsoleTitle"),
                true);
            returnVal = RemovePackageDialog.PACMAN_RAN;
            String dispose = jacmanProperties.getProperty("jacman.disposeMainMenu", "true");
            if (dispose.equals("true") && returnVal == RemovePackageDialog.PACMAN_RAN) {
              ((Frame) getParent()).dispose();
            } else {
              ((Frame) getParent()).setVisible(true);
            }
            dispose();
          }
        });
    buttonPanel.add(removeButton);

    JButton closeButton = new JButton(i18n.getString("CloseButton"));
    closeButton.setIcon(JacmanUtils.loadIcon("icons/button_cancel_16x16.png"));
    closeButton.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            dispose();
          }
        });
    buttonPanel.add(closeButton);

    add(buttonPanel, BorderLayout.SOUTH);

    setSize(800, 600);

    setVisible(true);
    postInit();
  }
コード例 #5
0
  private JPanel getPackageDescPanel() {

    if (pnlPackageDescPane == null) {

      JPanel pnlPackageDesc = new JPanel();

      GridBagConstraints gridBagConstraints;

      JLabel lblPackageName = new JLabel(i18n.getString("DescPackageName"));
      JLabel lblPackageDesc = new JLabel(i18n.getString("DescPackageDesc"));
      JLabel lblInstalledVersion = new JLabel(i18n.getString("DescInstalledVersion"));
      JLabel lblSize = new JLabel(i18n.getString("DescSize"));

      pnlPackageDesc.setLayout(new GridBagLayout());

      gridBagConstraints = new GridBagConstraints();
      gridBagConstraints.insets = new Insets(0, 0, 0, 3);
      gridBagConstraints.anchor = GridBagConstraints.EAST;
      pnlPackageDesc.add(lblPackageName, gridBagConstraints);

      gridBagConstraints = new GridBagConstraints();
      gridBagConstraints.insets = new Insets(0, 3, 0, 0);
      gridBagConstraints.anchor = GridBagConstraints.WEST;
      gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
      gridBagConstraints.weightx = 1.0;
      pnlPackageDesc.add(packageName, gridBagConstraints);

      gridBagConstraints = new GridBagConstraints();
      gridBagConstraints.gridx = 0;
      gridBagConstraints.gridy = 1;
      gridBagConstraints.insets = new Insets(3, 0, 0, 0);
      gridBagConstraints.anchor = GridBagConstraints.EAST;
      pnlPackageDesc.add(lblPackageDesc, gridBagConstraints);

      gridBagConstraints = new GridBagConstraints();
      gridBagConstraints.gridx = 1;
      gridBagConstraints.gridy = 1;
      gridBagConstraints.insets = new Insets(3, 3, 0, 0);
      gridBagConstraints.anchor = GridBagConstraints.WEST;
      gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
      gridBagConstraints.weightx = 1.0;
      pnlPackageDesc.add(packageDesc, gridBagConstraints);

      gridBagConstraints = new GridBagConstraints();
      gridBagConstraints.gridx = 0;
      gridBagConstraints.gridy = 2;
      gridBagConstraints.insets = new Insets(3, 3, 0, 0);
      gridBagConstraints.anchor = GridBagConstraints.EAST;
      pnlPackageDesc.add(lblInstalledVersion, gridBagConstraints);

      gridBagConstraints = new GridBagConstraints();
      gridBagConstraints.gridx = 1;
      gridBagConstraints.gridy = 2;
      gridBagConstraints.insets = new Insets(3, 3, 0, 0);
      gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
      gridBagConstraints.weightx = 1.0;
      gridBagConstraints.anchor = GridBagConstraints.WEST;
      pnlPackageDesc.add(installedVersion, gridBagConstraints);

      gridBagConstraints = new GridBagConstraints();
      gridBagConstraints.gridx = 0;
      gridBagConstraints.gridy = 3;
      gridBagConstraints.insets = new Insets(3, 3, 0, 0);
      gridBagConstraints.anchor = GridBagConstraints.EAST;
      pnlPackageDesc.add(lblSize, gridBagConstraints);

      gridBagConstraints = new GridBagConstraints();
      gridBagConstraints.gridx = 1;
      gridBagConstraints.gridy = 3;
      gridBagConstraints.insets = new Insets(3, 3, 0, 0);
      gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
      gridBagConstraints.weightx = 1.0;
      gridBagConstraints.anchor = GridBagConstraints.WEST;
      pnlPackageDesc.add(size, gridBagConstraints);

      pnlPackageDescPane = new JPanel(new BorderLayout());
      JScrollPane scroll = new JScrollPane(pnlPackageDesc);
      pnlPackageDescPane.add(scroll, BorderLayout.CENTER);
    }

    return pnlPackageDescPane;
  }