if(event != null) { NSPoint dragPosition = view.convertPoint_fromView(event.locationInWindow(), null); NSRect imageRect = new NSRect(new NSPoint(dragPosition.x.doubleValue() - 16, dragPosition.y.doubleValue() - 16), new NSSize(32, 32)); view.dragPromisedFilesOfTypes(NSMutableArray.arrayWithObject(fileTypes.iterator().next()), imageRect, this.id(), true, event);
/** * Overlay badge image. * * @param badge Overlay * @param icon Icon * @return Cached icon */ @Override protected NSImage badge(final NSImage badge, final NSImage icon) { NSImage f = NSImage.imageWithSize(icon.size()); f.lockFocus(); icon.drawInRect(new NSRect(new NSPoint(0, 0), icon.size()), NSZeroRect, NSGraphics.NSCompositeSourceOver, 1.0f); badge.drawInRect(new NSRect(new NSPoint(0, 0), badge.size()), NSZeroRect, NSGraphics.NSCompositeSourceOver, 1.0f); f.unlockFocus(); return f; }
@Override public void loadBundle(final NSAlert alert) { this.inputField = NSTextField.textfieldWithFrame(new NSRect(alert.window().frame().size.width.doubleValue(), 22)); this.inputField.cell().setPlaceholderString(alert.informativeText()); super.loadBundle(alert); }
/** * @return Minimum size to fit content view of currently selected tab. */ private NSRect getContentRect() { NSRect contentRect = new NSRect(0, 0); final NSView view = tabView.selectedTabViewItem().view(); final NSEnumerator enumerator = view.subviews().objectEnumerator(); NSObject next; while(null != (next = enumerator.nextObject())) { final NSView subview = Rococoa.cast(next, NSView.class); contentRect = FoundationKitFunctionsLibrary.NSUnionRect(contentRect, subview.frame()); } return contentRect; } }
public NSView getAccessoryView(final NSAlert alert) { if(this.hasLocation()) { view = NSView.create(new NSRect(alert.window().frame().size.width.doubleValue(), 0)); regionPopup = NSPopUpButton.buttonWithFrame(new NSRect(alert.window().frame().size.width.doubleValue(), 26)); regions.stream().sorted(Comparator.comparing(Location.Name::toString)).forEach(region -> { regionPopup.addItemWithTitle(region.toString()); regionPopup.itemWithTitle(region.toString()).setRepresentedObject(region.getIdentifier()); if(region.getIdentifier().equals(PreferencesFactory.get().getProperty("s3.location"))) { regionPopup.selectItem(regionPopup.lastItem()); } }); // Override accessory view with location menu added regionPopup.setFrameOrigin(new NSPoint(0, 0)); view.addSubview(regionPopup); inputField.setFrameOrigin(new NSPoint(0, this.getFrame(alert, view).size.height.doubleValue() + view.subviews().count().doubleValue() * SUBVIEWS_VERTICAL_SPACE)); view.addSubview(inputField); return view; } return super.getAccessoryView(alert); }
public NSView getAccessoryView(final NSAlert alert) { view = NSView.create(new NSRect(alert.window().frame().size.width.doubleValue(), 0)); regionPopup = NSPopUpButton.buttonWithFrame(new NSRect(alert.window().frame().size.width.doubleValue(), 26)); regionPopup.setFrameOrigin(new NSPoint(0, 0)); for(Location.Name region : regions) { regionPopup.addItemWithTitle(region.toString()); regionPopup.itemWithTitle(region.toString()).setRepresentedObject(region.getIdentifier()); if(region.getIdentifier().equals(PreferencesFactory.get().getProperty("s3.location"))) { regionPopup.selectItem(regionPopup.lastItem()); } } // Override accessory view with location menu added view.addSubview(regionPopup); return view; }
public GotoController(final BrowserController parent, final Cache<Path> cache) { this.parent = parent; this.cache = cache; folderCombobox = NSComboBox.textfieldWithFrame(new NSRect(0, 26)); folderCombobox.setCompletes(true); folderCombobox.setUsesDataSource(true); folderComboboxModel = new FolderComboboxModel(parent.workdir()); folderCombobox.setDataSource(folderComboboxModel.id()); folderCombobox.setStringValue(parent.workdir().getAbsolute()); }
protected NSRect getFrame(final NSAlert alert, final NSView accessory) { final NSRect frame = new NSRect(alert.window().frame().size.width.doubleValue(), accessory.frame().size.height.doubleValue()); final NSEnumerator enumerator = accessory.subviews().objectEnumerator(); NSObject next; while(null != (next = enumerator.nextObject())) { final NSView subview = Rococoa.cast(next, NSView.class); frame.size.height = new CGFloat(frame.size.height.doubleValue() + subview.frame().size.height.doubleValue() + SUBVIEWS_VERTICAL_SPACE * 2); } return frame; }
@Override public NSView getAccessoryView(final NSAlert alert) { view = NSView.create(new NSRect(alert.window().frame().size.width.doubleValue(), 0)); if(options.keychain) { keychainCheckbox = NSButton.buttonWithFrame(new NSRect(alert.window().frame().size.width.doubleValue(), 18)); keychainCheckbox.setTitle(LocaleFactory.localizedString("Save Password", "Keychain")); keychainCheckbox.setAction(Foundation.selector("keychainCheckboxClicked:")); keychainCheckbox.setTarget(this.id()); keychainCheckbox.setButtonType(NSButton.NSSwitchButton); keychainCheckbox.setState(options.save ? NSCell.NSOnState : NSCell.NSOffState); keychainCheckbox.sizeToFit(); // Override accessory view with location menu added keychainCheckbox.setFrameOrigin(new NSPoint(0, this.getFrame(alert, view).size.height.doubleValue())); view.addSubview(keychainCheckbox); } inputField = NSSecureTextField.textfieldWithFrame(new NSRect(alert.window().frame().size.width.doubleValue(), 22)); inputField.cell().setPlaceholderString(options.getPasswordPlaceholder()); inputField.setFrameOrigin(new NSPoint(0, this.getFrame(alert, view).size.height.doubleValue() + view.subviews().count().doubleValue() * SUBVIEWS_VERTICAL_SPACE)); view.addSubview(inputField); return view; }
/** * Resize window frame to fit the content view of the currently selected tab. */ private void resize() { final NSRect windowFrame = NSWindow.contentRectForFrameRect_styleMask(window.frame(), window.styleMask()); final double height = this.getMinWindowHeight(); final NSRect frameRect = new NSRect( new NSPoint(windowFrame.origin.x.doubleValue(), windowFrame.origin.y.doubleValue() + windowFrame.size.height.doubleValue() - height), new NSSize(windowFrame.size.width.doubleValue(), height) ); window.setFrame_display_animate(NSWindow.frameRectForContentRect_styleMask(frameRect, window.styleMask()), true, window.isVisible()); }
return false; final NSPopUpButton bookmarksPopup = NSPopUpButton.buttonWithFrame(new NSRect(0, 26)); bookmarksPopup.setToolTip(LocaleFactory.localizedString("Bookmarks", "Browser")); for(Host b : bookmarks) {
public NSView getAccessoryView(final NSAlert alert) { view = NSView.create(new NSRect(alert.window().frame().size.width.doubleValue(), 0)); confirmField = NSSecureTextField.textfieldWithFrame(new NSRect(alert.window().frame().size.width.doubleValue(), 22)); confirmField.cell().setPlaceholderString(LocaleFactory.localizedString("Confirm Passphrase", "Cryptomator")); confirmField.setFrameOrigin(new NSPoint(0, 0)); view.addSubview(confirmField); strengthIndicator = NSLevelIndicator.levelIndicatorWithFrame(new NSRect(alert.window().frame().size.width.doubleValue(), 18)); if(strengthIndicator.respondsToSelector(Foundation.selector("setLevelIndicatorStyle:"))) { strengthIndicator.setLevelIndicatorStyle(NSLevelIndicator.NSDiscreteCapacityLevelIndicatorStyle); } strengthIndicator.setFrameOrigin(new NSPoint(0, this.getFrame(alert, view).size.height.doubleValue() + view.subviews().count().doubleValue() * SUBVIEWS_VERTICAL_SPACE)); view.addSubview(strengthIndicator); passwordField = NSSecureTextField.textfieldWithFrame(new NSRect(alert.window().frame().size.width.doubleValue(), 22)); passwordField.cell().setPlaceholderString(LocaleFactory.localizedString("Passphrase", "Cryptomator")); notificationCenter.addObserver(this.id(), Foundation.selector("passwordFieldTextDidChange:"), NSControl.NSControlTextDidChangeNotification, passwordField.id()); passwordField.setFrameOrigin(new NSPoint(0, this.getFrame(alert, view).size.height.doubleValue() + view.subviews().count().doubleValue() * SUBVIEWS_VERTICAL_SPACE)); view.addSubview(passwordField); final NSView accessory = super.getAccessoryView(alert); accessory.setFrameSize(this.getFrame(alert, accessory).size); accessory.setFrameOrigin(new NSPoint(0, this.getFrame(alert, view).size.height.doubleValue() + view.subviews().count().doubleValue() * SUBVIEWS_VERTICAL_SPACE)); view.addSubview(accessory); return view; }
/** * @param rowIndexes is the list of row numbers that will be participating in the drag. * @return To refuse the drag, return false. To start a drag, return true and place * the drag data onto pboard (data, owner, and so on). * @see NSTableView.DataSource * Invoked by view after it has been determined that a drag should begin, but before the drag has been started. * The drag image and other drag-related information will be set up and provided by the table view once this call * returns with true. */ @Override public boolean tableView_writeRowsWithIndexes_toPasteboard(final NSTableView view, final NSIndexSet rowIndexes, final NSPasteboard pboard) { for(NSUInteger index = rowIndexes.firstIndex(); !index.equals(NSIndexSet.NSNotFound); index = rowIndexes.indexGreaterThanIndex(index)) { pasteboard.add(this.getSource().get(index.intValue())); } NSEvent event = NSApplication.sharedApplication().currentEvent(); if(event != null) { NSPoint dragPosition = view.convertPoint_fromView(event.locationInWindow(), null); NSRect imageRect = new NSRect(new NSPoint(dragPosition.x.doubleValue() - 16, dragPosition.y.doubleValue() - 16), new NSSize(32, 32)); // Writing a promised file of the host as a bookmark file to the clipboard view.dragPromisedFilesOfTypes(NSArray.arrayWithObject("duck"), imageRect, this.id(), true, event); return true; } return false; }
final NSPopUpButton button = NSPopUpButton.buttonWithFrame(new NSRect(52, 26)); button.setImage(bandwidth.image()); button.setMenu(bandwidthMenu); final NSPopUpButton button = NSPopUpButton.buttonWithFrame(new NSRect(52, 26)); button.setImage(connections.image()); button.setMenu(connectionsMenu); item.setTarget(controller.id()); item.setAction(type.action()); final NSButton button = NSButton.buttonWithFrame(new NSRect(0, 0)); button.setBezelStyle(NSButtonCell.NSTexturedRoundedBezelStyle); button.setImage(type.image());
@Action public void uploadButtonClicked(final ID sender) { uploadPanel = NSOpenPanel.openPanel(); uploadPanel.setCanChooseDirectories(true); uploadPanel.setCanChooseFiles(pool.getFeature(Touch.class).isSupported( new UploadTargetFinder(workdir).find(this.getSelectedPath()) )); uploadPanel.setCanCreateDirectories(false); uploadPanel.setTreatsFilePackagesAsDirectories(true); uploadPanel.setAllowsMultipleSelection(true); uploadPanel.setPrompt(LocaleFactory.localizedString("Upload", "Transfer")); if(uploadPanel.respondsToSelector(Foundation.selector("setShowsHiddenFiles:"))) { uploadPanelHiddenFilesCheckbox = NSButton.buttonWithFrame(new NSRect(0, 0)); uploadPanelHiddenFilesCheckbox.setTitle(LocaleFactory.localizedString("Show Hidden Files")); uploadPanelHiddenFilesCheckbox.setTarget(this.id()); uploadPanelHiddenFilesCheckbox.setAction(Foundation.selector("uploadPanelSetShowHiddenFiles:")); uploadPanelHiddenFilesCheckbox.setButtonType(NSButton.NSSwitchButton); uploadPanelHiddenFilesCheckbox.setState(NSCell.NSOffState); uploadPanelHiddenFilesCheckbox.sizeToFit(); uploadPanel.setAccessoryView(uploadPanelHiddenFilesCheckbox); } uploadPanel.beginSheetForDirectory(new UploadDirectoryFinder().find(pool.getHost()).getAbsolute(), null, this.window, this.id(), Foundation.selector("uploadPanelDidEnd:returnCode:contextInfo:"), null); }
item.setPaletteLabel(quickconnect.label()); item.setToolTip(quickconnect.tooltip()); final NSComboBox button = NSComboBox.textfieldWithFrame(new NSRect(170, 26)); button.setTarget(controller.id()); button.setAction(quickconnect.action()); final NSPopUpButton button = NSPopUpButton.buttonWithFrame(new NSRect(120, 26)); button.setImage(encoding.image()); button.setMenu(charsetMenu); editMenu.setDelegate(controller.getEditMenuDelegate().id()); toolbarMenu.setSubmenu(editMenu); final NSButton button = NSButton.buttonWithFrame(new NSRect(0, 0)); button.setBezelStyle(NSButtonCell.NSTexturedRoundedBezelStyle); button.setImage(edit.image()); item.setTarget(controller.id()); item.setAction(terminal.action()); final NSButton button = NSButton.buttonWithFrame(new NSRect(0, 0)); button.setBezelStyle(NSButtonCell.NSTexturedRoundedBezelStyle); button.setImage(terminal.image()); item.setLabel(BrowserToolbarItem.quicklook.label()); item.setPaletteLabel(BrowserToolbarItem.quicklook.label()); final NSButton button = NSButton.buttonWithFrame(new NSRect(0, 0)); button.setBezelStyle(NSButtonCell.NSTexturedRoundedBezelStyle); button.setImage(BrowserToolbarItem.quicklook.image()); item.setToolTip(type.tooltip());