/** * Update ProgressBar values. * * @param minValue the minimum value * @param maxValue the maximum value * @param selValue the value */ void eswtSetProgressbarValues(int minValue, int maxValue, int selValue) { if (eswtProgressBar != null) { eswtProgressBar.setMinimum(minValue); eswtProgressBar.setMaximum(maxValue); eswtProgressBar.setSelection(selValue); } }
@Test public void testRenderMaxmum() throws IOException { progressBar.setMaximum(10); lca.renderChanges(progressBar); Message message = Fixture.getProtocolMessage(); assertEquals(10, message.findSetProperty(progressBar, "maximum").asInt()); }
/** * Set the text at the right end of the progress bar and the maximum property on the progress bar. * This is the total length of the song. * * @param totalTimeInSeconds total length of the song in seconds */ public void setTotalTime(int totalTimeInSeconds) { // Don't do any work if the total time hasn't changed. if (currentTotalTime != totalTimeInSeconds) { progressBar.setMaximum(totalTimeInSeconds); totalTimeText.setText(formatTimeToString(totalTimeInSeconds)); totalTimeText.pack(); } }
// 创建进度条 private ProgressBar createProgressBar(Composite parent) { ProgressBar progressBar = new ProgressBar(parent, SWT.SMOOTH); progressBar.setMinimum(0); // 最小值 progressBar.setMaximum(100); // 最大值 return progressBar; }
@Test public void testRenderMaxmumUnchanged() throws IOException { Fixture.markInitialized(display); Fixture.markInitialized(progressBar); progressBar.setMaximum(10); Fixture.preserveWidgets(); lca.renderChanges(progressBar); Message message = Fixture.getProtocolMessage(); assertNull(message.findSetOperation(progressBar, "maximum")); }
public void open(int minValue, int maxValue) { childShell = new Shell(shell.getDisplay(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); childShell.setText("Exporting to Excel.. please wait"); progressBar = new ProgressBar(childShell, SWT.SMOOTH); progressBar.setMinimum(minValue); progressBar.setMaximum(maxValue); progressBar.setBounds(0, 0, 400, 25); progressBar.setFocus(); childShell.pack(); childShell.open(); }
/** Create contents of the window */ protected void createContents() { setImage( SWTResourceManager.getImage(FileDownloadShell.class, "/org/wayne/feiq/ui/image/ico.png")); setSize(443, 141); setText("download file.."); lblMsg = new Label(this, SWT.NONE); lblMsg.setText("Counting file size..."); lblMsg.setBounds(10, 51, 350, 16); progressBar = new ProgressBar(this, SWT.SMOOTH); progressBar.setMaximum(100); progressBar.setBounds(10, 86, 417, 16); lblFile = new Label(this, SWT.NONE); lblFile.setBounds(10, 66, 350, 16); // }
public static Object create(ActionContext actionContext) { Thing self = (Thing) actionContext.get("self"); int style = SWT.NONE; String selfStyle = self.getString("style"); if ("HORIZONTAL".equals(selfStyle)) { style |= SWT.HORIZONTAL; } else if ("VERTICAL".equals(selfStyle)) { style |= SWT.VERTICAL; } if (self.getBoolean("SMOOTH")) style |= SWT.SMOOTH; if (self.getBoolean("BORDER")) style |= SWT.BORDER; if (self.getBoolean("INDETERMINATE")) style |= SWT.INDETERMINATE; Composite parent = (Composite) actionContext.get("parent"); ProgressBar bar = new ProgressBar(parent, style); // 父类的初始化方法 Bindings bindings = actionContext.push(null); bindings.put("control", bar); try { self.doAction("super.init", actionContext); } finally { actionContext.pop(); } bar.setMaximum(self.getInt("maximum", 100)); bar.setMinimum(self.getInt("minimum", 0)); bar.setSelection(self.getInt("selection", 0)); // 保存变量和创建子事物 actionContext.getScope(0).put(self.getString("name"), bar); actionContext.peek().put("parent", bar); for (Thing child : self.getAllChilds()) { child.doAction("create", actionContext); } actionContext.peek().remove("parent"); Designer.attach(bar, self.getMetadata().getPath(), actionContext); return bar; }
public Upload(Composite parent, int style, int... uploadStyles) { super(parent, style); setLayout(FormLayoutFactory.defaults().create()); fileUpload = new FileUpload(this, SWT.NONE); fileUpload.setLayoutData(FormDataFactory.filled().create()); fileUpload.setText(i18n.get("select")); fileUpload.setData(RWT.TOOLTIP_MARKUP_ENABLED, Boolean.TRUE); setData(RWT.TOOLTIP_MARKUP_ENABLED, Boolean.TRUE); fileUpload.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent ev) { UIUtils.activateCallback("upload"); fileUpload.submit(UploadService.registerHandler(Upload.this)); } }); if (ArrayUtils.contains(uploadStyles, SHOW_UPLOAD_BUTTON)) { log.info("SHOW_UPLOAD_BUTTON is not supported yet."); } if (ArrayUtils.contains(uploadStyles, SHOW_PROGRESS)) { fileUpload.setLayoutData(FormDataFactory.filled().noRight().create()); progress = new ProgressBar(this, SWT.HORIZONTAL); progress.setLayoutData(FormDataFactory.filled().left(fileUpload).create()); progress.setMaximum(Integer.MAX_VALUE); progressLabel = new Label(this, SWT.NONE); progressLabel.setLayoutData(FormDataFactory.filled().top(0, 5).left(fileUpload, 20).create()); progressLabel.setText(i18n.get("progressLabel")); log.warn("not yet ported: progressLabel.setForeground( new Color( 0x60, 0x60, 0x60 ) ) "); progressLabel.moveAbove(progress); } }
// this method must be private or protected so the auto-gen tool keeps it private void setDefaults() { progressBar.setMaximum(100); progressBar.setMinimum(10); progressBar.setSelection(50); }
public void ProgessBarExample1( String ip, String port, String database, String username, String password) { final Display display = Display.getDefault(); final Shell shell = new Shell(SWT.CLOSE); shell.setText(""); shell.setSize(315, 127); shell.setLocation(350, 180); shell.setLayout(new FormLayout()); progressBar = new ProgressBar(shell, SWT.HORIZONTAL); FormData data = new FormData(237, 20); data.left = new FormAttachment(0, 35); data.bottom = new FormAttachment(100, -30); progressBar.setLayoutData(data); progressBar.setMaximum(100); max = progressBar.getMaximum(); text = new Text(shell, SWT.BORDER); data.right = new FormAttachment(100, -69); text.setEnabled(false); final FormData fd_text = new FormData(); fd_text.top = new FormAttachment(progressBar, 0, SWT.TOP); fd_text.left = new FormAttachment(progressBar, 11); fd_text.right = new FormAttachment(100, -25); text.setLayoutData(fd_text); Label label = new Label(shell, SWT.NONE); data.top = new FormAttachment(label, 25); FormData fd_label = new FormData(); fd_label.bottom = new FormAttachment(100, -72); fd_label.right = new FormAttachment(100, -67); fd_label.left = new FormAttachment(0, 25); label.setLayoutData(fd_label); label.setText("\u9A8C\u8BC1\u4E2D\uFF0C\u8BF7\u7A0D\u540E\u3002\u3002\u3002\u3002\u3002"); new Thread() { public void run() { new Thread() { public void run() { PropertyConfigurator.configure(ClassLoader.getSystemResource("log4j.properties")); Logger logger = Logger.getLogger(ProgressBarWindow.class); try { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); @SuppressWarnings("unused") Connection conn = DriverManager.getConnection( "jdbc:sqlserver://" + ip + ":" + port + ";DatabaseName=" + database + "", "" + username + "", "" + password + ""); flag = true; PropertiesUtil.writePropertiesFile( "jdbc.ip", ip, System.getProperty("user.dir") + "\\configuration\\database_configuration.properties"); PropertiesUtil.writePropertiesFile( "jdbc.port", port, System.getProperty("user.dir") + "\\configuration\\database_configuration.properties"); PropertiesUtil.writePropertiesFile( "jdbc.databasename", database, System.getProperty("user.dir") + "\\configuration\\database_configuration.properties"); PropertiesUtil.writePropertiesFile( "jdbc.username", username, System.getProperty("user.dir") + "\\configuration\\database_configuration.properties"); PropertiesUtil.writePropertiesFile( "jdbc.password", password, System.getProperty("user.dir") + "\\configuration\\database_configuration.properties"); } catch (ClassNotFoundException e) { flag = false; e.printStackTrace(); logger.info(e.getMessage()); } catch (SQLException e) { flag = false; e.printStackTrace(); logger.info(e.getMessage()); } } }.start(); for (i = 1; i < max; i++) { try { Thread.sleep(150); } catch (Throwable e) { } display.asyncExec( new Runnable() { public void run() { progressBar.setSelection(i); Value = progressBar.getMaximum(); value = progressBar.getSelection(); text.setText(value + "%"); if (Value == value) { final Display dis = Display.getDefault(); @SuppressWarnings("unused") Shell sh = new Shell(dis); if (flag == false) { MessageDialog.openInformation(shell, "提示", "数据库参数有误,请核对"); } else { MessageDialog.openInformation(shell, "提示", "数据库参数配置正确,将重启软件"); try { Runtime.getRuntime() .exec( System.getProperty("user.dir") + "//APL.exe"); // 此处的exe文件名必须和打包生成的exe文件名一致 } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.exit(Value); } shell.dispose(); return; } } }); } } }.start(); shell.open(); shell.layout(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } }
private void loadOfflineImages() { if (OfflineLoadManager.isLoading()) { return; } final int selectedZoomLevel = _targetZoomLevels[_comboTargetZoom.getSelectionIndex()]; final int tileSize = _selectedMp.getTileSize(); final int worldStartX = _offlineWorldStart.x; final int worldStartY = _offlineWorldStart.y; final int worldEndX = _offlineWorldEnd.x; final int worldEndY = _offlineWorldEnd.y; double worldX1 = Math.min(worldStartX, worldEndX); double worldX2 = Math.max(worldStartX, worldEndX); double worldY1 = Math.min(worldStartY, worldEndY); double worldY2 = Math.max(worldStartY, worldEndY); for (int zoomLevel = _validMapZoomLevel; zoomLevel <= selectedZoomLevel; zoomLevel++) { final int maxMapTileSize = _selectedMp.getMapTileSize(zoomLevel).width; final int areaPixelWidth = (int) (worldX2 - worldX1); final int areaPixelHeight = (int) (worldY2 - worldY1); final int numTileWidth = (int) Math.ceil((double) areaPixelWidth / (double) tileSize); final int numTileHeight = (int) Math.ceil((double) areaPixelHeight / (double) tileSize); int tilePosMinX = (int) Math.floor(worldX1 / tileSize); int tilePosMinY = (int) Math.floor(worldY1 / tileSize); int tilePosMaxX = tilePosMinX + numTileWidth; int tilePosMaxY = tilePosMinY + numTileHeight; // ensure tiles are within the map tilePosMinX = Math.max(0, tilePosMinX); tilePosMinY = Math.max(0, tilePosMinY); tilePosMaxX = Math.min(tilePosMaxX, maxMapTileSize); tilePosMaxY = Math.min(tilePosMaxY, maxMapTileSize); for (int tilePosX = tilePosMinX; tilePosX <= tilePosMaxX; tilePosX++) { for (int tilePosY = tilePosMinY; tilePosY <= tilePosMaxY; tilePosY++) { // create offline tile final Tile offlineTile = new Tile(_selectedMp, zoomLevel, tilePosX, tilePosY, null); offlineTile.setBoundingBoxEPSG4326(); _selectedMp.doPostCreation(offlineTile); _offlineManager.addOfflineTile(_selectedMp, offlineTile); } } // set next zoom level, zoom into the map worldX1 *= 2; worldX2 *= 2; worldY1 *= 2; worldY2 *= 2; } // initialize progress bar _maxQueue = MP.getTileWaitingQueue().size(); _progbarQueue.setMaximum(_maxQueue); }
/** * Open the dialog. * * @return the result */ public Object open() { Display display = getParent().getDisplay(); shellww = new Shell(getParent(), 0); shellww.setSize(450, 316); { shell = LayoutUtils.centerDWdefult(shellww, "更新程序", true, false); } shell.setLayout(new FormLayout()); updatepro = new ProgressBar(shell, 0); FormData fd_updatepro = new FormData(); fd_updatepro.right = new FormAttachment(0, 406); fd_updatepro.top = new FormAttachment(0, 131); fd_updatepro.left = new FormAttachment(0, 127); updatepro.setLayoutData(fd_updatepro); updatepro.setMaximum(100); updatepro.setMinimum(0); Label label = new Label(shell, SWT.NONE); FormData fd_label = new FormData(); fd_label.right = new FormAttachment(0, 121); fd_label.top = new FormAttachment(0, 131); fd_label.left = new FormAttachment(0, 61); label.setLayoutData(fd_label); label.setText("下载进度"); Label label_1 = new Label(shell, SWT.NONE); FormData fd_label_1 = new FormData(); fd_label_1.right = new FormAttachment(0, 337); fd_label_1.top = new FormAttachment(0, 46); fd_label_1.left = new FormAttachment(0, 146); label_1.setLayoutData(fd_label_1); label_1.setText("下载完成将自动重启更新!"); begin = new Button(shell, SWT.NONE); FormData fd_begin = new FormData(); fd_begin.right = new FormAttachment(0, 166); fd_begin.top = new FormAttachment(0, 215); fd_begin.left = new FormAttachment(0, 98); begin.setLayoutData(fd_begin); begin.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { down(); } }); begin.setText("开 始"); cacel = new Button(shell, SWT.NONE); FormData fd_cacel = new FormData(); fd_cacel.right = new FormAttachment(0, 406); fd_cacel.top = new FormAttachment(0, 215); fd_cacel.left = new FormAttachment(0, 338); cacel.setLayoutData(fd_cacel); cacel.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { shellww.close(); } }); cacel.setText("取 消"); shellww.open(); shellww.layout(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return result; }
public static void main(String[] args) { final Display display = new Display(); final int[] count = new int[] {4}; final Image image = new Image(display, 300, 300); GC gc = new GC(image); gc.setBackground(display.getSystemColor(SWT.COLOR_CYAN)); gc.fillRectangle(image.getBounds()); gc.drawText("Splash Screen", 10, 10); gc.dispose(); final Shell splash = new Shell(SWT.ON_TOP); final ProgressBar bar = new ProgressBar(splash, SWT.NONE); bar.setMaximum(count[0]); Label label = new Label(splash, SWT.NONE); label.setImage(SWTResourceManager.getImage(SplashScreen.class, "/resources/splashep.png")); FormLayout layout = new FormLayout(); splash.setLayout(layout); FormData labelData = new FormData(); labelData.right = new FormAttachment(100, 0); labelData.bottom = new FormAttachment(100, 0); label.setLayoutData(labelData); FormData progressData = new FormData(); progressData.left = new FormAttachment(0, 5); progressData.right = new FormAttachment(100, -5); progressData.bottom = new FormAttachment(100, -5); bar.setLayoutData(progressData); splash.pack(); Rectangle splashRect = splash.getBounds(); Rectangle displayRect = display.getBounds(); int x = (displayRect.width - splashRect.width) / 2; int y = (displayRect.height - splashRect.height) / 2; splash.setLocation(x, y); splash.open(); display.asyncExec( new Runnable() { @Override public void run() { Shell[] shells = new Shell[count[0]]; for (int i = 0; i < count[0]; i++) { shells[i] = new Shell(display); shells[i].setSize(300, 300); shells[i].addListener( SWT.Close, new Listener() { @Override public void handleEvent(Event e) { --count[0]; } }); bar.setSelection(i + 1); try { Thread.sleep(1000); } catch (Throwable e) { } } splash.close(); image.dispose(); // Start Main Window MainWindow.main(null); } }); while (count[0] != 0) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
private void create() { shell = new Shell(SWT.APPLICATION_MODAL | SWT.CLOSE); shell.setText("Project File Restore/Replace"); shell.setMinimumSize(450, 250); GridLayout layout = new GridLayout(1, false); shell.setLayout(layout); layout.horizontalSpacing = 5; layout.verticalSpacing = 5; layout.makeColumnsEqualWidth = true; // Groups Group restoreGroup = new Group(shell, SWT.NONE); restoreGroup.setText("Restore/Replace"); restoreGroup.setLayout(new GridLayout(2, false)); Group statusGroup = new Group(shell, SWT.NONE); statusGroup.setText("Status"); statusGroup.setLayout(new GridLayout(1, false)); // Status box final ProgressBar progress = new ProgressBar(statusGroup, SWT.NONE); progress.setMaximum(100); progress.setMinimum(0); progress.setSelection(0); final Text status = new Text(statusGroup, SWT.MULTI | SWT.READ_ONLY | SWT.V_SCROLL); // Restore box final Text file = new Text(restoreGroup, SWT.SINGLE | SWT.BORDER); Button browse = new Button(restoreGroup, SWT.PUSH); browse.setText("Browse..."); final Combo symCombo = new Combo(restoreGroup, SWT.DROP_DOWN); for (int sym : Config.getSyms()) { symCombo.add("Sym " + sym); } Button doit = new Button(restoreGroup, SWT.PUSH); doit.setText("Replace"); browse.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { org.eclipse.swt.widgets.FileDialog f = new org.eclipse.swt.widgets.FileDialog(shell, SWT.OPEN); String fn = f.open(); if (fn != null) file.setText(fn); } }); doit.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { // Oh my god, error checking like this sucks. I am tempted to make an // "easy error dialog" static method... Imagine... // ErrorBox.open("Error: no file specified", "You must specify a file to continue"); // that would be so much nicer than this crappy 7 line method of doing it. if (file.getText() == null || !(new File(file.getText())).exists()) { MessageBox error = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR); error.setText("File Error"); error.setMessage("You must specify a file that exists."); error.open(); return; } if (symCombo.getSelectionIndex() == -1) { MessageBox error = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR); error.setText("Select a sym"); error.setMessage("You must select a sym"); error.open(); return; } int sym = Integer.parseInt(symCombo.getItem(symCombo.getSelectionIndex()).substring(4)); if (RepDevMain.SYMITAR_SESSIONS.get(sym).isConnected()) { MessageBox error = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR); error.setText("Not logged out"); error.setMessage( "You must log out of the sym that you want to restore your project file in"); error.open(); return; } progress.setSelection(10); status.setText(status.getText() + "Logging in to sym " + sym + "\r\n"); int err = SymLoginShell.symLogin(shell.getDisplay(), shell, sym); if (err != -1) { progress.setSelection(25); SymitarSession session = RepDevMain.SYMITAR_SESSIONS.get(sym); SymitarFile pf = new SymitarFile( sym, "repdev." + session.getUserID().substring(0, 3) + "projects", FileType.REPGEN); status.setText( status.getText() + "Replacing Project file for " + session.getUserID().substring(0, 3) + " on sym " + sym + "...\r\n"); try { progress.setSelection(40); File f = new File(file.getText()); FileReader project = new FileReader(f); char[] data = new char[(int) f.length()]; project.read(data); progress.setSelection(50); SessionError se = session.saveFile(pf, new String(data)); progress.setSelection(80); status.setText(status.getText() + "Finished, errors: " + se.toString() + "\r\n"); } catch (FileNotFoundException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } session.disconnect(); progress.setSelection(100); } } }); // restoreGroup's layout data GridData data = new GridData(SWT.FILL, SWT.TOP, true, false); restoreGroup.setLayoutData(data); file.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); symCombo.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); browse.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); doit.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); // inside of statusGroup... data = new GridData(SWT.FILL, SWT.TOP, true, false); progress.setLayoutData(data); data = new GridData(SWT.FILL, SWT.FILL, true, true); status.setLayoutData(data); // For the status group's layout stuff... data = new GridData(SWT.FILL, SWT.FILL, true, true); statusGroup.setLayoutData(data); restoreGroup.pack(); statusGroup.pack(); shell.pack(); shell.open(); }
/** * Create the shell. * * @param display */ public MainUI(Display display) { super(display, SWT.SHELL_TRIM); Menu menu = new Menu(this, SWT.BAR); setMenuBar(menu); MenuItem mntmBuscar = new MenuItem(menu, SWT.CASCADE); mntmBuscar.setText("Buscar"); Menu menu_1 = new Menu(mntmBuscar); mntmBuscar.setMenu(menu_1); MenuItem mntmMilanuncioscom = new MenuItem(menu_1, SWT.NONE); mntmMilanuncioscom.setText("MilAnuncios.com"); progressBar = new ProgressBar(this, SWT.NONE); progressBar.setBounds(10, 2, 545, 25); progressBar.setMaximum(11); // Este valor deberia ser dinamico Composite composite = new Composite(this, SWT.NONE); composite.setBounds(0, 33, 684, 408); tableReport = new Table(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.CHECK); tableReport.setBounds(0, 0, 681, 408); tableReport.setHeaderVisible(true); tableReport.setLinesVisible(true); TableColumn colNombre = new TableColumn(tableReport, SWT.NONE); colNombre.setWidth(378); colNombre.setText("Nombre"); TableColumn colUrl = new TableColumn(tableReport, SWT.NONE); colUrl.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { SelectionEvent evento = e; String txt = evento.text; System.out.println(txt); } }); colUrl.setWidth(68); colUrl.setText("URL"); TableColumn tblclmnTelefono = new TableColumn(tableReport, SWT.NONE); tblclmnTelefono.setWidth(131); tblclmnTelefono.setText("telefono"); mntmMilanuncioscom.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { for (String url : UrlsJobScrapper.MILANUNCIOSURLS) { nomEvento = "onPaintTable"; currentUrl = url; run(); } // } }); Button btnNewButton = new Button(this, SWT.NONE); btnNewButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { int totalFilas = tableReport.getItemCount(); int filaSelected = -1; tableReport.isSelected(0); for (int x = 0; x < totalFilas; x++) { TableItem fila = tableReport.getItem(x); boolean selected = fila.getChecked(); if (selected) { nomEvento = "onGoUrl"; currentUrl = fila.getText( 1); // <-- no se si saca toda la fila , o solo una columna de la fila run(); } } } }); btnNewButton.setBounds(561, 2, 113, 25); btnNewButton.setText("Ir a ..."); createContents(); }