use of java.awt.event.ActionEvent in project kotlin by JetBrains.
the class MoveKotlinTopLevelDeclarationsDialog method initFileChooser.
private void initFileChooser(@Nullable KtFile targetFile, @NotNull Set<KtNamedDeclaration> elementsToMove, @NotNull List<KtFile> sourceFiles) {
final PsiDirectory sourceDir = sourceFiles.get(0).getParent();
assert sourceDir != null : sourceFiles.get(0).getVirtualFile().getPath();
fileChooser.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
KotlinFileChooserDialog dialog = new KotlinFileChooserDialog("Choose Containing File", myProject);
File targetFile = new File(getTargetFilePath());
PsiFile targetPsiFile = KotlinRefactoringUtilKt.toPsiFile(targetFile, myProject);
if (targetPsiFile instanceof KtFile) {
dialog.select((KtFile) targetPsiFile);
} else {
PsiDirectory targetDir = KotlinRefactoringUtilKt.toPsiDirectory(targetFile.getParentFile(), myProject);
if (targetDir == null) {
targetDir = sourceDir;
}
dialog.selectDirectory(targetDir);
}
dialog.showDialog();
KtFile selectedFile = dialog.isOK() ? dialog.getSelected() : null;
if (selectedFile != null) {
fileChooser.setText(selectedFile.getVirtualFile().getPath());
}
}
});
String initialTargetPath = targetFile != null ? targetFile.getVirtualFile().getPath() : sourceFiles.get(0).getVirtualFile().getParent().getPath() + "/" + MoveUtilsKt.guessNewFileName(elementsToMove);
fileChooser.setText(initialTargetPath);
}
use of java.awt.event.ActionEvent in project EnrichmentMapApp by BaderLab.
the class AddRanksDialog method createButtonPanel.
private JPanel createButtonPanel() {
okButton = new JButton(new AbstractAction("OK") {
public void actionPerformed(ActionEvent e) {
if (validateDuplicateRankName()) {
loadRanksAndClose();
}
}
});
JButton cancelButton = new JButton(new AbstractAction("Cancel") {
public void actionPerformed(ActionEvent e) {
dispose();
}
});
JPanel buttonPanel = LookAndFeelUtil.createOkCancelPanel(okButton, cancelButton);
LookAndFeelUtil.setDefaultOkCancelKeyStrokes(getRootPane(), okButton.getAction(), cancelButton.getAction());
getRootPane().setDefaultButton(okButton);
okButton.setEnabled(false);
return buttonPanel;
}
use of java.awt.event.ActionEvent in project EnrichmentMapApp by BaderLab.
the class PostAnalysisPanelMediator method showDialog.
@SuppressWarnings("serial")
public void showDialog(Component parent, CyNetworkView netView) {
final EnrichmentMap map = emManager.getEnrichmentMap(netView.getModel().getSUID());
invokeOnEDT(() -> {
final PostAnalysisInputPanel panel = panelFactory.create(map);
final JDialog dialog = new JDialog(swingApplication.getJFrame(), "Add Signature Gene Sets", ModalityType.APPLICATION_MODAL);
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
JButton helpButton = SwingUtil.createOnlineHelpButton(EnrichmentMapBuildProperties.USER_MANUAL_URL, "Online Manual...", serviceRegistrar);
JButton resetButton = new JButton("Reset");
resetButton.addActionListener(e -> panel.reset());
JButton closeButton = new JButton(new AbstractAction("Close") {
@Override
public void actionPerformed(ActionEvent e) {
dialog.dispose();
}
});
JButton runButton = new JButton(new AbstractAction("Add") {
@Override
public void actionPerformed(ActionEvent e) {
if (panel.isReady()) {
Optional<PostAnalysisParameters> params = buildPostAnalysisParameters(panel, map, dialog);
if (params.isPresent()) {
addGeneSets(netView, params.get());
dialog.dispose();
} else {
JOptionPane.showMessageDialog(panel, "Could not run post analysis.", "EnrichmentMap: Error", JOptionPane.WARNING_MESSAGE);
}
}
}
});
JPanel buttonPanel = LookAndFeelUtil.createOkCancelPanel(runButton, closeButton, helpButton, resetButton);
dialog.getContentPane().add(panel, BorderLayout.CENTER);
dialog.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
LookAndFeelUtil.setDefaultOkCancelKeyStrokes(dialog.getRootPane(), runButton.getAction(), closeButton.getAction());
dialog.getRootPane().setDefaultButton(runButton);
dialog.pack();
dialog.setLocationRelativeTo(swingApplication.getJFrame());
dialog.setVisible(true);
});
}
use of java.awt.event.ActionEvent in project EnrichmentMapApp by BaderLab.
the class PostAnalysisSignatureDiscoveryPanel method createSignatureDiscoveryGMTPanel.
/**
* @return Panel for choosing and loading GMT and SignatureGMT Geneset-Files
*/
private JPanel createSignatureDiscoveryGMTPanel() {
signatureDiscoveryGMTFileNameTextField = new JFormattedTextField();
signatureDiscoveryGMTFileNameTextField.setColumns(15);
signatureDiscoveryGMTFileNameTextField.setToolTipText(Messages.GMT_INSTRUCTION);
final Color textFieldForeground = signatureDiscoveryGMTFileNameTextField.getForeground();
signatureDiscoveryGMTFileNameTextField.addPropertyChangeListener("value", (PropertyChangeEvent e) -> {
// if the text is red set it back to black as soon as the user starts typing
signatureDiscoveryGMTFileNameTextField.setForeground(textFieldForeground);
});
JButton selectSigGMTFileButton = new JButton("Browse...");
selectSigGMTFileButton.setToolTipText(Messages.GMT_INSTRUCTION);
selectSigGMTFileButton.setActionCommand("Signature Discovery");
selectSigGMTFileButton.addActionListener((ActionEvent evt) -> {
parentPanel.chooseGMTFile(signatureDiscoveryGMTFileNameTextField);
});
JLabel filterLabel = new JLabel("Filter:");
filterTextField = new JFormattedTextField();
filterTextField.setColumns(4);
filterTextField.setHorizontalAlignment(JTextField.RIGHT);
filterTextField.addPropertyChangeListener("value", (PropertyChangeEvent e) -> {
StringBuilder message = new StringBuilder("The value you have entered is invalid.\n");
Number number = (Number) filterTextField.getValue();
PostAnalysisFilterType filterType = getFilterType();
Optional<Double> value = PostAnalysisInputPanel.validateAndGetFilterValue(number, filterType, message);
savedFilterValues.put(filterType, value.orElse(filterType.defaultValue));
if (!value.isPresent()) {
filterTextField.setValue(filterType.defaultValue);
JOptionPane.showMessageDialog(application.getJFrame(), message.toString(), "Parameter out of bounds", JOptionPane.WARNING_MESSAGE);
}
});
// Types of filters:
// 1. filter by percent, i.e. the overlap between the signature geneset and EM geneset
// has to be X percentage of the EM set it overlaps with for at least one geneset in the enrichment map.
// 2. filter by number, i.e. the overlap between the signature geneset and EM geneset
// has to be X genes of the EM set it overlaps with for at least one geneset in the enrichment map.
// 3. filter by specificity, i.e looking for the signature genesets that are more specific than other genesets
// for instance a drug A that targets only X and Y as opposed to drug B that targets X,y,L,M,N,O,P.
filterTypeCombo = new JComboBox<>();
// default
filterTypeCombo.addItem(PostAnalysisFilterType.NO_FILTER);
// filterTypeCombo.addItem(PostAnalysisFilterType.MANN_WHIT_TWO_SIDED);
// filterTypeCombo.addItem(PostAnalysisFilterType.MANN_WHIT_GREATER);
// filterTypeCombo.addItem(PostAnalysisFilterType.MANN_WHIT_LESS);
filterTypeCombo.addItem(PostAnalysisFilterType.HYPERGEOM);
filterTypeCombo.addItem(PostAnalysisFilterType.NUMBER);
filterTypeCombo.addItem(PostAnalysisFilterType.PERCENT);
filterTypeCombo.addItem(PostAnalysisFilterType.SPECIFIC);
filterTypeCombo.addActionListener(e -> {
updateFilterTextField();
});
updateFilterTextField();
//TODO: Maybe move loading SigGMT to File-selection Event add load button
JButton loadButton = new JButton();
loadButton.setText("Load Gene Sets");
loadButton.addActionListener(e -> {
String filePath = (String) signatureDiscoveryGMTFileNameTextField.getValue();
if (filePath == null || PostAnalysisInputPanel.checkFile(filePath).equals(Color.RED)) {
String message = "Signature GMT file name not valid.\n";
signatureDiscoveryGMTFileNameTextField.setForeground(Color.RED);
JOptionPane.showMessageDialog(application.getJFrame(), message, "Post Analysis Known Signature", JOptionPane.WARNING_MESSAGE);
return;
}
if (!EnrichmentMapParameters.checkFile(filePath)) {
String message = "Signature GMT does not exist.\n";
signatureDiscoveryGMTFileNameTextField.setForeground(Color.RED);
JOptionPane.showMessageDialog(application.getJFrame(), message, "Post Analysis Known Signature", JOptionPane.WARNING_MESSAGE);
return;
}
FilterMetric filterMetric = createFilterMetric();
LoadSignatureSetsActionListener action = loadSignatureSetsActionListenerFactory.create(new File(filePath), filterMetric, parentPanel.getEnrichmentMap());
action.setGeneSetCallback(gs -> {
this.signatureGenesets = gs;
});
action.setFilteredSignatureSetsCallback(selected -> {
availSigSetsModel.clear();
selectedSigSetsModel.clear();
for (String name : selected) availSigSetsModel.addElement(name);
update();
});
action.actionPerformed(null);
});
makeSmall(signatureDiscoveryGMTFileNameTextField, selectSigGMTFileButton);
makeSmall(filterLabel, filterTypeCombo, filterTextField);
makeSmall(loadButton);
JPanel panel = new JPanel();
panel.setBorder(LookAndFeelUtil.createTitledBorder("SigGMT File (contains signature-genesets)"));
final GroupLayout layout = new GroupLayout(panel);
panel.setLayout(layout);
layout.setAutoCreateContainerGaps(true);
layout.setAutoCreateGaps(!LookAndFeelUtil.isAquaLAF());
layout.setHorizontalGroup(layout.createParallelGroup(Alignment.CENTER, true).addGroup(layout.createSequentialGroup().addComponent(signatureDiscoveryGMTFileNameTextField, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE).addComponent(selectSigGMTFileButton, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE)).addGroup(layout.createSequentialGroup().addComponent(filterLabel, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addComponent(filterTypeCombo, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE).addComponent(filterTextField, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE)).addComponent(loadButton, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE));
layout.setVerticalGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(Alignment.CENTER, false).addComponent(signatureDiscoveryGMTFileNameTextField, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addComponent(selectSigGMTFileButton)).addGroup(layout.createParallelGroup(Alignment.CENTER, false).addComponent(filterLabel, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addComponent(filterTypeCombo, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addComponent(filterTextField, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE)).addComponent(loadButton, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE));
if (LookAndFeelUtil.isAquaLAF())
panel.setOpaque(false);
return panel;
}
use of java.awt.event.ActionEvent in project EnrichmentMapApp by BaderLab.
the class CardDialog method createButtonPanel.
@SuppressWarnings("serial")
private JPanel createButtonPanel() {
finishButton = new JButton(new AbstractAction(params.getFinishButtonText()) {
public void actionPerformed(ActionEvent e) {
currentPage.finish();
}
});
JButton cancelButton = new JButton(new AbstractAction("Cancel") {
public void actionPerformed(ActionEvent e) {
dialog.setVisible(false);
}
});
AbstractButton[] additional = params.getAdditionalButtons();
if (additional != null) {
for (AbstractButton button : additional) {
button.addActionListener(e -> {
currentPage.extraButtonClicked(e.getActionCommand());
});
}
}
JPanel buttonPanel = LookAndFeelUtil.createOkCancelPanel(finishButton, cancelButton, additional);
LookAndFeelUtil.setDefaultOkCancelKeyStrokes(dialog.getRootPane(), finishButton.getAction(), cancelButton.getAction());
dialog.getRootPane().setDefaultButton(finishButton);
return buttonPanel;
}
Aggregations