Пример #1
0
 public void setSelection(final MultiModeSelection mms) {
   //  Impl_ZThread.ddTQ.postTask(new Impl_ZThread.Task(){
   //      public void doTask() {
   mms.render(mmtm.getMultimodeContext(), getSelectedRow() + 1);
   //      }
   //  });
 }
Пример #2
0
  public MultiModeSelection getSelection() throws DeviceException {
    int[] selRows = getSelectedRows();

    int[] selCols = getSelectedColumns();
    // map columns to TableColumnModel
    for (int i = 0, n = selCols.length; i < n; i++)
      selCols[i] =
          convertColumnIndexToModel(selCols[i]) - 1; // +1 used here to compensate for row header

    return new MultiModeSelection(device, mmtm.getMultimodeContext(), selCols, selRows);
  }
Пример #3
0
  protected Component[] getCustomMenuItems() {
    final int[] selRows = this.getSelectedRows();
    Action dc =
        new AbstractAction("Disable channel") {
          public void actionPerformed(ActionEvent e) {
            MultiModeContext mmc = null;
            try {
              mmc = device.getMultiModeContext();
              for (int i = 0, j = selRows.length; i < j; i++) {
                try {
                  mmc.setPreset(IntPool.get(selRows[i] + 1), IntPool.get(-1)).post();
                } catch (ResourceUnavailableException e1) {
                  e1.printStackTrace();
                }
              }
            } catch (DeviceException e1) {
              e1.printStackTrace();
            }
          }
        };
    JMenuItem pmi = null;
    try {
      ArrayList selPresets = new ArrayList();
      PresetContext dpc = device.getDefaultPresetContext();
      MultiModeContext mmc = device.getMultiModeContext();
      for (int i = 0; i < selRows.length; i++) {
        Integer preset =
            mmc.getPreset(IntPool.get(selRows[i] + 1)); // +1 because midi channels indexed from 1
        if (preset.intValue() >= 0) selPresets.add(dpc.getReadablePreset(preset));
      }
      if (selPresets.size() > 0) {

        Object[] sp = ZUtilities.eliminateDuplicates(selPresets.toArray());
        String name =
            (sp.length > 1
                ? "Presets on selected channels"
                : ((ReadablePreset) sp[0]).getDisplayName());
        pmi = ZCommandFactory.getMenu(sp, name);
      }
    } catch (Exception e) {
    }

    Action stm = null;
    if (this.getSelectedRows().length == 1 && this.getSelectedRow() < 16)
      stm =
          new AbstractAction("Set Ch " + (getSelectedRow() + 1) + " as effects channel") {
            public void actionPerformed(ActionEvent e) {
              try {
                device
                    .getMasterContext()
                    .setMasterParam(IntPool.get(245), IntPool.get(getSelectedRow()))
                    .post();
              } catch (Exception e1) {
                e1.printStackTrace();
              }
            }
          };
    ArrayList comps = new ArrayList();
    // comps.add(new PopupCategoryLabel("Multimode"));
    JMenuItem[] mi;
    Component[] mmi;
    if (pmi != null) mi = new JMenuItem[] {pmi, new JMenuItem(dc)};
    else mi = new JMenuItem[] {new JMenuItem(dc)};

    mmi =
        ZCommandFactory.getMenu(new Object[] {mmtm.getMultimodeContext()}, "Multimode")
            .getMenuComponents();
    comps.addAll(Arrays.asList(mmi));
    comps.addAll(Arrays.asList(mi));
    if (stm != null) comps.add(new JMenuItem(stm));
    return (Component[]) comps.toArray(new Component[comps.size()]);
  }