javax.swing.plaf.basic.BasicFileChooserUI#org.openide.windows.WindowManager源码实例Demo

下面列出了javax.swing.plaf.basic.BasicFileChooserUI#org.openide.windows.WindowManager 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: constellation   文件: Startup.java
@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();
}
 
源代码2 项目: constellation   文件: TutorialStartup.java
@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();
            }
        });
    }
}
 
源代码3 项目: netbeans   文件: AnalysisResultTopComponent.java
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;
}
 
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);
}
 
源代码5 项目: netbeans   文件: MaximizeWindowAction.java
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();
}
 
源代码6 项目: netbeans   文件: TerminalContainerTopComponent.java
/**
 * 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();
}
 
源代码7 项目: netbeans   文件: Installer.java
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();
            }
        });
    }
}
 
源代码8 项目: TencentKona-8   文件: RemoveFilterAction.java
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));
        }
    }
}
 
源代码9 项目: netbeans   文件: CollapseTabGroupAction.java
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();
            }
        });
    }
}
 
源代码10 项目: netbeans   文件: TaskListTopComponent.java
@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();
                }
            });
        }
    });
}
 
源代码11 项目: NBANDROID-V2   文件: LogTopComponent.java
/**
 * 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();
}
 
源代码12 项目: netbeans   文件: AntProjectModule.java
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();
                    }
                });
            }
        }
    });
}
 
源代码13 项目: netbeans   文件: InitializeInAWTTest.java
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());
}
 
源代码14 项目: visualvm   文件: SnapshotsWindowUI.java
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;
}
 
源代码15 项目: netbeans   文件: Central.java
/** 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);
    }
 
/**
 * 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();
}
 
源代码17 项目: netbeans   文件: ProgressDialog.java
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);
}
 
源代码18 项目: snap-desktop   文件: NewWorkspaceAction.java
@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();
    }
}
 
源代码19 项目: netbeans   文件: GetRightEditorAction.java
/** 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();
     }
 }
 
源代码20 项目: hottub   文件: BytecodeViewTopComponent.java
/**
 * 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();
}
 
源代码21 项目: netbeans   文件: RunOffEDTImplTest.java
public void testShowProgressDialogAndRun_3args_2() throws InterruptedException {
    final WM wm = Lookup.getDefault().lookup(WM.class);
    //make sure main window is on screen before proceeding
    wm.await();
    final JFrame jf = (JFrame) WindowManager.getDefault().getMainWindow();
    final CountDownLatch countDown = new CountDownLatch(1);
    final AtomicBoolean glassPaneFound = new AtomicBoolean(false);
    final boolean testGlassPane = canTestGlassPane();
    class R implements Runnable {
        volatile boolean hasRun;
        @Override
        public void run() {
            try {
                wm.waitForGlassPane();
                if (testGlassPane) {
                    glassPaneFound.set(jf.getGlassPane() instanceof RunOffEDTImpl.TranslucentMask);
                }
                hasRun = true;
            } finally {
                countDown.countDown();
            }
        }
    }
    R r = new R();
    ProgressUtils.showProgressDialogAndRun(r, "Something");
    countDown.await();
    assertTrue (r.hasRun);
    assertTrue ("Glass pane not set", !testGlassPane || glassPaneFound.get());
}
 
源代码22 项目: openjdk-8-source   文件: EditFilterDialog.java
/** Creates new form EditFilterDialog */
public EditFilterDialog(CustomFilter customFilter) {
    super(WindowManager.getDefault().getMainWindow(), true);
    this.customFilter = customFilter;
    initComponents();

    sourceTextArea.setText(customFilter.getCode());
    nameTextField.setText(customFilter.getName());
}
 
源代码23 项目: netbeans   文件: UtilTestCase.java
public void testCreateNewQuery() {
    Repository repo = getRepo();
    APITestRepository apiRepo = getApiRepo();
    
    assertNull(apiRepo.newQuery);
    Util.createNewQuery(repo);
    
    long t = System.currentTimeMillis();
    TopComponent openedTC = null;
    while(openedTC == null) {
        Set<TopComponent> openedTCs = WindowManager.getDefault().getRegistry().getOpened();
        for (TopComponent tc : openedTCs) {
            if(tc instanceof QueryTopComponent) {
                QueryTopComponent itc = (QueryTopComponent)tc;
                QueryImpl queryImpl = itc.getQuery();
                if(queryImpl != null && queryImpl.isData(apiRepo.newQuery)) {
                    openedTC = tc;
                    break;
                }
            }
        }
        if(System.currentTimeMillis() - t > 50000) {
            break;
        }
    }
    
    assertNotNull(apiRepo.newQuery);
    if(openedTC == null) {
        fail("TopComponent with new query wasn't opened");
    }
    openedTC.close();
}
 
源代码24 项目: constellation   文件: AbstractTopComponent.java
@Override
protected void componentHidden() {
    super.componentHidden();
    if (WindowManager.getDefault().isTopComponentFloating(this)) {
        ConstellationLogger.getDefault().viewInfo(this, "Hidden / Floating");
    } else if (WindowManager.getDefault().isTopComponentMinimized(this)) {
        ConstellationLogger.getDefault().viewInfo(this, "Hidden / Minimised");
    } else {
        ConstellationLogger.getDefault().viewInfo(this, "Hidden / Docked");
    }
}
 
源代码25 项目: netbeans   文件: PopupUtil.java
public static void hidePopup() {
        if (popupWindow != null) {
//            popupWindow.getContentPane().removeAll();
            Toolkit.getDefaultToolkit().removeAWTEventListener(hideListener);
            
            popupWindow.setVisible( false );
            popupWindow.dispose();
        }
        WindowManager.getDefault().getMainWindow().removeWindowStateListener(hideListener);
        WindowManager.getDefault().getMainWindow().removeComponentListener(hideListener);
        popupWindow = null;
    }
 
源代码26 项目: openjdk-jdk9   文件: OutlineTopComponent.java
/**
 * Obtain the OutlineTopComponent instance. Never call {@link #getDefault} directly!
 */
public static synchronized OutlineTopComponent findInstance() {
    TopComponent win = WindowManager.getDefault().findTopComponent(PREFERRED_ID);
    if (win == null) {
        ErrorManager.getDefault().log(ErrorManager.WARNING, "Cannot find Outline component. It will not be located properly in the window system.");
        return getDefault();
    }
    if (win instanceof OutlineTopComponent) {
        return (OutlineTopComponent) 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();
}
 
源代码27 项目: snap-desktop   文件: WorkspaceTopComponent.java
public static WorkspaceTopComponent findShowingInstance() {
    TopComponent activated = WindowManager.getDefault().getRegistry().getActivated();
    if (activated instanceof WorkspaceTopComponent) {
        return (WorkspaceTopComponent) activated;
    }
    List<WorkspaceTopComponent> showingWorkspaces = findShowingInstances();
    if (!showingWorkspaces.isEmpty()) {
        return showingWorkspaces.get(0);
    }
    return null;
}
 
源代码28 项目: TencentKona-8   文件: OutlineTopComponent.java
/**
 * Obtain the OutlineTopComponent instance. Never call {@link #getDefault} directly!
 */
public static synchronized OutlineTopComponent findInstance() {
    TopComponent win = WindowManager.getDefault().findTopComponent(PREFERRED_ID);
    if (win == null) {
        ErrorManager.getDefault().log(ErrorManager.WARNING, "Cannot find Outline component. It will not be located properly in the window system.");
        return getDefault();
    }
    if (win instanceof OutlineTopComponent) {
        return (OutlineTopComponent) 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();
}
 
源代码29 项目: Open-LaTeX-Studio   文件: Undo.java
@Override
public void actionPerformed(ActionEvent e) {
    TopComponent tc = WindowManager.getDefault().findTopComponent("EditorTopComponent");
    EditorTopComponent etc = (EditorTopComponent) tc;
    
    etc.undoAction();
    etc.getEditorState().setDirty(true);
}
 
源代码30 项目: jdk8u60   文件: EditorTopComponent.java
public static EditorTopComponent getActive() {
    Set<? extends Mode> modes = WindowManager.getDefault().getModes();
    for (Mode m : modes) {
        TopComponent tc = m.getSelectedTopComponent();
        if (tc instanceof EditorTopComponent) {
            return (EditorTopComponent) tc;
        }
    }
    return null;
}