Java Code Examples for org.eclipse.jface.dialogs.IDialogConstants#OK_ID

The following examples show how to use org.eclipse.jface.dialogs.IDialogConstants#OK_ID . 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: GroupOutlineEditPart.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void performRequest(final Request request) {
    final ColumnGroup columnGroup = (ColumnGroup) getModel();
    final ERDiagram diagram = getDiagram();

    final GroupSet groupSet = diagram.getDiagramContents().getGroups();

    if (request.getType().equals(RequestConstants.REQ_OPEN)) {
        final GroupDialog dialog = new GroupDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), groupSet, diagram, groupSet.indexOf(columnGroup));

        if (dialog.open() == IDialogConstants.OK_ID) {
            final List<CopyGroup> newColumnGroups = dialog.getCopyColumnGroups();

            final Command command = new ChangeGroupCommand(diagram, groupSet, newColumnGroups);

            execute(command);
        }
    }

    super.performRequest(request);
}
 
Example 2
Source File: TableOutlineEditPart.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void performRequest(Request request) {
	ERTable table = (ERTable) this.getModel();
	ERDiagram diagram = (ERDiagram) this.getRoot().getContents().getModel();

	if (request.getType().equals(RequestConstants.REQ_OPEN)) {
		ERTable copyTable = table.copyData();

		TableDialog dialog = new TableDialog(PlatformUI.getWorkbench()
				.getActiveWorkbenchWindow().getShell(), this.getViewer(),
				copyTable, diagram.getDiagramContents().getGroups());

		if (dialog.open() == IDialogConstants.OK_ID) {
			CompoundCommand command = ERTableEditPart
					.createChangeTablePropertyCommand(diagram, table,
							copyTable);

			this.execute(command.unwrap());
		}
	}

	super.performRequest(request);
}
 
Example 3
Source File: ConfigureWorkingSetAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void run() {
	List<IWorkingSet> workingSets= new ArrayList<IWorkingSet>(Arrays.asList(fWorkingSetModel.getAllWorkingSets()));
	IWorkingSet[] activeWorkingSets;
	if (fWorkingSetModel.needsConfiguration()) {
		activeWorkingSets= fWorkingSetModel.getAllWorkingSets();
	} else {
		activeWorkingSets= fWorkingSetModel.getActiveWorkingSets();
	}
	boolean isSortingEnabled= fWorkingSetModel.isSortingEnabled();
	WorkingSetConfigurationDialog dialog= new WorkingSetConfigurationDialog(fSite.getShell(), workingSets.toArray(new IWorkingSet[workingSets.size()]), isSortingEnabled);
	dialog.setSelection(activeWorkingSets);
	if (dialog.open() == IDialogConstants.OK_ID) {
		isSortingEnabled= dialog.isSortingEnabled();
		fWorkingSetModel.setWorkingSets(dialog.getAllWorkingSets(), isSortingEnabled, dialog.getSelection());
	}
}
 
Example 4
Source File: XmlConvertManagerDialog.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 编辑选中的元素 ;
 */
protected void editElement() {
	ISelection selection = tableViewer.getSelection();
	if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
		IStructuredSelection structuredSelection = (IStructuredSelection) selection;
		@SuppressWarnings("unchecked")
		Iterator<ElementBean> iter = structuredSelection.iterator();
		ElementBean bean = iter.next();

		AddOrEditElementOfXmlConvertDialog dialog = new AddOrEditElementOfXmlConvertDialog(getShell(), false,
				elementsList);
		dialog.create();
		dialog.setInitEditData(bean);
		int result = dialog.open();
		if (result == IDialogConstants.OK_ID) {
			refreshTable(dialog.getCurrentElement());
		}
	} else {
		MessageDialog.openInformation(getShell(), Messages.getString("dialogs.XmlConvertManagerDialog.msgTitle2"),
				Messages.getString("dialogs.XmlConvertManagerDialog.msg3"));
	}
}
 
Example 5
Source File: PluginConfigurationDialog.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
public void editPuginConfig() {
	ISelection selection = tableViewer.getSelection();
	if (selection != null && !selection.isEmpty() && selection instanceof StructuredSelection) {
		StructuredSelection structuredSelection = (StructuredSelection) selection;
		Iterator<PluginConfigBean> it = structuredSelection.iterator();
		if (it.hasNext()) {
			PluginConfigBean configBean = it.next();
			PluginConfigManageDialog dialog = new PluginConfigManageDialog(getShell(), false);
			dialog.create();
			dialog.setEditInitData(configBean);
			int result = dialog.open();
			if (result == IDialogConstants.OK_ID) {
				refreshTable(dialog.getCurPluginBean());
			}
		}
	} else {
		MessageDialog.openInformation(getShell(), Messages.getString("dialog.PluginConfigurationDialog.msgTitle"),
				Messages.getString("dialog.PluginConfigurationDialog.msg1"));
	}
}
 
Example 6
Source File: IndexOutlineEditPart.java    From erflute with Apache License 2.0 6 votes vote down vote up
@Override
public void performRequest(Request request) {
    final ERIndex index = (ERIndex) getModel();
    final ERDiagram diagram = getDiagram();

    if (request.getType().equals(RequestConstants.REQ_OPEN)) {
        final IndexDialog dialog = new IndexDialog(
                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), index, index.getTable());

        if (dialog.open() == IDialogConstants.OK_ID) {
            final ChangeIndexCommand command = new ChangeIndexCommand(diagram, index, dialog.getResultIndex());
            execute(command);
        }
    }

    super.performRequest(request);
}
 
Example 7
Source File: TableOutlineEditPart.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void performRequest(final Request request) {
    final ERTable table = (ERTable) getModel();
    final ERDiagram diagram = (ERDiagram) getRoot().getContents().getModel();

    if (request.getType().equals(RequestConstants.REQ_OPEN)) {
        final ERTable copyTable = table.copyData();

        final TableDialog dialog = new TableDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), getViewer(), copyTable);

        if (dialog.open() == IDialogConstants.OK_ID) {
            final CompoundCommand command = ERTableEditPart.createChangeTablePropertyCommand(diagram, table, copyTable);

            execute(command.unwrap());
        }
    }

    super.performRequest(request);
}
 
Example 8
Source File: SrxLanguageRulesManageDialog.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
public void editLangRule() {
	ISelection selection = tableViewer.getSelection();
	if (!selection.isEmpty() && selection != null && selection instanceof StructuredSelection) {
		StructuredSelection structSelection = (StructuredSelection) selection;
		@SuppressWarnings("unchecked")
		Iterator<LanguageRuleBean> it = structSelection.iterator();
		// 只修改选中规则中的一个
		if (it.hasNext()) {
			LanguageRuleBean selectBean = it.next();
			AddOrEditLangRuleOfSrxDialog editDialog = new AddOrEditLangRuleOfSrxDialog(getShell(), false,
					langRulesList);
			editDialog.create();
			editDialog.setEditInitData(selectBean);
			int editResult = editDialog.open();
			if (editResult == IDialogConstants.OK_ID) {
				refreshTable(editDialog.getCurLangRuleBean());
			}
		}
	} else {
		MessageDialog.openInformation(getShell(), Messages.getString("srx.SrxLanguageRulesManageDialog.msgTitle"),
				Messages.getString("srx.SrxLanguageRulesManageDialog.msg7"));
	}
}
 
Example 9
Source File: EditCubeDimensionAction.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected boolean doAction( ) throws Exception
{
	if ( Policy.TRACING_ACTIONS )
	{
		System.out.println( "Edit Dimension action >> Runs ..." ); //$NON-NLS-1$
	}
	DimensionHandle dimension = (DimensionHandle) getSelection( );
	CubeBuilder dialog = new CubeBuilder( PlatformUI.getWorkbench( )
			.getDisplay( )
			.getActiveShell( ), (TabularCubeHandle) dimension.getContainer( ) );

	dialog.showPage( CubeBuilder.GROUPPAGE );

	return ( dialog.open( ) == IDialogConstants.OK_ID );
}
 
Example 10
Source File: GetActiveKeyDialog.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void okPressed() {
	Point p = getShell().getLocation();
	super.okPressed();
	SelectGrantFileDialog dialog = new SelectGrantFileDialog(getShell(), p);
	int result = dialog.open();
	if (result != IDialogConstants.OK_ID) {
		System.exit(0);
	}
}
 
Example 11
Source File: CreateParamDialog.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void buttonPressed(int buttonId) {
	setErrorMessage(null);
	if (buttonId == IDialogConstants.OK_ID) {
		if ("".equals(this.paramNameText.getText())) { //$NON-NLS-1$
			setErrorMessage("param\u540D\u4E0D\u80FD\u4E3A\u7A7A"); //$NON-NLS-1$
			return;
		}
		if ("".equals(this.paramValueText.getText())) { //$NON-NLS-1$
			setErrorMessage("param\u503C\u4E0D\u80FD\u4E3A\u7A7A"); //$NON-NLS-1$
			return;
		}
		StructuredSelection ss = (StructuredSelection)list.getSelection();
		Feature feature = (Feature)ss.getFirstElement();
		
		for(Param param : feature.getParams()) {
			if(param.getName().equals(this.paramNameText.getText())) {
				setErrorMessage(Messages.PARAMNAMEREPEAT); //$NON-NLS-1$
				return;
			}
		}
		Param p = new Param();
		p.setName(this.paramNameText.getText());
		p.setValue(this.paramValueText.getText());
		
		feature.addParams(p);
		TreeNode node = new TreeNode(p);
		node.setParent(new TreeNode(feature));
		treeViewer.setInput(config.createTreeNode());
		treeViewer.collapseAll();
		StructuredSelection selection = new StructuredSelection(node);
		treeViewer.setSelection(selection, true);
		treeViewer.refresh();
		editor.setDirty(true);
		editor.change();
	} 
	super.buttonPressed(buttonId);
}
 
Example 12
Source File: EditDataSourceAction.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected boolean doAction( ) throws Exception
{
	if ( Policy.TRACING_ACTIONS )
	{
		System.out.println( "Edit data source action >> Runs ..." ); //$NON-NLS-1$
	}
	DataSourceHandle handle = (DataSourceHandle) getSelection( );
	DataSourceEditor dialog = new AdvancedDataSourceEditor( PlatformUI
			.getWorkbench( ).getDisplay( ).getActiveShell( ), handle );

	return ( dialog.open( ) == IDialogConstants.OK_ID );
}
 
Example 13
Source File: ExportWarningDialog.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void buttonPressed(final int buttonId) {
    if (buttonId == IDialogConstants.CLOSE_ID || buttonId == IDialogConstants.CANCEL_ID) {
        setReturnCode(buttonId);
        close();

    } else if (buttonId == IDialogConstants.OK_ID) {
        setReturnCode(buttonId);
        close();
    }

    super.buttonPressed(buttonId);
}
 
Example 14
Source File: ViewEditPart.java    From erflute with Apache License 2.0 5 votes vote down vote up
@Override
public void performRequestOpen() {
    final ERView view = (ERView) getModel();
    final ERDiagram diagram = getDiagram();
    final ERView copyView = view.copyData();
    final ViewDialog dialog = new ViewDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
            getViewer(), copyView, diagram.getDiagramContents().getColumnGroupSet());

    if (dialog.open() == IDialogConstants.OK_ID) {
        final CompoundCommand command = createChangeViewPropertyCommand(diagram, view, copyView);
        executeCommand(command.unwrap());
    }
}
 
Example 15
Source File: TestDataManageDialog.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
private void addTestData() {
    final TestData oldTestData = new TestData();

    final TestDataDialog testDataDialog = new TestDataDialog(getShell(), diagram, oldTestData);

    if (testDataDialog.open() == IDialogConstants.OK_ID) {
        final TestData newTestData = testDataDialog.getTestData();

        testDataList.add(newTestData);

        initTestDataList();

        for (int i = 0; i < testDataList.size(); i++) {
            final TestData testData = testDataList.get(i);

            if (testData == newTestData) {
                testDataListWidget.setSelection(i);
                break;
            }
        }

        editButton.setEnabled(true);
        deleteButton.setEnabled(true);
        copyButton.setEnabled(true);

        initTableData();
    }
}
 
Example 16
Source File: XmlConverterConfigurationDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 编辑转换配置XML文件 ;
 */
public void editConfigXml() {
	ISelection selection = tableViewer.getSelection();
	if (!selection.isEmpty() && selection != null && selection instanceof IStructuredSelection) {
		IStructuredSelection structuredSelection = (IStructuredSelection) selection;
		@SuppressWarnings("unchecked")
		Iterator<String[]> iter = structuredSelection.iterator();
		String convertXml = iter.next()[1];

		AddOrEditXmlConvertConfigDialog dialog = new AddOrEditXmlConvertConfigDialog(getShell(), false);
		dialog.create();
		String convertXmlLoaction = root.getLocation().append(ADConstants.AD_xmlConverterConfigFolder)
				.append(convertXml).toOSString();
		if (dialog.setInitEditData(convertXmlLoaction)) {
			int result = dialog.open();
			// 如果点击的是确定按钮,那么更新列表
			if (result == IDialogConstants.OK_ID) {
				String curentConvertXMl = dialog.getCurentConverXML();
				refreshTable();
				setTableSelection(curentConvertXMl);
			}
		}
	} else {
		MessageDialog.openInformation(getShell(),
				Messages.getString("dialogs.XmlConverterConfigurationDialog.msgTitle"),
				Messages.getString("dialogs.XmlConverterConfigurationDialog.msg2"));
	}
}
 
Example 17
Source File: ColumnMappingDialog.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void buttonPressed( int buttonId )
{
	output = null;
	if ( buttonId == IDialogConstants.OK_ID )
	{
		IMappingSource[] sources = null;
		try
		{
			if ( this.containsParam )
			{
				sources = input.getMappingPath( );
			}
			else
				sources = Utils.getMappingSource( txtMappingPath.getText( )
						.trim( ) );
		}
		catch ( OdaException e )
		{
			ExceptionHandler.showException( getShell( ),
					e.getLocalizedMessage( ),
					e.getLocalizedMessage( ),
					e );
			txtMappingPath.selectAll( );
			txtMappingPath.setFocus( );
			return;
		}
		output = new ColumnDefinition( sources,
				txtName.getText( ).trim( ),
				getSelectedType( ) );
	}
	super.buttonPressed( buttonId );
}
 
Example 18
Source File: ConfigureRepositoriesDialog.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void run() {
	AddRepositoryDialog dialog = new AddRepositoryDialog();
	if (dialog.open() != IDialogConstants.OK_ID)
		return;
	dialog.saveConfig();
	viewer.setInput(RepositoryConfig.loadAll(Database.get()));
}
 
Example 19
Source File: CreateRelationByExistingColumnsCommand.java    From ermaster-b with Apache License 2.0 4 votes vote down vote up
public boolean selectColumns() {
	if (this.target == null) {
		return false;
	}

	ERTable sourceTable = (ERTable) this.source.getModel();
	TableView targetTable = (TableView) this.target.getModel();

	Map<NormalColumn, List<NormalColumn>> referencedMap = new HashMap<NormalColumn, List<NormalColumn>>();
	Map<Relation, Set<NormalColumn>> foreignKeySetMap = new HashMap<Relation, Set<NormalColumn>>();

	for (NormalColumn normalColumn : targetTable.getNormalColumns()) {
		NormalColumn rootReferencedColumn = normalColumn.getRootReferencedColumn();
		if (rootReferencedColumn != null) {
			List<NormalColumn> foreignKeyList = referencedMap
					.get(rootReferencedColumn);

			if (foreignKeyList == null) {
				foreignKeyList = new ArrayList<NormalColumn>();
				referencedMap.put(rootReferencedColumn, foreignKeyList);
			}

			foreignKeyList.add(normalColumn);

			for (Relation relation : normalColumn.getRelationList()) {
				Set<NormalColumn> foreignKeySet = foreignKeySetMap
						.get(relation);
				if (foreignKeySet == null) {
					foreignKeySet = new HashSet<NormalColumn>();
					foreignKeySetMap.put(relation, foreignKeySet);
				}

				foreignKeySet.add(normalColumn);
			}
		}
	}

	List<NormalColumn> candidateForeignKeyColumns = new ArrayList<NormalColumn>();

	for (NormalColumn column : targetTable.getNormalColumns()) {
		if (!column.isForeignKey()) {
			candidateForeignKeyColumns.add(column);
		}
	}

	if (candidateForeignKeyColumns.isEmpty()) {
		Activator
				.showErrorDialog("error.no.candidate.of.foreign.key.exist");
		return false;
	}

	RelationByExistingColumnsDialog dialog = new RelationByExistingColumnsDialog(
			PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
			sourceTable, candidateForeignKeyColumns, referencedMap,
			foreignKeySetMap);

	if (dialog.open() == IDialogConstants.OK_ID) {
		this.relation = new Relation(dialog.isReferenceForPK(), dialog
				.getReferencedComplexUniqueKey(), dialog
				.getReferencedColumn());
		final String defaultName = prepareDefaultFKConstraintName(sourceTable, targetTable);
		if (defaultName != null) {
			this.relation.setName(defaultName);
		}
		this.referencedColumnList = dialog.getReferencedColumnList();
		this.foreignKeyColumnList = dialog.getForeignKeyColumnList();

	} else {
		return false;
	}

	return true;
}
 
Example 20
Source File: BaseTitleAreaDialog.java    From birt with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * Creates a new button with the given id. Override this method to support
 * custom label for OK button
 * 
 * 
 * @param parent
 *            the parent composite
 * @param id
 *            the id of the button (see <code>IDialogConstants.*_ID</code>
 *            constants for standard dialog button ids)
 * @param label
 *            the label from the button
 * @param defaultButton
 *            <code>true</code> if the button is to be the default button,
 *            and <code>false</code> otherwise
 * 
 * @return the new button
 * 
 * @see #getCancelButton
 * @see #getOKButton()
 */
protected Button createButton( Composite parent, int id, String label,
		boolean defaultButton )
{
	if ( IDialogConstants.OK_ID == id && okLabel != null )
	{
		return super.createButton( parent, id, okLabel, defaultButton );
	}
	return super.createButton( parent, id, label, defaultButton );
}