當前位置: 首頁>>代碼示例>>Java>>正文


Java TopComponent類代碼示例

本文整理匯總了Java中org.openide.windows.TopComponent的典型用法代碼示例。如果您正苦於以下問題:Java TopComponent類的具體用法?Java TopComponent怎麽用?Java TopComponent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TopComponent類屬於org.openide.windows包,在下文中一共展示了TopComponent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: updateTitle

import org.openide.windows.TopComponent; //導入依賴的package包/類
/**
 * Updates the title of the enclosing view.
 */
void updateTitle() {
    EventQueue.invokeLater(new Runnable() {
        @Override
        public void run() {
            if (active) {
                TopComponent tc = WindowManager.getDefault().findTopComponent("CssStylesTC"); // NOI18N
                if(tc != null) {
                    FileObject fob = getContext();
                    if(fob != null) {
                        ((CssStylesTC)tc).setTitle(fob.getNameExt());
                    }
                }
            }
        }
    });
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:DocumentViewPanel.java

示例2: setContextAwareOptions

import org.openide.windows.TopComponent; //導入依賴的package包/類
/**
 * Set options that depend on current context, and listeners that ensure
 * they stay valid when the context changes.
 */
private void setContextAwareOptions(boolean searchAndReplace) {
    if (!searchAndReplace) {
        updateSearchInGeneratedForActiveTopComponent();
        topComponentRegistryListener = new PropertyChangeListener() {
            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                if (evt.getPropertyName().equals(
                        TopComponent.Registry.PROP_ACTIVATED)) {
                    updateSearchInGeneratedForActiveTopComponent();
                }
            }
        };
        TopComponent.getRegistry().addPropertyChangeListener(
                WeakListeners.propertyChange(topComponentRegistryListener,
                TopComponent.getRegistry()));
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:BasicSearchForm.java

示例3: CssStylesTCController

import org.openide.windows.TopComponent; //導入依賴的package包/類
public CssStylesTCController() {
    //register a weak property change listener to the window manager registry
    //XXX is the weak listener really necessary? Is the registry ever GCed?
    Registry reg = WindowManager.getDefault().getRegistry();
    reg.addPropertyChangeListener(
            WeakListeners.propertyChange(this, reg));

    Lookup.Result<PageInspector> lookupResult = Lookup.getDefault().lookupResult(PageInspector.class);
    lookupResult.addLookupListener(this);
    resultChanged(new LookupEvent(lookupResult));

    //called from CssCaretAwareSourceTask constructor when the caret is set to a css source code
    //for the first time, which means if we initialize the window listener now, we won't get the component
    //activated event since it happened just before the caret was set.

    //fire an artificial even so the rule editor possibly opens
    //the active TC should be the editor which triggered the css caret event
    propertyChange(new PropertyChangeEvent(this, TopComponent.Registry.PROP_ACTIVATED, null,
            TopComponent.getRegistry().getActivated()));
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:CssStylesTCController.java

示例4: attachTopComponent

import org.openide.windows.TopComponent; //導入依賴的package包/類
/** Uses Central.userDroppedTopComponents(ModeImpl mode, TopComponentDraggable draggable, String side)
 * to attach source TopComponent to target Mode according to sideConstant
 * value.
 * @param sourceTc source TopComponent
 * @param mode target mode
 * @param sideConstant side constant
 */
private static void attachTopComponent(TopComponent sourceTc, Mode mode, String sideConstant) {
    try {
        Class<?> centralClass = classForName("org.netbeans.core.windows.Central");
        Class<?> tcdClass = classForName("org.netbeans.core.windows.view.dnd.TopComponentDraggable");
        Class<?> modeImplClass = classForName("org.netbeans.core.windows.ModeImpl");
        Method attachMethod = centralClass.getMethod("userDroppedTopComponents", modeImplClass, tcdClass, String.class);
        Method getCentralMethod = WindowManager.getDefault().getClass().getDeclaredMethod("getCentral", (Class<?>[]) null);
        getCentralMethod.setAccessible(true);
        Object centralInstance = getCentralMethod.invoke(WindowManager.getDefault(), (Object[]) null);
        Constructor<?> tcdConstructor = tcdClass.getDeclaredConstructor(TopComponent.class);
        tcdConstructor.setAccessible(true);
        Object tcdInstance = tcdConstructor.newInstance(sourceTc);
        attachMethod.setAccessible(true);
        attachMethod.invoke(centralInstance, mode, tcdInstance, sideConstant);
    } catch (Exception e) {
        throw new JemmyException("Cannot attach TopComponent.", e);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:26,代碼來源:AttachWindowAction.java

示例5: getTopComponents

import org.openide.windows.TopComponent; //導入依賴的package包/類
public Set<TopComponent> getTopComponents() {
    Set<String> s;
    synchronized(LOCK_TOPCOMPONENTS) {
        s = new HashSet<String>(topComponents);
    }
    
    Set<TopComponent> result = new HashSet<TopComponent>(s.size());
    for(String tcId: s) {
        TopComponent tc = getTopComponent(tcId);
        if(tc != null) {
            result.add(tc);
        }
    }
    
    return result;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:DefaultTopComponentGroupModel.java

示例6: dropIndication

import org.openide.windows.TopComponent; //導入依賴的package包/類
@Override
public Rectangle dropIndication( TopComponent draggedTC, Point location ) {
    int tabIndex = dropIndexOfPoint( location );
    if( tabIndex < 0 )
        return null;
    if( tabIndex == getModel().size() )
        tabIndex--;
    Rectangle rect = getTabBounds( tabIndex );
    if( orientation == JTabbedPane.VERTICAL ) {
        if( location.y <= rect.y + rect.height/2 ) {
            rect.y -= rect.height / 2;
        } else {
            rect.y += rect.height / 2;
        }
    } else {
        if( location.x <= rect.x + rect.width/2 ) {
            rect.x -= rect.width / 2;
        } else {
            rect.x += rect.width / 2;
        }
    }
    return rect;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:SimpleTabDisplayer.java

示例7: getOpenedTopComponents

import org.openide.windows.TopComponent; //導入依賴的package包/類
public Set<TopComponent> getOpenedTopComponents() {
    Set<String> s;
    synchronized(LOCK_OPENED) {
        s = new HashSet<String>(openedTopComponents);
    }
    
    Set<TopComponent> result = new HashSet<TopComponent>(s.size());
    for(String tcId: s) {
        TopComponent tc = getTopComponent(tcId);
        if(tc != null) {
            result.add(tc);
        }
    }
    
    return result;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:DefaultTopComponentGroupModel.java

示例8: enable

import org.openide.windows.TopComponent; //導入依賴的package包/類
@Override
public boolean enable(Node[] nodes) {
    if (super.enable(nodes)) {
        Context ctx = getCachedContext(nodes);
        if(!Subversion.getInstance().getStatusCache().containsFiles(ctx, enabledForStatus, true)) {
            return false;
        }  
        TopComponent activated = TopComponent.getRegistry().getActivated();
        if (activated instanceof DiffSetupSource) {
            return true;
        }
        return Lookup.getDefault().lookup(DiffProvider.class) != null;                
    } else {
        return false;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:ExportDiffAction.java

示例9: doFullRefactoring

import org.openide.windows.TopComponent; //導入依賴的package包/類
private void doFullRefactoring() {
    releaseAll();
    final TopComponent activetc = TopComponent.getRegistry().getActivated();
    final Runnable task = new Runnable() {

        @Override
        public void run() {
            SHOW.show(ui.getRefactoringUI(), activetc);
        }
    };
    if(!EventQueue.isDispatchThread()) {
        SwingUtilities.invokeLater(new Runnable() {
            
            @Override
            public void run() {
                UIUtilities.runWhenScanFinished(task, "Instant Refactoring");
            }
        });
    } else {
        UIUtilities.runWhenScanFinished(task, "Instant Refactoring");
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:InstantRefactoringPerformer.java

示例10: addModeOpenedTopComponentNoNotify

import org.openide.windows.TopComponent; //導入依賴的package包/類
/** Adds opened TopComponent into model and requests view (if needed). */
void addModeOpenedTopComponentNoNotify(ModeImpl mode, TopComponent tc) {
    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));
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:Central.java

示例11: showScene

import org.openide.windows.TopComponent; //導入依賴的package包/類
/** Shows given Scene wrapped in TopComponent and JFrame.
 * @param scene Scene to be shown
 * @return TopComponent instance where scene resides
 */
public static TopComponent showScene(Scene scene) {
    JComponent sceneView = scene.getView();
    if (sceneView == null) {
        sceneView = scene.createView();
    }
    int width = 450, height = 250;
    JFrame frame = new JFrame("Test Scene");
    TopComponent tc = new TopComponent();
    tc.setLayout(new BorderLayout());
    tc.add(sceneView);
    frame.add(tc);
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    frame.setBounds((screenSize.width - width) / 2, (screenSize.height - height) / 2, width, height);
    frame.setVisible(true);
    return tc;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:Utils.java

示例12: testDelegatesAsArrayOfAction

import org.openide.windows.TopComponent; //導入依賴的package包/類
public void testDelegatesAsArrayOfAction () throws Exception {
    OurAction[] arr = {
        new OurAction ()
    };
    action.putValue ("delegates", arr);
    //arr[0].setEnabled (true);
    
    TopComponent tc = new TopComponent();
    tc.getActionMap ().put(javax.swing.text.DefaultEditorKit.pasteAction, action);
    tc.requestActive();
    
    CharSequence log = Log.enable(PasteAction.class.getName(), Level.WARNING);
    global.actionPerformed (new ActionEvent (this, 0, "waitFinished"));
    assertEquals("Log is empty", "", log.toString());
    
    arr[0].assertCnt ("Performed on delegate", 1);
    action.assertCnt ("Not performed on action", 0);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:PasteActionTest.java

示例13: show

import org.openide.windows.TopComponent; //導入依賴的package包/類
@Override
public void show(RefactoringUI ui, TopComponent activetc) {
    if (ui!=null) {
        UI.openRefactoringUI(ui, activetc);
    } else {
        JOptionPane.showMessageDialog(null,NbBundle.getMessage(RefactoringActionsProvider.class, "ERR_CannotRenameKeyword"));
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:ContextAnalyzer.java

示例14: isFromEditorWindow

import org.openide.windows.TopComponent; //導入依賴的package包/類
protected boolean isFromEditorWindow(DataObject dobj,
        final TopComponent tc) {
    final EditorCookie editor = dobj.getLookup().lookup(
            EditorCookie.class);
    if (editor != null) {
        return Mutex.EVENT.readAccess(new Action<Boolean>() {
            @Override
            public Boolean run() {
                return (tc instanceof CloneableTopComponent) // #246597
                        || NbDocument.findRecentEditorPane(editor) != null;
            }
        });
    }
    return false;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:OpenFilesSearchScopeProvider.java

示例15: someoneActivated

import org.openide.windows.TopComponent; //導入依賴的package包/類
private void someoneActivated() {
    TopComponent win = TopComponent.getRegistry().getActivated();
    if (LOG.isLoggable(Level.FINER)) {
        String winId;
        if (win == null) {
            winId = "<null>";
        } else {
            String winName = win.getDisplayName();
            if (winName == null) {
                winName = win.getHtmlDisplayName();
            }
            if (winName == null) {
                winName = win.getName();
            }
            if (winName != null) {
                winName = '"' + winName + '"';
            } else {
                winName = "<noname>";
            }
            winId = winName + '(' + win.getClass().getName() + ')';
        }
        LOG.log(Level.FINER, "someoneActivated ({0})", winId);
    }

    if ((win == null) || (win instanceof CloneableEditorSupport.Pane)) {
        return;
    }

    Object key = getActionMapKey();
    ActionMap actionMap = win.getActionMap();

    if ((actionMap.get(key) == null) && activatedOnWindows.add(win)) {
        Action ls = getAction();
        actionMap.put(key, ls);
        win.putClientProperty(getMappedActionKey(),
                new WeakReference<Action>(ls));
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:39,代碼來源:ActionManager.java


注:本文中的org.openide.windows.TopComponent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。