-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
912 additions
and
7 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package org.jkiss.dbeaver.ui.editors.text; | ||
import org.eclipse.core.resources.IFile; | ||
import org.eclipse.core.resources.ResourcesPlugin; | ||
import org.eclipse.core.runtime.CoreException; | ||
import org.eclipse.jface.action.GroupMarker; | ||
import org.eclipse.jface.action.IAction; | ||
import org.eclipse.jface.action.IMenuManager; | ||
import org.eclipse.jface.action.Separator; | ||
import org.eclipse.jface.text.IDocument; | ||
import org.eclipse.jface.text.IUndoManager; | ||
import org.eclipse.jface.text.TextViewer; | ||
import org.eclipse.jface.text.source.SourceViewer; | ||
import org.eclipse.swt.SWT; | ||
import org.eclipse.swt.custom.ST; | ||
import org.eclipse.swt.custom.StyledText; | ||
import org.eclipse.swt.widgets.Composite; | ||
import org.eclipse.ui.IEditorInput; | ||
import org.eclipse.ui.IEditorPart; | ||
import org.eclipse.ui.IWorkbenchActionConstants; | ||
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditor; | ||
import org.eclipse.ui.texteditor.IDocumentProvider; | ||
import org.eclipse.ui.texteditor.ITextEditorActionConstants; | ||
import org.jkiss.code.Nullable; | ||
import org.jkiss.dbeaver.runtime.DBWorkbench; | ||
import org.jkiss.dbeaver.ui.ICommentsSupport; | ||
import org.jkiss.dbeaver.ui.ISingleControlEditor; | ||
import org.jkiss.dbeaver.ui.UIUtils; | ||
import org.jkiss.dbeaver.ui.dialogs.DialogUtils; | ||
import org.jkiss.dbeaver.ui.editors.*; | ||
import org.jkiss.dbeaver.utils.ContentUtils; | ||
import org.jkiss.dbeaver.utils.GeneralUtils; | ||
import org.jkiss.utils.IOUtils; | ||
import java.io.*; | ||
import java.lang.reflect.InvocationTargetException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
public abstract class BaseTextEditor extends AbstractDecoratedTextEditor implements ISingleControlEditor { | ||
public static final String TEXT_EDITOR_CONTEXT = "org.eclipse.ui.textEditorScope"; | ||
public static final String GROUP_SQL_PREFERENCES = "sql.preferences"; | ||
public static final String GROUP_SQL_ADDITIONS = "sql.additions"; | ||
public static final String GROUP_SQL_EXTRAS = "sql.extras"; | ||
private List<IActionContributor> actionContributors = new ArrayList<>(); | ||
public void addContextMenuContributor(IActionContributor contributor) { | ||
actionContributors.add(contributor); | ||
} | ||
public static BaseTextEditor getTextEditor(IEditorPart editor) | ||
{ | ||
if (editor == null) { | ||
return null; | ||
} | ||
if (editor instanceof BaseTextEditor) { | ||
return (BaseTextEditor) editor; | ||
} | ||
return editor.getAdapter(BaseTextEditor.class); | ||
} | ||
@Override | ||
protected void doSetInput(IEditorInput input) throws CoreException { | ||
if (input != getEditorInput()) { | ||
IEditorInput editorInput = getEditorInput(); | ||
if (editorInput instanceof IStatefulEditorInput) { | ||
((IStatefulEditorInput) editorInput).release(); | ||
} | ||
} | ||
super.doSetInput(input); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.netbeans.modules.web.common.api; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.concurrent.CopyOnWriteArrayList; | ||
import org.netbeans.api.annotations.common.CheckForNull; | ||
import org.netbeans.api.annotations.common.NonNull; | ||
import org.netbeans.api.annotations.common.NullAllowed; | ||
import org.netbeans.api.project.Project; | ||
import org.netbeans.modules.web.common.cssprep.CssPreprocessorAccessor; | ||
import org.netbeans.modules.web.common.cssprep.CssPreprocessorsAccessor; | ||
import org.netbeans.modules.web.common.spi.CssPreprocessorImplementation; | ||
import org.netbeans.modules.web.common.spi.CssPreprocessorImplementationListener; | ||
import org.openide.filesystems.FileObject; | ||
import org.openide.util.Lookup; | ||
import org.openide.util.LookupEvent; | ||
import org.openide.util.LookupListener; | ||
import org.openide.util.Parameters; | ||
import org.openide.util.RequestProcessor; | ||
import org.openide.util.lookup.Lookups; | ||
public final class CssPreprocessors { | ||
public static final String PREPROCESSORS_PATH = "CSS/PreProcessors"; | ||
private static final RequestProcessor RP = new RequestProcessor(CssPreprocessors.class.getName(), 2); | ||
private static final Lookup.Result<CssPreprocessorImplementation> PREPROCESSORS = Lookups.forPath(PREPROCESSORS_PATH).lookupResult(CssPreprocessorImplementation.class); | ||
private static final CssPreprocessors INSTANCE = new CssPreprocessors(); | ||
private final List<CssPreprocessor> preprocessors = new CopyOnWriteArrayList<>(); | ||
final CssPreprocessorsListener.Support listenersSupport = new CssPreprocessorsListener.Support(); | ||
private final PreprocessorImplementationsListener preprocessorImplementationsListener = new PreprocessorImplementationsListener(); | ||
|
||
void reinitProcessors() { | ||
synchronized (preprocessors) { | ||
clearProcessors(); | ||
assert preprocessors.isEmpty() : "Empty preprocessors expected but: " + preprocessors; | ||
preprocessors.addAll(map(PREPROCESSORS.allInstances())); | ||
for (CssPreprocessor cssPreprocessor : preprocessors) { | ||
cssPreprocessor.getDelegate().addCssPreprocessorListener(preprocessorImplementationsListener); | ||
} | ||
} | ||
listenersSupport.firePreprocessorsChanged(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
package org.openide.awt; | ||
import java.awt.Component; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.Map; | ||
import javax.swing.Action; | ||
import javax.swing.Icon; | ||
import javax.swing.ImageIcon; | ||
import javax.swing.JComponent; | ||
import javax.swing.JMenu; | ||
import javax.swing.JMenuItem; | ||
import javax.swing.JPopupMenu; | ||
import javax.swing.JSeparator; | ||
import javax.swing.UIManager; | ||
import org.openide.filesystems.FileObject; | ||
import org.openide.util.ImageUtilities; | ||
import org.openide.util.Utilities; | ||
import org.openide.util.actions.Presenter; | ||
class DynaMenuModel { | ||
private static final Icon BLANK_ICON = new ImageIcon(ImageUtilities.loadImage("org/openide/loaders/empty.gif")); | ||
private List<JComponent> menuItems; | ||
private HashMap<DynamicMenuContent, JComponent[]> actionToMenuMap; | ||
private boolean isWithIcons = false; | ||
public DynaMenuModel() { | ||
actionToMenuMap = new HashMap<DynamicMenuContent, JComponent[]>(); | ||
} | ||
public void loadSubmenu(List<Object> cInstances, JMenu m, boolean remove, Map<Object,FileObject> cookiesToFiles) { | ||
boolean addSeparator = false; | ||
Icon curIcon = null; | ||
Iterator it = cInstances.iterator(); | ||
menuItems = new ArrayList<JComponent>(cInstances.size()); | ||
actionToMenuMap.clear(); | ||
while (it.hasNext()) { | ||
Object obj = it.next(); | ||
if (obj instanceof Action) { | ||
FileObject file = cookiesToFiles.get(obj); | ||
if (file != null) { | ||
AcceleratorBinding.setAccelerator((Action) obj, file); | ||
} | ||
} | ||
if (obj instanceof Presenter.Menu) { | ||
obj = ((Presenter.Menu)obj).getMenuPresenter(); | ||
} | ||
if (obj instanceof DynamicMenuContent) { | ||
if(addSeparator) { | ||
menuItems.add(null); | ||
addSeparator = false; | ||
} | ||
DynamicMenuContent mn = (DynamicMenuContent)obj; | ||
JComponent[] itms = convertArray(mn.getMenuPresenters()); | ||
actionToMenuMap.put(mn, itms); | ||
Iterator itx = Arrays.asList(itms).iterator(); | ||
while (itx.hasNext()) { | ||
JComponent comp = (JComponent)itx.next(); | ||
menuItems.add(comp); | ||
isWithIcons = checkIcon(comp, isWithIcons); | ||
} | ||
continue; | ||
} | ||
if (obj instanceof JMenuItem) { | ||
if(addSeparator) { | ||
menuItems.add(null); | ||
addSeparator = false; | ||
} | ||
isWithIcons = checkIcon(obj, isWithIcons); | ||
menuItems.add((JMenuItem)obj); | ||
} else if (obj instanceof JSeparator) { | ||
addSeparator = menuItems.size() > 0; | ||
} else if (obj instanceof Action) { | ||
if(addSeparator) { | ||
menuItems.add(null); | ||
addSeparator = false; | ||
} | ||
Action a = (Action)obj; | ||
Actions.MenuItem item = new Actions.MenuItem(a, true); | ||
isWithIcons = checkIcon(item, isWithIcons); | ||
actionToMenuMap.put(item, new JComponent[] {item}); | ||
menuItems.add(item); | ||
} | ||
} | ||
if (isWithIcons) { | ||
menuItems = alignVertically(menuItems); | ||
} | ||
if (remove) { | ||
m.removeAll(); | ||
} | ||
JComponent curItem = null; | ||
boolean wasSeparator = false; | ||
for (Iterator<JComponent> iter = menuItems.iterator(); iter.hasNext(); ) { | ||
curItem = iter.next(); | ||
if (curItem == null) { | ||
JMenu menu = new JMenu(); | ||
menu.addSeparator(); | ||
curItem = (JSeparator)menu.getPopupMenu().getComponent(0); | ||
} | ||
m.add(curItem); | ||
boolean isSeparator = curItem instanceof JSeparator; | ||
if (isSeparator && wasSeparator) { | ||
curItem.setVisible(false); | ||
} | ||
if (!(curItem instanceof InvisibleMenuItem)) { | ||
wasSeparator = isSeparator; | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package org.springframework.messaging.rsocket; | ||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
import io.netty.buffer.ByteBuf; | ||
import io.netty.buffer.ByteBufAllocator; | ||
import io.netty.buffer.CompositeByteBuf; | ||
import io.rsocket.metadata.CompositeMetadataFlyweight; | ||
import io.rsocket.metadata.TaggingMetadataFlyweight; | ||
import io.rsocket.metadata.WellKnownMimeType; | ||
import reactor.core.publisher.Mono; | ||
import org.springframework.core.ReactiveAdapter; | ||
import org.springframework.core.ResolvableType; | ||
import org.springframework.core.codec.Encoder; | ||
import org.springframework.core.io.buffer.DataBuffer; | ||
import org.springframework.core.io.buffer.DataBufferFactory; | ||
import org.springframework.core.io.buffer.NettyDataBufferFactory; | ||
import org.springframework.lang.Nullable; | ||
import org.springframework.util.Assert; | ||
import org.springframework.util.CollectionUtils; | ||
import org.springframework.util.MimeType; | ||
import org.springframework.util.ObjectUtils; | ||
final class MetadataEncoder { | ||
private static final Pattern VARS_PATTERN = Pattern.compile("\\{(.+?)}"); | ||
private static final Object NO_VALUE = new Object(); | ||
private final MimeType metadataMimeType; | ||
private final RSocketStrategies strategies; | ||
private final boolean isComposite; | ||
private final ByteBufAllocator allocator; | ||
@Nullable | ||
private String route; | ||
private final List<MetadataEntry> metadataEntries = new ArrayList<>(4); | ||
private boolean hasAsyncValues; | ||
MetadataEncoder(MimeType metadataMimeType, RSocketStrategies strategies) { | ||
Assert.notNull(metadataMimeType, "'metadataMimeType' is required"); | ||
Assert.notNull(strategies, "RSocketStrategies is required"); | ||
this.metadataMimeType = metadataMimeType; | ||
this.strategies = strategies; | ||
this.isComposite = this.metadataMimeType.toString().equals( | ||
WellKnownMimeType.MESSAGE_RSOCKET_COMPOSITE_METADATA.getString()); | ||
this.allocator = bufferFactory() instanceof NettyDataBufferFactory ? | ||
((NettyDataBufferFactory) bufferFactory()).getByteBufAllocator() : ByteBufAllocator.DEFAULT; | ||
} | ||
private DataBufferFactory bufferFactory() { | ||
return this.strategies.dataBufferFactory(); | ||
} | ||
public MetadataEncoder route(String route, Object... routeVars) { | ||
this.route = expand(route, routeVars); | ||
if (!this.isComposite) { | ||
int count = this.route != null ? this.metadataEntries.size() + 1 : this.metadataEntries.size(); | ||
Assert.isTrue(count < 2, "Composite metadata required for multiple metadata entries."); | ||
} | ||
return this; | ||
} | ||
|
||
} |
Oops, something went wrong.