Search in sources :

Example 76 with ListSelectionEvent

use of javax.swing.event.ListSelectionEvent in project otapij by FellowTraveler.

the class AddressBookDialog method initValues.

private void initValues() {
    ContactTableModel.removeCols(jTable5);
    switch(mode) {
        case 1:
            {
                jRadioButton1.setSelected(true);
                ((ContactDetailsTableModel) jTable6.getModel()).setColumnNames(new String[] { "Account List" });
                System.out.println("In case1");
            }
            break;
        case 2:
            {
                jRadioButton2.setSelected(true);
                ((ContactDetailsTableModel) jTable6.getModel()).setColumnNames(new String[] { "Nym List" });
            }
            break;
        case 3:
            break;
        default:
            break;
    }
    ((ContactTableModel) jTable5.getModel()).setValue(AddressBookHelper.getContactList());
    jPanel3.setLayout(new CardLayout());
    jPanel3.add(new BlankPanel(), "BlankPanel");
    jPanel3.add(new ContactNymPanel(), "ContactNymPanel");
    jPanel3.add(new ContactAcctPanel(), "ContactAcctPanel");
    jTable6.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting()) {
                return;
            }
            if (jTable6.getSelectedRow() >= 0) {
                CardLayout cardLayout = (CardLayout) jPanel3.getLayout();
                if (mode == 1) {
                    cardLayout.show(jPanel3, "ContactAcctPanel");
                    contactDetails = AddressBookHelper.getContactDetails(contactID, mode);
                    if (contactDetails != null) {
                        ContactAcctPanel.setValues(jTable6.getSelectedRow(), contactID);
                        ContactAcctPanel.populateDetails(AddressBookHelper.getContactAccDetails(contactDetails.getContact(), jTable6.getSelectedRow()));
                    }
                // Set details panel here
                } else if (mode == 2) {
                    cardLayout.show(jPanel3, "ContactNymPanel");
                    contactDetails = AddressBookHelper.getContactDetails(contactID, mode);
                    if (contactDetails != null) {
                        ContactNymPanel.setValues(jTable6.getSelectedRow(), contactID);
                        ContactNymPanel.populateDetails(AddressBookHelper.getContactNymDetails(contactDetails.getContact(), jTable6.getSelectedRow()));
                    }
                } else {
                    cardLayout.show(jPanel3, "BlankPanel");
                }
            }
        }
    });
    jTable5.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting()) {
                return;
            }
            if (jTable5.getSelectedRow() >= 0) {
                if (!jRadioButton1.isSelected() && !jRadioButton2.isSelected()) {
                    JOptionPane.showMessageDialog(null, "Please select mode", "Mode Error", JOptionPane.ERROR_MESSAGE);
                    return;
                }
                if (jRadioButton2.isSelected()) {
                    jButton2.setEnabled(false);
                    jButton3.setEnabled(true);
                    ((ContactDetailsTableModel) jTable6.getModel()).setColumnNames(new String[] { "Nym List" });
                    mode = 2;
                } else if (jRadioButton1.isSelected()) {
                    jButton2.setEnabled(true);
                    jButton3.setEnabled(false);
                    ((ContactDetailsTableModel) jTable6.getModel()).setColumnNames(new String[] { "Account List" });
                    mode = 1;
                }
                contactID = (String) jTable5.getModel().getValueAt(jTable5.getSelectedRow(), 1);
                ContactDetails contactDetails = AddressBookHelper.getContactDetails(contactID, mode);
                populateContactDetails(contactDetails, mode);
            }
        }
    });
}
Also used : ContactTableModel(com.moneychanger.ui.model.ContactTableModel) CardLayout(java.awt.CardLayout) ContactNymPanel(com.moneychanger.ui.panels.ContactNymPanel) ContactDetails(com.moneychanger.core.dataobjects.ContactDetails) ListSelectionEvent(javax.swing.event.ListSelectionEvent) BlankPanel(com.moneychanger.ui.panels.BlankPanel) ContactAcctPanel(com.moneychanger.ui.panels.ContactAcctPanel) ListSelectionListener(javax.swing.event.ListSelectionListener) ContactDetailsTableModel(com.moneychanger.ui.model.ContactDetailsTableModel)

Example 77 with ListSelectionEvent

use of javax.swing.event.ListSelectionEvent in project otapij by FellowTraveler.

the class MainPage method initBasketsTab.

private void initBasketsTab() {
    Helpers.populateComboWithoutAll(serverMap, jComboBox7);
    BasketTableModel.removeCols(jTable19);
    jLabel62.setText("");
    String currentServerID = "ALL";
    if (serverMap != null && serverMap.size() > 0 && jComboBox7.getSelectedIndex() > -1) {
        currentServerID = ((String[]) serverMap.get((Integer) jComboBox7.getSelectedIndex()))[1];
    }
    List baskets = Basket.getBasketList(currentServerID, null);
    System.out.println("baskets:" + baskets);
    System.out.println("baskets.size():" + baskets.size());
    if (baskets != null && baskets.size() > 0 && !"Popup Dialog".equalsIgnoreCase(((String[]) baskets.get(0))[0])) {
        ((BasketTableModel) jTable19.getModel()).setValue(baskets);
    } else if (baskets != null && !baskets.isEmpty()) {
        // Show dialog asking for register
        new RegisterNymOnServerDialog(this, true, currentServerID).setVisible(true);
        if (!Utility.VerifyStringVal(Helpers.getNymID())) {
            return;
        }
        String nymID = Helpers.getNymID();
        ((BasketTableModel) jTable19.getModel()).setValue(Basket.getBasketList(currentServerID, nymID));
    }
    jTable19.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting()) {
                return;
            }
            System.out.println("jTable19 valueChanged Basket List Action Listener :" + jTable19.getSelectedRow() + "e:" + e.getSource());
            basketClick();
        }
    });
}
Also used : BasketTableModel(com.moneychanger.ui.model.BasketTableModel) RegisterNymOnServerDialog(com.moneychanger.ui.dialogs.RegisterNymOnServerDialog) ListSelectionEvent(javax.swing.event.ListSelectionEvent) List(java.util.List) ListSelectionListener(javax.swing.event.ListSelectionListener)

Example 78 with ListSelectionEvent

use of javax.swing.event.ListSelectionEvent in project otapij by FellowTraveler.

the class MainPage method initPaymentsInitTab.

private void initPaymentsInitTab() {
    PaymentInboxTableModel.removeCols(jTable20);
    PaymentOutboxTableModel.removeCols(jTable21);
    PaymentRecordboxTableModel.removeCols(jTable22);
    setCustomWidthPayments();
    NYMTableModel.removeCols(jTable6);
    Helpers.populateComboWithoutAll(serverMap, jComboSrvPay);
    ((NYMTableModel) jTable6.getModel()).setValue(new NYM().loadNYM(), jTable6);
    jTable6.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting()) {
                return;
            }
            System.out.println("jTable6 valueChanged Payment List Action Listener :" + jTable6.getSelectedRow() + "e:" + e.getSource());
            try {
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                paymentClick();
            } catch (InterruptedException ex) {
                Logger.getLogger(MainPage.class.getName()).log(Level.SEVERE, null, ex);
            } finally {
                setCursor(Cursor.getDefaultCursor());
            }
        }
    });
}
Also used : NYMTableModel(com.moneychanger.ui.model.NYMTableModel) NYM(com.moneychanger.core.NYM) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ListSelectionListener(javax.swing.event.ListSelectionListener)

Example 79 with ListSelectionEvent

use of javax.swing.event.ListSelectionEvent in project android by JetBrains.

the class ConfigureAvdOptionsStep method bindComponents.

private void bindComponents() {
    myBindings.bindTwoWay(new TextProperty(myAvdDisplayName), getModel().avdDisplayName());
    myBindings.bind(new TextProperty(myAvdId), new StringExpression(getModel().avdDisplayName()) {

        @NotNull
        @Override
        public String get() {
            String displayName = getModel().avdDisplayName().get();
            getModel().avdId().set(StringUtil.isNotEmpty(displayName) ? AvdWizardUtils.cleanAvdName(connection, displayName, !displayName.equals(myOriginalName)) : "");
            return getModel().avdId().get();
        }
    });
    myBindings.bindTwoWay(new TextProperty(mySystemImageName), getModel().systemImageName());
    myBindings.bindTwoWay(new TextProperty(mySystemImageDetails), getModel().systemImageDetails());
    myBindings.bindTwoWay(new SelectedProperty(myQemu2CheckBox), getModel().useQemu2());
    myBindings.bindTwoWay(new SelectedItemProperty<Integer>(myCoreCount), getModel().cpuCoreCount());
    myBindings.bindTwoWay(myRamStorage.storage(), getModel().getAvdDeviceData().ramStorage());
    myBindings.bindTwoWay(myVmHeapStorage.storage(), getModel().vmHeapStorage());
    myBindings.bindTwoWay(myInternalStorage.storage(), getModel().internalStorage());
    myBindings.bindTwoWay(myBuiltInSdCardStorage.storage(), new OptionalToValuePropertyAdapter<Storage>(getModel().sdCardStorage()));
    myBindings.bindTwoWay(new SelectedItemProperty<GpuMode>(myHostGraphics), getModel().hostGpuMode());
    myBindings.bindTwoWay(new SelectedProperty(myDeviceFrameCheckbox), getModel().hasDeviceFrame());
    myBindings.bindTwoWay(new SelectedItemProperty<File>(mySkinComboBox.getComboBox()), getModel().getAvdDeviceData().customSkinFile());
    myOrientationToggle.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            ScreenOrientation orientation = myOrientationToggle.getSelectedElement();
            if (orientation == null) {
                getModel().selectedAvdOrientation().set(ScreenOrientation.PORTRAIT);
            } else {
                getModel().selectedAvdOrientation().set(orientation);
            }
        }
    });
    FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false) {

        @Override
        public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
            return super.isFileVisible(file, true);
        }
    };
    fileChooserDescriptor.setHideIgnored(false);
    myExternalSdCard.addBrowseFolderListener("Select SD Card", "Select an existing SD card image", myProject, fileChooserDescriptor);
    myBindings.bindTwoWay(new TextProperty(myExternalSdCard.getTextField()), getModel().externalSdCardLocation());
    myBindings.bindTwoWay(new OptionalToValuePropertyAdapter<AvdCamera>(new SelectedItemProperty<AvdCamera>(myFrontCameraCombo)), getModel().selectedFrontCamera());
    myBindings.bindTwoWay(new OptionalToValuePropertyAdapter<AvdCamera>(new SelectedItemProperty<AvdCamera>(myBackCameraCombo)), getModel().selectedBackCamera());
    myBindings.bindTwoWay(new OptionalToValuePropertyAdapter<AvdNetworkSpeed>(new SelectedItemProperty<AvdNetworkSpeed>(mySpeedCombo)), getModel().selectedNetworkSpeed());
    myBindings.bindTwoWay(new OptionalToValuePropertyAdapter<AvdNetworkLatency>(new SelectedItemProperty<AvdNetworkLatency>(myLatencyCombo)), getModel().selectedNetworkLatency());
    myBindings.bindTwoWay(new SelectedProperty(myEnableComputerKeyboard), getModel().enableHardwareKeyboard());
    myBindings.bindTwoWay(new SelectedProperty(myExternalRadioButton), getModel().useExternalSdCard());
    myBindings.bindTwoWay(new SelectedProperty(myBuiltInRadioButton), getModel().useBuiltInSdCard());
    myCheckSdForChanges = true;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) GpuMode(com.android.sdklib.internal.avd.GpuMode) ListSelectionEvent(javax.swing.event.ListSelectionEvent) NotNull(org.jetbrains.annotations.NotNull) TextProperty(com.android.tools.idea.ui.properties.swing.TextProperty) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) ListSelectionListener(javax.swing.event.ListSelectionListener) ScreenOrientation(com.android.resources.ScreenOrientation) SelectedItemProperty(com.android.tools.idea.ui.properties.swing.SelectedItemProperty) StringExpression(com.android.tools.idea.ui.properties.expressions.string.StringExpression) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) SelectedProperty(com.android.tools.idea.ui.properties.swing.SelectedProperty)

Example 80 with ListSelectionEvent

use of javax.swing.event.ListSelectionEvent in project intellij-community by JetBrains.

the class ShowFeatureUsageStatisticsDialog method createCenterPanel.

protected JComponent createCenterPanel() {
    Splitter splitter = new Splitter(true);
    splitter.setShowDividerControls(true);
    ProductivityFeaturesRegistry registry = ProductivityFeaturesRegistry.getInstance();
    ArrayList<FeatureDescriptor> features = new ArrayList<>();
    for (String id : registry.getFeatureIds()) {
        features.add(registry.getFeatureDescriptor(id));
    }
    final TableView table = new TableView<>(new ListTableModel<>(COLUMNS, features, 0));
    new TableViewSpeedSearch<FeatureDescriptor>(table) {

        @Override
        protected String getItemText(@NotNull FeatureDescriptor element) {
            return element.getDisplayName();
        }
    };
    JPanel controlsPanel = new JPanel(new VerticalFlowLayout());
    Application app = ApplicationManager.getApplication();
    long uptime = System.currentTimeMillis() - app.getStartTime();
    long idleTime = app.getIdleTime();
    final String uptimeS = FeatureStatisticsBundle.message("feature.statistics.application.uptime", ApplicationNamesInfo.getInstance().getFullProductName(), DateFormatUtil.formatDuration(uptime));
    final String idleTimeS = FeatureStatisticsBundle.message("feature.statistics.application.idle.time", DateFormatUtil.formatDuration(idleTime));
    String labelText = uptimeS + ", " + idleTimeS;
    CompletionStatistics stats = ((FeatureUsageTrackerImpl) FeatureUsageTracker.getInstance()).getCompletionStatistics();
    if (stats.dayCount > 0 && stats.sparedCharacters > 0) {
        String total = formatCharacterCount(stats.sparedCharacters, true);
        String perDay = formatCharacterCount(stats.sparedCharacters / stats.dayCount, false);
        labelText += "<br>Code completion has saved you from typing at least " + total + " since " + DateFormatUtil.formatDate(stats.startDate) + " (~" + perDay + " per working day)";
    }
    CumulativeStatistics fstats = ((FeatureUsageTrackerImpl) FeatureUsageTracker.getInstance()).getFixesStats();
    if (fstats.dayCount > 0 && fstats.invocations > 0) {
        labelText += "<br>Quick fixes have saved you from " + fstats.invocations + " possible bugs since " + DateFormatUtil.formatDate(fstats.startDate) + " (~" + fstats.invocations / fstats.dayCount + " per working day)";
    }
    controlsPanel.add(new JLabel(XmlStringUtil.wrapInHtml(labelText)), BorderLayout.NORTH);
    JPanel topPanel = new JPanel(new BorderLayout());
    topPanel.add(controlsPanel, BorderLayout.NORTH);
    topPanel.add(ScrollPaneFactory.createScrollPane(table), BorderLayout.CENTER);
    splitter.setFirstComponent(topPanel);
    final JEditorPane browser = TipUIUtil.createTipBrowser();
    splitter.setSecondComponent(ScrollPaneFactory.createScrollPane(browser));
    table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            Collection selection = table.getSelection();
            try {
                if (selection.isEmpty()) {
                    browser.read(new StringReader(""), null);
                } else {
                    FeatureDescriptor feature = (FeatureDescriptor) selection.iterator().next();
                    TipUIUtil.openTipInBrowser(feature.getTipFileName(), browser, feature.getProvider());
                }
            } catch (IOException ex) {
                LOG.info(ex);
            }
        }
    });
    return splitter;
}
Also used : ArrayList(java.util.ArrayList) ListSelectionEvent(javax.swing.event.ListSelectionEvent) TableViewSpeedSearch(com.intellij.ui.TableViewSpeedSearch) NotNull(org.jetbrains.annotations.NotNull) StringReader(java.io.StringReader) TableView(com.intellij.ui.table.TableView) VerticalFlowLayout(com.intellij.openapi.ui.VerticalFlowLayout) Splitter(com.intellij.openapi.ui.Splitter) IOException(java.io.IOException) ListSelectionListener(javax.swing.event.ListSelectionListener) Collection(java.util.Collection) Application(com.intellij.openapi.application.Application)

Aggregations

ListSelectionEvent (javax.swing.event.ListSelectionEvent)129 ListSelectionListener (javax.swing.event.ListSelectionListener)120 ActionEvent (java.awt.event.ActionEvent)35 JScrollPane (javax.swing.JScrollPane)32 ActionListener (java.awt.event.ActionListener)29 JPanel (javax.swing.JPanel)28 MouseEvent (java.awt.event.MouseEvent)25 BorderLayout (java.awt.BorderLayout)21 JButton (javax.swing.JButton)20 Dimension (java.awt.Dimension)18 JLabel (javax.swing.JLabel)18 JBList (com.intellij.ui.components.JBList)16 MouseAdapter (java.awt.event.MouseAdapter)15 FlowLayout (java.awt.FlowLayout)11 Insets (java.awt.Insets)11 JList (javax.swing.JList)11 NotNull (org.jetbrains.annotations.NotNull)11 KeyAdapter (java.awt.event.KeyAdapter)10 KeyEvent (java.awt.event.KeyEvent)10 ArrayList (java.util.ArrayList)10