Search in sources :

Example 1 with DeleteProvider

use of com.intellij.ide.DeleteProvider in project intellij-community by JetBrains.

the class DeleteAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    DataContext dataContext = e.getDataContext();
    DeleteProvider provider = getDeleteProvider(dataContext);
    if (provider == null)
        return;
    try {
        provider.deleteElement(dataContext);
    } catch (Throwable t) {
        LOG.error(t);
    }
}
Also used : DeleteProvider(com.intellij.ide.DeleteProvider)

Example 2 with DeleteProvider

use of com.intellij.ide.DeleteProvider in project intellij-community by JetBrains.

the class DeleteAction method update.

@Override
public void update(AnActionEvent e) {
    Presentation presentation = e.getPresentation();
    if (ActionPlaces.PROJECT_VIEW_POPUP.equals(e.getPlace()) || ActionPlaces.COMMANDER_POPUP.equals(e.getPlace())) {
        presentation.setText(IdeBundle.message("action.delete.ellipsis"));
    } else {
        presentation.setText(IdeBundle.message("action.delete"));
    }
    if (e.getProject() == null) {
        presentation.setEnabled(false);
        return;
    }
    DataContext dataContext = e.getDataContext();
    DeleteProvider provider = getDeleteProvider(dataContext);
    if (e.getInputEvent() instanceof KeyEvent) {
        KeyEvent keyEvent = (KeyEvent) e.getInputEvent();
        Object component = PlatformDataKeys.CONTEXT_COMPONENT.getData(dataContext);
        // Do not override text deletion
        if (component instanceof JTextComponent)
            provider = null;
        if (keyEvent.getKeyCode() == KeyEvent.VK_BACK_SPACE) {
            // Do not override text deletion in speed search
            if (component instanceof JComponent) {
                SpeedSearchSupply searchSupply = SpeedSearchSupply.getSupply((JComponent) component);
                if (searchSupply != null)
                    provider = null;
            }
            String activeSpeedSearchFilter = SpeedSearchSupply.SPEED_SEARCH_CURRENT_QUERY.getData(dataContext);
            if (!StringUtil.isEmpty(activeSpeedSearchFilter)) {
                provider = null;
            }
        }
    }
    if (provider instanceof TitledHandler) {
        presentation.setText(((TitledHandler) provider).getActionTitle());
    }
    boolean canDelete = provider != null && provider.canDeleteElement(dataContext);
    if (ActionPlaces.isPopupPlace(e.getPlace())) {
        presentation.setVisible(canDelete);
    } else {
        presentation.setEnabled(canDelete);
    }
}
Also used : DeleteProvider(com.intellij.ide.DeleteProvider) KeyEvent(java.awt.event.KeyEvent) SpeedSearchSupply(com.intellij.ui.speedSearch.SpeedSearchSupply) JTextComponent(javax.swing.text.JTextComponent) TitledHandler(com.intellij.ide.TitledHandler)

Example 3 with DeleteProvider

use of com.intellij.ide.DeleteProvider in project intellij-community by JetBrains.

the class DeleteUnversionedFilesAction method actionPerformed.

public void actionPerformed(final AnActionEvent e) {
    DeleteProvider deleteProvider = e.getData(PlatformDataKeys.DELETE_ELEMENT_PROVIDER);
    if (deleteProvider == null)
        return;
    deleteProvider.deleteElement(e.getDataContext());
}
Also used : DeleteProvider(com.intellij.ide.DeleteProvider)

Example 4 with DeleteProvider

use of com.intellij.ide.DeleteProvider in project intellij-community by JetBrains.

the class DeleteUnversionedFilesAction method update.

@Override
public void update(AnActionEvent e) {
    DeleteProvider deleteProvider = e.getData(PlatformDataKeys.DELETE_ELEMENT_PROVIDER);
    e.getPresentation().setEnabled(deleteProvider != null && deleteProvider.canDeleteElement(e.getDataContext()));
}
Also used : DeleteProvider(com.intellij.ide.DeleteProvider)

Aggregations

DeleteProvider (com.intellij.ide.DeleteProvider)4 TitledHandler (com.intellij.ide.TitledHandler)1 SpeedSearchSupply (com.intellij.ui.speedSearch.SpeedSearchSupply)1 KeyEvent (java.awt.event.KeyEvent)1 JTextComponent (javax.swing.text.JTextComponent)1