org.eclipse.ui.internal.ide.misc.ResourceAndContainerGroup Java Examples

The following examples show how to use org.eclipse.ui.internal.ide.misc.ResourceAndContainerGroup. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SaveAsDialog2.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Get the "resourceGroup" field for the specified dialog. This is a silly hack to workaround
 * org.eclipse.ui.dialogs.SaveAsDialog's resourceGroup field and class not being public or protected, or otherwise
 * supporting methods to manipulate the UI programatically.
 */
protected static synchronized ResourceAndContainerGroup getResourceGroup(final SaveAsDialog2 d) {
	boolean origAccessible = false;
	try {
		// cache it to avoid unneccessary reflection look ups
		if (resourceGroupField == null) {
			resourceGroupField = org.eclipse.ui.dialogs.SaveAsDialog.class.getDeclaredField("resourceGroup"); //$NON-NLS-1$
		}

		// make it accessible, since it's normally private
		origAccessible = resourceGroupField.isAccessible();
		try {
			resourceGroupField.setAccessible(true);
			return (ResourceAndContainerGroup) resourceGroupField.get(d);
		} finally {
			resourceGroupField.setAccessible(origAccessible);
		}
	} catch (final Exception ex) {
		return null;
	}
}
 
Example #2
Source File: InternalFileDialog.java    From erflute with Apache License 2.0 6 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
    final Composite topLevel = new Composite(parent, SWT.NONE);
    topLevel.setLayout(new GridLayout());
    topLevel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL));
    topLevel.setFont(parent.getFont());
    resourceGroup = new ResourceAndContainerGroup(topLevel, this, "File name:",
            IDEWorkbenchMessages.WizardNewFileCreationPage_file, false, 250);
    resourceGroup.setResourceExtension(fileExtension);
    resourceGroup.setContainerFullPath(new Path(initialFolder).removeLastSegments(1));
    if (new Path(initialFolder).lastSegment() != null) {
        resourceGroup.setResource(new Path(initialFolder).lastSegment());
        resourceGroup.setFocus();
    }
    setTitle("File");
    return super.createDialogArea(parent);
}
 
Example #3
Source File: InternalDirectoryDialog.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
@Override
	protected Control createDialogArea(Composite parent) {

		Composite topLevel = new Composite(parent, SWT.NONE);
		topLevel.setLayout(new GridLayout());
		topLevel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL
				| GridData.HORIZONTAL_ALIGN_FILL));
		topLevel.setFont(parent.getFont());

		resourceGroup = new ResourceAndContainerGroup(topLevel, this,
				"Directory name:",
				"folder", false,
				250);
		resourceGroup.setContainerFullPath(new Path(initialFolder));

//		if (new Path(initialFolder).lastSegment() != null) {
//			resourceGroup.setResource(new Path(initialFolder).lastSegment());
//		}

		setTitle("Directory");

		return super.createDialogArea(parent);
	}
 
Example #4
Source File: SaveAsDialog2.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the current file name as entered by the user, or its anticipated initial value.
 *
 * @return the file name, its anticipated initial value, or <code>null</code> if no file name is known
 */
public String getFileName() {
	final ResourceAndContainerGroup resourceGroup = getResourceGroup(this);
	if (resourceGroup != null) { return resourceGroup.getResource(); }

	return ""; //$NON-NLS-1$
}
 
Example #5
Source File: SaveAsDialog2.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Set the filename of the dialog.
 */
public void setFileName(final String filename) {
	final ResourceAndContainerGroup resourceGroup = getResourceGroup(this);
	if (resourceGroup != null) {
		resourceGroup.setResource(filename);
	} else {
		setOriginalName(filename);
	}
}
 
Example #6
Source File: InternalDirectoryDialog.java    From erflute with Apache License 2.0 5 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
    final Composite topLevel = new Composite(parent, SWT.NONE);
    topLevel.setLayout(new GridLayout());
    topLevel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL));
    topLevel.setFont(parent.getFont());

    resourceGroup = new ResourceAndContainerGroup(topLevel, this, "Directory name:", "folder", false, 250);
    resourceGroup.setContainerFullPath(new Path(initialFolder));

    setTitle("Directory");

    return super.createDialogArea(parent);
}
 
Example #7
Source File: InternalFileDialog.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
@Override
	protected Control createDialogArea(Composite parent) {

		Composite topLevel = new Composite(parent, SWT.NONE);
		topLevel.setLayout(new GridLayout());
		topLevel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL
				| GridData.HORIZONTAL_ALIGN_FILL));
		topLevel.setFont(parent.getFont());

		resourceGroup = new ResourceAndContainerGroup(topLevel, this,
				"File name:",
				IDEWorkbenchMessages.WizardNewFileCreationPage_file, false,
				250);
		resourceGroup.setResourceExtension(fileExtension);
		resourceGroup.setContainerFullPath(new Path(initialFolder).removeLastSegments(1));

		if (new Path(initialFolder).lastSegment() != null) {
			resourceGroup.setResource(new Path(initialFolder).lastSegment());
			resourceGroup.setFocus();
		}

		setTitle("File");

//		Text text = new Text(parent, SWT.NONE);
//		text.setText("abc");
		// TODO Auto-generated method stub
		return super.createDialogArea(parent);
	}