public void testRenderIncrement() throws IOException { Scale scale = new Scale(shell, SWT.NONE); scale.setIncrement(2); lca.renderChanges(scale); Message message = Fixture.getProtocolMessage(); assertEquals(new Integer(2), message.findSetProperty(scale, "increment")); }
public void testRenderIncrementUnchanged() throws IOException { Scale scale = new Scale(shell, SWT.NONE); Fixture.markInitialized(display); Fixture.markInitialized(scale); scale.setIncrement(2); Fixture.preserveWidgets(); lca.renderChanges(scale); Message message = Fixture.getProtocolMessage(); assertNull(message.findSetOperation(scale, "increment")); }
/** {@inheritDoc} */ public Composite createControls(Composite parent, FormToolkit toolkit) { Section section = toolkit.createSection(parent, Section.TITLE_BAR); section.setText("Sampling Rate"); section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); Composite composite = toolkit.createComposite(section); section.setClient(composite); GridLayout layout = new GridLayout(4, false); layout.marginLeft = 10; layout.horizontalSpacing = 10; composite.setLayout(layout); GridData gridData = new GridData(SWT.MAX, SWT.DEFAULT); gridData.grabExcessHorizontalSpace = true; composite.setLayoutData(gridData); final Label sliderLabel = toolkit.createLabel(composite, "no sensitivity selected", SWT.LEFT); GridData data = new GridData(SWT.FILL, SWT.FILL, false, false); data.widthHint = sliderLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).x; sliderLabel.setLayoutData(data); slider = new Scale(composite, SWT.HORIZONTAL); toolkit.adapt(slider, true, true); slider.setMinimum(0); slider.setMaximum(Sensitivity.values().length - 1); slider.setIncrement(1); slider.setSize(200, 10); slider.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); slider.addSelectionListener( new SelectionAdapter() { /** {@inheritDoc} */ @Override public void widgetSelected(SelectionEvent event) { Sensitivity sensitivity = Sensitivity.fromOrd(slider.getSelection()); switch (sensitivity) { case NO_SENSITIVITY: sliderLabel.setText("no sensitivity selected"); break; case VERY_FINE: sliderLabel.setText("very fine"); break; case FINE: sliderLabel.setText("fine"); break; case MEDIUM: sliderLabel.setText("medium"); break; case COARSE: sliderLabel.setText("coarse"); break; case VERY_COARSE: sliderLabel.setText("very coarse"); break; default: break; } } }); slider.setSelection(DEFAULT_SENSITIVITY.ordinal()); slider.notifyListeners(SWT.Selection, null); Label modeLabel = toolkit.createLabel(composite, "Sampling Rate Mode: ", SWT.LEFT); modeLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); timeframeModeButton = toolkit.createButton(composite, "Timeframe dividing", SWT.RADIO); timeframeModeButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); timeframeModeButton.setSelection(true); return composite; }
public RoomDataComposite(Composite parent, RoomController control) { super(parent, SWT.NONE); setLayout(new GridLayout(3, false)); this.roomC = control; container = Manager.getCurrentShip(); final ShipController shipC = container.getShipController(); label = new Label(this, SWT.NONE); label.setAlignment(SWT.CENTER); label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1)); label.setText("Room"); Label separator = new Label(this, SWT.SEPARATOR | SWT.HORIZONTAL); separator.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1)); Label lblSystem = new Label(this, SWT.NONE); lblSystem.setText("System: "); btnSystem = new Button(this, SWT.NONE); GridData gd_btnSystem = new GridData(SWT.RIGHT, SWT.CENTER, true, false, 2, 1); gd_btnSystem.widthHint = 100; btnSystem.setLayoutData(gd_btnSystem); btnSystem.setText(""); btnAvailable = new Button(this, SWT.CHECK); btnAvailable.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 3, 1)); btnAvailable.setText("Available At Start"); lblSysLevel = new Label(this, SWT.NONE); lblSysLevel.setText("Starting Level:"); scaleSysLevel = new Scale(this, SWT.NONE); scaleSysLevel.setMaximum(2); scaleSysLevel.setMinimum(1); scaleSysLevel.setPageIncrement(1); scaleSysLevel.setIncrement(1); scaleSysLevel.setSelection(1); scaleSysLevel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1)); txtSysLevel = new Text(this, SWT.BORDER | SWT.READ_ONLY); txtSysLevel.setText(""); txtSysLevel.setTextLimit(3); GridData gd_txtSysLevel = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1); gd_txtSysLevel.widthHint = 20; txtSysLevel.setLayoutData(gd_txtSysLevel); scaleSysLevel.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Systems sys = container.getActiveSystem(roomC.getGameObject()); SystemController system = container.getSystemController(sys); system.setLevel(scaleSysLevel.getSelection()); txtSysLevel.setText("" + scaleSysLevel.getSelection()); } }); if (!Manager.getCurrentShip().getShipController().isPlayerShip()) { lblMaxLevel = new Label(this, SWT.NONE); lblMaxLevel.setText("Max Level:"); scaleMaxLevel = new Scale(this, SWT.NONE); scaleMaxLevel.setMaximum(2); scaleMaxLevel.setMinimum(1); scaleMaxLevel.setPageIncrement(1); scaleMaxLevel.setIncrement(1); scaleMaxLevel.setSelection(1); scaleMaxLevel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1)); txtMaxLevel = new Text(this, SWT.BORDER | SWT.READ_ONLY); txtMaxLevel.setText(""); txtMaxLevel.setTextLimit(3); GridData gd_txtMaxLevel = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1); gd_txtMaxLevel.widthHint = 20; txtMaxLevel.setLayoutData(gd_txtMaxLevel); scaleMaxLevel.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Systems sys = container.getActiveSystem(roomC.getGameObject()); SystemController system = container.getSystemController(sys); system.setLevelMax(scaleMaxLevel.getSelection()); txtMaxLevel.setText("" + scaleMaxLevel.getSelection()); if (!shipC.isPlayerShip()) { scaleSysLevel.setMaximum(scaleMaxLevel.getSelection()); scaleSysLevel.notifyListeners(SWT.Selection, null); scaleSysLevel.setEnabled(scaleMaxLevel.getSelection() > 1); scaleSysLevel.setSelection( Math.min(scaleSysLevel.getSelection(), scaleSysLevel.getMaximum())); } } }); } else { imagesComposite = new Composite(this, SWT.NONE); GridLayout gl_imagesComposite = new GridLayout(4, false); gl_imagesComposite.marginHeight = 0; gl_imagesComposite.marginWidth = 0; imagesComposite.setLayout(gl_imagesComposite); imagesComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 3, 1)); // Interior widgets Label lblInterior = new Label(imagesComposite, SWT.NONE); lblInterior.setText("Interior image:"); btnInteriorView = new Button(imagesComposite, SWT.NONE); btnInteriorView.setEnabled(false); btnInteriorView.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1)); btnInteriorView.setText("View"); btnInteriorBrowse = new Button(imagesComposite, SWT.NONE); btnInteriorBrowse.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); btnInteriorBrowse.setText("Browse"); btnInteriorClear = new Button(imagesComposite, SWT.NONE); btnInteriorClear.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); btnInteriorClear.setText("Reset"); txtInterior = new Text(imagesComposite, SWT.BORDER | SWT.READ_ONLY); txtInterior.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 4, 1)); // Glow widgets lblGlow = new Label(imagesComposite, SWT.NONE); lblGlow.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblGlow.setText("Manning glow:"); btnGlow = new Button(imagesComposite, SWT.NONE); GridData gd_btnGlow = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 3, 1); gd_btnGlow.widthHint = 120; btnGlow.setLayoutData(gd_btnGlow); btnGlow.setText("None"); SelectionAdapter imageViewListener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Systems sys = container.getActiveSystem(roomC.getGameObject()); SystemController system = container.getSystemController(sys); File file = new File(system.getInteriorPath()); if (file != null && file.exists()) { if (Desktop.isDesktopSupported()) { Desktop desktop = Desktop.getDesktop(); if (desktop != null) { try { desktop.open(file.getParentFile()); } catch (IOException ex) { } } } else { Superluminal.log.error( "Unable to open file location - AWT Desktop not supported."); } } } }; btnInteriorView.addSelectionListener(imageViewListener); SelectionAdapter imageBrowseListener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Systems sys = container.getActiveSystem(roomC.getGameObject()); SystemController system = container.getSystemController(sys); FileDialog dialog = new FileDialog(EditorWindow.getInstance().getShell()); dialog.setFilterExtensions(new String[] {"*.png"}); String path = dialog.open(); // path == null only when user cancels if (path != null) { system.setInteriorPath("file:" + path); updateData(); } } }; btnInteriorBrowse.addSelectionListener(imageBrowseListener); SelectionAdapter imageClearListener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Systems sys = container.getActiveSystem(roomC.getGameObject()); SystemController system = container.getSystemController(sys); system.setInteriorPath(null); updateData(); } }; btnInteriorClear.addSelectionListener(imageClearListener); btnGlow.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Systems sys = container.getActiveSystem(roomC.getGameObject()); SystemObject systemObject = container.getSystemController(sys).getGameObject(); GlowSelectionDialog dialog = new GlowSelectionDialog(EditorWindow.getInstance().getShell()); GlowSet glowSet = dialog.open(systemObject); if (glowSet != null) { btnGlow.setText(glowSet.getIdentifier()); systemObject.setGlowSet(glowSet); } } }); } btnSystem.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Point p = btnSystem.getLocation(); SystemsMenu sysMenu = SystemsMenu.getInstance(); sysMenu.setLocation(toDisplay(p.x, p.y + btnSystem.getSize().y)); sysMenu.open(); } }); btnAvailable.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Systems sys = container.getActiveSystem(roomC.getGameObject()); SystemController system = container.getSystemController(sys); system.setAvailableAtStart(btnAvailable.getSelection()); roomC.redraw(); } }); updateData(); pack(); }
private void initialize(Composite parentComposite) { // Create logging composite under parent composite Composite loggingComposite = new Composite(parentComposite, SWT.NONE); loggingComposite.setLayout(new GridLayout(5, false)); loggingComposite.setLayoutData(new GridData(SWT.BEGINNING)); // 1. Log category label CLabel logCategoryLabel = new CLabel(loggingComposite, SWT.NONE); logCategoryLabel.setText("Log category:"); logCategoryLabel.setLayoutData(new GridData(SWT.BEGINNING)); // 2. Log categories list logCategoryCombo = new Combo(loggingComposite, SWT.DROP_DOWN | SWT.READ_ONLY); logCategoryCombo.setEnabled(false); populateLogCategory(); logCategoryCombo.addSelectionListener( new org.eclipse.swt.events.SelectionListener() { @Override public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { String logCategoryText = ((Combo) e.widget).getText(); handleLogCategoryChange(LogCategoryExt.fromExternalValue(logCategoryText)); } private void handleLogCategoryChange(LogCategoryExt logCategoryExt) { // fchang: hook for display diff log category w/o requesting server again. - per bill: // not possible // w/o refactoring server-side code. logLevelScale.setEnabled(true); // enable scale only after logCategory is set. LoggingInfo loggingInfo = loggingService.getLoggingInfoByCategory( project, logCategoryExt, supportedFeatureEnum); setLoggingInfo(loggingInfo); } @Override public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {} }); // 3. Log level label CLabel logLevel = new CLabel(loggingComposite, SWT.NONE); logLevel.setText("Log level: --"); logLevel.setLayoutData(new GridData(SWT.BEGINNING)); // 4. Log levels scale logLevelScale = new Scale(loggingComposite, SWT.NULL); logLevelScale.setIncrement(1); logLevelScale.setMaximum(7); logLevelScale.setEnabled(false); logLevelScale.setPageIncrement(1); logLevelScale.setLayoutData(new GridData(SWT.BEGINNING)); logLevelScale.addListener( SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { LoggingInfo loggingInfo = LoggingInfo.getLoggingInfo( logLevelScale.getSelection(), logCategoryCombo.getText()); loggingService.setLoggingInfo(project, loggingInfo, supportedFeatureEnum); logLevelDesc.setText(PLUS_PREFIX + loggingInfo.getLevelLabelText()); layout(true, true); } }); // 5. Log level description label logLevelDesc = new CLabel(loggingComposite, SWT.NONE); logLevelDesc.setText(INIT_PLUS_PREFIX); GridData logLevelDescGd = new GridData(); logLevelDesc.setLayoutData(logLevelDescGd); }