Author: rob.stryker(a)jboss.com
Date: 2012-02-08 12:46:07 -0500 (Wed, 08 Feb 2012)
New Revision: 38516
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ModuleRestartSection.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerWorkingCopyPropertyButtonCommand.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IDeployableServer.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServer.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerPasswordSection.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerWorkingCopyPropertyCommand.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
Log:
JBIDE-10464 - additions for UI
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IDeployableServer.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IDeployableServer.java 2012-02-08
16:55:29 UTC (rev 38515)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IDeployableServer.java 2012-02-08
17:46:07 UTC (rev 38516)
@@ -27,7 +27,8 @@
public static final String DEPLOY_DIRECTORY_TYPE =
"org.jboss.ide.eclipse.as.core.server.deployDirectoryType"; //$NON-NLS-1$
public static final String ZIP_DEPLOYMENTS_PREF =
"org.jboss.ide.eclipse.as.core.server.zipDeploymentsPreference"; //$NON-NLS-1$
public static final String ORG_JBOSS_TOOLS_AS_RESTART_FILE_PATTERN =
"org.jboss.tools.as.restartFilePattern"; //$NON-NLS-1$
-
+ public static final String ORG_JBOSS_TOOLS_AS_RESTART_DEFAULT_FILE_PATTERN =
"\\.jar$"; //$NON-NLS-1$
+
public static final String DEPLOY_METADATA = "metadata"; //$NON-NLS-1$
public static final String DEPLOY_CUSTOM = "custom"; //$NON-NLS-1$
public static final String DEPLOY_SERVER = "server"; //$NON-NLS-1$
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServer.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServer.java 2012-02-08
16:55:29 UTC (rev 38515)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServer.java 2012-02-08
17:46:07 UTC (rev 38516)
@@ -117,9 +117,17 @@
return getAttribute(ZIP_DEPLOYMENTS_PREF, false);
}
- // kept static to avoid overhead of pattern compilation
- final private static Pattern defaultFilePattern = Pattern.compile("\\.jar$",
Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
+ // cannot be static, as different servers may have different defaults
private Pattern restartFilePattern = null;
+ protected Pattern defaultFilePattern = Pattern.compile(
+ getDefaultModuleRestartPattern(),
+ Pattern.CASE_INSENSITIVE);
+
+ /* Needs to be public so UI can access this */
+ public String getDefaultModuleRestartPattern() {
+ return IDeployableServer.ORG_JBOSS_TOOLS_AS_RESTART_DEFAULT_FILE_PATTERN;
+ }
+
public void setRestartFilePattern(String filepattern) {
setAttribute(ORG_JBOSS_TOOLS_AS_RESTART_FILE_PATTERN, filepattern);
this.restartFilePattern = null;
@@ -127,20 +135,25 @@
public Pattern getRestartFilePattern() {
if( this.restartFilePattern == null ) {
- // ensure it's set properly from the saved attribute
- String currentPattern = getAttribute(ORG_JBOSS_TOOLS_AS_RESTART_FILE_PATTERN,
(String)null);
- try {
- this.restartFilePattern = currentPattern == null ? defaultFilePattern :
- Pattern.compile(currentPattern, Pattern.CASE_INSENSITIVE);
- } catch(PatternSyntaxException pse) {
- JBossServerCorePlugin.log("Could not set restart file pattern to: " +
currentPattern, pse); //$NON-NLS-1$
- // avoid errors over and over
- this.restartFilePattern = defaultFilePattern;
- }
+ compileRestartPattern();
}
return this.restartFilePattern;
}
+ private void compileRestartPattern() {
+ // ensure it's set properly from the saved attribute
+ String currentPattern = getAttribute(ORG_JBOSS_TOOLS_AS_RESTART_FILE_PATTERN,
(String)null);
+ try {
+ this.restartFilePattern = currentPattern == null ? defaultFilePattern :
+ Pattern.compile(currentPattern, Pattern.CASE_INSENSITIVE);
+ } catch(PatternSyntaxException pse) {
+ JBossServerCorePlugin.log("Could not set restart file pattern to: " +
currentPattern, pse); //$NON-NLS-1$
+ // avoid errors over and over
+ this.restartFilePattern = defaultFilePattern;
+ }
+ }
+
+
/*
* (non-Javadoc)
* @see
org.jboss.ide.eclipse.as.core.server.attributes.IDeployableServer#getAttributeHelper()
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ModuleRestartSection.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ModuleRestartSection.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ModuleRestartSection.java 2012-02-08
17:46:07 UTC (rev 38516)
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.ui.editor;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.eclipse.wst.server.ui.editor.ServerEditorSection;
+import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+import org.jboss.ide.eclipse.as.core.server.internal.DeployableServer;
+import org.jboss.ide.eclipse.as.core.server.internal.ServerAttributeHelper;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+import org.jboss.ide.eclipse.as.ui.Messages;
+import org.jboss.ide.eclipse.as.ui.UIUtil;
+
+public class ModuleRestartSection extends ServerEditorSection {
+
+ public ModuleRestartSection() {
+ }
+ private Button customizePattern;
+ private Text restartPatternText;
+ private SelectionListener checkboxListener;
+ private ModifyListener textListener;
+ protected ServerAttributeHelper helper;
+
+ public void init(IEditorSite site, IEditorInput input) {
+ super.init(site, input);
+ helper = new ServerAttributeHelper(server.getOriginal(), server);
+ }
+
+ public void createSection(Composite parent) {
+ super.createSection(parent);
+ createUI(parent);
+ addListeners();
+ DeployableServer ds =
(DeployableServer)ServerConverter.getDeployableServer(server.getOriginal());
+ String defaultPattern = ds.getDefaultModuleRestartPattern();
+ String pattern =
server.getAttribute(IDeployableServer.ORG_JBOSS_TOOLS_AS_RESTART_FILE_PATTERN,
defaultPattern);
+ customizePattern.setSelection(!defaultPattern.equals(pattern));
+ restartPatternText.setEnabled(!defaultPattern.equals(pattern));
+ restartPatternText.setText(pattern == null ? defaultPattern : pattern);
+ }
+
+ protected void createUI(Composite parent) {
+
+ FormToolkit toolkit = new FormToolkit(parent.getDisplay());
+ Section section = toolkit.createSection(parent,
ExpandableComposite.TWISTIE|ExpandableComposite.EXPANDED|ExpandableComposite.TITLE_BAR);
+ section.setText("Application Reload Behavior");
+ section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL |
GridData.VERTICAL_ALIGN_FILL));
+
+ Composite composite = toolkit.createComposite(section);
+ composite.setLayout(new FormLayout());
+
+ customizePattern = toolkit.createButton(composite, "Customize application reload
behavior on changes to project resources", SWT.CHECK);
+ customizePattern.setLayoutData(UIUtil.createFormData2(0, 5, null, 0, 0, 5, null, 0));
+ Label l = toolkit.createLabel(composite, "Force module restart on following regex
pattern: ");
+ l.setLayoutData(UIUtil.createFormData2(customizePattern, 5, null, 0, 0, 5, null, 0));
+ restartPatternText = toolkit.createText(composite, "");
+ restartPatternText.setLayoutData(UIUtil.createFormData2(l, 5, null, 0, 0, 5, 100,
-5));
+
+ toolkit.paintBordersFor(composite);
+ section.setClient(composite);
+ }
+
+ protected void addListeners() {
+ checkboxListener = new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ execute(new SetCustomizePatternCommand(server));
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ };
+ textListener = new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ execute(new SetCustomPatternCommand(server));
+ }
+ };
+
+ this.customizePattern.addSelectionListener(checkboxListener);
+ this.restartPatternText.addModifyListener(textListener);
+ }
+
+ public class SetCustomizePatternCommand extends ServerWorkingCopyPropertyButtonCommand
{
+ public SetCustomizePatternCommand(IServerWorkingCopy server) {
+ super(server, Messages.EditorChangeStartPollerCommandName,
+ customizePattern, customizePattern.getSelection(), null, checkboxListener);
+ }
+ public void execute() {
+ super.execute();
+ restartPatternText.setEnabled(customizePattern.getSelection());
+ }
+ public void undo() {
+ super.undo();
+ restartPatternText.setEnabled(customizePattern.getSelection());
+ }
+ }
+
+ public class SetCustomPatternCommand extends ServerWorkingCopyPropertyCommand {
+ public SetCustomPatternCommand(IServerWorkingCopy server) {
+ super(server, Messages.EditorChangeStopPollerCommandName,
+ restartPatternText, restartPatternText.getText(),
+ IDeployableServer.ORG_JBOSS_TOOLS_AS_RESTART_FILE_PATTERN,
+ textListener);
+ }
+ }
+}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerPasswordSection.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerPasswordSection.java 2012-02-08
16:55:29 UTC (rev 38515)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerPasswordSection.java 2012-02-08
17:46:07 UTC (rev 38516)
@@ -1,24 +1,13 @@
-/**
- * JBoss by Red Hat
- * Copyright 2006-2009, Red Hat Middleware, LLC, and individual contributors as
indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.ide.eclipse.as.ui.editor;
import org.eclipse.core.runtime.IProgressMonitor;
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerWorkingCopyPropertyButtonCommand.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerWorkingCopyPropertyButtonCommand.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerWorkingCopyPropertyButtonCommand.java 2012-02-08
17:46:07 UTC (rev 38516)
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.ui.editor;
+
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.eclipse.wst.server.ui.internal.command.ServerCommand;
+/**
+ * @since 2.3
+ */
+public class ServerWorkingCopyPropertyButtonCommand extends ServerCommand {
+ protected boolean oldVal;
+ protected boolean newVal;
+ protected String key;
+ protected Button button;
+ protected SelectionListener listener;
+ protected IServerWorkingCopy wc;
+
+ public ServerWorkingCopyPropertyButtonCommand(IServerWorkingCopy wc, String commandName,
+ Button button, boolean newVal, String attributeKey, SelectionListener listener) {
+ super(wc, commandName);
+ this.wc = wc;
+ this.button = button;
+ this.key = attributeKey;
+ this.newVal = newVal;
+ this.listener = listener;
+ if( key != null )
+ this.oldVal = wc.getAttribute(attributeKey, false);
+ }
+
+ public void execute() {
+ if( key != null )
+ wc.setAttribute(key, newVal);
+ }
+
+ public void undo() {
+ if( listener != null )
+ button.removeSelectionListener(listener);
+ if( key != null )
+ wc.setAttribute(key, oldVal);
+ if( button != null && !button.isDisposed())
+ button.setSelection(oldVal);
+ if( listener != null )
+ button.addSelectionListener(listener);
+ }
+}
\ No newline at end of file
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerWorkingCopyPropertyCommand.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerWorkingCopyPropertyCommand.java 2012-02-08
16:55:29 UTC (rev 38515)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerWorkingCopyPropertyCommand.java 2012-02-08
17:46:07 UTC (rev 38516)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.ide.eclipse.as.ui.editor;
import org.eclipse.swt.events.ModifyListener;
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2012-02-08 16:55:29 UTC (rev
38515)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2012-02-08 17:46:07 UTC (rev
38516)
@@ -165,6 +165,12 @@
-->
<section
+ class="org.jboss.ide.eclipse.as.ui.editor.ModuleRestartSection"
+ id="org.jboss.ide.eclipse.as.ui.editor.moduleRestartSection"
+ insertionId="org.eclipse.wst.server.editor.overview.right"
+ order="9"
+ typeIds="%AllJBossServerTypes"/>
+ <section
class="org.jboss.ide.eclipse.as.ui.editor.PollerSection"
id="org.jboss.ide.eclipse.as.ui.editor.pollerSection"
insertionId="org.eclipse.wst.server.editor.overview.right"