protected void updatePeriodActions() { IActionBars actionBars = getViewSite().getActionBars(); IMenuManager menuManager = actionBars.getMenuManager(); if (periodActions != null) { for (int i = 0; i < periodActions.length; i++) { menuManager.remove(periodActions[i]); periodActions[i].dispose(); } periodActions = null; } createPeriodActions(); if (periodActions != null) { for (int i = 0; i < periodActions.length; i++) { menuManager.appendToGroup("periods", periodActions[i]); } } TimeSpan periodTimeSpan = TimeSpan.fromString(dialogSettings.get(K_PERIOD)); TimeSpan resolutionTimeSpan = TimeSpan.fromString(dialogSettings.get(K_RESOLUTION)); setPeriodActionSelection(periodTimeSpan, resolutionTimeSpan); actionBars.updateActionBars(); }
@Override protected void restoreWidgetValues() { super.restoreWidgetValues(); IDialogSettings settings = getDialogSettings(); if (settings != null) { if (getDefaultSourceFile() == null) { directoryFileSelector.setDirectorySelected(settings.getBoolean("isDirectory")); String file = settings.get("source.file"); if (Strings.isValid(file)) { directoryFileSelector.setText(file); } } String parser = settings.get("selected.parser"); if (Strings.isValid(parser)) { for (IArtifactExtractor item : importContributionManager.getExtractors()) { if (parser.equals(item.getClass().getSimpleName())) { parserSelectPanel.setArtifactExtractor(item); } } } if (getDefaultDestinationArtifact() == null) { String guid = settings.get("destination.artifact.guid"); String branchUuidStr = settings.get("destination.branch.uuid"); if (GUID.isValid(guid) && Strings.isNumeric(branchUuidStr)) { try { Long bramchUuid = Long.valueOf(branchUuidStr); Artifact artifact = ArtifactQuery.getArtifactFromId(guid, BranchManager.getBranchByUuid(bramchUuid)); artifactSelectPanel.setDefaultItem(artifact); } catch (OseeCoreException ex) { OseeLog.logf( Activator.class, Level.SEVERE, "Unable to restore destination artifact- guid:[%s] branch uuid:[%d]", guid, branchUuidStr); } } } boolean toUpdate = settings.getBoolean("is.update.existing.selected"); updateExistingArtifacts.setSelection(toUpdate); deleteUnmatchedArtifacts.setEnabled(toUpdate); if (toUpdate) { try { ArtifactType artType = ArtifactTypeManager.getType(getArtifactType()); attributeTypeSelectPanel.setAllowedAttributeTypes( artType.getAttributeTypes(getDestinationArtifact().getFullBranch())); } catch (OseeCoreException ex) { OseeLog.log(Activator.class, Level.SEVERE, ex); } } else { attributeTypeSelectPanel.setAllowedAttributeTypes(new ArrayList<IAttributeType>()); } } }
public static SearchPattern create(final IDialogSettings settings) { String loadedSearchString = settings.get("searchString"); boolean loadedIsCaseSensitive = settings.getBoolean("isCaseSensitive"); boolean loadedIsRegularExpression = settings.getBoolean("isRegularExpression"); SortedMap<String, Boolean> loadedEvents = new TreeMap<String, Boolean>(); for (String entry : Constants.EVENT_CATEGORIES.keySet()) { loadedEvents.put(entry, settings.getBoolean(entry)); } Map<Field, Boolean> loadedLimitTo = new HashMap<Field, Boolean>(); loadedLimitTo.put(Field.SOURCE_INFO, settings.getBoolean(Field.SOURCE_INFO.toString())); loadedLimitTo.put(Field.MESSAGE, settings.getBoolean(Field.MESSAGE.toString())); FilterPattern loadedFilterPattern = new FilterPattern( loadedSearchString, loadedLimitTo, loadedIsCaseSensitive, loadedIsRegularExpression); loadedFilterPattern.setEventsToFilter(loadedEvents, true, false); String[] wsIds = settings.getArray("workingSets"); // $NON-NLS-1$ IWorkingSet[] workingSets = null; if (wsIds != null && wsIds.length > 0) { IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager(); workingSets = new IWorkingSet[wsIds.length]; for (int i = 0; workingSets != null && i < wsIds.length; i++) { workingSets[i] = workingSetManager.getWorkingSet(wsIds[i]); if (workingSets[i] == null) { workingSets = null; } } } return new SearchPattern(loadedFilterPattern, settings.getInt("scope"), workingSets); }
public QualifiedNameComponent( Composite parent, int style, final IQualifiedNameUpdating refactoring, IDialogSettings settings) { super(parent, style); GridLayout layout = new GridLayout(); layout.marginWidth = 0; layout.marginHeight = 0; layout.numColumns = 2; setLayout(layout); Label label = new Label(this, SWT.NONE); label.setText(RefactoringMessages.QualifiedNameComponent_patterns_label); fPatterns = new Text(this, SWT.BORDER); fPatterns.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); label = new Label(this, SWT.NONE); label.setText(RefactoringMessages.QualifiedNameComponent_patterns_description); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; label.setLayoutData(gd); String text = refactoring.getFilePatterns(); if (text == null) text = settings.get(PATTERNS); if (text != null) { fPatterns.setText(text); refactoring.setFilePatterns(text); } fPatterns.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { refactoring.setFilePatterns(fPatterns.getText()); } }); }
public static SearchPatternData create(IDialogSettings settings) { String textPattern = settings.get("textPattern"); // $NON-NLS-1$ String[] wsIds = settings.getArray("workingSets"); // $NON-NLS-1$ IWorkingSet[] workingSets = null; if (wsIds != null && wsIds.length > 0) { IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager(); workingSets = new IWorkingSet[wsIds.length]; for (int i = 0; workingSets != null && i < wsIds.length; i++) { workingSets[i] = workingSetManager.getWorkingSet(wsIds[i]); if (workingSets[i] == null) { workingSets = null; } } } String[] fileNamePatterns = settings.getArray("fileNamePatterns"); // $NON-NLS-1$ if (fileNamePatterns == null) { fileNamePatterns = new String[0]; } try { int scope = settings.getInt("scope"); // $NON-NLS-1$ boolean isRegExSearch = settings.getBoolean("isRegExSearch"); // $NON-NLS-1$ boolean ignoreCase = settings.getBoolean("ignoreCase"); // $NON-NLS-1$ return new SearchPatternData( textPattern, !ignoreCase, isRegExSearch, fileNamePatterns, scope, workingSets); } catch (NumberFormatException e) { return null; } }
/** Initializes controls with values from the Dialog Settings object */ protected void initSettings() { final IDialogSettings settings = getDialogSettings(); if (settings.get(SETTINGS_SAVED) == null) { // Set default values destDirText.setText(""); } else { // Retrieve previous values from the dialog settings final String directory = settings.get(DEST_DIR_SETTING); if (directory != null) { destDirText.setText(settings.get(DEST_DIR_SETTING)); } } }
protected void saveSettings(IDialogSettings settings) { ISecurePreferences preferences = getPreferences(settings.getName()); if (preferences == null) { // only in case it is not possible to create secured storage in // default location -> in that case do not persist settings return; } try { preferences.putBoolean(S_SIGN_JARS, fButton.getSelection(), true); preferences.put(S_KEYSTORE, fKeystoreText.getText().trim(), true); preferences.put(S_ALIAS, fAliasText.getText().trim(), true); preferences.put(S_PASSWORD, fPasswordText.getText().trim(), true); preferences.put(S_KEYPASS, fKeypassText.getText().trim(), true); // bug387565 - for keys which are starting with this bugfix to be // stored // in secured storage, replace value in settings with empty string // to avoid keeping sensitive info in plain text String[] obsoleted = new String[] {S_KEYSTORE, S_ALIAS, S_PASSWORD, S_KEYPASS}; for (String key : obsoleted) { if (settings.get(key) != null) { settings.put(key, ""); // $NON-NLS-1$ } } } catch (StorageException e) { PDEPlugin.log( "Failed to store JarSigning settings in secured preferences store"); //$NON-NLS-1$ } }
private int getLastSelectedJREKind() { int kind = PROJECT_RE; IDialogSettings settings = JavaPlugin.getDefault().getDialogSettings(); if (settings.get(LAST_SELECTED_JRE_KIND2_KEY) != null) { kind = settings.getInt(LAST_SELECTED_JRE_KIND2_KEY); } return kind; }
private String getParentDirectory() { IDialogSettings settings = DartToolsPlugin.getDefault().getDialogSettingsSection(NEW_APPPLICATION_SETTINGS); String path = settings.get(PARENT_DIR); if (path != null) { return path; } return getDefaultFolder(); }
private void selectLastUsedUri() { String lastUri = settings.get(lastUriKey); if (lastUri != null) { int i = uriCombo.indexOf(lastUri); if (i != -1) { uriCombo.select(i); return; } } uriCombo.select(0); }
private void initBuildNotesButton() { if (settings == null || settings.get(NOTES_BUTTON_KEY) == null) { buildNotesButton.setSelection(false); buildNotesButtonChecked = false; return; } else { boolean b = settings.getBoolean(NOTES_BUTTON_KEY); buildNotesButton.setSelection(b); buildNotesButtonChecked = b; } }
public static SearchPatternData create(final IDialogSettings settings) { final String pattern = settings.get("pattern"); if (pattern.length() == 0) { return null; } final String[] wsIds = settings.getArray("workingSets"); IWorkingSet[] workingSets = null; if (wsIds != null && wsIds.length > 0) { final IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager(); workingSets = new IWorkingSet[wsIds.length]; for (int i = 0; workingSets != null && i < wsIds.length; i++) { workingSets[i] = workingSetManager.getWorkingSet(wsIds[i]); if (workingSets[i] == null) { workingSets = null; } } } try { final int scope = settings.getInt("scope"); // $NON-NLS-1$ LimitTo limitTo; try { limitTo = LimitTo.valueOf(settings.get("limitTo")); // //$NON-NLS-1$ } catch (final IllegalArgumentException e) { limitTo = LimitTo.REFERENCES; } SearchFor searchFor; try { searchFor = SearchFor.valueOf(settings.get("searchFor")); // //$NON-NLS-1$ } catch (final IllegalArgumentException e) { searchFor = SearchFor.FUNCTION; } final int includeMask = settings.getInt("includeMask"); // $NON-NLS-1$ return new SearchPatternData(pattern, scope, limitTo, searchFor, workingSets, includeMask); } catch (final NumberFormatException e) { } return null; }
/** @return Returns the activeSet. */ public ScopeSet getActiveSet() { if (activeSet == null) { IDialogSettings settings = HelpUIPlugin.getDefault().getDialogSettings(); String name = settings.get(ACTIVE_SET); activeSet = findSet(name); if (activeSet == null) { return (ScopeSet) sets.get(0); } if (!activeSet.isImplicit()) lastExplicitSet = activeSet; } return activeSet; }
/* * (non-Javadoc) * * @see * org.xmind.gef.image.FigureRenderer#render(org.eclipse.swt.graphics.GC) */ @Override public void render(GC gc) { gc.setClipping(pageClientArea.x, pageClientArea.y, pageClientArea.width, pageClientArea.height); drawSourceContent(gc); gc.setClipping(pageClientArea.x, pageClientArea.y, pageClientArea.width, pageClientArea.height); if (!settings.getBoolean(PrintConstants.NO_BORDER)) { drawBorder(gc); } String headerText = settings.get(PrintConstants.HEADER_TEXT); if (headerText != null && !"".equals(headerText)) { // $NON-NLS-1$ drawHeader(gc, headerText); } String footerText = settings.get(PrintConstants.FOOTER_TEXT); if (footerText != null && !"".equals(footerText)) { // $NON-NLS-1$ drawFooter(gc, footerText); } }
private String getPageToActivate() { if (getEditorInput() instanceof IFileEditorInput) { final IFileEditorInput fileInput = (IFileEditorInput) getEditorInput(); final String projectName = fileInput.getFile().getProject().getName(); final String sectionName = ID + ".activePage." + projectName; final IDialogSettings dialogSettings = RedPlugin.getDefault().getDialogSettings(); final IDialogSettings section = dialogSettings.getSection(sectionName); if (section == null) { return null; } return section.get("activePage"); } return null; }
@Override protected void restoreWidgetValues() { IDialogSettings settings = getDialogSettings(); if (settings == null) return; String password = null; String login = settings.get(STORE_LOGIN); if (login == null) login = ""; else password = loadSecurePassword(login); if (password == null) password = ""; loginField.setText(login); passwordField.setText(password); }
public SearchDialog(IWorkbenchWindow window, String pageId) { super(window.getShell()); fWorkbenchWindow = window; fCurrentSelection = window.getSelectionService().getSelection(); fCurrentEnclosingProject = evaluateEnclosingProject(fCurrentSelection, getActiveEditor()); fDescriptors = filterByActivities(SearchPlugin.getDefault().getEnabledSearchPageDescriptors(pageId)); fInitialPageId = pageId; if (fInitialPageId == null && fDialogSettings.getBoolean(STORE_IS_OPEN_PREVIOUS_PAGE)) { fInitialPageId = fDialogSettings.get(STORE_PREVIOUS_PAGE); } fPageChangeListeners = null; setUseEmbeddedProgressMonitorPart(false); }
@Override public void propertyChange(PropertyChangeEvent evt) { if (IPropertyConstants.BARS.equals(evt.getPropertyName())) { TimeSpan resolution = TimeSpan.fromString(dialogSettings.get(K_RESOLUTION)); view.setRootDataSeries( new OHLCDataSeries( security.getName(), subsetHistory.getAdjustedOHLC(), resolution)); Display.getDefault() .asyncExec( new Runnable() { @Override public void run() { if (!viewer.getControl().isDisposed()) { refreshChart(); } } }); } }
@Override public void restoreState(IMemento memento) { super.restoreState(memento); IDialogSettings settings = getSettings(); boolean showEnclosingDefinitions = true; if (settings.get(KEY_SHOW_ENCLOSING_DEFINITIONS) != null) showEnclosingDefinitions = settings.getBoolean(KEY_SHOW_ENCLOSING_DEFINITIONS); if (memento != null) { Boolean value = memento.getBoolean(KEY_SHOW_ENCLOSING_DEFINITIONS); if (value != null) showEnclosingDefinitions = value.booleanValue(); String[] keys = { KEY_LOCATION_COLUMN_WIDTH, KEY_DEFINITION_COLUMN_WIDTH, KEY_MATCH_COLUMN_WIDTH }; for (int i = 0; i < keys.length; i++) { Integer width = memento.getInteger(keys[i]); if (width == null) continue; if (width > 0) fColumnWidths[i] = width; } } setShowEnclosingDefinitions(showEnclosingDefinitions); }
private void saveImportOrder(List elements) { IDialogSettings dialogSettings = JavaScriptPlugin.getDefault().getDialogSettings(); FileDialog dialog = new FileDialog(getShell(), SWT.SAVE); dialog.setText(PreferencesMessages.ImportOrganizeConfigurationBlock_saveDialog_title); dialog.setFilterExtensions(new String[] {"*.importorder", "*.*"}); // $NON-NLS-1$ //$NON-NLS-2$ dialog.setFileName("example.importorder"); // $NON-NLS-1$ String lastPath = dialogSettings.get(DIALOGSETTING_LASTSAVEPATH); if (lastPath != null) { dialog.setFilterPath(lastPath); } String fileName = dialog.open(); if (fileName != null) { dialogSettings.put(DIALOGSETTING_LASTSAVEPATH, dialog.getFilterPath()); Properties properties = new Properties(); for (int i = 0; i < elements.size(); i++) { ImportOrderEntry entry = (ImportOrderEntry) elements.get(i); properties.setProperty(String.valueOf(i), entry.serialize()); } FileOutputStream fos = null; try { fos = new FileOutputStream(fileName); properties.store(fos, "Organize Import Order"); // $NON-NLS-1$ } catch (IOException e) { JavaScriptPlugin.log(e); String title = PreferencesMessages.ImportOrganizeConfigurationBlock_saveDialog_error_title; String message = PreferencesMessages.ImportOrganizeConfigurationBlock_saveDialog_error_message; MessageDialog.openError(getShell(), title, message); } finally { if (fos != null) { try { fos.close(); } catch (IOException e) { } } } } }
private List loadImportOrder() { IDialogSettings dialogSettings = JavaScriptPlugin.getDefault().getDialogSettings(); FileDialog dialog = new FileDialog(getShell(), SWT.OPEN); dialog.setText(PreferencesMessages.ImportOrganizeConfigurationBlock_loadDialog_title); dialog.setFilterExtensions(new String[] {"*.importorder", "*.*"}); // $NON-NLS-1$ //$NON-NLS-2$ String lastPath = dialogSettings.get(DIALOGSETTING_LASTLOADPATH); if (lastPath != null) { dialog.setFilterPath(lastPath); } String fileName = dialog.open(); if (fileName != null) { dialogSettings.put(DIALOGSETTING_LASTLOADPATH, dialog.getFilterPath()); Properties properties = new Properties(); FileInputStream fis = null; try { fis = new FileInputStream(fileName); properties.load(fis); List res = loadFromProperties(properties); if (res != null) { return res; } } catch (IOException e) { JavaScriptPlugin.log(e); } finally { if (fis != null) { try { fis.close(); } catch (IOException e) { } } } String title = PreferencesMessages.ImportOrganizeConfigurationBlock_loadDialog_error_title; String message = PreferencesMessages.ImportOrganizeConfigurationBlock_loadDialog_error_message; MessageDialog.openError(getShell(), title, message); } return null; }
/** * Restors the state of the filter from the given dialog settings. * * @param dialogSettings the dialog settings */ public void restoreState(final IDialogSettings dialogSettings) { this.resetState(); final IDialogSettings settings = dialogSettings.getSection(TAG_DIALOG_SECTION); if (settings != null) { String setting = null; if ((setting = settings.get(TAG_ENABLED)) != null) { this.mEnabled = Boolean.valueOf(setting).booleanValue(); } if ((setting = settings.get(TAG_ON_RESOURCE)) != null) { try { this.mOnResource = Integer.parseInt(setting); } catch (final NumberFormatException eNumberFormat) { // ignore and use default value } } if ((setting = settings.get(TAG_WORKING_SET)) != null) { this.setWorkingSet( Activator.getDefault().getWorkbench().getWorkingSetManager().getWorkingSet(setting)); } if ((setting = settings.get(TAG_SELECT_BY_SEVERITY)) != null) { this.mSelectBySeverity = Boolean.valueOf(setting).booleanValue(); } if ((setting = settings.get(TAG_SEVERITY)) != null) { try { this.mSeverity = Integer.parseInt(setting); } catch (final NumberFormatException eNumberFormat) { // ignore and use default value } } if ((setting = settings.get(TAG_SELECT_BY_REGEX)) != null) { this.mFilterByRegex = Boolean.valueOf(setting).booleanValue(); } final String[] regex = settings.getArray(TAG_REGULAR_EXPRESSIONS); if (regex != null) { this.mFilterRegex = Arrays.asList(regex); } } }
/* (non-Javadoc) * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) */ protected Control createDialogArea(Composite parent) { Composite result = (Composite) super.createDialogArea(parent); final Button button = new Button(result, SWT.CHECK); button.setText(fFilterMessage); button.setFont(parent.getFont()); IDialogSettings settings = PhingUi.getDefault().getDialogSettings(); fShowAll = settings.getBoolean(DIALOG_SETTING); String lastPath = settings.get(LAST_CONTAINER); if (lastPath != null) { IPath path = Path.fromPortableString(lastPath); IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path); setInitialSelection(resource); } fFilter.considerExtension(!fShowAll); getTreeViewer().addFilter(fFilter); if (!fShowAll) { button.setSelection(true); } button.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { if (button.getSelection()) { fShowAll = false; } else { fShowAll = true; } fFilter.considerExtension(!fShowAll); getTreeViewer().refresh(); } }); applyDialogFont(result); return result; }
private Font getFont(String fontKey) { Font font = null; String fontValue = settings.get(fontKey); if (fontValue != null) { FontData[] fontData = FontUtils.toFontData(fontValue); if (fontData != null) { for (FontData fd : fontData) { fd.setHeight(fd.getHeight() * dpi.y / UnitConvertor.getScreenDpi().y); } font = new Font(Display.getCurrent(), fontData); } } if (font == null) { FontData[] defaultFontData = JFaceResources.getDefaultFontDescriptor().getFontData(); int defaultHeight = defaultFontData[0].getHeight(); font = new Font( Display.getCurrent(), FontUtils.newHeight( defaultFontData, defaultHeight * dpi.y / UnitConvertor.getScreenDpi().y)); } return font; }
/** Initializes itself from the stored page settings. */ private void readConfiguration() { IDialogSettings s = getDialogSettings(); fIsCaseSensitive = s.getBoolean(STORE_CASE_SENSITIVE); fIsRegExSearch = s.getBoolean(STORE_IS_REG_EX_SEARCH); fSearchDerived = s.getBoolean(STORE_SEARCH_DERIVED); try { int historySize = s.getInt(STORE_HISTORY_SIZE); for (int i = 0; i < historySize; i++) { IDialogSettings histSettings = s.getSection(STORE_HISTORY + i); if (histSettings != null) { SearchPatternData data = SearchPatternData.create(histSettings); if (data != null) { fPreviousSearchPatterns.add(data); } } } } catch (NumberFormatException e) { // ignore } Set<String> previousExtensions = new LinkedHashSet<String>(HISTORY_SIZE); IDialogSettings extensionsSettings = s.getSection(STORE_EXTENSIONS); if (extensionsSettings != null) { for (int i = 0; i < HISTORY_SIZE; i++) { String extension = extensionsSettings.get(Integer.toString(i)); if (extension == null) { break; } previousExtensions.add(extension); } fPreviousExtensions = new String[previousExtensions.size()]; previousExtensions.toArray(fPreviousExtensions); } else { fPreviousExtensions = getPreviousExtensionsOldStyle(); } }
/** * Use the dialog store to restore widget values to the values that they held last time this * dialog was used to completion. */ protected void restoreWidgetValues() { IDialogSettings settings = getDialogSettings(); String[] expandedCategoryIds = settings.getArray(STORE_EXPANDED_CATEGORIES_ID); if (expandedCategoryIds == null) return; ArrayList<OperationCategory> categoriesToExpand = new ArrayList<OperationCategory>(expandedCategoryIds.length); for (int i = 0; i < expandedCategoryIds.length; i++) { OperationCategory category = opMenuFactory.findCategory(expandedCategoryIds[i]); if (category != null) // ie.- it still exists categoriesToExpand.add(category); } if (!categoriesToExpand.isEmpty()) tree.setExpandedElements(categoriesToExpand.toArray()); String selectedOperationID = settings.get(STORE_SELECTED_OPERATION_ID); if (selectedOperationID != null) { OpAction action = opMenuFactory.find(selectedOperationID); if (action != null) { tree.setSelection(new StructuredSelection(action), true); } } }
private String getString(IDialogSettings settings, String key) { String s = settings.get(key); return s == null ? "" : s; // $NON-NLS-1$ }
/** * Restores the selected item for the given combo based on the stored value from the dialog * settings * * @param combo * @param id * @param settings */ private void restoreTextSelection(String id, IDialogSettings settings) { String restoredValue = settings.get(id); if (restoredValue != null) { this.getText().setText(restoredValue); } }
/* (non-Javadoc) * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) */ @Override public void createPartControl(Composite parent) { viewer = new TreeViewer(parent, SWT.FULL_SELECTION | SWT.MULTI); viewer.getTree().setHeaderVisible(true); viewer.getTree().setLinesVisible(false); createContextMenu(); model = new TradingSystemsViewModel(tradingSystemService); String[] columns = dialogSettings.getArray(COLUMNS); IDialogSettings namesSection = dialogSettings.getSection(COLUMN_NAMES); List<ViewColumn> list = new ArrayList<ViewColumn>(); for (int i = 0; i < columns.length; i++) { String name = namesSection.get(columns[i]); list.add(new ViewColumn(name, activator.getDataProviderFactory(columns[i]))); } model.setDataProviders(list); for (final TradingSystemItem item : model.getList()) { PropertyChangeSupport changeSupport = (PropertyChangeSupport) item.getTradingSystem().getAdapter(PropertyChangeSupport.class); if (changeSupport != null) { changeSupport.addPropertyChangeListener( new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { Display.getDefault() .asyncExec( new Runnable() { @Override public void run() { if (viewer.getControl().isDisposed()) { return; } viewer.refresh(item); } }); } }); } } final ObservableListTreeContentProvider contentProvider = new ObservableListTreeContentProvider(model, model); viewer.setContentProvider(contentProvider); IDialogSettings widthSettings = dialogSettings.getSection(COLUMN_WIDTHS); TreeViewerColumn viewerColumn = new TreeViewerColumn(viewer, SWT.NONE); int width = 300; if (widthSettings.get(LABEL_COLUMN) != null) { width = widthSettings.getInt(LABEL_COLUMN); } viewerColumn.getColumn().setWidth(width); viewerColumn.getColumn().addControlListener(columnControlListener); final List<IObservableMap> properties = new ArrayList<IObservableMap>(); properties.add(new ViewerObservableMap(contentProvider.getKnownElements(), LABEL_COLUMN)); for (ViewColumn column : model.getDataProviders()) { viewerColumn = new TreeViewerColumn(viewer, SWT.RIGHT); viewerColumn.getColumn().setText(column.getName()); width = 100; if (widthSettings.get(column.getDataProviderFactory().getId()) != null) { width = widthSettings.getInt(column.getDataProviderFactory().getId()); } viewerColumn.getColumn().setWidth(width); viewerColumn.getColumn().addControlListener(columnControlListener); column.addPropertyChangeListener(ViewColumn.PROP_NAME, columnPropertiesChangeListener); properties.add( new ViewerObservableMap( contentProvider.getKnownElements(), column.getDataProviderFactory().getId())); } createLabelProvider(properties.toArray(new IObservableMap[properties.size()])); model .getObservableDataProviders() .addListChangeListener( new IListChangeListener() { @Override public void handleListChange(ListChangeEvent event) { event.diff.accept( new ListDiffVisitor() { @Override public void handleRemove(int index, Object element) { TreeColumn treeColumn = viewer.getTree().getColumn(index + 1); treeColumn.dispose(); ViewColumn column = (ViewColumn) element; column.removePropertyChangeListener( ViewColumn.PROP_NAME, columnPropertiesChangeListener); IObservableMap observableMap = properties.remove(index + 1); if (observableMap != null) { observableMap.dispose(); } } @Override public void handleAdd(int index, Object element) { ViewColumn column = (ViewColumn) element; TreeViewerColumn viewerColumn = new TreeViewerColumn(viewer, SWT.RIGHT, index + 1); viewerColumn.getColumn().setText(column.getName()); int width = 100; IDialogSettings widthSettings = dialogSettings.getSection(COLUMN_WIDTHS); if (widthSettings.get(column.getDataProviderFactory().getId()) != null) { width = widthSettings.getInt(column.getDataProviderFactory().getId()); } viewerColumn.getColumn().setWidth(width); viewerColumn.getColumn().addControlListener(columnControlListener); column.addPropertyChangeListener( ViewColumn.PROP_NAME, columnPropertiesChangeListener); properties.add( index + 1, new ViewerObservableMap( contentProvider.getKnownElements(), column.getDataProviderFactory().getId())); } }); createLabelProvider(properties.toArray(new IObservableMap[properties.size()])); IDialogSettings namesSection = dialogSettings.getSection(COLUMN_NAMES); List<String> list = new ArrayList<String>(); for (ViewColumn column : model.getDataProviders()) { list.add(column.getDataProviderFactory().getId()); namesSection.put(column.getDataProviderFactory().getId(), column.getName()); } dialogSettings.put(COLUMNS, list.toArray(new String[list.size()])); } }); viewer.setComparator(new ViewerComparator()); getSite().setSelectionProvider(viewer); viewer.setInput(model); viewer.expandAll(); }
void scheduleLoadJob() { final Display display = viewer.getControl().getDisplay(); if (subsetHistory != null) { PropertyChangeSupport propertyChangeSupport = (PropertyChangeSupport) subsetHistory.getAdapter(PropertyChangeSupport.class); if (propertyChangeSupport != null) { propertyChangeSupport.removePropertyChangeListener(propertyChangeListener); } } ChartLoadJob job = new ChartLoadJob(security); job.addJobChangeListener( new JobChangeAdapter() { @Override public void done(IJobChangeEvent event) { final ChartLoadJob job = (ChartLoadJob) event.getJob(); history = job.getHistory(); subsetHistory = job.getSubsetHistory(); view.setRootDataSeries( new OHLCDataSeries( security.getName(), subsetHistory.getAdjustedOHLC(), job.getResolutionTimeSpan())); display.asyncExec( new Runnable() { @Override public void run() { if (viewer.getControl().isDisposed()) { return; } if (memento == null) { memento = XMLMemento.createWriteRoot("root"); // $NON-NLS-1$ } saveState(memento); TimeSpan resolutionTimeSpan = TimeSpan.fromString(dialogSettings.get(K_RESOLUTION)); if (resolutionTimeSpan == null) { resolutionTimeSpan = TimeSpan.days(1); } viewer.setResolutionTimeSpan(resolutionTimeSpan); dropListener.setView(view); PropertyChangeSupport propertyChangeSupport = (PropertyChangeSupport) subsetHistory.getAdapter(PropertyChangeSupport.class); if (propertyChangeSupport != null) { propertyChangeSupport.addPropertyChangeListener(propertyChangeListener); } refreshChart(); } }); } }); job.setTimeSpan(TimeSpan.fromString(dialogSettings.get(K_PERIOD))); job.setResolutionTimeSpan(TimeSpan.fromString(dialogSettings.get(K_RESOLUTION))); job.setName(Messages.ChartViewPart_LoadingText + getPartName()); job.setUser(true); job.schedule(); }