⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 updatemonitor.java

📁 java 文件下载器。可自定义
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
				super();
			}
		});
		delayed_task.queue();
	}

	private String format(UpdateCheckInstance instance, String str)
	{
		String name = instance.getName();
		if (MessageText.keyExists(name))
			name = MessageText.getString(name);
		return (new StringBuilder()).append(name).append(" - ").append(str).toString();
	}

	private String format(UpdateChecker checker, String str)
	{
		return (new StringBuilder()).append("    ").append(checker.getComponent().getName()).append(" - ").append(str).toString();
	}

	protected void requestRecheck()
	{
		if (Logger.isEnabled())
			Logger.log(new LogEvent(LOGID, "UpdateMonitor: recheck requested"));
		performCheck(false, true, true, null);
	}

	protected void performAutoCheck(final boolean start_of_day)
	{
		boolean check_at_start = false;
		boolean check_periodic = false;
		boolean bOldSWT = SWT.getVersion() < 3139;
		if (!SystemProperties.isJavaWebStartInstance())
		{
			check_at_start = COConfigurationManager.getBooleanParameter("update.start") || bOldSWT;
			check_periodic = COConfigurationManager.getBooleanParameter("update.periodic");
		}
		check_at_start = check_at_start || check_periodic;
		if (check_at_start && start_of_day || check_periodic && !start_of_day)
			performCheck(bOldSWT, true, false, null);
		else
			new DelayedEvent("UpdateMon:wait2", 5000L, new AERunnable() {

				final boolean val$start_of_day;
				final UpdateMonitor this$0;

				public void runSupport()
				{
					if (start_of_day)
					{
						UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
						if (uiFunctions != null)
							uiFunctions.setStatusText("");
					}
					CoreUpdateChecker.doUsageStats();
				}

			
			{
				this$0 = UpdateMonitor.this;
				start_of_day = flag;
				super();
			}
			});
	}

	public void performCheck(boolean bForce, boolean automatic, boolean isRecheck, UpdateCheckInstanceListener l)
	{
		long now = SystemTime.getCurrentTime();
		if (isRecheck)
		{
			if (last_recheck_time > now || now - last_recheck_time < 0x4ef6d80L)
			{
				if (Logger.isEnabled())
					Logger.log(new LogEvent(LOGID, "skipping recheck as consecutive recheck too soon"));
				return;
			}
			last_recheck_time = now;
		} else
		{
			last_recheck_time = 0L;
		}
		if (SystemProperties.isJavaWebStartInstance())
		{
			if (Logger.isEnabled())
				Logger.log(new LogEvent(LOGID, "skipping update check as java web start"));
			return;
		}
		if (current_update_window != null && !current_update_window.isDisposed())
			current_update_window.dispose();
		if (current_update_instance != null)
			current_update_instance.cancel();
		UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
		if (uiFunctions != null)
			uiFunctions.setStatusText("MainWindow.status.checking ...");
		AEThread2 t = new AEThread2(automatic, l) {

			final boolean val$bForce;
			final boolean val$automatic;
			final UpdateCheckInstanceListener val$l;
			final UpdateMonitor this$0;

			public void run()
			{
				UpdateManager um = azCore.getPluginManager().getDefaultPluginInterface().getUpdateManager();
				current_update_instance = um.createUpdateCheckInstance(bForce ? 1 : 2, "update.instance.update");
				if (!automatic)
					current_update_instance.setAutomatic(false);
				if (l != null)
					current_update_instance.addListener(l);
				current_update_instance.start();
			}

			
			{
				this$0 = UpdateMonitor.this;
				bForce = flag;
				automatic = flag1;
				l = updatecheckinstancelistener;
				super(x0, x1);
			}
		};
		t.start();
	}

	public void complete(UpdateCheckInstance instance)
	{
		if (instance.isLowNoise())
		{
			handleLowNoise(instance);
			return;
		}
		boolean hasDownloads = false;
		Update us[] = instance.getUpdates();
		int i = 0;
		do
		{
			if (i >= us.length)
				break;
			if (us[i].getDownloaders().length > 0)
			{
				hasDownloads = true;
				break;
			}
			i++;
		} while (true);
		try
		{
			int ui = ((Integer)instance.getProperty(1)).intValue();
			if (ui == 2)
			{
				new SimpleInstallUI(this, instance);
				return;
			}
		}
		catch (Throwable e)
		{
			Debug.printStackTrace(e);
		}
		boolean update_action = instance.getType() == 2;
		UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
		if (uiFunctions != null)
			uiFunctions.setStatusText("");
		if (hasDownloads)
		{
			UpdateWindow this_window = null;
			boolean autoDownload = COConfigurationManager.getBooleanParameter("update.autodownload");
			if (update_action)
			{
				if (!autoDownload && (current_update_window == null || current_update_window.isDisposed()))
					this_window = current_update_window = new UpdateWindow(this, azCore, instance);
			} else
			{
				this_window = new UpdateWindow(this, azCore, instance);
			}
			if (this_window != null)
			{
				for (int i = 0; i < us.length; i++)
					if (us[i].getDownloaders().length > 0)
						this_window.addUpdate(us[i]);

				this_window.updateAdditionComplete();
			} else
			if (autoDownload)
				new UpdateAutoDownloader(us, new UpdateAutoDownloader.cbCompletion() {

					final UpdateMonitor this$0;

					public void allUpdatesComplete(boolean requiresRestart, boolean bHadMandatoryUpdates)
					{
						if (requiresRestart)
							handleRestart();
						else
						if (bHadMandatoryUpdates)
							requestRecheck();
					}

			
			{
				this$0 = UpdateMonitor.this;
				super();
			}
				});
			else
			if (Logger.isEnabled())
				Logger.log(new LogEvent(LOGID, 1, "UpdateMonitor: user dialog already in progress, updates skipped"));
		} else
		if (Logger.isEnabled())
			Logger.log(new LogEvent(LOGID, "UpdateMonitor: check instance resulted in no user-actionable updates"));
	}

	public void cancelled(UpdateCheckInstance instance)
	{
		UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
		if (uiFunctions != null)
			uiFunctions.setStatusText("");
	}

	protected void handleRestart()
	{
		UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
		if (uiFunctions != null)
		{
			String title = MessageText.getString("UpdateMonitor.messagebox.restart.title");
			String text = MessageText.getString("UpdateMonitor.messagebox.restart.text");
			uiFunctions.bringToFront();
			int timeout = 0x2bf20;
			if (azCore != null && !azCore.getPluginManager().isSilentRestartEnabled())
				timeout = -1;
			if (uiFunctions.promptUser(title, text, new String[] {
	MessageText.getString("UpdateWindow.restart"), MessageText.getString("UpdateWindow.restartLater")
}, 0, null, null, false, timeout) == 0)
				uiFunctions.dispose(true, false);
		}
	}

	protected void addDecisionHandler(UpdateCheckInstance instance)
	{
		instance.addDecisionListener(new UpdateManagerDecisionListener() {

			final UpdateMonitor this$0;

			public Object decide(Update update, int decision_type, String decision_name, String decision_description, Object decision_data)
			{
				if (decision_type == 0)
				{
					String options[] = (String[])(String[])decision_data;
					org.eclipse.swt.widgets.Shell shell = UIFunctionsManagerSWT.getUIFunctionsSWT().getMainShell();
					if (shell == null)
					{
						Debug.out("Shell doesn't exist");
						return null;
					}
					StringListChooser chooser = new StringListChooser(shell);
					chooser.setTitle(decision_name);
					chooser.setText(decision_description);
					for (int i = 0; i < options.length; i++)
						chooser.addOption(options[i]);

					String result = chooser.open();
					return result;
				} else
				{
					return null;
				}
			}

			
			{
				this$0 = UpdateMonitor.this;
				super();
			}
		});
	}

	protected void handleLowNoise(UpdateCheckInstance instance)
	{
		addDecisionHandler(instance);
		Update updates[] = instance.getUpdates();
		try
		{
			for (int i = 0; i < updates.length; i++)
			{
				ResourceDownloader downloaders[] = updates[i].getDownloaders();
				for (int j = 0; j < downloaders.length; j++)
					downloaders[j].download();

			}

			boolean restart_required = false;
			for (int i = 0; i < updates.length; i++)
				if (updates[i].getRestartRequired() == 2)
					restart_required = true;

			if (restart_required)
				handleRestart();
		}
		catch (Throwable e)
		{
			e.printStackTrace();
		}
	}

	static 
	{
		LOGID = LogIDs.GUI;
	}





}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -