org.openide.windows.WindowManager Java Examples

The following examples show how to use org.openide.windows.WindowManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InitializeInAWTTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testInitializeAndBlockInAWT() throws Exception {
    assertTrue("Running in AWT", SwingUtilities.isEventDispatchThread());
    
    class R implements PropertyChangeListener {
        JEditorPane p;
        public void run() {
            p = support.getOpenedPanes()[0];
        }

        public void propertyChange(PropertyChangeEvent evt) {
            if (TopComponent.Registry.PROP_ACTIVATED.equals(evt.getPropertyName())) {
                run();
            }
        }
    }
    R r = new R();
    WindowManager.getDefault().getRegistry().addPropertyChangeListener(r);
    
    final Object LOCK = new JPanel().getTreeLock();
    synchronized (LOCK) {
        support.open();
        assertNotNull(r.p);
    }
    
    assertKit(r.p.getEditorKit());
}
 
Example #2
Source File: GetRightEditorAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Perform the action. Sets/unsets maximzed mode. */
 public void actionPerformed(java.awt.event.ActionEvent ev) {
     WindowManager wm = WindowManager.getDefault();
     MultiViewHandler handler = MultiViews.findMultiViewHandler(wm.getRegistry().getActivated());
     if (handler != null) {
         MultiViewPerspective pers = handler.getSelectedPerspective();
         MultiViewPerspective[] all = handler.getPerspectives();
         for (int i = 0; i < all.length; i++) {
             if (pers.equals(all[i])) {
                 int newIndex = i != all.length  - 1 ? i + 1 : 0;
   MultiViewDescription selectedDescr = Accessor.DEFAULT.extractDescription(pers);
   if (selectedDescr instanceof ContextAwareDescription) {
if (((ContextAwareDescription) selectedDescr).isSplitDescription()) {
    newIndex = i != all.length  - 1 ? i + 2 : 1;
} else {
    newIndex = i != all.length  - 2 ? i + 2 : 0;
}
   }
                 handler.requestActive(all[newIndex]);
   break;
             }
         }
     } else {
         Utilities.disabledActionBeep();
     }
 }
 
Example #3
Source File: AnalysisResultTopComponent.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static synchronized AnalysisResultTopComponent findInstance() {
    TopComponent win = WindowManager.getDefault().findTopComponent(PREFERRED_ID);
    if (win instanceof AnalysisResultTopComponent) {
        return (AnalysisResultTopComponent) win;
    }
    if (win == null) {
        Logger.getLogger(AnalysisResultTopComponent.class.getName()).warning(
                "Cannot find " + PREFERRED_ID + " component. It will not be located properly in the window system.");
    } else {
        Logger.getLogger(AnalysisResultTopComponent.class.getName()).warning(
                "There seem to be multiple components with the '" + PREFERRED_ID +
                "' ID. That is a potential source of errors and unexpected behavior.");
    }
    
    AnalysisResultTopComponent result = new AnalysisResultTopComponent();
    Mode outputMode = WindowManager.getDefault().findMode("output");
    
    if (outputMode != null) {
        outputMode.dockInto(result);
    }
    return result;
}
 
Example #4
Source File: NewWorkspaceAction.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
    String defaultName = WindowUtilities.getUniqueTitle(Bundle.VAL_NewWorkspaceActionValue(),
                                                        WorkspaceTopComponent.class);
    NotifyDescriptor.InputLine d = new NotifyDescriptor.InputLine(Bundle.LBL_NewWorkspaceActionName(),
                                                                  Bundle.CTL_NewWorkspaceActionName());
    d.setInputText(defaultName);
    Object result = DialogDisplayer.getDefault().notify(d);
    if (NotifyDescriptor.OK_OPTION.equals(result)) {
        WorkspaceTopComponent workspaceTopComponent = new WorkspaceTopComponent(d.getInputText());
        Mode editor = WindowManager.getDefault().findMode("editor");
        Assert.notNull(editor, "editor");
        editor.dockInto(workspaceTopComponent);
        workspaceTopComponent.open();
        workspaceTopComponent.requestActive();
    }
}
 
Example #5
Source File: TutorialStartup.java    From constellation with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
    final Preferences prefs = NbPreferences.forModule(ApplicationPreferenceKeys.class);
    if (prefs.getBoolean(ApplicationPreferenceKeys.TUTORIAL_ON_STARTUP, ApplicationPreferenceKeys.TUTORIAL_ON_STARTUP_DEFAULT)) {
        SwingUtilities.invokeLater(() -> {
            final TopComponent tutorial = WindowManager.getDefault().findTopComponent(TutorialTopComponent.class.getSimpleName());
            if (tutorial != null) {
                if (!tutorial.isOpened()) {
                    tutorial.open();
                }
                tutorial.setEnabled(true);
                tutorial.requestActive();
            }
        });
    }
}
 
Example #6
Source File: ProgressDialog.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void createDialog(String title) {
    pHandle = ProgressHandleFactory.createHandle(title);
    JPanel panel = new ProgressPanel(pHandle);
    
    DialogDescriptor descriptor = new DialogDescriptor(
            panel, title
    );
    
    final Object[] OPTIONS = new Object[0];
    descriptor.setOptions(OPTIONS);
    descriptor.setClosingOptions(OPTIONS);
    descriptor.setModal(true);
    descriptor.setOptionsAlign(DialogDescriptor.BOTTOM_ALIGN);
    
    dialog = DialogDisplayer.getDefault().createDialog(descriptor);
    
    Frame mainWindow = WindowManager.getDefault().getMainWindow();
    int windowWidth = mainWindow.getWidth();
    int windowHeight = mainWindow.getHeight();
    int dialogWidth = dialog.getWidth();
    int dialogHeight = dialog.getHeight();
    int dialogX = (int)(windowWidth/2.0) - (int)(dialogWidth/2.0);
    int dialogY = (int)(windowHeight/2.0) - (int)(dialogHeight/2.0);
    
    dialog.setLocation(dialogX, dialogY);
}
 
Example #7
Source File: AssetPackBrowserTopComponent.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Obtain the AssetPackBrowserTopComponent instance. Never call {@link #getDefault} directly!
 */
public static synchronized AssetPackBrowserTopComponent findInstance() {
    TopComponent win = WindowManager.getDefault().findTopComponent(PREFERRED_ID);
    if (win == null) {
        Logger.getLogger(AssetPackBrowserTopComponent.class.getName()).warning(
                "Cannot find " + PREFERRED_ID + " component. It will not be located properly in the window system.");
        return getDefault();
    }
    if (win instanceof AssetPackBrowserTopComponent) {
        return (AssetPackBrowserTopComponent) win;
    }
    Logger.getLogger(AssetPackBrowserTopComponent.class.getName()).warning(
            "There seem to be multiple components with the '" + PREFERRED_ID
            + "' ID. That is a potential source of errors and unexpected behavior.");
    return getDefault();
}
 
Example #8
Source File: Startup.java    From constellation with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
    ConstellationSecurityManager.startSecurityLater(null);

    // application environment
    final String environment = System.getProperty(SYSTEM_ENVIRONMENT);
    final String name = environment != null
            ? String.format("%s %s", BrandingUtilities.APPLICATION_NAME, environment)
            : BrandingUtilities.APPLICATION_NAME;

    // update the main window title with the version number
    WindowManager.getDefault().invokeWhenUIReady(() -> {
        final JFrame frame = (JFrame) WindowManager.getDefault().getMainWindow();
        final String title = String.format("%s - %s", name, VERSION);
        frame.setTitle(title);
    });

    FontUtilities.initialiseFontPreferenceOnFirstUse();
}
 
Example #9
Source File: DefaultQualityControlAutoButton.java    From constellation with Apache License 2.0 6 votes vote down vote up
public DefaultQualityControlAutoButton() {
    getStylesheets().add(JavafxStyleManager.getMainStyleSheet());
    setStyle(QUERY_RISK_DEFAULT_STYLE + BUTTON_STYLE + String.format("-fx-font-size:%d;", FontUtilities.getOutputFontSize()));

    setOnAction(value -> {
        SwingUtilities.invokeLater(() -> {
            final TopComponent qualityControlView = WindowManager.getDefault().findTopComponent(QualityControlViewTopComponent.class.getSimpleName());
            if (qualityControlView != null) {
                if (!qualityControlView.isOpened()) {
                    qualityControlView.open();
                }
                qualityControlView.requestActive();
            }
        });
    });

    QualityControlAutoVetter.getInstance().addListener(this);
    QualityControlAutoVetter.getInstance().invokeListener(this);
}
 
Example #10
Source File: MaximizeWindowAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public MaximizeWindowAction() {
    String label = NbBundle.getMessage(MaximizeWindowAction.class, "CTL_MaximizeWindowAction"); //NOI18N
    putValue(Action.NAME, label);
    propListener = new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            String propName = evt.getPropertyName();
            if(WindowManagerImpl.PROP_MAXIMIZED_MODE.equals(propName)
            || WindowManagerImpl.PROP_EDITOR_AREA_STATE.equals(evt.getPropertyName())
            || WindowManager.PROP_MODES.equals(evt.getPropertyName())
            || WindowManagerImpl.PROP_ACTIVE_MODE.equals(evt.getPropertyName())) {
                updateState();
            }
            // #64876: correctly initialize after startup 
            if (TopComponent.Registry.PROP_ACTIVATED.equals(propName)) {
                updateState();
            }
        }
    };
    TopComponent.Registry registry = TopComponent.getRegistry();
    registry.addPropertyChangeListener(WeakListeners.propertyChange(propListener, registry));
    WindowManagerImpl wm = WindowManagerImpl.getInstance();
    wm.addPropertyChangeListener(WeakListeners.propertyChange(propListener, wm));
    
    updateState();
}
 
Example #11
Source File: Central.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Adds mode into model and requests view (if needed). */
    public void addMode(ModeImpl mode, SplitConstraint[] modeConstraints) {
        // PENDING which one to use?
//        if(getModes().contains(mode)) {
//            return;
//        }
        SplitConstraint[] old = getModeConstraints(mode);
        if(modeConstraints == old) {
            return;
        }
        
        model.addMode(mode, modeConstraints);
        
        if(isVisible()) {
            viewRequestor.scheduleRequest(
                new ViewRequest(null, View.CHANGE_MODE_ADDED, null, mode));
        }
        
        WindowManagerImpl.getInstance().doFirePropertyChange(
            WindowManager.PROP_MODES, null, null);
    }
 
Example #12
Source File: TerminalContainerTopComponent.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Obtain the TerminalContainerTopComponent instance. Never call {@link #getDefault} directly!
 */
public static synchronized TerminalContainerTopComponent findInstance() {
    TopComponent win = WindowManager.getDefault().findTopComponent(PREFERRED_ID);
    if (win == null) {
        Logger.getLogger(TerminalContainerTopComponent.class.getName()).warning(
                "Cannot find " + PREFERRED_ID + " component. It will not be located properly in the window system.");// NOI18N
        return getDefault();
    }
    if (win instanceof TerminalContainerTopComponent) {
        return (TerminalContainerTopComponent) win;
    }
    Logger.getLogger(TerminalContainerTopComponent.class.getName()).warning(
            "There seem to be multiple components with the '" + PREFERRED_ID // NOI18N
            + "' ID. That is a potential source of errors and unexpected behavior.");// NOI18N
    return getDefault();
}
 
Example #13
Source File: Installer.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void usageStatisticsReminder () {
    //Increment number of IDE starts, stop at 4 because we are interested at second start
    long nbOfIdeStarts = corePref.getLong(USAGE_STATISTICS_NB_OF_IDE_STARTS, 0);
    nbOfIdeStarts++;
    if (nbOfIdeStarts < 4) {
        corePref.putLong(USAGE_STATISTICS_NB_OF_IDE_STARTS, nbOfIdeStarts);
    }
    boolean setByIde = corePref.getBoolean(USAGE_STATISTICS_SET_BY_IDE, false);
    boolean usageEnabled = corePref.getBoolean(USAGE_STATISTICS_ENABLED, false);

    //If "usageStatisticsEnabled" was set by IDE do not ask again.
    if (setByIde) {
        return;
    }
    //If "usageStatisticsEnabled" was not set by IDE, it is false and it is second start ask again
    if (!setByIde && !usageEnabled && (nbOfIdeStarts == 2)) {
        WindowManager.getDefault().invokeWhenUIReady(new Runnable() {
            @Override
            public void run() {
                showDialog();
            }
        });
    }
}
 
Example #14
Source File: RemoveFilterAction.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
protected void performAction(Node[] activatedNodes) {
    Object[] options = {"Yes",
        "No",
        "Cancel"
    };
    int n = JOptionPane.showOptionDialog(WindowManager.getDefault().getMainWindow(),
            "Do you really want to delete " + activatedNodes.length + " filter/s?", "Delete?",
            JOptionPane.YES_NO_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE,
            null,
            options,
            options[2]);

    if (n == JOptionPane.YES_OPTION) {
        for (int i = 0; i < activatedNodes.length; i++) {
            FilterTopComponent.findInstance().removeFilter(activatedNodes[i].getLookup().lookup(Filter.class));
        }
    }
}
 
Example #15
Source File: CollapseTabGroupAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public CollapseTabGroupAction() {
    putValue(NAME, NbBundle.getMessage(CloseModeAction.class, "CTL_CollapseTabGroupAction"));
    TopComponent.getRegistry().addPropertyChangeListener(
        WeakListeners.propertyChange(this, TopComponent.getRegistry()));
    WindowManager.getDefault().addPropertyChangeListener(
        WeakListeners.propertyChange(this, WindowManager.getDefault()));
    if (SwingUtilities.isEventDispatchThread()) {
        updateEnabled();
    } else {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                updateEnabled();
            }
        });
    }
}
 
Example #16
Source File: AntProjectModule.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void showWarning() {
    NotifyDescriptor nd = new NotifyDescriptor.Message(NbBundle.getMessage(AntProjectModule.class, "LBL_Incompatible_Xalan")); // NOI18N
    
    DialogDisplayer.getDefault().notify(nd);
    
    //the IDE cannot be closed here (the window system data are corrupted then), wait until the main window appears
    //and close then:
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            Frame f = WindowManager.getDefault().getMainWindow();
            
            if (f == null || f.isShowing()) {
                LifecycleManager.getDefault().exit();
            } else {
                f.addWindowListener(new WindowAdapter() {
                    public @Override void windowOpened(WindowEvent e) {
                        LifecycleManager.getDefault().exit();
                    }
                });
            }
        }
    });
}
 
Example #17
Source File: TaskListTopComponent.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void componentOpened() {
    if( null == model ) {
        toolbarSeparator.setVisible(false);
        statusSeparator.setVisible(false);
        tableScroll.setViewportView( createNoTasksMessage() );
    }

    WindowManager.getDefault().invokeWhenUIReady(new Runnable() {
        @Override
        public void run() {
            TaskManagerImpl.RP.post(new Runnable() {
                @Override
                public void run() {
                    init();
                }
            });
        }
    });
}
 
Example #18
Source File: SnapshotsWindowUI.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
private static boolean isOpen(Snapshot s) {
    File f = FileUtil.toFile(s.getFile());
    if (f == null) return false; // #236480

    if (s.isHeapDump()) {
        Set<TopComponent> tcs = WindowManager.getDefault().getRegistry().getOpened();
        for (TopComponent tc : tcs) {
            if (f.equals(tc.getClientProperty(ProfilerTopComponent.RECENT_FILE_KEY)))
                return true;
        }
    } else {
        LoadedSnapshot ls = ResultsManager.getDefault().findLoadedSnapshot(f);
        if (ls != null) return true;
    }
    return false;
}
 
Example #19
Source File: LogTopComponent.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
/**
 * Obtain the LogTopComponent instance. Never call {@link #getDefault}
 * directly!
 */
public static synchronized LogTopComponent findInstance() {
    TopComponent win = WindowManager.getDefault().findTopComponent(PREFERRED_ID);
    if (win == null) {
        Logger.getLogger(LogTopComponent.class.getName()).warning(
                "Cannot find " + PREFERRED_ID + " component. It will not be located properly in the window system.");
        return getDefault();
    }
    if (win instanceof LogTopComponent) {
        return (LogTopComponent) win;
    }
    Logger.getLogger(LogTopComponent.class.getName()).warning(
            "There seem to be multiple components with the '" + PREFERRED_ID
            + "' ID. That is a potential source of errors and unexpected behavior.");
    return getDefault();
}
 
Example #20
Source File: DesignView.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent evt) {
    if (TopComponent.Registry.PROP_OPENED.equals(evt.getPropertyName())) {
        for (Mode m : WindowManager.getDefault().getModes()) {
            for (TopComponent topComponent : m.getTopComponents()) {
                if (topComponent instanceof DesignViewComponent) {
                    continue;
                }
                topComponent.close();
            }
        }
    }
}
 
Example #21
Source File: WorkSpaceTrashDialog.java    From jeddict with Apache License 2.0 5 votes vote down vote up
private void save_ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_save_ButtonActionPerformed
    if (!validateField()) {
        return;
    }
    int option = JOptionPane.showConfirmDialog(
            WindowManager.getDefault().getMainWindow(),
            getMessage(WorkSpaceTrashDialog.class, "WorkSpaceTrashDialog.delete.selected.content"),
            getMessage(WorkSpaceTrashDialog.class, "WorkSpaceTrashDialog.delete.selected.title"),
            JOptionPane.YES_NO_OPTION);
    if (option == javax.swing.JOptionPane.OK_OPTION) {
        currentWorkSpaceDeleted = entityMappings.removeAllWorkSpace(getSelectedWorkSpace());
        scene.getModelerPanelTopComponent().changePersistenceState(false);
        saveActionPerformed(evt);
    }
}
 
Example #22
Source File: Install.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    WindowManager.getDefault().invokeWhenUIReady(() -> {
        final PropertyChangeListener listener = new RegListener();
        if (listenerRef.compareAndSet(null, listener)) {
            WindowManager.getDefault().getRegistry().addPropertyChangeListener(listener);
        }
    });
}
 
Example #23
Source File: BytecodeViewTopComponent.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Obtain the BytecodeViewTopComponent instance. Never call {@link #getDefault} directly!
 */
public static synchronized BytecodeViewTopComponent findInstance() {
    TopComponent win = WindowManager.getDefault().findTopComponent(PREFERRED_ID);
    if (win == null) {
        ErrorManager.getDefault().log(ErrorManager.WARNING, "Cannot find BytecodeView component. It will not be located properly in the window system.");
        return getDefault();
    }
    if (win instanceof BytecodeViewTopComponent) {
        return (BytecodeViewTopComponent) win;
    }
    ErrorManager.getDefault().log(ErrorManager.WARNING, "There seem to be multiple components with the '" + PREFERRED_ID + "' ID. That is a potential source of errors and unexpected behavior.");
    return getDefault();
}
 
Example #24
Source File: BytecodeViewTopComponent.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Obtain the BytecodeViewTopComponent instance. Never call {@link #getDefault} directly!
 */
public static synchronized BytecodeViewTopComponent findInstance() {
    TopComponent win = WindowManager.getDefault().findTopComponent(PREFERRED_ID);
    if (win == null) {
        ErrorManager.getDefault().log(ErrorManager.WARNING, "Cannot find BytecodeView component. It will not be located properly in the window system.");
        return getDefault();
    }
    if (win instanceof BytecodeViewTopComponent) {
        return (BytecodeViewTopComponent) win;
    }
    ErrorManager.getDefault().log(ErrorManager.WARNING, "There seem to be multiple components with the '" + PREFERRED_ID + "' ID. That is a potential source of errors and unexpected behavior.");
    return getDefault();
}
 
Example #25
Source File: PropertiesHandler.java    From jeddict with Apache License 2.0 5 votes vote down vote up
private static boolean validateCollectionType(String collectionType, String implType, boolean collectionTypeChanged){
     boolean valid = false;
     String changedValue = collectionTypeChanged ? collectionType : implType;
            try {
                if (StringUtils.isNotBlank(changedValue)) {
                    if (java.util.Collection.class.isAssignableFrom(Class.forName(changedValue))
                            || java.util.Map.class.isAssignableFrom(Class.forName(changedValue))) {
                        valid = true;
                    }

                    if (StringUtils.isNotBlank(collectionType) && StringUtils.isNotBlank(implType)) {
                        Class type1Class = Class.forName(collectionType);
                        if (java.util.Collection.class.isAssignableFrom(type1Class)
                                && !type1Class.isAssignableFrom(Class.forName(implType))) {
                            valid = false;
                        }
                        if (java.util.Map.class.isAssignableFrom(type1Class)
                                && !type1Class.isAssignableFrom(Class.forName(implType))) {
                            valid = false;
                        }
                    }

                }
            } catch (ClassNotFoundException ex) {
                //skip allow = false;
            }
            if(!valid) {
                if (StringUtils.isNotBlank(collectionType) && StringUtils.isNotBlank(implType)) {
                    JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), 
                            String.format("Incompatible Collection type [%s] and Implementation type [%s]", collectionType, implType), 
                            "Incompatible types", ERROR_MESSAGE);
                } else if(!collectionTypeChanged && StringUtils.isBlank(implType) ){
                    JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), 
                            "Set collection implementation type to generate add/remove method", 
                            "Add/Remove method", ERROR_MESSAGE);
                }
            }
    return valid;
}
 
Example #26
Source File: JavaHelp.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * If the help frame is opened from a modal dialog, it should be closed
 * automatically if that dialog closes. See bug 233543. Also the windows
 * should be rearranged so that both are visible. See bug #233542.
 */
private void bindFrameViewerToCurrentDialog() {
    int maxDepth = 0;
    Dialog topDialog = null;
    for (Window w : JDialog.getWindows()) {
        if (w instanceof Dialog && w.isVisible()) {
            Dialog d = (Dialog) w;
            if (isRelevantDialog(d)) {
                int depth = 0;
                for (Window o = d.getOwner(); o != null; o = o.getOwner()) {
                    depth++;
                    if (o == WindowManager.getDefault().getMainWindow()
                            && depth > maxDepth) {
                        maxDepth = depth;
                        topDialog = d;
                        break;
                    }
                }
            }
        }
    }
    if (topDialog != null) {
        rearrange(topDialog, frameViewer);
        final Dialog finalTopDialog = topDialog;
        topDialog.addWindowListener(new WindowAdapter() {

            @Override
            public void windowClosed(WindowEvent e) {
                if (frameViewer != null) {
                    frameViewer.setVisible(false);
                }
                finalTopDialog.removeWindowListener(this);
            }
        });
    }
}
 
Example #27
Source File: TokensBrowserTopComponent.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Obtain the TokensBrowserTopComponent instance. Never call {@link #getDefault} directly!
 */
public static synchronized TokensBrowserTopComponent findInstance () {
    TopComponent win = WindowManager.getDefault ().findTopComponent (PREFERRED_ID);
    if (win == null) {
        ErrorManager.getDefault ().log (ErrorManager.WARNING, "Cannot find TokensBrowser component. It will not be located properly in the window system.");
        return getDefault ();
    }
    if (win instanceof TokensBrowserTopComponent) {
        return (TokensBrowserTopComponent)win;
    }
    ErrorManager.getDefault ().log (ErrorManager.WARNING, "There seem to be multiple components with the '" + PREFERRED_ID + "' ID. That is a potential source of errors and unexpected behavior.");
    return getDefault ();
}
 
Example #28
Source File: VersioningOutputTopComponent.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static synchronized VersioningOutputTopComponent getInstance() {
    if (VersioningOutputTopComponent.instance == null) {
        VersioningOutputTopComponent.instance = (VersioningOutputTopComponent) WindowManager.getDefault().findTopComponent("versioning_output"); // NOI18N
        if (VersioningOutputTopComponent.instance == null) {
            ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, new IllegalStateException(
                "Can not find Versioning Output component")); // NOI18N
            VersioningOutputTopComponent.instance = new VersioningOutputTopComponent();
        }
    }

    return VersioningOutputTopComponent.instance;
}
 
Example #29
Source File: RecentViewList.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent evt) {
    if (TopComponent.Registry.PROP_ACTIVATED.equals(evt.getPropertyName())) {
        TopComponent tc = (TopComponent) evt.getNewValue();
        if (tc != null) {
            String tcId = WindowManager.getDefault().findTopComponentID( tc );
            //Update list
            tcIdList.remove( tcId );
            tcIdList.add( 0, tcId );
            // #69486: ensure all components are listed
            fillList(TopComponent.getRegistry().getOpened());
        }
    }
}
 
Example #30
Source File: NavigatorTC.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Singleton accessor, finds instance in winsys structures */
public static final NavigatorTC getInstance () {
    NavigatorTC navTC = (NavigatorTC)WindowManager.getDefault().
                    findTopComponent("navigatorTC"); //NOI18N
    if (navTC == null) {
        // shouldn't happen under normal conditions
        navTC = privateGetInstance();
        Logger.getAnonymousLogger().warning(
            "Could not locate the navigator component via its winsys id"); //NOI18N
    }
    return navTC;
}