Example #1
0
  /** Creates new form ValuesDialog */
  public StylesDialog(java.awt.Frame parent, boolean modal) {
    super(parent, modal);
    initComponents();
    applyI18n();
    this.setSize(490, 250);
    // DefaultTableColumnModel dtcm = (DefaultTableColumnModel)jTableParameters.getColumnModel();
    // DefaultTableCellRenderer tcr =
    // (DefaultTableCellRenderer)dtcm.getColumn(0).getHeaderRenderer();

    // new DefaultTableCellRenderer();
    // tcr.setFont(jTableParameters.getFont());
    // tcr.setBackground(this.getBackground());
    // tcr.setBorder( new javax.swing.border.BevelBorder( javax.swing.border.BevelBorder.RAISED));
    // dtcm.getColumn(0).setHeaderRenderer(tcr);

    DefaultListSelectionModel dlsm =
        (DefaultListSelectionModel) this.jTableParameters.getSelectionModel();
    dlsm.addListSelectionListener(
        new javax.swing.event.ListSelectionListener() {
          public void valueChanged(ListSelectionEvent e) {
            jTableParametersListSelectionValueChanged(e);
          }
        });

    // Open in center...
    it.businesslogic.ireport.util.Misc.centerFrame(this);

    DefaultTableModel dtm = (DefaultTableModel) jTableParameters.getModel();

    it.businesslogic.ireport.gui.MainFrame.getMainInstance()
        .getActiveReportFrame()
        .getReport()
        .addStyleChangedListener(this);
    Enumeration e =
        it.businesslogic.ireport.gui.MainFrame.getMainInstance()
            .getActiveReportFrame()
            .getReport()
            .getStyles()
            .elements();
    while (e.hasMoreElements()) {
      Style style = (Style) e.nextElement();
      addStyle(style);
    }

    DefaultTableColumnModel dtcm = (DefaultTableColumnModel) jTableParameters.getColumnModel();
    dtcm.getColumn(0).setPreferredWidth(350);
    dtcm.getColumn(1).setPreferredWidth(100);

    javax.swing.KeyStroke escape =
        javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0, false);
    javax.swing.Action escapeAction =
        new javax.swing.AbstractAction() {
          public void actionPerformed(java.awt.event.ActionEvent e) {
            setVisible(false);
          }
        };

    getRootPane().getInputMap(javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE");
    getRootPane().getActionMap().put("ESCAPE", escapeAction);
  }
  private void jButtonMoveUpActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButtonMoveUpActionPerformed

    if (jTable1.getSelectedRow() > 0) {
      DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel();
      int[] indices = jTable1.getSelectedRows();
      for (int i = indices.length - 1; i >= 0; --i) {
        if (indices[i] == 0) continue;

        Object val = jTable1.getValueAt(indices[i], 0);
        dtm.removeRow(indices[i]);
        dtm.insertRow(indices[i] - 1, new Object[5]);
        setRowValues((MeterInterval) val, indices[i] - 1);
        indices[i]--;
      }

      DefaultListSelectionModel dlsm = (DefaultListSelectionModel) jTable1.getSelectionModel();
      dlsm.setValueIsAdjusting(true);
      dlsm.clearSelection();
      for (int i = 0; i < indices.length; ++i) {
        dlsm.addSelectionInterval(indices[i], indices[i]);
      }
      dlsm.setValueIsAdjusting(false);
    }
  } // GEN-LAST:event_jButtonMoveUpActionPerformed
Example #3
0
 public void mouseReleased(MouseEvent e) {
   current = e.getPoint();
   // intersect with graph
   Rectangle selrect =
       new Rectangle(start.x, start.y, current.x - start.x, current.y - start.y);
   int[] gi = gs.getIndicesAt(selrect, graph.getXAxis(), graph.getYAxis());
   DefaultListSelectionModel rsm = new DefaultListSelectionModel();
   if (gi != null) {
     rsm.setValueIsAdjusting(true);
     for (int j = 0; j < gi.length; j++) {
       // find node and select segs for node and all descendents
       int nodeidx = gi[j] / 2;
       TreeNode tn = nodemap[nodeidx];
       selectTraverse(tn, rsm);
     }
     rsm.setValueIsAdjusting(false);
   }
   if (ctx != null) {
     // Merge this selection with the table selection list
     // using the current set selection operator
     ColumnMap cmap = ctx.getColumnMap(tm, 0);
     if (cmap != null) {
       cmap.selectValues(rsm);
     }
   }
   if (ctx != null) {
     // restore the original selection set operator
     ctx.getSetOperator(tm).setSetOperator(prevSetOp);
   }
   repaint();
 }
Example #4
0
 public int getSelectedIndex() {
   int i1 = selection.getMinSelectionIndex(), i2 = selection.getMaxSelectionIndex();
   if (i1 == i2 && i1 >= 0 && i1 < filters.size()) {
     return i1;
   } else {
     return -1;
   }
 }
Example #5
0
 @Override
 public void setSelectionInterval(final int index0, final int index1) {
   if (isSelectedIndex(index0) && !this.gestureStarted) {
     super.removeSelectionInterval(index0, index1);
   } else {
     super.setSelectionInterval(index0, index1);
   }
   this.gestureStarted = true;
 }
 @Override
 public void setSelectionInterval(int index0, int index1) {
   if (adjusting) {
     return;
   } else if (isSelectedIndex(index1)) {
     super.removeSelectionInterval(index0, index1);
   } else {
     super.addSelectionInterval(index0, index1);
   }
   adjusting = getValueIsAdjusting();
 }
 public void removeSelected() {
   Iterator<String> it = data.iterator();
   int i = 0;
   while (it.hasNext()) {
     it.next();
     if (selectionModel.isSelectedIndex(i)) {
       it.remove();
     }
     i++;
   }
   fireTableDataChanged();
   selectionModel.clearSelection();
 }
Example #8
0
    public void remove(int i) {
      int s = getSelectedIndex();
      if (s != -1) {
        filters.remove(i);
        fireIntervalRemoved(this, i, i);

        if (i < s) {
          selection.setSelectionInterval(s - 1, s - 1);
        }
        if (i == s) {
          selection.setSelectionInterval(100, 0);
        }
      }
    }
 @SuppressWarnings("unchecked")
 protected void whenClassroomsTableSelectionChanged(ListSelectionEvent anEvent) {
   DefaultListSelectionModel source = (DefaultListSelectionModel) anEvent.getSource();
   if (source.isSelectionEmpty()) {
     classroomSelected = null;
     moveAssignmentOfClassroomButton.setEnabled(false);
   } else {
     int index = source.getMinSelectionIndex();
     List<Classroom> model =
         ((ReadOnlyTableModel<Classroom>) classroomsTable.getModel()).getModel();
     classroomSelected = model.get(index);
     moveAssignmentOfClassroomButton.setEnabled(
         !classroomSelected.equals(assignment.getAssignableItem()));
   }
 }
 public void addStylesFromSources(List<StyleSourceInfo> sources) {
   if (sources == null) return;
   for (StyleSourceInfo info : sources) {
     data.add(info.url);
   }
   sort();
   fireTableDataChanged();
   selectionModel.clearSelection();
   for (StyleSourceInfo info : sources) {
     int pos = data.indexOf(info.url);
     if (pos >= 0) {
       selectionModel.addSelectionInterval(pos, pos);
     }
   }
 }
 @Override
 public void setValueIsAdjusting(boolean isAdjusting) {
   if (!isAdjusting) {
     adjusting = false;
   }
   super.setValueIsAdjusting(isAdjusting);
 }
Example #12
0
    public TestList() {
      setLayout(new BorderLayout());

      final JList list = new JList(C2dTests.getNames());
      final JButton button = new JButton("Run Test");
      JScrollPane pane = new JScrollPane(list);

      DefaultListSelectionModel m = new DefaultListSelectionModel();
      m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
      m.setLeadAnchorNotificationEnabled(false);
      list.setSelectionModel(m);

      list.addMouseListener(
          new MouseAdapter() {
            public void mouseClicked(MouseEvent event) {
              if (event.getClickCount() == 2) button.doClick();
            }
          });

      final Preferences prefs =
          new LwjglPreferences(
              new FileHandle(new LwjglFiles().getExternalStoragePath() + ".prefs/c2d-tests"));
      list.setSelectedValue(prefs.getString("last", null), true);

      button.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              String testName = (String) list.getSelectedValue();
              Engine test = C2dTests.newTest(testName);
              LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
              config.fullscreen = false;
              config.width = (int) Engine.getWidth();
              config.height = (int) Engine.getHeight();
              config.title = testName;
              config.vSyncEnabled = true;

              prefs.putString("last", testName);
              prefs.flush();

              new LwjglApplication(test, config);
            }
          });

      add(pane, BorderLayout.CENTER);
      add(button, BorderLayout.SOUTH);
    }
Example #13
0
 @Override
 public void clearSelection() {
   System.err.println("DSM: clearSelection()");
   // new Exception().printStackTrace();
   delegate.clearSelection();
   fireSelectionChanged(
       new ListSelectionEvent(this, 0, sortedModel.getRowCount() - 1, getValueIsAdjusting()));
 }
Example #14
0
 public FilterModel(FilterRepository rep) {
   filters = new ArrayList<TaskFilter>(rep.size() * 2);
   int selectedi = 0;
   for (TaskFilter f : rep.getFilters()) {
     if (f == rep.getActive()) selection.setSelectionInterval(selectedi, selectedi);
     filters.add((TaskFilter) f.clone());
     selectedi++;
   }
 }
 public List<StyleSourceInfo> getSelected() {
   ArrayList<StyleSourceInfo> ret = new ArrayList<StyleSourceInfo>();
   for (int i = 0; i < data.size(); i++) {
     if (selectionModel.isSelectedIndex(i)) {
       ret.add(data.get(i));
     }
   }
   return ret;
 }
 public void addPath(String path) {
   if (path == null) return;
   data.add(path);
   sort();
   fireTableDataChanged();
   int idx = data.indexOf(path);
   if (idx >= 0) {
     selectionModel.setSelectionInterval(idx, idx);
   }
 }
 public void addStyle(String style) {
   if (style == null) return;
   data.add(style);
   sort();
   fireTableDataChanged();
   int idx = data.indexOf(style);
   if (idx >= 0) {
     selectionModel.setSelectionInterval(idx, idx);
   }
 }
 public void updatePath(int pos, String path) {
   if (path == null) return;
   if (pos < 0 || pos >= getRowCount()) return;
   data.set(pos, path);
   sort();
   fireTableDataChanged();
   int idx = data.indexOf(path);
   if (idx >= 0) {
     selectionModel.setSelectionInterval(idx, idx);
   }
 }
Example #19
0
  @Override
  public int getMaxSelectionIndex() {
    int min = delegate.getMinSelectionIndex();

    if (min >= 0) {
      int max = delegate.getMaxSelectionIndex();
      int viewMaxIndex = 0;

      for (int i = min; i <= max; i++) {
        int viewIndex = sortedModel.convertRowIndexToView(i);

        if (viewIndex > viewMaxIndex) {
          viewMaxIndex = viewIndex;
        }
      }

      return viewMaxIndex;
    }

    return -1;
  }
 public void deleteSelected() {
   Iterator<StyleSourceInfo> it = data.iterator();
   int i = 0;
   while (it.hasNext()) {
     it.next();
     if (selectionModel.isSelectedIndex(i)) {
       it.remove();
     }
     i++;
   }
   fireContentsChanged(this, 0, data.size());
 }
  public JRTabStopsPropertyCustomEditor(Object value, PropertyEditor editor, PropertyEnv env) {
    this.env = env;
    this.editor = editor;
    this.env.setState(PropertyEnv.STATE_NEEDS_VALIDATION);
    this.env.addPropertyChangeListener(this);

    initComponents();

    Tag[] tags =
        new Tag[] {
          new Tag(
              TabStopAlignEnum.LEFT.getValueByte(),
              I18n.getString("AbstractStyleNode.Property.Left")),
          new Tag(
              TabStopAlignEnum.CENTER.getValueByte(),
              I18n.getString("AbstractStyleNode.Property.Center")),
          new Tag(
              TabStopAlignEnum.RIGHT.getValueByte(),
              I18n.getString("AbstractStyleNode.Property.Right"))
        };

    jTableProperties.getColumnModel().getColumn(1).setCellEditor(new ComboBoxEditor(tags));

    jTableProperties.getColumnModel().getColumn(1).setCellRenderer(new ComboBoxRenderer(tags));

    DefaultListSelectionModel dlsm =
        (DefaultListSelectionModel) this.jTableProperties.getSelectionModel();
    dlsm.addListSelectionListener(
        new javax.swing.event.ListSelectionListener() {
          public void valueChanged(ListSelectionEvent e) {
            jTablePropertiesListSelectionValueChanged(e);
          }
        });

    if (value instanceof List && value != null) {
      setTabStops((List) value);
    }
  }
Example #22
0
  private void addSelectionInterval(int index0, int index1, boolean clear) {
    System.err.println(
        "DSM: addSelectionInterval(" + index0 + " - " + index1 + ": clear = " + clear + ")");

    int start = Math.min(index0, index1);
    int end = Math.max(index0, index1);
    boolean oldValue = getValueIsAdjusting();

    setValueIsAdjusting(true);

    if (clear) {
      delegate.clearSelection();
    }

    for (int i = start; i <= end; i++) {
      int modelIndex = sortedModel.convertRowIndexToModel(i);
      delegate.addSelectionInterval(modelIndex, modelIndex);
    }

    setValueIsAdjusting(oldValue);
    fireSelectionChanged(
        new ListSelectionEvent(this, 0, sortedModel.getRowCount() - 1, getValueIsAdjusting()));
  }
Example #23
0
  /**
   * Constructor
   *
   * @param model the via list model. Must not be null.
   * @param selectionModel the selection model. Must not be null.
   */
  public ViaList(ViaListModel model, DefaultListSelectionModel selectionModel) {
    super(model);
    this.model = model;
    setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    setSelectionModel(selectionModel);
    setCellRenderer(new OsmPrimitivRenderer());
    setDragEnabled(true);
    setTransferHandler(transferHandler = new ViaListTransferHandler(model));
    setVisibleRowCount(4);

    actDelete = new DeleteAction();
    selectionModel.addListSelectionListener(actDelete);
    registerKeyboardAction(
        actDelete,
        KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0),
        JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    actMoveDown = new MoveDownAction();
    selectionModel.addListSelectionListener(actMoveDown);
    registerKeyboardAction(
        actMoveDown,
        KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, KeyEvent.ALT_DOWN_MASK),
        JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    actMoveUp = new MoveUpAction();
    selectionModel.addListSelectionListener(actMoveUp);
    registerKeyboardAction(
        actMoveUp,
        KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.ALT_DOWN_MASK),
        JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    actCopy = new CopyAction();
    actPaste = new PasteAction();
    getSelectionModel().addListSelectionListener(actCopy);

    addMouseListener(new ViaListPopupMenuLaucher());
  }
Example #24
0
  @Override
  public void removeSelectionInterval(int index0, int index1) {
    System.err.println("DSM: removeSelectionInterval(" + index0 + " - " + index1 + ")");

    int start = Math.min(index0, index1);
    int end = Math.max(index0, index1);
    boolean oldValue = getValueIsAdjusting();

    setValueIsAdjusting(true);

    for (int i = start; i <= end; i++) {
      int modelIndex = sortedModel.convertRowIndexToModel(i);
      delegate.removeSelectionInterval(modelIndex, modelIndex);
    }

    setValueIsAdjusting(oldValue);
    fireSelectionChanged(
        new ListSelectionEvent(this, 0, sortedModel.getRowCount() - 1, getValueIsAdjusting()));
  }
Example #25
0
 public PermanentSingleSelectionModel() {
   super.setSelectionMode(SINGLE_SELECTION);
 }
Example #26
0
 @Override
 public boolean isSelectionEmpty() {
   return delegate.isSelectionEmpty();
 }
Example #27
0
  public void init() {

    // <Begin_init>
    if (getParameter("RESOURCE_PROPERTIES") != null) {
      localePropertiesFileName = getParameter("RESOURCE_PROPERTIES");
    }
    resourceBundle =
        com.adventnet.apiutils.Utility.getBundle(
            localePropertiesFileName, getParameter("RESOURCE_LOCALE"), applet);
    if (initialized) return;
    this.setSize(getPreferredSize().width + 495, getPreferredSize().height + 480);
    setTitle(resourceBundle.getString("ViewConfig"));
    Container container = getContentPane();
    container.setLayout(new BorderLayout());
    try {
      initVariables();
      setUpGUI(container);
      setUpProperties();
      setUpConnections();
    } catch (Exception ex) {
      showStatus(resourceBundle.getString("Error in init method"), ex);
    }
    // let us set the initialized variable to true so
    // we dont initialize again even if init is called
    initialized = true;

    // <End_init>
    setTitle(resourceBundle.getString("View Configuration"));
    setIconImage(AuthMain.getBuilderUiIfInstance().getFrameIcon());
    JLabel1.setIcon(AuthMain.getBuilderUiIfInstance().getImage("viewconfig.png"));
    com.adventnet.security.ui.ViewListCellRenderer ViewListCellRenderer1 =
        new com.adventnet.security.ui.ViewListCellRenderer();
    JTable1.setDefaultRenderer(JTable1.getColumnClass(0), ViewListCellRenderer1);

    JLabel2.setIcon(AuthMain.getBuilderUiIfInstance().getImage("addview1.png"));
    JTable1.getCellEditor(0, 0)
        .getTableCellEditorComponent(JTable1, null, true, 0, 0)
        .setEnabled(false);
    DefaultCellEditor te = (DefaultCellEditor) JTable1.getCellEditor(0, 0);
    te.setClickCountToStart(10);
    JTable1.setCellEditor(te);

    JViewport vp = new JViewport();
    JLabel lab = new JLabel(resourceBundle.getString("List of available views"));
    lab.setHorizontalAlignment((int) JLabel.CENTER_ALIGNMENT);
    lab.setForeground(Color.black);
    vp.setView(lab);

    AuthMain.getBuilderUiIfInstance().centerWindow(this);
    setData();

    viewc = this;

    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent we) {
            close();
          }
        });

    /*
    TableColumn col2  = JTable1.getColumnModel().getColumn(1);
    DefaultTableCellRenderer ren = new DefaultTableCellRenderer();
    ren.setIcon(AuthMain.getBuilderUiIfInstance().getImage("task1.png"));
    	col2.setCellRenderer(ren);
     	col2.setMaxWidth(30);
    */

    DefaultListSelectionModel selModel = new DefaultListSelectionModel();
    selModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JTable1.setSelectionModel(selModel);
  }
Example #28
0
 @Override
 public void setSelectionMode(int selectionMode) {
   delegate.setSelectionMode(selectionMode);
 }
Example #29
0
 @Override
 public void setLeadSelectionIndex(int index) {
   delegate.setLeadSelectionIndex(sortedModel.convertRowIndexToModel(index));
 }
Example #30
0
 @Override
 public int getLeadSelectionIndex() {
   return sortedModel.convertRowIndexToView(delegate.getLeadSelectionIndex());
 }