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()); } }
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()); }
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(); } }
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)); } }
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); } } }
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")); }
/** * 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; }
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); }
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)); } }
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; }
/** * 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; }
/** * 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; }
/** * 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); } }
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()); }
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)); }
public OutlineViewOutline(final OutlineModel mdl, PropertiesRowModel rowModel) { super(mdl); this.rowModel = rowModel; setSelectVisibleColumnsLabel(NbBundle.getMessage(OutlineView.class, "CTL_ColumnsSelector")); //NOI18N // fix for #198694 // default action map for JTable defines these shortcuts // but we use our own mechanism for handling them // following lines disable default L&F handling (if it is // defined on Ctrl-c, Ctrl-v and Ctrl-x) removeDefaultCutCopyPaste(getInputMap(WHEN_FOCUSED)); removeDefaultCutCopyPaste(getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)); KeyStroke ctrlSpace; if (Utilities.isMac()) { ctrlSpace = KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, KeyEvent.META_MASK, false); } else { ctrlSpace = KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, KeyEvent.CTRL_DOWN_MASK, false); } Object ctrlSpaceActionBind = getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).get(ctrlSpace); if (ctrlSpaceActionBind != null) { getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(ctrlSpace, "invokeCustomEditor"); //NOI18N Action invokeCustomEditorAction = new InvokeCustomEditorAction(ctrlSpaceActionBind); getActionMap().put("invokeCustomEditor", invokeCustomEditorAction); } }
public static boolean isValidPackageName(String str) { if (str.length() > 0 && str.charAt(0) == '.') { return false; } StringTokenizer tukac = new StringTokenizer(str, "."); while (tukac.hasMoreTokens()) { String token = tukac.nextToken(); if ("".equals(token)) { return false; } if (!Utilities.isJavaIdentifier(token)) { return false; } } return true; }
private void initEscenario(){ String rutaIconoRobot = rutapaqueteConstructorEscenariosROSACE + imageniconoRobot; IMAGErobot = Utilities.loadImage (rutaIconoRobot); IMAGEmujerRes = Utilities.loadImage ( rutapaqueteConstructorEscenariosROSACE +imageniconoMujerRescatada); IMAGEmujer = Utilities.loadImage ( rutapaqueteConstructorEscenariosROSACE +imageniconoMujer); IMAGEmujerAsignada= Utilities.loadImage ("utilsDiseniaEscenariosRosace/MujerAsignada.png"); IMAGEmujerReAsignada= Utilities.loadImage ("utilsDiseniaEscenariosRosace/MujerReasignada.png"); tablaEntidadesEnEscenario= new HashMap<String, JLabel>(); // JLabel label = new javax.swing.JLabel("RobotPrueba"); // String rutaIconoRobot = directorioTrabajo + "/" + rutassrc + rutapaqueteConstructorEscenariosROSACE + imageniconoRobot; // label.setIcon(new javax.swing.ImageIcon(rutaIconoRobot)); //System.out.println("Ruta->" + rutaIconoRobot); // label.createImage(10,10); // this.getRootPane().add(label); // this.repaint(); }
private void updateHelp() { //System.err.println ("Updating help for NbDialog..."); HelpCtx help = getHelpCtx(); // Handle help from the inner component automatically (see docs // in DialogDescriptor): if (HelpCtx.DEFAULT_HELP.equals(help)) { Object msg = descriptor.getMessage(); if (msg instanceof Component) { help = HelpCtx.findHelp((Component) msg); } if (HelpCtx.DEFAULT_HELP.equals(help)) help = null; } if (! Utilities.compareObjects(currentHelp, help)) { currentHelp = help; if (help != null && help.getHelpID() != null) { //System.err.println ("New help ID for root pane: " + help.getHelpID ()); HelpCtx.setHelpIDString(getRootPane(), help.getHelpID()); } // Refresh button list if it had already been created. if (haveCalledInitializeButtons) initializeButtons(); } }
@Override public void actionPerformed(ActionEvent e) { PasteType[] arr; synchronized (this) { arr = this.pasteTypes; } if (arr != null && arr.length > 0) { try { arr[0].paste(); return; } catch (IOException ex) { Exceptions.printStackTrace(ex); } } Utilities.disabledActionBeep(); }
private @NonNull synchronized FileObject[] getShadedJarSources() { try { List<Coordinates> coordinates = coorProvider.apply(Utilities.toFile(binary.toURI())); File lrf = EmbedderFactory.getProjectEmbedder().getLocalRepositoryFile(); List<FileObject> fos = new ArrayList<FileObject>(); if (coordinates != null) { for (Coordinates coord : coordinates) { if (coord.artifactId.equals(artifactId) && coord.groupId.equals(groupId) && coord.version.equals(version)) { continue; //skip the current jar, we've catered to in other ways. } File sourceJar = new File(lrf, coord.groupId.replace(".", File.separator) + File.separator + coord.artifactId + File.separator + coord.version + File.separator + coord.artifactId + "-" + coord.version + "-sources.jar"); fos.addAll(Arrays.asList(getSourceJarRoot(sourceJar))); } } return fos.toArray(new FileObject[0]); } catch (Exception ex) { LOG.log(Level.INFO, "error while examining binary " + binary, ex); } return new FileObject[0]; }
private void doActionIsCreatedOnlyOnce_13195(String name) throws Exception { // crate XML FS from data String[] stringLayers = new String [] { "/org/openide/awt/data/testActionOnlyOnce.xml" }; URL[] layers = new URL[stringLayers.length]; for (int cntr = 0; cntr < layers.length; cntr++) { layers[cntr] = Utilities.class.getResource(stringLayers[cntr]); } XMLFileSystem system = new XMLFileSystem(); system.setXmlUrls(layers); // build menu DataFolder dataFolder = DataFolder.findFolder(system.findResource(name)); MenuBar menuBar = new MenuBar(dataFolder); menuBar.waitFinished(); if (CreateOnlyOnceAction.instancesCount != 1) { // ensure that only one instance of action was created fail("Action created only once, but was: " + CreateOnlyOnceAction.instancesCount + "\n" + CreateOnlyOnceAction.w); } }
@Before @Override public void setUp() { //This will cause ContextAction instances to invoke notifyAll() //when their enablement changes ContextAction.unitTest = true; MockServices.setServices(Provider.class); ContextGlobalProvider x = Lookup.getDefault().lookup(ContextGlobalProvider.class); assertNotNull(x); assertTrue(x instanceof Provider); Provider p = (Provider) x; content = p.content; lkp = p.lkp; //some sanity checks setContent("hello"); assertEquals("hello", lkp.lookupAll(String.class).iterator().next()); assertEquals("hello", Utilities.actionsGlobalContext().lookupAll(String.class).iterator().next()); clearContent(); assertEquals(null, lkp.lookup(String.class)); assertEquals(null, Utilities.actionsGlobalContext().lookup(String.class)); assertEquals(0, Utilities.actionsGlobalContext().lookupAll(Object.class).size()); }
/** 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.getDisplayName().equals(all[i].getDisplayName())) { int newIndex = i != 0 ? i -1 : all.length - 1; MultiViewDescription selectedDescr = Accessor.DEFAULT.extractDescription(pers); if (selectedDescr instanceof ContextAwareDescription) { if (((ContextAwareDescription) selectedDescr).isSplitDescription()) { newIndex = i > 1 ? i - 2 : all.length - 1; } else { newIndex = i != 0 ? i - 2 : all.length - 2; } } handler.requestActive(all[newIndex]); break; } } } else { Utilities.disabledActionBeep(); } }
/** * Checks whether the given <code>packageName</code> represents a * valid name for a package. * * @param packageName the package name to check; must not be null. * @return true if the given <code>packageName</code> is a valid package * name, false otherwise. */ public static boolean isValidPackageName(String packageName) { Parameters.notNull("packageName", packageName); //NOI18N if ("".equals(packageName)) { return true; } if (packageName.startsWith(".") || packageName.endsWith(".")) {// NOI18N return false; } if(packageName.equals("java") || packageName.startsWith("java.")) {//NOI18N return false; } String[] tokens = packageName.split("\\."); //NOI18N if (tokens.length == 0) { return Utilities.isJavaIdentifier(packageName); } for(String token : tokens) { if (!Utilities.isJavaIdentifier(token)) { return false; } } return true; }
public void testEqualSymlinks() throws Exception { if (!Utilities.isUnix()) { return; } File copy = new File(getWorkDir(), "copy"); int ret = new ProcessBuilder("ln", "-s", "orig", copy.getPath()).start().waitFor(); assertEquals("Symlink created", ret, 0); assertTrue("Dir exists", copy.exists()); File f = new File(copy, "test.js"); assertTrue("File exists", f.exists()); URLEquality oe = new URLEquality(orig.toURI().toURL()); URLEquality ne = new URLEquality(f.toURI().toURL()); assertEquals("Same hashCode", oe.hashCode(), ne.hashCode()); assertEquals("They are similar", oe, ne); }
/** Invokes navigator data context change upon current nodes change or * current navigator hints change, * performs coalescing of fast coming changes. */ @Override public void resultChanged(LookupEvent ev) { if (!navigatorTC.getTopComponent().equals(WindowManager.getDefault().getRegistry().getActivated()) // #117089: allow node change when we are empty || (curNodes == null || curNodes.isEmpty())) { Lookup globalContext = Utilities.actionsGlobalContext(); NavigatorLookupPanelsPolicy panelsPolicy = globalContext.lookup(NavigatorLookupPanelsPolicy.class); Collection<? extends NavigatorLookupHint> lkpHints = globalContext.lookupAll(NavigatorLookupHint.class); ActNodeSetter nodeSetter = new ActNodeSetter(panelsPolicy, lkpHints); if (navigatorTC.allowAsyncUpdate()) { synchronized (NODE_SETTER_LOCK) { if (nodeSetterTask != null) { nodeSetterTask.cancel(); } // wait some time before propagating the change further nodeSetterTask = RequestProcessor.getDefault().post(nodeSetter, COALESCE_TIME); nodeSetterTask.addTaskListener(nodeSetter); } } else { nodeSetter.run(); } } }
protected void initComponents() { if (!oPanel.isPrepared()) { initComponent = new JLabel(NbBundle.getMessage(InitPanel.class, "LBL_computing")); // NOI18N initComponent.setPreferredSize(new Dimension(850, 450)); // avoid flicking ? Color c = UIManager.getColor("Tree.background"); // NOI18N if (c == null) { //GTK 1.4.2 will return null for Tree.background c = Color.WHITE; } initComponent.setBackground(c); // NOI18N initComponent.setHorizontalAlignment(SwingConstants.CENTER); initComponent.setOpaque(true); CardLayout card = new CardLayout(); setLayout(card); add(initComponent, "init"); // NOI18N card.show(this, "init"); // NOI18N Utilities.attachInitJob(this, this); } else { finished(); } }
private static Map<String, String> normalize(List<MultiKeyBinding> keybindings) { Map<String, String> norm = new TreeMap<String, String>(); for(MultiKeyBinding mkb : keybindings) { StringBuilder strokes = new StringBuilder(); for(Iterator<KeyStroke> i = mkb.getKeyStrokeList().iterator(); i.hasNext(); ) { KeyStroke stroke = i.next(); String s = Utilities.keyToString(stroke); strokes.append(s); if (i.hasNext()) { strokes.append(" "); } } String mkbId = "'" + strokes.toString() + "'"; String normalizedActionName = mkb.getActionName() == null ? "'null'" : "'" + mkb.getActionName() + "'"; assertFalse("Dulicate MultiKeyBinding '" + mkbId + "'", norm.containsKey(mkbId)); norm.put(mkbId, normalizedActionName); } return norm; }
public void testRenameFileChangeCase_DO () throws Exception { // prepare File fromFile = createFile("file"); File toFile = new File(getWorkTreeDir(), "FILE"); commit(fromFile); // move renameDO(fromFile, toFile.getName()); // test if (Utilities.isWindows() || Utilities.isMac()) { assertTrue(Arrays.asList(toFile.getParentFile().list()).contains(toFile.getName())); assertFalse(Arrays.asList(fromFile.getParentFile().list()).contains(fromFile.getName())); } else { assertFalse(fromFile.exists()); assertTrue(toFile.exists()); assertEquals(FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY, getCache().refresh(fromFile).getStatus()); assertEquals(FileInformation.STATUS_VERSIONED_ADDEDLOCALLY, getCache().refresh(toFile).getStatus()); } }
private void assertOpts(String body, String expected, String root) throws Exception { TestFileUtils.writeFile(wd, "pom.xml", "<project><modelVersion>4.0.0</modelVersion>" + "<groupId>test</groupId><artifactId>prj</artifactId>" + "<packaging>jar</packaging><version>1.0</version>" + body + "</project>"); FileObject rootFO = FileUtil.createFolder(wd, root); assertNotNull(rootFO); AnnotationProcessingQuery.Result r = AnnotationProcessingQuery.getAnnotationProcessingOptions(rootFO); URL sOD = r.sourceOutputDirectory(); Map<String,String> opts = new TreeMap<String,String>(r.processorOptions()); assertEquals("false", opts.remove("eclipselink.canonicalmodel.use_static_factory")); assertEquals(expected, "enabled=" + r.annotationProcessingEnabled() + " run=" + r.annotationProcessorsToRun() + " s=" + (sOD != null ? sOD.toString().replace(Utilities.toURI(getWorkDir()).toString(), ".../") : "-") + " opts=" + opts); }
private void setProperty(String name, String value, boolean split) { if (Utilities.compareObjects(value, getProperty(name))) { return; } modified = true; if (value != null) { value = value.trim(); } if (value != null && value.length() > 0) { if (split) { props[props.length - 1].setProperty(name, splitBySentence(value)); } else { props[props.length - 1].setProperty(name, value); } } else { for (int i = 0; i < props.length; i++) { props[i].remove(name); } } // XXX Bundle-Name added by project template; could add Bundle-Category and/or Bundle-Description if similar properties set here }
/** * Returns a new instance of BrowserImpl implementation. * @throws UnsupportedOperationException when method is called and OS is not supported. * @return browserImpl implementation of browser. */ @Override public HtmlBrowser.Impl createHtmlBrowserImpl() { ExtBrowserImpl impl = null; if (Utilities.isUnix() && !Utilities.isMac()) { impl = new UnixBrowserImpl(this); } else if (Utilities.isWindows()) { impl = new NbDdeBrowserImpl(this); } else { throw new UnsupportedOperationException (NbBundle. getMessage(FirefoxBrowser.class, "MSG_CannotUseBrowser")); // NOI18N } return impl; }
/** * Workaround for Apple bug 3644261 - after using form editor, all boldface * fonts start showing up with incorrect metrics, such that all boldface * fonts in the entire IDE are displayed 12px below where they should be. * Embarrassing and awful. */ private static final Font deriveFont(Font f, int style) { // return f.deriveFont(style); // see #49973 for details. Font result = Utilities.isMac() ? new Font(f.getName(), style, f.getSize()) : f.deriveFont(style); return result; }
private URL asDir(String path) throws Exception { URL u = Utilities.toURI(simple2.helper().resolveFile(path)).toURL(); String us = u.toExternalForm(); if (us.endsWith("/")) { return u; } else { return new URL(us + "/"); } }
private void showPopupMenu(int x, int y) { Node[] activatedNodes = getActivatedNodes(); if (activatedNodes.length == 1) { Action[] actions = activatedNodes[0].getActions(true); JPopupMenu contextMenu = Utilities.actionsToPopup(actions, ScreenshotComponent.this); contextMenu.show(ScreenshotComponent.this.canvas, x, y); } }
public void testResolve() throws Exception { File pom = TestFileUtils.writeFile(new File(getWorkDir(), "pom.xml"), "<project xmlns='http://maven.apache.org/POM/4.0.0'><modelVersion>4.0.0</modelVersion>" + "<groupId>g</groupId><artifactId>a</artifactId><version>0</version>" + "</project>"); MavenFileOwnerQueryImpl.getInstance().registerCoordinates("g", "a", "0", Utilities.toURI(getWorkDir()).toURL(), true); assertEquals(pom, new NbArtifactFixer().resolve(new DefaultArtifact("g:a:pom:0"))); assertEquals(null, new NbArtifactFixer().resolve(new DefaultArtifact("g:a:jar:0"))); File fallback = new NbArtifactFixer().resolve(new DefaultArtifact("g:a:pom:1")); assertNotNull(fallback); assertFalse(fallback.equals(pom)); assertEquals(null, new NbArtifactFixer().resolve(new DefaultArtifact("g:a:pom:stuff:0"))); }
private void collectClassFiles(@NonNull final File folder, @NonNull final Queue<? super URL> q) throws MalformedURLException { final File[] chld = folder.listFiles(); if (chld == null) { return; } for (File f : chld) { if (f.isDirectory()) { collectClassFiles(f, q); } else if (FileObjects.CLASS.equals(FileObjects.getExtension(f.getName()))) { q.offer(Utilities.toURL(f)); } } }
private boolean addRemoveJAR(File jar, POMModel mdl, String scope, boolean add) throws IOException { if (!add) { throw new UnsupportedOperationException("removing JARs not yet supported"); } NBVersionInfo dep = null; for (NBVersionInfo _dep : RepositoryQueries.findBySHA1Result(jar, RepositoryPreferences.getInstance().getRepositoryInfos()).getResults()) { if (!"unknown.binary".equals(_dep.getGroupId())) { dep = _dep; break; } } if (dep == null) { dep = new NBVersionInfo(null, "unknown.binary", jar.getName().replaceFirst("[.]jar$", ""), "SNAPSHOT", null, null, null, null, null); addJarToPrivateRepo(jar, mdl, dep); } //if not found anywhere, add to a custom file:// based repository structure within the project's directory. boolean added = false; Dependency dependency = ModelUtils.checkModelDependency(mdl, dep.getGroupId(), dep.getArtifactId(), false); if (dependency == null) { dependency = ModelUtils.checkModelDependency(mdl, dep.getGroupId(), dep.getArtifactId(), true); LOG.log(Level.FINE, "added new dep {0} as {1}", new Object[] {jar, dep}); added = true; } if (!Utilities.compareObjects(dep.getVersion(), dependency.getVersion())) { dependency.setVersion(dep.getVersion()); LOG.log(Level.FINE, "upgraded version on {0} as {1}", new Object[] {jar, dep}); added = true; } if (!Utilities.compareObjects(scope, dependency.getScope())) { dependency.setScope(scope); LOG.log(Level.FINE, "changed scope on {0} as {1}", new Object[] {jar, dep}); added = true; } return added; }