public Icon getIcon() { try { return defPC.getReadablePreset(pm.getValue()).getIcon(); } catch (NoSuchPresetException e) { } catch (ParameterUnavailableException e) { } return null; }
public String getToolTipText() { try { return defPC.getReadablePreset(pm.getValue()).getToolTipText(); } catch (NoSuchPresetException e) { } catch (ParameterUnavailableException e) { } return ""; }
public String toString() { Integer pn = IntPool.get(0); try { pn = pm.getValue(); return new AggRemoteName(pn, defPC.getPresetName(pm.getValue())).toString(); } catch (ParameterUnavailableException e) { // e.printStackTrace(); } catch (NoSuchPresetException e) { } catch (PresetEmptyException e) { return new AggRemoteName(pn, DeviceContext.EMPTY_PRESET).toString(); } return pn.toString(); }
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()]); }