rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
log().debug( "request: " + file + " handled by " + handler.getClass().getName());
private Handler getHandler(String file) { if (handlers.containsKey(file)) { Handler handler = handlers.get(file); log().debug( "request: " + file + " handled by " + handler.getClass().getName()); return handler; } if (file.startsWith("/download")) { log().debug( "request: " + file + " handled by " + downloadHandler.getClass().getName()); return downloadHandler; } return null; }
log().verbose( "Updated SyncStatusPanel due to change in: " + folderEvent);
if (logEnabled) { log().verbose( "Updated SyncStatusPanel due to change in: " + folderEvent); }
public void statisticsCalculated(FolderEvent folderEvent) { updatePanel(); log().verbose( "Updated SyncStatusPanel due to change in: " + folderEvent); }
.debug( getController().getMySelf().getNick() + " start requesting");
.debug("start requesting");
public void run() { long waitTime = getController().getWaitTime() * 4; while (!myThread.isInterrupted()) { log() .debug( getController().getMySelf().getNick() + " start requesting"); FolderInfo[] folders = getController().getFolderRepository() .getJoinedFolderInfos(); for (FolderInfo folderInfo : folders) { Folder folder = getController().getFolderRepository() .getFolder(folderInfo); // Download new files on folder if autodownload is wanted if (folder != null) { // maybe null during shutdown requestMissingFilesForAutodownload(folder); } } try { if (!triggered) { synchronized (requestTrigger) { // use waiter, will quit faster requestTrigger.wait(waitTime); } } triggered = false; // Sleep a bit to avoid spamming Thread.sleep(200); } catch (InterruptedException e) { log().verbose(e); break; } } }
log().verbose( getController().getMySelf().getNick() + " Requesting files (autodownload), has own DB? "
log().verbose("Requesting files (autodownload), has own DB? "
public void requestMissingFilesForAutodownload(Folder folder) { if (!folder.getSyncProfile().isAutodownload()) { return; } if (logVerbose) { log().verbose( getController().getMySelf().getNick() + " Requesting files (autodownload), has own DB? " + folder.hasOwnDatabase()); } // Dont request files until has own database if (!folder.hasOwnDatabase()) { return; } List<FileInfo> expectedFiles = folder.getIncomingFiles(folder .getSyncProfile().isAutoDownloadFromOthers()); TransferManager tm = getController().getTransferManager(); for (FileInfo fInfo : expectedFiles) { if (fInfo.isDeleted() || tm.isDownloadingActive(fInfo) || tm.isDownloadingPending(fInfo)) { // Already downloading/file is deleted continue; } boolean download = folder.getSyncProfile() .isAutoDownloadFromOthers() || (folder.getSyncProfile().isAutoDownloadFromFriends() && fInfo .getModifiedBy().getNode(getController()).isFriend()); if (download) { tm.downloadNewestVersion(fInfo, true); } } }
sendToApplicationQueue(aMessage);
boolean sentToQueue = sendToApplicationQueue(aMessage); if (sentToQueue) logAddNewOrder(aMessage);
protected void addNewOrder(Message aMessage) throws FieldNotFound, MarketceteraException { try { fixMessageHistory.addOutgoingMessage(aMessage); sendToApplicationQueue(aMessage); } catch (JMSException ex) { internalMainLogger.error( "Error sending message to JMS", ex); } }
sendToApplicationQueue(cancelMessage);
boolean sentToQueue = sendToApplicationQueue(cancelMessage); if (sentToQueue) logCancelOneOrder(cancelMessage);
protected void cancelReplaceOneOrder(Message cancelMessage) throws NoMoreIDsException, FieldNotFound, JMSException { String clOrdId = (String) cancelMessage.getString(OrigClOrdID.FIELD); Message latestMessage = fixMessageHistory.getLatestMessage(clOrdId); if (latestMessage != null){ cancelMessage.setField(new OrigClOrdID(clOrdId)); cancelMessage.setField(new ClOrdID(this.idFactory.getNext())); fillFieldsFromExistingMessage(cancelMessage, latestMessage); fixMessageHistory.addOutgoingMessage(cancelMessage); try { sendToApplicationQueue(cancelMessage); } catch (JMSException e) { internalMainLogger.error("Error sending cancel/replace for order "+clOrdId, e); } } else { internalMainLogger.error("Could not send cancel/replace request for order ID "+clOrdId); } }
LOG.warn("Restarting controller"); controller = null; try { Thread.sleep(1000 * 1000); } catch (InterruptedException e) { e.printStackTrace(); }
public static void startPowerFolder(String[] args) { // Default exception logger Thread .setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { public void uncaughtException(Thread t, Throwable e) { LOG.error("Exception in " + t + ": " + e.toString(), e); } }); // Command line parsing Options options = new Options(); options .addOption( "c", "config", true, "<config file>. Sets the configuration file to start. Default: PowerFolder.config"); options.addOption("t", "tester", false, "Enables tester mode. Will check for new development version"); options.addOption("m", "minimized", false, "Start PowerFolder minimized"); options.addOption("s", "server", false, "Start PowerFolder as server/supernode. GUI will be disabled"); options .addOption("d", "dns", true, "<ip/dns>. Sets the dns/ip to listen to. May also be an dyndns address"); options.addOption("h", "help", false, "Displays this help"); options.addOption("n", "nick", true, "<nickname> Sets the nickname"); options.addOption("k", "kill", false, "Shutsdown a running PowerFolder instance"); options.addOption("l", "log", false, "Displays logging information on console"); options .addOption( "f", "langfile", true, "<path\\file> Sets the language file to use (e.g. \"--langfile c:\\powerfolder\\translation\\translation_XX.properties\", forces PowerFolder to load this file as language file)"); options .addOption( "g", "language", true, "<language> Sets the language to use (e.g. \"--language de\", sets language to german)"); options.addOption("p", "createfolder", true, "<createfolder> Creates a new PowerFolder"); CommandLineParser parser = new PosixParser(); CommandLine commandLine; try { // parse the command line arguments commandLine = parser.parse(options, args); } catch (ParseException exp) { // oops, something went wrong System.err.println("Start failed. Reason: " + exp.getMessage()); // automatically generate the help statement HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("PowerFolder", options); return; } // Enable console logging if wanted (--log) Logger.setEnabledConsoleLogging(commandLine.hasOption("l")); if (commandLine.hasOption("s")) { // Server mode, supress debug output on console Logger.setExcludeConsoleLogLevel(Logger.DEBUG); } if (commandLine.hasOption("h")) { // Show help HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("PowerFolder", options); return; } if (commandLine.hasOption("k")) { if (!RemoteCommandManager.hasRunningInstance()) { System.err.println("PowerFolder not running"); } else { System.out.println("Stopping PowerFolder"); // Send quit command RemoteCommandManager.sendCommand(RemoteCommandManager.QUIT); } // stop return; } // set language from commandline to preferences if (commandLine.hasOption("g")) { Preferences.userNodeForPackage(Translation.class).put("locale", commandLine.getOptionValue("g")); } // The controller // Replace this line, when all calls to getInstance are removed Controller controller = Controller.createController(); String[] files = commandLine.getArgs(); // Parsing of command line completed // Start controller if no running instance boolean startController = !RemoteCommandManager.hasRunningInstance(); try { LOG.info("PowerFolder v" + Controller.PROGRAM_VERSION); // Start controller if (startController) { controller.startConfig(commandLine); } // Send remote command if there a files in commandline if (files.length > 0) { // Parse filenames and build remote command StringBuffer openFilesRCommand = new StringBuffer( RemoteCommandManager.OPEN); for (int i = 0; i < files.length; i++) { openFilesRCommand.append(files[i]); // FIXME: Add ; separator ? } // Send remote command to running PowerFolder instance RemoteCommandManager.sendCommand(openFilesRCommand.toString()); } if (commandLine.hasOption("p")) { RemoteCommandManager.sendCommand(RemoteCommandManager.MAKEFOLDER + commandLine.getOptionValue("p")); } } catch (Throwable t) { LOG.error(t); return; } // Started if (startController) { System.out.println("------------ PowerFolder " + Controller.PROGRAM_VERSION + " started ------------"); } // Not go into console mode if ui is open if (!startController) { return; } if (controller.isUIEnabled()) { boolean restartRequested = false; do { // Go into restart loop while (controller.isStarted() || controller.isShuttingDown()) { try { Thread.sleep(2000); } catch (InterruptedException e) { LOG.warn(e); return; } } restartRequested = controller.isRestartRequested(); if (restartRequested) { Map<Thread, StackTraceElement[]> threads = Thread .getAllStackTraces(); for (Thread thread : threads.keySet()) { if (thread.getName().startsWith("PoolThread") || thread.getName().startsWith("Reconnector") || thread.getName().startsWith("ConHandler")) { thread.interrupt(); } } System.gc(); LOG.warn("Restarting controller"); controller = null; try { Thread.sleep(1000 * 1000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } controller = Controller.createController(); // Start controller controller.startConfig(commandLine); } } while (restartRequested); // Exit return; } // Console mode comes here ... // Add shutdown hook LOG.verbose("Adding shutdown hook"); final Controller con = controller; Runtime.getRuntime().addShutdownHook( new Thread("Shutdown hook for PowerFolder") { public void run() { // Shut down controller on VM exit con.shutdown(); } }); if (controller == null) { // Stop return; } // Console loop BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); while (controller.isStarted()) { try { String line = in.readLine(); if (line == null) { line = ""; } line = line.toLowerCase(); if (line.startsWith("x")) { // x pressed, exit controller.exit(0); } else if (line.startsWith("connect ")) { String conStr = line.substring(8); try { controller.connect(conStr); } catch (ConnectionException e) { LOG.error("Unable to connect to " + conStr); } } else if (line.startsWith("c ")) { String conStr = line.substring(2); try { controller.connect(conStr); } catch (ConnectionException e) { LOG.error("Unable to connect to " + conStr); } } else if (line.startsWith("ul ")) { String ulimit = line.substring(3); try { controller.getTransferManager().setAllowedUploadCPSForWAN( (long) Double.parseDouble(ulimit) * 1024); } catch (NumberFormatException e) { LOG.error("Unable to parse new upload limit bandwidth " + ulimit); } } else if (line.startsWith("r")) { // write report controller.writeDebugReport(); System.out.println(controller.getDebugReport()); } // Sleep a bit, if commands are comming in too fast // on linux background processing Thread.sleep(200); } catch (IOException e) { LOG.error(e); break; } catch (InterruptedException e) { LOG.error(e); break; } } }
commandStatusLineContribution.addCommandListener(Application.getOrderManager().getCommandListener());
protected void makeActions(IWorkbenchWindow window) { this.window = window; commandStatusLineContribution = new CommandStatusLineContribution(CommandStatusLineContribution.ID); commandStatusLineContribution.addCommandListener(Application.getOrderManager().getCommandListener()); feedStatusLineContribution = new FeedStatusLineContribution("feedStatus", new String[] {JMSConnector.JMS_CONNECTOR_ID}); Application.getJMSConnector().addFeedComponentListener(feedStatusLineContribution); closeAllAction = ActionFactory.CLOSE_ALL.create(window); register(closeAllAction); closeAction = ActionFactory.CLOSE.create(window); register(closeAction); quitAction = ActionFactory.QUIT.create(window); register(quitAction); undoAction = ActionFactory.UNDO.create(window); register(undoAction); redoAction = ActionFactory.REDO.create(window); register(redoAction); cutAction = ActionFactory.CUT.create(window); register(cutAction); copyAction = ActionFactory.COPY.create(window); register(copyAction); create = ActionFactory.PASTE.create(window); register(create); deleteAction = ActionFactory.DELETE.create(window); register(deleteAction); selectAllAction = ActionFactory.SELECT_ALL.create(window); register(selectAllAction); findAction = ActionFactory.FIND.create(window); register(findAction); openNewWindowAction = ActionFactory.OPEN_NEW_WINDOW.create(window); register(openNewWindowAction); newEditorAction = ActionFactory.NEW_EDITOR.create(window); register(newEditorAction); perspectiveList = ContributionItemFactory.PERSPECTIVES_SHORTLIST .create(window); viewList = ContributionItemFactory.VIEWS_SHORTLIST.create(window); savePerspectiveAction = ActionFactory.SAVE_PERSPECTIVE.create(window); register(savePerspectiveAction); resetPerspectiveAction = ActionFactory.RESET_PERSPECTIVE.create(window); register(resetPerspectiveAction); closePerspectiveAction = ActionFactory.CLOSE_PERSPECTIVE.create(window); register(closePerspectiveAction); closeAllPerspectivesAction = ActionFactory.CLOSE_ALL_PERSPECTIVES .create(window); register(closeAllPerspectivesAction); maximizeAction = ActionFactory.MAXIMIZE.create(window); register(maximizeAction); minimizeAction = ActionFactory.MINIMIZE.create(window); register(minimizeAction); activateEditorAction = ActionFactory.ACTIVATE_EDITOR.create(window); register(activateEditorAction); nextEditorAction = ActionFactory.NEXT_EDITOR.create(window); register(nextEditorAction); previousEditorAction = ActionFactory.PREVIOUS_EDITOR.create(window); register(previousEditorAction); showEditorAction = ActionFactory.SHOW_EDITOR.create(window); register(showEditorAction); nextPerspectiveAction = ActionFactory.NEXT_PERSPECTIVE.create(window); register(nextPerspectiveAction); previousPerspectiveAction = ActionFactory.PREVIOUS_PERSPECTIVE .create(window); register(previousPerspectiveAction); webHelpAction = new WebHelpAction(window); register(webHelpAction);// helpContentsAction = ActionFactory.HELP_CONTENTS.create(window); register(helpContentsAction);// helpSearchAction = ActionFactory.HELP_SEARCH.create(window); register(helpSearchAction);// dynamicHelpAction = ActionFactory.DYNAMIC_HELP.create(window); register(dynamicHelpAction); checkForUpdatesAction = new CheckForUpdatesAction(window); register(checkForUpdatesAction); aboutAction = ActionFactory.ABOUT.create(window); register(aboutAction); reconnectJMSAction = new ReconnectJMSAction(); register(reconnectJMSAction); //viewSecurityAction = new ViewSecurityAction(window); focusCommandAction = new FocusCommandAction(window, commandStatusLineContribution); register(focusCommandAction); orderHistoryAction = new OrderHistoryAction(window); }
this.window = window;
public CancelOrderAction( IWorkbenchWindow window, OrderManager manager) { this.window = window; this.manager = manager; setId(ID); setActionDefinitionId(ID); setText("Cancel an order"); setToolTipText("Cancel an order"); setImageDescriptor(PhotonPlugin.getImageDescriptor(IImageKeys.CANCEL)); }
new Job("Startup"){ @Override protected IStatus run(IProgressMonitor monitor) { try { startJMS(); } catch (Exception ex) { PhotonPlugin.getMainConsoleLogger().error("Exception connecting to message queue", ex); } try { startQuoteFeed(); } catch (Exception ex) { PhotonPlugin.getMainConsoleLogger().error("Exception connecting to quote feed", ex); } startIDFactory(); return JobStatus.OK_STATUS; } }.schedule();
public Object run(Object args) throws Exception { PhotonPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this); Display display = PlatformUI.createDisplay(); try { new Job("Startup"){ @Override protected IStatus run(IProgressMonitor monitor) { try { startJMS(); } catch (Exception ex) { PhotonPlugin.getMainConsoleLogger().error("Exception connecting to message queue", ex); } try { startQuoteFeed(); } catch (Exception ex) { PhotonPlugin.getMainConsoleLogger().error("Exception connecting to quote feed", ex); } startIDFactory(); return JobStatus.OK_STATUS; } }.schedule(); int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor()); if (returnCode == PlatformUI.RETURN_RESTART) { return IPlatformRunnable.EXIT_RESTART; } stopJMS(); stopQuoteFeed(); return IPlatformRunnable.EXIT_OK; } finally { display.dispose(); } }
stopJMS(); stopQuoteFeed();
public Object run(Object args) throws Exception { PhotonPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this); Display display = PlatformUI.createDisplay(); try { new Job("Startup"){ @Override protected IStatus run(IProgressMonitor monitor) { try { startJMS(); } catch (Exception ex) { PhotonPlugin.getMainConsoleLogger().error("Exception connecting to message queue", ex); } try { startQuoteFeed(); } catch (Exception ex) { PhotonPlugin.getMainConsoleLogger().error("Exception connecting to quote feed", ex); } startIDFactory(); return JobStatus.OK_STATUS; } }.schedule(); int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor()); if (returnCode == PlatformUI.RETURN_RESTART) { return IPlatformRunnable.EXIT_RESTART; } stopJMS(); stopQuoteFeed(); return IPlatformRunnable.EXIT_OK; } finally { display.dispose(); } }
Object[] path = new Object[]{ getRoot(), getUIController().getFolderRepositoryModel() .getMyFoldersTreeNode(), folder.getTreeNode()}; TreeModelEvent te = new TreeModelEvent(this, path); fireTreeStructureChanged(te);
FolderRepositoryModel folderRepositoryModel = getUIController() .getFolderRepositoryModel(); if (folderRepositoryModel != null) { TreeNodeList list = folderRepositoryModel .getMyFoldersTreeNode(); if (list != null) { Object[] path = new Object[]{getRoot(), list, folder.getTreeNode()}; TreeModelEvent te = new TreeModelEvent(this, path); fireTreeStructureChanged(te); } }
private void updateFolderTreeNode(Folder folder) { // Update tree on that folder if (logVerbose) { log().verbose("Updating files of folder " + folder); } Object[] path = new Object[]{ getRoot(), getUIController().getFolderRepositoryModel() .getMyFoldersTreeNode(), folder.getTreeNode()}; TreeModelEvent te = new TreeModelEvent(this, path); fireTreeStructureChanged(te); }
ChatModelListener chatModelListener = (ChatModelListener) chatModelListeners
ChatModelListener chatModelListener = chatModelListeners
private void fireChatModelChanged(Object source, boolean isStatus) { for (int i = 0; i < chatModelListeners.size(); i++) { ChatModelListener chatModelListener = (ChatModelListener) chatModelListeners .get(i); if (isStatus) { chatModelListener.chatChanged(new ChatModelEvent(source, true)); } else { chatModelListener.chatChanged(new ChatModelEvent(source)); } } }
public Map<String, Object> get(String... keys) { final Map<String, Object> rv=new ConcurrentHashMap<String, Object>(); final AtomicInteger requests=new AtomicInteger(); final SynchronizationObject<AtomicInteger> sync =new SynchronizationObject<AtomicInteger>(requests); GetOperation.Callback cb=new GetOperation.Callback() { public void getComplete() { requests.decrementAndGet(); sync.set(requests); } public void gotData(String k, int flags, byte[] data) { rv.put(k, transcoder.decode(new CachedData(flags, data))); } }; Map<Integer, Collection<String>> chunks =new HashMap<Integer, Collection<String>>(); for(String key : keys) { int which=getServerForKey(key); Collection<String> ks=chunks.get(which); if(ks == null) { ks=new ArrayList<String>(); chunks.put(which, ks);
public Object get(final String key) { final CachedData[] rvContainer=new CachedData[1]; final SynchronizationObject<Object> sync =new SynchronizationObject<Object>(null); asyncGet(new GetOperation.Callback() { public void getComplete() { sync.set(new Object());
public Map<String, Object> get(String... keys) { final Map<String, Object> rv=new ConcurrentHashMap<String, Object>(); final AtomicInteger requests=new AtomicInteger(); final SynchronizationObject<AtomicInteger> sync =new SynchronizationObject<AtomicInteger>(requests); GetOperation.Callback cb=new GetOperation.Callback() { public void getComplete() { requests.decrementAndGet(); sync.set(requests); } public void gotData(String k, int flags, byte[] data) { rv.put(k, transcoder.decode(new CachedData(flags, data))); } }; // Break the gets down into groups by key Map<Integer, Collection<String>> chunks =new HashMap<Integer, Collection<String>>(); for(String key : keys) { int which=getServerForKey(key); Collection<String> ks=chunks.get(which); if(ks == null) { ks=new ArrayList<String>(); chunks.put(which, ks); } ks.add(key); } for(Map.Entry<Integer, Collection<String>> me : chunks.entrySet()) { requests.incrementAndGet(); conn.addOperation(me.getKey(), new GetOperation(me.getValue(), cb)); } try { sync.waitUntilTrue( new SynchronizationObject.Predicate<AtomicInteger>() { public boolean evaluate(AtomicInteger val) { return val.get() == 0; }}, Long.MAX_VALUE, TimeUnit.SECONDS); } catch (InterruptedException e) { throw new RuntimeException("Interrupted waiting for results", e); } catch (TimeoutException e) { throw new RuntimeException("Timed out waiting forever", e); } return rv; }
ks.add(key); } for(Map.Entry<Integer, Collection<String>> me : chunks.entrySet()) { requests.incrementAndGet(); conn.addOperation(me.getKey(), new GetOperation(me.getValue(), cb)); } try { sync.waitUntilTrue( new SynchronizationObject.Predicate<AtomicInteger>() { public boolean evaluate(AtomicInteger val) { return val.get() == 0; }}, Long.MAX_VALUE, TimeUnit.SECONDS); } catch (InterruptedException e) { throw new RuntimeException("Interrupted waiting for results", e); } catch (TimeoutException e) { throw new RuntimeException("Timed out waiting forever", e);
public void gotData(String k, int flags, byte[] data) { assert k.equals(key) : "Incorrect key returned: " + k; rvContainer[0]=new CachedData(flags, data); }}, key); waitForNotNull(sync); Object rv=null; if(rvContainer[0] != null) { rv=transcoder.decode(rvContainer[0]);
public Map<String, Object> get(String... keys) { final Map<String, Object> rv=new ConcurrentHashMap<String, Object>(); final AtomicInteger requests=new AtomicInteger(); final SynchronizationObject<AtomicInteger> sync =new SynchronizationObject<AtomicInteger>(requests); GetOperation.Callback cb=new GetOperation.Callback() { public void getComplete() { requests.decrementAndGet(); sync.set(requests); } public void gotData(String k, int flags, byte[] data) { rv.put(k, transcoder.decode(new CachedData(flags, data))); } }; // Break the gets down into groups by key Map<Integer, Collection<String>> chunks =new HashMap<Integer, Collection<String>>(); for(String key : keys) { int which=getServerForKey(key); Collection<String> ks=chunks.get(which); if(ks == null) { ks=new ArrayList<String>(); chunks.put(which, ks); } ks.add(key); } for(Map.Entry<Integer, Collection<String>> me : chunks.entrySet()) { requests.incrementAndGet(); conn.addOperation(me.getKey(), new GetOperation(me.getValue(), cb)); } try { sync.waitUntilTrue( new SynchronizationObject.Predicate<AtomicInteger>() { public boolean evaluate(AtomicInteger val) { return val.get() == 0; }}, Long.MAX_VALUE, TimeUnit.SECONDS); } catch (InterruptedException e) { throw new RuntimeException("Interrupted waiting for results", e); } catch (TimeoutException e) { throw new RuntimeException("Timed out waiting forever", e); } return rv; }
WorkbenchAdapterBuilder.registerAdapters();
registerIdeAdapters(); declareIdeWorkbenchImages();
public void initialize(IWorkbenchConfigurer configurer) { configurer.setSaveAndRestore(true); // explicitly register ide- and resource-related adapters that rdt relies on WorkbenchAdapterBuilder.registerAdapters(); ConsolePlugin.getDefault().getConsoleManager().addConsoles( new IConsole[] { new MainConsole() }); }
showAdvancedSettingsModel = new ValueHolder(getController().getPreferences().getBoolean(SHOWADVANCEDSETTINGS, false));
showAdvancedSettingsModel = new ValueHolder(PreferencesEntry.SHOWADVANCEDSETTINGS.getValueBoolean(getController()));
private void initComponents() { writeTrigger = new Trigger(); showAdvancedSettingsModel = new ValueHolder(getController().getPreferences().getBoolean(SHOWADVANCEDSETTINGS, false)); nickField = new JTextField(getController().getMySelf().getNick()); ValueModel csModel = new PreferencesAdapter(getController() .getPreferences(), "createdesktopshortcuts", Boolean.TRUE); createDesktopShortcutsBox = BasicComponentFactory.createCheckBox( new BufferedValueModel(csModel, writeTrigger), Translation .getTranslation("preferences.dialog.createdesktopshortcuts")); // Only available on windows systems createDesktopShortcutsBox.setEnabled(OSUtil.isWindowsSystem()); // Language selector languageChooser = createLanguageChooser(); // Build color theme chooser colorThemeChooser = createThemeChooser(); if (UIManager.getLookAndFeel() instanceof PlasticXPLookAndFeel) { colorThemeChooser.setEnabled(true); oldTheme = PlasticXPLookAndFeel.getPlasticTheme(); } else { // Only available if PlasicXPLookAndFeel is enabled colorThemeChooser.setEnabled(false); } // Create xBehaviorchooser ValueModel xBehaviorModel = new PreferencesAdapter(getController() .getPreferences(), "quitonx", Boolean.FALSE); // Build behavior chooser xBehaviorChooser = createXBehaviorChooser(new BufferedValueModel( xBehaviorModel, writeTrigger)); // Only available on systems with system tray xBehaviorChooser.setEnabled(OSUtil.isSystraySupported()); if (!xBehaviorChooser.isEnabled()) { // Display exit on x if not enabled xBehaviorModel.setValue(Boolean.TRUE); } // Local base selection localBaseHolder = new ValueHolder(getController().getFolderRepository() .getFoldersBasedir()); localBaseSelectField = ComplexComponentFactory .createDirectorySelectionField(Translation .getTranslation("preferences.dialog.basedir.title"), localBaseHolder, null); showAdvancedSettingsBox = BasicComponentFactory.createCheckBox( showAdvancedSettingsModel, Translation .getTranslation("preferences.dialog.showadvanced")); }
Preferences pref = getController().getPreferences();
public void save() { Preferences pref = getController().getPreferences(); // Write properties into core writeTrigger.triggerCommit(); // Set locale if (languageChooser.getSelectedItem() instanceof Locale) { Locale locale = (Locale) languageChooser.getSelectedItem(); // Check if we need to restart needsRestart |= !Util.equals(locale.getLanguage(), Translation .getActiveLocale().getLanguage()); // Save settings Translation.saveLocalSetting(locale); } else { // Remove setting Translation.saveLocalSetting(null); } // Set folder base String folderbase = (String) localBaseHolder.getValue(); ConfigurationEntry.FOLDER_BASEDIR.setValue(getController(), folderbase); // Store ui theme if (UIManager.getLookAndFeel() instanceof PlasticXPLookAndFeel) { PlasticTheme theme = PlasticXPLookAndFeel.getPlasticTheme(); pref.put("uitheme", theme.getClass().getName()); if (!Util.equals(theme, oldTheme)) { // FIXME: Themechange does not repaint SimpleInternalFrames. // thus restart required needsRestart = true; } } // Nickname if (!StringUtils.isBlank(nickField.getText())) { getController().changeNick(nickField.getText(), false); } // setAdvanced pref.putBoolean(SHOWADVANCEDSETTINGS, showAdvancedSettingsBox.isSelected()); }
pref.put("uitheme", theme.getClass().getName());
PreferencesEntry.UI_COLOUR_THEME.setValue(getController(), theme.getClass().getName());
public void save() { Preferences pref = getController().getPreferences(); // Write properties into core writeTrigger.triggerCommit(); // Set locale if (languageChooser.getSelectedItem() instanceof Locale) { Locale locale = (Locale) languageChooser.getSelectedItem(); // Check if we need to restart needsRestart |= !Util.equals(locale.getLanguage(), Translation .getActiveLocale().getLanguage()); // Save settings Translation.saveLocalSetting(locale); } else { // Remove setting Translation.saveLocalSetting(null); } // Set folder base String folderbase = (String) localBaseHolder.getValue(); ConfigurationEntry.FOLDER_BASEDIR.setValue(getController(), folderbase); // Store ui theme if (UIManager.getLookAndFeel() instanceof PlasticXPLookAndFeel) { PlasticTheme theme = PlasticXPLookAndFeel.getPlasticTheme(); pref.put("uitheme", theme.getClass().getName()); if (!Util.equals(theme, oldTheme)) { // FIXME: Themechange does not repaint SimpleInternalFrames. // thus restart required needsRestart = true; } } // Nickname if (!StringUtils.isBlank(nickField.getText())) { getController().changeNick(nickField.getText(), false); } // setAdvanced pref.putBoolean(SHOWADVANCEDSETTINGS, showAdvancedSettingsBox.isSelected()); }
pref.putBoolean(SHOWADVANCEDSETTINGS, showAdvancedSettingsBox.isSelected());
PreferencesEntry.SHOWADVANCEDSETTINGS.setValue(getController(), showAdvancedSettingsBox.isSelected());
public void save() { Preferences pref = getController().getPreferences(); // Write properties into core writeTrigger.triggerCommit(); // Set locale if (languageChooser.getSelectedItem() instanceof Locale) { Locale locale = (Locale) languageChooser.getSelectedItem(); // Check if we need to restart needsRestart |= !Util.equals(locale.getLanguage(), Translation .getActiveLocale().getLanguage()); // Save settings Translation.saveLocalSetting(locale); } else { // Remove setting Translation.saveLocalSetting(null); } // Set folder base String folderbase = (String) localBaseHolder.getValue(); ConfigurationEntry.FOLDER_BASEDIR.setValue(getController(), folderbase); // Store ui theme if (UIManager.getLookAndFeel() instanceof PlasticXPLookAndFeel) { PlasticTheme theme = PlasticXPLookAndFeel.getPlasticTheme(); pref.put("uitheme", theme.getClass().getName()); if (!Util.equals(theme, oldTheme)) { // FIXME: Themechange does not repaint SimpleInternalFrames. // thus restart required needsRestart = true; } } // Nickname if (!StringUtils.isBlank(nickField.getText())) { getController().changeNick(nickField.getText(), false); } // setAdvanced pref.putBoolean(SHOWADVANCEDSETTINGS, showAdvancedSettingsBox.isSelected()); }
showPreviewPanelBox.setSelected(getController().getPreferences().getBoolean(CONFIG_SHOW_PREVIEW_PANEL, false));
showPreviewPanelBox.setSelected(PreferencesEntry.CONFIG_SHOW_PREVIEW_PANEL.getValueBoolean(getController()));
private void initComponents() { String port = ConfigurationEntry.NET_BIND_PORT .getValue(getController()); if (port == null) { port = Integer.toString(ConnectionListener.DEFAULT_PORT); } advPort = new JTextField(port) { protected Document createDefaultModel() { return new NumberAndCommaDocument(); } }; advPort.setToolTipText(Translation .getTranslation("preferences.dialog.advPort.tooltip")); String cfgBind = ConfigurationEntry.NET_BIND_ADDRESS .getValue(getController()); bindAddress = new JComboBox(); bindAddress.addItem(Translation .getTranslation("preferences.dialog.bind.any")); // Fill in all known InetAddresses of this machine try { Enumeration<NetworkInterface> e = NetworkInterface .getNetworkInterfaces(); while (e.hasMoreElements()) { NetworkInterface ni = e.nextElement(); Enumeration<InetAddress> ie = ni.getInetAddresses(); while (ie.hasMoreElements()) { InetAddress addr = ie.nextElement(); bindAddress.addItem(new InterfaceChoice(ni, addr)); if (!StringUtils.isEmpty(cfgBind)) { if (addr.getHostAddress().equals(cfgBind)) { bindAddress.setSelectedIndex(bindAddress .getItemCount() - 1); } } } } } catch (SocketException e1) { log().error(e1); } ifDescr = new JTextArea(3, 20); ifDescr.setLineWrap(true); ifDescr.setWrapStyleWord(true); ifDescr.setEditable(false); ifDescr.setOpaque(false); updateIFDescr(); bindAddress.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent arg0) { if (arg0.getStateChange() == ItemEvent.SELECTED) { updateIFDescr(); } } }); showPreviewPanelBox = SimpleComponentFactory.createCheckBox(Translation .getTranslation("preferences.dialog.showpreviewpanel")); showPreviewPanelBox.setToolTipText(Translation .getTranslation("preferences.dialog.showpreviewpanel.tooltip")); showPreviewPanelBox.setSelected(getController().getPreferences().getBoolean(CONFIG_SHOW_PREVIEW_PANEL, false)); useZipOnLanCheckBox = SimpleComponentFactory.createCheckBox(Translation .getTranslation("preferences.dialog.useziponlan")); useZipOnLanCheckBox.setToolTipText(Translation .getTranslation("preferences.dialog.useziponlan.tooltip")); useZipOnLanCheckBox.setSelected(ConfigurationEntry.USE_ZIP_ON_LAN .getValueBoolean(getController()).booleanValue()); }
boolean current =pref.getBoolean(CONFIG_SHOW_PREVIEW_PANEL, false);
boolean current = PreferencesEntry.CONFIG_SHOW_PREVIEW_PANEL.getValueBoolean(getController());
public void save() { Preferences pref = getController().getPreferences(); // Check for correctly entered port values try { // Check if it's a commaseperated list of parseable numbers String port = advPort.getText(); StringTokenizer st = new StringTokenizer(port, ","); while (st.hasMoreTokens()) { int p = Integer.parseInt(st.nextToken()); if (p < 0 || p > 65535) { throw new NumberFormatException( "Port out of range [0,65535]"); } } // Check if only one port was given which is the default port if (ConfigurationEntry.NET_BIND_PORT.getValue(getController()) == null) { try { int portnum = Integer.parseInt(port); if (portnum != ConnectionListener.DEFAULT_PORT) { needsRestart = true; } } catch (NumberFormatException e) { } } // Only compare with old value if the things above don't match if (!needsRestart) { // Check if the value actually changed if (!port.equals(ConfigurationEntry.NET_BIND_PORT .getValue(getController()))) { needsRestart = true; } } ConfigurationEntry.NET_BIND_PORT.setValue(getController(), port); } catch (NumberFormatException e) { log().warn("Unparsable port number"); } String cfgBind = ConfigurationEntry.NET_BIND_ADDRESS .getValue(getController()); Object bindObj = bindAddress.getSelectedItem(); if (bindObj instanceof String) { // Selected ANY if (!StringUtils.isEmpty(cfgBind)) { ConfigurationEntry.NET_BIND_ADDRESS .removeValue(getController()); needsRestart = true; } } else { InetAddress addr = ((InterfaceChoice) bindObj).getAddress(); if (!addr.getHostAddress().equals(cfgBind)) { ConfigurationEntry.NET_BIND_ADDRESS.setValue(getController(), addr.getHostAddress()); needsRestart = true; } } // image previewer boolean current =pref.getBoolean(CONFIG_SHOW_PREVIEW_PANEL, false); if (current != showPreviewPanelBox.isSelected()) { pref.putBoolean(CONFIG_SHOW_PREVIEW_PANEL, showPreviewPanelBox .isSelected()); needsRestart = true; } // zip on lan? current = ConfigurationEntry.USE_ZIP_ON_LAN.getValueBoolean( getController()).booleanValue(); if (current != useZipOnLanCheckBox.isSelected()) { ConfigurationEntry.USE_ZIP_ON_LAN.setValue(getController(), useZipOnLanCheckBox.isSelected() + ""); } }
pref.putBoolean(CONFIG_SHOW_PREVIEW_PANEL, showPreviewPanelBox .isSelected());
PreferencesEntry.CONFIG_SHOW_PREVIEW_PANEL.setValue(getController(), showPreviewPanelBox.isSelected());
public void save() { Preferences pref = getController().getPreferences(); // Check for correctly entered port values try { // Check if it's a commaseperated list of parseable numbers String port = advPort.getText(); StringTokenizer st = new StringTokenizer(port, ","); while (st.hasMoreTokens()) { int p = Integer.parseInt(st.nextToken()); if (p < 0 || p > 65535) { throw new NumberFormatException( "Port out of range [0,65535]"); } } // Check if only one port was given which is the default port if (ConfigurationEntry.NET_BIND_PORT.getValue(getController()) == null) { try { int portnum = Integer.parseInt(port); if (portnum != ConnectionListener.DEFAULT_PORT) { needsRestart = true; } } catch (NumberFormatException e) { } } // Only compare with old value if the things above don't match if (!needsRestart) { // Check if the value actually changed if (!port.equals(ConfigurationEntry.NET_BIND_PORT .getValue(getController()))) { needsRestart = true; } } ConfigurationEntry.NET_BIND_PORT.setValue(getController(), port); } catch (NumberFormatException e) { log().warn("Unparsable port number"); } String cfgBind = ConfigurationEntry.NET_BIND_ADDRESS .getValue(getController()); Object bindObj = bindAddress.getSelectedItem(); if (bindObj instanceof String) { // Selected ANY if (!StringUtils.isEmpty(cfgBind)) { ConfigurationEntry.NET_BIND_ADDRESS .removeValue(getController()); needsRestart = true; } } else { InetAddress addr = ((InterfaceChoice) bindObj).getAddress(); if (!addr.getHostAddress().equals(cfgBind)) { ConfigurationEntry.NET_BIND_ADDRESS.setValue(getController(), addr.getHostAddress()); needsRestart = true; } } // image previewer boolean current =pref.getBoolean(CONFIG_SHOW_PREVIEW_PANEL, false); if (current != showPreviewPanelBox.isSelected()) { pref.putBoolean(CONFIG_SHOW_PREVIEW_PANEL, showPreviewPanelBox .isSelected()); needsRestart = true; } // zip on lan? current = ConfigurationEntry.USE_ZIP_ON_LAN.getValueBoolean( getController()).booleanValue(); if (current != useZipOnLanCheckBox.isSelected()) { ConfigurationEntry.USE_ZIP_ON_LAN.setValue(getController(), useZipOnLanCheckBox.isSelected() + ""); } }
java.lang.String userId, java.lang.String threadId, java.lang.String parentMessageId, java.lang.String subject, java.lang.String body)
java.lang.String userId, java.lang.String subject, java.lang.String body)
public static com.liferay.portlet.messageboards.model.MBMessage addDiscussionMessage( java.lang.String userId, java.lang.String threadId, java.lang.String parentMessageId, java.lang.String subject, java.lang.String body) throws com.liferay.portal.PortalException, com.liferay.portal.SystemException { try { MBMessageLocalService mbMessageLocalService = MBMessageLocalServiceFactory.getService(); return mbMessageLocalService.addDiscussionMessage(userId, threadId, parentMessageId, subject, body); } catch (com.liferay.portal.PortalException pe) { throw pe; } catch (com.liferay.portal.SystemException se) { throw se; } catch (Exception e) { throw new com.liferay.portal.SystemException(e); } }
return mbMessageLocalService.addDiscussionMessage(userId, threadId, parentMessageId, subject, body);
return mbMessageLocalService.addDiscussionMessage(userId, subject, body);
public static com.liferay.portlet.messageboards.model.MBMessage addDiscussionMessage( java.lang.String userId, java.lang.String threadId, java.lang.String parentMessageId, java.lang.String subject, java.lang.String body) throws com.liferay.portal.PortalException, com.liferay.portal.SystemException { try { MBMessageLocalService mbMessageLocalService = MBMessageLocalServiceFactory.getService(); return mbMessageLocalService.addDiscussionMessage(userId, threadId, parentMessageId, subject, body); } catch (com.liferay.portal.PortalException pe) { throw pe; } catch (com.liferay.portal.SystemException se) { throw se; } catch (Exception e) { throw new com.liferay.portal.SystemException(e); } }
if (fInfo == null) { throw new NullPointerException("File is null"); } Member[] nodes = getController().getNodeManager().getNodes(); List sources = new ArrayList(nodes.length); for (int i = 0; i < nodes.length; i++) { Member node = nodes[i];
Reject.ifNull(fInfo, "File is null"); List<Member> nodes = getController().getNodeManager() .getNodeWithFileListFrom(fInfo.getFolderInfo()); List<Member> sources = new ArrayList<Member>(nodes.size()); for (Member node : nodes) {
public Member[] getSourcesFor(FileInfo fInfo) { if (fInfo == null) { throw new NullPointerException("File is null"); } Member[] nodes = getController().getNodeManager().getNodes(); List sources = new ArrayList(nodes.length); for (int i = 0; i < nodes.length; i++) { Member node = nodes[i]; if (node.isCompleteyConnected() && node.hasFile(fInfo)) { // node is connected and has file sources.add(node); } } /* * log().verbose( "Got these sources for dl " + fInfo + " (" + * sources.size() + "): " + sources); */ Collections.shuffle(sources); Member[] srces = new Member[sources.size()]; sources.toArray(srces); // Sort by the best upload availibility Arrays.sort(srces, new ReverseComparator( MemberComparator.BY_UPLOAD_AVAILIBILITY)); return srces; }
quoteFeed = plugin.getQuoteFeed();
plugin.registerStockOrderTicket(this);
public void createPartControl(Composite parent) { GridData gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; gridData.verticalAlignment = GridData.END; top = new Composite(parent, SWT.NONE); GridLayout gridLayout = new GridLayout(); gridLayout.marginWidth = 0; gridLayout.marginHeight = 0; top.setLayout(gridLayout); createForm(); errorMessageLabel = getFormToolkit().createLabel(top, ""); errorMessageLabel.setLayoutData(gridData); top.setBackground(errorMessageLabel.getBackground()); PhotonPlugin plugin = PhotonPlugin.getDefault(); plugin.getPreferenceStore().addPropertyChangeListener(this); quoteFeed = plugin.getQuoteFeed(); }
quoteFeed = null;
PhotonPlugin plugin = PhotonPlugin.getDefault(); plugin.unregisterStockOrderTicket(this);
public void dispose() { PhotonPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this); unlisten(); if (quoteFeed != null) { quoteFeed.unlistenLevel2(listenedSymbol); } quoteFeed = null; }
} else { log().debug("Don't know how to handle: " + selection.getClass());
} else { throw new IllegalStateException("Don't know how to handle: " + selection.getClass());
public void update() { Object[] selections = getSelectionModel().getSelections(); Object displayTarget = getUIController().getInformationQuarter() .getDisplayTarget(); Folder folder; if (displayTarget instanceof Directory) { folder = ((Directory) displayTarget).getRootFolder(); } else if (displayTarget instanceof Folder) { folder = (Folder) displayTarget; } else { return; } if (selections != null && selections.length != 0) { setEnabled(false); Blacklist blacklist = folder.getBlacklist(); for (Object selection : selections) { if (selection instanceof FileInfo) { if (!blacklist.isIgnored((FileInfo) selection)) { // found one that was not ignored // enable this action setEnabled(true); } } else if (selection instanceof Directory) { Directory dir = (Directory) selection; if (!blacklist.areIgnored(dir.getFiles())) { // found a dir that was not ignored // enable this action setEnabled(true); } } else { log().debug("Don't know how to handle: " + selection.getClass()); //throw new IllegalStateException(selection); } } } }
throw new IllegalStateException();
throw new IllegalStateException("Don't know how to handle: " + selection.getClass());
public void update() { Object[] selections = getSelectionModel().getSelections(); Object displayTarget = getUIController().getInformationQuarter() .getDisplayTarget(); Folder folder; if (displayTarget instanceof Directory) { folder = ((Directory) displayTarget).getRootFolder(); } else if (displayTarget instanceof Folder) { folder = (Folder) displayTarget; } else { return; } if (selections != null && selections.length != 0) { setEnabled(false); Blacklist blacklist = folder.getBlacklist(); for (Object selection : selections) { if (selection instanceof FileInfo) { if (blacklist.isExplicitIgnored((FileInfo) selection)) { // found that was ignored // enable this action setEnabled(true); } } else if (selection instanceof Directory) { Directory dir = (Directory) selection; if (blacklist.areExplicitIgnored(dir.getFiles())) { // found a dir that was ignored // enable this action setEnabled(true); } } else { throw new IllegalStateException(); } } } }
Member[] nodes = getController().getNodeManager().getNodes();
List<Member> conNodes = getController().getNodeManager() .getConnectedNodes();
public void actionPerformed(ActionEvent e) { Member[] nodes = getController().getNodeManager().getNodes(); List canidates = new ArrayList(); for (int i = 0; i < nodes.length; i++) { if (nodes[i].isCompleteyConnected()) { canidates.add(new MemberWrapper(nodes[i])); } } Object none = Translation.getTranslation("masternode.nobody"); canidates.add(0, none); Member masterNode = getController().getNodeManager().getMasterNode(); Object result = JOptionPane.showInputDialog(getUIController() .getMainFrame().getUIComponent(), Translation .getTranslation("setmasternode.dialog.text"), Translation .getTranslation("setmasternode.dialog.title"), JOptionPane.QUESTION_MESSAGE, (Icon) getValue(Action.SMALL_ICON), canidates.toArray(), masterNode != null ? new MemberWrapper( masterNode) : none); if (result != null) { // Not canceled if (result == none) { // No master ConfigurationEntry.MASTER_NODE_ID.removeValue(getController()); } else { MemberWrapper choosenMaster = (MemberWrapper) result; ConfigurationEntry.MASTER_NODE_ID.setValue(getController(), choosenMaster.member.getId()); // Request his nodelist, to get in sync choosenMaster.member.sendMessageAsynchron(RequestNodeList .createRequestAllNodes(), null); } getController().saveConfig(); } }
for (int i = 0; i < nodes.length; i++) { if (nodes[i].isCompleteyConnected()) { canidates.add(new MemberWrapper(nodes[i]));
for (Member node : conNodes) { if (node.isCompleteyConnected()) { canidates.add(new MemberWrapper(node));
public void actionPerformed(ActionEvent e) { Member[] nodes = getController().getNodeManager().getNodes(); List canidates = new ArrayList(); for (int i = 0; i < nodes.length; i++) { if (nodes[i].isCompleteyConnected()) { canidates.add(new MemberWrapper(nodes[i])); } } Object none = Translation.getTranslation("masternode.nobody"); canidates.add(0, none); Member masterNode = getController().getNodeManager().getMasterNode(); Object result = JOptionPane.showInputDialog(getUIController() .getMainFrame().getUIComponent(), Translation .getTranslation("setmasternode.dialog.text"), Translation .getTranslation("setmasternode.dialog.title"), JOptionPane.QUESTION_MESSAGE, (Icon) getValue(Action.SMALL_ICON), canidates.toArray(), masterNode != null ? new MemberWrapper( masterNode) : none); if (result != null) { // Not canceled if (result == none) { // No master ConfigurationEntry.MASTER_NODE_ID.removeValue(getController()); } else { MemberWrapper choosenMaster = (MemberWrapper) result; ConfigurationEntry.MASTER_NODE_ID.setValue(getController(), choosenMaster.member.getId()); // Request his nodelist, to get in sync choosenMaster.member.sendMessageAsynchron(RequestNodeList .createRequestAllNodes(), null); } getController().saveConfig(); } }
new BigDecimal("12.3"), new BigDecimal(100), new BigDecimal(100), new BigDecimal("12.3"), OrderManagerTest.SYMBOL);
new BigDecimal("12.3"), new BigDecimal(100), new BigDecimal(100), new BigDecimal("12.3"), OrderManagerTest.SYMBOL, null);
public void testMessageAdapter() { PhotonAdapterFactory fact = new PhotonAdapterFactory(); Message aMessage = FIXMessageUtil.newExecutionReport(new InternalID("456"), OrderManagerTest.CL_ORD_ID, "987", ExecTransType.STATUS, ExecType.PARTIAL_FILL, OrdStatus.PARTIALLY_FILLED, Side.BUY, new BigDecimal(1000), new BigDecimal("12.3"), new BigDecimal(100), new BigDecimal("12.3"), new BigDecimal(100), new BigDecimal(100), new BigDecimal("12.3"), OrderManagerTest.SYMBOL); aMessage.setUtcTimeStamp(TransactTime.FIELD, OrderManagerTest.THE_TRANSACT_TIME); IncomingMessageHolder holder = new IncomingMessageHolder(aMessage); IWorkbenchAdapter adapter = (IWorkbenchAdapter)fact.getAdapter(holder, IWorkbenchAdapter.class); String label = adapter.getLabel(holder); assertEquals("Message", label); assertNull(adapter.getParent(holder)); assertEquals(0, adapter.getChildren(holder).length); }
if (pref.getBoolean(AdvancedSettingsTab.CONFIG_SHOW_PREVIEW_PANEL, false))
if (PreferencesEntry.CONFIG_SHOW_PREVIEW_PANEL.getValueBoolean(getController()))
private JComponent createFileDetailsPanel() { FileDetailsPanel fileDetailsPanel = new FileDetailsPanel( getController(), selectionModel); Preferences pref = getController().getPreferences(); // check property to enable preview // preview of images is memory hungry // may cause OutOfMemoryErrors if (pref.getBoolean(AdvancedSettingsTab.CONFIG_SHOW_PREVIEW_PANEL, false)) { PreviewPanel previewPanel = new PreviewPanel(getController(), selectionModel, this); FormLayout layout = new FormLayout("pref, fill:pref:grow", "3dlu, pref, fill:pref, pref"); PanelBuilder builder = new PanelBuilder(layout); CellConstraints cc = new CellConstraints(); builder.addSeparator(null, cc.xy(1, 2)); builder.add(fileDetailsPanel.getEmbeddedPanel(), cc.xy(1, 3)); builder.add(previewPanel.getUIComponent(), cc.xy(2, 3)); builder.addSeparator(null, cc.xy(1, 4)); return builder.getPanel(); } FormLayout layout = new FormLayout("fill:pref:grow", "3dlu, pref, fill:pref, pref"); PanelBuilder builder = new PanelBuilder(layout); CellConstraints cc = new CellConstraints(); builder.addSeparator(null, cc.xy(1, 2)); builder.add(fileDetailsPanel.getEmbeddedPanel(), cc.xy(1, 3)); builder.addSeparator(null, cc.xy(1, 4)); return builder.getPanel(); }
FIXDataDictionaryManager.setFIXVersion(FIXDataDictionaryManager.FIX_4_2_BEGIN_STRING); MessageBundleManager.registerCoreMessageBundle();
initResources();
public Object run(Object args) throws Exception { FIXDataDictionaryManager.setFIXVersion(FIXDataDictionaryManager.FIX_4_2_BEGIN_STRING); MessageBundleManager.registerCoreMessageBundle(); fixMessageHistory = new FIXMessageHistory(); jmsConnector = new JMSConnector(); orderManager = new OrderManager(idFactory, fixMessageHistory); setUpQuoteFeed(); Display display = PlatformUI.createDisplay(); try { int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor()); if (returnCode == PlatformUI.RETURN_RESTART) { return IPlatformRunnable.EXIT_RESTART; } return IPlatformRunnable.EXIT_OK; } finally { display.dispose(); } }
System.err.println("Setting tooltip to '" + tooltip + "'");
public void run() { String tooltip = Translation.getTranslation("general.powerfolder"); tooltip += " "; if (getController().getFolderRepository().isAnyFolderSyncing()) { tooltip += Translation .getTranslation("systray.tooltip.syncing"); } else { tooltip += Translation.getTranslation("systray.tooltip.insync"); } double totalCPSdownKB = getController().getTransferManager() .getTotalDownloadTrafficCounter().calculateAverageCPS() / 1024; double totalCPSupKB = getController().getTransferManager() .getTotalUploadTrafficCounter().calculateAverageCPS() / 1024; String downText = null; String upText = null; if (totalCPSdownKB > 1024) { downText = Translation.getTranslation( "systray.tooltip.down.mb", Format.NUMBER_FORMATS .format(totalCPSdownKB / 1024)); } else { downText = Translation.getTranslation("systray.tooltip.down", Format.NUMBER_FORMATS.format(totalCPSdownKB)); } if (totalCPSupKB > 1024) { upText = Translation.getTranslation("systray.tooltip.up.mb", Format.NUMBER_FORMATS.format(totalCPSupKB / 1024)); } else { upText = Translation.getTranslation("systray.tooltip.up", Format.NUMBER_FORMATS.format(totalCPSupKB)); } tooltip += " " + upText + " " + downText; System.err.println("Setting tooltip to '" + tooltip + "'"); sysTrayMenu.setToolTip(tooltip); }
putValue(SUPPORTED, OSUtil.isWindowsSystem());
public CreateShortcutAction(Controller controller) { super("createshortcut", controller); }
if (g == null ) { return; }
public void setCompletionPercentage(int absPerc) { if (startTime == null) { // Started startTime = new Date(); } if (absPerc >= 100) { long startTook = System.currentTimeMillis() - startTime.getTime(); // completed controller.getPreferences().putLong("lastStartTookMS", startTook); } // Not longer guessed nPercentageGuessed = 0; bar.setValue(absPerc); // draw version number only once (cannot do in init, no yet Graphics // there) Graphics g = image.getGraphics(); g.setColor(Color.RED); String version = Translation.getTranslation("splash.version", Controller.PROGRAM_VERSION); g.drawString(version, 500, 180); }
public void testNetworkAddresses() {
public void testNetworkAddresses() throws UnknownHostException {
public void testNetworkAddresses() { NetworkHelper nu = NetworkHelper.getInstance(); assertNotNull(nu); // TODO: Cheap, needs change assertEquals(nu.getInterfaceAddresses().size(), nu.getNetworkAddresses().size()); }
assertFalse(NetworkUtil.isOnAnySubnet( (Inet4Address) InetAddress.getByName("217.23.244.121"))); NetworkAddress nw = nu.getNetworkAddresses().iterator().next(); assertTrue(NetworkUtil.isOnAnySubnet(nw.getAddress()));
public void testNetworkAddresses() { NetworkHelper nu = NetworkHelper.getInstance(); assertNotNull(nu); // TODO: Cheap, needs change assertEquals(nu.getInterfaceAddresses().size(), nu.getNetworkAddresses().size()); }
getConfigCPS(ConfigurationEntry.UPLOADLIMIT_WAN); getConfigCPS(ConfigurationEntry.DOWNLOADLIMIT_WAN); getConfigCPS(ConfigurationEntry.UPLOADLIMIT_LAN); getConfigCPS(ConfigurationEntry.DOWNLOADLIMIT_LAN);
public TransferManager(Controller controller) { super(controller); this.started = false; this.queuedUploads = Collections .synchronizedList(new LinkedList<Upload>()); this.activeUploads = Collections .synchronizedList(new LinkedList<Upload>()); this.downloads = new ConcurrentHashMap<FileInfo, Download>(); this.pendingDownloads = Collections .synchronizedList(new LinkedList<Download>()); this.completedDownloads = Collections .synchronizedList(new LinkedList<Download>()); this.uploadCounter = new TransferCounter(); this.downloadCounter = new TransferCounter(); // Create listener support this.listenerSupport = (TransferManagerListener) ListenerSupportFactory .createListenerSupport(TransferManagerListener.class); // maximum concurrent uploads allowedUploads = ConfigurationEntry.UPLOADS_MAX_CONCURRENT.getValueInt( getController()).intValue(); if (allowedUploads <= 0) { throw new NumberFormatException("Illegal value for max uploads: " + allowedUploads); } bandwidthProvider = new BandwidthProvider(); sharedWANOutputHandler = new BandwidthLimiter(); sharedWANInputHandler = new BandwidthLimiter(); // bandwidthProvider.setLimitBPS(sharedWANOutputHandler, maxCps); // set ul limit setAllowedUploadCPSForWAN(getConfigCPS(ConfigurationEntry.UPLOADLIMIT_WAN)); setAllowedDownloadCPSForWAN(getConfigCPS(ConfigurationEntry.DOWNLOADLIMIT_WAN)); sharedLANOutputHandler = new BandwidthLimiter(); sharedLANInputHandler = new BandwidthLimiter();// bandwidthProvider.setLimitBPS(sharedLANOutputHandler, maxCps); // set ul limit setAllowedUploadCPSForLAN(getConfigCPS(ConfigurationEntry.UPLOADLIMIT_LAN)); setAllowedDownloadCPSForLAN(getConfigCPS(ConfigurationEntry.DOWNLOADLIMIT_LAN)); }
entry.setValue(getController(), Long.toString(maxCps));
private long getConfigCPS(ConfigurationEntry entry) { String cps = entry.getValue(getController()); long maxCps = 0; if (cps != null) { try { maxCps = (long) Double.parseDouble(cps) * 1024; if (maxCps < 0) { throw new NumberFormatException(); } } catch (NumberFormatException e) { log().warn( "Illegal value for KByte." + entry + " '" + cps + "'"); } } return maxCps; }
if (isOnLAN()) getController().getNodeManager().addChatMember(member);
public void setMember(Member member) { this.member = member; }
if (onlan) getController().getNodeManager().addChatMember(member); else getController().getNodeManager().removeChatMember(member);
public void setOnLAN(boolean onlan) { onLAN = onlan; if (onlan) getController().getNodeManager().addChatMember(member); else getController().getNodeManager().removeChatMember(member); synchronized (out) { out.setBandwidthLimiter(getController().getTransferManager() .getOutputLimiter(this)); //System.err.println("LAN:" + out.getBandwidthLimiter()); } // TODO: BYTEKEEPR: from tot: I removed the synchronized block, since // this kills connection process under some cirumstances // TODO: TOT: from Bytekeeper: This circumstances most likly mean that // setOnLAN is called from different threads within a short amount of time. //synchronized (in) { in.setBandwidthLimiter(getController().getTransferManager() .getInputLimiter(this)); //} }
return history.getLatestExecutionReports();
return history.getHistory();
public Object[] getChildren(Object element) { if (element instanceof FIXMessageHistory) { FIXMessageHistory history = (FIXMessageHistory) element; return history.getLatestExecutionReports(); } return new Object[0]; }
log().warn("Setting connection factory: " + conHanFactory);
log().verbose("Setting new connection factory: " + conHanFactory);
public synchronized void setConnectionHandlerFactory( ConnectionHandlerFactory conHanFactory) { Reject.ifNull(conHanFactory, "The factory must not be null"); log().warn("Setting connection factory: " + conHanFactory); this.conHanFactory = conHanFactory; }
return bartModel.getRowCount() > 0;
return getContollerBart().getTransferManager() .getActiveUploads().length == 1;
public void testAbortUpload() { // Create a 10 megs file TestHelper.createRandomFile(folderBart.getLocalBase(), 10000000); folderBart.scanLocalFiles(true); TestHelper.waitForCondition(2, new TestHelper.Condition() { public boolean reached() { return bartModel.getRowCount() > 0; } }); TestHelper.waitMilliSeconds(200); // Abort Download download = getContollerLisa().getTransferManager() .getActiveDownloads()[0]; download.abort(); TestHelper.waitForCondition(10, new TestHelper.Condition() { public boolean reached() { return bartModel.getRowCount() == 0; } }); // no active upload assertEquals(0, bartModel.getRowCount()); // Check correct events from model assertEquals(3, bartModelListener.events.size()); assertTrue(bartModelListener.events.get(0).getType() == TableModelEvent.INSERT); assertTrue(bartModelListener.events.get(1).getType() == TableModelEvent.UPDATE); assertTrue(bartModelListener.events.get(2).getType() == TableModelEvent.DELETE); TestHelper.waitMilliSeconds(500); }
return bartModel.getRowCount() > 0;
return getContollerBart().getTransferManager() .getActiveUploads().length == 1;
public boolean reached() { return bartModel.getRowCount() > 0; }
return bartModel.getRowCount() > 0;
return getContollerBart().getTransferManager() .getActiveUploads().length >= 1;
public boolean reached() { return bartModel.getRowCount() > 0; }
return bartModel.getRowCount() == 0;
return getContollerBart().getTransferManager() .getActiveUploads().length == 0 && getContollerBart().getTransferManager() .getQueuedUploads().length == 0;
public boolean reached() { return bartModel.getRowCount() == 0; }
TestHelper.waitMilliSeconds(5000);
TestHelper.waitMilliSeconds(1500);
public void testSingleFileUpload() { TestHelper.createRandomFile(folderBart.getLocalBase()); folderBart.scanLocalFiles(true); // Copy TestHelper.waitMilliSeconds(5000); // No upload in tablemodel assertEquals(0, bartModel.getRowCount()); // Check correct events from model assertEquals(3, bartModelListener.events.size()); assertTrue(bartModelListener.events.get(0).getType() == TableModelEvent.INSERT); assertTrue(bartModelListener.events.get(1).getType() == TableModelEvent.UPDATE); assertTrue(bartModelListener.events.get(2).getType() == TableModelEvent.DELETE); }
FileFilterChangeListener listener = (FileFilterChangeListener) listeners .get(i);
FileFilterChangeListener listener = listeners.get(i);
private void fireFileCountChanged() { synchronized (this) { if (filteredFilelist != null) { FilterChangedEvent event = new FilterChangedEvent(this, filteredFilelist); for (int i = 0; i < listeners.size(); i++) { FileFilterChangeListener listener = (FileFilterChangeListener) listeners .get(i); listener.countChanged(event); } } } }
FileFilterChangeListener listener = (FileFilterChangeListener) listeners .get(i);
FileFilterChangeListener listener = listeners.get(i);
private void fireFileFilterChanged() { synchronized (this) { if (filteredFilelist != null) { FilterChangedEvent event = new FilterChangedEvent(this, filteredFilelist); for (int i = 0; i < listeners.size(); i++) { FileFilterChangeListener listener = (FileFilterChangeListener) listeners .get(i); listener.filterChanged(event); } } } }
Reconnector reconnector = reconnectors.remove(0);
private void resizeReconnectorPool() { synchronized (reconnectors) { int nReconnector = reconnectors.size(); // Calculate required reconnectors int reqReconnectors = Math.min( Constants.MAX_NUMBER_RECONNECTORS, reconnectionQueue.size() / 5); int reconDiffer = reqReconnectors - nReconnector; if (logVerbose) { log().verbose( "Got " + reconnectionQueue.size() + " nodes queued for reconnection"); } // TODO: Remove reconnectors if not longer needed if (reconDiffer > 0) { // We have to less reconnectors, spawning one... for (int i = 0; i < reconDiffer; i++) { Reconnector reconnector = new Reconnector(); // add reconnector to nodemanager reconnectors.add(reconnector); // and start reconnector.start(); } log().debug( "Spawned " + reconDiffer + " reconnectors. " + reconnectors.size() + "/" + reqReconnectors + ", nodes in reconnection queue: " + reconnectionQueue.size()); } else if (reconDiffer < 0) { for (int i = 0; i < -reconDiffer; i++) { // Kill one reconnector Reconnector reconnector = reconnectors.remove(0); if (reconnectors.size() <= 1) { log().warn("Not killing last reconnector"); // Have at least one reconnector break; } if (reconnector != null) { log().debug("Killing reconnector " + reconnector); reconnector.shutdown(); } } } } }
Reconnector reconnector = reconnectors.remove(0);
private void resizeReconnectorPool() { synchronized (reconnectors) { int nReconnector = reconnectors.size(); // Calculate required reconnectors int reqReconnectors = Math.min( Constants.MAX_NUMBER_RECONNECTORS, reconnectionQueue.size() / 5); int reconDiffer = reqReconnectors - nReconnector; if (logVerbose) { log().verbose( "Got " + reconnectionQueue.size() + " nodes queued for reconnection"); } // TODO: Remove reconnectors if not longer needed if (reconDiffer > 0) { // We have to less reconnectors, spawning one... for (int i = 0; i < reconDiffer; i++) { Reconnector reconnector = new Reconnector(); // add reconnector to nodemanager reconnectors.add(reconnector); // and start reconnector.start(); } log().debug( "Spawned " + reconDiffer + " reconnectors. " + reconnectors.size() + "/" + reqReconnectors + ", nodes in reconnection queue: " + reconnectionQueue.size()); } else if (reconDiffer < 0) { for (int i = 0; i < -reconDiffer; i++) { // Kill one reconnector Reconnector reconnector = reconnectors.remove(0); if (reconnectors.size() <= 1) { log().warn("Not killing last reconnector"); // Have at least one reconnector break; } if (reconnector != null) { log().debug("Killing reconnector " + reconnector); reconnector.shutdown(); } } } } }
LoggerAdapter.initializeLogger("test");
public static Test suite() { LoggerAdapter.initializeLogger("test");/* TestSuite suite = new TestSuite(); suite.addTest(new OrderLoaderTest("testEndToEndCustom")); suite.addTest(new OrderLoaderTest("testWithCustomField")); return suite;*/ return new MarketceteraTestSuite(OrderLoaderTest.class, OrderLoader.OL_MESSAGE_BUNDLE_INFO); }
LoggerAdapter.debug("Returning latest execution report id:"+holder.getMessageReference(), this);
public Message getLatestExecutionReport(String clOrdID) { for (MessageHolder holder : latestExecutionReportsList) { Message executionReport = holder.getMessage(); try { String possMatch = executionReport.getString(ClOrdID.FIELD); if (possMatch.equals(clOrdID)){ LoggerAdapter.debug("Returning latest execution report id:"+holder.getMessageReference(), this); return executionReport; } } catch (FieldNotFound fnf) { // do nothing } } return null; }
Lexer lexer = new Lexer(); lexer.setInput("ASDF asd 123,4 123.4 123;4 abc;d abc.d 1 1.1.1\t .01\te1.0\t123.b");
CommandParser parser = new CommandParser(); Tok[] parsedTokens = parser.lex("ASDF asd 123.4 123;4 abc;d abc.d 1 1.1.1 .01 e1.0 123.b");
public void testLexer(){ Lexer lexer = new Lexer(); lexer.setInput("ASDF asd 123,4 123.4 123;4 abc;d abc.d 1 1.1.1\t .01\te1.0\t123.b"); Token aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("ASDF", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("asd", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123,4", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals("123.4", aToken.getImage()); assertEquals(123.4, ((FloatToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123;4", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("abc;d", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("abc.d", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(IntToken.class, aToken.getClass()); assertEquals("1", aToken.getImage()); assertEquals(1, ((IntToken)aToken).intValue()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("1.1.1", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals(".01", aToken.getImage()); assertEquals(.01, ((FloatToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("e1.0", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123.b", aToken.getImage()); }
Token aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("ASDF", aToken.getImage());
int i = 0; Tok aToken = parsedTokens[i++]; assertEquals(TokenType.Word, ((TypedToken)aToken.getToken()).getType()); assertEquals("ASDF", ((TypedToken)aToken.getToken()).getText());
public void testLexer(){ Lexer lexer = new Lexer(); lexer.setInput("ASDF asd 123,4 123.4 123;4 abc;d abc.d 1 1.1.1\t .01\te1.0\t123.b"); Token aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("ASDF", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("asd", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123,4", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals("123.4", aToken.getImage()); assertEquals(123.4, ((FloatToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123;4", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("abc;d", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("abc.d", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(IntToken.class, aToken.getClass()); assertEquals("1", aToken.getImage()); assertEquals(1, ((IntToken)aToken).intValue()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("1.1.1", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals(".01", aToken.getImage()); assertEquals(.01, ((FloatToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("e1.0", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123.b", aToken.getImage()); }
aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("asd", aToken.getImage());
aToken = parsedTokens[i++]; assertEquals(TokenType.Word, ((TypedToken)aToken.getToken()).getType()); assertEquals("asd", ((TypedToken)aToken.getToken()).getText());
public void testLexer(){ Lexer lexer = new Lexer(); lexer.setInput("ASDF asd 123,4 123.4 123;4 abc;d abc.d 1 1.1.1\t .01\te1.0\t123.b"); Token aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("ASDF", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("asd", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123,4", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals("123.4", aToken.getImage()); assertEquals(123.4, ((FloatToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123;4", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("abc;d", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("abc.d", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(IntToken.class, aToken.getClass()); assertEquals("1", aToken.getImage()); assertEquals(1, ((IntToken)aToken).intValue()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("1.1.1", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals(".01", aToken.getImage()); assertEquals(.01, ((FloatToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("e1.0", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123.b", aToken.getImage()); }
aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123,4", aToken.getImage());
aToken = parsedTokens[i++]; assertEquals(TokenType.Decimal, ((TypedToken)aToken.getToken()).getType()); assertEquals("123.4", ((TypedToken)aToken.getToken()).getText());
public void testLexer(){ Lexer lexer = new Lexer(); lexer.setInput("ASDF asd 123,4 123.4 123;4 abc;d abc.d 1 1.1.1\t .01\te1.0\t123.b"); Token aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("ASDF", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("asd", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123,4", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals("123.4", aToken.getImage()); assertEquals(123.4, ((FloatToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123;4", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("abc;d", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("abc.d", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(IntToken.class, aToken.getClass()); assertEquals("1", aToken.getImage()); assertEquals(1, ((IntToken)aToken).intValue()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("1.1.1", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals(".01", aToken.getImage()); assertEquals(.01, ((FloatToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("e1.0", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123.b", aToken.getImage()); }
aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals("123.4", aToken.getImage()); assertEquals(123.4, ((FloatToken)aToken).doubleValue(), .001);
aToken = parsedTokens[i++]; assertEquals(TokenType.Word, ((TypedToken)aToken.getToken()).getType()); assertEquals("123;4", ((TypedToken)aToken.getToken()).getText());
public void testLexer(){ Lexer lexer = new Lexer(); lexer.setInput("ASDF asd 123,4 123.4 123;4 abc;d abc.d 1 1.1.1\t .01\te1.0\t123.b"); Token aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("ASDF", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("asd", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123,4", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals("123.4", aToken.getImage()); assertEquals(123.4, ((FloatToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123;4", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("abc;d", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("abc.d", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(IntToken.class, aToken.getClass()); assertEquals("1", aToken.getImage()); assertEquals(1, ((IntToken)aToken).intValue()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("1.1.1", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals(".01", aToken.getImage()); assertEquals(.01, ((FloatToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("e1.0", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123.b", aToken.getImage()); }
aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123;4", aToken.getImage());
aToken = parsedTokens[i++]; assertEquals(TokenType.Word, ((TypedToken)aToken.getToken()).getType()); assertEquals("abc;d", ((TypedToken)aToken.getToken()).getText());
public void testLexer(){ Lexer lexer = new Lexer(); lexer.setInput("ASDF asd 123,4 123.4 123;4 abc;d abc.d 1 1.1.1\t .01\te1.0\t123.b"); Token aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("ASDF", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("asd", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123,4", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals("123.4", aToken.getImage()); assertEquals(123.4, ((FloatToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123;4", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("abc;d", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("abc.d", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(IntToken.class, aToken.getClass()); assertEquals("1", aToken.getImage()); assertEquals(1, ((IntToken)aToken).intValue()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("1.1.1", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals(".01", aToken.getImage()); assertEquals(.01, ((FloatToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("e1.0", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123.b", aToken.getImage()); }
aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("abc;d", aToken.getImage());
aToken = parsedTokens[i++]; assertEquals(TokenType.Word, ((TypedToken)aToken.getToken()).getType()); assertEquals("abc.d", ((TypedToken)aToken.getToken()).getText());
public void testLexer(){ Lexer lexer = new Lexer(); lexer.setInput("ASDF asd 123,4 123.4 123;4 abc;d abc.d 1 1.1.1\t .01\te1.0\t123.b"); Token aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("ASDF", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("asd", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123,4", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals("123.4", aToken.getImage()); assertEquals(123.4, ((FloatToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123;4", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("abc;d", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("abc.d", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(IntToken.class, aToken.getClass()); assertEquals("1", aToken.getImage()); assertEquals(1, ((IntToken)aToken).intValue()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("1.1.1", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals(".01", aToken.getImage()); assertEquals(.01, ((FloatToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("e1.0", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123.b", aToken.getImage()); }
aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("abc.d", aToken.getImage());
aToken = parsedTokens[i++]; assertEquals(TokenType.Integer, ((TypedToken)aToken.getToken()).getType()); assertEquals("1", ((TypedToken)aToken.getToken()).getText());
public void testLexer(){ Lexer lexer = new Lexer(); lexer.setInput("ASDF asd 123,4 123.4 123;4 abc;d abc.d 1 1.1.1\t .01\te1.0\t123.b"); Token aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("ASDF", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("asd", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123,4", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals("123.4", aToken.getImage()); assertEquals(123.4, ((FloatToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123;4", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("abc;d", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("abc.d", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(IntToken.class, aToken.getClass()); assertEquals("1", aToken.getImage()); assertEquals(1, ((IntToken)aToken).intValue()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("1.1.1", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals(".01", aToken.getImage()); assertEquals(.01, ((FloatToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("e1.0", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123.b", aToken.getImage()); }
aToken = lexer.getNextToken(); assertEquals(IntToken.class, aToken.getClass()); assertEquals("1", aToken.getImage()); assertEquals(1, ((IntToken)aToken).intValue());
aToken = parsedTokens[i++]; assertEquals(TokenType.Word, ((TypedToken)aToken.getToken()).getType()); assertEquals("1.1.1", ((TypedToken)aToken.getToken()).getText());
public void testLexer(){ Lexer lexer = new Lexer(); lexer.setInput("ASDF asd 123,4 123.4 123;4 abc;d abc.d 1 1.1.1\t .01\te1.0\t123.b"); Token aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("ASDF", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("asd", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123,4", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals("123.4", aToken.getImage()); assertEquals(123.4, ((FloatToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123;4", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("abc;d", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("abc.d", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(IntToken.class, aToken.getClass()); assertEquals("1", aToken.getImage()); assertEquals(1, ((IntToken)aToken).intValue()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("1.1.1", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals(".01", aToken.getImage()); assertEquals(.01, ((FloatToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("e1.0", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123.b", aToken.getImage()); }
aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("1.1.1", aToken.getImage());
aToken = parsedTokens[i++]; assertEquals(TokenType.Decimal, ((TypedToken)aToken.getToken()).getType()); assertEquals(".01", ((TypedToken)aToken.getToken()).getText());
public void testLexer(){ Lexer lexer = new Lexer(); lexer.setInput("ASDF asd 123,4 123.4 123;4 abc;d abc.d 1 1.1.1\t .01\te1.0\t123.b"); Token aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("ASDF", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("asd", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123,4", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals("123.4", aToken.getImage()); assertEquals(123.4, ((FloatToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123;4", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("abc;d", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("abc.d", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(IntToken.class, aToken.getClass()); assertEquals("1", aToken.getImage()); assertEquals(1, ((IntToken)aToken).intValue()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("1.1.1", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals(".01", aToken.getImage()); assertEquals(.01, ((FloatToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("e1.0", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123.b", aToken.getImage()); }
aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals(".01", aToken.getImage()); assertEquals(.01, ((FloatToken)aToken).doubleValue(), .001);
aToken = parsedTokens[i++]; assertEquals(TokenType.Word, ((TypedToken)aToken.getToken()).getType()); assertEquals("e1.0", ((TypedToken)aToken.getToken()).getText());
public void testLexer(){ Lexer lexer = new Lexer(); lexer.setInput("ASDF asd 123,4 123.4 123;4 abc;d abc.d 1 1.1.1\t .01\te1.0\t123.b"); Token aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("ASDF", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("asd", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123,4", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals("123.4", aToken.getImage()); assertEquals(123.4, ((FloatToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123;4", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("abc;d", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("abc.d", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(IntToken.class, aToken.getClass()); assertEquals("1", aToken.getImage()); assertEquals(1, ((IntToken)aToken).intValue()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("1.1.1", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals(".01", aToken.getImage()); assertEquals(.01, ((FloatToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("e1.0", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123.b", aToken.getImage()); }
aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("e1.0", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123.b", aToken.getImage());
aToken = parsedTokens[i++]; assertEquals(TokenType.Word, ((TypedToken)aToken.getToken()).getType()); assertEquals("123.b", ((TypedToken)aToken.getToken()).getText());
public void testLexer(){ Lexer lexer = new Lexer(); lexer.setInput("ASDF asd 123,4 123.4 123;4 abc;d abc.d 1 1.1.1\t .01\te1.0\t123.b"); Token aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("ASDF", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("asd", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123,4", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals("123.4", aToken.getImage()); assertEquals(123.4, ((FloatToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123;4", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("abc;d", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("abc.d", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(IntToken.class, aToken.getClass()); assertEquals("1", aToken.getImage()); assertEquals(1, ((IntToken)aToken).intValue()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("1.1.1", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals(".01", aToken.getImage()); assertEquals(.01, ((FloatToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("e1.0", aToken.getImage()); aToken = lexer.getNextToken(); assertEquals(StringToken.class, aToken.getClass()); assertEquals("123.b", aToken.getImage()); }
Lexer lexer = new Lexer(); lexer.setInput("17 18.5 16.4 12.3 19");
CommandParser parser = new CommandParser(); Tok[] parsedTokens = parser.lex("17 18.5 16.4 12.3 19");
public void testTypedTokens() { Lexer lexer = new Lexer(); lexer.setInput("17 18.5 16.4 12.3 19"); Token aToken = lexer.getNextToken(); assertEquals(IntToken.class, aToken.getClass()); assertEquals("17", aToken.getImage()); assertEquals(17, ((NumberToken)aToken).intValue()); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals("18.5", aToken.getImage()); assertEquals(18, ((NumberToken)aToken).intValue()); assertEquals(18.5, ((NumberToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals("16.4", aToken.getImage()); assertEquals(16, ((NumberToken)aToken).intValue()); assertEquals(16.4, ((NumberToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals("12.3", aToken.getImage()); assertEquals(12, ((NumberToken)aToken).intValue()); assertEquals(12.3, ((NumberToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(IntToken.class, aToken.getClass()); assertEquals("19", aToken.getImage()); assertEquals(19, ((NumberToken)aToken).intValue()); assertEquals(19, ((NumberToken)aToken).doubleValue(), .001);}
Token aToken = lexer.getNextToken(); assertEquals(IntToken.class, aToken.getClass()); assertEquals("17", aToken.getImage()); assertEquals(17, ((NumberToken)aToken).intValue());
int i = 0; Tok aToken = parsedTokens[i++]; assertEquals(TokenType.Integer, ((TypedToken)aToken.getToken()).getType()); assertEquals("17", ((TypedToken)aToken.getToken()).getText());
public void testTypedTokens() { Lexer lexer = new Lexer(); lexer.setInput("17 18.5 16.4 12.3 19"); Token aToken = lexer.getNextToken(); assertEquals(IntToken.class, aToken.getClass()); assertEquals("17", aToken.getImage()); assertEquals(17, ((NumberToken)aToken).intValue()); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals("18.5", aToken.getImage()); assertEquals(18, ((NumberToken)aToken).intValue()); assertEquals(18.5, ((NumberToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals("16.4", aToken.getImage()); assertEquals(16, ((NumberToken)aToken).intValue()); assertEquals(16.4, ((NumberToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals("12.3", aToken.getImage()); assertEquals(12, ((NumberToken)aToken).intValue()); assertEquals(12.3, ((NumberToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(IntToken.class, aToken.getClass()); assertEquals("19", aToken.getImage()); assertEquals(19, ((NumberToken)aToken).intValue()); assertEquals(19, ((NumberToken)aToken).doubleValue(), .001);}
aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals("18.5", aToken.getImage()); assertEquals(18, ((NumberToken)aToken).intValue()); assertEquals(18.5, ((NumberToken)aToken).doubleValue(), .001);
aToken = parsedTokens[i++]; assertEquals(TokenType.Decimal, ((TypedToken)aToken.getToken()).getType()); assertEquals("18.5", ((TypedToken)aToken.getToken()).getText());
public void testTypedTokens() { Lexer lexer = new Lexer(); lexer.setInput("17 18.5 16.4 12.3 19"); Token aToken = lexer.getNextToken(); assertEquals(IntToken.class, aToken.getClass()); assertEquals("17", aToken.getImage()); assertEquals(17, ((NumberToken)aToken).intValue()); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals("18.5", aToken.getImage()); assertEquals(18, ((NumberToken)aToken).intValue()); assertEquals(18.5, ((NumberToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals("16.4", aToken.getImage()); assertEquals(16, ((NumberToken)aToken).intValue()); assertEquals(16.4, ((NumberToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals("12.3", aToken.getImage()); assertEquals(12, ((NumberToken)aToken).intValue()); assertEquals(12.3, ((NumberToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(IntToken.class, aToken.getClass()); assertEquals("19", aToken.getImage()); assertEquals(19, ((NumberToken)aToken).intValue()); assertEquals(19, ((NumberToken)aToken).doubleValue(), .001);}
aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals("16.4", aToken.getImage()); assertEquals(16, ((NumberToken)aToken).intValue()); assertEquals(16.4, ((NumberToken)aToken).doubleValue(), .001);
aToken = parsedTokens[i++]; assertEquals(TokenType.Decimal, ((TypedToken)aToken.getToken()).getType()); assertEquals("16.4", ((TypedToken)aToken.getToken()).getText());
public void testTypedTokens() { Lexer lexer = new Lexer(); lexer.setInput("17 18.5 16.4 12.3 19"); Token aToken = lexer.getNextToken(); assertEquals(IntToken.class, aToken.getClass()); assertEquals("17", aToken.getImage()); assertEquals(17, ((NumberToken)aToken).intValue()); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals("18.5", aToken.getImage()); assertEquals(18, ((NumberToken)aToken).intValue()); assertEquals(18.5, ((NumberToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals("16.4", aToken.getImage()); assertEquals(16, ((NumberToken)aToken).intValue()); assertEquals(16.4, ((NumberToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals("12.3", aToken.getImage()); assertEquals(12, ((NumberToken)aToken).intValue()); assertEquals(12.3, ((NumberToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(IntToken.class, aToken.getClass()); assertEquals("19", aToken.getImage()); assertEquals(19, ((NumberToken)aToken).intValue()); assertEquals(19, ((NumberToken)aToken).doubleValue(), .001);}
aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals("12.3", aToken.getImage()); assertEquals(12, ((NumberToken)aToken).intValue()); assertEquals(12.3, ((NumberToken)aToken).doubleValue(), .001);
aToken = parsedTokens[i++]; assertEquals(TokenType.Decimal, ((TypedToken)aToken.getToken()).getType()); assertEquals("12.3", ((TypedToken)aToken.getToken()).getText());
public void testTypedTokens() { Lexer lexer = new Lexer(); lexer.setInput("17 18.5 16.4 12.3 19"); Token aToken = lexer.getNextToken(); assertEquals(IntToken.class, aToken.getClass()); assertEquals("17", aToken.getImage()); assertEquals(17, ((NumberToken)aToken).intValue()); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals("18.5", aToken.getImage()); assertEquals(18, ((NumberToken)aToken).intValue()); assertEquals(18.5, ((NumberToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals("16.4", aToken.getImage()); assertEquals(16, ((NumberToken)aToken).intValue()); assertEquals(16.4, ((NumberToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals("12.3", aToken.getImage()); assertEquals(12, ((NumberToken)aToken).intValue()); assertEquals(12.3, ((NumberToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(IntToken.class, aToken.getClass()); assertEquals("19", aToken.getImage()); assertEquals(19, ((NumberToken)aToken).intValue()); assertEquals(19, ((NumberToken)aToken).doubleValue(), .001);}
aToken = lexer.getNextToken(); assertEquals(IntToken.class, aToken.getClass()); assertEquals("19", aToken.getImage()); assertEquals(19, ((NumberToken)aToken).intValue()); assertEquals(19, ((NumberToken)aToken).doubleValue(), .001);
aToken = parsedTokens[i++]; assertEquals(TokenType.Integer, ((TypedToken)aToken.getToken()).getType()); assertEquals("19", ((TypedToken)aToken.getToken()).getText());
public void testTypedTokens() { Lexer lexer = new Lexer(); lexer.setInput("17 18.5 16.4 12.3 19"); Token aToken = lexer.getNextToken(); assertEquals(IntToken.class, aToken.getClass()); assertEquals("17", aToken.getImage()); assertEquals(17, ((NumberToken)aToken).intValue()); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals("18.5", aToken.getImage()); assertEquals(18, ((NumberToken)aToken).intValue()); assertEquals(18.5, ((NumberToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals("16.4", aToken.getImage()); assertEquals(16, ((NumberToken)aToken).intValue()); assertEquals(16.4, ((NumberToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(FloatToken.class, aToken.getClass()); assertEquals("12.3", aToken.getImage()); assertEquals(12, ((NumberToken)aToken).intValue()); assertEquals(12.3, ((NumberToken)aToken).doubleValue(), .001); aToken = lexer.getNextToken(); assertEquals(IntToken.class, aToken.getClass()); assertEquals("19", aToken.getImage()); assertEquals(19, ((NumberToken)aToken).intValue()); assertEquals(19, ((NumberToken)aToken).doubleValue(), .001);}
fOut.close();
public synchronized void saveConfig() { if (!isStarted()) { return; } log().debug("Saving config (" + getConfigName() + ".config)"); OutputStream fOut; try { // Store config in misc base File file = new File(getConfigLocationBase(), getConfigName() + ".config"); fOut = new BufferedOutputStream(new FileOutputStream(file)); getConfig().store(fOut, "PowerFolder config file (v" + PROGRAM_VERSION + ")"); } catch (IOException e) { log().error("Unable to save config", e); } }
fileFilterModel.setShowExpected(showExpectedBox.isSelected());
fileFilterModel.setShowNormal(showNormalBox.isSelected());
public void actionPerformed(ActionEvent event) { fileFilterModel.setShowExpected(showExpectedBox.isSelected()); }
fileFilterModel.setShowDeleted(showDeletedBox.isSelected());
fileFilterModel.setShowExpected(showExpectedBox.isSelected());
public void actionPerformed(ActionEvent event) { fileFilterModel.setShowDeleted(showDeletedBox.isSelected()); }
normalCount.setText(" (" + normalText + ")"); deletedCount.setText(" (" + deletedText + ")"); expectedCount.setText(" (" + expectedText + ")");
final String normalTextFinal = normalText; final String deletedTextFinal = deletedText; final String expectedTextFinal = expectedText; Runnable runner = new Runnable() { public void run() { normalCount.setText(" (" + normalTextFinal + ")"); deletedCount.setText(" (" + deletedTextFinal + ")"); expectedCount.setText(" (" + expectedTextFinal + ")"); } }; EventQueue.invokeLater(runner);
private void update() { int normal = fileFilterModel.getNormalCount(); int deleted = fileFilterModel.getDeletedCount(); int expected = fileFilterModel.getExpectedCount(); String normalText = ""; if (normal == -1) { normalText = "?"; } else { normalText = normal + ""; } String deletedText = ""; if (deleted == -1) { deletedText = "?"; } else { deletedText = deleted + ""; } String expectedText = ""; if (expected == -1) { expectedText = "?"; } else { expectedText = expected + ""; } normalCount.setText(" (" + normalText + ")"); deletedCount.setText(" (" + deletedText + ")"); expectedCount.setText(" (" + expectedText + ")"); }
assertFalse(na.getMask().sameSubnet(a, b));
assertFalse(na.isValid() && na.getMask().sameSubnet(a, b));
public void testNetworkAddresses() throws UnknownHostException { NetworkHelper nu = NetworkHelper.getInstance(); assertNotNull(nu); // TODO: Cheap, needs change assertEquals(nu.getInterfaceAddresses().size(), nu.getNetworkAddresses().size()); // Test a non LAN address: assertFalse(NetworkUtil.isOnAnySubnet( (Inet4Address) InetAddress.getByName("217.23.244.121"))); NetworkAddress nw = nu.getNetworkAddresses().iterator().next(); assertTrue(NetworkUtil.isOnAnySubnet(nw.getAddress())); Inet4Address a = (Inet4Address) InetAddress.getByName("0.0.0.0"); Inet4Address b = (Inet4Address) InetAddress.getByName("255.255.255.255"); for (NetworkAddress na: nu.getNetworkAddresses()) { assertFalse(na.getMask().sameSubnet(a, b)); } }
UIUtil.removeBorder(pane);
private Component getProblemComponent(FileInfo fileInfo) { JList jList = new ProblemJList(scanResult.getProblemFiles().get( fileInfo)); List<FilenameProblem> problemDesctiptions = scanResult .getProblemFiles().get(fileInfo); String tooltip = ""; String line = ""; for (FilenameProblem problem : problemDesctiptions) { tooltip += line + problem.describeProblem(); line = "<hr>"; } int index = tooltip.indexOf("\n"); while (index != -1) { String before = tooltip.substring(0, index); String after = tooltip.substring(index + 1, tooltip.length()); tooltip = before + "<br>" + after; index = tooltip.indexOf("\n"); } tooltip = "<html>" + tooltip + "</html>"; jList.setToolTipText(tooltip); jList.setSize(jList.getPreferredSize()); JScrollPane pane = new JScrollPane(jList); pane.setToolTipText(tooltip); pane .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); pane .setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); return pane; }
table.setDefaultRenderer(Object.class, new ProblemTableCellRenderer()); table.setDefaultEditor(Object.class, new ProblemTableCellRenderer());
ProblemTableCellRenderer problemTableCellRenderer = new ProblemTableCellRenderer(); table.setDefaultRenderer(Object.class, problemTableCellRenderer); table.setDefaultEditor(Object.class, problemTableCellRenderer);
protected Component getContent() { FormLayout layout = new FormLayout("pref:grow", "pref"); PanelBuilder builder = new PanelBuilder(layout); CellConstraints cc = new CellConstraints(); table = new JTable(new ProblemTableModel()); table.setDefaultRenderer(Object.class, new ProblemTableCellRenderer()); table.setDefaultEditor(Object.class, new ProblemTableCellRenderer()); table.getTableHeader().setReorderingAllowed(false); JScrollPane scrollPane = new JScrollPane(table); builder.add(scrollPane, cc.xy(1, 1)); setColumnSizes(table); UIUtil.whiteStripTable(table); // UIUtil.setZeroHeight(scrollPane); UIUtil.removeBorder(scrollPane); JPanel panel = builder.getPanel(); panel.setPreferredSize(new Dimension(600, 300)); setColumnSizes(table); return panel; }
protected void handleCounterpartyMessage(Message aMessage) {
public void handleCounterpartyMessage(Message aMessage) {
protected void handleCounterpartyMessage(Message aMessage) { super.handleCounterpartyMessage(aMessage); }
protected void handleInternalMessage(Message aMessage) {
public void handleInternalMessage(Message aMessage) {
protected void handleInternalMessage(Message aMessage) { super.handleInternalMessage(aMessage); }
hideSplash();
public void start() { // set default implementations getController().getRecycleBin().setRecycleBinConfirmationHandler( new RecycleBinConfirmationHandlerDefaultImpl(getController())); getController().getFolderRepository().setInvitationReceivedHandler( new InvitationReceivedHandlerDefaultImpl(getController())); getController().getNodeManager().setAskForFriendshipHandler( new AskForFriendshipHandlerDefaultImpl(getController())); // create the Frame mainFrame = new MainFrame(getController()); // install system tray files installNativeFiles(); // create the models NavTreeModel navTreeModel = mainFrame.getControlQuarter() .getNavigationTreeModel(); chatModel = new ChatModel(getController()); nodeManagerModel = new NodeManagerModel(getController(), navTreeModel); blinkManager = new BlinkManager(getController()); folderRepoModel = new FolderRepositoryModel(getController(), navTreeModel); folderRepoModel.initalize(); // now load log().debug("Building UI"); mainFrame.buildUI(); log().debug("UI built"); // // Show window contents while dragging // Toolkit.getDefaultToolkit().setDynamicLayout(true); // System.setProperty("sun.awt.noerasebackground", "true"); // Completely loaded now // setLoadingCompletion(100); if (OSUtil.isSystraySupported()) { // Not create systray on windows before 2000 systems String iconPath = Controller.getTempFilesLocation() .getAbsolutePath() + "/"; defaultIcon = new SysTrayMenuIcon(iconPath + "PowerFolder", "openui"); sysTrayMenu = new SysTrayMenu(defaultIcon, getController() .getMySelf().getNick() + " | " + Translation.getTranslation("systray.powerfolder", Controller.PROGRAM_VERSION)); SysTrayMenuItem exit = new SysTrayMenuItem(Translation .getTranslation("systray.exit"), "exit"); exit.addSysTrayMenuListener(this); sysTrayMenu.addItem(exit); sysTrayMenu.addSeparator(); final SysTrayMenuItem opentUI = new SysTrayMenuItem(Translation .getTranslation("systray.show"), "openui"); opentUI.addSysTrayMenuListener(this); sysTrayMenu.addItem(opentUI); SysTrayMenuItem sync = new SysTrayMenuItem(Translation .getTranslation("systray.syncall"), "syncall"); sync.addSysTrayMenuListener(this); sysTrayMenu.addItem(sync); sysTrayMenu.addSeparator(); SysTrayMenuItem pfLabel = new SysTrayMenuItem(getController() .getMySelf().getNick() + " | " + Translation.getTranslation("systray.powerfolder", Controller.PROGRAM_VERSION), "gotohp"); sysTrayMenu.addItem(pfLabel); pfLabel.addSysTrayMenuListener(this); defaultIcon.addSysTrayMenuListener(this); UpdateSystrayTask updateSystrayTask = new UpdateSystrayTask(); getController().scheduleAndRepeat(updateSystrayTask, 5000); // Switch Systray show/hide menuitem dynamically mainFrame.getUIComponent().addComponentListener( new ComponentAdapter() { public void componentShown(ComponentEvent arg0) { opentUI.setLabel(Translation .getTranslation("systray.hide")); opentUI.setActionCommand("hideui"); } public void componentHidden(ComponentEvent arg0) { opentUI.setLabel(Translation .getTranslation("systray.show")); opentUI.setActionCommand("openui"); } }); } else { log().warn("System tray currently only supported on windows (>98)"); mainFrame.getUIComponent().setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE); } if (getController().isStartMinimized()) { log().warn("Starting minimized"); } mainFrame.getUIComponent().setVisible( !getController().isStartMinimized()); // Add mouse listner for double click getControlQuarter().getUITree().addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { Object target = getControlQuarter().getSelectedItem(); if (target != null) { doubleClickOn(target); } } } }); started = true; // Process all pending runners synchronized (pendingJobs) { if (!pendingJobs.isEmpty()) { log().verbose( "Executing " + pendingJobs.size() + " pending ui jobs"); for (Iterator it = pendingJobs.iterator(); it.hasNext();) { Runnable runner = (Runnable) it.next(); SwingUtilities.invokeLater(runner); } } } // Open wizard on first start if (getController().getPreferences().getBoolean("openwizard2", true)) { PFWizard wizard = new PFWizard(getController()); wizard.open(); // Now never again, only on button getController().getPreferences().putBoolean("openwizard2", false); } }
return type;
if (this.type == null) return this.getClass().getSimpleName(); else return type;
public String getType() { return type; }
if (getController().isLanOnly()) { log().warn("LanOnly debug:"); log().warn("newNode: " + newNode); log().warn("newNode.connectAddress: " + newNode.getConnectAddress()); }
public void queueNewNodes(MemberInfo[] newNodes) { if (newNodes == null || newNodes.length == 0) { return; } // queue new members if (logVerbose) { log().verbose("Received new list of " + newNodes.length + " nodes"); } int nNewNodes = 0; int nQueuedNodes = 0; for (int i = 0; i < newNodes.length; i++) { MemberInfo newNode = newNodes[i]; // just check, for a faster shutdown if (Thread.currentThread().isInterrupted()) { return; } if (newNode == null || newNode.isInvalid(getController())) { // Member is too old, ignore if (logVerbose) { log().verbose("Not adding new node: " + newNode); } continue; } Member thisNode = getNode(newNode); if (newNode.matches(mySelf)) { // ignore myself continue; } else if (getController().isLanOnly() && !NetworkUtil.isOnLanOrLoopback(newNode.getConnectAddress() .getAddress())) { // ignore if lan only mode && newNode not is onlan continue; } else if (thisNode == null) { // add node thisNode = addNode(newNode); nNewNodes++; } else { // update own information if more valueable thisNode.updateInfo(newNode); } if (newNode.isConnected) { // Node is connected to the network thisNode.setConnectedToNetwork(newNode.isConnected); synchronized (reconnectionQueue) { // Add node to reconnection queue if (!thisNode.isReconnecting() && reconnectionQueue.indexOf(thisNode) < 0) { reconnectionQueue.add(thisNode); nQueuedNodes++; } } } } if (nQueuedNodes > 0 || nNewNodes > 0) { if (nQueuedNodes > 0) { // Resort reconnection queue synchronized (reconnectionQueue) { Collections.sort(reconnectionQueue, MemberComparator.BY_RECONNECTION_PRIORITY); } } if (logVerbose) { log().verbose( "Queued " + nQueuedNodes + " new nodes for reconnection, " + nNewNodes + " added"); } } }
if (type != Integer.class) {
if (type != String.class) {
public String getValueString(Controller controller) { if (type != Integer.class) { throw new IllegalStateException("This preferences entry has type " + type.getName() + " cannot acces as String"); } return controller.getPreferences().get(preferencesKey, defaultValueString); }
MarketceteraTestSuite suite = new MarketceteraTestSuite(QuickFIXAdapterTest.class);
MarketceteraTestSuite suite = new MarketceteraTestSuite(QuickFIXAdapterTest.class, OrderManagementSystem.OMS_MESSAGE_BUNDLE_INFO);
public static Test suite() { MarketceteraTestSuite suite = new MarketceteraTestSuite(QuickFIXAdapterTest.class); suite.addTest(new RepeatedTest(new QuickFIXAdapterTest("testMessagePassthrough"), 5)); return suite; }
folderAtBart.scanLocalFiles(true);
folderAtBart.forceScanOnNextMaintenance(); folderAtBart.maintain();
public void testBigFileCopy() { System.out.println("FileTransferTest.testEmptyFileCopy"); // Set both folders to auto download folderAtBart.setSyncProfile(SyncProfile.AUTO_DOWNLOAD_FROM_ALL); folderAtLisa.setSyncProfile(SyncProfile.AUTO_DOWNLOAD_FROM_ALL); // Register listeners MyTransferManagerListener tm1Listener = new MyTransferManagerListener(); getContollerBart().getTransferManager().addListener(tm1Listener); final MyTransferManagerListener tm2Listener = new MyTransferManagerListener(); getContollerLisa().getTransferManager().addListener(tm2Listener); // 1Meg testfile TestHelper.createRandomFile(folderAtBart.getLocalBase(), 1000000); // Let him scan the new content folderAtBart.scanLocalFiles(true); TestHelper.waitForCondition(5, new Condition() { public boolean reached() { return tm2Listener.downloadCompleted >= 1; } }); // Check correct event fireing assertEquals(1, tm1Listener.uploadRequested); assertEquals(1, tm1Listener.uploadStarted); assertEquals(1, tm1Listener.uploadCompleted); // Check correct event fireing assertEquals(1, tm2Listener.downloadRequested); assertEquals(1, tm2Listener.downloadQueued); assertEquals(1, tm2Listener.downloadStarted); assertEquals(1, tm2Listener.downloadCompleted); assertEquals(0, tm2Listener.downloadsCompletedRemoved); // Test ;) assertEquals(1, folderAtLisa.getFilesCount()); // 2 physical files (1 + 1 system dir) assertEquals(2, folderAtLisa.getLocalBase().list().length); // No active downloads? assertEquals(0, getContollerLisa().getTransferManager() .getActiveDownloadCount()); // Clear completed downloads getContollerLisa().getTransferManager().clearCompletedDownloads(); // give time for event firering TestHelper.waitMilliSeconds(500); assertEquals(1, tm2Listener.downloadsCompletedRemoved); }
folderAtBart.scanLocalFiles(true);
folderAtBart.forceScanOnNextMaintenance(); folderAtBart.maintain();
public void testEmptyFileCopy() throws IOException, InterruptedException { System.out.println("FileTransferTest.testEmptyFileCopy"); // Set both folders to auto download folderAtBart.setSyncProfile(SyncProfile.AUTO_DOWNLOAD_FROM_ALL); folderAtLisa.setSyncProfile(SyncProfile.AUTO_DOWNLOAD_FROM_ALL); // Register listeners MyTransferManagerListener tm1Listener = new MyTransferManagerListener(); getContollerBart().getTransferManager().addListener(tm1Listener); final MyTransferManagerListener tm2Listener = new MyTransferManagerListener(); getContollerLisa().getTransferManager().addListener(tm2Listener); File testFile1 = new File(folderAtBart.getLocalBase() + "/TestFile.txt"); FileOutputStream fOut = new FileOutputStream(testFile1); fOut.write(new byte[]{}); fOut.close(); assertTrue(testFile1.exists()); // Let him scan the new content folderAtBart.scanLocalFiles(true); TestHelper.waitForCondition(5, new Condition() { public boolean reached() { return tm2Listener.downloadCompleted >= 1; } }); // Check correct event fireing assertEquals(1, tm1Listener.uploadRequested); assertEquals(1, tm1Listener.uploadStarted); assertEquals(1, tm1Listener.uploadCompleted); // Check correct event fireing assertEquals(1, tm2Listener.downloadRequested); assertEquals(1, tm2Listener.downloadQueued); assertEquals(1, tm2Listener.downloadStarted); assertEquals(1, tm2Listener.downloadCompleted); assertEquals(0, tm2Listener.downloadsCompletedRemoved); // Test ;) assertEquals(1, folderAtLisa.getFilesCount()); // 2 physical files (1 + 1 system dir) assertEquals(2, folderAtLisa.getLocalBase().list().length); // No active downloads? assertEquals(0, getContollerLisa().getTransferManager() .getActiveDownloadCount()); // Clear completed downloads getContollerLisa().getTransferManager().clearCompletedDownloads(); // give time for event firering Thread.sleep(500); assertEquals(1, tm2Listener.downloadsCompletedRemoved); }
folderAtBart.scanLocalFiles(true);
folderAtBart.forceScanOnNextMaintenance(); folderAtBart.maintain();
public void testFileUpdate() throws IOException { System.out.println("FileTransferTest.testFileUpdate"); // Set both folders to auto download folderAtBart.setSyncProfile(SyncProfile.AUTO_DOWNLOAD_FROM_ALL); folderAtLisa.setSyncProfile(SyncProfile.AUTO_DOWNLOAD_FROM_ALL); // First copy file testSmallFileCopy(); File testFile1 = new File(folderAtBart.getLocalBase() + "/TestFile.txt"); FileOutputStream fOut = new FileOutputStream(testFile1, true); fOut.write("-> Next content<-".getBytes()); fOut.close(); // Readin file content FileInputStream fIn = new FileInputStream(testFile1); byte[] content1 = new byte[fIn.available()]; fIn.read(content1); fIn.close(); // Let him scan the new content folderAtBart.scanLocalFiles(true); // Give them time to copy TestHelper.waitMilliSeconds(5000); // Test ;) assertEquals(1, folderAtLisa.getFilesCount()); FileInfo testFileInfo2 = folderAtLisa.getFiles()[0]; assertEquals(testFile1.length(), testFileInfo2.getSize()); // Read content File testFile2 = testFileInfo2.getDiskFile(getContollerLisa() .getFolderRepository()); fIn = new FileInputStream(testFile2); byte[] conten2 = new byte[fIn.available()]; fIn.read(conten2); fIn.close(); // Check version assertEquals(1, testFileInfo2.getVersion()); // Check content assertEquals(new String(content1), new String(conten2)); }
folderAtBart.scanLocalFiles(true); TestHelper.waitMilliSeconds(1000);
folderAtBart.forceScanOnNextMaintenance(); folderAtBart.maintain();
public void testMultipleFileCopy() throws IOException { System.out.println("FileTransferTest.testMultipleFileCopy"); // Set both folders to auto download folderAtBart.setSyncProfile(SyncProfile.AUTO_DOWNLOAD_FROM_ALL); folderAtLisa.setSyncProfile(SyncProfile.AUTO_DOWNLOAD_FROM_ALL); // Register listeners MyTransferManagerListener tm1Listener = new MyTransferManagerListener(); getContollerBart().getTransferManager().addListener(tm1Listener); final MyTransferManagerListener tm2Listener = new MyTransferManagerListener(); getContollerLisa().getTransferManager().addListener(tm2Listener); final int nFiles = 35; for (int i = 0; i < nFiles; i++) { createRandomFile(folderAtBart.getLocalBase()); } // Let him scan the new content folderAtBart.scanLocalFiles(true); TestHelper.waitMilliSeconds(1000); assertEquals(nFiles, folderAtBart.getFilesCount()); // Wait for copy (timeout 50) TestHelper.waitForCondition(120, new Condition() { public boolean reached() { return tm2Listener.downloadCompleted >= nFiles; } }); // Check correct event fireing assertEquals(nFiles, tm1Listener.uploadRequested); assertEquals(nFiles, tm1Listener.uploadStarted); assertEquals(nFiles, tm1Listener.uploadCompleted); // Check correct event fireing assertEquals(nFiles, tm2Listener.downloadRequested); assertEquals(nFiles, tm2Listener.downloadQueued); assertEquals(nFiles, tm2Listener.downloadStarted); assertEquals(nFiles, tm2Listener.downloadCompleted); assertEquals(0, tm2Listener.downloadsCompletedRemoved); // Test ;) assertEquals(nFiles, folderAtLisa.getFilesCount()); // test physical files (1 + 1 system dir) assertEquals(nFiles + 1, folderAtLisa.getLocalBase().list().length); // No active downloads?! assertEquals(0, getContollerLisa().getTransferManager() .getActiveDownloadCount()); // Clear completed downloads getContollerLisa().getTransferManager().clearCompletedDownloads(); TestHelper.waitMilliSeconds(500); assertEquals(nFiles, tm2Listener.downloadsCompletedRemoved); }
folderAtBart.scanLocalFiles(true); TestHelper.waitMilliSeconds(2000);
folderAtBart.forceScanOnNextMaintenance(); folderAtBart.maintain();
public void testSmallFileCopy() throws IOException { // Set both folders to auto download folderAtBart.setSyncProfile(SyncProfile.AUTO_DOWNLOAD_FROM_ALL); folderAtLisa.setSyncProfile(SyncProfile.AUTO_DOWNLOAD_FROM_ALL); File testFileBart = new File(folderAtBart.getLocalBase(), "TestFile.txt"); FileOutputStream fOut = new FileOutputStream(testFileBart); byte[] testContent = "This is the contenent of the testfile".getBytes(); fOut.write(testContent); fOut.close(); // Let him scan the new content folderAtBart.scanLocalFiles(true); TestHelper.waitMilliSeconds(2000); assertEquals(1, folderAtBart.getFilesCount()); // Give them time to copy TestHelper.waitMilliSeconds(2000); // Test ;) assertEquals(1, folderAtLisa.getFilesCount()); File testFileLisa = new File(folderAtLisa.getLocalBase(), "TestFile.txt"); assertEquals(testContent.length, testFileLisa.length()); assertEquals(testFileBart.length(), testFileLisa.length()); }
return "The filename is a reserved filename on Windows,\nit is recommended not to use this names on windows:\n CON, PRN, AUX, CLOCK$, NUL COM0, COM1, COM2, COM3, COM4, COM5,\nCOM6, COM7, COM8, COM9, LPT0, LPT1, LPT2,\nLPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9.";
return "The filename is a reserved filename on Windows,\nit is recommended not to use this names on windows:\n CON, PRN, AUX, CLOCK$, NUL COM0, COM1, COM2, COM3,\nCOM4, COM5,COM6, COM7, COM8, COM9, LPT0, LPT1,\nLPT2, LPT3, LPT4,LPT5, LPT6, LPT7, LPT8, and LPT9.";
public final String describeProblem() { switch (problemType) { case CONTAINS_ILLEGAL_LINUX_CHARS : return "The filename contains characters that may cause problems on Unix/Linux computers.\nThe character / is not allowed on those computers"; case CONTAINS_ILLEGAL_MACOSX_CHARS : return "The filename contains characters that may cause problems on Mac OSX computers.\nThe characters / and : are not allowed on those computers"; case CONTAINS_ILLEGAL_WINDOWS_CHARS : return "The filename contains characters that may cause problems on Windows computers.\nThe characters |\\?*<\":>/ and \"controll\" characters (ASCII code 0 till 31)\nare not allowed on those computers"; case ENDS_WITH_ILLEGAL_WINDOWS_CHARS : return "The filename ends with characters that may cause problems on Windows computers.\nThe characters . and space ( ) are not allowed as last\ncharacters on those computers"; case IS_RESERVED_WINDOWS_WORD : return "The filename is a reserved filename on Windows,\nit is recommended not to use this names on windows:\n CON, PRN, AUX, CLOCK$, NUL COM0, COM1, COM2, COM3, COM4, COM5,\nCOM6, COM7, COM8, COM9, LPT0, LPT1, LPT2,\nLPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9."; case TO_LONG : return "The filename is longer than 255 characters,\nthis in know to cause problems on Windows, Mac OSX and Unix/Linux computers."; case DUPLICATE_FOUND : return "A filename with the same name is found but it has a differend case:\n" + fileInfoDupe.getName() + "\nthis causes problems on windows computers"; } throw new IllegalStateException("invalid problemType: " + problemType); }
new Thread("Preferences saver/validator") { public void run() {
SwingWorker worker = new SwingWorker() { @Override public Object construct() {
private JButton createOKButton() { JButton theButton = createOKButton(new ActionListener() { public void actionPerformed(ActionEvent e) { // // OK button event handler // // disable the OK button while we are in the // working thread (i.e. prohibit re-entrance) okButton.setEnabled(false); // since we are performing a validation // that could take some time we need to warn the user about it. // However updating the gui while the task is progressing, // requires us to run the validation in a new thread that will // give the chance of the swing thread to update the GUI new Thread("Preferences saver/validator") { public void run() { // validate the user input and check the result boolean succes = validateSettings(); if (!succes) { okButton.setEnabled(true); return; } // Save settings saveSettings(); if (needsRestart()) { handleRestartRequest(); } close(); } // end run }.start(); // start the working thread } }); return theButton; }
okButton.setEnabled(true); return;
return Boolean.FALSE;
private JButton createOKButton() { JButton theButton = createOKButton(new ActionListener() { public void actionPerformed(ActionEvent e) { // // OK button event handler // // disable the OK button while we are in the // working thread (i.e. prohibit re-entrance) okButton.setEnabled(false); // since we are performing a validation // that could take some time we need to warn the user about it. // However updating the gui while the task is progressing, // requires us to run the validation in a new thread that will // give the chance of the swing thread to update the GUI new Thread("Preferences saver/validator") { public void run() { // validate the user input and check the result boolean succes = validateSettings(); if (!succes) { okButton.setEnabled(true); return; } // Save settings saveSettings(); if (needsRestart()) { handleRestartRequest(); } close(); } // end run }.start(); // start the working thread } }); return theButton; }
close();
return Boolean.TRUE; }
private JButton createOKButton() { JButton theButton = createOKButton(new ActionListener() { public void actionPerformed(ActionEvent e) { // // OK button event handler // // disable the OK button while we are in the // working thread (i.e. prohibit re-entrance) okButton.setEnabled(false); // since we are performing a validation // that could take some time we need to warn the user about it. // However updating the gui while the task is progressing, // requires us to run the validation in a new thread that will // give the chance of the swing thread to update the GUI new Thread("Preferences saver/validator") { public void run() { // validate the user input and check the result boolean succes = validateSettings(); if (!succes) { okButton.setEnabled(true); return; } // Save settings saveSettings(); if (needsRestart()) { handleRestartRequest(); } close(); } // end run }.start(); // start the working thread } }); return theButton; }
} }.start();
@Override public void finished() { if (get() == Boolean.TRUE) { setVisible(false); } okButton.setEnabled(true); } }; worker.start();
private JButton createOKButton() { JButton theButton = createOKButton(new ActionListener() { public void actionPerformed(ActionEvent e) { // // OK button event handler // // disable the OK button while we are in the // working thread (i.e. prohibit re-entrance) okButton.setEnabled(false); // since we are performing a validation // that could take some time we need to warn the user about it. // However updating the gui while the task is progressing, // requires us to run the validation in a new thread that will // give the chance of the swing thread to update the GUI new Thread("Preferences saver/validator") { public void run() { // validate the user input and check the result boolean succes = validateSettings(); if (!succes) { okButton.setEnabled(true); return; } // Save settings saveSettings(); if (needsRestart()) { handleRestartRequest(); } close(); } // end run }.start(); // start the working thread } }); return theButton; }
new Thread("Preferences saver/validator") { public void run() {
SwingWorker worker = new SwingWorker() { @Override public Object construct() {
public void actionPerformed(ActionEvent e) { // // OK button event handler // // disable the OK button while we are in the // working thread (i.e. prohibit re-entrance) okButton.setEnabled(false); // since we are performing a validation // that could take some time we need to warn the user about it. // However updating the gui while the task is progressing, // requires us to run the validation in a new thread that will // give the chance of the swing thread to update the GUI new Thread("Preferences saver/validator") { public void run() { // validate the user input and check the result boolean succes = validateSettings(); if (!succes) { okButton.setEnabled(true); return; } // Save settings saveSettings(); if (needsRestart()) { handleRestartRequest(); } close(); } // end run }.start(); // start the working thread }