Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
Original file line number Diff line number Diff line change
Expand Up @@ -34,96 +34,96 @@
* @author lobas_av
*/
public final class Activator extends AbstractUIPlugin {
public static final String PLUGIN_ID = "org.eclipse.wb.core.databinding.xml";
private static Activator m_plugin;
public static final String PLUGIN_ID = "org.eclipse.wb.core.databinding.xml";
private static Activator m_plugin;

////////////////////////////////////////////////////////////////////////////
//
// Life cycle
//
////////////////////////////////////////////////////////////////////////////
@Override
public void stop(BundleContext context) throws Exception {
m_plugin = null;
super.stop(context);
}
////////////////////////////////////////////////////////////////////////////
//
// Life cycle
//
////////////////////////////////////////////////////////////////////////////
@Override
public void stop(BundleContext context) throws Exception {
m_plugin = null;
super.stop(context);
}

@Override
public void start(BundleContext context) throws Exception {
super.start(context);
m_plugin = this;
}
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
m_plugin = this;
}

public static Activator getDefault() {
return m_plugin;
}
public static Activator getDefault() {
return m_plugin;
}

////////////////////////////////////////////////////////////////////////////
//
// Utils
//
////////////////////////////////////////////////////////////////////////////
/**
* @return the {@link InputStream} for file from plugin directory.
*/
public static InputStream getFile(final String path) {
return ExecutionUtils.runObject(new RunnableObjectEx<InputStream>() {
@Override
public InputStream runObject() throws Exception {
return m_plugin.getBundle().getEntry(path).openStream();
}
}, "Unable to open plugin file %s", path);
}
////////////////////////////////////////////////////////////////////////////
//
// Utils
//
////////////////////////////////////////////////////////////////////////////
/**
* @return the {@link InputStream} for file from plugin directory.
*/
public static InputStream getFile(final String path) {
return ExecutionUtils.runObject(new RunnableObjectEx<InputStream>() {
@Override
public InputStream runObject() throws Exception {
return m_plugin.getBundle().getEntry(path).openStream();
}
}, "Unable to open plugin file %s", path);
}

////////////////////////////////////////////////////////////////////////////
//
// Caches
//
////////////////////////////////////////////////////////////////////////////
private static final Map<String, Image> m_nameToIconMap = Maps.newHashMap();
////////////////////////////////////////////////////////////////////////////
//
// Caches
//
////////////////////////////////////////////////////////////////////////////
private static final Map<String, Image> m_nameToIconMap = Maps.newHashMap();

/**
* Get image from "icons" directory.
*/
public static Image getImage(String name) {
Image image = m_nameToIconMap.get(name);
if (image == null) {
// prepare path
String path;
if (name.startsWith("/")) {
path = name;
} else {
path = "icons/" + name;
}
//
InputStream is = getFile(path);
try {
image = new Image(Display.getCurrent(), is);
m_nameToIconMap.put(name, image);
} finally {
IOUtils.closeQuietly(is);
}
}
return image;
}
/**
* Get image from "icons" directory.
*/
public static Image getImage(String name) {
Image image = m_nameToIconMap.get(name);
if (image == null) {
// prepare path
String path;
if (name.startsWith("/")) {
path = name;
} else {
path = "icons/" + name;
}
//
InputStream is = getFile(path);
try {
image = new Image(Display.getCurrent(), is);
m_nameToIconMap.put(name, image);
} finally {
IOUtils.closeQuietly(is);
}
}
return image;
}

/**
* Get image descriptor from "icons" directory.
*/
public static ImageDescriptor getImageDescriptor(String name) {
URL url = m_plugin.getBundle().getEntry("icons/" + name);
return ImageDescriptor.createFromURL(url);
}
/**
* Get image descriptor from "icons" directory.
*/
public static ImageDescriptor getImageDescriptor(String name) {
URL url = m_plugin.getBundle().getEntry("icons/" + name);
return ImageDescriptor.createFromURL(url);
}

////////////////////////////////////////////////////////////////////////////
//
// Preferences
//
////////////////////////////////////////////////////////////////////////////
/**
* Returns preference store for DB plugin.
*/
public static IPreferenceStore getStore() {
return m_plugin.getPreferenceStore();
}
////////////////////////////////////////////////////////////////////////////
//
// Preferences
//
////////////////////////////////////////////////////////////////////////////
/**
* Returns preference store for DB plugin.
*/
public static IPreferenceStore getStore() {
return m_plugin.getPreferenceStore();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import org.eclipse.osgi.util.NLS;

public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.wb.internal.core.databinding.xml.messages"; //$NON-NLS-1$
public static String BindingXmlPage_errorMessage;
public static String BindingXmlPage_name;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}
private static final String BUNDLE_NAME = "org.eclipse.wb.internal.core.databinding.xml.messages"; //$NON-NLS-1$
public static String BindingXmlPage_errorMessage;
public static String BindingXmlPage_name;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}

private Messages() {
}
private Messages() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
* @coverage bindings.xml.model
*/
public interface IDatabindingFactory {
/**
* @return {@link IDatabindingsProvider} for given root {@link XmlObjectInfo} or <code>null</code>
* if operation for given root not supported.
*/
IDatabindingsProvider createProvider(XmlObjectInfo xmlObjectRoot) throws Exception;
/**
* @return {@link IDatabindingsProvider} for given root {@link XmlObjectInfo} or <code>null</code>
* if operation for given root not supported.
*/
IDatabindingsProvider createProvider(XmlObjectInfo xmlObjectRoot) throws Exception;

/**
* @return {@link AbstractUIPlugin} host for this factory.
*/
AbstractUIPlugin getPlugin();
/**
* @return {@link AbstractUIPlugin} host for this factory.
*/
AbstractUIPlugin getPlugin();
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,50 +25,50 @@
* @coverage bindings.xml.model
*/
public final class SynchronizeManager {
private final IDatabindingsProvider m_provider;
private final IDatabindingsProvider m_provider;

////////////////////////////////////////////////////////////////////////////
//
// Constructor
//
////////////////////////////////////////////////////////////////////////////
public SynchronizeManager(IDatabindingsProvider provider, XmlObjectInfo xmlObjectRoot) {
m_provider = provider;
xmlObjectRoot.addBroadcastListener(new ObjectInfoDelete() {
@Override
public void after(ObjectInfo parent, ObjectInfo child) throws Exception {
synchronizeObserves();
}
});
xmlObjectRoot.addBroadcastListener(new XmlObjectAdd() {
@Override
public void after(ObjectInfo parent, final XmlObjectInfo child) throws Exception {
child.addBroadcastListener(new XmlObjectSetObjectAfter() {
@Override
public void invoke(XmlObjectInfo target, Object o) throws Exception {
if (child == target) {
target.removeBroadcastListener(this);
synchronizeObserves();
}
}
});
}
});
xmlObjectRoot.addBroadcastListener(new XmlObjectMove() {
@Override
public void after(XmlObjectInfo child, ObjectInfo oldParent, ObjectInfo newParent)
throws Exception {
synchronizeObserves();
}
});
}
////////////////////////////////////////////////////////////////////////////
//
// Constructor
//
////////////////////////////////////////////////////////////////////////////
public SynchronizeManager(IDatabindingsProvider provider, XmlObjectInfo xmlObjectRoot) {
m_provider = provider;
xmlObjectRoot.addBroadcastListener(new ObjectInfoDelete() {
@Override
public void after(ObjectInfo parent, ObjectInfo child) throws Exception {
synchronizeObserves();
}
});
xmlObjectRoot.addBroadcastListener(new XmlObjectAdd() {
@Override
public void after(ObjectInfo parent, final XmlObjectInfo child) throws Exception {
child.addBroadcastListener(new XmlObjectSetObjectAfter() {
@Override
public void invoke(XmlObjectInfo target, Object o) throws Exception {
if (child == target) {
target.removeBroadcastListener(this);
synchronizeObserves();
}
}
});
}
});
xmlObjectRoot.addBroadcastListener(new XmlObjectMove() {
@Override
public void after(XmlObjectInfo child, ObjectInfo oldParent, ObjectInfo newParent)
throws Exception {
synchronizeObserves();
}
});
}

////////////////////////////////////////////////////////////////////////////
//
// Handle
//
////////////////////////////////////////////////////////////////////////////
private void synchronizeObserves() throws Exception {
m_provider.synchronizeObserves();
}
////////////////////////////////////////////////////////////////////////////
//
// Handle
//
////////////////////////////////////////////////////////////////////////////
private void synchronizeObserves() throws Exception {
m_provider.synchronizeObserves();
}
}
Loading