use of java.awt.event.MouseEvent in project android by JetBrains.
the class WorkBenchTest method fireButtonDropped.
private void fireButtonDropped(@NotNull JComponent dragImage, int xStart, int yStart, int x, int y) {
AbstractButton button = myToolWindow1.getMinimizedButton();
MouseEvent mouseEvent = new MouseEvent(button, MouseEvent.MOUSE_RELEASED, 1, InputEvent.BUTTON1_MASK, x, y, 1, false);
DragEvent event = new DragEvent(mouseEvent, dragImage, new Point(xStart, yStart));
myToolWindow1.fireButtonDropped(event);
}
use of java.awt.event.MouseEvent 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));
}
use of java.awt.event.MouseEvent 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 " " part so set the text here.
mySignatureHelpLabel.setText("<html><a href=\"\">Signature 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);
}
}
}
}
});
}
use of java.awt.event.MouseEvent 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));
}
});
}
use of java.awt.event.MouseEvent 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();
}
}
});
}
Aggregations