public MarketOrdersToolSettingsPanel(final Program program, final SettingsDialog settingsDialog) {
    super(
        program,
        settingsDialog,
        DialoguesSettings.get().marketOrders(),
        Images.TOOL_MARKET_ORDERS.getIcon());

    jSaveHistory = new JCheckBox(DialoguesSettings.get().marketOrdersSaveHistory());

    JLabelMultiline jSaveHistoryWarning =
        new JLabelMultiline(DialoguesSettings.get().saveHistoryWarning(), 2);

    layout.setHorizontalGroup(
        layout
            .createParallelGroup(GroupLayout.Alignment.LEADING)
            .addComponent(jSaveHistory)
            .addComponent(
                jSaveHistoryWarning,
                GroupLayout.PREFERRED_SIZE,
                GroupLayout.PREFERRED_SIZE,
                Integer.MAX_VALUE));
    layout.setVerticalGroup(
        layout
            .createSequentialGroup()
            .addComponent(
                jSaveHistory,
                Program.getButtonsHeight(),
                Program.getButtonsHeight(),
                Program.getButtonsHeight())
            .addComponent(
                jSaveHistoryWarning,
                GroupLayout.PREFERRED_SIZE,
                GroupLayout.PREFERRED_SIZE,
                GroupLayout.PREFERRED_SIZE));
  }
Exemplo n.º 2
0
 protected static boolean confirmOpenLinks(final Program program, final int size) {
   if (size <= 1) {
     return true;
   }
   int value =
       JOptionPane.showConfirmDialog(
           program.getMainWindow().getFrame(),
           GuiShared.get().openLinks(size),
           GuiShared.get().openLinksTitle(),
           JOptionPane.OK_CANCEL_OPTION,
           JOptionPane.PLAIN_MESSAGE);
   return (value == JOptionPane.OK_OPTION);
 }
Exemplo n.º 3
0
  public IndustryJobsTab(final Program program) {
    super(program, TabsJobs.get().industry(), Images.TOOL_INDUSTRY_JOBS.getIcon(), true);

    ListenerClass listener = new ListenerClass();
    // Table Format
    tableFormat =
        new EnumTableFormatAdaptor<IndustryJobTableFormat, MyIndustryJob>(
            IndustryJobTableFormat.class);
    // Backend
    eventList = program.getProfileData().getIndustryJobsEventList();
    // Sorting (per column)
    eventList.getReadWriteLock().readLock().lock();
    SortedList<MyIndustryJob> sortedList = new SortedList<MyIndustryJob>(eventList);
    eventList.getReadWriteLock().readLock().unlock();

    // Filter
    eventList.getReadWriteLock().readLock().lock();
    filterList = new FilterList<MyIndustryJob>(sortedList);
    eventList.getReadWriteLock().readLock().unlock();
    filterList.addListEventListener(listener);
    // Table Model
    tableModel = EventModels.createTableModel(filterList, tableFormat);
    // Table
    jTable = new JAutoColumnTable(program, tableModel);
    jTable.setCellSelectionEnabled(true);
    PaddingTableCellRenderer.install(jTable, 1);
    // Sorting
    TableComparatorChooser.install(
        jTable, sortedList, TableComparatorChooser.MULTIPLE_COLUMN_MOUSE, tableFormat);
    // Selection Model
    selectionModel = EventModels.createSelectionModel(filterList);
    selectionModel.setSelectionMode(ListSelection.MULTIPLE_INTERVAL_SELECTION_DEFENSIVE);
    jTable.setSelectionModel(selectionModel);
    // Listeners
    installTable(jTable, NAME);
    // Scroll
    JScrollPane jTableScroll = new JScrollPane(jTable);
    // Table Filter
    Map<String, List<Filter>> defaultFilters = new HashMap<String, List<Filter>>();
    List<Filter> filter;
    filter = new ArrayList<Filter>();
    filter.add(
        new Filter(
            LogicType.AND,
            IndustryJobTableFormat.STATE,
            CompareType.EQUALS_NOT,
            IndustryJobState.STATE_DELIVERED.toString()));
    defaultFilters.put(TabsJobs.get().active(), filter);
    filter = new ArrayList<Filter>();
    filter.add(
        new Filter(
            LogicType.AND,
            IndustryJobTableFormat.STATE,
            CompareType.EQUALS,
            IndustryJobState.STATE_DELIVERED.toString()));
    defaultFilters.put(TabsJobs.get().completed(), filter);
    filterControl =
        new IndustryJobsFilterControl(
            program.getMainWindow().getFrame(),
            tableFormat,
            sortedList,
            filterList,
            Settings.get().getTableFilters(NAME),
            defaultFilters);

    // Menu
    installMenu(program, new JobsTableMenu(), jTable, MyIndustryJob.class);

    jInventionSuccess =
        StatusPanel.createLabel(
            TabsJobs.get().inventionSuccess(), Images.JOBS_INVENTION_SUCCESS.getIcon());
    this.addStatusbarLabel(jInventionSuccess);

    jManufactureOutputValue =
        StatusPanel.createLabel(
            TabsJobs.get().manufactureJobsValue(), Images.TOOL_VALUES.getIcon());
    this.addStatusbarLabel(jManufactureOutputValue);

    layout.setHorizontalGroup(
        layout
            .createParallelGroup()
            .addComponent(filterControl.getPanel())
            .addComponent(jTableScroll, 700, 700, Short.MAX_VALUE));
    layout.setVerticalGroup(
        layout
            .createSequentialGroup()
            .addComponent(filterControl.getPanel())
            .addComponent(jTableScroll, 100, 400, Short.MAX_VALUE));
  }
Exemplo n.º 4
0
  FilterPanel(final FilterGui<E> gui, final FilterControl<E> filterControl) {
    this.gui = gui;
    this.filterControl = filterControl;

    ListenerClass listener = new ListenerClass();

    allColumns = new ArrayList<EnumTableColumn<E>>();
    allColumns.add(new AllColumn<E>());
    allColumns.addAll(filterControl.getColumns());

    numericColumns = new ArrayList<EnumTableColumn<E>>();
    for (EnumTableColumn<E> object : filterControl.getColumns()) {
      if (filterControl.isNumeric(object)) {
        numericColumns.add(object);
      }
    }

    dateColumns = new ArrayList<EnumTableColumn<E>>();
    for (EnumTableColumn<E> object : filterControl.getColumns()) {
      if (filterControl.isDate(object)) {
        dateColumns.add(object);
      }
    }

    jEnabled = new JCheckBox();
    jEnabled.setSelected(true);
    jEnabled.addActionListener(listener);
    jEnabled.setActionCommand(FilterPanelAction.FILTER.name());

    jLogic = new JComboBox<LogicType>(LogicType.values());
    jLogic.setPrototypeDisplayValue(LogicType.AND);
    jLogic.addActionListener(listener);
    jLogic.setActionCommand(FilterPanelAction.FILTER.name());

    JComboBox<String> jComboBox = new JComboBox<String>();
    FontMetrics fontMetrics = jComboBox.getFontMetrics(jComboBox.getFont());
    EnumTableColumn<E> longestColumn = null;
    for (EnumTableColumn<E> column : allColumns) {
      if (longestColumn == null
          || fontMetrics.stringWidth(longestColumn.getColumnName())
              < fontMetrics.stringWidth(column.getColumnName())) {
        longestColumn = column;
      }
    }

    jColumn =
        new JComboBox<EnumTableColumn<E>>(new ListComboBoxModel<EnumTableColumn<E>>(allColumns));
    jColumn.setPrototypeDisplayValue(longestColumn);
    jColumn.addActionListener(listener);
    jColumn.setActionCommand(FilterPanelAction.FILTER.name());

    jCompare = new JComboBox<CompareType>();
    jCompare.setPrototypeDisplayValue(CompareType.CONTAINS_NOT_COLUMN);
    jCompare.addActionListener(listener);
    jCompare.setActionCommand(FilterPanelAction.FILTER.name());

    jText = new JTextField();
    jText.getDocument().addDocumentListener(listener);
    jText.addKeyListener(listener);

    jCompareColumn = new JComboBox<EnumTableColumn<E>>();
    jCompareColumn.setPrototypeDisplayValue(longestColumn);
    jCompareColumn.addActionListener(listener);
    jCompareColumn.setActionCommand(FilterPanelAction.FILTER.name());

    jDate = new JDateChooser(false);
    jDate.addDateChangeListener(listener);

    jSpacing = new JLabel();

    jRemove = new JButton();
    jRemove.setIcon(Images.EDIT_DELETE.getIcon());
    jRemove.addActionListener(listener);
    jRemove.setActionCommand(FilterPanelAction.REMOVE.name());

    timer = new Timer(500, listener);
    timer.setActionCommand(FilterPanelAction.FILTER_TIMER.name());

    jPanel = new JPanel();

    layout = new GroupLayout(jPanel);
    jPanel.setLayout(layout);
    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(false);

    layout.setHorizontalGroup(
        layout
            .createSequentialGroup()
            .addComponent(jEnabled, 30, 30, 30)
            .addComponent(
                jLogic,
                GroupLayout.PREFERRED_SIZE,
                GroupLayout.PREFERRED_SIZE,
                GroupLayout.PREFERRED_SIZE)
            .addComponent(
                jColumn,
                GroupLayout.PREFERRED_SIZE,
                GroupLayout.PREFERRED_SIZE,
                GroupLayout.PREFERRED_SIZE)
            .addComponent(
                jCompare,
                GroupLayout.PREFERRED_SIZE,
                GroupLayout.PREFERRED_SIZE,
                GroupLayout.PREFERRED_SIZE)
            .addComponent(jText, 100, 100, Integer.MAX_VALUE)
            .addComponent(
                jCompareColumn,
                GroupLayout.PREFERRED_SIZE,
                GroupLayout.PREFERRED_SIZE,
                GroupLayout.PREFERRED_SIZE)
            .addComponent(
                jDate,
                GroupLayout.PREFERRED_SIZE,
                GroupLayout.PREFERRED_SIZE,
                GroupLayout.PREFERRED_SIZE)
            .addComponent(jSpacing, 0, 0, Integer.MAX_VALUE)
            .addComponent(jRemove, 30, 30, 30));
    layout.setVerticalGroup(
        layout
            .createParallelGroup()
            .addComponent(
                jEnabled,
                Program.getButtonsHeight(),
                Program.getButtonsHeight(),
                Program.getButtonsHeight())
            .addComponent(
                jLogic,
                Program.getButtonsHeight(),
                Program.getButtonsHeight(),
                Program.getButtonsHeight())
            .addComponent(
                jColumn,
                Program.getButtonsHeight(),
                Program.getButtonsHeight(),
                Program.getButtonsHeight())
            .addComponent(
                jCompare,
                Program.getButtonsHeight(),
                Program.getButtonsHeight(),
                Program.getButtonsHeight())
            .addComponent(
                jText,
                Program.getButtonsHeight(),
                Program.getButtonsHeight(),
                Program.getButtonsHeight())
            .addComponent(
                jCompareColumn,
                Program.getButtonsHeight(),
                Program.getButtonsHeight(),
                Program.getButtonsHeight())
            .addComponent(
                jDate,
                Program.getButtonsHeight(),
                Program.getButtonsHeight(),
                Program.getButtonsHeight())
            .addComponent(
                jSpacing,
                Program.getButtonsHeight(),
                Program.getButtonsHeight(),
                Program.getButtonsHeight())
            .addComponent(
                jRemove,
                Program.getButtonsHeight(),
                Program.getButtonsHeight(),
                Program.getButtonsHeight()));
    updateNumeric(false);
  }