use of org.eclipse.jface.util.IPropertyChangeListener in project epp.mpc by eclipse.
the class MarketplacePage method createControl.
@Override
public void createControl(final Composite parent) {
currentBranding = getDefaultBranding();
boolean needSwitchMarketplaceControl = configuration.getCatalogDescriptors().size() > 1;
Composite pageContent = new Composite(parent, SWT.NULL);
GridLayoutFactory.fillDefaults().numColumns(1).spacing(0, 5).applyTo(pageContent);
tabFolder = new TabFolder(pageContent, SWT.TOP);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(tabFolder);
super.createControl(tabFolder);
tabContent = getControl();
searchTabItem = createCatalogTab(-1, ContentType.SEARCH, WIDGET_ID_TAB_SEARCH, currentBranding.getSearchTabName());
recentTabItem = createCatalogTab(-1, ContentType.RECENT, WIDGET_ID_TAB_RECENT, currentBranding.getRecentTabName());
popularTabItem = createCatalogTab(-1, ContentType.POPULAR, WIDGET_ID_TAB_POPULAR, currentBranding.getPopularTabName());
favoritedTabItem = createCatalogTab(-1, ContentType.FAVORITES, WIDGET_ID_TAB_FAVORITES, getFavoritedTabName(currentBranding));
installedTabItem = createCatalogTab(-1, ContentType.INSTALLED, WIDGET_ID_TAB_INSTALLED, Messages.MarketplacePage_installed);
updateNewsTab();
searchTabItem.setControl(tabContent);
tabFolder.setSelection(searchTabItem);
tabFolder.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
if (e.item.isDisposed()) {
return;
}
setActiveTab((TabItem) e.item);
}
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
{
// TODO id
contentListLinks = new Link(pageContent, SWT.NULL);
contentListLinks.setToolTipText(Messages.MarketplacePage_showSelection);
contentListLinks.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
String actionId = e.text;
ActionLink actionLink = actions.get(actionId);
if (actionLink != null) {
actionLink.selected();
}
}
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(contentListLinks);
updateSelectionLink();
}
if (needSwitchMarketplaceControl) {
createMarketplaceSwitcher(pageContent);
}
updateBranding();
// bug 312411: a selection listener so that we can streamline install of single product
getViewer().addSelectionChangedListener(new ISelectionChangedListener() {
private int previousSelectionSize = 0;
public void selectionChanged(SelectionChangedEvent event) {
if (!isCurrentPage()) {
return;
}
SelectionModel selectionModel = getWizard().getSelectionModel();
int newSelectionSize = selectionModel.getItemToSelectedOperation().size();
// sets the empty selection whenever the catalog is updated.
if (!event.getSelection().isEmpty()) {
if (previousSelectionSize == 0 && newSelectionSize > 0 && selectionModel.computeProvisioningOperationViableForFeatureSelection()) {
showNextPage();
}
}
previousSelectionSize = newSelectionSize;
}
});
getViewer().addPropertyChangeListener(new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(MarketplaceViewer.CONTENT_TYPE_PROPERTY) && event.getNewValue() != null) {
setActiveTab((ContentType) event.getNewValue());
}
}
});
setControl(pageContent);
if (!tabContent.isDisposed()) {
// bug 473031 - no clue how this can happen during createControl...
MarketplaceClientUi.setDefaultHelp(tabContent);
}
}
use of org.eclipse.jface.util.IPropertyChangeListener in project epp.mpc by eclipse.
the class MarketplaceWizardCommand method createConfiguration.
@Override
protected MarketplaceCatalogConfiguration createConfiguration(final MarketplaceCatalog catalog, ExecutionEvent event) {
MarketplaceCatalogConfiguration configuration = super.createConfiguration(catalog, event);
if (configuration == null) {
// errors have already been logged, just return
return null;
}
configuration.getFilters().clear();
final ComboTagFilter marketFilter = new ComboTagFilter() {
@Override
public void catalogUpdated(boolean wasCancelled) {
List<Tag> choices = new ArrayList<Tag>();
List<IMarket> markets = catalog.getMarkets();
for (IMarket market : markets) {
Tag marketTag = new Tag(IMarket.class, market.getId(), market.getName());
marketTag.setData(market);
choices.add(marketTag);
}
setChoices(choices);
}
};
marketFilter.setSelectAllOnNoSelection(true);
marketFilter.setNoSelectionLabel(Messages.MarketplaceWizardCommand_allMarkets);
marketFilter.setTagClassification(ICategory.class);
marketFilter.setChoices(new ArrayList<Tag>());
final ComboTagFilter marketCategoryTagFilter = new ComboTagFilter() {
@Override
public void catalogUpdated(boolean wasCancelled) {
updateCategoryChoices(this, marketFilter);
}
};
marketCategoryTagFilter.setSelectAllOnNoSelection(true);
marketCategoryTagFilter.setNoSelectionLabel(Messages.MarketplaceWizardCommand_allCategories);
marketCategoryTagFilter.setTagClassification(ICategory.class);
marketCategoryTagFilter.setChoices(new ArrayList<Tag>());
final IPropertyChangeListener marketListener = new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
final String property = event.getProperty();
if (AbstractTagFilter.PROP_SELECTED.equals(property)) {
updateCategoryChoices(marketCategoryTagFilter, marketFilter);
}
}
};
marketFilter.addPropertyChangeListener(marketListener);
configuration.getFilters().add(marketFilter);
configuration.getFilters().add(marketCategoryTagFilter);
configuration.setInitialState(wizardState);
if (operations != null && !operations.isEmpty()) {
configuration.setInitialOperations(operations);
}
for (CatalogFilter filter : configuration.getFilters()) {
((MarketplaceFilter) filter).setCatalog(catalog);
}
return configuration;
}
use of org.eclipse.jface.util.IPropertyChangeListener in project polymap4-core by Polymap4.
the class CommonNavigatorActionGroup method makeActions.
/**
*/
private void makeActions() {
FrameList frameList = commonViewer.getFrameList();
backAction = new BackAction(frameList);
forwardAction = new ForwardAction(frameList);
upAction = new UpAction(frameList);
frameList.addPropertyChangeListener(new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(FrameList.P_RESET)) {
upAction.setEnabled(false);
backAction.setEnabled(false);
forwardAction.setEnabled(false);
}
commonNavigator.updateTitle();
IActionBars actionBars = commonNavigator.getViewSite().getActionBars();
updateToolBar(actionBars.getToolBarManager());
}
});
IHandlerService service = (IHandlerService) commonNavigator.getSite().getService(IHandlerService.class);
INavigatorViewerDescriptor viewerDescriptor = commonViewer.getNavigatorContentService().getViewerDescriptor();
boolean hideLinkWithEditorAction = viewerDescriptor.getBooleanConfigProperty(INavigatorViewerDescriptor.PROP_HIDE_LINK_WITH_EDITOR_ACTION);
if (!hideLinkWithEditorAction) {
toggleLinkingAction = new LinkEditorAction(commonNavigator, commonViewer, linkHelperService);
// $NON-NLS-1$
ImageDescriptor syncIcon = getImageDescriptor("elcl16/synced.gif");
toggleLinkingAction.setImageDescriptor(syncIcon);
toggleLinkingAction.setHoverImageDescriptor(syncIcon);
service.activateHandler(toggleLinkingAction.getActionDefinitionId(), new ActionHandler(toggleLinkingAction));
}
boolean hideCollapseAllAction = viewerDescriptor.getBooleanConfigProperty(INavigatorViewerDescriptor.PROP_HIDE_COLLAPSE_ALL_ACTION);
if (!hideCollapseAllAction) {
collapseAllAction = new CollapseAllAction(commonViewer);
// $NON-NLS-1$
ImageDescriptor collapseAllIcon = getImageDescriptor("elcl16/collapseall.gif");
collapseAllAction.setImageDescriptor(collapseAllIcon);
collapseAllAction.setHoverImageDescriptor(collapseAllIcon);
collapseAllHandler = new CollapseAllHandler(commonViewer);
service.activateHandler(CollapseAllHandler.COMMAND_ID, collapseAllHandler);
}
filterGroup = new FilterActionGroup(commonViewer);
}
use of org.eclipse.jface.util.IPropertyChangeListener in project netxms by netxms.
the class AlarmTab method createTabContent.
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.objectview.objecttabs.ObjectTab#createTabContent(org.eclipse.swt.widgets.Composite)
*/
@Override
protected void createTabContent(Composite parent) {
final IDialogSettings settings = Activator.getDefault().getDialogSettings();
initShowFilter = settings.getBoolean("AlarmTab.showFilter");
alarmList = new AlarmList(getViewPart(), parent, SWT.NONE, getConfigPrefix(), new VisibilityValidator() {
@Override
public boolean isVisible() {
return isActive();
}
});
alarmList.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
settings.put("AlarmTab.showFilter", alarmList.isFilterEnabled());
}
});
// Force update of "show colors" menu item in object tabbed view
// when settings changes in any alarm viewer
propertyChangeListener = new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (// $NON-NLS-1$
event.getProperty().equals("SHOW_ALARM_STATUS_COLORS")) {
ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
service.refreshElements("org.netxms.ui.eclipse.alarmviewer.commands.show_status_colors", null);
}
}
};
Activator.getDefault().getPreferenceStore().addPropertyChangeListener(propertyChangeListener);
alarmList.setFilterCloseAction(new Action() {
@Override
public void run() {
alarmList.enableFilter(false);
ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
// $NON-NLS-1$
Command command = service.getCommand("org.netxms.ui.eclipse.alarmviewer.commands.show_filter_alarm_list");
// $NON-NLS-1$
State state = command.getState("org.netxms.ui.eclipse.alarmviewer.commands.show_filter_alarm_list.state");
state.setValue(false);
service.refreshElements(command.getId(), null);
}
});
alarmList.enableFilter(initShowFilter);
}
use of org.eclipse.jface.util.IPropertyChangeListener in project webtools.sourceediting by eclipse.
the class HTMLSyntaxColoringPage method createContents.
protected Control createContents(final Composite parent) {
initializeDialogUnits(parent);
fDefaultForeground = parent.getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND);
fDefaultBackground = parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND);
Composite pageComponent = createComposite(parent, 2);
PlatformUI.getWorkbench().getHelpSystem().setHelp(pageComponent, IHelpContextIds.HTML_PREFWEBX_STYLES_HELPID);
Link link = new Link(pageComponent, SWT.WRAP);
link.setText(SSEUIMessages.SyntaxColoring_Link);
link.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
PreferencesUtil.createPreferenceDialogOn(parent.getShell(), e.text, null, null);
}
});
GridData linkData = new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1);
// only expand further if anyone else requires it
linkData.widthHint = 150;
link.setLayoutData(linkData);
new Label(pageComponent, SWT.NONE).setLayoutData(new GridData());
new Label(pageComponent, SWT.NONE).setLayoutData(new GridData());
SashForm editor = new SashForm(pageComponent, SWT.VERTICAL);
GridData gridData2 = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData2.horizontalSpan = 2;
editor.setLayoutData(gridData2);
SashForm top = new SashForm(editor, SWT.HORIZONTAL);
Composite styleEditor = createComposite(top, 1);
((GridLayout) styleEditor.getLayout()).marginRight = 5;
((GridLayout) styleEditor.getLayout()).marginLeft = 0;
createLabel(styleEditor, HTMLUIMessages.SyntaxColoringPage_0);
fStylesViewer = createStylesViewer(styleEditor);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData.horizontalIndent = 0;
Iterator iterator = fStyleToDescriptionMap.values().iterator();
while (iterator.hasNext()) {
gridData.widthHint = Math.max(gridData.widthHint, convertWidthInCharsToPixels(iterator.next().toString().length()));
}
gridData.heightHint = convertHeightInCharsToPixels(5);
fStylesViewer.getControl().setLayoutData(gridData);
Composite editingComposite = createComposite(top, 1);
((GridLayout) styleEditor.getLayout()).marginLeft = 5;
// $NON-NLS-1$
createLabel(editingComposite, "");
Button enabler = createCheckbox(editingComposite, HTMLUIMessages.SyntaxColoringPage_2);
enabler.setEnabled(false);
enabler.setSelection(true);
Composite editControls = createComposite(editingComposite, 2);
((GridLayout) editControls.getLayout()).marginLeft = 20;
fForegroundLabel = createLabel(editControls, SSEUIMessages.Foreground_UI_);
((GridData) fForegroundLabel.getLayoutData()).verticalAlignment = SWT.CENTER;
fForegroundLabel.setEnabled(false);
fForegroundColorEditor = new ColorSelector(editControls);
Button fForegroundColor = fForegroundColorEditor.getButton();
GridData gd = new GridData(SWT.BEGINNING, SWT.FILL, false, false);
fForegroundColor.setLayoutData(gd);
fForegroundColorEditor.setEnabled(false);
fForegroundColorEditor.getButton().getAccessible().addAccessibleListener(new AccessibleAdapter() {
public void getName(final AccessibleEvent e) {
e.result = SSEUIMessages.Foreground_Color_Selector_Button;
}
});
fBackgroundLabel = createLabel(editControls, SSEUIMessages.Background_UI_);
((GridData) fBackgroundLabel.getLayoutData()).verticalAlignment = SWT.CENTER;
fBackgroundLabel.setEnabled(false);
fBackgroundColorEditor = new ColorSelector(editControls);
Button fBackgroundColor = fBackgroundColorEditor.getButton();
gd = new GridData(SWT.BEGINNING, SWT.FILL, false, false);
fBackgroundColor.setLayoutData(gd);
fBackgroundColorEditor.setEnabled(false);
fBackgroundColorEditor.getButton().getAccessible().addAccessibleListener(new AccessibleAdapter() {
public void getName(final AccessibleEvent e) {
e.result = SSEUIMessages.Background_Color_Selector_Button;
}
});
fBold = createCheckbox(editControls, HTMLUIMessages.SyntaxColoringPage_3);
fBold.setEnabled(false);
((GridData) fBold.getLayoutData()).horizontalSpan = 2;
fItalic = createCheckbox(editControls, HTMLUIMessages.SyntaxColoringPage_4);
fItalic.setEnabled(false);
((GridData) fItalic.getLayoutData()).horizontalSpan = 2;
fStrike = createCheckbox(editControls, HTMLUIMessages.SyntaxColoringPage_5);
fStrike.setEnabled(false);
((GridData) fStrike.getLayoutData()).horizontalSpan = 2;
fUnderline = createCheckbox(editControls, HTMLUIMessages.SyntaxColoringPage_6);
fUnderline.setEnabled(false);
((GridData) fUnderline.getLayoutData()).horizontalSpan = 2;
fClearStyle = new Button(editingComposite, SWT.PUSH);
// $NON-NLS-1$ = "Restore Default"
fClearStyle.setText(SSEUIMessages.Restore_Default_UI_);
fClearStyle.setLayoutData(new GridData(SWT.BEGINNING));
((GridData) fClearStyle.getLayoutData()).horizontalIndent = 20;
fClearStyle.setEnabled(false);
Composite sampleArea = createComposite(editor, 1);
((GridLayout) sampleArea.getLayout()).marginLeft = 5;
((GridLayout) sampleArea.getLayout()).marginTop = 5;
// $NON-NLS-1$ = "&Sample text:"
createLabel(sampleArea, SSEUIMessages.Sample_text__UI_);
fPreviewViewer = new SourceViewer(sampleArea, null, SWT.BORDER | SWT.LEFT_TO_RIGHT | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.READ_ONLY);
fText = fPreviewViewer.getTextWidget();
GridData gridData3 = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData3.widthHint = convertWidthInCharsToPixels(20);
gridData3.heightHint = convertHeightInCharsToPixels(5);
gridData3.horizontalSpan = 2;
fText.setLayoutData(gridData3);
fText.setEditable(false);
// $NON-NLS-1$
fText.setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont"));
fText.addKeyListener(getTextKeyListener());
fText.addSelectionListener(getTextSelectionListener());
fText.addMouseListener(getTextMouseListener());
fText.addTraverseListener(getTraverseListener());
setAccessible(fText, SSEUIMessages.Sample_text__UI_);
fDocument = StructuredModelManager.getModelManager().createStructuredDocumentFor(ContentTypeIdForHTML.ContentTypeID_HTML);
fDocument.set(getExampleText());
initializeSourcePreviewColors(fPreviewViewer);
fPreviewViewer.setDocument(fDocument);
top.setWeights(new int[] { 1, 1 });
editor.setWeights(new int[] { 1, 1 });
PlatformUI.getWorkbench().getHelpSystem().setHelp(pageComponent, IHelpContextIds.HTML_PREFWEBX_STYLES_HELPID);
fStylesViewer.setInput(getStylePreferenceKeys());
applyStyles();
fStylesViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
if (!event.getSelection().isEmpty()) {
Object o = ((IStructuredSelection) event.getSelection()).getFirstElement();
String namedStyle = o.toString();
activate(namedStyle);
if (namedStyle == null)
return;
}
}
});
fForegroundColorEditor.addListener(new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(ColorSelector.PROP_COLORCHANGE)) {
Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement();
String namedStyle = o.toString();
String prefString = getOverlayStore().getString(namedStyle);
String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
if (stylePrefs != null) {
String oldValue = stylePrefs[0];
// open color dialog to get new color
String newValue = ColorHelper.toRGBString(fForegroundColorEditor.getColorValue());
if (!newValue.equals(oldValue)) {
stylePrefs[0] = newValue;
String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
getOverlayStore().setValue(namedStyle, newPrefString);
applyStyles();
fText.redraw();
}
}
}
}
});
fBackgroundColorEditor.addListener(new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(ColorSelector.PROP_COLORCHANGE)) {
Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement();
String namedStyle = o.toString();
String prefString = getOverlayStore().getString(namedStyle);
String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
if (stylePrefs != null) {
String oldValue = stylePrefs[1];
// open color dialog to get new color
String newValue = ColorHelper.toRGBString(fBackgroundColorEditor.getColorValue());
if (!newValue.equals(oldValue)) {
stylePrefs[1] = newValue;
String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
getOverlayStore().setValue(namedStyle, newPrefString);
applyStyles();
fText.redraw();
activate(namedStyle);
}
}
}
}
});
fBold.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
// get current (newly old) style
Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement();
String namedStyle = o.toString();
String prefString = getOverlayStore().getString(namedStyle);
String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
if (stylePrefs != null) {
String oldValue = stylePrefs[2];
String newValue = String.valueOf(fBold.getSelection());
if (!newValue.equals(oldValue)) {
stylePrefs[2] = newValue;
String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
getOverlayStore().setValue(namedStyle, newPrefString);
applyStyles();
fText.redraw();
}
}
}
});
fItalic.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
// get current (newly old) style
Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement();
String namedStyle = o.toString();
String prefString = getOverlayStore().getString(namedStyle);
String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
if (stylePrefs != null) {
String oldValue = stylePrefs[3];
String newValue = String.valueOf(fItalic.getSelection());
if (!newValue.equals(oldValue)) {
stylePrefs[3] = newValue;
String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
getOverlayStore().setValue(namedStyle, newPrefString);
applyStyles();
fText.redraw();
}
}
}
});
fStrike.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
// get current (newly old) style
Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement();
String namedStyle = o.toString();
String prefString = getOverlayStore().getString(namedStyle);
String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
if (stylePrefs != null) {
String oldValue = stylePrefs[4];
String newValue = String.valueOf(fStrike.getSelection());
if (!newValue.equals(oldValue)) {
stylePrefs[4] = newValue;
String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
getOverlayStore().setValue(namedStyle, newPrefString);
applyStyles();
fText.redraw();
}
}
}
});
fUnderline.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
// get current (newly old) style
Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement();
String namedStyle = o.toString();
String prefString = getOverlayStore().getString(namedStyle);
String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
if (stylePrefs != null) {
String oldValue = stylePrefs[5];
String newValue = String.valueOf(fUnderline.getSelection());
if (!newValue.equals(oldValue)) {
stylePrefs[5] = newValue;
String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
getOverlayStore().setValue(namedStyle, newPrefString);
applyStyles();
fText.redraw();
}
}
}
});
fClearStyle.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (fStylesViewer.getSelection().isEmpty())
return;
String namedStyle = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement().toString();
getOverlayStore().setToDefault(namedStyle);
applyStyles();
fText.redraw();
activate(namedStyle);
}
});
return pageComponent;
}
Aggregations