Java Code Examples for org.eclipse.swt.events.SelectionAdapter

The following examples show how to use org.eclipse.swt.events.SelectionAdapter. These examples are extracted from open source projects.
Example 1
Project: depan   File: NodeFilterViewPart.java    License: 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 2
Project: depan   File: NodeStatsViewPart.java    License: 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 3
Project: tmxeditor8   File: PromptDialog.java    License: 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 4
Project: hop   File: RadioTab.java    License: Apache License 2.0 6 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 5
Project: Eclipse-Postfix-Code-Completion   File: SortMembersMessageDialog.java    License: 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 6
Project: neoscada   File: DetailsPart.java    License: 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 7
Project: bonita-studio   File: DocumentWizardPage.java    License: 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 8
Project: Eclipse-Postfix-Code-Completion   File: CustomFiltersActionGroup.java    License: 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 9
Project: bonita-studio   File: ConfigureCoolbarItem.java    License: 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 10
Project: birt   File: ImageBuilder.java    License: 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 11
Project: Eclipse-Postfix-Code-Completion   File: ModifyDialogTabPage.java    License: 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 12
Project: birt   File: SelectVariableDialog.java    License: 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 13
Project: gama   File: EditorMenu.java    License: 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 14
Project: tmxeditor8   File: PluginConfigManageDialog.java    License: 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 15
Project: texlipse   File: StyleListFieldEditor.java    License: 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 16
Project: birt   File: RotatedTextBuilder.java    License: Eclipse Public License 1.0 6 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 17
Project: nebula   File: TransitionManager.java    License: 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 18
Project: spotbugs   File: ReportConfigurationTab.java    License: 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 19
Project: nebula   File: CheckBoxGroup.java    License: 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 20
Project: elexis-3-core   File: ContactSorterSwitcher.java    License: 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 21
Project: nebula   File: ColumnsSnippet.java    License: 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 22
Project: Eclipse-Postfix-Code-Completion   File: ChangeParametersControl.java    License: 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 23
Project: xds-ide   File: TabPageNewLines.java    License: 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 24
Project: pentaho-kettle   File: DirectoryDialogButtonListenerFactory.java    License: 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 25
Project: xds-ide   File: SDKsPreferencePage.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void createControl(Composite parent) {
        super.createControl(parent);
        
        getDefaultsButton().setVisible(false);
        getApplyButton().setEnabled(false);
        getApplyButton().addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                        getApplyButton().setEnabled(false);
                }
        });
}
 
Example 26
Project: elexis-3-core   File: GenericSelectionComposite.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent){
	Composite ret = (Composite) super.createDialogArea(parent);
	ScrolledComposite sc = new ScrolledComposite(ret, SWT.H_SCROLL | SWT.V_SCROLL);
	
	Composite child = new Composite(sc, SWT.NONE);
	child.setLayout(new GridLayout());
	
	GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
	data.heightHint = 400;
	sc.setLayoutData(data);

	Label title = new Label(child, SWT.NONE);
	title.setText("Auswahl:");
	// create the UI
	for (Object object : input) {
		Button button = new Button(child, SWT.CHECK);
		button.setText(getLabel(object));
		button.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e){
				if (button.getSelection()) {
					selection.add(object);
				} else {
					selection.remove(object);
				}
			}
		});
		buttonMap.put(object, button);
	}
	sc.setMinSize(child.computeSize(SWT.DEFAULT, SWT.DEFAULT));
	sc.setExpandHorizontal(true);
	sc.setExpandVertical(true);
    sc.setContent(child);

	updateSelectionUi();
	
	return ret;
}
 
Example 27
Project: eip-designer   File: ServiceActivatorPropertiesEditionPartImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 
 */
protected Composite createToChannelsAdvancedReferencesTable(Composite parent) {
	String label = getDescription(EipViewsRepository.ServiceActivator.Properties.toChannels, EipMessages.ServiceActivatorPropertiesEditionPart_ToChannelsLabel);		 
	this.toChannels = new ReferencesTable(label, new ReferencesTableListener() {
		public void handleAdd() { addToChannels(); }
		public void handleEdit(EObject element) { editToChannels(element); }
		public void handleMove(EObject element, int oldIndex, int newIndex) { moveToChannels(element, oldIndex, newIndex); }
		public void handleRemove(EObject element) { removeFromToChannels(element); }
		public void navigateTo(EObject element) { }
	});
	this.toChannels.setHelpText(propertiesEditionComponent.getHelpContent(EipViewsRepository.ServiceActivator.Properties.toChannels, EipViewsRepository.SWT_KIND));
	this.toChannels.createControls(parent);
	this.toChannels.addSelectionListener(new SelectionAdapter() {
		
		public void widgetSelected(SelectionEvent e) {
			if (e.item != null && e.item.getData() instanceof EObject) {
				propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(ServiceActivatorPropertiesEditionPartImpl.this, EipViewsRepository.ServiceActivator.Properties.toChannels, PropertiesEditionEvent.CHANGE, PropertiesEditionEvent.SELECTION_CHANGED, null, e.item.getData()));
			}
		}
		
	});
	GridData toChannelsData = new GridData(GridData.FILL_HORIZONTAL);
	toChannelsData.horizontalSpan = 3;
	this.toChannels.setLayoutData(toChannelsData);
	this.toChannels.disableMove();
	toChannels.setID(EipViewsRepository.ServiceActivator.Properties.toChannels);
	toChannels.setEEFType("eef::AdvancedReferencesTable"); //$NON-NLS-1$
	return parent;
}
 
Example 28
Project: hop   File: CommonTransformDialog.java    License: Apache License 2.0 5 votes vote down vote up
protected Button buildGetFieldsButton( final Composite parent, final SelectionAdapter listener ) {
  // get fields button
  wGet = new Button( parent, SWT.PUSH );
  updateGetFieldsButtonStatus();
  wGet.setText( BaseMessages.getString( PKG, "CommonTransformDialog.Button.GetFields" ) ); //$NON-NLS-1$
  props.setLook( wGet );
  wGet.setLayoutData( new FormDataBuilder().right( 100, 0 ).bottom( 100, 0 ).result() );
  wGet.addSelectionListener( listener );
  return wGet;
}
 
Example 29
Project: gwt-eclipse-plugin   File: WebAppHostPageSelectionDialog.java    License: Eclipse Public License 1.0 5 votes vote down vote up
protected void createExternalUI(Composite parent) {
  createExternalRootContentArea(parent);
  SWTFactory.createVerticalSpacer(parent, 16);
  useProjectFileCheckbox = new Button(parent, SWT.CHECK);
  useProjectFileCheckbox.setText("Select an HTML page:");
  useProjectFileCheckbox.setSelection(true);
  useProjectFileCheckbox.addSelectionListener(new SelectionAdapter() {
    @Override
    public void widgetSelected(SelectionEvent e) {
      boolean enabled = useProjectFileCheckbox.getSelection();
      useFile = enabled;
      SWTUtilities.setEnabledRecursive(fileSelectionGroup, enabled);

      if (enabled) {
        updateStatus(oldStatus);
      } else {
        // save the current status so that if the user re-enables the file
        // selector,
        // if it was in a bad state (ie, no selection), that state is
        // restored.
        if (status != null) {
          oldStatus = status;
        } else {
          oldStatus = OK_STATUS;
        }

        // it's ok to blast the current state because it doesn't depend on
        // anything new added to the UI (specifically, the external server
        // text)
        updateStatus(OK_STATUS);
      }

      updateUrlLabelText();
    }
  });
}
 
Example 30
Project: google-cloud-eclipse   File: NewDataflowProjectWizardLandingPage.java    License: Apache License 2.0 5 votes vote down vote up
private SelectionListener templateVersionListener() {
  return new SelectionAdapter() {
    @Override
    public void widgetSelected(SelectionEvent event) {
      updateArchetypeVersion();
    }
  };
}
 
Example 31
Project: eip-designer   File: RouterPropertiesEditionPartImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 
 */
protected Composite createFromChannelsAdvancedReferencesTable(Composite parent) {
	String label = getDescription(EipViewsRepository.Router.Properties.fromChannels, EipMessages.RouterPropertiesEditionPart_FromChannelsLabel);		 
	this.fromChannels = new ReferencesTable(label, new ReferencesTableListener() {
		public void handleAdd() { addFromChannels(); }
		public void handleEdit(EObject element) { editFromChannels(element); }
		public void handleMove(EObject element, int oldIndex, int newIndex) { moveFromChannels(element, oldIndex, newIndex); }
		public void handleRemove(EObject element) { removeFromFromChannels(element); }
		public void navigateTo(EObject element) { }
	});
	this.fromChannels.setHelpText(propertiesEditionComponent.getHelpContent(EipViewsRepository.Router.Properties.fromChannels, EipViewsRepository.SWT_KIND));
	this.fromChannels.createControls(parent);
	this.fromChannels.addSelectionListener(new SelectionAdapter() {
		
		public void widgetSelected(SelectionEvent e) {
			if (e.item != null && e.item.getData() instanceof EObject) {
				propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(RouterPropertiesEditionPartImpl.this, EipViewsRepository.Router.Properties.fromChannels, PropertiesEditionEvent.CHANGE, PropertiesEditionEvent.SELECTION_CHANGED, null, e.item.getData()));
			}
		}
		
	});
	GridData fromChannelsData = new GridData(GridData.FILL_HORIZONTAL);
	fromChannelsData.horizontalSpan = 3;
	this.fromChannels.setLayoutData(fromChannelsData);
	this.fromChannels.disableMove();
	fromChannels.setID(EipViewsRepository.Router.Properties.fromChannels);
	fromChannels.setEEFType("eef::AdvancedReferencesTable"); //$NON-NLS-1$
	return parent;
}
 
Example 32
Project: jbt   File: NodesSearcher.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates the search Button.
 * 
 * @param parent
 *            the Composite where the Button is placed.
 */
private void createSearchButton(Composite parent) {
	Button button = new Button(parent, SWT.PUSH);
	button.setText("Search");
	button.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));

	/* When clicked, the button performs the search. */
	button.addSelectionListener(new SelectionAdapter() {
		public void widgetSelected(SelectionEvent e) {
			String searchText = searchTextField.getText();
			performSearch(searchText);
		}
	});
}
 
Example 33
Project: xds-ide   File: XFindPanel.java    License: Eclipse Public License 1.0 5 votes vote down vote up
protected ToolItem createPreviousItem(final ToolBar bar) {
    bPrev = createTool(bar, Messages.XFindPanel_FindPrevious_tooltip,
            ImageUtils.FIND_PREV, new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent e) {
                    findPrevious();
                }
            });
    bPrev.setEnabled(false);
    return bPrev;
}
 
Example 34
Project: Eclipse-Postfix-Code-Completion   File: IntroduceParameterObjectWizard.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private void createLocationInput(Composite parent) {
	Label l= new Label(parent, SWT.NONE);
	l.setText(RefactoringMessages.IntroduceParameterObjectWizard_destination_label);

	Composite composite= new Composite(parent, SWT.None);
	GridLayout gridLayout= new GridLayout(2, false);
	gridLayout.marginHeight= 0;
	gridLayout.marginWidth= 0;
	composite.setLayout(gridLayout);
	GridData gridData= new GridData(GridData.FILL_HORIZONTAL);
	composite.setLayoutData(gridData);

	final Button topLvlRadio= new Button(composite, SWT.RADIO);
	topLvlRadio.setText(RefactoringMessages.IntroduceParameterObjectWizard_createastoplevel_radio);
	topLvlRadio.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			boolean fAsTopLevel= topLvlRadio.getSelection();
			fProcessor.setCreateAsTopLevel(fAsTopLevel);
			updateSignaturePreview();
			validateRefactoring();
		}
	});

	Button nestedRadio= new Button(composite, SWT.RADIO);
	nestedRadio.setText(Messages.format(RefactoringMessages.IntroduceParameterObjectWizard_createasnestedclass_radio, BasicElementLabels.getJavaElementName(fProcessor.getContainingClass().getName())));
	boolean createAsTopLevel= getBooleanSetting(CREATE_TOP_LEVEL_SETTING, fProcessor.isCreateAsTopLevel());
	fProcessor.setCreateAsTopLevel(createAsTopLevel);
	topLvlRadio.setSelection(createAsTopLevel);
	nestedRadio.setSelection(!createAsTopLevel);

}
 
Example 35
Project: offspring   File: GenerericTreeViewer.java    License: MIT License 5 votes vote down vote up
private SelectionAdapter getSelectionAdapter(final TreeColumn column,
    final IGenericTableColumn c) {
  SelectionAdapter selectionAdapter = new SelectionAdapter() {

    @Override
    public void widgetSelected(SelectionEvent e) {
      comparator.setColumn(c);
      int dir = comparator.getDirection();
      getTree().setSortDirection(dir);
      getTree().setSortColumn(column);
      refresh();
    }
  };
  return selectionAdapter;
}
 
Example 36
Project: arx   File: ClipboardHandlerTable.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates a pop up menu for this handler.
 *
 * @return
 */
public Menu getMenu() {
    Menu menu = new Menu(table);
    MenuItem itemCopy = new MenuItem(menu, SWT.NONE);
    itemCopy.setText(Resources.getMessage("ClipboardHandlerTable.0")); //$NON-NLS-1$
    itemCopy.addSelectionListener(new SelectionAdapter(){
        public void widgetSelected(SelectionEvent arg0) {
            copy();
        }
    });
    return menu;
}
 
Example 37
Project: Eclipse-Postfix-Code-Completion   File: DelegateUIHelper.java    License: 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;
}
 
Example 38
Project: offspring   File: PeerTableViewer.java    License: 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 39
Project: lapse-plus   File: SourceView.java    License: 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 40
Project: nebula   File: SnippetCompositeTableDataBinding.java    License: 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);
}