bugged
stringlengths
6
599k
fixed
stringlengths
10
599k
__index_level_0__
int64
0
1.13M
public Binding bind(IObservable targetObservable, IObservable modelObservable, BindSpec bindSpec) { Binding result = doCreateBinding(targetObservable, modelObservable, bindSpec, this); if (result != null) return result; throw new BindingException( "No binding found for target: " + targetObservable.getClass().getName() + ", model: " + modelObservable.getClass().getName()); //$NON-NLS-1$ //$NON-NLS-2$ }
public Binding bind(IObservable targetObservable, IObservable modelObservable, org.eclipse.jface.databinding.BindSpec bindSpec) { Binding result = doCreateBinding(targetObservable, modelObservable, bindSpec, this); if (result != null) return result; throw new BindingException( "No binding found for target: " + targetObservable.getClass().getName() + ", model: " + modelObservable.getClass().getName()); //$NON-NLS-1$ //$NON-NLS-2$ }
1,120,941
public DialogMarkerProperties(Shell parentShell, String title) { super(parentShell); setShellStyle(getShellStyle() | SWT.RESIZE); this.title = title; }
public DialogMarkerProperties(Shell parentShell) { super(parentShell); setShellStyle(getShellStyle() | SWT.RESIZE); this.title = title; }
1,120,942
public DialogMarkerProperties(Shell parentShell, String title) { super(parentShell); setShellStyle(getShellStyle() | SWT.RESIZE); this.title = title; }
public DialogMarkerProperties(Shell parentShell, String title) { super(parentShell); setShellStyle(getShellStyle() | SWT.RESIZE); }
1,120,943
public IViewReference createView(String id, String secondaryId) throws PartInitException { IViewDescriptor desc = viewReg.find(id); // ensure that the view id is valid if (desc == null) throw new PartInitException(WorkbenchMessages.format("ViewFactory.couldNotCreate", new Object[] { id })); //$NON-NLS-1$ // ensure that multiple instances are allowed if a secondary id is given if (secondaryId != null) { if (!desc.getAllowMultiple()) { throw new PartInitException(WorkbenchMessages.format("ViewFactory.noMultiple", new Object[] { id })); //$NON-NLS-1$ } } String key = getKey(id, secondaryId); IViewReference ref = (IViewReference) counter.get(key); if (ref == null) { IMemento memento = (IMemento)mementoTable.get(id); ref = new ViewReference(id, secondaryId, memento); counter.put(key, ref); } else { counter.addRef(key); } return ref; }
public IViewReference createView(String id, String secondaryId) throws PartInitException { IViewDescriptor desc = viewReg.find(id); // ensure that the view id is valid if (desc == null) throw new PartInitException(WorkbenchMessages.format("ViewFactory.couldNotCreate", new Object[] { id })); //$NON-NLS-1$ // ensure that multiple instances are allowed if a secondary id is given if (secondaryId != null) { if (!desc.getAllowMultiple()) { throw new PartInitException(WorkbenchMessages.format("ViewFactory.noMultiple", new Object[] { id })); //$NON-NLS-1$ } } String key = getKey(id, secondaryId); IViewReference ref = (IViewReference) counter.get(key); if (ref == null) { IMemento memento = (IMemento)mementoTable.get(id); ref = new ViewReference(id, secondaryId, memento); counter.put(key, ref); } else { counter.addRef(key); } return ref; }
1,120,944
public PartStack(int appearance, AbstractPresentationFactory factory) { super("PartStack"); //$NON-NLS-1$ this.appearance = appearance; this.factory = factory; }
public PartStack(int appearance, AbstractPresentationFactory factory) { super("PartStack"); //$NON-NLS-1$ this.appearance = appearance; this.factory = factory; }
1,120,945
public void setPerspective(final IPerspectiveDescriptor desc) { if (Util.equals(getPerspective(), desc)) { return; } // Going from multiple to single rows can make the coolbar // and its adjacent views appear jumpy as perspectives are // switched. Turn off redraw to help with this. ICoolBarManager2 mgr = (ICoolBarManager2) window.getCoolBarManager2(); try { mgr.getControl2().setRedraw(false); getClientComposite().setRedraw(false); // Run op in busy cursor. BusyIndicator.showWhile(null, new Runnable() { public void run() { busySetPerspective(desc); } }); } finally { getClientComposite().setRedraw(true); mgr.getControl2().setRedraw(true); IWorkbenchPart part = getActivePart(); if (part != null) { part.setFocus(); } } }
public void setPerspective(final IPerspectiveDescriptor desc) { if (Util.equals(getPerspective(), desc)) { return; } // Going from multiple to single rows can make the coolbar // and its adjacent views appear jumpy as perspectives are // switched. Turn off redraw to help with this. ICoolBarManager2 mgr = (ICoolBarManager2) window.getCoolBarManager2(); try { mgr.getControl2().setRedraw(false); getClientComposite().setRedraw(false); // Run op in busy cursor. BusyIndicator.showWhile(null, new Runnable() { public void run() { busySetPerspective(desc); } }); } finally { getClientComposite().setRedraw(true); mgr.getControl2().setRedraw(true); IWorkbenchPart part = getActivePart(); if (part != null) { part.setFocus(); } } }
1,120,946
public void setPerspective(final IPerspectiveDescriptor desc) { if (Util.equals(getPerspective(), desc)) { return; } // Going from multiple to single rows can make the coolbar // and its adjacent views appear jumpy as perspectives are // switched. Turn off redraw to help with this. ICoolBarManager2 mgr = (ICoolBarManager2) window.getCoolBarManager2(); try { mgr.getControl2().setRedraw(false); getClientComposite().setRedraw(false); // Run op in busy cursor. BusyIndicator.showWhile(null, new Runnable() { public void run() { busySetPerspective(desc); } }); } finally { getClientComposite().setRedraw(true); mgr.getControl2().setRedraw(true); IWorkbenchPart part = getActivePart(); if (part != null) { part.setFocus(); } } }
public void setPerspective(final IPerspectiveDescriptor desc) { if (Util.equals(getPerspective(), desc)) { return; } // Going from multiple to single rows can make the coolbar // and its adjacent views appear jumpy as perspectives are // switched. Turn off redraw to help with this. ICoolBarManager2 mgr = (ICoolBarManager2) window.getCoolBarManager2(); try { mgr.getControl2().setRedraw(false); getClientComposite().setRedraw(false); // Run op in busy cursor. BusyIndicator.showWhile(null, new Runnable() { public void run() { busySetPerspective(desc); } }); } finally { getClientComposite().setRedraw(true); mgr.getControl2().setRedraw(true); IWorkbenchPart part = getActivePart(); if (part != null) { part.setFocus(); } } }
1,120,947
public void setPerspective(final IPerspectiveDescriptor desc) { if (Util.equals(getPerspective(), desc)) { return; } // Going from multiple to single rows can make the coolbar // and its adjacent views appear jumpy as perspectives are // switched. Turn off redraw to help with this. ICoolBarManager2 mgr = (ICoolBarManager2) window.getCoolBarManager2(); try { mgr.getControl2().setRedraw(false); getClientComposite().setRedraw(false); // Run op in busy cursor. BusyIndicator.showWhile(null, new Runnable() { public void run() { busySetPerspective(desc); } }); } finally { getClientComposite().setRedraw(true); mgr.getControl2().setRedraw(true); IWorkbenchPart part = getActivePart(); if (part != null) { part.setFocus(); } } }
public void setPerspective(final IPerspectiveDescriptor desc) { if (Util.equals(getPerspective(), desc)) { return; } // Going from multiple to single rows can make the coolbar // and its adjacent views appear jumpy as perspectives are // switched. Turn off redraw to help with this. ICoolBarManager2 mgr = (ICoolBarManager2) window.getCoolBarManager2(); try { mgr.getControl2().setRedraw(false); getClientComposite().setRedraw(false); // Run op in busy cursor. BusyIndicator.showWhile(null, new Runnable() { public void run() { busySetPerspective(desc); } } } finally { getClientComposite().setRedraw(true); mgr.getControl2().setRedraw(true); IWorkbenchPart part = getActivePart(); if (part != null) { part.setFocus(); } } }
1,120,948
public void setPerspective(final IPerspectiveDescriptor desc) { if (Util.equals(getPerspective(), desc)) { return; } // Going from multiple to single rows can make the coolbar // and its adjacent views appear jumpy as perspectives are // switched. Turn off redraw to help with this. ICoolBarManager2 mgr = (ICoolBarManager2) window.getCoolBarManager2(); try { mgr.getControl2().setRedraw(false); getClientComposite().setRedraw(false); // Run op in busy cursor. BusyIndicator.showWhile(null, new Runnable() { public void run() { busySetPerspective(desc); } }); } finally { getClientComposite().setRedraw(true); mgr.getControl2().setRedraw(true); IWorkbenchPart part = getActivePart(); if (part != null) { part.setFocus(); } } }
public void setPerspective(final IPerspectiveDescriptor desc) { if (Util.equals(getPerspective(), desc)) { return; } // Going from multiple to single rows can make the coolbar // and its adjacent views appear jumpy as perspectives are // switched. Turn off redraw to help with this. ICoolBarManager2 mgr = (ICoolBarManager2) window.getCoolBarManager2(); try { mgr.getControl2().setRedraw(false); getClientComposite().setRedraw(false); // Run op in busy cursor. BusyIndicator.showWhile(null, new Runnable() { public void run() { busySetPerspective(desc); } }); } finally { getClientComposite().setRedraw(true); mgr.getControl2().setRedraw(true); IWorkbenchPart part = getActivePart(); if (part != null) { part.setFocus(); } } }
1,120,949
public SLocation(final SLocation parent, final String id) { this(parent, id, MNEMONIC_NONE); }
public SLocation(final SLocation parent, final String id) { this(parent, id, MNEMONIC_NONE); }
1,120,951
public static final boolean equals(final Object[] leftArray, final Object[] rightArray) { if (leftArray.length != rightArray.length) { return false; } for (int i = 0; i < leftArray.length; i++) { final Object left = leftArray[i]; final Object right = rightArray[i]; final boolean equal = (left == null) ? (right == null) : (left .equals(right)); if (!equal) { return false; } } return true; }
public static final boolean equals(final Object[] leftArray, final Object[] rightArray) { if (leftArray.length != rightArray.length) { return false; } for (int i = 0; i < leftArray.length; i++) { final Object left = leftArray[i]; final Object right = rightArray[i]; final boolean equal = (left == null) ? (right == null) : (left .equals(right)); if (!equal) { return false; } } return true; }
1,120,952
public void hideView(IViewPart view) { hideView((IViewReference)getReference(view)); }
public void hideView(IViewPart view) { hideView((IViewReference)getReference(view)); }
1,120,953
public void selectionChanged(SelectionChangedEvent event) { ISelection sel = event.getSelection(); if (sel instanceof IStructuredSelection) selectionChanged((IStructuredSelection) sel); }
public void selectionChanged(SelectionChangedEvent event) { ISelection sel = event.getSelection(); if (sel instanceof IStructuredSelection) selectionChanged((IStructuredSelection) sel); }
1,120,954
public FontFieldEditor(String name, String labelText, String previewAreaText, Composite parent) { init(name, labelText); previewText = previewAreaText; changeButtonText = JFaceResources.getString("openChange"); //$NON-NLS-1$ createControl(parent); }
public FontFieldEditor(String name, String labelText, String previewAreaText, Composite parent) { init(name, labelText); previewText = previewAreaText; changeButtonText = JFaceResources.getString("openChange"); //$NON-NLS-1$ createControl(parent); }
1,120,955
public static ImageDescriptor createFromImage(Image img, Device theDevice) { return new ImageDataImageDescriptor(img, theDevice); }
public static ImageDescriptor createFromImage(Image img, Device theDevice) { return new ImageDataImageDescriptor(img, theDevice); }
1,120,956
public void fill(Menu parent, int index) { if (widget == null && parent != null) { Menu subMenu = null; int flags = SWT.PUSH; if (action != null) { int style = action.getStyle(); if (style == IAction.AS_CHECK_BOX) { flags = SWT.CHECK; } else if (style == IAction.AS_RADIO_BUTTON) { flags = SWT.RADIO; } else if (style == IAction.AS_DROP_DOWN_MENU) { IMenuCreator mc = action.getMenuCreator(); if (mc != null) { subMenu = mc.getMenu(parent); flags = SWT.CASCADE; } } } MenuItem mi = null; if (index >= 0) { mi = new MenuItem(parent, flags, index); } else { mi = new MenuItem(parent, flags); } widget = mi; mi.setData(this); mi.addListener(SWT.Dispose, getMenuItemListener()); mi.addListener(SWT.Selection, getMenuItemListener()); if (action.getHelpListener() != null) { mi.addHelpListener(action.getHelpListener()); } if (subMenu != null) { mi.setMenu(subMenu); } update(null); // Attach some extra listeners. action.addPropertyChangeListener(propertyListener); if (action != null) { String commandId = action.getActionDefinitionId(); ExternalActionManager.ICallback callback = ExternalActionManager .getInstance().getCallback(); if ((callback != null) && (commandId != null)) { callback.addPropertyChangeListener(commandId, actionTextListener); } } } }
public void fill(Composite parent) { if (widget == null && parent != null) { Menu subMenu = null; int flags = SWT.PUSH; if (action != null) { int style = action.getStyle(); if (style == IAction.AS_CHECK_BOX) { flags = SWT.CHECK; } else if (style == IAction.AS_RADIO_BUTTON) { flags = SWT.RADIO; } else if (style == IAction.AS_DROP_DOWN_MENU) { IMenuCreator mc = action.getMenuCreator(); if (mc != null) { subMenu = mc.getMenu(parent); flags = SWT.CASCADE; } } } MenuItem mi = null; if (index >= 0) { mi = new MenuItem(parent, flags, index); } else { mi = new MenuItem(parent, flags); } widget = mi; mi.setData(this); mi.addListener(SWT.Dispose, getMenuItemListener()); mi.addListener(SWT.Selection, getMenuItemListener()); if (action.getHelpListener() != null) { mi.addHelpListener(action.getHelpListener()); } if (subMenu != null) { mi.setMenu(subMenu); } update(null); // Attach some extra listeners. action.addPropertyChangeListener(propertyListener); if (action != null) { String commandId = action.getActionDefinitionId(); ExternalActionManager.ICallback callback = ExternalActionManager .getInstance().getCallback(); if ((callback != null) && (commandId != null)) { callback.addPropertyChangeListener(commandId, actionTextListener); } } } }
1,120,957
public void fill(Menu parent, int index) { if (widget == null && parent != null) { Menu subMenu = null; int flags = SWT.PUSH; if (action != null) { int style = action.getStyle(); if (style == IAction.AS_CHECK_BOX) { flags = SWT.CHECK; } else if (style == IAction.AS_RADIO_BUTTON) { flags = SWT.RADIO; } else if (style == IAction.AS_DROP_DOWN_MENU) { IMenuCreator mc = action.getMenuCreator(); if (mc != null) { subMenu = mc.getMenu(parent); flags = SWT.CASCADE; } } } MenuItem mi = null; if (index >= 0) { mi = new MenuItem(parent, flags, index); } else { mi = new MenuItem(parent, flags); } widget = mi; mi.setData(this); mi.addListener(SWT.Dispose, getMenuItemListener()); mi.addListener(SWT.Selection, getMenuItemListener()); if (action.getHelpListener() != null) { mi.addHelpListener(action.getHelpListener()); } if (subMenu != null) { mi.setMenu(subMenu); } update(null); // Attach some extra listeners. action.addPropertyChangeListener(propertyListener); if (action != null) { String commandId = action.getActionDefinitionId(); ExternalActionManager.ICallback callback = ExternalActionManager .getInstance().getCallback(); if ((callback != null) && (commandId != null)) { callback.addPropertyChangeListener(commandId, actionTextListener); } } } }
public void fill(Menu parent, int index) { if (widget == null && parent != null) { int flags = SWT.PUSH; if (action != null) { int style = action.getStyle(); if (style == IAction.AS_CHECK_BOX) { flags = SWT.CHECK; } else if (style == IAction.AS_RADIO_BUTTON) { flags = SWT.RADIO; } else if (style == IAction.AS_DROP_DOWN_MENU) { IMenuCreator mc = action.getMenuCreator(); if (mc != null) { subMenu = mc.getMenu(parent); flags = SWT.CASCADE; } } } MenuItem mi = null; if (index >= 0) { mi = new MenuItem(parent, flags, index); } else { mi = new MenuItem(parent, flags); } widget = mi; mi.setData(this); mi.addListener(SWT.Dispose, getMenuItemListener()); mi.addListener(SWT.Selection, getMenuItemListener()); if (action.getHelpListener() != null) { mi.addHelpListener(action.getHelpListener()); } if (subMenu != null) { mi.setMenu(subMenu); } update(null); // Attach some extra listeners. action.addPropertyChangeListener(propertyListener); if (action != null) { String commandId = action.getActionDefinitionId(); ExternalActionManager.ICallback callback = ExternalActionManager .getInstance().getCallback(); if ((callback != null) && (commandId != null)) { callback.addPropertyChangeListener(commandId, actionTextListener); } } } }
1,120,958
public void fill(Menu parent, int index) { if (widget == null && parent != null) { Menu subMenu = null; int flags = SWT.PUSH; if (action != null) { int style = action.getStyle(); if (style == IAction.AS_CHECK_BOX) { flags = SWT.CHECK; } else if (style == IAction.AS_RADIO_BUTTON) { flags = SWT.RADIO; } else if (style == IAction.AS_DROP_DOWN_MENU) { IMenuCreator mc = action.getMenuCreator(); if (mc != null) { subMenu = mc.getMenu(parent); flags = SWT.CASCADE; } } } MenuItem mi = null; if (index >= 0) { mi = new MenuItem(parent, flags, index); } else { mi = new MenuItem(parent, flags); } widget = mi; mi.setData(this); mi.addListener(SWT.Dispose, getMenuItemListener()); mi.addListener(SWT.Selection, getMenuItemListener()); if (action.getHelpListener() != null) { mi.addHelpListener(action.getHelpListener()); } if (subMenu != null) { mi.setMenu(subMenu); } update(null); // Attach some extra listeners. action.addPropertyChangeListener(propertyListener); if (action != null) { String commandId = action.getActionDefinitionId(); ExternalActionManager.ICallback callback = ExternalActionManager .getInstance().getCallback(); if ((callback != null) && (commandId != null)) { callback.addPropertyChangeListener(commandId, actionTextListener); } } } }
public void fill(Menu parent, int index) { if (widget == null && parent != null) { Menu subMenu = null; int flags = SWT.PUSH; if (action != null) { int style = action.getStyle(); if (style == IAction.AS_CHECK_BOX) { flags = SWT.CHECK; } else if (style == IAction.AS_RADIO_BUTTON) { flags = SWT.RADIO; } else if (style == IAction.AS_DROP_DOWN_MENU) { IMenuCreator mc = action.getMenuCreator(); if (mc != null) { subMenu = mc.getMenu(parent); flags = SWT.CASCADE; } } } MenuItem mi = null; if (index >= 0) { mi = new MenuItem(parent, flags, index); } else { mi = new MenuItem(parent, flags); } widget = mi; mi.setData(this); mi.addListener(SWT.Dispose, getMenuItemListener()); mi.addListener(SWT.Selection, getMenuItemListener()); if (action.getHelpListener() != null) { mi.addHelpListener(action.getHelpListener()); } if (subMenu != null) { mi.setMenu(subMenu); } update(null); // Attach some extra listeners. action.addPropertyChangeListener(propertyListener); if (action != null) { String commandId = action.getActionDefinitionId(); ExternalActionManager.ICallback callback = ExternalActionManager .getInstance().getCallback(); if ((callback != null) && (commandId != null)) { callback.addPropertyChangeListener(commandId, actionTextListener); } } } }
1,120,959
public void fill(Menu parent, int index) { if (widget == null && parent != null) { Menu subMenu = null; int flags = SWT.PUSH; if (action != null) { int style = action.getStyle(); if (style == IAction.AS_CHECK_BOX) { flags = SWT.CHECK; } else if (style == IAction.AS_RADIO_BUTTON) { flags = SWT.RADIO; } else if (style == IAction.AS_DROP_DOWN_MENU) { IMenuCreator mc = action.getMenuCreator(); if (mc != null) { subMenu = mc.getMenu(parent); flags = SWT.CASCADE; } } } MenuItem mi = null; if (index >= 0) { mi = new MenuItem(parent, flags, index); } else { mi = new MenuItem(parent, flags); } widget = mi; mi.setData(this); mi.addListener(SWT.Dispose, getMenuItemListener()); mi.addListener(SWT.Selection, getMenuItemListener()); if (action.getHelpListener() != null) { mi.addHelpListener(action.getHelpListener()); } if (subMenu != null) { mi.setMenu(subMenu); } update(null); // Attach some extra listeners. action.addPropertyChangeListener(propertyListener); if (action != null) { String commandId = action.getActionDefinitionId(); ExternalActionManager.ICallback callback = ExternalActionManager .getInstance().getCallback(); if ((callback != null) && (commandId != null)) { callback.addPropertyChangeListener(commandId, actionTextListener); } } } }
public void fill(Menu parent, int index) { if (widget == null && parent != null) { Menu subMenu = null; int flags = SWT.PUSH; if (action != null) { int style = action.getStyle(); if (style == IAction.AS_CHECK_BOX) { flags = SWT.CHECK; } else if (style == IAction.AS_RADIO_BUTTON) { flags = SWT.RADIO; } else if (style == IAction.AS_DROP_DOWN_MENU) { IMenuCreator mc = action.getMenuCreator(); if (mc != null) { subMenu = mc.getMenu(parent); flags = SWT.CASCADE; } } } MenuItem mi = null; if (index >= 0) { mi = new MenuItem(parent, flags, index); } else { mi = new MenuItem(parent, flags); } widget = mi; mi.setData(this); mi.addListener(SWT.Dispose, getMenuItemListener()); mi.addListener(SWT.Selection, getMenuItemListener()); if (action.getHelpListener() != null) { mi.addHelpListener(action.getHelpListener()); } if (subMenu != null) { mi.setMenu(subMenu); } update(null); // Attach some extra listeners. action.addPropertyChangeListener(propertyListener); if (action != null) { String commandId = action.getActionDefinitionId(); ExternalActionManager.ICallback callback = ExternalActionManager .getInstance().getCallback(); if ((callback != null) && (commandId != null)) { callback.addPropertyChangeListener(commandId, actionTextListener); } } } }
1,120,960
public void fill(Menu parent, int index) { if (widget == null && parent != null) { Menu subMenu = null; int flags = SWT.PUSH; if (action != null) { int style = action.getStyle(); if (style == IAction.AS_CHECK_BOX) { flags = SWT.CHECK; } else if (style == IAction.AS_RADIO_BUTTON) { flags = SWT.RADIO; } else if (style == IAction.AS_DROP_DOWN_MENU) { IMenuCreator mc = action.getMenuCreator(); if (mc != null) { subMenu = mc.getMenu(parent); flags = SWT.CASCADE; } } } MenuItem mi = null; if (index >= 0) { mi = new MenuItem(parent, flags, index); } else { mi = new MenuItem(parent, flags); } widget = mi; mi.setData(this); mi.addListener(SWT.Dispose, getMenuItemListener()); mi.addListener(SWT.Selection, getMenuItemListener()); if (action.getHelpListener() != null) { mi.addHelpListener(action.getHelpListener()); } if (subMenu != null) { mi.setMenu(subMenu); } update(null); // Attach some extra listeners. action.addPropertyChangeListener(propertyListener); if (action != null) { String commandId = action.getActionDefinitionId(); ExternalActionManager.ICallback callback = ExternalActionManager .getInstance().getCallback(); if ((callback != null) && (commandId != null)) { callback.addPropertyChangeListener(commandId, actionTextListener); } } } }
public void fill(Menu parent, int index) { if (widget == null && parent != null) { Menu subMenu = null; int flags = SWT.PUSH; if (action != null) { int style = action.getStyle(); if (style == IAction.AS_CHECK_BOX) { flags = SWT.CHECK; } else if (style == IAction.AS_RADIO_BUTTON) { flags = SWT.RADIO; } else if (style == IAction.AS_DROP_DOWN_MENU) { IMenuCreator mc = action.getMenuCreator(); if (mc != null) { subMenu = mc.getMenu(parent); flags = SWT.CASCADE; } } } MenuItem mi = null; if (index >= 0) { mi = new MenuItem(parent, flags, index); } else { mi = new MenuItem(parent, flags); } widget = mi; mi.setData(this); mi.addListener(SWT.Dispose, getMenuItemListener()); mi.addListener(SWT.Selection, getMenuItemListener()); if (action.getHelpListener() != null) { mi.addHelpListener(action.getHelpListener()); } if (subMenu != null) { mi.setMenu(subMenu); } update(null); // Attach some extra listeners. action.addPropertyChangeListener(propertyListener); if (action != null) { String commandId = action.getActionDefinitionId(); ExternalActionManager.ICallback callback = ExternalActionManager .getInstance().getCallback(); if ((callback != null) && (commandId != null)) { callback.addPropertyChangeListener(commandId, actionTextListener); } } } }
1,120,961
public void fill(Menu parent, int index) { if (widget == null && parent != null) { Menu subMenu = null; int flags = SWT.PUSH; if (action != null) { int style = action.getStyle(); if (style == IAction.AS_CHECK_BOX) { flags = SWT.CHECK; } else if (style == IAction.AS_RADIO_BUTTON) { flags = SWT.RADIO; } else if (style == IAction.AS_DROP_DOWN_MENU) { IMenuCreator mc = action.getMenuCreator(); if (mc != null) { subMenu = mc.getMenu(parent); flags = SWT.CASCADE; } } } MenuItem mi = null; if (index >= 0) { mi = new MenuItem(parent, flags, index); } else { mi = new MenuItem(parent, flags); } widget = mi; mi.setData(this); mi.addListener(SWT.Dispose, getMenuItemListener()); mi.addListener(SWT.Selection, getMenuItemListener()); if (action.getHelpListener() != null) { mi.addHelpListener(action.getHelpListener()); } if (subMenu != null) { mi.setMenu(subMenu); } update(null); // Attach some extra listeners. action.addPropertyChangeListener(propertyListener); if (action != null) { String commandId = action.getActionDefinitionId(); ExternalActionManager.ICallback callback = ExternalActionManager .getInstance().getCallback(); if ((callback != null) && (commandId != null)) { callback.addPropertyChangeListener(commandId, actionTextListener); } } } }
public void fill(Menu parent, int index) { if (widget == null && parent != null) { Menu subMenu = null; int flags = SWT.PUSH; if (action != null) { int style = action.getStyle(); if (style == IAction.AS_CHECK_BOX) { flags = SWT.CHECK; } else if (style == IAction.AS_RADIO_BUTTON) { flags = SWT.RADIO; } else if (style == IAction.AS_DROP_DOWN_MENU) { IMenuCreator mc = action.getMenuCreator(); if (mc != null) { subMenu = mc.getMenu(parent); flags = SWT.CASCADE; } } } MenuItem mi = null; if (index >= 0) { mi = new MenuItem(parent, flags, index); } else { mi = new MenuItem(parent, flags); } widget = mi; mi.setData(this); mi.addListener(SWT.Dispose, getMenuItemListener()); mi.addListener(SWT.Selection, getMenuItemListener()); if (action.getHelpListener() != null) { mi.addHelpListener(action.getHelpListener()); } if (subMenu != null) { mi.setMenu(subMenu); } update(null); // Attach some extra listeners. action.addPropertyChangeListener(propertyListener); if (action != null) { String commandId = action.getActionDefinitionId(); ExternalActionManager.ICallback callback = ExternalActionManager .getInstance().getCallback(); if ((callback != null) && (commandId != null)) { callback.addPropertyChangeListener(commandId, actionTextListener); } } } }
1,120,962
public void write(IFile resource, String destinationPath) throws IOException, CoreException { ZipEntry newEntry = new ZipEntry(destinationPath); write(newEntry, resource); }
public void write(IFile resource, String destinationPath) throws IOException, CoreException { ZipEntry newEntry = new ZipEntry(destinationPath); write(newEntry, resource); }
1,120,963
public boolean isPartVisible(IWorkbenchPartReference reference) { IWorkbenchPart part = reference.getPart(false); // Can't be visible if it isn't created yet if (part == null) { return false; } return isPartVisible(part); }
public boolean isPartVisible(IWorkbenchPartReference reference) { IWorkbenchPart part = reference.getPart(false); // Can't be visible if it isn't created yet if (part == null) { return false; } return isPartVisible(part); }
1,120,964
public void applyFontsAndColors(TreeItem control) { if(colorProvider == null){ if(usedDecorators){ //If there is no provider only apply set values if(background != null) control.setBackground(background); if(foreground != null) control.setForeground(foreground); } } else{ //Always set the value if there is a provider control.setBackground(background); control.setForeground(foreground); } if(fontProvider == null){ if(usedDecorators && font != null) control.setFont(font); } else//Always set the value if there is a provider control.setFont(font); clear(); }
public void applyFontsAndColors(TreeItem control) { if(colorProvider == null){ if(usedDecorators){ //If there is no provider only apply set values if(background != null) control.setBackground(background); if(foreground != null) control.setForeground(foreground); } } else{ //Always set the value if there is a provider control.setBackground(background); control.setForeground(foreground); } if(fontProvider == null){ if(usedDecorators && font != null) control.setFont(font); } else//Always set the value if there is a provider control.setFont(font); clear(); }
1,120,965
public void applyFontsAndColors(TreeItem control) { if(colorProvider == null){ if(usedDecorators){ //If there is no provider only apply set values if(background != null) control.setBackground(background); if(foreground != null) control.setForeground(foreground); } } else{ //Always set the value if there is a provider control.setBackground(background); control.setForeground(foreground); } if(fontProvider == null){ if(usedDecorators && font != null) control.setFont(font); } else//Always set the value if there is a provider control.setFont(font); clear(); }
public void applyFontsAndColors(TreeItem control) { if(colorProvider == null){ if(usedDecorators){ //If there is no provider only apply set values if(background != null) control.setBackground(background); if(foreground != null) control.setForeground(foreground); } } else{ //Always set the value if there is a provider control.setBackground(background); control.setForeground(foreground); } if(fontProvider == null){ if(usedDecorators && font != null) control.setFont(font); } else//Always set the value if there is a provider control.setFont(font); clear(); }
1,120,966
public void applyFontsAndColors(TreeItem control) { if(colorProvider == null){ if(usedDecorators){ //If there is no provider only apply set values if(background != null) control.setBackground(background); if(foreground != null) control.setForeground(foreground); } } else{ //Always set the value if there is a provider control.setBackground(background); control.setForeground(foreground); } if(fontProvider == null){ if(usedDecorators && font != null) control.setFont(font); } else//Always set the value if there is a provider control.setFont(font); clear(); }
public void applyFontsAndColors(TreeItem control) { if(colorProvider == null){ if(usedDecorators){ //If there is no provider only apply set values if(background != null) control.setBackground(background); if(foreground != null) control.setForeground(foreground); } } else{ //Always set the value if there is a provider control.setBackground(background); control.setForeground(foreground); } if(fontProvider == null){ if(usedDecorators && font != null) control.setFont(font); } else//Always set the value if there is a provider control.setFont(font); clear(); }
1,120,967
public void update(String propertyName) { if (widget != null) { // determine what to do boolean textChanged = propertyName == null || propertyName.equals(IAction.TEXT); boolean imageChanged = propertyName == null || propertyName.equals(IAction.IMAGE); boolean tooltipTextChanged = propertyName == null || propertyName.equals(IAction.TOOL_TIP_TEXT); boolean enableStateChanged = propertyName == null || propertyName.equals(IAction.ENABLED) || propertyName .equals(IContributionManagerOverrides.P_ENABLED); boolean checkChanged = (action.getStyle() == IAction.AS_CHECK_BOX || action .getStyle() == IAction.AS_RADIO_BUTTON) && (propertyName == null || propertyName .equals(IAction.CHECKED)); if (widget instanceof ToolItem) { ToolItem ti = (ToolItem) widget; String text = action.getText(); // the set text is shown only if there is no image or if forced by MODE_FORCE_TEXT boolean showText = text != null && ((getMode() & MODE_FORCE_TEXT) != 0 || !hasImages(action)); // only do the trimming if the text will be used if (showText && text != null) { text = Action.removeAcceleratorText(text); text = Action.removeMnemonics(text); } if (textChanged) { String textToSet = showText ? text : ""; //$NON-NLS-1$ boolean rightStyle = (ti.getParent().getStyle() & SWT.RIGHT) != 0; if (rightStyle || !ti.getText().equals(textToSet)) { // In addition to being required to update the text if it // gets nulled out in the action, this is also a workaround // for bug 50151: Using SWT.RIGHT on a ToolBar leaves blank space ti.setText(textToSet); } } if (imageChanged) { // only substitute a missing image if it has no text updateImages(!showText); } if (tooltipTextChanged || textChanged) { String toolTip = action.getToolTipText(); if ((toolTip == null) || (toolTip.length() == 0)) { toolTip = text; } // if the text is showing, then only set the tooltip if // different if (!showText || toolTip != null && !toolTip.equals(text)) { ti.setToolTipText(toolTip); } else { ti.setToolTipText(null); } } if (enableStateChanged) { boolean shouldBeEnabled = action.isEnabled() && isEnabledAllowed(); if (ti.getEnabled() != shouldBeEnabled) { ti.setEnabled(shouldBeEnabled); } } if (checkChanged) { boolean bv = action.isChecked(); if (ti.getSelection() != bv) { ti.setSelection(bv); } } return; } if (widget instanceof MenuItem) { MenuItem mi = (MenuItem) widget; if (textChanged) { int accelerator = 0; String acceleratorText = null; IAction updatedAction = getAction(); String text = null; accelerator = updatedAction.getAccelerator(); ExternalActionManager.ICallback callback = ExternalActionManager .getInstance().getCallback(); // Block accelerators that are already in use. if ((accelerator != 0) && (callback != null) && (callback.isAcceleratorInUse(accelerator))) { accelerator = 0; } /* * Process accelerators on GTK in a special way to avoid Bug * 42009. We will override the native input method by * allowing these reserved accelerators to be placed on the * menu. We will only do this for "Ctrl+Shift+[0-9A-FU]". */ final String commandId = updatedAction .getActionDefinitionId(); if (("gtk".equals(SWT.getPlatform())) && (callback instanceof IBindingManagerCallback) //$NON-NLS-1$ && (commandId != null)) { final IBindingManagerCallback bindingManagerCallback = (IBindingManagerCallback) callback; final IKeyLookup lookup = KeyLookupFactory.getDefault(); final TriggerSequence[] triggerSequences = bindingManagerCallback .getActiveBindingsFor(commandId); for (int i = 0; i < triggerSequences.length; i++) { final TriggerSequence triggerSequence = triggerSequences[i]; final Trigger[] triggers = triggerSequence .getTriggers(); if (triggers.length == 1) { final Trigger trigger = triggers[0]; if (trigger instanceof KeyStroke) { final KeyStroke currentKeyStroke = (KeyStroke) trigger; final int currentNaturalKey = currentKeyStroke .getNaturalKey(); if ((currentKeyStroke.getModifierKeys() == (lookup .getCtrl() | lookup.getShift())) && ((currentNaturalKey >= '0' && currentNaturalKey <= '9') || (currentNaturalKey >= 'A' && currentNaturalKey <= 'F') || (currentNaturalKey == 'U'))) { accelerator = currentKeyStroke .getModifierKeys() | currentNaturalKey; acceleratorText = triggerSequence .format(); break; } } } } } if (accelerator == 0) { if ((callback != null) && (commandId != null)) { acceleratorText = callback .getAcceleratorText(commandId); } } else { acceleratorText = Action .convertAccelerator(accelerator); } IContributionManagerOverrides overrides = null; if (getParent() != null) { overrides = getParent().getOverrides(); } if (overrides != null) { text = getParent().getOverrides().getText(this); } mi.setAccelerator(accelerator); if (text == null) { text = updatedAction.getText(); } if (text == null) { text = ""; //$NON-NLS-1$ } else { text = Action.removeAcceleratorText(text); } if (acceleratorText == null) { mi.setText(text); } else { mi.setText(text + '\t' + acceleratorText); } } if (imageChanged) { updateImages(false); } if (enableStateChanged) { boolean shouldBeEnabled = action.isEnabled() && isEnabledAllowed(); if (mi.getEnabled() != shouldBeEnabled) { mi.setEnabled(shouldBeEnabled); } } if (checkChanged) { boolean bv = action.isChecked(); if (mi.getSelection() != bv) { mi.setSelection(bv); } } return; } if (widget instanceof Button) { Button button = (Button) widget; if (imageChanged && updateImages(false)) { textChanged = false; // don't update text if it has an image } if (textChanged) { String text = action.getText(); if (text == null) { text = ""; //$NON-NLS-1$ } else { text = Action.removeAcceleratorText(text); } button.setText(text); } if (tooltipTextChanged) { button.setToolTipText(action.getToolTipText()); } if (enableStateChanged) { boolean shouldBeEnabled = action.isEnabled() && isEnabledAllowed(); if (button.getEnabled() != shouldBeEnabled) { button.setEnabled(shouldBeEnabled); } } if (checkChanged) { boolean bv = action.isChecked(); if (button.getSelection() != bv) { button.setSelection(bv); } } return; } } }
public void update(String propertyName) { if (widget != null) { // determine what to do boolean textChanged = propertyName == null || propertyName.equals(IAction.TEXT); boolean imageChanged = propertyName == null || propertyName.equals(IAction.IMAGE); boolean tooltipTextChanged = propertyName == null || propertyName.equals(IAction.TOOL_TIP_TEXT); boolean enableStateChanged = propertyName == null || propertyName.equals(IAction.ENABLED) || propertyName .equals(IContributionManagerOverrides.P_ENABLED); boolean checkChanged = (action.getStyle() == IAction.AS_CHECK_BOX || action .getStyle() == IAction.AS_RADIO_BUTTON) && (propertyName == null || propertyName .equals(IAction.CHECKED)); if (widget instanceof ToolItem) { ToolItem ti = (ToolItem) widget; String text = action.getText(); // the set text is shown only if there is no image or if forced by MODE_FORCE_TEXT boolean showText = text != null && ((getMode() & MODE_FORCE_TEXT) != 0 || !hasImages(action)); // only do the trimming if the text will be used if (showText && text != null) { text = Action.removeAcceleratorText(text); text = Action.removeMnemonics(text); } if (textChanged) { String textToSet = showText ? text : ""; //$NON-NLS-1$ boolean rightStyle = (ti.getParent().getStyle() & SWT.RIGHT) != 0; if (rightStyle || !ti.getText().equals(textToSet)) { // In addition to being required to update the text if it // gets nulled out in the action, this is also a workaround // for bug 50151: Using SWT.RIGHT on a ToolBar leaves blank space ti.setText(textToSet); } } if (imageChanged) { // only substitute a missing image if it has no text updateImages(!showText); } if (tooltipTextChanged || textChanged) { String toolTip = action.getToolTipText(); if ((toolTip == null) || (toolTip.length() == 0)) { toolTip = text; } // if the text is showing, then only set the tooltip if // different if (!showText || toolTip != null && !toolTip.equals(text)) { ti.setToolTipText(toolTip); } else { ti.setToolTipText(null); } } if (enableStateChanged) { boolean shouldBeEnabled = action.isEnabled() && isEnabledAllowed(); if (ti.getEnabled() != shouldBeEnabled) { ti.setEnabled(shouldBeEnabled); } } if (checkChanged) { boolean bv = action.isChecked(); if (ti.getSelection() != bv) { ti.setSelection(bv); } } return; } if (widget instanceof MenuItem) { MenuItem mi = (MenuItem) widget; if (textChanged) { int accelerator = 0; String acceleratorText = null; IAction updatedAction = getAction(); String text = null; accelerator = updatedAction.getAccelerator(); ExternalActionManager.ICallback callback = ExternalActionManager .getInstance().getCallback(); // Block accelerators that are already in use. if ((accelerator != 0) && (callback != null) && (callback.isAcceleratorInUse(accelerator))) { accelerator = 0; } /* * Process accelerators on GTK in a special way to avoid Bug * 42009. We will override the native input method by * allowing these reserved accelerators to be placed on the * menu. We will only do this for "Ctrl+Shift+[0-9A-FU]". */ final String commandId = updatedAction .getActionDefinitionId(); if (("gtk".equals(SWT.getPlatform())) && (callback instanceof IBindingManagerCallback) //$NON-NLS-1$ && (commandId != null)) { final IBindingManagerCallback bindingManagerCallback = (IBindingManagerCallback) callback; final IKeyLookup lookup = KeyLookupFactory.getDefault(); final TriggerSequence[] triggerSequences = bindingManagerCallback .getActiveBindingsFor(commandId); for (int i = 0; i < triggerSequences.length; i++) { final TriggerSequence triggerSequence = triggerSequences[i]; final Trigger[] triggers = triggerSequence .getTriggers(); if (triggers.length == 1) { final Trigger trigger = triggers[0]; if (trigger instanceof KeyStroke) { final KeyStroke currentKeyStroke = (KeyStroke) trigger; final int currentNaturalKey = currentKeyStroke .getNaturalKey(); if ((currentKeyStroke.getModifierKeys() == (lookup .getCtrl() | lookup.getShift())) && ((currentNaturalKey >= '0' && currentNaturalKey <= '9') || (currentNaturalKey >= 'A' && currentNaturalKey <= 'F') || (currentNaturalKey == 'U'))) { accelerator = currentKeyStroke .getModifierKeys() | currentNaturalKey; acceleratorText = triggerSequence .format(); break; } } } } } if (accelerator == 0) { if ((callback != null) && (commandId != null)) { acceleratorText = callback .getAcceleratorText(commandId); } } else { acceleratorText = Action .convertAccelerator(accelerator); } IContributionManagerOverrides overrides = null; if (getParent() != null) { overrides = getParent().getOverrides(); } if (overrides != null) { text = getParent().getOverrides().getText(this); } mi.setAccelerator(accelerator); if (text == null) { text = updatedAction.getText(); } if (text == null) { text = ""; //$NON-NLS-1$ } else { text = Action.removeAcceleratorText(text); } if (acceleratorText == null) { mi.setText(text); } else { mi.setText(text + '\t' + acceleratorText); } } if (imageChanged) { updateImages(false); } if (enableStateChanged) { boolean shouldBeEnabled = action.isEnabled() && isEnabledAllowed(); if (mi.getEnabled() != shouldBeEnabled) { mi.setEnabled(shouldBeEnabled); } } if (checkChanged) { boolean bv = action.isChecked(); if (mi.getSelection() != bv) { mi.setSelection(bv); } } return; } if (widget instanceof Button) { Button button = (Button) widget; if (imageChanged && updateImages(false)) { textChanged = false; // don't update text if it has an image } if (textChanged) { String text = action.getText(); if (text == null) { text = ""; //$NON-NLS-1$ } else { text = Action.removeAcceleratorText(text); } button.setText(text); } if (tooltipTextChanged) { button.setToolTipText(action.getToolTipText()); } if (enableStateChanged) { boolean shouldBeEnabled = action.isEnabled() && isEnabledAllowed(); if (button.getEnabled() != shouldBeEnabled) { button.setEnabled(shouldBeEnabled); } } if (checkChanged) { boolean bv = action.isChecked(); if (button.getSelection() != bv) { button.setSelection(bv); } } return; } } }
1,120,968
protected Action(String text, ImageDescriptor image) { this(); setText(text); setImageDescriptor(image);}
protected Action(String text, ImageDescriptor image) { this(); setText(text); setImageDescriptor(image);}
1,120,969
public PartInitException(IStatus status) { super(status);}
public PartInitException(IStatus status) { super(status);}
1,120,970
public void add(Object parentElement, Object childElement) { add(parentElement, new Object[] { childElement }); }
public void add(Object parentElement, Object childElement) { add(parentElement, new Object[] { childElement }); }
1,120,971
protected ChangeEvent fireChangeEvent(int changeType, Object oldValue, Object newValue, Object parent, int position) { ChangeEvent changeEvent = new ChangeEvent(this, changeType, oldValue, newValue, parent, position); if(changeListeners==null) { // disposed return changeEvent; } IChangeListener[] listeners = (IChangeListener[]) changeListeners .toArray(new IChangeListener[changeListeners.size()]); for (int i = 0; i < listeners.length; i++) { listeners[i].handleChange(changeEvent); } return changeEvent; }
protected ChangeEvent fireChangeEvent(int changeType, Object oldValue, Object newValue, Object parent, int position) { ChangeEvent changeEvent = new ChangeEvent(this, changeType, oldValue, newValue, parent, position); if(changeListeners==null) { // disposed return changeEvent; } IChangeListener[] listeners = (IChangeListener[]) changeListeners .toArray(new IChangeListener[changeListeners.size()]); for (int i = 0; i < listeners.length; i++) { listeners[i].handleChange(changeEvent); } return changeEvent; }
1,120,972
protected void insertAfter(IContributionManager mgr, String refId, IContributionItem item) { mgr.insertAfter(refId, item); }
protected void insertAfter(IContributionManager mgr, String refId, IContributionItem item) { mgr.insertAfter(refId, item); }
1,120,973
public Accelerator(String id,int accelerator) { this(id,null,null,null); accelerators = new int[1][]; accelerators[0] = new int[]{accelerator}; }
public Accelerator(String id,int accelerator) { this(id,null,null,null); accelerators = new int[1][]; accelerators[0] = new int[]{accelerator}; }
1,120,974
public static KeyStroke getInstance(String string) throws ParseException { if (string == null) throw new NullPointerException(); SortedSet modifierKeys = new TreeSet(); NaturalKey naturalKey = null; StringTokenizer stringTokenizer = new StringTokenizer(string, KEY_DELIMITERS, true); int i = 0; while (stringTokenizer.hasMoreTokens()) { String token = stringTokenizer.nextToken(); if (i % 2 == 0) { if (stringTokenizer.hasMoreTokens()) { token = token.toUpperCase(); ModifierKey modifierKey = (ModifierKey) ModifierKey.modifierKeysByName.get(token); if (modifierKey == null || !modifierKeys.add(modifierKey)) throw new ParseException(); } else if (token.length() == 1) { naturalKey = CharacterKey.getInstance(token.charAt(0)); break; } else { token = token.toUpperCase(); naturalKey = (NaturalKey) CharacterKey.characterKeysByName.get(token); if (naturalKey == null) naturalKey = (NaturalKey) SpecialKey.specialKeysByName.get(token); if (naturalKey == null) throw new ParseException(); } } i++; } try { return new KeyStroke(modifierKeys, naturalKey); } catch (Throwable t) { throw new ParseException(); } }
public static KeyStroke getInstance(String string) throws ParseException { if (string == null) throw new NullPointerException(); SortedSet modifierKeys = new TreeSet(); NaturalKey naturalKey = null; StringTokenizer stringTokenizer = new StringTokenizer(string, KEY_DELIMITERS, true); int i = 0; while (stringTokenizer.hasMoreTokens()) { String token = stringTokenizer.nextToken(); if (i % 2 == 0) { if (stringTokenizer.hasMoreTokens()) { token = token.toUpperCase(); ModifierKey modifierKey = (ModifierKey) ModifierKey.modifierKeysByName.get(token); if (modifierKey == null || !modifierKeys.add(modifierKey)) throw new ParseException(); } else if (token.length() == 1) { naturalKey = CharacterKey.getInstance(token.charAt(0)); break; } else { token = token.toUpperCase(); naturalKey = (NaturalKey) CharacterKey.characterKeysByName.get(token); if (naturalKey == null) naturalKey = (NaturalKey) SpecialKey.specialKeysByName.get(token); if (naturalKey == null) throw new ParseException(); } } i++; } try { return new KeyStroke(modifierKeys, naturalKey); } catch (Throwable t) { throw new ParseException(); } }
1,120,975
public static KeyStroke getInstance(String string) throws ParseException { if (string == null) throw new NullPointerException(); SortedSet modifierKeys = new TreeSet(); NaturalKey naturalKey = null; StringTokenizer stringTokenizer = new StringTokenizer(string, KEY_DELIMITERS, true); int i = 0; while (stringTokenizer.hasMoreTokens()) { String token = stringTokenizer.nextToken(); if (i % 2 == 0) { if (stringTokenizer.hasMoreTokens()) { token = token.toUpperCase(); ModifierKey modifierKey = (ModifierKey) ModifierKey.modifierKeysByName.get(token); if (modifierKey == null || !modifierKeys.add(modifierKey)) throw new ParseException(); } else if (token.length() == 1) { naturalKey = CharacterKey.getInstance(token.charAt(0)); break; } else { token = token.toUpperCase(); naturalKey = (NaturalKey) CharacterKey.characterKeysByName.get(token); if (naturalKey == null) naturalKey = (NaturalKey) SpecialKey.specialKeysByName.get(token); if (naturalKey == null) throw new ParseException(); } } i++; } try { return new KeyStroke(modifierKeys, naturalKey); } catch (Throwable t) { throw new ParseException(); } }
public static KeyStroke getInstance(String string) throws ParseException { if (string == null) throw new NullPointerException(); SortedSet modifierKeys = new TreeSet(); NaturalKey naturalKey = null; StringTokenizer stringTokenizer = new StringTokenizer(string, KEY_DELIMITERS, true); int i = 0; while (stringTokenizer.hasMoreTokens()) { String token = stringTokenizer.nextToken(); if (i % 2 == 0) { if (stringTokenizer.hasMoreTokens()) { token = token.toUpperCase(); ModifierKey modifierKey = (ModifierKey) ModifierKey.modifierKeysByName.get(token); if (modifierKey == null || !modifierKeys.add(modifierKey)) throw new ParseException(); } else if (token.length() == 1) { naturalKey = CharacterKey.getInstance(token.charAt(0)); break; } else { token = token.toUpperCase(); naturalKey = (NaturalKey) CharacterKey.characterKeysByName.get(token); if (naturalKey == null) naturalKey = (NaturalKey) SpecialKey.specialKeysByName.get(token); if (naturalKey == null) throw new ParseException(); } } i++; } try { return new KeyStroke(modifierKeys, naturalKey); } catch (Throwable t) { throw new ParseException(); } }
1,120,976
public ImportResourcesAction(IWorkbench workbench) { this(workbench.getActiveWorkbenchWindow()); }
public ImportResourcesAction(IWorkbench workbench) { this(workbench.getActiveWorkbenchWindow()); }
1,120,977
public ExportResourcesAction(IWorkbench workbench) { this(workbench.getActiveWorkbenchWindow()); }
public ExportResourcesAction(IWorkbench workbench) { this(workbench.getActiveWorkbenchWindow()); }
1,120,978
protected abstract void readINIFile(URL iniURL, URL propertiesURL) throws CoreException;
protected abstract void readINIFile(URL iniURL, URL propertiesURL) throws CoreException;
1,120,979
public ActionExpression(String expressionType, String expressionValue) { if (expressionType.equals(EXP_TYPE_OBJECT_CLASS)) { root = new SingleExpression(new ObjectClassExpression( expressionValue)); } }
public ActionExpression(String expressionType, String expressionValue) { if (expressionType.equals(EXP_TYPE_OBJECT_CLASS)) { root = new SingleExpression(new ObjectClassExpression( expressionValue)); } }
1,120,980
public ChangeEvent(Object source, int changeType, Object oldValue, Object newValue, Object parent, int position) { super(source); this.oldValue = oldValue; this.changeType = changeType; this.newValue = newValue; this.parent = parent; this.position = position; }
public ChangeEvent(Object source, int changeType, Object oldValue, Object newValue, Object parent, int position) { super(source); this.oldValue = oldValue; this.changeType = changeType; this.newValue = newValue; this.parent = parent; this.position = position; }
1,120,981
public WizardFileSystemResourceExportPage1(IStructuredSelection selection) { this("fileSystemExportPage1", selection);//$NON-NLS-1$ setTitle(DataTransferMessages.getString("DataTransfer.fileSystemTitle")); //$NON-NLS-1$ setDescription(DataTransferMessages.getString("FileExport.exportLocalFileSystem")); //$NON-NLS-1$}
public WizardFileSystemResourceExportPage1(IStructuredSelection selection) { this("fileSystemExportPage1", selection);//$NON-NLS-1$ setTitle(DataTransferMessages.getString("DataTransfer.fileSystemTitle")); //$NON-NLS-1$ setDescription(DataTransferMessages.getString("FileExport.exportLocalFileSystem")); //$NON-NLS-1$}
1,120,982
public static String asString(Point value) { Assert.isNotNull(value); StringBuffer buffer = new StringBuffer(); buffer.append(value.x); buffer.append(','); buffer.append(value.y); return buffer.toString();}
public static String asString(Point value) { Assert.isNotNull(value); StringBuffer buffer = new StringBuffer(); buffer.append(value.x); buffer.append(','); buffer.append(value.y); return buffer.toString();}
1,120,983
public static final WorkbenchPreferenceDialog createDialogOn(final String preferencePageId, String[] displayedIds) { WorkbenchPreferenceDialog dialog = createDialogOn(null,preferencePageId); if(dialog == null) return null; if (displayedIds != null) dialog.showOnly(displayedIds); return dialog; }
public static final WorkbenchPreferenceDialog createDialogOn(final String preferencePageId, String[] displayedIds) { WorkbenchPreferenceDialog dialog = createDialogOn(null,preferencePageId); if(dialog == null) return null; if (displayedIds != null) dialog.showOnly(displayedIds); return dialog; }
1,120,984
public void add(int index, Object element) { wrappedList.add(index, element); fireListChange(Diffs.createListDiff(Diffs.createListDiffEntry(index, true, element))); }
public void add(int index, Object element) { wrappedList.add(index, element); fireListChange(Diffs.createListDiff(Diffs.createListDiffEntry(index, true, element))); }
1,120,985
public WorkbenchPreferenceNode(String nodeId, String nodeLabel, String category, ImageDescriptor nodeImage, IWorkbenchPreferencePage preferencePage) { super(nodeId, nodeLabel, nodeImage, null); setPage(preferencePage);}
public WorkbenchPreferenceNode(String nodeId, String nodeLabel, String category, ImageDescriptor nodeImage, IConfigurationElement element, IWorkbench newWorkbench) { super(nodeId, nodeLabel, nodeImage, null); setPage(preferencePage);}
1,120,986
public WorkbenchPreferenceNode(String nodeId, String nodeLabel, String category, ImageDescriptor nodeImage, IWorkbenchPreferencePage preferencePage) { super(nodeId, nodeLabel, nodeImage, null); setPage(preferencePage);}
public WorkbenchPreferenceNode(String nodeId, String nodeLabel, String category, ImageDescriptor nodeImage, IWorkbenchPreferencePage preferencePage) { super(nodeId, nodeLabel, nodeImage, null); this.category = category; this.configurationElement = element; this.workbench = newWorkbench;}
1,120,987
public String getAppName() { if (appName == null) appName = getAppName(product); return appName; }
public String getAppName() { if (appName == null) appName = getAppName(product); return appName; }
1,120,988
public ImageDescriptor[] getWindowImages() { if (windowImageDescriptors == null) windowImageDescriptors = getWindowImages(product); return windowImageDescriptors; }
public ImageDescriptor[] getWindowImages() { if (windowImageDescriptors == null) windowImageDescriptors = getWindowImages(product); return windowImageDescriptors; }
1,120,989
public static MarkerList compute(MarkerFilter filter, IProgressMonitor mon, boolean ignoreExceptions) throws CoreException { return new MarkerList(filter.findMarkers(mon, ignoreExceptions)); }
public static MarkerList compute(MarkerFilter[] filters, IProgressMonitor mon, boolean ignoreExceptions) throws CoreException { return new MarkerList(filter.findMarkers(mon, ignoreExceptions)); }
1,120,990
public static MarkerList compute(MarkerFilter filter, IProgressMonitor mon, boolean ignoreExceptions) throws CoreException { return new MarkerList(filter.findMarkers(mon, ignoreExceptions)); }
public static MarkerList compute(MarkerFilter filter, IProgressMonitor mon, boolean ignoreExceptions) throws CoreException { Collection returnMarkers = new ArrayList(); for (int i = 0; i < filters.length; i++) { returnMarkers.addAll(filters[i].findMarkers(mon, ignoreExceptions)); } return new MarkerList(returnMarkers); }
1,120,991
public List getEnabledContentDescriptors(Object anElement, NavigatorViewerDescriptor aViewerDescriptor) { List descriptors = new ArrayList(); /* Find other ContentProviders which enable for this object */ for (Iterator contentDescriptorsItr = contentDescriptors.values().iterator(); contentDescriptorsItr.hasNext();) { NavigatorContentDescriptor descriptor = (NavigatorContentDescriptor) contentDescriptorsItr.next(); if (NAVIGATOR_ACTIVATION_SERVICE.isNavigatorExtensionActive(aViewerDescriptor.getViewerId(), descriptor.getId()) && !aViewerDescriptor.filtersContentDescriptor(descriptor)) { if (descriptor.isEnabledFor(anElement)) descriptors.add(descriptor); } } Collections.sort(descriptors, EXTENSION_COMPARATOR); return Collections.unmodifiableList(descriptors); }
public List getEnabledContentDescriptors(Object anElement, NavigatorViewerDescriptor aViewerDescriptor) { List descriptors = new ArrayList(); /* Find other ContentProviders which enable for this object */ for (Iterator contentDescriptorsItr = contentDescriptors.values().iterator(); contentDescriptorsItr.hasNext();) { NavigatorContentDescriptor descriptor = (NavigatorContentDescriptor) contentDescriptorsItr.next(); if (NAVIGATOR_ACTIVATION_SERVICE.isNavigatorExtensionActive(aViewerDescriptor.getViewerId(), descriptor.getId()) && !aViewerDescriptor.filtersContentDescriptor(descriptor)) { if (descriptor.isEnabledFor(anElement)) descriptors.add(descriptor); } } Collections.sort(descriptors, EXTENSION_COMPARATOR); return Collections.unmodifiableList(descriptors); }
1,120,992
public List getEnabledContentDescriptors(Object anElement, NavigatorViewerDescriptor aViewerDescriptor) { List descriptors = new ArrayList(); /* Find other ContentProviders which enable for this object */ for (Iterator contentDescriptorsItr = contentDescriptors.values().iterator(); contentDescriptorsItr.hasNext();) { NavigatorContentDescriptor descriptor = (NavigatorContentDescriptor) contentDescriptorsItr.next(); if (NAVIGATOR_ACTIVATION_SERVICE.isNavigatorExtensionActive(aViewerDescriptor.getViewerId(), descriptor.getId()) && !aViewerDescriptor.filtersContentDescriptor(descriptor)) { if (descriptor.isEnabledFor(anElement)) descriptors.add(descriptor); } } Collections.sort(descriptors, EXTENSION_COMPARATOR); return Collections.unmodifiableList(descriptors); }
public List getEnabledContentDescriptors(Object anElement, NavigatorViewerDescriptor aViewerDescriptor) { List descriptors = new ArrayList(); /* Find other ContentProviders which enable for this object */ for (Iterator contentDescriptorsItr = contentDescriptors.values().iterator(); contentDescriptorsItr.hasNext();) { NavigatorContentDescriptor descriptor = (NavigatorContentDescriptor) contentDescriptorsItr.next(); if (NAVIGATOR_ACTIVATION_SERVICE.isNavigatorExtensionActive(aViewerDescriptor.getViewerId(), descriptor.getId()) && !aViewerDescriptor.filtersContentDescriptor(descriptor)) { if (descriptor.isEnabledFor(anElement)) descriptors.add(descriptor); } } Collections.sort(descriptors, EXTENSION_COMPARATOR); return Collections.unmodifiableList(descriptors); }
1,120,993
public List getEnabledContentDescriptors(Object anElement, NavigatorViewerDescriptor aViewerDescriptor) { List descriptors = new ArrayList(); /* Find other ContentProviders which enable for this object */ for (Iterator contentDescriptorsItr = contentDescriptors.values().iterator(); contentDescriptorsItr.hasNext();) { NavigatorContentDescriptor descriptor = (NavigatorContentDescriptor) contentDescriptorsItr.next(); if (NAVIGATOR_ACTIVATION_SERVICE.isNavigatorExtensionActive(aViewerDescriptor.getViewerId(), descriptor.getId()) && !aViewerDescriptor.filtersContentDescriptor(descriptor)) { if (descriptor.isEnabledFor(anElement)) descriptors.add(descriptor); } } Collections.sort(descriptors, EXTENSION_COMPARATOR); return Collections.unmodifiableList(descriptors); }
public List getEnabledContentDescriptors(Object anElement, NavigatorViewerDescriptor aViewerDescriptor) { List descriptors = new ArrayList(); /* Find other ContentProviders which enable for this object */ for (Iterator contentDescriptorsItr = contentDescriptors.values().iterator(); contentDescriptorsItr.hasNext();) { NavigatorContentDescriptor descriptor = (NavigatorContentDescriptor) contentDescriptorsItr.next(); if (NAVIGATOR_ACTIVATION_SERVICE.isNavigatorExtensionActive(aViewerDescriptor.getViewerId(), descriptor.getId()) && !aViewerDescriptor.filtersContentDescriptor(descriptor)) { if (descriptor.isEnabledFor(anElement)) descriptors.add(descriptor); } } return Collections.unmodifiableList(descriptors); }
1,120,994
public List getEnabledContentDescriptors(Object anElement, NavigatorViewerDescriptor aViewerDescriptor) { List descriptors = new ArrayList(); /* Find other ContentProviders which enable for this object */ for (Iterator contentDescriptorsItr = contentDescriptors.values().iterator(); contentDescriptorsItr.hasNext();) { NavigatorContentDescriptor descriptor = (NavigatorContentDescriptor) contentDescriptorsItr.next(); if (NAVIGATOR_ACTIVATION_SERVICE.isNavigatorExtensionActive(aViewerDescriptor.getViewerId(), descriptor.getId()) && !aViewerDescriptor.filtersContentDescriptor(descriptor)) { if (descriptor.isEnabledFor(anElement)) descriptors.add(descriptor); } } Collections.sort(descriptors, EXTENSION_COMPARATOR); return Collections.unmodifiableList(descriptors); }
public List getEnabledContentDescriptors(Object anElement, NavigatorViewerDescriptor aViewerDescriptor) { List descriptors = new ArrayList(); /* Find other ContentProviders which enable for this object */ for (Iterator contentDescriptorsItr = contentDescriptors.values().iterator(); contentDescriptorsItr.hasNext();) { NavigatorContentDescriptor descriptor = (NavigatorContentDescriptor) contentDescriptorsItr.next(); if (NAVIGATOR_ACTIVATION_SERVICE.isNavigatorExtensionActive(aViewerDescriptor.getViewerId(), descriptor.getId()) && !aViewerDescriptor.filtersContentDescriptor(descriptor)) { if (descriptor.isEnabledFor(anElement)) descriptors.add(descriptor); } } Collections.sort(descriptors, EXTENSION_COMPARATOR); return descriptors; }
1,120,995
public void applyFontsAndColors(TableTreeItem control) { if(colorProvider == null){ if(usedDecorators){ //If there is no provider only apply set values if(background != null) control.setBackground(background); if(foreground != null) control.setForeground(foreground); } } else{ //Always set the value if there is a provider control.setBackground(background); control.setForeground(foreground); } if(fontProvider == null){ if(usedDecorators && font != null) control.setFont(font); } else//Always set the value if there is a provider control.setFont(font); clear(); }
public void applyFontsAndColors(TableItem control) { if(colorProvider == null){ if(usedDecorators){ //If there is no provider only apply set values if(background != null) control.setBackground(background); if(foreground != null) control.setForeground(foreground); } } else{ //Always set the value if there is a provider control.setBackground(background); control.setForeground(foreground); } if(fontProvider == null){ if(usedDecorators && font != null) control.setFont(font); } else//Always set the value if there is a provider control.setFont(font); clear(); }
1,120,996
public DynamicHelpAction(IWorkbenchWindow window) { if (window == null) { throw new IllegalArgumentException(); } this.workbenchWindow = window; setActionDefinitionId("org.eclipse.ui.help.dynamicHelp"); //$NON-NLS-1$ // support for allowing a product to override the text for the action String overrideText = PrefUtil.getAPIPreferenceStore().getString( IWorkbenchPreferenceConstants.DYNAMIC_HELP_ACTION_TEXT); if ("".equals(overrideText)) { //$NON-NLS-1$ setText(appendAccelerator(WorkbenchMessages.DynamicHelpAction_text)); setToolTipText(WorkbenchMessages.DynamicHelpAction_toolTip); } else { setText(appendAccelerator(overrideText)); setToolTipText(Action.removeMnemonics(overrideText)); } window.getWorkbench().getHelpSystem().setHelp(this, IWorkbenchHelpContextIds.DYNAMIC_HELP_ACTION); }
public DynamicHelpAction(IWorkbenchWindow window) { if (window == null) { throw new IllegalArgumentException(); } this.workbenchWindow = window; setActionDefinitionId("org.eclipse.ui.help.dynamicHelp"); //$NON-NLS-1$ // support for allowing a product to override the text for the action String overrideText = PrefUtil.getAPIPreferenceStore().getString( IWorkbenchPreferenceConstants.DYNAMIC_HELP_ACTION_TEXT); if ("".equals(overrideText)) { //$NON-NLS-1$ setText(appendAccelerator(WorkbenchMessages.DynamicHelpAction_text)); setToolTipText(WorkbenchMessages.DynamicHelpAction_toolTip); } else { setText(appendAccelerator(overrideText)); setToolTipText(Action.removeMnemonics(overrideText)); } window.getWorkbench().getHelpSystem().setHelp(this, IWorkbenchHelpContextIds.DYNAMIC_HELP_ACTION); }
1,120,997
private List findMarkers(IResource[] resources, int depth, int limit, IProgressMonitor mon, boolean ignoreExceptions) throws CoreException { if (resources == null) { return Collections.EMPTY_LIST; } List resultList = new ArrayList(resources.length * 2); // Optimization: if a type appears in the selectedTypes list along with // all of its // subtypes, then combine these in a single search. // List of types that haven't been replaced by one of their supertypes HashSet typesToSearch = new HashSet(selectedTypes.size()); // List of types that appeared in selectedTypes along with all of their // subtypes HashSet includeAllSubtypes = new HashSet(selectedTypes.size()); typesToSearch.addAll(selectedTypes); Iterator iter = selectedTypes.iterator(); while (iter.hasNext()) { MarkerType type = (MarkerType) iter.next(); Collection subtypes = Arrays.asList(type.getAllSubTypes()); if (selectedTypes.containsAll(subtypes)) { typesToSearch.removeAll(subtypes); includeAllSubtypes.add(type); } } mon.beginTask(MarkerMessages.MarkerFilter_searching, typesToSearch .size() * resources.length); // Use this hash set to determine if there are any resources in the // list that appear along with their parent. HashSet resourcesToSearch = new HashSet(); // Insert all the resources into the hashset for (int idx = 0; idx < resources.length; idx++) { IResource next = resources[idx]; if (!next.exists()) { continue; } if (resourcesToSearch.contains(next)) { mon.worked(typesToSearch.size()); } else { resourcesToSearch.add(next); } } // Iterate through all the selected resources for (int resourceIdx = 0; resourceIdx < resources.length; resourceIdx++) { iter = typesToSearch.iterator(); IResource resource = resources[resourceIdx]; // Skip resources that don't exist if (!resource.isAccessible()) { continue; } if (depth == IResource.DEPTH_INFINITE) { // Determine if any parent of this resource is also in our // filter IResource parent = resource.getParent(); boolean found = false; while (parent != null) { if (resourcesToSearch.contains(parent)) { found = true; } parent = parent.getParent(); } // If a parent of this resource is also in the filter, we can // skip it // because we'll pick up its markers when we search the parent. if (found) { continue; } } // Iterate through all the marker types while (iter.hasNext()) { MarkerType markerType = (MarkerType) iter.next(); // Only search for subtypes of the marker if we found all of its // subtypes in the filter criteria. IMarker[] markers = resource.findMarkers(markerType.getId(), includeAllSubtypes.contains(markerType), depth); mon.worked(1); for (int idx = 0; idx < markers.length; idx++) { ConcreteMarker marker; try { marker = MarkerList.createMarker(markers[idx]); } catch (CoreException e) { if (ignoreExceptions) { continue; } else { throw e; } } if (limit != -1 && resultList.size() >= limit) { return resultList; } if (selectMarker(marker)) { resultList.add(marker); } } } } mon.done(); return resultList; }
private List findMarkers(IResource[] resources, int depth, int limit, IProgressMonitor mon, boolean ignoreExceptions) throws CoreException { if (resources == null) { return Collections.EMPTY_LIST; } List resultList = new ArrayList(resources.length * 2); // Optimization: if a type appears in the selectedTypes list along with // all of its // subtypes, then combine these in a single search. // List of types that haven't been replaced by one of their supertypes HashSet typesToSearch = new HashSet(selectedTypes.size()); // List of types that appeared in selectedTypes along with all of their // subtypes HashSet includeAllSubtypes = new HashSet(selectedTypes.size()); typesToSearch.addAll(selectedTypes); Iterator iter = selectedTypes.iterator(); while (iter.hasNext()) { MarkerType type = (MarkerType) iter.next(); Collection subtypes = Arrays.asList(type.getAllSubTypes()); if (selectedTypes.containsAll(subtypes)) { typesToSearch.removeAll(subtypes); includeAllSubtypes.add(type); } } mon.beginTask(MarkerMessages.MarkerFilter_searching, typesToSearch .size() * resources.length); // Use this hash set to determine if there are any resources in the // list that appear along with their parent. HashSet resourcesToSearch = new HashSet(); // Insert all the resources into the hashset for (int idx = 0; idx < resources.length; idx++) { IResource next = resources[idx]; if (!next.exists()) { continue; } if (resourcesToSearch.contains(next)) { mon.worked(typesToSearch.size()); } else { resourcesToSearch.add(next); } } // Iterate through all the selected resources for (int resourceIdx = 0; resourceIdx < resources.length; resourceIdx++) { iter = typesToSearch.iterator(); IResource resource = resources[resourceIdx]; // Skip resources that don't exist if (!resource.isAccessible()) { continue; } if (depth == IResource.DEPTH_INFINITE) { // Determine if any parent of this resource is also in our // filter IResource parent = resource.getParent(); boolean found = false; while (parent != null) { if (resourcesToSearch.contains(parent)) { found = true; } parent = parent.getParent(); } // If a parent of this resource is also in the filter, we can // skip it // because we'll pick up its markers when we search the parent. if (found) { continue; } } // Iterate through all the marker types while (iter.hasNext()) { MarkerType markerType = (MarkerType) iter.next(); // Only search for subtypes of the marker if we found all of its // subtypes in the filter criteria. IMarker[] markers = resource.findMarkers(markerType.getId(), includeAllSubtypes.contains(markerType), depth); mon.worked(1); for (int idx = 0; idx < markers.length; idx++) { ConcreteMarker marker; try { marker = MarkerList.createMarker(markers[idx]); } catch (CoreException e) { if (ignoreExceptions) { continue; } else { throw e; } } if (limit != -1 && resultList.size() >= limit) { return resultList; } if (selectMarker(marker)) { resultList.add(marker); } } } } mon.done(); return resultList; }
1,120,998
public UIJob(Display jobDisplay, String name) { super(name); setDisplay(jobDisplay); }
public UIJob(Display jobDisplay, String name) { super(name); }
1,121,000
public CTabItem getItem(Point pt) { //checkWidget(); if (items.length == 0) return null; int lastItem = getLastItem(); lastItem = Math.min(items.length - 1, lastItem + 1); for (int i = topTabIndex; i <= lastItem; i++) { Rectangle bounds = items[i].getBounds(); if (bounds.contains(pt)) return items[i]; } return null; }
public CTabItem getItem(Point pt) { //checkWidget(); if (items.length == 0) return null; int lastItem = getLastItem(); lastItem = Math.min(items.length - 1, lastItem + 1); for (int i = topTabIndex; i <= lastItem; i++) { Rectangle bounds = items[i].getBounds(); if (bounds.contains(pt)) return items[i]; } return null; }
1,121,001
public SearchPattern(String pattern, int allowedRules) { initializePatternAndMatchRule(pattern); matchRule = matchRule & allowedRules; if (matchRule == RULE_PATTERN_MATCH) { stringMatcher = new StringMatcher(stringPattern, true, false); } }
public SearchPattern(String pattern, int allowedRules) { initializePatternAndMatchRule(pattern); matchRule = matchRule & allowedRules; if (matchRule == RULE_PATTERN_MATCH) { stringMatcher = new StringMatcher(stringPattern, true, false); } }
1,121,002
public static RubyObject convertJavaToRuby(Ruby ruby, Object object, Class javaClass) { if (object == null) { return ruby.getNil(); } if (javaClass == null) { javaClass = object.getClass(); } if (javaClass.isPrimitive()) { String cName = javaClass.getName(); if (cName == "boolean") { return RubyBoolean.newBoolean(ruby, ((Boolean) object).booleanValue()); } else if (cName == "float" || cName == "double") { return RubyFloat.newFloat(ruby, ((Number) object).doubleValue()); } else if (cName == "char") { return RubyFixnum.newFixnum(ruby, ((Character) object).charValue()); } else { // else it's one of the integral types return RubyFixnum.newFixnum(ruby, ((Number) object).longValue()); } } else if (javaClass == String.class) { return RubyString.newString(ruby, object.toString()); } else if (javaClass.isArray()) { Class arrayClass = javaClass.getComponentType(); int len = Array.getLength(object); RubyObject[] items = new RubyObject[len]; for (int i = 0; i < len; i++) { items[i] = convertJavaToRuby(ruby, Array.get(object, i), arrayClass); } return RubyArray.create(ruby, null, items); } else if (List.class.isAssignableFrom(javaClass)) { int len = ((List) object).size(); RubyObject[] items = new RubyObject[len]; for (int i = 0; i < len; i++) { items[i] = convertJavaToRuby(ruby, ((List) object).get(i), null); } return RubyArray.create(ruby, null, items); } else if (Map.class.isAssignableFrom(javaClass)) { int len = ((Map) object).size(); RubyObject[] items = new RubyObject[len * 2]; Iterator iter = ((Map) object).entrySet().iterator(); for (int i = 0; i < len; i++) { Map.Entry entry = (Map.Entry) iter.next(); items[2 * i] = convertJavaToRuby(ruby, entry.getKey(), null); items[2 * i + 1] = convertJavaToRuby(ruby, entry.getValue(), null); } return RubyHash.create(ruby, null, items); } else { return new RubyJavaObject(ruby, (RubyClass)ruby.getJavaSupport().loadClass(javaClass, null), object); } }
public static RubyObject convertJavaToRuby(Ruby ruby, Object object) { if (object == null) { return ruby.getNil(); } if (javaClass == null) { javaClass = object.getClass(); } if (javaClass.isPrimitive()) { String cName = javaClass.getName(); if (cName == "boolean") { return RubyBoolean.newBoolean(ruby, ((Boolean) object).booleanValue()); } else if (cName == "float" || cName == "double") { return RubyFloat.newFloat(ruby, ((Number) object).doubleValue()); } else if (cName == "char") { return RubyFixnum.newFixnum(ruby, ((Character) object).charValue()); } else { // else it's one of the integral types return RubyFixnum.newFixnum(ruby, ((Number) object).longValue()); } } else if (javaClass == String.class) { return RubyString.newString(ruby, object.toString()); } else if (javaClass.isArray()) { Class arrayClass = javaClass.getComponentType(); int len = Array.getLength(object); RubyObject[] items = new RubyObject[len]; for (int i = 0; i < len; i++) { items[i] = convertJavaToRuby(ruby, Array.get(object, i), arrayClass); } return RubyArray.create(ruby, null, items); } else if (List.class.isAssignableFrom(javaClass)) { int len = ((List) object).size(); RubyObject[] items = new RubyObject[len]; for (int i = 0; i < len; i++) { items[i] = convertJavaToRuby(ruby, ((List) object).get(i), null); } return RubyArray.create(ruby, null, items); } else if (Map.class.isAssignableFrom(javaClass)) { int len = ((Map) object).size(); RubyObject[] items = new RubyObject[len * 2]; Iterator iter = ((Map) object).entrySet().iterator(); for (int i = 0; i < len; i++) { Map.Entry entry = (Map.Entry) iter.next(); items[2 * i] = convertJavaToRuby(ruby, entry.getKey(), null); items[2 * i + 1] = convertJavaToRuby(ruby, entry.getValue(), null); } return RubyHash.create(ruby, null, items); } else { return new RubyJavaObject(ruby, (RubyClass)ruby.getJavaSupport().loadClass(javaClass, null), object); } }
1,121,003
public static RubyObject convertJavaToRuby(Ruby ruby, Object object, Class javaClass) { if (object == null) { return ruby.getNil(); } if (javaClass == null) { javaClass = object.getClass(); } if (javaClass.isPrimitive()) { String cName = javaClass.getName(); if (cName == "boolean") { return RubyBoolean.newBoolean(ruby, ((Boolean) object).booleanValue()); } else if (cName == "float" || cName == "double") { return RubyFloat.newFloat(ruby, ((Number) object).doubleValue()); } else if (cName == "char") { return RubyFixnum.newFixnum(ruby, ((Character) object).charValue()); } else { // else it's one of the integral types return RubyFixnum.newFixnum(ruby, ((Number) object).longValue()); } } else if (javaClass == String.class) { return RubyString.newString(ruby, object.toString()); } else if (javaClass.isArray()) { Class arrayClass = javaClass.getComponentType(); int len = Array.getLength(object); RubyObject[] items = new RubyObject[len]; for (int i = 0; i < len; i++) { items[i] = convertJavaToRuby(ruby, Array.get(object, i), arrayClass); } return RubyArray.create(ruby, null, items); } else if (List.class.isAssignableFrom(javaClass)) { int len = ((List) object).size(); RubyObject[] items = new RubyObject[len]; for (int i = 0; i < len; i++) { items[i] = convertJavaToRuby(ruby, ((List) object).get(i), null); } return RubyArray.create(ruby, null, items); } else if (Map.class.isAssignableFrom(javaClass)) { int len = ((Map) object).size(); RubyObject[] items = new RubyObject[len * 2]; Iterator iter = ((Map) object).entrySet().iterator(); for (int i = 0; i < len; i++) { Map.Entry entry = (Map.Entry) iter.next(); items[2 * i] = convertJavaToRuby(ruby, entry.getKey(), null); items[2 * i + 1] = convertJavaToRuby(ruby, entry.getValue(), null); } return RubyHash.create(ruby, null, items); } else { return new RubyJavaObject(ruby, (RubyClass)ruby.getJavaSupport().loadClass(javaClass, null), object); } }
public static RubyObject convertJavaToRuby(Ruby ruby, Object object, Class javaClass) { if (object == null) { return ruby.getNil(); } if (javaClass == null) { javaClass = object.getClass(); } if (javaClass.isPrimitive()) { String cName = javaClass.getName(); if (cName == "boolean") { return RubyBoolean.newBoolean(ruby, ((Boolean) object).booleanValue()); } else if (cName == "float" || cName == "double") { return RubyFloat.newFloat(ruby, ((Number) object).doubleValue()); } else if (cName == "char") { return RubyFixnum.newFixnum(ruby, ((Character) object).charValue()); } else { // else it's one of the integral types return RubyFixnum.newFixnum(ruby, ((Number) object).longValue()); } } else if (javaClass == String.class) { return RubyString.newString(ruby, object.toString()); } else if (javaClass.isArray()) { Class arrayClass = javaClass.getComponentType(); int len = Array.getLength(object); RubyObject[] items = new RubyObject[len]; for (int i = 0; i < len; i++) { items[i] = convertJavaToRuby(ruby, Array.get(object, i), arrayClass); } return RubyArray.create(ruby, null, items); } else if (List.class.isAssignableFrom(javaClass)) { int len = ((List) object).size(); RubyObject[] items = new RubyObject[len]; for (int i = 0; i < len; i++) { items[i] = convertJavaToRuby(ruby, ((List) object).get(i), null); } return RubyArray.create(ruby, null, items); } else if (Map.class.isAssignableFrom(javaClass)) { int len = ((Map) object).size(); RubyObject[] items = new RubyObject[len * 2]; Iterator iter = ((Map) object).entrySet().iterator(); for (int i = 0; i < len; i++) { Map.Entry entry = (Map.Entry) iter.next(); items[2 * i] = convertJavaToRuby(ruby, entry.getKey(), null); items[2 * i + 1] = convertJavaToRuby(ruby, entry.getValue(), null); } return RubyHash.create(ruby, null, items); } else { return new RubyJavaObject(ruby, (RubyClass)ruby.getJavaSupport().loadClass(javaClass, null), object); } }
1,121,004
public static RubyObject convertJavaToRuby(Ruby ruby, Object object, Class javaClass) { if (object == null) { return ruby.getNil(); } if (javaClass == null) { javaClass = object.getClass(); } if (javaClass.isPrimitive()) { String cName = javaClass.getName(); if (cName == "boolean") { return RubyBoolean.newBoolean(ruby, ((Boolean) object).booleanValue()); } else if (cName == "float" || cName == "double") { return RubyFloat.newFloat(ruby, ((Number) object).doubleValue()); } else if (cName == "char") { return RubyFixnum.newFixnum(ruby, ((Character) object).charValue()); } else { // else it's one of the integral types return RubyFixnum.newFixnum(ruby, ((Number) object).longValue()); } } else if (javaClass == String.class) { return RubyString.newString(ruby, object.toString()); } else if (javaClass.isArray()) { Class arrayClass = javaClass.getComponentType(); int len = Array.getLength(object); RubyObject[] items = new RubyObject[len]; for (int i = 0; i < len; i++) { items[i] = convertJavaToRuby(ruby, Array.get(object, i), arrayClass); } return RubyArray.create(ruby, null, items); } else if (List.class.isAssignableFrom(javaClass)) { int len = ((List) object).size(); RubyObject[] items = new RubyObject[len]; for (int i = 0; i < len; i++) { items[i] = convertJavaToRuby(ruby, ((List) object).get(i), null); } return RubyArray.create(ruby, null, items); } else if (Map.class.isAssignableFrom(javaClass)) { int len = ((Map) object).size(); RubyObject[] items = new RubyObject[len * 2]; Iterator iter = ((Map) object).entrySet().iterator(); for (int i = 0; i < len; i++) { Map.Entry entry = (Map.Entry) iter.next(); items[2 * i] = convertJavaToRuby(ruby, entry.getKey(), null); items[2 * i + 1] = convertJavaToRuby(ruby, entry.getValue(), null); } return RubyHash.create(ruby, null, items); } else { return new RubyJavaObject(ruby, (RubyClass)ruby.getJavaSupport().loadClass(javaClass, null), object); } }
public static RubyObject convertJavaToRuby(Ruby ruby, Object object, Class javaClass) { if (object == null) { return ruby.getNil(); } if (javaClass == null) { javaClass = object.getClass(); } if (javaClass.isPrimitive()) { String cName = javaClass.getName(); if (cName == "boolean") { return RubyBoolean.newBoolean(ruby, ((Boolean) object).booleanValue()); } else if (cName == "float" || cName == "double") { return RubyFloat.newFloat(ruby, ((Number) object).doubleValue()); } else if (cName == "char") { return RubyFixnum.newFixnum(ruby, ((Character) object).charValue()); } else { // else it's one of the integral types return RubyFixnum.newFixnum(ruby, ((Number) object).longValue()); } } else if (javaClass == String.class) { return RubyString.newString(ruby, object.toString()); } else if (javaClass.isArray()) { Class arrayClass = javaClass.getComponentType(); int len = Array.getLength(object); RubyObject[] items = new RubyObject[len]; for (int i = 0; i < len; i++) { items[i] = convertJavaToRuby(ruby, Array.get(object, i)); } return RubyArray.create(ruby, null, items); } else if (List.class.isAssignableFrom(javaClass)) { int len = ((List) object).size(); RubyObject[] items = new RubyObject[len]; for (int i = 0; i < len; i++) { items[i] = convertJavaToRuby(ruby, ((List) object).get(i), null); } return RubyArray.create(ruby, null, items); } else if (Map.class.isAssignableFrom(javaClass)) { int len = ((Map) object).size(); RubyObject[] items = new RubyObject[len * 2]; Iterator iter = ((Map) object).entrySet().iterator(); for (int i = 0; i < len; i++) { Map.Entry entry = (Map.Entry) iter.next(); items[2 * i] = convertJavaToRuby(ruby, entry.getKey(), null); items[2 * i + 1] = convertJavaToRuby(ruby, entry.getValue(), null); } return RubyHash.create(ruby, null, items); } else { return new RubyJavaObject(ruby, (RubyClass)ruby.getJavaSupport().loadClass(javaClass, null), object); } }
1,121,005
public static RubyObject convertJavaToRuby(Ruby ruby, Object object, Class javaClass) { if (object == null) { return ruby.getNil(); } if (javaClass == null) { javaClass = object.getClass(); } if (javaClass.isPrimitive()) { String cName = javaClass.getName(); if (cName == "boolean") { return RubyBoolean.newBoolean(ruby, ((Boolean) object).booleanValue()); } else if (cName == "float" || cName == "double") { return RubyFloat.newFloat(ruby, ((Number) object).doubleValue()); } else if (cName == "char") { return RubyFixnum.newFixnum(ruby, ((Character) object).charValue()); } else { // else it's one of the integral types return RubyFixnum.newFixnum(ruby, ((Number) object).longValue()); } } else if (javaClass == String.class) { return RubyString.newString(ruby, object.toString()); } else if (javaClass.isArray()) { Class arrayClass = javaClass.getComponentType(); int len = Array.getLength(object); RubyObject[] items = new RubyObject[len]; for (int i = 0; i < len; i++) { items[i] = convertJavaToRuby(ruby, Array.get(object, i), arrayClass); } return RubyArray.create(ruby, null, items); } else if (List.class.isAssignableFrom(javaClass)) { int len = ((List) object).size(); RubyObject[] items = new RubyObject[len]; for (int i = 0; i < len; i++) { items[i] = convertJavaToRuby(ruby, ((List) object).get(i), null); } return RubyArray.create(ruby, null, items); } else if (Map.class.isAssignableFrom(javaClass)) { int len = ((Map) object).size(); RubyObject[] items = new RubyObject[len * 2]; Iterator iter = ((Map) object).entrySet().iterator(); for (int i = 0; i < len; i++) { Map.Entry entry = (Map.Entry) iter.next(); items[2 * i] = convertJavaToRuby(ruby, entry.getKey(), null); items[2 * i + 1] = convertJavaToRuby(ruby, entry.getValue(), null); } return RubyHash.create(ruby, null, items); } else { return new RubyJavaObject(ruby, (RubyClass)ruby.getJavaSupport().loadClass(javaClass, null), object); } }
public static RubyObject convertJavaToRuby(Ruby ruby, Object object, Class javaClass) { if (object == null) { return ruby.getNil(); } if (javaClass == null) { javaClass = object.getClass(); } if (javaClass.isPrimitive()) { String cName = javaClass.getName(); if (cName == "boolean") { return RubyBoolean.newBoolean(ruby, ((Boolean) object).booleanValue()); } else if (cName == "float" || cName == "double") { return RubyFloat.newFloat(ruby, ((Number) object).doubleValue()); } else if (cName == "char") { return RubyFixnum.newFixnum(ruby, ((Character) object).charValue()); } else { // else it's one of the integral types return RubyFixnum.newFixnum(ruby, ((Number) object).longValue()); } } else if (javaClass == String.class) { return RubyString.newString(ruby, object.toString()); } else if (javaClass.isArray()) { Class arrayClass = javaClass.getComponentType(); int len = Array.getLength(object); RubyObject[] items = new RubyObject[len]; for (int i = 0; i < len; i++) { items[i] = convertJavaToRuby(ruby, Array.get(object, i), arrayClass); } return RubyArray.create(ruby, null, items); } else if (List.class.isAssignableFrom(javaClass)) { int len = ((List) object).size(); RubyObject[] items = new RubyObject[len]; for (int i = 0; i < len; i++) { items[i] = convertJavaToRuby(ruby, ((List) object).get(i)); } return RubyArray.create(ruby, null, items); } else if (Map.class.isAssignableFrom(javaClass)) { int len = ((Map) object).size(); RubyObject[] items = new RubyObject[len * 2]; Iterator iter = ((Map) object).entrySet().iterator(); for (int i = 0; i < len; i++) { Map.Entry entry = (Map.Entry) iter.next(); items[2 * i] = convertJavaToRuby(ruby, entry.getKey(), null); items[2 * i + 1] = convertJavaToRuby(ruby, entry.getValue(), null); } return RubyHash.create(ruby, null, items); } else { return new RubyJavaObject(ruby, (RubyClass)ruby.getJavaSupport().loadClass(javaClass, null), object); } }
1,121,006
public static RubyObject convertJavaToRuby(Ruby ruby, Object object, Class javaClass) { if (object == null) { return ruby.getNil(); } if (javaClass == null) { javaClass = object.getClass(); } if (javaClass.isPrimitive()) { String cName = javaClass.getName(); if (cName == "boolean") { return RubyBoolean.newBoolean(ruby, ((Boolean) object).booleanValue()); } else if (cName == "float" || cName == "double") { return RubyFloat.newFloat(ruby, ((Number) object).doubleValue()); } else if (cName == "char") { return RubyFixnum.newFixnum(ruby, ((Character) object).charValue()); } else { // else it's one of the integral types return RubyFixnum.newFixnum(ruby, ((Number) object).longValue()); } } else if (javaClass == String.class) { return RubyString.newString(ruby, object.toString()); } else if (javaClass.isArray()) { Class arrayClass = javaClass.getComponentType(); int len = Array.getLength(object); RubyObject[] items = new RubyObject[len]; for (int i = 0; i < len; i++) { items[i] = convertJavaToRuby(ruby, Array.get(object, i), arrayClass); } return RubyArray.create(ruby, null, items); } else if (List.class.isAssignableFrom(javaClass)) { int len = ((List) object).size(); RubyObject[] items = new RubyObject[len]; for (int i = 0; i < len; i++) { items[i] = convertJavaToRuby(ruby, ((List) object).get(i), null); } return RubyArray.create(ruby, null, items); } else if (Map.class.isAssignableFrom(javaClass)) { int len = ((Map) object).size(); RubyObject[] items = new RubyObject[len * 2]; Iterator iter = ((Map) object).entrySet().iterator(); for (int i = 0; i < len; i++) { Map.Entry entry = (Map.Entry) iter.next(); items[2 * i] = convertJavaToRuby(ruby, entry.getKey(), null); items[2 * i + 1] = convertJavaToRuby(ruby, entry.getValue(), null); } return RubyHash.create(ruby, null, items); } else { return new RubyJavaObject(ruby, (RubyClass)ruby.getJavaSupport().loadClass(javaClass, null), object); } }
public static RubyObject convertJavaToRuby(Ruby ruby, Object object, Class javaClass) { if (object == null) { return ruby.getNil(); } if (javaClass == null) { javaClass = object.getClass(); } if (javaClass.isPrimitive()) { String cName = javaClass.getName(); if (cName == "boolean") { return RubyBoolean.newBoolean(ruby, ((Boolean) object).booleanValue()); } else if (cName == "float" || cName == "double") { return RubyFloat.newFloat(ruby, ((Number) object).doubleValue()); } else if (cName == "char") { return RubyFixnum.newFixnum(ruby, ((Character) object).charValue()); } else { // else it's one of the integral types return RubyFixnum.newFixnum(ruby, ((Number) object).longValue()); } } else if (javaClass == String.class) { return RubyString.newString(ruby, object.toString()); } else if (javaClass.isArray()) { Class arrayClass = javaClass.getComponentType(); int len = Array.getLength(object); RubyObject[] items = new RubyObject[len]; for (int i = 0; i < len; i++) { items[i] = convertJavaToRuby(ruby, Array.get(object, i), arrayClass); } return RubyArray.create(ruby, null, items); } else if (List.class.isAssignableFrom(javaClass)) { int len = ((List) object).size(); RubyObject[] items = new RubyObject[len]; for (int i = 0; i < len; i++) { items[i] = convertJavaToRuby(ruby, ((List) object).get(i), null); } return RubyArray.create(ruby, null, items); } else if (Map.class.isAssignableFrom(javaClass)) { int len = ((Map) object).size(); RubyObject[] items = new RubyObject[len * 2]; Iterator iter = ((Map) object).entrySet().iterator(); for (int i = 0; i < len; i++) { Map.Entry entry = (Map.Entry) iter.next(); items[2 * i] = convertJavaToRuby(ruby, entry.getKey(), null); items[2 * i + 1] = convertJavaToRuby(ruby, entry.getValue(), null); } return RubyHash.create(ruby, null, items); } else { return new RubyJavaObject(ruby, (RubyClass)ruby.getJavaSupport().loadClass(javaClass, null), object); } }
1,121,007
public static String getCompanyId(ActionRequest req) { ActionRequestImpl reqImpl = (ActionRequestImpl)req; return getCompanyId(reqImpl.getHttpServletRequest()); }
public static String getCompanyId(ActionRequest req) { ActionRequestImpl reqImpl = (ActionRequestImpl)req; return getCompanyId(reqImpl.getHttpServletRequest()); }
1,121,008
public static String getCompanyId(ActionRequest req) { ActionRequestImpl reqImpl = (ActionRequestImpl)req; return getCompanyId(reqImpl.getHttpServletRequest()); }
public static String getCompanyId(ActionRequest req) { ActionRequestImpl reqImpl = (ActionRequestImpl)req; if (companyId == null) { companyId = (String)req.getAttribute(WebKeys.COMPANY_ID); } return companyId; }
1,121,009
private void checkQueuedUploads() { // Check uploads to start List<Upload> uploadsToStart = new LinkedList<Upload>(); Map<Member, Long> uploadSizeToStartNodes = new HashMap<Member, Long>(); List<Upload> uploadsToBreak = new ArrayList<Upload>(); if (logVerbose) { log().verbose( "Checking " + queuedUploads.size() + " queued uploads"); } synchronized (queuedUploads) { for (Iterator it = queuedUploads.iterator(); it.hasNext();) { Upload upload = (Upload) it.next(); if (upload.isBroken()) { // add to break dls uploadsToBreak.add(upload); } else if (hasFreeUploadSlots() || upload.getPartner().isOnLAN()) { // The total size planned+current uploading to that node. long totalPlannedSizeUploadingTo = uploadingToSize(upload .getPartner()); if (totalPlannedSizeUploadingTo < 0) { totalPlannedSizeUploadingTo = 0; } Long plannedSizeUploadingTo = uploadSizeToStartNodes .get(upload.getPartner()); if (plannedSizeUploadingTo != null) { totalPlannedSizeUploadingTo += plannedSizeUploadingTo .longValue(); } totalPlannedSizeUploadingTo += upload.getFile().getSize(); if (totalPlannedSizeUploadingTo <= 5 * 1024 * 1024) { if (totalPlannedSizeUploadingTo >= 0) { log() .warn( "Starting another upload to " + upload.getPartner().getNick() + ". Total size to upload to: " + Format .formatBytesShort(totalPlannedSizeUploadingTo)); } // start the upload if we have free slots // and not uploading to member currently // or user is on local network // TODO should check if this file is not sended (or is // being send) to other user in the last minute or so to // allow for disitributtion of that file by user that // just received that file from us // Enqueue upload to friends and lan members first int uploadIndex = upload.getPartner().isFriend() ? 0 : uploadsToStart.size(); log() .verbose( "Starting upload at queue position: " + uploadIndex); uploadsToStart.add(uploadIndex, upload); uploadSizeToStartNodes.put(upload.getPartner(), Long .valueOf(upload.getFile().getSize())); } } } } if (logVerbose) { log().verbose( "Starting " + uploadsToStart.size() + " Uploads, " + uploadsToBreak.size() + " are getting broken"); } // Start uploads for (Iterator it = uploadsToStart.iterator(); it.hasNext();) { Upload upload = (Upload) it.next(); upload.start(); } for (Iterator it = uploadsToBreak.iterator(); it.hasNext();) { Upload upload = (Upload) it.next(); // Set broken setBroken(upload); } }
private void checkQueuedUploads() { // Check uploads to start List<Upload> uploadsToStart = new LinkedList<Upload>(); Map<Member, Long> uploadSizeToStartNodes = new HashMap<Member, Long>(); List<Upload> uploadsToBreak = new ArrayList<Upload>(); if (logVerbose) { log().verbose( "Checking " + queuedUploads.size() + " queued uploads"); } synchronized (queuedUploads) { for (Iterator it = queuedUploads.iterator(); it.hasNext();) { Upload upload = (Upload) it.next(); if (upload.isBroken()) { // add to break dls uploadsToBreak.add(upload); } else if (hasFreeUploadSlots() || upload.getPartner().isOnLAN()) { // The total size planned+current uploading to that node. long totalPlannedSizeUploadingTo = uploadingToSize(upload .getPartner()); if (totalPlannedSizeUploadingTo < 0) { totalPlannedSizeUploadingTo = 0; } Long plannedSizeUploadingTo = uploadSizeToStartNodes .get(upload.getPartner()); if (plannedSizeUploadingTo != null) { totalPlannedSizeUploadingTo += plannedSizeUploadingTo .longValue(); } totalPlannedSizeUploadingTo += upload.getFile().getSize(); if (noUploadYet || totalPlannedSizeUploadingTo <= 500 * 1024) { if (totalPlannedSizeUploadingTo >= 0) { log() .warn( "Starting another upload to " + upload.getPartner().getNick() + ". Total size to upload to: " + Format .formatBytesShort(totalPlannedSizeUploadingTo)); } // start the upload if we have free slots // and not uploading to member currently // or user is on local network // TODO should check if this file is not sended (or is // being send) to other user in the last minute or so to // allow for disitributtion of that file by user that // just received that file from us // Enqueue upload to friends and lan members first int uploadIndex = upload.getPartner().isFriend() ? 0 : uploadsToStart.size(); log() .verbose( "Starting upload at queue position: " + uploadIndex); uploadsToStart.add(uploadIndex, upload); uploadSizeToStartNodes.put(upload.getPartner(), Long .valueOf(upload.getFile().getSize())); } } } } if (logVerbose) { log().verbose( "Starting " + uploadsToStart.size() + " Uploads, " + uploadsToBreak.size() + " are getting broken"); } // Start uploads for (Iterator it = uploadsToStart.iterator(); it.hasNext();) { Upload upload = (Upload) it.next(); upload.start(); } for (Iterator it = uploadsToBreak.iterator(); it.hasNext();) { Upload upload = (Upload) it.next(); // Set broken setBroken(upload); } }
1,121,010
public static void addListener(Object listenerSupport, Object listener) { if (listenerSupport == null) { throw new NullPointerException("Listener support is null"); } if (!Proxy.isProxyClass(listenerSupport.getClass())) { throw new IllegalArgumentException( "Listener support is not valid. Seems not to be created with createListenerSupport."); } InvocationHandler invHandler = Proxy .getInvocationHandler(listenerSupport); if (invHandler instanceof ListenerSupportInvocationHandler) { ListenerSupportInvocationHandler lsInvHandler = (ListenerSupportInvocationHandler) invHandler; // Now add listener lsInvHandler.addListener(listener); } else { throw new IllegalArgumentException( "Listener support is not valid. Seems not to be created with createListenerSupport."); } }
public static void addListener(ListenerInterface listenerSupport, ListenerInterface listener) { if (listenerSupport == null) { throw new NullPointerException("Listener support is null"); } if (!Proxy.isProxyClass(listenerSupport.getClass())) { throw new IllegalArgumentException( "Listener support is not valid. Seems not to be created with createListenerSupport."); } InvocationHandler invHandler = Proxy .getInvocationHandler(listenerSupport); if (invHandler instanceof ListenerSupportInvocationHandler) { ListenerSupportInvocationHandler lsInvHandler = (ListenerSupportInvocationHandler) invHandler; // Now add listener lsInvHandler.addListener(listener); } else { throw new IllegalArgumentException( "Listener support is not valid. Seems not to be created with createListenerSupport."); } }
1,121,011
public synchronized void addChunk(FileChunk chunk) { Reject.ifNull(chunk, "Chunk is null"); if (isBroken()) { return; } if (!isStarted()) { // donwload begins to start setStarted(); } lastTouch.setTime(System.currentTimeMillis()); // check tempfile File tempFile = getTempFile(); // create subdirs File subdirs = tempFile.getParentFile(); if (!subdirs.exists()) { // TODO check if works else give warning because of invalid // directory name // and move to blacklist subdirs.mkdirs(); log().verbose("Subdirectory created: " + subdirs); } if (tempFile.exists() && chunk.offset == 0) { // download started from offset 0 new, remove file, // "erase and rewind" ;) if (!tempFile.delete()) { log().error( "Unable to removed broken tempfile for download: " + tempFile.getAbsolutePath()); tempFileError = true; abort(); return; } } if (!tempFile.exists()) { try { // TODO check if works else give warning because of invalid // filename or diskfull? // and move to blacklist tempFile.createNewFile(); } catch (IOException e) { log().error( "Unable to create/open tempfile for donwload: " + tempFile.getAbsolutePath() + ". " + e.getMessage()); tempFileError = true; abort(); return; } } // log().warn("Tempfile exists ? " + tempFile.exists() + ", " + // tempFile.getAbsolutePath()); if (!tempFile.canWrite()) { log().error( "Unable to write to tempfile for donwload: " + tempFile.getAbsolutePath()); tempFileError = true; abort(); return; } try { if (raf == null) { raf = new RandomAccessFile(tempFile, "rw"); } // check chunk validity if (chunk.offset < 0 || chunk.offset > getFile().getSize() || chunk.data == null || (chunk.data.length + chunk.offset > getFile().getSize()) || chunk.offset != raf.length()) { String reason = "unknown"; if (chunk.offset < 0 || chunk.offset > getFile().getSize()) { reason = "Illegal offset " + chunk.offset; } if (chunk.data == null) { reason = "Chunk data null"; } else { if (chunk.data.length + chunk.offset > getFile().getSize()) { reason = "Chunk exceeds filesize"; } if (chunk.offset != raf.length()) { reason = "Offset does not matches the current tempfile size. offset: " + chunk.offset + ", filesize: " + tempFile.length(); } } log().error( "Received illegal chunk. " + chunk + ". Reason: " + reason); // Abort dl abort(); return; } // add bytes to transferred status getCounter().chunkTransferred(chunk); FolderStatistic stat = getFile().getFolder(getController().getFolderRepository()) .getStatistic(); if (stat != null) { stat.getDownloadCounter().chunkTransferred(chunk); } // FIXME: Parse offset/not expect linar download // FIXME: Don't use a BufferedOutputStream // FIXME: Don't open the file over and over again /* Old code: OutputStream fOut = new BufferedOutputStream(new FileOutputStream( tempFile, true)); fOut.write(chunk.data); fOut.close(); */ // Testing code: raf.seek(chunk.offset); raf.write(chunk.data); // Set lastmodified date of file info /* * log().warn( "Setting lastmodified of tempfile for: " + * getFile().toDetailString()); */ // FIXME: This generates alot of head-jumps on the harddisc! tempFile.setLastModified(getFile().getModifiedDate().getTime()); log().verbose( "Wrote " + chunk.data.length + " bytes to tempfile " + tempFile.getAbsolutePath()); } catch (IOException e) { // TODO: Disk full warning ? log().error( "Error while writing to tempfile for donwload: " + tempFile.getAbsolutePath() + ". " + e.getMessage()); log().verbose(e); tempFileError = true; abort(); return; } // FIXME: currently the trigger to stop dl is // the arrival of a chunk which matches exactly to // the last chunk of the file if (!completed) { completed = chunk.data.length + chunk.offset == getFile().getSize(); if (completed) { // Finish download log().debug("Download completed: " + this); // Inform transfer manager getTransferManager().setCompleted(this); } } }
public synchronized void addChunk(FileChunk chunk) { Reject.ifNull(chunk, "Chunk is null"); if (isBroken()) { return; } if (!isStarted()) { // donwload begins to start setStarted(); } lastTouch.setTime(System.currentTimeMillis()); // check tempfile File tempFile = getTempFile(); // create subdirs File subdirs = tempFile.getParentFile(); if (!subdirs.exists()) { // TODO check if works else give warning because of invalid // directory name // and move to blacklist subdirs.mkdirs(); log().verbose("Subdirectory created: " + subdirs); } if (tempFile.exists() && chunk.offset == 0) { // download started from offset 0 new, remove file, // "erase and rewind" ;) if (!tempFile.delete()) { log().error( "Unable to removed broken tempfile for download: " + tempFile.getAbsolutePath()); tempFileError = true; abort(); return; } } if (!tempFile.exists()) { try { // TODO check if works else give warning because of invalid // filename or diskfull? // and move to blacklist tempFile.createNewFile(); } catch (IOException e) { log().error( "Unable to create/open tempfile for donwload: " + tempFile.getAbsolutePath() + ". " + e.getMessage()); tempFileError = true; abort(); return; } } // log().warn("Tempfile exists ? " + tempFile.exists() + ", " + // tempFile.getAbsolutePath()); if (!tempFile.canWrite()) { log().error( "Unable to write to tempfile for donwload: " + tempFile.getAbsolutePath()); tempFileError = true; abort(); return; } try { if (raf == null) { raf = new RandomAccessFile(tempFile, "rw"); } // check chunk validity if (chunk.offset < 0 || chunk.offset > getFile().getSize() || chunk.data == null || (chunk.data.length + chunk.offset > getFile().getSize()) || chunk.offset != raf.length()) { String reason = "unknown"; if (chunk.offset < 0 || chunk.offset > getFile().getSize()) { reason = "Illegal offset " + chunk.offset; } if (chunk.data == null) { reason = "Chunk data null"; } else { if (chunk.data.length + chunk.offset > getFile().getSize()) { reason = "Chunk exceeds filesize"; } if (chunk.offset != raf.length()) { reason = "Offset does not matches the current tempfile size. offset: " + chunk.offset + ", filesize: " + tempFile.length(); } } log().error( "Received illegal chunk. " + chunk + ". Reason: " + reason); // Abort dl abort(); return; } // add bytes to transferred status getCounter().chunkTransferred(chunk); FolderStatistic stat = getFile().getFolder(getController().getFolderRepository()) .getStatistic(); if (stat != null) { stat.getDownloadCounter().chunkTransferred(chunk); } // FIXME: Parse offset/not expect linar download // FIXME: Don't use a BufferedOutputStream // FIXME: Don't open the file over and over again /* Old code: OutputStream fOut = new BufferedOutputStream(new FileOutputStream( tempFile, true)); fOut.write(chunk.data); fOut.close(); */ // Testing code: raf.seek(chunk.offset); raf.write(chunk.data); // Set lastmodified date of file info /* * log().warn( "Setting lastmodified of tempfile for: " + * getFile().toDetailString()); */ // FIXME: This generates alot of head-jumps on the harddisc! tempFile.setLastModified(getFile().getModifiedDate().getTime()); log().verbose( "Wrote " + chunk.data.length + " bytes to tempfile " + tempFile.getAbsolutePath()); } catch (IOException e) { // TODO: Disk full warning ? log().error( "Error while writing to tempfile for donwload: " + tempFile.getAbsolutePath() + ". " + e.getMessage()); log().verbose(e); tempFileError = true; abort(); return; } // FIXME: currently the trigger to stop dl is // the arrival of a chunk which matches exactly to // the last chunk of the file if (!completed) { completed = chunk.data.length + chunk.offset == getFile().getSize(); if (completed) { // Finish download log().debug("Download completed: " + this); // Inform transfer manager getTransferManager().setCompleted(this); } } }
1,121,012
Download(TransferManager tm, FileInfo file, boolean automatic) { super(tm, file, null); // from can be null this.lastTouch = new Date(); this.automatic = automatic; this.queued = false; this.completed = false; this.tempFileError = false; File tempFile = getTempFile(); if (tempFile != null && tempFile.exists()) { String reason = ""; // Compare with global file date precision, because of // different precisions on different filesystems (e.g. FAT32 only // supports second near values) if (file.getSize() > tempFile.length() && Convert.convertToGlobalPrecision(file.getModifiedDate() .getTime()) == Convert.convertToGlobalPrecision(tempFile .lastModified())) { // Set offset only if file matches exactly setStartOffset(tempFile.length()); } else { if (file.getModifiedDate().getTime() != tempFile.lastModified()) { reason = ": Modified date of tempfile (" + new Date(Convert.convertToGlobalPrecision(tempFile .lastModified())) + ") does not match with file (" + new Date(Convert.convertToGlobalPrecision(file .getModifiedDate().getTime())) + ")"; } // Otherwise delete tempfile an start at 0 tempFile.delete(); setStartOffset(0); } log().verbose( "Tempfile exists for " + file + ", tempFile: " + tempFile + ", " + (tempFile.exists() ? "using it" : "removed") + " " + reason); } }
Download(TransferManager tm, FileInfo file, boolean automatic) { super(tm, file, null); // from can be null this.lastTouch = new Date(); this.automatic = automatic; this.queued = false; this.completed = false; this.tempFileError = false; File tempFile = getTempFile(); if (tempFile != null && tempFile.exists()) { String reason = ""; // Compare with global file date precision, because of // different precisions on different filesystems (e.g. FAT32 only // supports second near values) if (file.getSize() > tempFile.length() && Convert.convertToGlobalPrecision(file.getModifiedDate() .getTime()) == Convert.convertToGlobalPrecision(tempFile .lastModified())) { // Set offset only if file matches exactly setStartOffset(tempFile.length()); } else { if (file.getModifiedDate().getTime() != tempFile.lastModified()) { reason = ": Modified date of tempfile (" + new Date(Convert.convertToGlobalPrecision(tempFile .lastModified())) + ") does not match with file (" + new Date(Convert.convertToGlobalPrecision(file .getModifiedDate().getTime())) + ")"; } // Otherwise delete tempfile an start at 0 tempFile.delete(); setStartOffset(0); } log().verbose( "Tempfile exists for " + file + ", tempFile: " + tempFile + ", " + (tempFile.exists() ? "using it" : "removed") + " " + reason); } }
1,121,013
void shutdown() { super.shutdown(); if (myThread != null) { myThread.interrupt(); } }
void shutdown() { super.shutdown(); if (myThread != null) { myThread.interrupt(); } }
1,121,014
public static void removeListener(Object listenerSupport, Object listener) { if (listenerSupport == null) { throw new NullPointerException("Listener support is null"); } if (!Proxy.isProxyClass(listenerSupport.getClass())) { throw new IllegalArgumentException( "Listener support is not valid. Seems not to be created with createListenerSupport."); } InvocationHandler invHandler = Proxy .getInvocationHandler(listenerSupport); if (invHandler instanceof ListenerSupportInvocationHandler) { ListenerSupportInvocationHandler lsInvHandler = (ListenerSupportInvocationHandler) invHandler; // Now remove the listener lsInvHandler.removeListener(listener); } else { throw new IllegalArgumentException( "Listener support is not valid. Seems not to be created with createListenerSupport."); } }
public static void removeListener(Object listenerSupport, ListenerInterface listener) { if (listenerSupport == null) { throw new NullPointerException("Listener support is null"); } if (!Proxy.isProxyClass(listenerSupport.getClass())) { throw new IllegalArgumentException( "Listener support is not valid. Seems not to be created with createListenerSupport."); } InvocationHandler invHandler = Proxy .getInvocationHandler(listenerSupport); if (invHandler instanceof ListenerSupportInvocationHandler) { ListenerSupportInvocationHandler lsInvHandler = (ListenerSupportInvocationHandler) invHandler; // Now remove the listener lsInvHandler.removeListener(listener); } else { throw new IllegalArgumentException( "Listener support is not valid. Seems not to be created with createListenerSupport."); } }
1,121,015
public String toDetailString() { String modifiedNick; if (modifiedBy == null) { modifiedNick = "-unknown-"; } else { modifiedNick = modifiedBy.nick; } return (deleted ? "(del) " : "") + toString() + ", size: " + size + " bytes, version: " + getVersion() + ", modified: " + lastModifiedDate + " (" + lastModifiedDate.getTime() + ") by '" + modifiedNick + "'"; }
public String toDetailString() { String modifiedNick; if (modifiedBy == null) { modifiedNick = "-unknown-"; } else { modifiedNick = modifiedBy.nick; } return (deleted ? "(del) " : "") + toString() + ", size: " + size + " bytes, version: " + getVersion() + ", modified: " + lastModifiedDate + " (" + lastModifiedDate.getTime() + ") by '" + modifiedNick + "'"; }
1,121,016
public String toDetailString() { String modifiedNick; if (modifiedBy == null) { modifiedNick = "-unknown-"; } else { modifiedNick = modifiedBy.nick; } return (deleted ? "(del) " : "") + toString() + ", size: " + size + " bytes, version: " + getVersion() + ", modified: " + lastModifiedDate + " (" + lastModifiedDate.getTime() + ") by '" + modifiedNick + "'"; }
public String toDetailString() { String modifiedNick; if (modifiedBy == null) { str.append("-unknown-"); } else { modifiedNick = modifiedBy.nick; } return (deleted ? "(del) " : "") + toString() + ", size: " + size + " bytes, version: " + getVersion() + ", modified: " + lastModifiedDate + " (" + lastModifiedDate.getTime() + ") by '" + modifiedNick + "'"; }
1,121,017
public String toDetailString() { String modifiedNick; if (modifiedBy == null) { modifiedNick = "-unknown-"; } else { modifiedNick = modifiedBy.nick; } return (deleted ? "(del) " : "") + toString() + ", size: " + size + " bytes, version: " + getVersion() + ", modified: " + lastModifiedDate + " (" + lastModifiedDate.getTime() + ") by '" + modifiedNick + "'"; }
public String toDetailString() { String modifiedNick; if (modifiedBy == null) { modifiedNick = "-unknown-"; } else { str.append(modifiedBy.nick); } return (deleted ? "(del) " : "") + toString() + ", size: " + size + " bytes, version: " + getVersion() + ", modified: " + lastModifiedDate + " (" + lastModifiedDate.getTime() + ") by '" + modifiedNick + "'"; }
1,121,018
public String toDetailString() { String modifiedNick; if (modifiedBy == null) { modifiedNick = "-unknown-"; } else { modifiedNick = modifiedBy.nick; } return (deleted ? "(del) " : "") + toString() + ", size: " + size + " bytes, version: " + getVersion() + ", modified: " + lastModifiedDate + " (" + lastModifiedDate.getTime() + ") by '" + modifiedNick + "'"; }
public String toDetailString() { String modifiedNick; if (modifiedBy == null) { modifiedNick = "-unknown-"; } else { modifiedNick = modifiedBy.nick; } return (deleted ? "(del) " : "") + toString() + ", size: " + size + " bytes, version: " + getVersion() + ", modified: " + lastModifiedDate + " (" + lastModifiedDate.getTime() + ") by '" + modifiedNick + "'"; }
1,121,019
public void fileNameProblemsDetected( FileNameProblemEvent fileNameProblemEvent) { log().debug( "****************** " + fileNameProblemEvent.getFolder() + " " + fileNameProblemEvent.getScanResult().getProblemFiles()); final FilenameProblemDialog dialog = new FilenameProblemDialog( getController(), fileNameProblemEvent.getScanResult()); Runnable runner = new Runnable() { public void run() { dialog.open(); } }; UIUtil.invokeLaterInEDT(runner); }
public void fileNameProblemsDetected( FileNameProblemEvent fileNameProblemEvent) { log().debug( fileNameProblemEvent.getFolder() + " " + fileNameProblemEvent.getScanResult().getProblemFiles()); final FilenameProblemDialog dialog = new FilenameProblemDialog( getController(), fileNameProblemEvent.getScanResult()); Runnable runner = new Runnable() { public void run() { dialog.open(); } }; UIUtil.invokeLaterInEDT(runner); }
1,121,020
public void fileNameProblemsDetected( FileNameProblemEvent fileNameProblemEvent) { log().debug( "****************** " + fileNameProblemEvent.getFolder() + " " + fileNameProblemEvent.getScanResult().getProblemFiles()); final FilenameProblemDialog dialog = new FilenameProblemDialog( getController(), fileNameProblemEvent.getScanResult()); Runnable runner = new Runnable() { public void run() { dialog.open(); } }; UIUtil.invokeLaterInEDT(runner); }
public void fileNameProblemsDetected( FileNameProblemEvent fileNameProblemEvent) { log().debug( "****************** " + fileNameProblemEvent.getFolder() + " " + fileNameProblemEvent.getScanResult().getProblemFiles()); FilenameProblemDialog dialog = new FilenameProblemDialog( getController(), fileNameProblemEvent.getScanResult()); Runnable runner = new Runnable() { public void run() { dialog.open(); } }; UIUtil.invokeLaterInEDT(runner); }
1,121,021
public void fileNameProblemsDetected( FileNameProblemEvent fileNameProblemEvent) { log().debug( "****************** " + fileNameProblemEvent.getFolder() + " " + fileNameProblemEvent.getScanResult().getProblemFiles()); final FilenameProblemDialog dialog = new FilenameProblemDialog( getController(), fileNameProblemEvent.getScanResult()); Runnable runner = new Runnable() { public void run() { dialog.open(); } }; UIUtil.invokeLaterInEDT(runner); }
public void fileNameProblemsDetected( FileNameProblemEvent fileNameProblemEvent) { log().debug( "****************** " + fileNameProblemEvent.getFolder() + " " + fileNameProblemEvent.getScanResult().getProblemFiles()); final FilenameProblemDialog dialog = new FilenameProblemDialog( getController(), fileNameProblemEvent.getScanResult()); Runnable runner = new Runnable() { public void run() { dialog.open(); } }; UIUtil.invokeLaterInEDT(runner); }
1,121,022
public TransferManager(Controller controller) { super(controller); this.started = false; this.queuedUploads = Collections.synchronizedList(new LinkedList()); this.activeUploads = Collections.synchronizedList(new LinkedList()); this.downloads = new ConcurrentHashMap<FileInfo, Download>(); this.pendingDownloads = Collections .synchronizedList(new LinkedList<Download>()); this.completedDownloads = Collections .synchronizedList(new LinkedList<Download>()); this.uploadCounter = new TransferCounter(); this.downloadCounter = new TransferCounter(); // Create listener support this.listenerSupport = (TransferManagerListener) ListenerSupportFactory .createListenerSupport(TransferManagerListener.class); // maximum concurrent uploads allowedUploads = ConfigurationEntry.UPLOADS_MAX_CONCURRENT.getValueInt( getController()).intValue(); if (allowedUploads <= 0) { throw new NumberFormatException("Illegal value for max uploads: " + allowedUploads); } // parse max upload cps String cps = ConfigurationEntry.UPLOADLIMIT_WAN .getValue(getController()); long maxCps = 0; if (cps != null) { try { maxCps = (long) Double.parseDouble(cps) * 1024; if (maxCps < 0) { throw new NumberFormatException(); } } catch (NumberFormatException e) { log().warn( "Illegal value for KByte upload limit. '" + cps + "'"); } } bandwidthProvider = new BandwidthProvider(); sharedWANOutputHandler = new BandwidthLimiter(); bandwidthProvider.setLimitBPS(sharedWANOutputHandler, maxCps); sharedInputHandler = new BandwidthLimiter(); // set ul limit setAllowedUploadCPSForWAN(maxCps); // parse max upload cps cps = ConfigurationEntry.UPLOADLIMIT_LAN.getValue(getController()); maxCps = 0; if (cps != null) { try { maxCps = (long) Double.parseDouble(cps) * 1024; if (maxCps < 0) { throw new NumberFormatException(); } } catch (NumberFormatException e) { log().warn( "Illegal value for KByte upload limit. '" + cps + "'"); } } sharedLANOutputHandler = new BandwidthLimiter(); bandwidthProvider.setLimitBPS(sharedLANOutputHandler, maxCps); // set ul limit setAllowedUploadCPSForLAN(maxCps); }
public TransferManager(Controller controller) { super(controller); this.started = false; this.queuedUploads = Collections.synchronizedList(new LinkedList()); this.activeUploads = Collections.synchronizedList(new LinkedList()); this.downloads = new ConcurrentHashMap<FileInfo, Download>(); this.pendingDownloads = Collections .synchronizedList(new LinkedList<Download>()); this.completedDownloads = Collections .synchronizedList(new LinkedList<Download>()); this.uploadCounter = new TransferCounter(); this.downloadCounter = new TransferCounter(); // Create listener support this.listenerSupport = (TransferManagerListener) ListenerSupportFactory .createListenerSupport(TransferManagerListener.class); // maximum concurrent uploads allowedUploads = ConfigurationEntry.UPLOADS_MAX_CONCURRENT.getValueInt( getController()).intValue(); if (allowedUploads <= 0) { throw new NumberFormatException("Illegal value for max uploads: " + allowedUploads); } // parse max upload cps String cps = ConfigurationEntry.UPLOADLIMIT_WAN .getValue(getController()); long maxCps = 0; if (cps != null) { try { maxCps = (long) Double.parseDouble(cps) * 1024; if (maxCps < 0) { throw new NumberFormatException(); } } catch (NumberFormatException e) { log().warn( "Illegal value for KByte upload limit. '" + cps + "'"); } } bandwidthProvider = new BandwidthProvider(); sharedWANOutputHandler = new BandwidthLimiter(); bandwidthProvider.setLimitBPS(sharedWANOutputHandler, maxCps); sharedInputHandler = new BandwidthLimiter(); // set ul limit setAllowedUploadCPSForWAN(maxCps); // parse max upload cps cps = ConfigurationEntry.UPLOADLIMIT_LAN.getValue(getController()); maxCps = 0; if (cps != null) { try { maxCps = (long) Double.parseDouble(cps) * 1024; if (maxCps < 0) { throw new NumberFormatException(); } } catch (NumberFormatException e) { log().warn( "Illegal value for KByte upload limit. '" + cps + "'"); } } sharedLANOutputHandler = new BandwidthLimiter(); bandwidthProvider.setLimitBPS(sharedLANOutputHandler, maxCps); // set ul limit setAllowedUploadCPSForLAN(maxCps); }
1,121,023
public Upload queueUpload(Member from, RequestDownload dl) { if (dl == null || dl.file == null) { throw new NullPointerException("Downloadrequest/File is null"); } // Never upload db files !! if (Folder.DB_FILENAME.equalsIgnoreCase(dl.file.getName()) || Folder.DB_BACKUP_FILENAME.equalsIgnoreCase(dl.file.getName())) { log() .error( from.getNick() + " has illegally requested to download a folder database file"); return null; } Upload upload; boolean isNew; synchronized (queuedUploads) { upload = new Upload(this, from, dl); if (upload.isBroken()) { // Check if this download is broken return null; } if (!queuedUploads.contains(upload)) { log().verbose( "Upload enqueud: " + dl.file + ", startOffset: " + dl.startOffset + ", member: " + from); queuedUploads.add(upload); isNew = true; } else { isNew = false; log().warn( "Received already known download request for " + dl.file + " from " + from.getNick()); } } // If upload is not started, tell peer if (!upload.isStarted()) { from.sendMessageAsynchron(new DownloadQueued(upload.getFile()), null); } if (isNew && !upload.isBroken()) { fireUploadRequested(new TransferManagerEvent(this, upload)); } // Trigger working thread triggerTransfersCheck(); return upload; }
public Upload queueUpload(Member from, RequestDownload dl) { if (dl == null || dl.file == null) { throw new NullPointerException("Downloadrequest/File is null"); } // Never upload db files !! if (Folder.DB_FILENAME.equalsIgnoreCase(dl.file.getName()) || Folder.DB_BACKUP_FILENAME.equalsIgnoreCase(dl.file.getName())) { log() .error( from.getNick() + " has illegally requested to download a folder database file"); return null; } Upload upload; boolean isNew; synchronized (queuedUploads) { upload = new Upload(this, from, dl); if (upload.isBroken()) { // Check if this download is broken return null; } if (!queuedUploads.contains(upload)) { log().verbose( "Upload enqueud: " + dl.file + ", startOffset: " + dl.startOffset + ", member: " + from); queuedUploads.add(upload); isNew = true; } else { isNew = false; log().warn( "Received already known download request for " + dl.file + " from " + from.getNick()); } } // If upload is not started, tell peer if (!upload.isStarted()) { from.sendMessageAsynchron(new DownloadQueued(upload.getFile()), null); } if (isNew && !upload.isBroken()) { fireUploadRequested(new TransferManagerEvent(this, upload)); } // Trigger working thread triggerTransfersCheck(); return upload; }
1,121,024
public Upload queueUpload(Member from, RequestDownload dl) { if (dl == null || dl.file == null) { throw new NullPointerException("Downloadrequest/File is null"); } // Never upload db files !! if (Folder.DB_FILENAME.equalsIgnoreCase(dl.file.getName()) || Folder.DB_BACKUP_FILENAME.equalsIgnoreCase(dl.file.getName())) { log() .error( from.getNick() + " has illegally requested to download a folder database file"); return null; } Upload upload; boolean isNew; synchronized (queuedUploads) { upload = new Upload(this, from, dl); if (upload.isBroken()) { // Check if this download is broken return null; } if (!queuedUploads.contains(upload)) { log().verbose( "Upload enqueud: " + dl.file + ", startOffset: " + dl.startOffset + ", member: " + from); queuedUploads.add(upload); isNew = true; } else { isNew = false; log().warn( "Received already known download request for " + dl.file + " from " + from.getNick()); } } // If upload is not started, tell peer if (!upload.isStarted()) { from.sendMessageAsynchron(new DownloadQueued(upload.getFile()), null); } if (isNew && !upload.isBroken()) { fireUploadRequested(new TransferManagerEvent(this, upload)); } // Trigger working thread triggerTransfersCheck(); return upload; }
public Upload queueUpload(Member from, RequestDownload dl) { if (dl == null || dl.file == null) { throw new NullPointerException("Downloadrequest/File is null"); } // Never upload db files !! if (Folder.DB_FILENAME.equalsIgnoreCase(dl.file.getName()) || Folder.DB_BACKUP_FILENAME.equalsIgnoreCase(dl.file.getName())) { log() .error( from.getNick() + " has illegally requested to download a folder database file"); return null; } Upload upload; boolean isNew; synchronized (queuedUploads) { upload = new Upload(this, from, dl); if (upload.isBroken()) { // Check if this download is broken return null; } if (!queuedUploads.contains(upload)) { log().verbose( "Upload enqueud: " + dl.file + ", startOffset: " + dl.startOffset + ", member: " + from); queuedUploads.add(upload); isNew = true; } else { isNew = false; log().warn( "Received already known download request for " + dl.file + " from " + from.getNick()); } } // If upload is not started, tell peer if (!upload.isStarted()) { from.sendMessageAsynchron(new DownloadQueued(upload.getFile()), null); } if (isNew && !upload.isBroken()) { fireUploadRequested(new TransferManagerEvent(this, upload)); } // Trigger working thread triggerTransfersCheck(); return upload; }
1,121,025
public Upload queueUpload(Member from, RequestDownload dl) { if (dl == null || dl.file == null) { throw new NullPointerException("Downloadrequest/File is null"); } // Never upload db files !! if (Folder.DB_FILENAME.equalsIgnoreCase(dl.file.getName()) || Folder.DB_BACKUP_FILENAME.equalsIgnoreCase(dl.file.getName())) { log() .error( from.getNick() + " has illegally requested to download a folder database file"); return null; } Upload upload; boolean isNew; synchronized (queuedUploads) { upload = new Upload(this, from, dl); if (upload.isBroken()) { // Check if this download is broken return null; } if (!queuedUploads.contains(upload)) { log().verbose( "Upload enqueud: " + dl.file + ", startOffset: " + dl.startOffset + ", member: " + from); queuedUploads.add(upload); isNew = true; } else { isNew = false; log().warn( "Received already known download request for " + dl.file + " from " + from.getNick()); } } // If upload is not started, tell peer if (!upload.isStarted()) { from.sendMessageAsynchron(new DownloadQueued(upload.getFile()), null); } if (isNew && !upload.isBroken()) { fireUploadRequested(new TransferManagerEvent(this, upload)); } // Trigger working thread triggerTransfersCheck(); return upload; }
public Upload queueUpload(Member from, RequestDownload dl) { if (dl == null || dl.file == null) { throw new NullPointerException("Downloadrequest/File is null"); } // Never upload db files !! if (Folder.DB_FILENAME.equalsIgnoreCase(dl.file.getName()) || Folder.DB_BACKUP_FILENAME.equalsIgnoreCase(dl.file.getName())) { log() .error( from.getNick() + " has illegally requested to download a folder database file"); return null; } Upload upload; boolean isNew; synchronized (queuedUploads) { upload = new Upload(this, from, dl); if (upload.isBroken()) { // Check if this download is broken return null; } if (!queuedUploads.contains(upload)) { log().verbose( "Upload enqueud: " + dl.file + ", startOffset: " + dl.startOffset + ", member: " + from); queuedUploads.add(upload); isNew = true; } else { isNew = false; log().warn( "Received already known download request for " + dl.file + " from " + from.getNick()); } } // If upload is not started, tell peer if (!upload.isStarted()) { from.sendMessageAsynchron(new DownloadQueued(upload.getFile()), null); } if (!upload.isBroken()) { fireUploadRequested(new TransferManagerEvent(this, upload)); } // Trigger working thread triggerTransfersCheck(); return upload; }
1,121,026
void setStarted(Transfer transfer) { if (transfer instanceof Upload) { synchronized (queuedUploads) { synchronized (activeUploads) { queuedUploads.remove(transfer); activeUploads.add(transfer); } } // Fire event fireUploadStarted(new TransferManagerEvent(this, (Upload) transfer)); } else if (transfer instanceof Download) { // Fire event fireDownloadStarted(new TransferManagerEvent(this, (Download) transfer)); } log().debug("Transfer started: " + transfer); }
void setStarted(Transfer transfer) { if (transfer instanceof Upload) { synchronized (queuedUploads) { synchronized (activeUploads) { queuedUploads.remove(transfer); activeUploads.add((Upload) transfer); } } // Fire event fireUploadStarted(new TransferManagerEvent(this, (Upload) transfer)); } else if (transfer instanceof Download) { // Fire event fireDownloadStarted(new TransferManagerEvent(this, (Download) transfer)); } log().debug("Transfer started: " + transfer); }
1,121,027
protected void handleKeyReleased(KeyEvent e) { Text theText = (Text) e.widget; String theInputString = theText.getText(); try { if ('\r' == e.character) { theText.setText(""); parseAndFireCommandEvent(theInputString, CommandEvent.Destination.BROKER); } else if (e.keyCode == 't' && ((e.stateMask & SWT.CONTROL) != 0)) { theText.setText(""); parseAndFireCommandEvent(theInputString, CommandEvent.Destination.EDITOR); } } catch (NoMoreIDsException e1) { Application.getMainConsoleLogger().error("Ran out of ID's parsing command '"+theInputString +"'"); } catch (ParserException e1) { Application.getMainConsoleLogger().error(theInputString+": "+e1.getMessage() ); } }
protected void handleKeyReleased(KeyEvent e) { Text theText = (Text) e.widget; String theInputString = theText.getText(); try { if ('\r' == e.character) { theText.setText(""); parseAndFireCommandEvent(theInputString, CommandEvent.Destination.BROKER); } else if (e.keyCode == 't' && ((e.stateMask & SWT.CONTROL) != 0)) { theText.setText(""); parseAndFireCommandEvent(theInputString, CommandEvent.Destination.EDITOR); } } catch (NoMoreIDsException e1) { Application.getMainConsoleLogger().error("Ran out of ID's parsing command '"+theInputString +"'"); } catch (ParserException e1) { Application.getMainConsoleLogger().error(theInputString+": "+e1.getMessage() ); } }
1,121,028
protected void handleKeyReleased(KeyEvent e) { Text theText = (Text) e.widget; String theInputString = theText.getText(); try { if ('\r' == e.character) { theText.setText(""); parseAndFireCommandEvent(theInputString, CommandEvent.Destination.BROKER); } else if (e.keyCode == 't' && ((e.stateMask & SWT.CONTROL) != 0)) { theText.setText(""); parseAndFireCommandEvent(theInputString, CommandEvent.Destination.EDITOR); } } catch (NoMoreIDsException e1) { Application.getMainConsoleLogger().error("Ran out of ID's parsing command '"+theInputString +"'"); } catch (ParserException e1) { Application.getMainConsoleLogger().error(theInputString+": "+e1.getMessage() ); } }
protected void handleKeyReleased(KeyEvent e) { Text theText = (Text) e.widget; String theInputString = theText.getText(); try { if ('\r' == e.character) { theText.setText(""); parseAndFireCommandEvent(theInputString, CommandEvent.Destination.BROKER); } else if (e.keyCode == 't' && ((e.stateMask & SWT.CONTROL) != 0)) { theText.setText(""); parseAndFireCommandEvent(theInputString, CommandEvent.Destination.EDITOR); } } catch (NoMoreIDsException e1) { Application.getMainConsoleLogger().error("Ran out of ID's parsing command '"+theInputString +"'"); } catch (ParserException e1) { Application.getMainConsoleLogger().error(theInputString+": "+e1.getMessage() ); } }
1,121,029
protected void handleKeyReleased(KeyEvent e) { Text theText = (Text) e.widget; String theInputString = theText.getText(); try { if ('\r' == e.character) { theText.setText(""); parseAndFireCommandEvent(theInputString, CommandEvent.Destination.BROKER); } else if (e.keyCode == 't' && ((e.stateMask & SWT.CONTROL) != 0)) { theText.setText(""); parseAndFireCommandEvent(theInputString, CommandEvent.Destination.EDITOR); } } catch (NoMoreIDsException e1) { Application.getMainConsoleLogger().error("Ran out of ID's parsing command '"+theInputString +"'"); } catch (ParserException e1) { Application.getMainConsoleLogger().error(theInputString+": "+e1.getMessage() ); } }
protected void handleKeyReleased(KeyEvent e) { Text theText = (Text) e.widget; String theInputString = theText.getText(); try { if ('\r' == e.character) { theText.setText(""); parseAndFireCommandEvent(theInputString, CommandEvent.Destination.BROKER); } else if (e.keyCode == 't' && ((e.stateMask & SWT.CONTROL) != 0)) { theText.setText(""); parseAndFireCommandEvent(theInputString, CommandEvent.Destination.EDITOR); } } catch (NoMoreIDsException e1) { Application.getMainConsoleLogger().error("Ran out of ID's parsing command '"+theInputString +"'"); } catch (ParserException e1) { Application.getMainConsoleLogger().error(theInputString+": "+e1.getMessage() ); } }
1,121,030
public void setIDFactory(IDFactory factory) { commandParser.init(factory); }
public void setIDFactory(IDFactory factory) { commandParser.setIDFactory(factory); }
1,121,031
public abstract Callback getMethod(String method, Class arg1);
public abstract Callback getMethod(String method);
1,121,032
public static Test suite() { LoggerAdapter.initializeLogger("unitTest"); return (new TestSuite(JCycloneStagesTest.class)); }
public static Test suite() { LoggerAdapter.initializeLogger("unitTest"); return (new TestSuite(JCycloneStagesTest.class)); }
1,121,033
public static LoggerAdapter initializeLogger(String name) { if(sLogger != null) { return sLogger; } sLogger = new LoggerAdapter(name); PropertyConfigurator.configureAndWatch(LOGGER_CONF_FILE, LOGGER_WATCH_DELAY); sLogger.setLevel(Level.ERROR); System.out.println("Initialized top-level Logger: "+name); return sLogger; }
public static LoggerAdapter initializeLogger(String name) { if(sLogger != null) { return sLogger; } sLogger = new LoggerAdapter(name); PropertyConfigurator.configureAndWatch(LOGGER_CONF_FILE, LOGGER_WATCH_DELAY); sLogger.setLevel(Level.ERROR); System.out.println(MessageKey.LOGGER_INIT.getLocalizedMessage(name)); return sLogger; }
1,121,034
public RubyObject funcall(String name) { return funcall(name, (RubyPointer) null); }
public RubyObject funcall(String name) { return funcall(name, (RubyPointer) null); }
1,121,035
public static void general( Level level, String msg, Throwable th ) { log( GENERAL, level, msg, th ); }
public static void general( Level level, String msg, Throwable th ) { log( GENERAL, level, msg, th ); }
1,121,036
public void init(ConfigData config) throws Exception { mCurFixVersion = config.get(ConnectionConstants.FIX_VERSION_KEY, FIX_VERSION_DEFAULT); FIXDataDictionaryManager.setFIXVersion(mCurFixVersion); String senderCompID = config.get(ConnectionConstants.FIX_SENDER_COMP_ID, ""); String targetCompID = config.get(ConnectionConstants.FIX_TARGET_COMP_ID, ""); mFixServerAddress = config.get(ConnectionConstants.FIX_SERVER_ADDRESS, ""); String dataDictionary = config.get(Session.SETTING_DATA_DICTIONARY, ""); String useDataDictionary = config.get(Session.SETTING_USE_DATA_DICTIONARY, "N"); long fixServerPort = config.getLong(ConnectionConstants.FIX_SERVER_PORT, 0); String resetOnLogout = config.get(Session.SETTING_RESET_ON_LOGOUT, "Y"); String resetOnDisconnect = config.get(Session.SETTING_RESET_ON_DISCONNECT, "Y"); String sendResetSeqNumFlag = config.get(Session.SETTING_RESET_WHEN_INITIATING_LOGON, "Y"); QuickFIXDescriptor descriptor = sFIXVersionMap.get(mCurFixVersion); if (descriptor == null) { throw new ClassNotFoundException( "Could not find class for fix version " + mCurFixVersion); } mMessageFactory = descriptor.getMessageFactory(); // populate the default FIX session settings Map<String, Object> defaults = new HashMap<String, Object>(); defaults.put("ConnectionType","initiator"); defaults.put("HeartBtInt",Long.toString(30)); defaults.put("FileStorePath","store"); defaults.put("StartTime","00:00:00"); defaults.put("EndTime","00:00:00"); defaults.put(Session.SETTING_DATA_DICTIONARY, dataDictionary); defaults.put("UseDataDictionary",useDataDictionary); defaults.put("ReconnectInterval",Long.toString(15)); defaults.put(Session.SETTING_RESET_ON_LOGOUT, resetOnLogout); defaults.put(Session.SETTING_RESET_ON_DISCONNECT, resetOnDisconnect); defaults.put(Session.SETTING_RESET_WHEN_INITIATING_LOGON, sendResetSeqNumFlag); defaults.put(SOCKET_CONNECT_HOST,mFixServerAddress); defaults.put(SOCKET_CONNECT_PORT,Long.toString(fixServerPort)); String [] keys = config.keys(); for (String key : keys) { if (key.startsWith(ConnectionConstants.FIX_SERVER_ADDRESS) && key.length() > ConnectionConstants.FIX_SERVER_ADDRESS.length() + 1) { String suffix = key.substring(ConnectionConstants.FIX_SERVER_ADDRESS.length() + 1); String newKey = SOCKET_CONNECT_HOST + suffix; defaults.put(newKey, config.get(key, "")); } } for (String key : keys) { if (key.startsWith(ConnectionConstants.FIX_SERVER_PORT) && key.length() > ConnectionConstants.FIX_SERVER_PORT.length()) { String suffix = key.substring(ConnectionConstants.FIX_SERVER_PORT.length() + 1); String newKey = SOCKET_CONNECT_PORT + suffix; defaults.put(newKey, config.get(key, "")); } } SessionSettings settings = new SessionSettings(); // this poorly named set method sets the defaults for the session settings settings.set(defaults); SessionID id = new SessionID(mCurFixVersion, senderCompID, targetCompID, ""); settings.setString(id, "BeginString", mCurFixVersion); settings.setString(id, "SenderCompID", senderCompID); settings.setString(id, "TargetCompID", targetCompID); settings.setString(id, "SessionQualifier", ""); MessageStoreFactory storeFactory = new FileStoreFactory(settings); LogFactory logFactory = new ScreenLogFactory(settings); mSocketInitiator = new SocketInitiator(this, storeFactory, settings, logFactory, getMessageFactory()); mDefaultSessionID = new SessionID(mCurFixVersion, senderCompID, targetCompID, null); mSessionMap.put(mDefaultSessionID, sessionAdapter); startSocketInitiator(mSocketInitiator); }
public void init(ConfigData config) throws Exception { mCurFixVersion = config.get(ConnectionConstants.FIX_VERSION_KEY, FIX_VERSION_DEFAULT); FIXDataDictionaryManager.setFIXVersion(mCurFixVersion); String senderCompID = config.get(ConnectionConstants.FIX_SENDER_COMP_ID, ""); String targetCompID = config.get(ConnectionConstants.FIX_TARGET_COMP_ID, ""); mFixServerAddress = config.get(ConnectionConstants.FIX_SERVER_ADDRESS, ""); String dataDictionary = config.get(Session.SETTING_DATA_DICTIONARY, ""); String useDataDictionary = config.get(Session.SETTING_USE_DATA_DICTIONARY, "N"); long fixServerPort = config.getLong(ConnectionConstants.FIX_SERVER_PORT, 0); String resetOnLogout = config.get(Session.SETTING_RESET_ON_LOGOUT, "Y"); String resetOnDisconnect = config.get(Session.SETTING_RESET_ON_DISCONNECT, "Y"); String sendResetSeqNumFlag = config.get(Session.SETTING_RESET_WHEN_INITIATING_LOGON, "Y"); QuickFIXDescriptor descriptor = sFIXVersionMap.get(mCurFixVersion); if (descriptor == null) { throw new ClassNotFoundException( "Could not find class for fix version " + mCurFixVersion); } mMessageFactory = descriptor.getMessageFactory(); // populate the default FIX session settings Map<String, Object> defaults = new HashMap<String, Object>(); defaults.put("ConnectionType","initiator"); defaults.put("HeartBtInt",Long.toString(30)); defaults.put("FileStorePath","store"); defaults.put("StartTime","00:00:00"); defaults.put("EndTime","00:00:00"); defaults.put(Session.SETTING_DATA_DICTIONARY, dataDictionary); defaults.put("UseDataDictionary",useDataDictionary); defaults.put("ReconnectInterval",Long.toString(15)); defaults.put(Session.SETTING_RESET_ON_LOGOUT, resetOnLogout); defaults.put(Session.SETTING_RESET_ON_DISCONNECT, resetOnDisconnect); defaults.put(Session.SETTING_RESET_WHEN_INITIATING_LOGON, sendResetSeqNumFlag); defaults.put(SOCKET_CONNECT_HOST,mFixServerAddress); defaults.put(SOCKET_CONNECT_PORT,Long.toString(fixServerPort)); String [] keys = config.keys(); for (String key : keys) { if (key.startsWith(ConnectionConstants.FIX_SERVER_ADDRESS) && key.length() > ConnectionConstants.FIX_SERVER_ADDRESS.length() + 1) { String suffix = key.substring(ConnectionConstants.FIX_SERVER_ADDRESS.length() + 1); String newKey = SOCKET_CONNECT_HOST + suffix; defaults.put(newKey, config.get(key, "")); } } for (String key : keys) { if (key.startsWith(ConnectionConstants.FIX_SERVER_PORT) && key.length() > ConnectionConstants.FIX_SERVER_PORT.length()) { String suffix = key.substring(ConnectionConstants.FIX_SERVER_PORT.length() + 1); String newKey = SOCKET_CONNECT_PORT + suffix; defaults.put(newKey, config.get(key, "")); } } SessionSettings settings = new SessionSettings(); // this poorly named set method sets the defaults for the session settings settings.set(defaults); SessionID id = new SessionID(mCurFixVersion, senderCompID, targetCompID, ""); settings.setString(id, "BeginString", mCurFixVersion); settings.setString(id, "SenderCompID", senderCompID); settings.setString(id, "TargetCompID", targetCompID); settings.setString(id, "SessionQualifier", ""); MessageStoreFactory storeFactory = new FileStoreFactory(settings); LogFactory logFactory = null; if (useJDBC) { logFactory = new CompositeLogFactory(new LogFactory[] {new JdbcLogFactory(settings), new ScreenLogFactory(settings)}); } else { logFactory = new ScreenLogFactory(settings); } mSocketInitiator = new SocketInitiator(this, storeFactory, settings, logFactory, getMessageFactory()); mDefaultSessionID = new SessionID(mCurFixVersion, senderCompID, targetCompID, null); mSessionMap.put(mDefaultSessionID, sessionAdapter); startSocketInitiator(mSocketInitiator); }
1,121,037
public final MessageFactory getMessageFactory() throws ClassNotFoundException { String className = "quickfix." + mQuickFIXPackage + ".MessageFactory"; try { Class messageFactoryClass = Class.forName(className); return (MessageFactory) messageFactoryClass.newInstance(); } catch (Exception ex) { throw new ClassNotFoundException("Could not find class: " + className); } }
public final MessageFactory getMessageFactory() throws ClassNotFoundException { String className = "quickfix." + mQuickFIXPackage + ".MessageFactory"; try { Class messageFactoryClass = Class.forName(className); return (MessageFactory) messageFactoryClass.newInstance(); } catch (Exception ex) { throw new ClassNotFoundException("Could not find class: " + className); } }
1,121,038
public static void debug(String msg, Object inCat) { getMyLogger(inCat).log(WRAPPER_FQCN, Level.DEBUG, msg, null); }
public void debug(String inMsg) { getMyLogger(inCat).log(WRAPPER_FQCN, Level.DEBUG, msg, null); }
1,121,040
public static void debug(String msg, Object inCat) { getMyLogger(inCat).log(WRAPPER_FQCN, Level.DEBUG, msg, null); }
public static void debug(String msg, Object inCat) { throw new IllegalArgumentException(MessageKey.LOGGER_MISSING_CAT.getLocalizedMessage()); }
1,121,041
public IOMetaClass(String name, Class clazz, RubyClass superClass, RubyModule parentModule) { super(name, clazz, superClass, parentModule); }
public IOMetaClass(String name, Class clazz, RubyClass superClass, RubyModule parentModule) { super(name, clazz, superClass, parentModule); }
1,121,042
private boolean drop(File file, Directory directory) { // test if a dir is dropped if (file.isDirectory()) { Directory subDirectory = directory.getCreateSubDirectory(file .getName()); File[] files = file.listFiles(); total += files.length; // Dropper dropper = new Dropper(subDirectory, files.length); for (File subFile : files) { // drop all files in this dir using a new dropper if (subFile.exists() && subFile.canRead()) { if (!drop(subFile, subDirectory)) { return false; } // if dialog was shown we take over the choice if (cancel) { break; } if (skipAll) { break; } } } return true; } // normal file: count++; if (directory.alreadyHasFileOnDisk(file)) { return false; } if (directory.contains(file)) { if (skipAll) { // skip all duplicates // continueDropping = true; return true; } if (!overwriteAll) { if (count < total) {// dialog for more items Object[] options = { Translation.getTranslation("general.overwrite"), Translation.getTranslation("general.overwrite_all"), Translation.getTranslation("general.skip"), Translation .getTranslation("directorypanel.dropfile_duplicate_dialog.skipall"), Translation.getTranslation("general.cancel")}; int option = JOptionPane .showOptionDialog( getUIController().getMainFrame() .getUIComponent(), Translation .getTranslation( "directorypanel.dropfile_duplicate_dialog.text", file.getName()), Translation .getTranslation("directorypanel.dropfile_duplicate_dialog.title"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[2]); switch (option) { case 0 : { // overwrite break; } case 1 : { // overwrite all overwriteAll = true; break; } case 2 : { // skip return true; } case 3 : { // skip all dupes skipAll = true; return true; } case 4 : { // cancel cancel = true; break; } } } else {// dialog for just one item Object[] options = { Translation.getTranslation("general.overwrite"), Translation.getTranslation("general.skip"), Translation.getTranslation("general.cancel")}; int option = JOptionPane .showOptionDialog( getUIController().getMainFrame() .getUIComponent(), Translation .getTranslation( "directorypanel.dropfile_duplicate_dialog.text", file.getName()), Translation .getTranslation("directorypanel.dropfile_duplicate_dialog.title"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[2]); switch (option) { case 0 : { // overwrite break; } case 1 : { // skip return true; } case 2 : { // cancel cancel = true; break; } } } } } if (cancel) { return true; } DirectoryPanel.this.directoryTable.getParent().setCursor( Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); if (!directory.copyFileFrom(file, getFileCopier())) { DirectoryPanel.this.directoryTable.getParent().setCursor( Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); // something failed return false; } DirectoryPanel.this.directoryTable.getParent().setCursor( Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); return true; }
private boolean drop(File file, Directory directory) { // test if a dir is dropped if (file.isDirectory()) { Directory subDirectory = directory.getCreateSubDirectory(file .getName()); File[] files = file.listFiles(); total += files.length; // Dropper dropper = new Dropper(subDirectory, files.length); for (File subFile : files) { // drop all files in this dir using a new dropper if (subFile.exists() && subFile.canRead()) { if (!drop(subFile, subDirectory)) { return false; } // if dialog was shown we take over the choice if (cancel) { break; } if (skipAll) { break; } } } return true; } // normal file: count++; if (directory.alreadyHasFileOnDisk(file)) { return false; } if (directory.contains(file)) { if (skipAll) { // skip all duplicates // continueDropping = true; return true; } if (!overwriteAll) { if (count < total) {// dialog for more items Object[] options = { Translation.getTranslation("general.overwrite"), Translation.getTranslation("general.overwrite_all"), Translation.getTranslation("general.skip"), Translation .getTranslation("directorypanel.dropfile_duplicate_dialog.skipall"), Translation.getTranslation("general.cancel")}; int option = JOptionPane .showOptionDialog( getUIController().getMainFrame() .getUIComponent(), Translation .getTranslation( "directorypanel.dropfile_duplicate_dialog.text", file.getName()), Translation .getTranslation("directorypanel.dropfile_duplicate_dialog.title"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[2]); switch (option) { case 0 : { // overwrite break; } case 1 : { // overwrite all overwriteAll = true; break; } case 2 : { // skip return true; } case 3 : { // skip all dupes skipAll = true; return true; } case 4 : { // cancel cancel = true; break; } } } else {// dialog for just one item Object[] options = { Translation.getTranslation("general.overwrite"), Translation.getTranslation("general.skip"), Translation.getTranslation("general.cancel")}; int option = JOptionPane .showOptionDialog( getUIController().getMainFrame() .getUIComponent(), Translation .getTranslation( "directorypanel.dropfile_duplicate_dialog.text", file.getName()), Translation .getTranslation("directorypanel.dropfile_duplicate_dialog.title"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[2]); switch (option) { case 0 : { // overwrite break; } case 1 : { // skip return true; } case 2 : { // cancel cancel = true; break; } } } } } if (cancel) { return true; } DirectoryPanel.this.directoryTable.getParent().setCursor( Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); if (!directory.copyFileFrom(file, getFileCopier())) { DirectoryPanel.this.directoryTable.getParent().setCursor( Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); // something failed return false; } DirectoryPanel.this.directoryTable.getParent().setCursor( Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); return true; }
1,121,043