Package gov.nasa.arc.mct.platform.spi

Examples of gov.nasa.arc.mct.platform.spi.WindowManager


            return true;
        }
       
        // Get references to platform and window manager; these will be used a few times
        Platform platform = PlatformAccess.getPlatform();
        WindowManager windowManager = platform.getWindowManager();
       
        // Can only complete action if there are no components which cannot be removed
        String confirm = BUNDLE.getString("SaveConfirm");
        String abort = BUNDLE.getString("SaveAbort");
        String[] options = { confirm, abort };

        // Issue a warning dialog to the user
        Map<String, Object> hints = new HashMap<String, Object>();
        hints.put(WindowManagerImpl.PARENT_COMPONENT, actionContext.getWindowManifestation());
        hints.put(WindowManagerImpl.OPTION_TYPE, OptionBox.YES_NO_OPTION);
        hints.put(WindowManagerImpl.MESSAGE_TYPE, OptionBox.WARNING_MESSAGE);
        hints.put(WindowManagerImpl.MESSAGE_OBJECT, buildWarningPanel(canSave, cannotSave));
        String choice = windowManager.showInputDialog(
                BUNDLE.getString("SaveWarningTitle"), //title
                "", // message - will be overridden by custom object
                options, // options
                null, // default option
                hints); // hints
View Full Code Here


   
    private void handleWarnings(Collection<AbstractComponent> toDelete, Collection<AbstractComponent> toRemove,
            Collection<AbstractComponent> cannotRemove) {
        // Get references to platform and window manager; these will be used a few times
        Platform platform = PlatformAccess.getPlatform();
        WindowManager windowManager = platform.getWindowManager();
       
        // Can only complete action if there are no components which cannot be removed
        if (cannotRemove.isEmpty()) {
            String confirm = bundle.getString("DeleteAllCoreText");
            String abort = bundle.getString("DeleteAllAbortText");
            String[] options = { confirm, abort };

            // Issue a warning dialog to the user
            Map<String, Object> hints = new HashMap<String, Object>();
            hints.put(WindowManagerImpl.PARENT_COMPONENT, actionContext.getWindowManifestation());
            hints.put(WindowManagerImpl.OPTION_TYPE, OptionBox.YES_NO_OPTION);
            hints.put(WindowManagerImpl.MESSAGE_TYPE, OptionBox.WARNING_MESSAGE);
            hints.put(WindowManagerImpl.MESSAGE_OBJECT, buildWarningPanel(toDelete, toRemove));
            String choice = windowManager.showInputDialog(
                    WARNING, //title
                    "", // message - will be overridden by custom object
                    options, // options
                    null, // default option
                    hints); // hints
           
            // Complete the action, if the user has confirmed it
            if (confirm.equals(choice)) {
                for (AbstractComponent delete : toDelete) {
                    windowManager.closeWindows(delete.getComponentId());
                }
                platform.getPersistenceProvider().delete(toDelete);
            }           
        } else {      
            // Some components cannot be removed safely - let the user know this
            String ok = bundle.getString("DeleteAllErrorConfirm");
            Map<String, Object> hints = new HashMap<String, Object>();
            hints.put(WindowManagerImpl.PARENT_COMPONENT, actionContext.getWindowManifestation());
            hints.put(WindowManagerImpl.MESSAGE_TYPE, OptionBox.ERROR_MESSAGE);
            windowManager.showInputDialog(
                    "ERROR: "+ WARNING, //title
                    bundle.getString("DeleteAllErrorHasDescendantsText"), // message
                    new String[] { ok }, // options
                    ok, // default option
                    hints); // hints (none)
View Full Code Here

        ContextAwareAction quit = new QuitAction();
        Mockito.reset(mockRuntime);
       
        // Set up window manager to support dialog call
        // Act as though the user clicked "OK" or "Cancel" (depending on argument "confirmed")
        WindowManager mockWindowManager = Mockito.mock(WindowManager.class);
        Mockito.when(mockPlatform.getWindowManager()).thenReturn(mockWindowManager);
        Mockito.when(mockWindowManager.showInputDialog(Mockito.anyString(), Mockito.anyString(), Mockito.<Object[]>any(), Mockito.any(), Mockito.<Map<String,Object>>any())).thenAnswer(new Answer<Object>() {
            @Override
            public Object answer(InvocationOnMock invocation) throws Throwable {
                Object[] options = (Object[]) invocation.getArguments()[2];
                return confirmed ? options[0] : options[1]; // options[0] presumed to mean "OK"
            }
View Full Code Here

        // Generate a new persistence provider each time
        PersistenceProvider persistence = Mockito.mock(PersistenceProvider.class);
        Mockito.when(mockPlatform.getPersistenceProvider()).thenReturn(persistence);

        // Ensure dialog choice
        WindowManager windowing = Mockito.mock(WindowManager.class);
        Mockito.when(mockPlatform.getWindowManager()).thenReturn(windowing);
        Mockito.when(windowing.<Object>showInputDialog(
                Mockito.anyString(), Mockito.anyString(),
                Mockito.<Object[]>any(), Mockito.any(),
                Mockito.<Map<String,Object>>any()))
                .thenReturn(confirm ? "Save" : "Cancel");
       
View Full Code Here

        ContextAwareAction quit = new QuitAction();
        Mockito.reset(mockRuntime);
       
        // Set up window manager to support dialog call
        // Act as though the user clicked "OK" or "Cancel" (depending on argument "confirmed")
        WindowManager mockWindowManager = Mockito.mock(WindowManager.class);
        Mockito.when(mockPlatform.getWindowManager()).thenReturn(mockWindowManager);
        Mockito.when(mockWindowManager.showInputDialog(Mockito.anyString(), Mockito.anyString(), Mockito.<Object[]>any(), Mockito.any(), Mockito.<Map<String,Object>>any())).thenAnswer(new Answer<Object>() {
            @Override
            public Object answer(InvocationOnMock invocation) throws Throwable {
                Object[] options = (Object[]) invocation.getArguments()[2];
                return confirmed ? options[0] : options[1]; // options[0] presumed to mean "OK"
            }
View Full Code Here

     * @param graphicsConfig - Detect multiple display monitor devices
     */
    public final void open(GraphicsConfiguration graphicsConfig) {
        Platform platform = PlatformAccess.getPlatform();
        assert platform != null;
        WindowManager windowManager = platform.getWindowManager();
        if (platform.getRootComponent() == this)
            windowManager.openInNewWindow(this, graphicsConfig);
        else
            windowManager.openInNewWindow(PlatformAccess.getPlatform().getPersistenceProvider().getComponent(getComponentId()), graphicsConfig);
    }
View Full Code Here

        PlatformAccess access = new PlatformAccess();
        Platform mockPlatform = Mockito.mock(Platform.class);
        PersistenceProvider mockPersistenceProvider = Mockito.mock(PersistenceProvider.class);
        PolicyManager mockpoPolicyManager = Mockito.mock(PolicyManager.class);      
        CoreComponentRegistry mockComponentRegistry = Mockito.mock(CoreComponentRegistry.class);
        WindowManager mockWindowManager = Mockito.mock(WindowManager.class);
       
        access.setPlatform(mockPlatform);
        Mockito.when(mockPlatform.getPersistenceProvider()).thenReturn(mockPersistenceProvider);
        Mockito.when(mockPlatform.getPolicyManager()).thenReturn(mockPolicyManager);
        Mockito.when(mockPlatform.getComponentRegistry()).thenReturn(mockComponentRegistry);
        Mockito.when(mockPlatform.getWindowManager()).thenReturn(mockWindowManager);
        ExecutionResult mockResult = new ExecutionResult(new PolicyContext(), true, "");
        Mockito.when(mockpoPolicyManager.execute(Mockito.anyString(), Mockito.any(PolicyContext.class))).thenReturn(mockResult);
        Mockito.when(mockWindowManager.<Object>showInputDialog(
                Mockito.anyString(), Mockito.anyString(), Mockito.<Object[]>any(), Mockito.any(), Mockito.anyMap()))
                .thenAnswer(new Answer<Object>() {
                    @Override
                    public Object answer(InvocationOnMock invocation) throws Throwable {
                        return ((Object[])invocation.getArguments()[2])[0];
View Full Code Here

        PlatformAccess access = new PlatformAccess();
        Platform mockPlatform = Mockito.mock(Platform.class);
        PersistenceProvider mockPersistenceProvider = Mockito.mock(PersistenceProvider.class);
        PolicyManager mockpoPolicyManager = Mockito.mock(PolicyManager.class);      
        CoreComponentRegistry mockComponentRegistry = Mockito.mock(CoreComponentRegistry.class);
        WindowManager mockWindowManager = Mockito.mock(WindowManager.class);
       
        access.setPlatform(mockPlatform);
        Mockito.when(mockPlatform.getPersistenceProvider()).thenReturn(mockPersistenceProvider);
        Mockito.when(mockPlatform.getPolicyManager()).thenReturn(mockPolicyManager);       
        ExecutionResult mockResult = new ExecutionResult(new PolicyContext(), true, "");
        Mockito.when(mockpoPolicyManager.execute(Mockito.anyString(), Mockito.any(PolicyContext.class))).thenReturn(mockResult);
        Mockito.when(mockPlatform.getComponentRegistry()).thenReturn(mockComponentRegistry);
        Mockito.when(mockPlatform.getWindowManager()).thenReturn(mockWindowManager);
        Mockito.when(mockWindowManager.<Object>showInputDialog(
                Mockito.anyString(), Mockito.anyString(), Mockito.<Object[]>any(), Mockito.any(), Mockito.anyMap()))
                .thenAnswer(new Answer<Object>() {
                    @Override
                    public Object answer(InvocationOnMock invocation) throws Throwable {
                        return ((Object[])invocation.getArguments()[2])[0];
View Full Code Here

        if (!initialized) {
            String username = this.currentUser;
            // If PersistenceProvider & WindowManager are available, we can create a dialog with available users
            Platform platform = PlatformAccess.getPlatform();
            PersistenceProvider persistence = platform != null ? platform.getPersistenceProvider() : null;
            WindowManager windowing = platform != null ? platform.getWindowManager() : null;
           
            if (username == null && persistence != null && windowing != null) {
                Object[] users = persistence.getAllUsers().toArray();
                if (users.length > 1) {
                    Arrays.sort(users);
                    username = (String) windowing.showInputDialog(bundle.getString("TITLE"), bundle.getString("QUESTION"), users, users[0], null); //NOI18N
                } else if (users.length == 1) {
                    username = users[0].toString();
                }
            }       
           
View Full Code Here

            private boolean confirmed = false;
           
            @Override
            public void run() {
                if (context.getServiceReference(PersistenceProvider.class.getName()) == null) {
                    WindowManager windowManager = getWindowManager();
                    Map<String, Object> hints = new HashMap<String, Object>();
                   
                    if (!confirmed) {
                        logger.warn("unable to obtain persistence provider");

                        hints.put(WindowManagerImpl.OPTION_TYPE, OptionBox.YES_NO_OPTION);
                       
                        String[] options = {
                                BUNDLE.getString("persistence_warning_ok"),
                                BUNDLE.getString("persistence_warning_cancel")
                                };
                        String result = windowManager.showInputDialog(
                                BUNDLE.getString("persistence_warning_title"),
                                BUNDLE.getString("persistence_warning_message"),
                                options,
                                options[0],
                                hints);
                        if (result.equals(options[1])) {
                            System.exit(0);
                        } else {                       
                            confirmed = true;
                        }
                    } else {
                        logger.error("unable to obtain persistence provider");
                       
                        hints.put(WindowManagerImpl.OPTION_TYPE, OptionBox.YES_OPTION);
                       
                        String[] options = {
                                BUNDLE.getString("persistence_error_ok"),
                                };
                        windowManager.showInputDialog(
                                BUNDLE.getString("persistence_error_title"),
                                BUNDLE.getString("persistence_error_message"),
                                options,
                                options[0],
                                hints);
                       
                        System.exit(0);
                    }
                }
            }
           
            private WindowManager getWindowManager() {
                // Try to use the Platform's version, in case something other
                // than WindowManagerImpl has been injected somewhere.
                Platform platform = PlatformAccess.getPlatform();
                if (platform != null) {
                    WindowManager windowManager = platform.getWindowManager();
                    if (windowManager != null) {
                        return windowManager;
                    }
                }
                // Otherwise, fall back to this bundle's version.
View Full Code Here

TOP

Related Classes of gov.nasa.arc.mct.platform.spi.WindowManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.