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


Java Utilities類代碼示例

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


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

示例1: testRenameFolderChangeCase_FO

import org.openide.util.Utilities; //導入依賴的package包/類
public void testRenameFolderChangeCase_FO () throws Exception {
    // prepare
    File fromFolder = createFolder(repositoryLocation, "folder");
    File fromFile = createFile(fromFolder, "file");
    File toFolder = new File(repositoryLocation, "FOLDER");
    File toFile = new File(toFolder, fromFile.getName());
    add(fromFolder);
    commit(fromFolder);
    
    // move
    h.setFilesToRefresh(new HashSet(Arrays.asList(fromFolder, toFolder)));
    renameFO(fromFolder, toFolder);
    
    // test
    if (Utilities.isWindows() || Utilities.isMac()) {
        assertTrue(Arrays.asList(toFolder.getParentFile().list()).contains(toFolder.getName()));
        assertFalse(Arrays.asList(fromFolder.getParentFile().list()).contains(fromFolder.getName()));
    } else {
        assertTrue(h.waitForFilesToRefresh());
        assertFalse(fromFolder.exists());
        assertTrue(toFolder.exists());
        assertTrue(toFile.exists());
        assertEquals(EnumSet.of(Status.REMOVED_HEAD_INDEX, Status.REMOVED_HEAD_WORKING_TREE), getCache().getStatus(fromFile).getStatus());
        assertEquals(EnumSet.of(Status.NEW_HEAD_INDEX, Status.NEW_HEAD_WORKING_TREE), getCache().getStatus(toFile).getStatus());
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:FilesystemInterceptorTest.java

示例2: testActionNameIsTaken

import org.openide.util.Utilities; //導入依賴的package包/類
public void testActionNameIsTaken() throws Exception {
    Action action = new ActionsTest.TestAction();
    JMenuItem item = new JMenuItem();
    JMenu jmenu = new JMenu();
    jmenu.addNotify();
    assertTrue("Peer created", jmenu.isDisplayable());
    jmenu.getPopupMenu().addNotify();
    assertTrue("Peer for popup", jmenu.getPopupMenu().isDisplayable());

    //action.putValue("popupText", "&Ahoj");
    //action.putValue("menuText", "&Ble");
    action.putValue(action.NAME, "&Mle");
    
    Actions.connect(item, action, false);
    
    assertEquals(Utilities.isMac() ? 0 : 'M', item.getMnemonic());
    assertEquals("Mle", item.getText());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:ActionsTest.java

示例3: getJarsForUserLibrary

import org.openide.util.Utilities; //導入依賴的package包/類
List<URL> getJarsForUserLibrary(String libRawPath) {
    if (userLibraries != null && userLibraries.get(libRawPath) != null) {
        List<String> jars = userLibraries.get(libRawPath);
        List<URL> urls = new ArrayList<URL>(jars.size());
        for (String jar : jars) {
            try {
                File f = new File(jar);
                URL url = Utilities.toURI(f).toURL();
                if (f.isFile()) {
                    url = FileUtil.getArchiveRoot(url);
                }
                urls.add(url);
            } catch (MalformedURLException ex) {
                Exceptions.printStackTrace(ex);
            }
        }
        return urls;
    } else {
        return Collections.<URL>emptyList();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:Workspace.java

示例4: checkKeyBinding

import org.openide.util.Utilities; //導入依賴的package包/類
private void checkKeyBinding(MultiKeyBinding kb, String... keyStrokes) {
    assertNotNull("Key binding should not be null", kb);
    
    ArrayList<KeyStroke> list = new ArrayList<KeyStroke>();
    for(String s : keyStrokes) {
        KeyStroke stroke = Utilities.stringToKey(s);
        if (stroke != null) {
            list.add(stroke);
        }
    }
    
    assertEquals("Wrong number of key strokes", list.size(), kb.getKeyStrokeCount());
    for(int i = 0; i < list.size(); i++) {
        assertEquals("KeyStroke[" + i + "] is different", 
            list.get(i), kb.getKeyStroke(i));
    }        
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:EditorSettingsStorageTest.java

示例5: addResource

import org.openide.util.Utilities; //導入依賴的package包/類
private void addResource(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addResource
    final boolean arp = allowRelativePaths != null && allowRelativePaths.booleanValue();
    final File baseFolder = arp ?
        FileUtil.normalizeFile(Utilities.toFile(URI.create(area.getLocation().toExternalForm())).getParentFile()):
        null;
    final File[] cwd = new File[]{lastFolder};
    final String[] paths = select(volumeType, impl.getName(), cwd, this, baseFolder);
    if (paths != null) {
        try {
            lastFolder = cwd[0];
            addFiles (
                pathsToURIs (
                    paths,
                    volumeType,
                    baseFolder),
                arp);
        } catch (MalformedURLException mue) {
            Exceptions.printStackTrace(mue);
        } catch (URISyntaxException ue) {
            Exceptions.printStackTrace(ue);
        } catch (IOException ex) {
            Exceptions.printStackTrace(ex);
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:26,代碼來源:J2SEVolumeCustomizer.java

示例6: postInitComponents

import org.openide.util.Utilities; //導入依賴的package包/類
private void postInitComponents () {
    this.jLabel2.setVisible(false);
    this.platformHome.setVisible(false);
    final Collection installFolders = platform.getInstallFolderURLs();
    if (platform.getInstallFolders().isEmpty() && installFolders.size() > 0) {
        this.jLabel2.setVisible(true);
        this.platformHome.setVisible(true);
        this.platformHome.setForeground(new Color (164,0,0));
        this.platformHome.setText (Utilities.toFile(URI.create(((URL)installFolders.iterator().next()).toExternalForm())).getAbsolutePath());
    }
    HTMLEditorKit htmlkit = new HTMLEditorKit();                
    StyleSheet css = htmlkit.getStyleSheet();
    if (css.getStyleSheets() == null) {
        StyleSheet css2 = new StyleSheet();
        Font f = jLabel2.getFont();
        css2.addRule(new StringBuffer("body { font-size: ").append(f.getSize()) // NOI18N
            .append("; font-family: ").append(f.getName()).append("; }").toString()); // NOI18N
        css2.addStyleSheet(css);
        htmlkit.setStyleSheet(css2);
    }
    jTextPane1.setEditorKit(htmlkit);        
    jTextPane1.setText(NbBundle.getMessage(BrokenPlatformCustomizer.class,"MSG_BrokenProject"));
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:BrokenPlatformCustomizer.java

示例7: findClassesOutputDir

import org.openide.util.Utilities; //導入依賴的package包/類
/**
 * Find output classes given a compilation unit from project.xml.
 */
private String findClassesOutputDir(Element compilationUnitEl) {
    // Look for an appropriate <built-to>.
    for (Element builtTo : XMLUtil.findSubElements(compilationUnitEl)) {
        if (builtTo.getLocalName().equals("built-to")) { // NOI18N
            String rawtext = XMLUtil.findText(builtTo);
            // Check that it is not an archive.
            String evaltext = evaluator.evaluate(rawtext);
            if (evaltext != null) {
                File dest = helper.resolveFile(evaltext);
                URL destU;
                try {
                    destU = Utilities.toURI(dest).toURL();
                } catch (MalformedURLException e) {
                    throw new AssertionError(e);
                }
                if (!FileUtil.isArchiveFile(destU)) {
                    // OK, dir, take it.
                    return rawtext;
                }
            }
        }
    }
    return null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:28,代碼來源:JavaActions.java

示例8: getContext

import org.openide.util.Utilities; //導入依賴的package包/類
private JavaSource getContext() {
    FileObject fo = Utilities.actionsGlobalContext().lookup(FileObject.class);
    if (fo == null) {
        final DataObject dobj = Utilities.actionsGlobalContext().lookup(DataObject.class);
        if (dobj != null) {
            fo = dobj.getPrimaryFile();
        }
    }
    if (fo == null) {
        return null;
    }
    TopComponent.Registry regs = WindowManager.getDefault().getRegistry();
    final TopComponent tc = regs.getActivated();
    final MultiViewHandler h = tc == null ?
            null :
            MultiViews.findMultiViewHandler(tc);
    if (h != null && FORM_VIEW_ID.equals(h.getSelectedPerspective().preferredID())) {
        //Form view does not support Members View
        return null;
    }
    return JavaSource.forFileObject(fo);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:ShowMembersAction.java

示例9: testCreateFolderOrDataFile_ReadOnly

import org.openide.util.Utilities; //導入依賴的package包/類
public void testCreateFolderOrDataFile_ReadOnly() throws Exception {
    clearWorkDir();
    final File wDir = getWorkDir();
    final File fold = new File(new File(new File(wDir,"a"), "b"), "c");
    final File data = new File(new File(new File(fold,"a"), "b"), "c.data");
    final boolean makeReadOnly = wDir.setReadOnly();
    if (!makeReadOnly && Utilities.isWindows()) {
        // According to bug 6728842: setReadOnly() only prevents the 
        // directory to be deleted on windows, does not prevent files
        // to be create in it. Thus the test cannot work on Windows.
        return;
    }
    assertTrue("Can change directory to read only: " + wDir, makeReadOnly);
    assertFalse("Cannot write", wDir.canWrite());
    try {
        implCreateFolderOrDataFile(fold, data);        
        fail("Creating folder or data should not be allowed: " + data);
    } catch (IOException ex) {            
    } finally {
        assertTrue(wDir.setWritable(true));
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:BaseFileObjectTestHid.java

示例10: registerTestDBDriverInstance

import org.openide.util.Utilities; //導入依賴的package包/類
private static JDBCDriver registerTestDBDriverInstance() throws Exception {
    JDBCDriver driver = null;
    TestCaseContext cxt = getContext();
    JDBCDriver[] drivers = JDBCDriverManager.getDefault().getDrivers(TEST_DB_DRIVER_CLASS);
    if (drivers.length == 0) {
        // if axion db driver not available in db explorer, add it.
        //URL[] url = new URL[1];
        File[] jars = cxt.getJars();
        ArrayList<URL> list = new java.util.ArrayList<URL>();
        for (int i = 0; i < jars.length; i++) {
            list.add(Utilities.toURI(jars[i]).toURL());
        }
        URL[] url = list.toArray(new URL[0]);
        driver = JDBCDriver.create(DRIVER_CLASS_NAME, "Mashup DB", DRIVER_CLASS_NAME, url);
        JDBCDriverManager.getDefault().addDriver(driver);
    }
    if (driver == null) {
        for (int i = 0; i < drivers.length; i++) {
            if (drivers[i].getClassName().equals(DRIVER_CLASS_NAME)) {
                driver = drivers[i];
                break;
            }
        }
    }
    return driver;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:DbUtil.java

示例11: layersOf

import org.openide.util.Utilities; //導入依賴的package包/類
/**
 * Lists any XML layers defined in a module JAR.
 * May include an explicit layer and/or a generated layer.
 * Layers from platform-specific modules are ignored automatically.
 * @param jar a module JAR file
 * @return from zero to two layer URLs
 */
public static List<URL> layersOf(File jar) throws IOException {
    ManifestManager mm = ManifestManager.getInstanceFromJAR(jar, true);
    for (String tok : mm.getRequiredTokens()) {
        if (tok.startsWith("org.openide.modules.os.")) { // NOI18N
            // Best to exclude platform-specific modules, e.g. ide/applemenu, as they can cause confusion.
            return Collections.emptyList();
        }
    }
    String layer = mm.getLayer();
    String generatedLayer = mm.getGeneratedLayer();
    List<URL> urls = new ArrayList<URL>(2);
    URI juri = Utilities.toURI(jar);
    for (String path : new String[] {layer, generatedLayer}) {
        if (path != null) {
            urls.add(new URL("jar:" + juri + "!/" + path));
        }
    }
    if (layer != null) {
        urls.add(new URL("jar:" + juri + "!/" + layer));
    }
    if (generatedLayer != null) {
        urls.add(new URL("jar:" + juri + "!/" + generatedLayer));
    }
    return urls;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:33,代碼來源:LayerUtil.java

示例12: convertToEmacs

import org.openide.util.Utilities; //導入依賴的package包/類
/**
 * Converts Map (ShortcutAction > Set (String (shortcut Alt+Shift+P))) to 
 * Map (ShortcutAction > Set (String (shortcut AS-P))).
 */
private static Map<ShortcutAction, Set<String>> convertToEmacs (Map<ShortcutAction, Set<String>> shortcuts) {
    Map<ShortcutAction, Set<String>> result = new HashMap<ShortcutAction, Set<String>> ();
    for (Map.Entry<ShortcutAction, Set<String>> entry: shortcuts.entrySet()) {
        ShortcutAction action = entry.getKey();
        Set<String> newSet = new HashSet<String> ();
        for (String s: entry.getValue()) {
            if (s.length () == 0) continue;
            KeyStroke[] ks = getKeyStrokes (s, " ");
            if (ks == null) 
                continue; // unparsable shortcuts ignorred
            StringBuffer sb = new StringBuffer (
                Utilities.keyToString (ks [0], true)
            );
            int i, k = ks.length;
            for (i = 1; i < k; i++)
                sb.append (' ').append (Utilities.keyToString (ks [i], true));
            newSet.add (sb.toString ());
        }
        result.put (action, newSet);
    }
    return result;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:MutableShortcutsModel.java

示例13: refreshFileStatus

import org.openide.util.Utilities; //導入依賴的package包/類
/**
 * Updates cache with scanned information for the given file
 * @param file
 * @param fi
 * @param interestingFiles
 * @param alwaysFireEvent
 */
private void refreshFileStatus(File file, FileInformation fi) {
    if(file == null || fi == null) return;
    FileInformation current;
    boolean fireEvent = true;
    synchronized (this) {
        file = FileUtil.normalizeFile(file);
        current = getInfo(file);
        fi = checkForIgnore(fi, current, file);
        if (equivalent(fi, current)) {
            // no need to fire an event
            if (Utilities.isWindows() || Utilities.isMac()) {
                // but for these we need to update keys in cache because of renames AAA.java -> aaa.java
                fireEvent = false;
            } else {
                return;
            }
        }
        boolean addToIndex = updateCachedValue(fi, file);
        updateIndex(file, fi, addToIndex);
    }
    if (fireEvent) {
        fireFileStatusChanged(file, current, fi);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:32,代碼來源:FileStatusCache.java

示例14: testSFBQImpl

import org.openide.util.Utilities; //導入依賴的package包/類
public void testSFBQImpl () throws Exception {
    MockServices.setServices(LegacySFBQImpl.class);
    SourceForBinaryQuery.Result2 res = SourceForBinaryQuery.findSourceRoots2(br1.toURL());
    assertNotNull(res);
    assertEquals(1, res.getRoots().length);
    assertEquals(Collections.singletonList(sr1), Arrays.asList(res.getRoots()));
    assertTrue(res.preferSources());
    
    res = SourceForBinaryQuery.findSourceRoots2(br2.toURL());
    assertNotNull(res);
    assertEquals(1, res.getRoots().length);
    assertEquals(Collections.singletonList(sr2), Arrays.asList(res.getRoots()));
    assertFalse(res.preferSources());
    
    res = SourceForBinaryQuery.findSourceRoots2(Utilities.toURI(getWorkDir()).toURL());
    assertNotNull(res);
    assertEquals(0, res.getRoots().length);
    assertFalse(res.preferSources());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:SourceForBinaryQueryTest.java

示例15: renameA2a_FO

import org.openide.util.Utilities; //導入依賴的package包/類
public void renameA2a_FO() throws Exception {
    // init
    File fileA = new File(wc, "A");
    fileA.createNewFile();
    commit(wc);

    File fileB = new File(wc, "a");

    // move
    renameFO(fileA, fileB);

    // test
    // test
    if (!Utilities.isMac() && !Utilities.isWindows()) {
        assertFalse(fileA.exists());
    }
    assertTrue(fileB.exists());

    assertEquals(SVNStatusKind.DELETED, getSVNStatus(fileA).getTextStatus());
    assertEquals(SVNStatusKind.ADDED, getSVNStatus(fileB).getTextStatus());

    assertEquals(FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY, getStatus(fileA));
    assertEquals(FileInformation.STATUS_VERSIONED_ADDEDLOCALLY, getStatus(fileB));
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:25,代碼來源:InteceptorTest.java


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