Search in sources :

Example 1 with Notification

use of org.openide.awt.Notification in project Universal-G-Code-Sender by winder.

the class ConsoleNotificationService method onMessage.

@Override
public void onMessage(MessageType messageType, String message) {
    if (messageType.equals(MessageType.ERROR)) {
        Notification notify = NotificationDisplayer.getDefault().notify(Localization.getString("controller.log.error.reported"), ImageUtilities.loadImageIcon(ERROR_ICON_PATH, false), message, null, NotificationDisplayer.Priority.LOW, NotificationDisplayer.Category.ERROR);
        // Clears the notification automatically
        ThreadHelper.invokeLater(notify::clear, TIME_TO_LIVE);
    }
}
Also used : Notification(org.openide.awt.Notification)

Example 2 with Notification

use of org.openide.awt.Notification in project netbeans-rcp-lite by outersky.

the class ShowNotifications method showNotification.

private static void showNotification(String notification, UpdateUnitProvider p) {
    if (notifications.get(p.getName()) != null) {
        notifications.get(p.getName()).clear();
    }
    Notification n = NotificationDisplayer.getDefault().notify(getTitle(notification), ImageUtilities.loadImageIcon("org/netbeans/modules/autoupdate/ui/resources/info_icon.png", false), createInfoPanel(notification), createInfoPanel(notification), NotificationDisplayer.Priority.HIGH);
    notifications.put(p.getName(), n);
}
Also used : Notification(org.openide.awt.Notification)

Example 3 with Notification

use of org.openide.awt.Notification in project constellation by constellation-app.

the class DataAccessSearchProviderNGTest method testRun3.

/**
 * Test of run method, of class PluginDisplayer. Testing when daPane is null
 */
@Test
public void testRun3() {
    System.out.println("testRun3 null data access pane");
    // Setting up mocks
    notifDisplayer = mock(NotificationDisplayer.class);
    final Notification notif = new Notification() {

        @Override
        public void clear() {
        // do nothing, used for testing.
        }
    };
    // Setting up a mock for DataAccessUtilities to return null when fetching the pane.
    try (MockedStatic<DataAccessUtilities> mockedStatic1 = Mockito.mockStatic(DataAccessUtilities.class)) {
        mockedStatic1.when(() -> DataAccessUtilities.getDataAccessPane()).thenReturn(null);
        // Mock the static method getDefault() to return the mock of NotificationDisplayer
        try (MockedStatic<NotificationDisplayer> mockedStatic3 = Mockito.mockStatic(NotificationDisplayer.class)) {
            when(notifDisplayer.notify("Data Access view", WARNING_ICON, "Please open the Data Access view and create a step.", null)).thenReturn(notif);
            mockedStatic3.when(() -> NotificationDisplayer.getDefault()).thenReturn(notifDisplayer);
            ShowDataAccessPluginTask pd = new ShowDataAccessPluginTask("SelectTopN");
            pd.run();
            // verify notificationdisplayer was called with correct string
            verify(notifDisplayer, times(1)).notify(Mockito.anyString(), Mockito.eq(WARNING_ICON), Mockito.eq("Please open the Data Access view and create a step."), Mockito.eq(null));
        }
    }
}
Also used : ShowDataAccessPluginTask(au.gov.asd.tac.constellation.views.dataaccess.tasks.ShowDataAccessPluginTask) DataAccessUtilities(au.gov.asd.tac.constellation.views.dataaccess.utilities.DataAccessUtilities) NotificationDisplayer(org.openide.awt.NotificationDisplayer) Notification(org.openide.awt.Notification) Test(org.testng.annotations.Test)

Example 4 with Notification

use of org.openide.awt.Notification in project constellation by constellation-app.

the class DataAccessSearchProviderNGTest method testRun2.

/**
 * Test of run method, of class PluginDisplayer. Testing when tab is null
 */
@Test
public void testRun2() {
    System.out.println("testRun2 testing null tab returned");
    // Setting up mocks
    daPane = mock(DataAccessPane.class);
    datPane = mock(DataAccessTabPane.class);
    notifDisplayer = mock(NotificationDisplayer.class);
    final Notification notif = new Notification() {

        @Override
        public void clear() {
        // do nothing, used for testing.
        }
    };
    // Setting up a mock for DataAccessUtilities to return null when fetching the pane.
    try (MockedStatic<DataAccessUtilities> mockedStatic1 = Mockito.mockStatic(DataAccessUtilities.class)) {
        when(daPane.getDataAccessTabPane()).thenReturn(datPane);
        when(datPane.getCurrentTab()).thenReturn(null);
        mockedStatic1.when(() -> DataAccessUtilities.getDataAccessPane()).thenReturn(daPane);
        // Mock the static method getDefault() to return the mock of NotificationDisplayer
        try (MockedStatic<NotificationDisplayer> mockedStatic3 = Mockito.mockStatic(NotificationDisplayer.class)) {
            when(notifDisplayer.notify("Data Access view", WARNING_ICON, "Please create a step in the Data Access view.", null)).thenReturn(notif);
            mockedStatic3.when(() -> NotificationDisplayer.getDefault()).thenReturn(notifDisplayer);
            ShowDataAccessPluginTask pd = new ShowDataAccessPluginTask("SelectTopN");
            pd.run();
            // Verify that the current tab was attempted to be retrieved
            verify(datPane, times(1)).getCurrentTab();
            // verify notificationdisplayer was called with correct string
            verify(notifDisplayer, times(1)).notify(Mockito.anyString(), Mockito.eq(WARNING_ICON), Mockito.eq("Please create a step in the Data Access view."), Mockito.eq(null));
        }
    }
}
Also used : DataAccessTabPane(au.gov.asd.tac.constellation.views.dataaccess.components.DataAccessTabPane) ShowDataAccessPluginTask(au.gov.asd.tac.constellation.views.dataaccess.tasks.ShowDataAccessPluginTask) DataAccessUtilities(au.gov.asd.tac.constellation.views.dataaccess.utilities.DataAccessUtilities) NotificationDisplayer(org.openide.awt.NotificationDisplayer) Notification(org.openide.awt.Notification) Test(org.testng.annotations.Test)

Example 5 with Notification

use of org.openide.awt.Notification in project netbeans-rcp-lite by outersky.

the class Janitor method cleanupAction.

@Messages({ "TIT_CONFIRM_CLEANUP=Confirm Cleanup", "# {0} - the dirname to be cleaned up", "TXT_CONFIRM_CLEANUP=Remove user and cache data for NetBeans {0}?", "# {0} - the dirname to be cleaned up", "LBL_CLEANUP=Removing user and cache dirs of {0}" })
static ActionListener cleanupAction(String name) {
    return new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            JanitorPanel panel = new JanitorPanel(Bundle.TXT_CONFIRM_CLEANUP(name));
            DialogDescriptor descriptor = new DialogDescriptor(panel, Bundle.TIT_CONFIRM_CLEANUP(), true, DialogDescriptor.YES_NO_OPTION, DialogDescriptor.YES_OPTION, null);
            if (DialogDescriptor.YES_OPTION == DialogDisplayer.getDefault().notify(descriptor)) {
                JANITOR_RP.post(() -> {
                    try (ProgressHandle handle = ProgressHandle.createHandle(Bundle.LBL_CLEANUP(name))) {
                        handle.start();
                        deleteDir(getUserDir(name));
                        deleteDir(getCacheDir(name));
                    }
                });
            }
            Janitor.setEnabled(panel.isEnabledOnStartup());
            Notification nf = CLEANUP_TASKS.get(this);
            if (nf != null) {
                nf.clear();
            }
        }
    };
}
Also used : ActionListener(java.awt.event.ActionListener) ProgressHandle(org.netbeans.api.progress.ProgressHandle) ActionEvent(java.awt.event.ActionEvent) Notification(org.openide.awt.Notification) Messages(org.openide.util.NbBundle.Messages)

Aggregations

Notification (org.openide.awt.Notification)6 ShowDataAccessPluginTask (au.gov.asd.tac.constellation.views.dataaccess.tasks.ShowDataAccessPluginTask)2 DataAccessUtilities (au.gov.asd.tac.constellation.views.dataaccess.utilities.DataAccessUtilities)2 NotificationDisplayer (org.openide.awt.NotificationDisplayer)2 Test (org.testng.annotations.Test)2 DataAccessTabPane (au.gov.asd.tac.constellation.views.dataaccess.components.DataAccessTabPane)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 ImageIcon (javax.swing.ImageIcon)1 ProgressHandle (org.netbeans.api.progress.ProgressHandle)1 Messages (org.openide.util.NbBundle.Messages)1