org.eclipse.swt.events.SelectionAdapter Java Examples

The following examples show how to use org.eclipse.swt.events.SelectionAdapter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RotatedTextBuilder.java    From birt with Eclipse Public License 1.0 9 votes vote down vote up
protected void createTextArea( Composite parent )
{
	Label lb = new Label( parent, SWT.None );
	lb.setText( "Text Content:" ); //$NON-NLS-1$

	txtText = new Text( parent, SWT.BORDER );
	GridData gd = new GridData( GridData.FILL_HORIZONTAL );
	txtText.setLayoutData( gd );

	Button btnExp = new Button( parent, SWT.PUSH );
	btnExp.setText( "..." ); //$NON-NLS-1$
	btnExp.setToolTipText( "Invoke Expression Builder" ); //$NON-NLS-1$

	btnExp.addSelectionListener( new SelectionAdapter( ) {

		public void widgetSelected( SelectionEvent event )
		{
			openExpression( txtText );
		}
	} );

}
 
Example #2
Source File: RadioTab.java    From hop with Apache License 2.0 8 votes vote down vote up
public Composite createContent( String radioText ) {
  Control[] existingButtons = radioGroup.getChildren();
  Button button = new Button( radioGroup, SWT.RADIO );
  button.setText( radioText );
  props.setLook( button );
  FormData fdButton = new FormData();
  fdButton.top = new FormAttachment( 0 );
  fdButton.left = existingButtons.length == 0
    ? new FormAttachment( 0 ) : new FormAttachment( existingButtons[ existingButtons.length - 1 ], 40 );
  button.setLayoutData( fdButton );
  button.setSelection( existingButtons.length == 0 );
  Composite content = new Composite( contentArea, SWT.NONE );
  content.setVisible( existingButtons.length == 0 );
  props.setLook( content );
  content.setLayout( noMarginLayout );
  content.setLayoutData( fdMaximize );
  button.addSelectionListener( new SelectionAdapter() {
    @Override public void widgetSelected( SelectionEvent selectionEvent ) {
      for ( Control control : contentArea.getChildren() ) {
        control.setVisible( false );
      }
      content.setVisible( true );
    }
  } );
  return content;
}
 
Example #3
Source File: SelectVariableDialog.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected Control createDialogArea( Composite parent )
{
	Composite content = new Composite( parent, SWT.NONE );
	content.setLayoutData( GridDataFactory.swtDefaults( ).hint( 300,
			SWT.DEFAULT ).create( ) );
	content.setLayout( GridLayoutFactory.swtDefaults( )
			.numColumns( 2 )
			.margins( 15, 15 )
			.create( ) );
	new Label( content, SWT.NONE ).setText( Messages.getString("SelectVariableDialog.AvailableVariables") ); //$NON-NLS-1$
	variablesCombo = new Combo( content, SWT.READ_ONLY );
	variablesCombo.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
	variablesCombo.setVisibleItemCount( 30 );
	variablesCombo.addSelectionListener( new SelectionAdapter( ) {

		public void widgetSelected( SelectionEvent e )
		{
			validate( );
		}
	} );
	UIUtil.bindHelp( parent, IHelpContextIds.SELECT_VARIABLE_DIALOG_ID );
	return content;
}
 
Example #4
Source File: CheckBoxGroup.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private void createCheckBoxButton() {
	button = new Button(this, SWT.CHECK);
	final GridData gdButton = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
	gdButton.horizontalIndent = 15;
	button.setLayoutData(gdButton);
	button.setSelection(true);
	button.pack();

	button.addSelectionListener(new SelectionAdapter() {
		/**
		 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
		 */
		@Override
		public void widgetSelected(final SelectionEvent e) {
			e.doit = fireSelectionListeners(e);
			if (!e.doit) {
				return;
			}
			if (button.getSelection()) {
				activate();
			} else {
				deactivate();
			}
		}
	});
}
 
Example #5
Source File: ContactSorterSwitcher.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void fill(Menu menu, int index){
	for (final ContactSelectorViewerComparator.sorter sortMethod : ContactSelectorViewerComparator.sorter
		.values()) {
		MenuItem temp = new MenuItem(menu, SWT.CHECK, index);
		temp.setData(sortMethod);
		temp.setText(sortMethod.label);
		temp.setSelection(ContactSelectorViewerComparator.getSelectedSorter()
			.equals(sortMethod));
		temp.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e){
				ContactSelectorViewerComparator.setSelectedSorter(sortMethod);
			}
		});
	}
}
 
Example #6
Source File: PromptDialog.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create contents of the dialog.
 * @param parent
 */
@Override
protected Control createDialogArea(Composite parent) {
	Composite container = (Composite) super.createDialogArea(parent);

	Label label = new Label(container, SWT.NONE);
	label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
	label.setText(Messages.getString("dialog.PromptDialog.label"));

	for (String toolId : toolIds) {
		final Button btn = new Button(container, SWT.RADIO);
		btn.setText(toolId);
		btn.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
		btn.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				if (btn.getSelection()) {
					choiceResult = btn.getText();
				}
			}
		});
	}

	return container;
}
 
Example #7
Source File: ColumnsSnippet.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private static void createForceSelection(final Shell shell, final ColumnBrowserWidget cbw, final ColumnItem item) {
	final Button button = new Button(shell, SWT.PUSH);
	button.setLayoutData(new GridData(GridData.END, GridData.FILL, false, false));
	button.setText("Force selection");

	button.addSelectionListener(new SelectionAdapter() {

		/**
		 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
		 */
		@Override
		public void widgetSelected(final SelectionEvent e) {
			cbw.select(item);
		}
	});

}
 
Example #8
Source File: ChangeParametersControl.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private Button createEditButton(Composite buttonComposite) {
	Button button= new Button(buttonComposite, SWT.PUSH);
	button.setText(RefactoringMessages.ChangeParametersControl_buttons_edit);
	button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	SWTUtil.setButtonDimensionHint(button);
	button.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			try {
				ParameterInfo[] selected= getSelectedElements();
				Assert.isTrue(selected.length == 1);
				ParameterInfo parameterInfo= selected[0];
				ParameterEditDialog dialog= new ParameterEditDialog(getShell(), parameterInfo, fMode.canChangeTypes(), fMode.canChangeDefault(), fTypeContext);
				dialog.open();
				fListener.parameterChanged(parameterInfo);
				fTableViewer.update(parameterInfo, PROPERTIES);
			} finally {
				fTableViewer.getControl().setFocus();
			}
		}
	});
	return button;
}
 
Example #9
Source File: NodeStatsViewPart.java    From depan with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unused")
private Group setupOptions(Composite parent) {
  Group result = Widgets.buildGridGroup(parent, "Statistics Options", 2);

  Label relSetLabel = Widgets.buildCompactLabel(result, "Edges: ");
  matcherChoice = new EdgeMatcherSelectorControl(result);
  matcherChoice.setLayoutData(Widgets.buildHorzFillData());

  Button updateBtn = Widgets.buildCompactPushButton(
      result, "Update Statistics");
  GridData updateLayout = Widgets.getLayoutData(updateBtn);
  updateLayout.horizontalSpan = 2;
  updateLayout.horizontalAlignment = SWT.TRAIL;
  updateBtn.addSelectionListener(new SelectionAdapter() {

    @Override
    public void widgetSelected(SelectionEvent e) {
      updateStats();
    }
  });

  return result;
}
 
Example #10
Source File: TabPageNewLines.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
private void mkChkbox(final NewlineSetting ss, int initValue, final boolean isBefore) {
// initValue: 0 - don't insert, remove if any
//            1,2.. lines to insert, 
//            -1 - do nothing
//            -2 - don't show control
// Now we use only -1, 1 or -2 (but formatter may support all)         
    if (initValue == -1 || initValue == 1) {
        final Button cb = SWTFactory.createCheckbox(fPropsGroup,
                isBefore ? Messages.TabPageNewLines_InsNewlineBefore
                         : Messages.TabPageNewLines_InsNewlineAfter, 2);
        optsControls.add(cb);
        cb.setSelection(initValue == 1);
        cb.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                int val = cb.getSelection() ? 1 : -1;
                if (isBefore) {
                    fp.setInsNewLineBefore(ss, val);
                } else {
                    fp.setInsNewLineAfter(ss, val);
                }
                fPreview.setProfile(fp);
            }
        });
    }
}
 
Example #11
Source File: NodeFilterViewPart.java    From depan with Apache License 2.0 6 votes vote down vote up
@Override
protected Composite createCommands(Composite parent) {
  Composite result = Widgets.buildGridContainer(parent, 1);
  Button compute = Widgets.buildCompactPushButton(
      result, "Compute Results");

  compute.addSelectionListener(new SelectionAdapter() {

    @Override
    public void widgetSelected(SelectionEvent e) {
      updateResults();
    }
  });

  return result;
}
 
Example #12
Source File: SortMembersMessageDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private Control createLinkControl(Composite composite) {
	Link link= new Link(composite, SWT.WRAP | SWT.RIGHT);
	link.setText(DialogsMessages.SortMembersMessageDialog_description);
	link.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			openMembersSortOrderPage();
		}
	});
	link.setToolTipText(DialogsMessages.SortMembersMessageDialog_link_tooltip);
	GridData gridData= new GridData(GridData.FILL, GridData.CENTER, true, false);
	gridData.widthHint= convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);//convertWidthInCharsToPixels(60);
	link.setLayoutData(gridData);
	link.setFont(composite.getFont());

	return link;
}
 
Example #13
Source File: ReportConfigurationTab.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void createPriorityGroup(Composite parent) {
    Composite prioGroup = new Composite(parent, SWT.NONE);
    prioGroup.setLayout(new GridLayout(2, false));

    Label minPrioLabel = new Label(prioGroup, SWT.NONE);
    minPrioLabel.setText(getMessage("property.minPriority"));
    minPrioLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));

    minPriorityCombo = new Combo(prioGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
    minPriorityCombo.add(ProjectFilterSettings.HIGH_PRIORITY);
    minPriorityCombo.add(ProjectFilterSettings.MEDIUM_PRIORITY);
    minPriorityCombo.add(ProjectFilterSettings.LOW_PRIORITY);
    minPriorityCombo.setText(propertyPage.getOriginalUserPreferences().getFilterSettings().getMinPriority());
    minPriorityCombo.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
    minPriorityCombo.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent event) {
            String data = minPriorityCombo.getText();
            getCurrentProps().getFilterSettings().setMinPriority(data);
        }
    });


}
 
Example #14
Source File: DocumentWizardPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private Button createRadioButtonMultiple(final Composite compo) {
    final Button radioButtonMultiple = new Button(compo, SWT.RADIO);
    radioButtonMultiple.setText(Messages.radioButtonMultiple);
    radioButtonMultiple.setLayoutData(GridDataFactory.swtDefaults().create());
    final ControlDecoration infoBonita = new ControlDecoration(radioButtonMultiple, SWT.RIGHT);
    infoBonita.show();
    infoBonita.setImage(Pics.getImage(PicsConstants.hint));
    infoBonita.setDescriptionText(Messages.radioButtonMultipleToolTip);

    radioButtonMultiple.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            if (radioButtonMultiple.getSelection()) {
                updateSingleMultipleStack(true);
            }
        }
    });
    return radioButtonMultiple;
}
 
Example #15
Source File: DirectoryDialogButtonListenerFactory.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public static final SelectionAdapter getSelectionAdapter( final Shell shell, final Text destination ) {
  // Listen to the Browse... button
  return new SelectionAdapter() {
    public void widgetSelected( SelectionEvent e ) {
      DirectoryDialog dialog = new DirectoryDialog( shell, SWT.OPEN );
      if ( destination.getText() != null ) {
        String fpath = destination.getText();
        // String fpath = StringUtil.environmentSubstitute(destination.getText());
        dialog.setFilterPath( fpath );
      }

      if ( dialog.open() != null ) {
        String str = dialog.getFilterPath();
        destination.setText( str );
      }
    }
  };
}
 
Example #16
Source File: EditorMenu.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
private void createOverviewToggle(final Menu menu) {
	final MenuItem overview = new MenuItem(menu, SWT.CHECK);
	overview.setText(" Show markers overview");
	overview.setSelection(getEditor().isOverviewRulerVisible());
	overview.setImage(GamaIcons.create("toggle.overview").image());
	overview.addSelectionListener(new SelectionAdapter() {

		@Override
		public void widgetSelected(final SelectionEvent e) {
			final boolean shown = getEditor().isOverviewRulerVisible();
			if (shown) {
				getEditor().hideOverviewRuler();
			} else {
				getEditor().showOverviewRuler();
			}
		}
	});

}
 
Example #17
Source File: ModifyDialogTabPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Create a new CheckboxPreference.
 * @param composite The composite on which the SWT widgets are added.
 * @param numColumns The number of columns in the composite's GridLayout.
 * @param preferences The map to store the values.
 * @param key The key to store the values.
 * @param values An array of two elements indicating the values to store on unchecked/checked.
 * @param text The label text for this Preference.
 * @param style SWT style flag for the button
 */
public ButtonPreference(Composite composite, int numColumns,
						  Map<String, String> preferences, String key,
						  String [] values, String text, int style) {
    super(preferences, key);
    if (values == null || text == null)
        throw new IllegalArgumentException(FormatterMessages.ModifyDialogTabPage_error_msg_values_text_unassigned);
	fValues= values;

	fCheckbox= new Button(composite, style);
	fCheckbox.setText(text);
	fCheckbox.setLayoutData(createGridData(numColumns, GridData.FILL_HORIZONTAL, SWT.DEFAULT));
	fCheckbox.setFont(composite.getFont());

	updateWidget();

	fCheckbox.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			checkboxChecked(((Button)e.widget).getSelection());
		}
	});
}
 
Example #18
Source File: PluginConfigManageDialog.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
private void createSwitchCmp(Composite tparent) {
	Composite cmp = new Composite(tparent, SWT.NONE);
	GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(cmp);
	GridLayoutFactory.swtDefaults().numColumns(3).applyTo(cmp);

	Label switchLbl = new Label(cmp, SWT.NONE);
	switchLbl.setText(Messages.getString("dialog.PluginConfigManageDialog.switchLbl"));

	switchTxt = new Text(cmp, SWT.BORDER);
	GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(switchTxt);

	switchBrowseBtn = new Button(cmp, SWT.NONE);
	switchBrowseBtn.setText(Messages.getString("dialog.PluginConfigManageDialog.switchBrowseBtn"));
	switchBrowseBtn.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			String fileLocation = browseFile(Messages.getString("dialog.PluginConfigManageDialog.dialogTitle2"),
					null, null);
			switchTxt.setText(fileLocation == null ? "" : fileLocation);
		}
	});
}
 
Example #19
Source File: StyleListFieldEditor.java    From texlipse with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates and returns the contents of an area of the dialog which appears
 * below the message and above the button bar.
 * 
 * This implementation creates two labels and two textfields.
 * 
 * @param parent parent composite to contain the custom area
 * @return the custom area control, or <code>null</code>
 */
protected Control createCustomArea(Composite parent) {
    
    Composite composite = new Composite(parent, SWT.NULL);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    composite.setLayout(new GridLayout());
    
    skVarList = new List(composite, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    skVarList.setLayoutData(new GridData(GridData.FILL_BOTH));
    skVarList.setItems(items);
    skVarList.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            selections = skVarList.getSelectionIndices();
        }});
    
    return composite;
}
 
Example #20
Source File: ImageBuilder.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private void buildEmbeddedImageList( )
{
	embeddedImageList = new List( inputArea, SWT.NONE
			| SWT.SINGLE
			| SWT.BORDER
			| SWT.V_SCROLL
			| SWT.H_SCROLL );
	embeddedImageList.setLayoutData( new GridData( GridData.FILL_BOTH ) );
	embeddedImageList.addSelectionListener( new SelectionAdapter( ) {

		public void widgetSelected( SelectionEvent event )
		{
			preview( );
			modifyDialogContent( );
			updateButtons( );
		}
	} );

	initList( );
}
 
Example #21
Source File: ConfigureCoolbarItem.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void fill(final ToolBar toolbar, final int index, final int iconSize) {
    final ToolItem item = new ToolItem(toolbar, SWT.PUSH);
    item.setToolTipText(Messages.ConfigureButtonLabel);
    item.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, SWTBotConstants.SWTBOT_ID_CONFIGURE_TOOLITEM);
    if (iconSize < 0) {
        item.setImage(Pics.getImage(PicsConstants.coolbar_configure_48));
        item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_configure_disabled_48));
    } else {
        item.setImage(Pics.getImage(PicsConstants.coolbar_configure_16));
        item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_configure_disabled_16));
    }
    item.setEnabled(false);
    item.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            final Command cmd = getCommand();
            try {
                cmd.executeWithChecks(new ExecutionEvent());
            } catch (final Exception ex) {
                BonitaStudioLog.error(ex);
            }
        }
    });
}
 
Example #22
Source File: CustomFiltersActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
		public void fill(Menu menu, int index) {
			MenuItem mi= new MenuItem(menu, SWT.CHECK, index);
			mi.setText("&" + fItemNumber + " " + fFilterName);  //$NON-NLS-1$  //$NON-NLS-2$
			/*
			 * XXX: Don't set the image - would look bad because other menu items don't provide image
			 * XXX: Get working set specific image name from XML - would need to cache icons
			 */
//			mi.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_JAVA_WORKING_SET));
			mi.setSelection(fState);
			mi.addSelectionListener(new SelectionAdapter() {
				@Override
				public void widgetSelected(SelectionEvent e) {
					fState= !fState;
					fActionGroup.setFilter(fFilterId, fState);
				}
			});
		}
 
Example #23
Source File: TransitionManager.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Constructs a transition manager to handle transitions on the provided
 * transitionable object.
 * @param transitionable the transitionable object to perform transitions on
 */
public TransitionManager(final Transitionable transitionable) {
    
    _transitionable = transitionable;
    _listeners      = new ArrayList<TransitionListener>();
    backgroundColor = Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
    
    //the selected item before the one to be transitioned to
    _lastItem       = transitionable.getSelection();
    
    transitionable.addSelectionListener(new SelectionAdapter() {
    public void widgetSelected(SelectionEvent event) {
    try {
        //the item to be transitioned to
        int currentItem = _transitionable.getSelection();
        
        startTransition(_lastItem, currentItem, transitionable.getDirection(currentItem, _lastItem));
        
        //now the item transition ends on will be used
        //to start transition from next time
        _lastItem = currentItem;
    } catch(Exception e) { e.printStackTrace(); }
    }});
}
 
Example #24
Source File: DetailsPart.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
private void createButton ( final Composite parent )
{
    this.wrapper = new Composite ( parent, SWT.NONE );
    final GridLayout layout = new GridLayout ( 1, true );
    layout.marginHeight = layout.marginWidth = 0;
    this.wrapper.setLayout ( layout );

    this.startButton = new Button ( this.wrapper, SWT.PUSH );
    this.startButton.setLayoutData ( new GridData ( SWT.CENTER, SWT.CENTER, true, true ) );
    this.startButton.setText ( Messages.DetailsPart_startButton_label );
    this.startButton.addSelectionListener ( new SelectionAdapter () {
        @Override
        public void widgetSelected ( final SelectionEvent e )
        {
            try
            {
                start ();
            }
            catch ( final Exception ex )
            {
                logger.error ( "Failed to start chart", ex ); //$NON-NLS-1$
                StatusManager.getManager ().handle ( StatusHelper.convertStatus ( Activator.PLUGIN_ID, ex ), StatusManager.BLOCK );
            }
        }
    } );
}
 
Example #25
Source File: ViewCostBenefitModel.java    From arx with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an input field
 * @param caption
 * @param callback
 * @return
 */
private Text createInputField(String caption, final Callback<Double> callback) {

    // Label
    Label label = new Label(root, SWT.NONE);
    label.setText(caption); 
    
    // Text field
    final Text text = new Text(root, SWT.BORDER | SWT.SINGLE);
    text.setText("0"); //$NON-NLS-1$
    text.setToolTipText("0"); //$NON-NLS-1$
    text.setLayoutData(SWTUtil.createFillHorizontallyGridData());
    text.setEditable(false);
    
    // Button
    Button btn1 = new Button(root, SWT.FLAT);
    btn1.setText(Resources.getMessage("ViewCostBenefitModel.0")); //$NON-NLS-1$
    btn1.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent arg0) {
            String value = controller.actionShowInputDialog(root.getShell(), 
                                                            Resources.getMessage("ViewCostBenefitModel.5"),  //$NON-NLS-1$
                                                            Resources.getMessage("ViewCostBenefitModel.6"),  //$NON-NLS-1$
                                                            text.getToolTipText(), 
                                                            validator);
            if (value != null) {
                callback.call(Double.valueOf(value));
                update();
            }
        }
    });
    
    // Return
    return text;
}
 
Example #26
Source File: SnippetCompositeTableDataBinding.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private void doLayout() {
	setLayout(new FormLayout());

	table = new CompositeTable(this, SWT.NULL);
	table.setBackground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
	new Header(table, SWT.NULL);
	new Row(table, SWT.NULL);

	addNew = new Button(this, SWT.NONE);
	addNew.setText("Add new Hero");
	addNew.addSelectionListener(new SelectionAdapter() {

		@Override
		public void widgetSelected(SelectionEvent e) {
			PersonTitleAreaDialog d = new PersonTitleAreaDialog(getShell());
			d.open();
			final int result = d.getReturnCode();
			if (result == Window.OK) {
				Hero p = d.getHero();
				getModel().addHero(p);
			}
		}
	});

	FormData data = new FormData();
	data.left = new FormAttachment(0, 100, 5);
	data.right = new FormAttachment(100, 100, -5);
	data.top = new FormAttachment(0, 100, 5);
	data.bottom = new FormAttachment(addNew, -5, SWT.TOP);
	table.setLayoutData(data);
	table.setRunTime(true);

	data = new FormData();
	data.right = new FormAttachment(100, 100, -5);
	data.bottom = new FormAttachment(100, 100, -5);
	addNew.setLayoutData(data);
}
 
Example #27
Source File: EditAllAttributesDialog.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
private Combo createTypeCombo(NormalColumn targetColumn) {
	GridData gridData = new GridData();
	gridData.widthHint = 100;

	final Combo typeCombo = new Combo(this.attributeTable, SWT.READ_ONLY);
	initializeTypeCombo(typeCombo);
	typeCombo.setLayoutData(gridData);

	typeCombo.addSelectionListener(new SelectionAdapter() {

		/**
		 * {@inheritDoc}
		 */
		@Override
		public void widgetSelected(SelectionEvent event) {
			validate();
		}

	});

	SqlType sqlType = targetColumn.getType();

	String database = this.diagram.getDatabase();

	if (sqlType != null && sqlType.getAlias(database) != null) {
		typeCombo.setText(sqlType.getAlias(database));
	}

	return typeCombo;
}
 
Example #28
Source File: SourceView.java    From lapse-plus with GNU General Public License v3.0 5 votes vote down vote up
private void createColumns() {
	        TableLayout layout = new TableLayout();
	        getTable().setLayout(layout);
	        getTable().setHeaderVisible(true);
	        for (int i = 0; i < columnHeaders.length; i++) {
	            layout.addColumnData(columnLayouts[i]);
	            TableColumn tc = new TableColumn(getTable(), SWT.NONE,i);
	            tc.setResizable(columnLayouts[i].resizable);
	            tc.setText(columnHeaders[i]);
	            final int j = i;
	            tc.addSelectionListener(new SelectionAdapter() {           	
                	public void widgetSelected(SelectionEvent e) {
                		ViewerSorter oldSorter = viewer.getSorter();
                		if(oldSorter instanceof ColumnBasedSorter) {
                			ColumnBasedSorter sorter = (ColumnBasedSorter) oldSorter;	                			 
                			if(sorter.getColumn() == j) {
                				sorter.toggle();
                				viewer.refresh();
//                				System.err.println("Resorting column " + j + " in order " + sorter.getOrientation());
                				return;
                			}
                		}
                		
                		viewer.setSorter(new ColumnBasedSorter(j));
//                		System.err.println("Sorting column " + j + " in order " + 1);	                		
                		viewer.refresh();
                    }	                
                });
	        }
	    }
 
Example #29
Source File: PeerTableViewer.java    From offspring with MIT License 5 votes vote down vote up
private SelectionAdapter getSelectionAdapter(final TableColumn column,
    final int index) {
  SelectionAdapter selectionAdapter = new SelectionAdapter() {

    @Override
    public void widgetSelected(SelectionEvent e) {
      comparator.setColumn(index);
      int dir = comparator.getDirection();
      getTable().setSortDirection(dir);
      getTable().setSortColumn(column);
      refresh();
    }
  };
  return selectionAdapter;
}
 
Example #30
Source File: DelegateUIHelper.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public static Button generateDeprecateDelegateCheckbox(Composite parent, Refactoring refactoring) {
	final IDelegateUpdating updating= (IDelegateUpdating) refactoring.getAdapter(IDelegateUpdating.class);
	if (updating == null || !updating.canEnableDelegateUpdating())
		return null;
	final Button button= createCheckbox(parent, getDeprecateDelegateCheckBoxTitle(), loadDeprecateDelegateSetting(updating));
	updating.setDeprecateDelegates(button.getSelection());
	button.addSelectionListener(new SelectionAdapter() {

		@Override
		public void widgetSelected(SelectionEvent e) {
			updating.setDeprecateDelegates(button.getSelection());
		}
	});
	return button;
}