use of com.intellij.openapi.actionSystem.AnActionEvent in project azure-tools-for-java by Microsoft.
the class WebAppDeployDialog method createUIComponents.
private void createUIComponents() {
DefaultTableModel tableModel = new DefaultTableModel() {
@Override
public boolean isCellEditable(int row, int column) {
return false;
}
};
tableModel.addColumn("Name");
tableModel.addColumn("JDK");
tableModel.addColumn("Web container");
tableModel.addColumn("Resource group");
table = new JBTable(tableModel);
table.setRowSelectionAllowed(true);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent event) {
if (event.getValueIsAdjusting())
return;
//System.out.println("row : " + table.getValueAt(table.getSelectedRow(), 0).toString());
fillAppServiceDetails();
}
});
AnActionButton refreshAction = new AnActionButton("Refresh", AllIcons.Actions.Refresh) {
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
refreshAppServices();
}
};
ToolbarDecorator tableToolbarDecorator = ToolbarDecorator.createDecorator(table).setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
createAppService();
}
}).setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
deleteAppService();
}
}).setRemoveActionUpdater(new AnActionButtonUpdater() {
@Override
public boolean isEnabled(AnActionEvent e) {
return table.getSelectedRow() != -1;
}
}).disableUpDownActions().addExtraActions(refreshAction);
panelTable = tableToolbarDecorator.createPanel();
}
use of com.intellij.openapi.actionSystem.AnActionEvent in project Intellij-Plugin by getgauge.
the class Spectacle method notifyToInstall.
void notifyToInstall() {
Notification notification = STANDARD_NOTIFICATION.createNotification("Error: Specification Preview", "Missing plugin: Spectacle. To install, run `gauge install spectacle` or click below", NotificationType.ERROR, null);
notification.addAction(new NotificationAction("Install Spectacle") {
@Override
public void actionPerformed(@NotNull AnActionEvent e, @NotNull Notification notification) {
install();
notification.expire();
}
});
Notifications.Bus.notify(notification);
}
use of com.intellij.openapi.actionSystem.AnActionEvent in project intellij-plugins by JetBrains.
the class ResolveAction method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent event) {
VirtualFile virtualFile = event.getData(CommonDataKeys.VIRTUAL_FILE);
Project project = event.getProject();
if (virtualFile == null || project == null)
return;
Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
if (document == null)
return;
FileDocumentManager.getInstance().saveAllDocuments();
new Task.Backgroundable(project, message("bnd.resolve.requirements.title"), true) {
private Map<Resource, List<Wire>> resolveResult;
private String updatedText;
@Override
public void run(@NotNull ProgressIndicator indicator) {
indicator.setIndeterminate(true);
File file = new File(virtualFile.getPath());
try (Workspace workspace = Workspace.findWorkspace(file);
Run run = Run.createRun(workspace, file);
ProjectResolver projectResolver = new ProjectResolver(run)) {
resolveResult = projectResolver.resolve();
List<VersionedClause> versionedClauses = projectResolver.getRunBundles().stream().map(c -> {
Attrs attrs = new Attrs();
attrs.put(Constants.VERSION_ATTRIBUTE, c.getVersion());
return new VersionedClause(c.getBundleSymbolicName(), attrs);
}).sorted(Comparator.comparing(VersionedClause::getName)).collect(Collectors.toList());
BndEditModel editModel = new BndEditModel();
IDocument bndDocument = new aQute.bnd.properties.Document(document.getImmutableCharSequence().toString());
editModel.loadFrom(bndDocument);
editModel.setRunBundles(versionedClauses);
editModel.saveChangesTo(bndDocument);
updatedText = bndDocument.get();
} catch (ProcessCanceledException e) {
throw e;
} catch (Exception e) {
throw new WrappingException(e);
}
indicator.checkCanceled();
}
@Override
public void onSuccess() {
if (new ResolutionSucceedDialog(project, resolveResult).showAndGet() && FileModificationService.getInstance().prepareVirtualFilesForWrite(project, Collections.singleton(virtualFile))) {
writeCommandAction(project).withName("Bndrun Resolve").run(() -> document.setText(updatedText));
}
}
@Override
public void onThrowable(@NotNull Throwable t) {
Throwable cause = t instanceof WrappingException ? t.getCause() : t;
LOG.warn("Resolution failed", cause);
if (cause instanceof ResolutionException) {
new ResolutionFailedDialog(project, (ResolutionException) cause).show();
} else {
OsmorcBundle.notification(message("bnd.resolve.failed.title"), cause.getMessage(), NotificationType.ERROR).notify(project);
}
}
}.queue();
}
use of com.intellij.openapi.actionSystem.AnActionEvent in project intellij-leiningen-plugin by derkork.
the class LeiningenNode method executeAction.
public static void executeAction(final String actionId, final InputEvent e) {
final ActionManager actionManager = ActionManager.getInstance();
final AnAction action = actionManager.getAction(actionId);
if (action != null) {
final Presentation presentation = new Presentation();
final AnActionEvent event = new AnActionEvent(e, DataManager.getInstance().getDataContext(e.getComponent()), "", presentation, actionManager, 0);
action.update(event);
if (presentation.isEnabled()) {
action.actionPerformed(event);
}
}
}
use of com.intellij.openapi.actionSystem.AnActionEvent in project ideavim by JetBrains.
the class KeyHandler method executeAction.
/**
* Execute an action
*
* @param action The action to execute
* @param context The context to run it in
*/
public static boolean executeAction(@NotNull AnAction action, @NotNull DataContext context) {
// Hopefully all the arguments are sufficient. So far they all seem to work OK.
// We don't have a specific InputEvent so that is null
// What is "place"? Leave it the empty string for now.
// Is the template presentation sufficient?
// What are the modifiers? Is zero OK?
final AnActionEvent event = new AnActionEvent(null, context, "", action.getTemplatePresentation(), ActionManager.getInstance(), 0);
action.update(event);
if (event.getPresentation().isEnabled()) {
action.actionPerformed(event);
return true;
}
return false;
}
Aggregations