Search in sources :

Example 46 with MouseAdapter

use of java.awt.event.MouseAdapter in project android by JetBrains.

the class NlOldPalettePanel method enableClickToLoadMissingDependency.

private void enableClickToLoadMissingDependency() {
    myPaletteTree.addMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(MouseEvent event) {
            Palette.BaseItem object = getItemForPath(myPaletteTree.getPathForLocation(event.getX(), event.getY()));
            if (needsLibraryLoad(object)) {
                Palette.Item item = (Palette.Item) object;
                String coordinate = item.getGradleCoordinateId();
                assert coordinate != null;
                Module module = getModule();
                assert module != null;
                GradleDependencyManager manager = GradleDependencyManager.getInstance(myProject);
                manager.ensureLibraryIsIncluded(module, toGradleCoordinates(Collections.singletonList(coordinate)), null);
            }
        }
    });
    GradleSyncState.subscribe(myProject, new GradleSyncListener.Adapter() {

        @Override
        public void syncSucceeded(@NotNull Project project) {
            if (checkForNewMissingDependencies()) {
                repaint();
            }
        }
    }, this);
}
Also used : DnDTransferItem(com.android.tools.idea.uibuilder.model.DnDTransferItem) Project(com.intellij.openapi.project.Project) MouseEvent(java.awt.event.MouseEvent) GradleSyncListener(com.android.tools.idea.gradle.project.sync.GradleSyncListener) MouseAdapter(java.awt.event.MouseAdapter) Module(com.intellij.openapi.module.Module) GradleDependencyManager(com.android.tools.idea.gradle.dependencies.GradleDependencyManager)

Example 47 with MouseAdapter

use of java.awt.event.MouseAdapter in project android by JetBrains.

the class ConfigureAvdOptionsStep method addListeners.

private void addListeners() {
    myAvdId.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent mouseEvent) {
            myAvdId.requestFocusInWindow();
        }
    });
    myShowAdvancedSettingsButton.addActionListener(myToggleAdvancedSettingsListener);
    myChangeDeviceButton.addActionListener(myChangeDeviceButtonListener);
    myChangeSystemImageButton.addActionListener(myChangeSystemImageButtonListener);
    myExternalRadioButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            myExternalSdCard.setEnabled(true);
            myBuiltInSdCardStorage.setEnabled(false);
        }
    });
    myBuiltInRadioButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            myExternalSdCard.setEnabled(false);
            myBuiltInSdCardStorage.setEnabled(true);
        }
    });
    myOrientationToggle.setOpaque(false);
    KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener(FOCUS_OWNER, myPropertyChangeListener);
    myListeners.receive(getModel().device(), device -> {
        toggleOptionals(device, true);
        if (device.isPresent()) {
            myDeviceName.setIcon(DeviceDefinitionPreview.getIcon(getModel().getAvdDeviceData()));
            myDeviceName.setText(getModel().device().getValue().getDisplayName());
            updateDeviceDetails();
        }
    });
    List<AbstractProperty<?>> deviceProperties = AbstractProperty.getAll(getModel().getAvdDeviceData());
    deviceProperties.add(getModel().systemImage());
    myListeners.listenAll(deviceProperties).with(new Runnable() {

        @Override
        public void run() {
            if (getModel().systemImage().get().isPresent() && getModel().getAvdDeviceData().customSkinFile().get().isPresent()) {
                File skin = AvdWizardUtils.resolveSkinPath(getModel().getAvdDeviceData().customSkinFile().getValue(), getModel().systemImage().getValue(), FileOpUtils.create());
                if (skin != null) {
                    getModel().getAvdDeviceData().customSkinFile().setValue(skin);
                    if (FileUtil.filesEqual(skin, AvdWizardUtils.NO_SKIN)) {
                        myDeviceFrameCheckbox.setSelected(false);
                    }
                } else {
                    getModel().getAvdDeviceData().customSkinFile().setValue(AvdWizardUtils.NO_SKIN);
                }
            }
        }
    });
    myListeners.listen(getModel().systemImage(), new InvalidationListener() {

        @Override
        public void onInvalidated(@NotNull ObservableValue<?> sender) {
            updateSystemImageData();
        }
    });
    myListeners.receive(getModel().sdCardStorage(), storage -> {
        if (myCheckSdForChanges && storage.isPresent() && !storage.get().equals(myOriginalSdCard)) {
            int result = Messages.showYesNoDialog((Project) null, "Changing the size of the built-in SD card will erase " + "the current contents of the card. Continue?", "Confirm Data Wipe", AllIcons.General.QuestionDialog);
            if (result == Messages.YES) {
                myCheckSdForChanges = false;
            } else {
                getModel().sdCardStorage().setValue(myOriginalSdCard);
            }
        }
    });
    myListeners.listen(getModel().useQemu2(), new InvalidationListener() {

        @Override
        public void onInvalidated(@NotNull ObservableValue<?> sender) {
            toggleSystemOptionals(true);
        }
    });
    myListeners.receive(getModel().selectedAvdOrientation(), screenOrientation -> myOrientationToggle.setSelectedElement(screenOrientation));
}
Also used : MouseEvent(java.awt.event.MouseEvent) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) MouseAdapter(java.awt.event.MouseAdapter) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 48 with MouseAdapter

use of java.awt.event.MouseAdapter in project android by JetBrains.

the class GradleSignStep method _init.

@Override
public void _init() {
    myAndroidModel = AndroidModuleModel.get(myWizard.getFacet());
    PropertiesComponent properties = PropertiesComponent.getInstance(myWizard.getProject());
    String lastSelectedBuildType = properties.getValue(PROPERTY_BUILD_TYPE);
    myBuildTypeComboModel.removeAllElements();
    Set<String> buildTypes = myAndroidModel == null ? Collections.<String>emptySet() : myAndroidModel.getBuildTypes();
    for (String buildType : buildTypes) {
        myBuildTypeComboModel.addElement(buildType);
        if ((lastSelectedBuildType == null && buildType.equals("release")) || buildType.equals(lastSelectedBuildType)) {
            myBuildTypeComboModel.setSelectedItem(buildType);
        }
    }
    myFlavorsListModel.clear();
    List<String> productFlavors;
    if (myAndroidModel == null || myAndroidModel.getProductFlavors().isEmpty()) {
        productFlavors = Collections.emptyList();
    } else {
        // if there are multiple flavors, we want the merged flavor list
        Set<String> mergedFlavors = Sets.newHashSet();
        for (Variant v : myAndroidModel.getAndroidProject().getVariants()) {
            mergedFlavors.add(ExportSignedPackageWizard.getMergedFlavorName(v));
        }
        productFlavors = Lists.newArrayList(mergedFlavors);
        Collections.sort(productFlavors);
    }
    TIntArrayList lastSelectedIndices = new TIntArrayList(productFlavors.size());
    String[] flavors = properties.getValues(PROPERTY_FLAVORS);
    Set<String> lastSelectedFlavors = flavors == null ? Collections.<String>emptySet() : Sets.newHashSet(flavors);
    for (int i = 0; i < productFlavors.size(); i++) {
        String flavor = productFlavors.get(i);
        myFlavorsListModel.addElement(flavor);
        if (lastSelectedFlavors.contains(flavor)) {
            lastSelectedIndices.add(i);
        }
    }
    myFlavorsList.setSelectedIndices(lastSelectedIndices.toNativeArray());
    String lastApkFolderPath = properties.getValue(PROPERTY_APK_PATH);
    File lastApkFolder;
    if (lastApkFolderPath != null) {
        lastApkFolder = new File(lastApkFolderPath);
    } else {
        if (myAndroidModel == null) {
            lastApkFolder = VfsUtilCore.virtualToIoFile(myWizard.getProject().getBaseDir());
        } else {
            lastApkFolder = myAndroidModel.getRootDirPath();
        }
    }
    myApkPathField.setText(lastApkFolder.getAbsolutePath());
    FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    myApkPathField.addBrowseFolderListener("Select APK Destination Folder", null, myWizard.getProject(), descriptor);
    GradleVersion modelVersion = null;
    if (myAndroidModel != null) {
        modelVersion = myAndroidModel.getModelVersion();
    }
    boolean enabled = modelVersion != null && modelVersion.compareIgnoringQualifiers(MIN_SIGNATURE_SELECTION_VERSION) >= 0;
    myV1JarSignatureCheckBox.setEnabled(enabled);
    myV1JarSignatureCheckBox.setSelected(properties.getBoolean(PROPERTY_V1_SIGN));
    myV2FullAPKSignatureCheckBox.setEnabled(enabled);
    myV2FullAPKSignatureCheckBox.setSelected(properties.getBoolean(PROPERTY_V2_SIGN));
    // Set HTML label here; the visual editor does not like the "&nbsp;" part so set the text here.
    mySignatureHelpLabel.setText("<html><a href=\"\">Signature&nbsp;Help</a></html>");
    mySignatureHelpLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    mySignatureHelpLabel.addMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(MouseEvent e) {
            if (Desktop.isDesktopSupported()) {
                Desktop desktop = Desktop.getDesktop();
                if (desktop.isSupported(Desktop.Action.BROWSE)) {
                    URI uri;
                    try {
                        uri = new URI("http://developer.android.com/about/versions/nougat/android-7.0.html#apk_signature_v2");
                    } catch (URISyntaxException ex) {
                        throw new AssertionError(ex);
                    }
                    try {
                        desktop.browse(uri);
                    } catch (IOException ex) {
                        LOG.error("Failed to open URI '" + uri + "'", ex);
                    }
                }
            }
        }
    });
}
Also used : MouseEvent(java.awt.event.MouseEvent) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) MouseAdapter(java.awt.event.MouseAdapter) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) URI(java.net.URI) TIntArrayList(gnu.trove.TIntArrayList) Variant(com.android.builder.model.Variant) GradleVersion(com.android.ide.common.repository.GradleVersion) PropertiesComponent(com.intellij.ide.util.PropertiesComponent) File(java.io.File)

Example 49 with MouseAdapter

use of java.awt.event.MouseAdapter in project android by JetBrains.

the class VmStatsTreeUtils method enableSorting.

// Enable sorting in the vm stats tree table.
// Sorting is ill-defined in the context of a TreeTable since you can't sort across different levels in the
// hierarchy. As a result, we can't hook into JTable's sorting infrastructure and we roll our own. This
// implementation listens to mouse click events on the tree table's header, interprets them as sort requests
// and passes them on to the model.
public static void enableSorting(final TreeTable treeTable, final VmStatsTreeTableModel vmStatsTreeTableModel) {
    JTableHeader header = treeTable.getTableHeader();
    header.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            TableColumnModel columnModel = treeTable.getColumnModel();
            int index = columnModel.getColumnIndexAtX(e.getX());
            vmStatsTreeTableModel.sortByColumn(StatsTableColumn.fromColumnIndex(index));
        }
    });
}
Also used : MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter)

Example 50 with MouseAdapter

use of java.awt.event.MouseAdapter in project android by JetBrains.

the class ThreadsSegment method initializeStateChartsList.

private void initializeStateChartsList() {
    mThreadsList.setCellRenderer(new ThreadsStateCellRenderer());
    mThreadsList.setSelectionBackground(AdtUiUtils.DEFAULT_BACKGROUND_COLOR);
    mThreadsList.setFixedCellHeight(mCellHeight);
    if (mThreadSelectedListener != null) {
        mThreadsList.addListSelectionListener((event) -> {
            int[] selectedThreadsIndices = mThreadsList.getSelectedIndices();
            List<ThreadStateDataSeries> selectedThreads = new ArrayList<>();
            for (int i = 0; i < selectedThreadsIndices.length; i++) {
                selectedThreads.add(mThreadsListModel.get(selectedThreadsIndices[i]));
            }
            mThreadSelectedListener.onSelected(selectedThreads);
        });
    }
    mThreadsList.addMouseMotionListener(new MouseAdapter() {

        @Override
        public void mouseMoved(MouseEvent me) {
            Point p = new Point(me.getX(), me.getY());
            int index = mThreadsList.locationToIndex(p);
            if (index != mHoveredListIndex) {
                mHoveredListIndex = index;
                mThreadsList.repaint();
            }
        }
    });
}
Also used : MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) ThreadStateDataSeries(com.android.tools.profilers.cpu.ThreadStateDataSeries)

Aggregations

MouseAdapter (java.awt.event.MouseAdapter)202 MouseEvent (java.awt.event.MouseEvent)199 JLabel (javax.swing.JLabel)52 JPanel (javax.swing.JPanel)48 ActionEvent (java.awt.event.ActionEvent)36 JScrollPane (javax.swing.JScrollPane)36 BorderLayout (java.awt.BorderLayout)35 Dimension (java.awt.Dimension)34 JButton (javax.swing.JButton)33 ActionListener (java.awt.event.ActionListener)32 Insets (java.awt.Insets)24 GridBagConstraints (java.awt.GridBagConstraints)20 KeyEvent (java.awt.event.KeyEvent)20 KeyAdapter (java.awt.event.KeyAdapter)19 JTextField (javax.swing.JTextField)16 ListSelectionEvent (javax.swing.event.ListSelectionEvent)16 Component (java.awt.Component)15 Point (java.awt.Point)15 JTable (javax.swing.JTable)15 ListSelectionListener (javax.swing.event.ListSelectionListener)15