@SuppressWarnings("unchecked") @Override public <T> T getAdapter(final Class<T> adapter) { if (adapter == ISaveablePart.class) return (T)clean_saveable; return null; }
public void propertyChange(PropertyChangeEvent evt) { getSite().getWorkbenchWindow().getShell().getDisplay().asyncExec(new Runnable() { public void run() { isDirty = true; firePropertyChange(ISaveablePart.PROP_DIRTY); } }); }
@Override public void doSave(IProgressMonitor monitor) { isRefresh = true; String xml = null; if (activePage == 0) { xml = model2xml(); } else if (activePage == 1) { xml2model(); } doSaveParticipate(monitor); xmlEditor.doSave(monitor); if (xml != null) { try { IFile f = getCurrentFile(); if (f != null) f.setContents(new ByteArrayInputStream(xml.getBytes("UTF-8")), IFile.KEEP_HISTORY | IFile.FORCE, monitor); } catch (Throwable e) { UIUtils.showError(e); } } Display.getDefault().asyncExec(new Runnable() { public void run() { isRefresh = false; firePropertyChange(ISaveablePart.PROP_DIRTY); } }); xmlFresh = true; }
public void propertyChange(PropertyChangeEvent evt) { getSite().getWorkbenchWindow().getShell().getDisplay().asyncExec(new Runnable() { public void run() { firePropertyChange(ISaveablePart.PROP_DIRTY); } }); }
protected void finishSave(IFile resource) { String resourceAbsolutePath = resource.getRawLocation().toOSString(); if (DefaultManager.INSTANCE.isCurrentDefault(resourceAbsolutePath)) { DefaultManager.INSTANCE.reloadCurrentDefault(); } Display.getDefault().asyncExec(new Runnable() { public void run() { isRefresh = false; firePropertyChange(ISaveablePart.PROP_DIRTY); } }); }
@Override protected void handlePropertyChange(int propertyId) { if (!isRefresh) { if (propertyId == ISaveablePart.PROP_DIRTY && previewEditor != null) previewEditor.setDirty(true); super.handlePropertyChange(propertyId); } }
@Override public void dirtyStateChanged() { WidgetUtils.runInDisplayThread(ChartEditor.this.getSite().getShell(), new Runnable() { @Override public void run() { firePropertyChange(ISaveablePart.PROP_DIRTY); } }); }
/** * Required by IReusableEditor - change our editor to a new input. * Unconditionally remove the existing input if there is one, undoing listeners and providers. * If the given input is not null, set the editor to work on it. Finally, notify that the * dirty and input properties have changed. * @param input the new input which is to replace the existing input */ @Override public void setInput(IEditorInput input) { unsetOldInput(); if (input == null) { setPartName("<disposed>"); } else { setNewInput(input); } setPageInputs(input); firePropertyChange(ISaveablePart.PROP_DIRTY); // following the instructions from the javadoc on IReusableEditor firePropertyChange(IWorkbenchPartConstants.PROP_INPUT); }
/** * When the dirty state changes, fire a property-change event for the "dirty" property. */ @Override public void dirtyStateChanged() { WidgetUtils.runInDisplayThread(MultiPagePlanEditor.this.getContainer(), new Runnable() { @Override public void run() { firePropertyChange(ISaveablePart.PROP_DIRTY); } }); }
@Override protected EvaluationResult evaluate(IEvaluationContext context) { IWorkbenchWindow window = InternalHandlerUtil.getActiveWorkbenchWindow(context); // no window? not active if (window == null) return EvaluationResult.FALSE; WorkbenchPage page = (WorkbenchPage) window.getActivePage(); // no page? not active if (page == null) return EvaluationResult.FALSE; // get saveable part ISaveablePart saveablePart = getSaveablePart(context); if (saveablePart == null) return EvaluationResult.FALSE; if (saveablePart instanceof ISaveablesSource) { ISaveablesSource modelSource = (ISaveablesSource) saveablePart; if (SaveableHelper.needsSave(modelSource)) return EvaluationResult.TRUE; return EvaluationResult.FALSE; } if (saveablePart != null && saveablePart.isDirty()) return EvaluationResult.TRUE; return EvaluationResult.FALSE; }
@Override public void run() { IPath ignoreThrownExceptionsPath = PyExceptionBreakPointManager.getInstance().ignoreCaughtExceptionsWhenThrownFrom .getIgnoreThrownExceptionsPath(); File file = ignoreThrownExceptionsPath.toFile(); IEditorPart openFile = EditorUtils.openFile(file); if (openFile instanceof ITextEditor) { final ITextEditor textEditor = (ITextEditor) openFile; IDocumentProvider documentProvider = textEditor.getDocumentProvider(); final IEditorInput input = openFile.getEditorInput(); if (documentProvider instanceof IStorageDocumentProvider) { IStorageDocumentProvider storageDocumentProvider = (IStorageDocumentProvider) documentProvider; // Make sure the file is seen as UTF-8. storageDocumentProvider.setEncoding(input, "utf-8"); textEditor.doRevertToSaved(); } if (textEditor instanceof ISaveablePart) { IPropertyListener listener = new IPropertyListener() { @Override public void propertyChanged(Object source, int propId) { if (propId == IWorkbenchPartConstants.PROP_DIRTY) { if (source == textEditor) { if (textEditor.getEditorInput() == input) { if (!textEditor.isDirty()) { PyExceptionBreakPointManager.getInstance().ignoreCaughtExceptionsWhenThrownFrom .updateIgnoreThrownExceptions(); } } } } } }; textEditor.addPropertyListener(listener); } } // Code to provide a dialog to edit it (decided on opening the file instead). // Collection<IgnoredExceptionInfo> ignoreThrownExceptionsForEdition = PyExceptionBreakPointManager.getInstance() // .getIgnoreThrownExceptionsForEdition(); // HashMap<String, String> map = new HashMap<>(); // for (IgnoredExceptionInfo ignoredExceptionInfo : ignoreThrownExceptionsForEdition) { // map.put(ignoredExceptionInfo.filename + ": " + ignoredExceptionInfo.line, ignoredExceptionInfo.contents); // } // // EditIgnoredCaughtExceptionsDialog dialog = new EditIgnoredCaughtExceptionsDialog(EditorUtils.getShell(), map); // int open = dialog.open(); // if (open == dialog.OK) { // Map<String, String> result = dialog.getResult(); // // } else { // System.out.println("Cancel"); // } }
/** * Creates a new script's document provider with the specified saveable * part. * * @param part * the saveable part. */ public ScriptDocumentProvider( ISaveablePart part ) { super( part ); }
/** * Creates a new javascript's document provider with the specified saveable * part. * * @param part * the saveable part. */ public JSDocumentProvider( ISaveablePart part ) { super( part ); }
/** * Creates a new document provider with the specified saveable part. * * @param part * the saveable part. */ public StorageDocumentProvider( ISaveablePart part ) { super( part ); }
/** * Creates a new document provider with the specified saveable part. * * @param part * the saveable part. */ public DocumentProvider( ISaveablePart part ) { super( ); this.part = part; }