Java Code Examples for org.openide.windows.TopComponent#isOpened()

The following examples show how to use org.openide.windows.TopComponent#isOpened() . 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: JPDAEngineComponentsProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void willCloseNotify(List<ComponentInfo> components) {
    for (ComponentInfo ci : components) {
        Component c = ci.getComponent();
        if (c instanceof TopComponent) {
            TopComponent tc = (TopComponent) c;
            boolean isOpened = tc.isOpened();
            String tcId = WindowManager.getDefault().findTopComponentID(tc);
            Properties.getDefault().getProperties(PROPERTY_BASE_NAME).
                    getProperties(PROPERTY_CLOSED_TC).setBoolean(tcId, !isOpened);
            boolean isMinimized = WindowManager.getDefault().isTopComponentMinimized(tc);
            Properties.getDefault().getProperties(PROPERTY_BASE_NAME).
                    getProperties(PROPERTY_MINIMIZED_TC).setBoolean(tcId, isMinimized);
        }
    }
}
 
Example 2
Source File: LaoutPreviewTopComponent.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
static void showLaoutPreview(JPanel panel, String name) {
    WindowManager wm = WindowManager.getDefault();
    TopComponent topComponent = wm.findTopComponent("LaoutPreviewTopComponent"); // NOI18N
    if (topComponent == null) {
        topComponent = new LaoutPreviewTopComponent();
    }
    if (topComponent instanceof LaoutPreviewTopComponent) {
        if (!topComponent.isOpened()) {
            Mode mode = wm.findMode("commonpalette");
            if (mode != null) {
                mode.dockInto(topComponent);
            }
            topComponent.removeAll();
            if (panel != null) {
                topComponent.add(panel);
            }
            topComponent.updateUI();
            topComponent.setName("Laout Preview [" + name + "]");
            topComponent.setToolTipText("Laout Preview [" + name + "]");
            topComponent.open();
        }
    }

}
 
Example 3
Source File: V8DebuggerEngineComponentsProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void willCloseNotify(List<ComponentInfo> components) {
    for (ComponentInfo ci : components) {
        Component c = ci.getComponent();
        if (c instanceof TopComponent) {
            TopComponent tc = (TopComponent) c;
            /*
            try {
                Method pid = TopComponent.class.getDeclaredMethod("preferredID");
                pid.setAccessible(true);
                System.err.println("JS EngineComponentsProviderImpl.closing("+pid.invoke(tc)+") name = "+tc.getName());
            } catch (Exception ex) {
                ex.printStackTrace();
            }*/
            boolean isOpened = tc.isOpened();
            String tcId = WindowManager.getDefault().findTopComponentID(tc);
            Properties.getDefault().getProperties(PROPERTY_BASE_NAME).
                    getProperties(PROPERTY_CLOSED_TC).setBoolean(tcId, !isOpened);
            boolean isMinimized = WindowManager.getDefault().isTopComponentMinimized(tc);
            Properties.getDefault().getProperties(PROPERTY_BASE_NAME).
                    getProperties(PROPERTY_MINIMIZED_TC).setBoolean(tcId, isMinimized);
        }
    }
}
 
Example 4
Source File: DomTCController.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Updates the state of DOM Tree view. This method can be called
 * from event-dispatch thread only.
 */
private void updateDomTC0() {
    synchronized (this) {
        TopComponentGroup group = getDOMTCGroup();
        Page inspectedPage = PageInspector.getDefault().getPage();
        if (inspectedPage == null) {
            group.close();                
        } else {
            TopComponent tc = WindowManager.getDefault().findTopComponent(DomTC.ID);
            boolean wasOpened = tc.isOpened();
            group.open();
            if (!wasOpened && tc.isOpened() && !WindowManager.getDefault().isTopComponentMinimized(tc)) {
                tc.requestVisible();
            }
        }
    }
}
 
Example 5
Source File: Central.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Adds opened TopComponent into model and requests view (if needed). */
public void addModeOpenedTopComponent(ModeImpl mode, TopComponent tc) {
    boolean wasOpened = tc.isOpened();
    if(getModeOpenedTopComponents(mode).contains(tc)) {
        return;
    }

    // Validate the TopComponent was removed from other modes.
    removeTopComponentFromOtherModes(mode, tc);

    model.addModeOpenedTopComponent(mode, tc);

    if(isVisible()) {
        viewRequestor.scheduleRequest(
            new ViewRequest(mode, View.CHANGE_MODE_TOPCOMPONENT_ADDED,
            null, tc));
    }

    if( !wasOpened ) { //make sure componentOpened() is called just once
        // Notify opened.
        WindowManagerImpl.getInstance().notifyTopComponentOpened(tc);
    }
}
 
Example 6
Source File: Central.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void insertModeOpenedTopComponent(ModeImpl mode, TopComponent tc, int index) {
    boolean wasOpened = tc.isOpened();
    List openedTcs = getModeOpenedTopComponents(mode);
    if(index >= 0 && !openedTcs.isEmpty()
    && openedTcs.size() > index && openedTcs.get(index) == tc) {
        return;
    }
    
    // Validate the TopComponent was removed from other modes.
    removeTopComponentFromOtherModes(mode, tc);
    
    model.insertModeOpenedTopComponent(mode, tc, index);
    
    if(isVisible()) {
        viewRequestor.scheduleRequest(
            new ViewRequest(mode, View.CHANGE_MODE_TOPCOMPONENT_ADDED, // PENDING inserted?
            null, tc));
    }
    
    if( !wasOpened ) { //make sure componentOpened() is called just once
        // #102258: Notify opened when opened through openAtTabPosition as well
        WindowManagerImpl.getInstance().notifyTopComponentOpened(tc);
    }
}
 
Example 7
Source File: Central.java    From netbeans with Apache License 2.0 6 votes vote down vote up
void setTopComponentMinimized( TopComponent tc, boolean minimized ) {
    if( !tc.isOpened() ) {
        return;
    }
    if( isTopComponentMinimized( tc ) == minimized ) {
        return; //nothing todo
    }
    ModeImpl mode = ( ModeImpl ) WindowManagerImpl.getInstance().findMode( tc );
    if( null == mode || mode.getState() != Constants.MODE_STATE_JOINED ) {
        return;
    }
    if( minimized ) {
        slide( tc, mode, guessSlideSide( tc ) );
    } else {
        unSlide( tc, mode );
    }
    //#207438 - make sure global minimize/dock actions get updated
    WindowManagerImpl.getInstance().doFirePropertyChange(
        WindowManager.PROP_MODES, null, null);
}
 
Example 8
Source File: AddWatchAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static void openWatchesView() {
    // open watches view
    TopComponent watchesView = WindowManager.getDefault().findTopComponent("watchesView"); // NOI18N
    if (watchesView != null && watchesView.isOpened()) {
        Mode mw = WindowManager.getDefault().findMode(watchesView);
        if (mw != null && mw.getSelectedTopComponent() == watchesView) {
            return ; // Watches is already selected
        }
    }
    String viewName = VariablesViewButtons.isWatchesViewNested() ? "localsView" : "watchesView";
    ViewActions.openComponent (viewName, false).requestVisible();
}
 
Example 9
Source File: DataAccessUtilities.java    From constellation with Apache License 2.0 5 votes vote down vote up
private static DataAccessPane getInternalDataAccessPane() {
    final TopComponent tc = WindowManager.getDefault().findTopComponent(DataAccessViewTopComponent.class.getSimpleName());
    if (tc != null) {
        if (!tc.isOpened()) {
            tc.open();
        }
        tc.requestVisible();
        return ((DataAccessViewTopComponent) tc).getDataAccessPane();
    } else {
        return null;
    }
}
 
Example 10
Source File: Edit.java    From BART with MIT License 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent ev) {       
    TopComponent tc = WindowManager.getDefault().findTopComponent(ViewResource.TOP_ID_DependenciesEditorTopComponent);
    if(tc != null)   {
        if(tc.isOpened()) {
            tc.requestActive();
            return;
        }
        tc.open();
        tc.requestActive();
    }
}
 
Example 11
Source File: Open.java    From BART with MIT License 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent ev) {
    TopComponent tc = WindowManager.getDefault().findTopComponent(ViewResource.TOP_ID_DependencyViewTopComponent);
    if(tc != null) {
        if(tc.isOpened())  {
            tc.requestActive();
        }else{
            tc.open();
            tc.requestActive();
        }
    }   
      
}
 
Example 12
Source File: WorkspaceTopComponent.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private TopComponent dockInternalFrame(JInternalFrame internalFrame) {
    TopComponent topComponent = closeInternalFrame(internalFrame, true);

    Mode mode = WindowManager.getDefault().findMode("editor");
    mode.dockInto(topComponent);
    if (!topComponent.isOpened()) {
        topComponent.open();
    }

    return topComponent;
}
 
Example 13
Source File: TopComponentListener.java    From Llunatic with GNU General Public License v3.0 5 votes vote down vote up
public void register(TopComponent slaveComponent, String masterComponentName) {
    this.tc = slaveComponent;
    this.mainComponent = masterComponentName;
    TopComponent.getRegistry().addPropertyChangeListener(this);
    TopComponent main = view.findWindowByName(masterComponentName);
    if (main == null || !main.isOpened()) {
        slaveComponent.close();
    }
}
 
Example 14
Source File: Central.java    From netbeans with Apache License 2.0 5 votes vote down vote up
boolean isTopComponentMinimized( TopComponent tc ) {
    if( !tc.isOpened() ) {
        return false;
    }
    ModeImpl mode = ( ModeImpl ) WindowManagerImpl.getInstance().findMode( tc );
    return null != mode && mode.getKind() == Constants.MODE_KIND_SLIDING;
}
 
Example 15
Source File: Open.java    From BART with MIT License 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent ev) {
    TopComponent tc = WindowManager.getDefault().findTopComponent(ViewResource.TOP_ID_ChartTopComponent);
    if(tc != null)   {
        if(tc.isOpened())  {
            tc.requestActive();
            return;
        }else{
            tc.open();
            tc.requestActive();
        }
    }
}
 
Example 16
Source File: LazyLoader.java    From netbeans with Apache License 2.0 5 votes vote down vote up
void loadAllNow() {
    isActive = false;
    isLoading = true;
    PersistenceHandler persistenceHandler = PersistenceHandler.getDefault();
    for( LazyMode lazyMode : lazyModes.values() ) {
        for( String tcId : lazyMode.getTopComponents() ) {
            TopComponent tc = persistenceHandler.getTopComponentForID( tcId, true );
            if( null != tc && !tc.isOpened() ) {
                lazyMode.mode.addOpenedTopComponent( tc, lazyMode.getPosition( tcId ) );
            }
        }
    }
    lazyModes.clear();
}
 
Example 17
Source File: PersistenceManager.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Tests if given top component with specified stringId is persistent.
 * This method is used for saving of TopComponent.
 * @param tc top component in question
 * @return true if component is persistent (which is by default), false
 * otherwise - top component's property exists saying "don't make me persistent"
 */
public boolean isTopComponentPersistent (TopComponent tc) {
    int persistenceType = persistenceType(tc);
    if ((TopComponent.PERSISTENCE_NEVER == persistenceType)
    || ((TopComponent.PERSISTENCE_ONLY_OPENED == persistenceType) && !tc.isOpened())) {
        return false;
    }
    return true;
}
 
Example 18
Source File: OpenFilesSearchScopeProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 *
 * @return all the currenlty opened FileObjects
 */
private Collection<FileObject> getCurrentlyOpenedFiles() {
    LinkedHashSet<FileObject> result = new LinkedHashSet<FileObject>();
    for (TopComponent tc : TopComponent.getRegistry().getOpened()) {
        DataObject dob = tc.getLookup().lookup(DataObject.class);
        if (tc.isOpened() && dob != null && isFromEditorWindow(dob, tc)) {
            FileObject primaryFile = dob.getPrimaryFile();
            if (primaryFile != null) {
                result.add(primaryFile);
            }
        }
    }
    return result;
}
 
Example 19
Source File: ScreenshotComponent.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
protected void componentShowing() {
    super.componentShowing();
    TopComponent properties = WindowManager.getDefault().findTopComponent("properties");    // NOI18N
    if (properties != null) {
        if (!properties.isOpened()) {
            propertiesOpened = true;
            properties.open();
        }
    }
}
 
Example 20
Source File: PaletteTopComponent.java    From netbeans with Apache License 2.0 4 votes vote down vote up
static void hidePalette() {
    TopComponent palette = instance;
    if (palette != null && palette.isOpened()) {
        palette.close();
    }
}