use of javax.swing.event.ListSelectionEvent in project otapij by FellowTraveler.
the class MainPage method initMainTab.
private void initMainTab() {
jPanel_TopPanel.setLayout(new CardLayout());
jPanel_BottomPanel.setLayout(new CardLayout());
jTable_AccountTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting()) {
return;
}
System.out.println("valueChanged Action Listener :" + jTable_AccountTable.getSelectedRow() + "e:" + e.getSource());
if (jTable_AccountTable.getSelectedRow() >= 0) {
try {
jPanel_TopPanel.setVisible(true);
jPanel_BottomPanel.setVisible(true);
CardLayout topLayout = (CardLayout) (jPanel_TopPanel.getLayout());
CardLayout bottomlayout = (CardLayout) (jPanel_BottomPanel.getLayout());
String type = null;
String accountID = null;
type = (String) jTable_AccountTable.getModel().getValueAt(jTable_AccountTable.getSelectedRow(), 2);
accountID = (String) jTable_AccountTable.getModel().getValueAt(jTable_AccountTable.getSelectedRow(), 3);
System.out.println("Type:" + type);
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
for (int i = 0; i < Account.allAccounts.length; i++) {
if (Account.allAccounts[i].equalsIgnoreCase(type)) {
try {
topLayout.show(jPanel_TopPanel, type + "TopPanel");
bottomlayout.show(jPanel_BottomPanel, type + "BottomPanel");
Class obj = Class.forName("com.moneychanger.core." + type);
Account account = (Account) obj.newInstance();
Object details = account.getAccountDetails(accountID);
if (details == null) {
JOptionPane.showMessageDialog(null, "Error loading details", "Details Error", JOptionPane.ERROR_MESSAGE);
break;
}
if ("OpenTransactionAccount".equalsIgnoreCase(type)) {
OTDetails otDetails = (OTDetails) details;
Helpers.populateOTDetails(otDetails);
((AccountTableModel) jTable_AccountTable.getModel()).setValueAt(otDetails.getBalance(), jTable_AccountTable.getSelectedRow(), 1);
} else if ("CashPurseAccount".equalsIgnoreCase(type)) {
CashPurseDetails cashDetails = (CashPurseDetails) details;
populateCashPurseDetails(cashDetails, cashDetails.getBalance());
}
break;
} catch (InstantiationException ex) {
Logger.getLogger(MainPage.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
Logger.getLogger(MainPage.class.getName()).log(Level.SEVERE, null, ex);
} catch (ClassNotFoundException ex) {
Logger.getLogger(MainPage.class.getName()).log(Level.SEVERE, null, ex);
}
repaint();
}
}
} catch (Exception ex) {
ex.printStackTrace();
} finally {
setCursor(Cursor.getDefaultCursor());
}
}
}
});
nymMap = new NYM().loadNYM();
jComboBox_Nyms.addItem(new ComboObject("ALL"));
jComboBoxServerContracts.addItem(new ComboObject("ALL"));
jComboBox_AssetContracts.addItem(new ComboObject("ALL"));
Helpers.populateCombo(nymMap, jComboBox_Nyms);
Contract contract = new Contract();
serverMap = contract.loadServerContract();
Helpers.populateCombo(serverMap, jComboBoxServerContracts);
assetMap = contract.loadAssetContract();
Helpers.populateCombo(assetMap, jComboBox_AssetContracts);
Account account = null;
for (int i = 0; i < Account.allAccounts.length; i++) {
try {
if ("OpenTransactionAccount".equals(Account.allAccounts[i]) || "CashPurseAccount".equals(Account.allAccounts[i])) {
Class obj = Class.forName("com.moneychanger.core." + Account.allAccounts[i]);
account = (Account) obj.newInstance();
try {
account.loadAccount("ALL", "ALL", "ALL");
} catch (Exception ex) {
Logger.getLogger(MainPage.class.getName()).log(Level.SEVERE, null, ex);
}
Class obj1 = Class.forName("com.moneychanger.ui.panels." + Account.allAccounts[i] + "TopPanel");
JPanel topPanel = (JPanel) obj1.newInstance();
jPanel_TopPanel.add(topPanel, Account.allAccounts[i] + "TopPanel");
Class obj2 = Class.forName("com.moneychanger.ui.panels." + Account.allAccounts[i] + "BottomPanel");
JPanel bottomPanel = (JPanel) obj2.newInstance();
jPanel_BottomPanel.add(bottomPanel, Account.allAccounts[i] + "BottomPanel");
}
} catch (InstantiationException ex) {
//Logger.getLogger(MainPage.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
///Logger.getLogger(MainPage.class.getName()).log(Level.SEVERE, null, ex);
} catch (ClassNotFoundException ex) {
//Logger.getLogger(MainPage.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
use of javax.swing.event.ListSelectionEvent in project otapij by FellowTraveler.
the class MainPage method initOtherTab.
private void initOtherTab() {
try {
jPanel27.setLayout(new CardLayout());
jPanel28.setLayout(new CardLayout());
System.out.println("in initOtherTab");
//load servers here
loadOtherTabServers();
jTable4.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting()) {
return;
}
System.out.println("selectedRow:" + jTable4.getSelectedRow());
if (jTable4.getSelectedRow() >= 0) {
String serverID = (String) jTable4.getModel().getValueAt(jTable4.getSelectedRow(), 2);
String type = (String) jTable4.getModel().getValueAt(jTable4.getSelectedRow(), 1);
System.out.println("selected serverID:" + serverID + " type:" + type);
if ("BitcoinAccount".equals(type)) {
Account account = null;
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
try {
try {
account = (Account) (Class.forName("com.moneychanger.core." + type)).newInstance();
account.setServerID(serverID);
} catch (InstantiationException ex) {
Logger.getLogger(MainPage.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
Logger.getLogger(MainPage.class.getName()).log(Level.SEVERE, null, ex);
}
} catch (ClassNotFoundException ex) {
Logger.getLogger(MainPage.class.getName()).log(Level.SEVERE, null, ex);
}
/*if (type.contains("Bitcoin")) {
account = new BitcoinAccount(serverID);
}*/
try {
account.loadAccount("", serverID, "");
((OtherTabAccountModel) jTable3.getModel()).setValue(account.getAccountList(), jTable3);
} catch (Exception ex) {
System.out.println("In BTC load exception:" + ex);
JOptionPane.showMessageDialog(null, "Cannot connect to bitcoin service - Connection refused", "Connection Error", JOptionPane.ERROR_MESSAGE);
//jTable4.setRowSelectionInterval(WIDTH, WIDTH);
} finally {
setCursor(Cursor.getDefaultCursor());
}
} else if ("RippleAccount".equalsIgnoreCase(type)) {
CardLayout topLayout = (CardLayout) (jPanel27.getLayout());
CardLayout bottomlayout = (CardLayout) (jPanel28.getLayout());
topLayout.show(jPanel27, "BlankTop");
bottomlayout.show(jPanel28, "BlankBottom");
((OtherTabAccountModel) jTable3.getModel()).clearValue();
String[] details = new RippleAccount().loadServerDetails(serverID);
if (details != null) {
RippleAccountTopPanel.openBrowser(details[0], details[1], details[2], details[3], details[4]);
}
}
}
}
});
//((OtherTabServerTableModel) jTable4.getModel()).setValue(new NYM().loadNYM(), jTable4);
jTable3.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting()) {
return;
}
System.out.println("valueChanged Action Listener :" + jTable3.getSelectedRow() + "e:" + e.getSource());
if (jTable3.getSelectedRow() >= 0) {
try {
jPanel27.setVisible(true);
jPanel28.setVisible(true);
CardLayout topLayout = (CardLayout) (jPanel27.getLayout());
CardLayout bottomlayout = (CardLayout) (jPanel28.getLayout());
String type = null;
String accountID = null;
type = (String) jTable3.getModel().getValueAt(jTable3.getSelectedRow(), 2);
accountID = (String) jTable3.getModel().getValueAt(jTable3.getSelectedRow(), 3);
System.out.println("Type:" + type);
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
for (int i = 0; i < Account.allAccounts.length; i++) {
if (Account.allAccounts[i].equalsIgnoreCase(type)) {
try {
topLayout.show(jPanel27, type + "TopPanel");
bottomlayout.show(jPanel28, type + "BottomPanel");
Class obj = Class.forName("com.moneychanger.core." + type);
Account account = (Account) obj.newInstance();
account.setServerID((String) jTable4.getModel().getValueAt(jTable4.getSelectedRow(), 2));
Object details = account.getAccountDetails(accountID);
if (details == null) {
JOptionPane.showMessageDialog(null, "Error loading details", "Details Error", JOptionPane.ERROR_MESSAGE);
break;
}
if ("BitcoinAccount".equalsIgnoreCase(type)) {
BitcoinDetails btcDetails = (BitcoinDetails) details;
populateBitcoinDetails(btcDetails);
}
//}
} catch (InstantiationException ex) {
Logger.getLogger(MainPage.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
Logger.getLogger(MainPage.class.getName()).log(Level.SEVERE, null, ex);
} catch (ClassNotFoundException ex) {
Logger.getLogger(MainPage.class.getName()).log(Level.SEVERE, null, ex);
}
repaint();
}
}
} catch (Exception ex) {
ex.printStackTrace();
} finally {
setCursor(Cursor.getDefaultCursor());
}
}
}
});
jPanel27.add(new BlankPanel(), "BlankTop");
jPanel28.add(new BlankPanel(), "BlankBottom");
for (int i = 0; i < Account.allAccounts.length; i++) {
try {
System.out.println("in initOtherTabloop");
if (!"OpenTransactionAccount".equals(Account.allAccounts[i]) && !"CashPurseAccount".equals(Account.allAccounts[i])) {
System.out.println("initOtherTabloop --- Account.allAccounts[i]:" + Account.allAccounts[i]);
Class obj1 = Class.forName("com.moneychanger.ui.panels." + Account.allAccounts[i] + "TopPanel");
JPanel topPanel = (JPanel) obj1.newInstance();
jPanel27.add(topPanel, Account.allAccounts[i] + "TopPanel");
Class obj2 = Class.forName("com.moneychanger.ui.panels." + Account.allAccounts[i] + "BottomPanel");
JPanel bottomPanel = (JPanel) obj2.newInstance();
// Setting the account account to retrieve in bottom panel
jPanel28.add(bottomPanel, Account.allAccounts[i] + "BottomPanel");
}
} catch (InstantiationException ex) {
//Logger.getLogger(MainPage.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
///Logger.getLogger(MainPage.class.getName()).log(Level.SEVERE, null, ex);
} catch (ClassNotFoundException ex) {
//Logger.getLogger(MainPage.class.getName()).log(Level.SEVERE, null, ex);
}
}
// TODO might need to uncomment
//loadOtherTabAccount("");
OtherTabAccountModel.removeCols(jTable3);
OtherTabServerTableModel.removeCols(jTable4);
} catch (Exception e) {
e.printStackTrace();
}
}
use of javax.swing.event.ListSelectionEvent in project adempiere by adempiere.
the class WFActivity method jbInit.
// dynInit
/**
* Static Init.
* Called after Dynamic Init
* @throws Exception
*/
private void jbInit() throws Exception {
int width = 150;
centerPanel.setLayout(centerLayout);
fNode.setReadWrite(false);
fDescription.setReadWrite(false);
fDescription.setPreferredSize(new Dimension(width, 40));
fHelp.setReadWrite(false);
fHelp.setPreferredSize(new Dimension(width, 40));
fHistory.setReadWrite(false);
fHistory.setPreferredSize(new Dimension(width, 80));
fTextMsg.setPreferredSize(new Dimension(width, 40));
//
// bPrevious.addActionListener(this);
// bNext.addActionListener(this);
selTable.setModel(selTableModel);
// 0-ID
selTable.setColumnClass(0, IDColumn.class, false, " ");
// 1-Priority
selTable.setColumnClass(1, Integer.class, true);
// 2-AD_WF_Node_ID
selTable.setColumnClass(2, String.class, true);
// 3-Summary
selTable.setColumnClass(3, String.class, true);
selTable.getSelectionModel().addListSelectionListener(this);
// Listen the Column Move Event
selTable.getColumnModel().addColumnModelListener(new TableColumnModelListener() {
public void columnMoved(TableColumnModelEvent e) {
if (columnValue == -1)
columnValue = e.getFromIndex();
columnNewValue = e.getToIndex();
}
@Override
public void columnAdded(TableColumnModelEvent e) {
}
@Override
public void columnMarginChanged(ChangeEvent e) {
}
@Override
public void columnRemoved(TableColumnModelEvent e) {
}
@Override
public void columnSelectionChanged(ListSelectionEvent e) {
}
});
//Listen the mouse released Moved
selTable.getTableHeader().addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
if (columnValue != -1 && (columnValue == 0 || columnNewValue == 0))
selTable.moveColumn(columnNewValue, columnValue);
columnValue = -1;
columnNewValue = -1;
}
});
bZoom.addActionListener(this);
bOK.addActionListener(this);
//
this.setLayout(new BorderLayout());
this.add(centerPanel, BorderLayout.CENTER);
this.add(statusBar, BorderLayout.SOUTH);
//
// answers.setOpaque(false);
answers.add(fAnswerText);
answers.add(fAnswerList);
answers.add(fAnswerButton);
fAnswerButton.addActionListener(this);
//
int row = 0;
selPane.setPreferredSize(new Dimension(width, 60));
selPane.setMinimumSize(new Dimension(100, 60));
centerPanel.add(selPane, new GridBagConstraints(0, row, 4, 1, 0.3, 0.3, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(5, 10, 5, 10), 0, 0));
centerPanel.add(lNode, new GridBagConstraints(0, ++row, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(5, 10, 5, 5), 0, 0));
centerPanel.add(fNode, new GridBagConstraints(1, row, 3, 2, 0.5, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 10), 0, 0));
centerPanel.add(lDesctiption, new GridBagConstraints(0, ++row, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(5, 10, 5, 5), 0, 0));
centerPanel.add(fDescription, new GridBagConstraints(1, row, 3, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 10), 0, 0));
centerPanel.add(lHelp, new GridBagConstraints(0, ++row, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(2, 10, 5, 5), 0, 0));
centerPanel.add(fHelp, new GridBagConstraints(1, row, 3, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(2, 0, 5, 10), 0, 0));
centerPanel.add(lHistory, new GridBagConstraints(0, ++row, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(5, 10, 5, 5), 0, 0));
centerPanel.add(fHistory, new GridBagConstraints(1, row, 3, 1, 0.5, 0.5, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(5, 0, 5, 10), 0, 0));
centerPanel.add(lAnswer, new GridBagConstraints(0, ++row, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(10, 10, 5, 5), 0, 0));
centerPanel.add(answers, new GridBagConstraints(1, row, 2, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 0, 5, 5), 0, 0));
centerPanel.add(bZoom, new GridBagConstraints(3, row, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(10, 0, 10, 10), 0, 0));
centerPanel.add(lTextMsg, new GridBagConstraints(0, ++row, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(5, 10, 5, 5), 0, 0));
centerPanel.add(fTextMsg, new GridBagConstraints(1, row, 3, 1, 0.5, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 10), 0, 0));
centerPanel.add(lForward, new GridBagConstraints(0, ++row, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(10, 10, 5, 5), 0, 0));
centerPanel.add(fForward, new GridBagConstraints(1, row, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 0, 5, 0), 0, 0));
centerPanel.add(lOptional, new GridBagConstraints(2, row, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 5, 5, 5), 0, 0));
centerPanel.add(bOK, new GridBagConstraints(3, row, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(10, 5, 5, 10), 0, 0));
}
use of javax.swing.event.ListSelectionEvent in project intellij-community by JetBrains.
the class ModuleAwareProjectConfigurable method createComponent.
@Override
public JComponent createComponent() {
if (myProject.isDefault()) {
T configurable = createDefaultProjectConfigurable();
if (configurable != null) {
myModuleConfigurables.put(null, configurable);
return configurable.createComponent();
}
}
final List<Module> modules = ContainerUtil.filter(ModuleAttachProcessor.getSortedModules(myProject), module -> isSuitableForModule(module));
final T projectConfigurable = createProjectConfigurable();
if (modules.size() == 1 && projectConfigurable == null) {
Module module = modules.get(0);
final T configurable = createModuleConfigurable(module);
myModuleConfigurables.put(module, configurable);
return configurable.createComponent();
}
final Splitter splitter = new Splitter(false, 0.25f);
CollectionListModel<Module> listDataModel = new CollectionListModel<>(modules);
final JBList moduleList = new JBList(listDataModel);
new ListSpeedSearch(moduleList, (Function<Object, String>) o -> {
if (o == null) {
return getProjectConfigurableItemName();
} else if (o instanceof Module) {
return ((Module) o).getName();
}
return null;
});
moduleList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
moduleList.setCellRenderer(new ModuleListCellRenderer() {
@Override
public void customize(JList list, Module module, int index, boolean selected, boolean hasFocus) {
if (module == null) {
setText(getProjectConfigurableItemName());
setIcon(getProjectConfigurableItemIcon());
} else {
super.customize(list, module, index, selected, hasFocus);
}
}
});
splitter.setFirstComponent(new JBScrollPane(moduleList));
final CardLayout layout = new CardLayout();
final JPanel cardPanel = new JPanel(layout);
splitter.setSecondComponent(cardPanel);
if (projectConfigurable != null) {
myModuleConfigurables.put(null, projectConfigurable);
final JComponent component = projectConfigurable.createComponent();
cardPanel.add(component, PROJECT_ITEM_KEY);
listDataModel.add(0, null);
}
for (Module module : modules) {
final T configurable = createModuleConfigurable(module);
myModuleConfigurables.put(module, configurable);
final JComponent component = configurable.createComponent();
cardPanel.add(component, module.getName());
}
moduleList.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
final Module value = (Module) moduleList.getSelectedValue();
layout.show(cardPanel, value == null ? PROJECT_ITEM_KEY : value.getName());
}
});
if (moduleList.getItemsCount() > 0) {
moduleList.setSelectedIndex(0);
Module module = listDataModel.getElementAt(0);
layout.show(cardPanel, module == null ? PROJECT_ITEM_KEY : module.getName());
}
return splitter;
}
use of javax.swing.event.ListSelectionEvent in project intellij-community by JetBrains.
the class GotoActionAction method createPopup.
@Nullable
private static ChooseByNamePopup createPopup(@Nullable Project project, @NotNull final GotoActionModel model, String initialText, int initialIndex, final Component component, final AnActionEvent e) {
ChooseByNamePopup oldPopup = project == null ? null : project.getUserData(ChooseByNamePopup.CHOOSE_BY_NAME_POPUP_IN_PROJECT_KEY);
if (oldPopup != null) {
oldPopup.close(false);
}
final Disposable disposable = Disposer.newDisposable();
final ChooseByNamePopup popup = new ChooseByNamePopup(project, model, new GotoActionItemProvider(model), oldPopup, initialText, false, initialIndex) {
private boolean myPaintInternalInfo;
@Override
protected void initUI(Callback callback, ModalityState modalityState, boolean allowMultipleSelection) {
super.initUI(callback, modalityState, allowMultipleSelection);
myList.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
Object value = myList.getSelectedValue();
String text = getText(value);
if (text != null && myDropdownPopup != null) {
myDropdownPopup.setAdText(text, SwingConstants.LEFT);
}
String description = getValueDescription(value);
ActionMenu.showDescriptionInStatusBar(true, myList, description);
}
@Nullable
private String getText(@Nullable Object o) {
if (o instanceof GotoActionModel.MatchedValue) {
GotoActionModel.MatchedValue mv = (GotoActionModel.MatchedValue) o;
if (myPaintInternalInfo) {
if (mv.value instanceof GotoActionModel.ActionWrapper) {
AnAction action = ((GotoActionModel.ActionWrapper) mv.value).getAction();
String actionId = ActionManager.getInstance().getId(action);
return StringUtil.notNullize(actionId, "class: " + action.getClass().getName());
}
}
if (mv.value instanceof BooleanOptionDescription || mv.value instanceof GotoActionModel.ActionWrapper && ((GotoActionModel.ActionWrapper) mv.value).getAction() instanceof ToggleAction) {
return "Press " + KeymapUtil.getKeystrokeText(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0)) + " to toggle option";
}
}
return getAdText();
}
});
myList.addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseMoved(MouseEvent e) {
int index = myList.locationToIndex(e.getPoint());
if (index == -1)
return;
Object value = myList.getModel().getElementAt(index);
String description = getValueDescription(value);
ActionMenu.showDescriptionInStatusBar(true, myList, description);
}
});
if (Registry.is("show.configurables.ids.in.settings")) {
new HeldDownKeyListener() {
@Override
protected void heldKeyTriggered(JComponent component, boolean pressed) {
myPaintInternalInfo = pressed;
// an easy way to repaint the AdText
ListSelectionEvent event = new ListSelectionEvent(this, -1, -1, false);
for (ListSelectionListener listener : myList.getListSelectionListeners()) {
listener.valueChanged(event);
}
}
}.installOn(myTextField);
}
}
@Nullable
private String getValueDescription(@Nullable Object value) {
if (value instanceof GotoActionModel.MatchedValue) {
GotoActionModel.MatchedValue mv = (GotoActionModel.MatchedValue) value;
if (mv.value instanceof GotoActionModel.ActionWrapper) {
AnAction action = ((GotoActionModel.ActionWrapper) mv.value).getAction();
return action.getTemplatePresentation().getDescription();
}
}
return null;
}
@NotNull
@Override
protected Set<Object> filter(@NotNull Set<Object> elements) {
return super.filter(model.sortItems(elements));
}
@Override
protected boolean closeForbidden(boolean ok) {
if (!ok)
return false;
Object element = getChosenElement();
return element instanceof GotoActionModel.MatchedValue && processOptionInplace(((GotoActionModel.MatchedValue) element).value, this, component, e) || super.closeForbidden(true);
}
@Override
public void setDisposed(boolean disposedFlag) {
super.setDisposed(disposedFlag);
Disposer.dispose(disposable);
ActionMenu.showDescriptionInStatusBar(true, myList, null);
for (ListSelectionListener listener : myList.getListSelectionListeners()) {
myList.removeListSelectionListener(listener);
}
UIUtil.dispose(myList);
}
};
ApplicationManager.getApplication().getMessageBus().connect(disposable).subscribe(ProgressWindow.TOPIC, new ProgressWindow.Listener() {
@Override
public void progressWindowCreated(ProgressWindow pw) {
Disposer.register(pw, new Disposable() {
@Override
public void dispose() {
if (!popup.checkDisposed()) {
popup.repaintList();
}
}
});
}
});
if (project != null) {
project.putUserData(ChooseByNamePopup.CHOOSE_BY_NAME_POPUP_IN_PROJECT_KEY, popup);
}
popup.addMouseClickListener(new MouseAdapter() {
@Override
public void mouseClicked(@NotNull MouseEvent me) {
Object element = popup.getSelectionByPoint(me.getPoint());
if (element instanceof GotoActionModel.MatchedValue) {
if (processOptionInplace(((GotoActionModel.MatchedValue) element).value, popup, component, e)) {
me.consume();
}
}
}
});
CustomShortcutSet shortcutSet = new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap().getShortcuts(IdeActions.ACTION_SHOW_INTENTION_ACTIONS));
new DumbAwareAction() {
@Override
public void actionPerformed(AnActionEvent e) {
Object o = popup.getChosenElement();
if (o instanceof GotoActionModel.MatchedValue) {
Comparable value = ((GotoActionModel.MatchedValue) o).value;
if (value instanceof GotoActionModel.ActionWrapper) {
GotoActionModel.ActionWrapper aw = (GotoActionModel.ActionWrapper) value;
boolean available = aw.isAvailable();
if (available) {
AnAction action = aw.getAction();
String id = ActionManager.getInstance().getId(action);
KeymapManagerImpl km = ((KeymapManagerImpl) KeymapManager.getInstance());
Keymap k = km.getActiveKeymap();
if (!k.canModify())
return;
KeymapPanel.addKeyboardShortcut(id, ActionShortcutRestrictions.getInstance().getForActionId(id), k, component);
popup.repaintListImmediate();
}
}
}
}
}.registerCustomShortcutSet(shortcutSet, popup.getTextField(), disposable);
return popup;
}
Aggregations