當前位置: 首頁>>代碼示例>>Java>>正文


Java IResourceChangeEvent.getResource方法代碼示例

本文整理匯總了Java中org.eclipse.core.resources.IResourceChangeEvent.getResource方法的典型用法代碼示例。如果您正苦於以下問題:Java IResourceChangeEvent.getResource方法的具體用法?Java IResourceChangeEvent.getResource怎麽用?Java IResourceChangeEvent.getResource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.core.resources.IResourceChangeEvent的用法示例。


在下文中一共展示了IResourceChangeEvent.getResource方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: start

import org.eclipse.core.resources.IResourceChangeEvent; //導入方法依賴的package包/類
@Override
public void start(BundleContext context) throws Exception {
	super.start(context);
	plugin = this;
	IResourceChangeListener resourceChangeListener = new IResourceChangeListener() {
		
		@Override
		public void resourceChanged(IResourceChangeEvent event) {
			IResource resource = event.getResource();
			if (resource.getFileExtension().equals("e")) {
				//TODO:
				//Run compiler
			}
		}
	};
	ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener);
}
 
開發者ID:Imhotup,項目名稱:LibertyEiffel-Eclipse-Plugin,代碼行數:18,代碼來源:Activator.java

示例2: handleCloseEvent

import org.eclipse.core.resources.IResourceChangeEvent; //導入方法依賴的package包/類
private void handleCloseEvent(IResourceChangeEvent event) {
	if (event.getResource() instanceof IProject) {
		IProject project = ((IProject) event.getResource());
		for (IDebugTarget target : activeTargets) {
			EObject object = (EObject) target.getAdapter(EObject.class);
			IFile file = WorkspaceSynchronizer.getFile(object.eResource());
			if (project.equals(file.getProject())) {
				try {
					target.terminate();
				} catch (DebugException e) {
					e.printStackTrace();
				}
			}
		}
	}
}
 
開發者ID:Yakindu,項目名稱:statecharts,代碼行數:17,代碼來源:SCTHotModelReplacementManager.java

示例3: resourceChanged

import org.eclipse.core.resources.IResourceChangeEvent; //導入方法依賴的package包/類
public void resourceChanged(IResourceChangeEvent event)
{
    /*
     * remove elements from the storage if the projects are deleted
     */
    IResource resource = event.getResource();
    if (resource != null && IResource.PROJECT == resource.getType()
            && IResourceChangeEvent.PRE_DELETE == event.getType())
    {
        specStorage.remove(resource.getName());
    }

}
 
開發者ID:tlaplus,項目名稱:tlaplus,代碼行數:14,代碼來源:WorkspaceSpecManager.java

示例4: resourceChanged

import org.eclipse.core.resources.IResourceChangeEvent; //導入方法依賴的package包/類
@Override
public void resourceChanged(IResourceChangeEvent event) {
	try {
		IResource resource = event.getResource();
		switch (event.getType()) {
		case IResourceChangeEvent.PRE_DELETE:
			if (resource != null) {
				switch (resource.getType()) {
				case IResource.PROJECT:
					// called when project is deleted.
					deleteProject((IProject) resource);
					break;
				}
			}
			break;
		case IResourceChangeEvent.PRE_CLOSE:
			if (resource != null) {
				switch (resource.getType()) {
				case IResource.PROJECT:
					// called when project is closed.
					closeProject((IProject) resource);
					break;
				}
			}
			break;
		case IResourceChangeEvent.POST_CHANGE:
			IResourceDelta delta = event.getDelta();
			if (delta != null) {
				delta.accept(this);
			}
			break;
		}
	} catch (Throwable e) {
		Trace.trace(Trace.SEVERE, "Error while TypeScript resource changed", e);
	}
}
 
開發者ID:angelozerr,項目名稱:typescript.java,代碼行數:37,代碼來源:ResourcesWatcher.java

示例5: start

import org.eclipse.core.resources.IResourceChangeEvent; //導入方法依賴的package包/類
/**
 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
 */
public void start(BundleContext context) throws Exception {
    super.start(context);
    plugin = this;

    // make sure the rbe nature and builder are set on java projects
    // if that is what the users prefers.
    if (MsgEditorPreferences.isBuilderSetupAutomatically()) {
        ToggleNatureAction.addOrRemoveNatureOnAllJavaProjects(true);
    }

    // the unique file change listener
    resourceChangeListener = new IResourceChangeListener() {
        public void resourceChanged(IResourceChangeEvent event) {
            IResource resource = event.getResource();
            if (resource != null) {
                String fullpath = resource.getFullPath().toString();
                Set<AbstractIFileChangeListener> listeners = resourceChangeSubscribers.get(fullpath);
                if (listeners != null) {
                    AbstractIFileChangeListener[] larray = listeners .toArray(new AbstractIFileChangeListener[0]);
                    for (int i = 0; i < larray.length; i++) {
                        larray[i].listenedFileChanged(event);
                    }
                }
            }
        }
    };
    ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener);
    try {
    Display.getDefault().asyncExec(new Runnable() {
        public void run() {
                Display.getDefault().addFilter(SWT.KeyUp, new UndoKeyListener());

        }
    });
    } catch (NullPointerException e) {
        // TODO [RAP] Non UI-Thread, no default display available, in RAP
        // multiple clients and displays
    }
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:43,代碼來源:MessagesEditorPlugin.java

示例6: resourceChanged

import org.eclipse.core.resources.IResourceChangeEvent; //導入方法依賴的package包/類
@Override
public void resourceChanged(IResourceChangeEvent event) {
    IResource resource = event.getResource();
    if ((event.getType() == IResourceChangeEvent.PRE_CLOSE
            || event.getType() == IResourceChangeEvent.PRE_DELETE)
            && resource != null && resource.equals(project)) {
        dispose();
    }
}
 
開發者ID:iloveeclipse,項目名稱:filesync4eclipse,代碼行數:10,代碼來源:ProjectProperties.java

示例7: handleResourceDeleteEvent

import org.eclipse.core.resources.IResourceChangeEvent; //導入方法依賴的package包/類
/**
 * Handle deletion of resources (does only handle deletion of projects)
 * @param event
 */
private void handleResourceDeleteEvent(IResourceChangeEvent event){
	IResource resource = event.getResource();
	if(!(resource instanceof IProject)){
		return;
	}
	Display.getDefault().asyncExec(new Runnable() {
		public void run() {
			IProject[] input = (IProject[]) combo.getInput();
			IStructuredSelection selection = combo.getStructuredSelection();

			//Deleted project is selected
			if(selection.getFirstElement() == resource){
				if(input.length > 1){
					int currentIndex = combo.getCombo().getSelectionIndex();
					Object newItem = combo.getElementAt(currentIndex + 1);
					if(newItem != null){
						combo.setSelection(new StructuredSelection(newItem)); 
					} else{
						newItem = combo.getElementAt(currentIndex - 1);
						if(newItem != null){
							combo.setSelection(new StructuredSelection(newItem)); 
						}
					}
				} else if (input.length == 1){
					combo.setSelection(StructuredSelection.EMPTY);
				}
			}
			combo.remove(resource);
		}
	});
}
 
開發者ID:sebastiangoetz,項目名稱:slr-toolkit,代碼行數:36,代碼來源:BibtexEntryView.java

示例8: resourceChanged

import org.eclipse.core.resources.IResourceChangeEvent; //導入方法依賴的package包/類
@Override
public void resourceChanged(final IResourceChangeEvent event) {
    if (event.getType() != IResourceChangeEvent.PRE_CLOSE || !(event.getResource() instanceof IProject)) {
        return;
    }

    final IProject project = (IProject) event.getResource();

    if (!project.isOpen()) {
        /* Sanity check */
        log.error(
            MessageFormat.format(
                "Project Manager received close notification for project {0} (already closed)", //$NON-NLS-1$
                project.getName()));

        return;
    }

    /* Exit if we don't manage this project */
    String providerName;
    try {
        providerName = project.getPersistentProperty(TeamUtils.PROVIDER_PROP_KEY);
    } catch (final CoreException e) {
        log.warn(
            MessageFormat.format(
                "Could not query repository manager for project {0} (when handling close notification)", //$NON-NLS-1$
                project.getName()),
            e);
        return;
    }

    if (providerName == null || !providerName.equals(TFSRepositoryProvider.PROVIDER_ID)) {
        return;
    }

    /*
     * If this is the only project for this connection, it will be
     * disconnected, thus we need to prompt for unsaved WIT changes.
     */
    final TFSRepository repository = projectManager.getRepository(project);

    if (repository != null) {
        final IProject[] allRepositoryProjects = projectManager.getProjectsForRepository(repository);

        if (allRepositoryProjects.length == 1 && allRepositoryProjects[0] == project) {
            /*
             * Note: we have to ignore the cancel button here, there is no
             * way to prevent the close from occurring.
             */
            ProjectManagerDataProviderFactory.getDataProvider().promptForDisconnect();
        }
    }

    projectManager.close(project);
}
 
開發者ID:Microsoft,項目名稱:team-explorer-everywhere,代碼行數:56,代碼來源:ProjectCloseListener.java

示例9: start

import org.eclipse.core.resources.IResourceChangeEvent; //導入方法依賴的package包/類
/**
 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(
 *         org.osgi.framework.BundleContext)
 */
public void start(BundleContext context) throws Exception {
	super.start(context);
	plugin = this;
	
	//make sure the rbe nature and builder are set on java projects
	//if that is what the users prefers.
	if (MsgEditorPreferences.getInstance().isBuilderSetupAutomatically()) {
		ToggleNatureAction.addOrRemoveNatureOnAllJavaProjects(true);
	}

	//TODO replace deprecated
       try {
           URL messagesUrl = FileLocator.find(getBundle(),
                   new Path("$nl$/messages.properties"), null);//$NON-NLS-1$
           if(messagesUrl != null) {
               resourceBundle = new PropertyResourceBundle(
                       messagesUrl.openStream());
           }
       } catch (IOException x) {
           resourceBundle = null;
       }

       //the unique file change listener
       resourceChangeListener = new IResourceChangeListener() {
       	public void resourceChanged(IResourceChangeEvent event) {
       		IResource resource = event.getResource();
       		if (resource != null) {
       			String fullpath = resource.getFullPath().toString();
       			Set<AbstractIFileChangeListener> listeners = resourceChangeSubscribers.get(fullpath);
       			if (listeners != null) {
       				AbstractIFileChangeListener[] larray = listeners.toArray(new AbstractIFileChangeListener[0]);//avoid concurrency issues. kindof.
       				for (int i = 0; i < larray.length; i++) {
       					larray[i].listenedFileChanged(event);
       				}
       			}
       		}
       	}
       };
       ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener);
}
 
開發者ID:wolfgang-ch,項目名稱:mytourbook,代碼行數:45,代碼來源:MessagesEditorPlugin.java


注:本文中的org.eclipse.core.resources.IResourceChangeEvent.getResource方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。